diff --git a/src/backend/postgres/.cvsignore b/src/backend/postgres/.cvsignore index 787254170c..d85b3b92e7 100644 --- a/src/backend/postgres/.cvsignore +++ b/src/backend/postgres/.cvsignore @@ -12,3 +12,4 @@ kvp-autogen.c table-audit.c table-create.c table-drop.c +table-version.c diff --git a/src/backend/postgres/Makefile.am b/src/backend/postgres/Makefile.am index b55a08ce28..8aedb2ccca 100644 --- a/src/backend/postgres/Makefile.am +++ b/src/backend/postgres/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS=test +SUBDIRS = . test pkglib_LTLIBRARIES = libgncmod-backend-postgres.la libgncmod_backend_postgres_la_LDFLAGS =-module -lpq -L../../engine -L../../engine/.libs -lgncmod-engine ${GLIB_LIBS} @@ -45,6 +45,7 @@ EXTRA_DIST = \ table-audit.sql \ table-create.sql \ table-drop.sql \ + table-version.sql \ demo.c INCLUDES = -I.. -I../.. -I../../engine -I../../gnc-module @@ -53,8 +54,8 @@ CFLAGS = @CFLAGS@ ${GLIB_CFLAGS} # Some of the required C files are built with the m4 pre-processor # As a result, we need to manually specify dependencies, clean targets. -PostgresBackend.o: base-autogen.c table-audit.c table-create.c table-drop.c functions.c -PostgresBackend.lo: base-autogen.c table-audit.c table-create.c table-drop.c functions.c +PostgresBackend.o: base-autogen.c table-audit.c table-create.c table-version.c table-drop.c functions.c +PostgresBackend.lo: base-autogen.c table-audit.c table-create.c table-version.c table-drop.c functions.c checkpoint.o: check-autogen.c checkpoint.lo: check-autogen.c @@ -95,8 +96,13 @@ table-drop.c: table-drop.sql cat table-drop.sql >> table-drop.c echo \" >> table-drop.c +table-version.c: table-version.sql + echo \" > table-version.c + echo "-- DO NOT EDIT THIS FILE. IT IS AUTOGENERATED." >> table-version.c + cat table-version.sql >> table-version.c + echo \" >> table-version.c clean: -rm -f base-autogen.c check-autogen.c kvp-autogen.c - -rm -f table-drop.c table-create.c functions.c + -rm -f table-drop.c table-create.c table-version.c functions.c diff --git a/src/backend/postgres/PostgresBackend.c b/src/backend/postgres/PostgresBackend.c index 423535f9ee..6314d63ecd 100644 --- a/src/backend/postgres/PostgresBackend.c +++ b/src/backend/postgres/PostgresBackend.c @@ -215,6 +215,10 @@ static const char *table_create_str = #include "table-create.c" ; +static const char *table_version_str = +#include "table-version.c" +; + static const char *sql_functions_str = #include "functions.c" ; @@ -1647,6 +1651,8 @@ pgend_session_begin (Backend *backend, GNCBook *book, const char * sessionid, */ SEND_QUERY (be,table_create_str, ); FINISH_QUERY(be->connection); + SEND_QUERY (be,table_version_str, ); + FINISH_QUERY(be->connection); SEND_QUERY (be,table_audit_str, ); FINISH_QUERY(be->connection); SEND_QUERY (be,sql_functions_str, ); diff --git a/src/backend/postgres/table-create.sql b/src/backend/postgres/table-create.sql index 99180c8d9e..9c97f9ed00 100644 --- a/src/backend/postgres/table-create.sql +++ b/src/backend/postgres/table-create.sql @@ -29,8 +29,6 @@ CREATE TABLE gncVersion ( name TEXT UNIQUE NOT NULL CHECK (name <> ''), date DATETIME DEFAULT 'NOW' ); -INSERT INTO gncVersion (major,minor,rev,name) VALUES (1,0,0,'Version Table'); -INSERT INTO gncVersion (major,minor,rev,name) VALUES (1,1,1,'iGUID in Main Tables'); -- Commodity structure -- Store currency, security types. Namespace includes diff --git a/src/backend/postgres/table-version.sql b/src/backend/postgres/table-version.sql new file mode 100644 index 0000000000..ee3e2ab352 --- /dev/null +++ b/src/backend/postgres/table-version.sql @@ -0,0 +1,16 @@ +-- +-- FILE: +-- table-version.sql +-- +-- FUNCTION: +-- Insert the latest version information into the gncVersion table. +-- +-- Inserting in the same query as creating the table does not +-- work under Postgres 7.0 +-- +-- HISTORY: +-- Copyright (C) 2001 Linux Developers Group +-- + +INSERT INTO gncVersion (major,minor,rev,name) VALUES (1,0,0,'Version Table'); +INSERT INTO gncVersion (major,minor,rev,name) VALUES (1,1,1,'iGUID in Main Tables'); diff --git a/src/backend/postgres/test/Makefile.am b/src/backend/postgres/test/Makefile.am index 1c5450da2a..dc5ae2a99a 100644 --- a/src/backend/postgres/test/Makefile.am +++ b/src/backend/postgres/test/Makefile.am @@ -17,6 +17,7 @@ LDADD = -L${top_srcdir}/src/gnc-module -L${top_srcdir}/src/gnc-module/.libs \ ${top_srcdir}/src/gnc-module/libgncmodule.la \ ${top_srcdir}/src/engine/libgncmod-engine.la \ ${top_srcdir}/src/engine/test-core/libgncmod-test-engine.la \ + ${top_srcdir}/src/backend/postgres/libgncmod-backend-postgres.la \ -lltdl CFLAGS = ${GLIB_CFLAGS}