Tue Mar 20 11:16:50 PDT 2007
- Previous message: [Slony1-commit] slony1-engine/src/backend slony1_funcs.sql
- Next message: [Slony1-commit] slony1-engine/tools/altperl old-apache-rotatelogs.patch slon-tools.pm
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Update of /home/cvsd/slony1/slony1-engine/src/backend In directory main.slony.info:/tmp/cvs-serv6438 Added Files: Tag: REL_1_1_STABLE slony1_base.v81.sql slony1_funcs.v81.sql Log Message: Add in base/funcs files for PG v8.1 --- NEW FILE: slony1_base.v81.sql --- -- ---------------------------------------------------------------------- -- slony1_base.v81.sql -- -- Version 8.1 specific parts of the basic replication schema. -- -- Copyright (c) 2003-2006, PostgreSQL Global Development Group -- Author: Jan Wieck, Afilias USA INC. -- -- $Id: slony1_base.v81.sql,v 1.1.4.1 2007-03-20 18:16:48 cbbrowne Exp $ -- ---------------------------------------------------------------------- --- NEW FILE: slony1_funcs.v81.sql --- -- ---------------------------------------------------------------------- -- slony1_funcs.v81.sql -- -- Version 8.1 specific part of the replication support functions. -- -- Copyright (c) 2003-2004, PostgreSQL Global Development Group -- Author: Jan Wieck, Afilias USA INC. -- -- $Id: slony1_funcs.v81.sql,v 1.1.4.1 2007-03-20 18:16:48 cbbrowne Exp $ -- ---------------------------------------------------------------------- -- ---------------------------------------------------------------------- -- FUNCTION prepareTableForCopy(tab_id) -- -- Remove all content from a table before the subscription -- content is loaded via COPY and disable index maintenance. -- ---------------------------------------------------------------------- create or replace function @NAMESPACE at .prepareTableForCopy(int4) returns int4 as ' declare p_tab_id alias for $1; v_tab_oid oid; v_tab_fqname text; begin -- ---- -- Get the OID and fully qualified name for the table -- --- select PGC.oid, @NAMESPACE at .slon_quote_brute(PGN.nspname) || ''.'' || @NAMESPACE at .slon_quote_brute(PGC.relname) as tab_fqname into v_tab_oid, v_tab_fqname from @NAMESPACE at .sl_table T, "pg_catalog".pg_class PGC, "pg_catalog".pg_namespace PGN where T.tab_id = p_tab_id and T.tab_reloid = PGC.oid and PGC.relnamespace = PGN.oid; if not found then raise exception ''Table with ID % not found in sl_table'', p_tab_id; end if; -- ---- -- Setting pg_class.relhasindex to false will cause copy not to -- maintain any indexes. At the end of the copy we will reenable -- them and reindex the table. This bulk creating of indexes is -- faster. -- ---- update pg_class set relhasindex = ''f'' where oid = v_tab_oid; -- ---- -- Try using truncate to empty the table and fallback to -- delete on error. -- ---- execute ''truncate '' || @NAMESPACE at .slon_quote_input(v_tab_fqname); raise notice ''truncate of % succeeded'', v_tab_fqname; return 1; exception when others then raise notice ''truncate of % failed - doing delete'', v_tab_fqname; update pg_class set relhasindex = ''f'' where oid = v_tab_oid; execute ''delete from only '' || @NAMESPACE at .slon_quote_input(v_tab_fqname); return 0; end; ' language plpgsql; comment on function @NAMESPACE at .prepareTableForCopy(int4) is 'Delete all data and suppress index maintenance'; -- ---------------------------------------------------------------------- -- FUNCTION finishTableAfterCopy(tab_id) -- -- Reenable index maintenance and reindex the table after COPY. -- ---------------------------------------------------------------------- create or replace function @NAMESPACE at .finishTableAfterCopy(int4) returns int4 as ' declare p_tab_id alias for $1; v_tab_oid oid; v_tab_fqname text; begin -- ---- -- Get the tables OID and fully qualified name -- --- select PGC.oid, @NAMESPACE at .slon_quote_brute(PGN.nspname) || ''.'' || @NAMESPACE at .slon_quote_brute(PGC.relname) as tab_fqname into v_tab_oid, v_tab_fqname from @NAMESPACE at .sl_table T, "pg_catalog".pg_class PGC, "pg_catalog".pg_namespace PGN where T.tab_id = p_tab_id and T.tab_reloid = PGC.oid and PGC.relnamespace = PGN.oid; if not found then raise exception ''Table with ID % not found in sl_table'', p_tab_id; end if; -- ---- -- Reenable indexes and reindex the table. -- ---- update pg_class set relhasindex = ''t'' where oid = v_tab_oid; execute ''reindex table '' || @NAMESPACE at .slon_quote_input(v_tab_fqname); return 1; end; ' language plpgsql; comment on function @NAMESPACE at .finishTableAfterCopy(int4) is 'Reenable index maintenance and reindex the table'; create or replace function @NAMESPACE at .pre74() returns integer as 'select 0' language sql; comment on function @NAMESPACE at .pre74() is 'Returns 1/0 based on whether or not the DB is running a version earlier than 7.4'; create or replace function @NAMESPACE at .make_function_strict (text, text) returns void as ' declare fun alias for $1; parms alias for $2; stmt text; begin stmt := ''ALTER FUNCTION "_ at CLUSTERNAME@".'' || fun || '' '' || parms || '' STRICT;''; execute stmt; return; end ' language plpgsql; comment on function @NAMESPACE at .make_function_strict (text, text) is 'Equivalent to 8.1+ ALTER FUNCTION ... STRICT';
- Previous message: [Slony1-commit] slony1-engine/src/backend slony1_funcs.sql
- Next message: [Slony1-commit] slony1-engine/tools/altperl old-apache-rotatelogs.patch slon-tools.pm
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Slony1-commit mailing list