Wed Sep 29 15:48:37 PDT 2004
- Previous message: [Slony1-commit] By wieck: Use TRUNCATE before subscription COPY on Postgres 7.4 and
- Next message: [Slony1-commit] By cbbrowne: This script always reported that it was subscribing set 1.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Log Message: ----------- Use TRUNCATE before subscription COPY on Postgres 7.4 and newer. Jan Modified Files: -------------- slony1-engine/src/backend: slony1_funcs.v73.sql (r1.4 -> r1.5) slony1_funcs.v74.sql (r1.2 -> r1.3) slony1-engine/src/slon: remote_worker.c (r1.62 -> r1.63) -------------- next part -------------- Index: slony1_funcs.v74.sql =================================================================== RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/backend/slony1_funcs.v74.sql,v retrieving revision 1.2 retrieving revision 1.3 diff -Lsrc/backend/slony1_funcs.v74.sql -Lsrc/backend/slony1_funcs.v74.sql -u -w -r1.2 -r1.3 --- src/backend/slony1_funcs.v74.sql +++ src/backend/slony1_funcs.v74.sql @@ -9,4 +9,20 @@ -- $Id$ -- ---------------------------------------------------------------------- +-- ---------------------------------------------------------------------- +-- FUNCTION truncateTable(tab_fqname) +-- +-- Remove all content from a table before the subscription +-- content is loaded via COPY. +-- ---------------------------------------------------------------------- +create or replace function @NAMESPACE at .truncateTable(text) +returns int4 +as ' +declare + p_tab_fqname alias for $1; +begin + execute ''truncate '' || p_tab_fqname; + return 1; +end; +' language plpgsql; Index: slony1_funcs.v73.sql =================================================================== RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/backend/slony1_funcs.v73.sql,v retrieving revision 1.4 retrieving revision 1.5 diff -Lsrc/backend/slony1_funcs.v73.sql -Lsrc/backend/slony1_funcs.v73.sql -u -w -r1.4 -r1.5 --- src/backend/slony1_funcs.v73.sql +++ src/backend/slony1_funcs.v73.sql @@ -9,4 +9,20 @@ -- $Id$ -- ---------------------------------------------------------------------- +-- ---------------------------------------------------------------------- +-- FUNCTION truncateTable(tab_fqname) +-- +-- Remove all content from a table before the subscription +-- content is loaded via COPY. +-- ---------------------------------------------------------------------- +create or replace function @NAMESPACE at .truncateTable(text) +returns int4 +as ' +declare + p_tab_fqname alias for $1; +begin + execute ''delete from only '' || p_tab_fqname; + return 1; +end; +' language plpgsql; Index: remote_worker.c =================================================================== RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/slon/remote_worker.c,v retrieving revision 1.62 retrieving revision 1.63 diff -Lsrc/slon/remote_worker.c -Lsrc/slon/remote_worker.c -u -w -r1.62 -r1.63 --- src/slon/remote_worker.c +++ src/slon/remote_worker.c @@ -2164,12 +2164,12 @@ /* * Begin a COPY from stdin for the table on the local DB - * TODO: use the transaction safe truncate table on 7.4 or - * better instead of delete. */ slon_mkquery(&query1, - "delete from only %s; " - "copy %s from stdin; ", tab_fqname, tab_fqname); + "select %s.truncateTable('%s'); " + "copy %s from stdin; ", + rtcfg_namespace, + tab_fqname, tab_fqname); res2 = PQexec(loc_dbconn, dstring_data(&query1)); if (PQresultStatus(res2) != PGRES_COPY_IN) {
- Previous message: [Slony1-commit] By wieck: Use TRUNCATE before subscription COPY on Postgres 7.4 and
- Next message: [Slony1-commit] By cbbrowne: This script always reported that it was subscribing set 1.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Slony1-commit mailing list