Wed Apr 18 08:03:53 PDT 2007
- Previous message: [Slony1-commit] slony1-engine/tests/test1 README init_add_tables.ik init_data.sql init_schema.sql schema.diff
- Next message: [Slony1-commit] slony1-engine/doc/adminguide addthings.sgml bestpractices.sgml defineset.sgml faq.sgml slonik_ref.sgml slonyupgrade.sgml
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Update of /home/cvsd/slony1/slony1-engine/src/backend In directory main.slony.info:/tmp/cvs-serv3274/src/backend Modified Files: slony1_base.sql slony1_funcs.c slony1_funcs.sql Log Message: Patch that removes TABLE ADD KEY from CVS HEAD. This supercedes the previous patch: http://lists.slony.info/pipermail/slony1-patches/2007-April/000008.html Per Bill Moran's comments, this also drops out usage of sl_rowid_seq. http://lists.slony.info/pipermail/slony1-general/2007-April/005883.html It passes test1, as revised in the patch (e.g. - to remove usage of TABLE ADD KEY)... ---------------------------------------------------- creating origin DB: cbbrowne -h localhost -U cbbrowne -p 5882 slonyregress1 add plpgsql to Origin loading origin DB with test1/init_schema.sql setting up user cbbrowne to have weak access to data done creating subscriber 2 DB: cbbrowne -h localhost -U cbbrowne -p 5882 slonyregress2 add plpgsql to subscriber loading subscriber 2 DB from slonyregress1 done creating cluster done storing nodes done Granting weak access on Slony-I schema done storing paths done launching originnode : /opt/OXRS/dbs/pgsql82/bin/slon -s500 -g10 -d2 slony_regress1 "dbname=slonyregress1 host=localhost user=cbbrowne port=5882" launching: /opt/OXRS/dbs/pgsql82/bin/slon -s500 -g10 -d2 slony_regress1 "dbname=slonyregress2 host=localhost user=cbbrowne port=5882" subscribing done generating 468 transactions of random data 0 % 5 % 10 % 15 % 20 % 25 % 30 % 35 % 40 % 45 % 50 % 55 % 60 % 65 % 70 % 75 % 80 % 85 % 90 % 95 % 100 % done launching polling script loading data data load complete completed generate_sync_event() test completed make_function_strict() test done slony is caught up getting data from origin DB for diffing done getting data from node 2 for diffing against origin comparing subscriber node 2 is the same as origin node 1 done **** killing slon node 1 **** killing slon node 2 waiting for slons to die done dropping database slonyregress1 slonyregress2 done *************************** test test1 completed successfully *************************** Index: slony1_funcs.c =================================================================== RCS file: /home/cvsd/slony1/slony1-engine/src/backend/slony1_funcs.c,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** slony1_funcs.c 16 Jan 2007 21:40:19 -0000 1.57 --- slony1_funcs.c 18 Apr 2007 15:03:51 -0000 1.58 *************** *** 41,44 **** --- 41,49 ---- #endif + /* -- Change from PostgreSQL Ver 8.3 -- */ + #ifndef VARATT_SIZEP + #define VARATT_SIZEP VARATT_SIZEP_DEPRECATED + #endif + PG_FUNCTION_INFO_V1(_Slony_I_createEvent); PG_FUNCTION_INFO_V1(_Slony_I_getLocalNodeId); *************** *** 1394,1411 **** */ sprintf(query, ! "insert into %s.sl_seqlog " ! "(seql_seqid, seql_origin, seql_ev_seqno, seql_last_value) " ! "select seq_id, '%d', currval('%s.sl_event_seq'), seq_last_value " ! "from %s.sl_seqlastvalue " ! "where seq_origin = '%d'; " ! "insert into %s.sl_seqlog " ! "(seql_seqid, seql_origin, seql_ev_seqno, seql_last_value) " ! "select '0', '%d', currval('%s.sl_event_seq'), " ! " last_value from %s.sl_rowid_seq; ", ! cs->clusterident, ! cs->localNodeId, cs->clusterident, ! cs->clusterident, cs->localNodeId, ! cs->clusterident, cs->localNodeId, ! cs->clusterident, cs->clusterident); cs->plan_record_sequences = SPI_saveplan(SPI_prepare(query, 0, NULL)); --- 1399,1415 ---- */ sprintf(query, ! "insert into %s.sl_seqlog " ! "(seql_seqid, seql_origin, seql_ev_seqno, seql_last_value) " ! "select seq_id, '%d', currval('%s.sl_event_seq'), seq_last_value " ! "from %s.sl_seqlastvalue " ! "where seq_origin = '%d'; " ! "insert into %s.sl_seqlog " ! "(seql_seqid, seql_origin, seql_ev_seqno) " ! "select '0', '%d', currval('%s.sl_event_seq'); ", ! cs->clusterident, ! cs->localNodeId, cs->clusterident, ! cs->clusterident, cs->localNodeId, ! cs->clusterident, cs->localNodeId, ! cs->clusterident); cs->plan_record_sequences = SPI_saveplan(SPI_prepare(query, 0, NULL)); Index: slony1_base.sql =================================================================== RCS file: /home/cvsd/slony1/slony1-engine/src/backend/slony1_base.sql,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** slony1_base.sql 18 Jul 2006 17:59:59 -0000 1.32 --- slony1_base.sql 18 Apr 2007 15:03:51 -0000 1.33 *************** *** 513,527 **** - -- ---------------------------------------------------------------------- - -- SEQUENCE sl_rowid_seq - -- - -- Application tables that do not have a natural primary key must - -- be modified and an int8 column added that serves as a rowid for us. - -- The values are assigned with a default from this sequence. - -- ---------------------------------------------------------------------- - create sequence @NAMESPACE at .sl_rowid_seq; - grant select, update on @NAMESPACE at .sl_rowid_seq to public; - comment on sequence @NAMESPACE at .sl_rowid_seq is 'Application tables that do not have a natural primary key must be modified and an int8 column added that serves as a rowid for us. The values are assigned with a default from this sequence.'; - -- ---------------------------------------------------------------------- --- 513,516 ---- Index: slony1_funcs.sql =================================================================== RCS file: /home/cvsd/slony1/slony1-engine/src/backend/slony1_funcs.sql,v retrieving revision 1.106 retrieving revision 1.107 diff -C2 -d -r1.106 -r1.107 *** slony1_funcs.sql 16 Mar 2007 14:43:29 -0000 1.106 --- slony1_funcs.sql 18 Apr 2007 15:03:51 -0000 1.107 *************** *** 719,724 **** -- ---- perform setval(''@NAMESPACE at .sl_local_node_id'', p_local_node_id); - perform setval(''@NAMESPACE at .sl_rowid_seq'', - p_local_node_id::int8 * ''1000000000000000''::int8); perform @NAMESPACE at .storeNode_int (p_local_node_id, p_comment, false); --- 719,722 ---- *************** *** 4649,4790 **** SYNC. '; - -- ---------------------------------------------------------------------- - -- FUNCTION tableAddKey (tab_fqname) - -- - -- If the specified table does not have a column - -- "_Slony-I_<clustername>_rowID", then add it as a bigint - -- with default nextval('"_<clustername>".sl_rowid_seq'). - -- ---------------------------------------------------------------------- - create or replace function @NAMESPACE at .tableAddKey(text) returns text - as ' - declare - p_tab_fqname alias for $1; - v_tab_fqname_quoted text default ''''; - v_attkind text default ''''; - v_attrow record; - v_have_serial bool default ''f''; - begin - v_tab_fqname_quoted := @NAMESPACE at .slon_quote_input(p_tab_fqname); - -- - -- Loop over the attributes of this relation - -- and add a "v" for every user column, and a "k" - -- if we find the Slony-I special serial column. - -- - for v_attrow in select PGA.attnum, PGA.attname - from "pg_catalog".pg_class PGC, - "pg_catalog".pg_namespace PGN, - "pg_catalog".pg_attribute PGA - where @NAMESPACE at .slon_quote_brute(PGN.nspname) || ''.'' || - @NAMESPACE at .slon_quote_brute(PGC.relname) = v_tab_fqname_quoted - and PGN.oid = PGC.relnamespace - and PGA.attrelid = PGC.oid - and not PGA.attisdropped - and PGA.attnum > 0 - order by attnum - loop - if v_attrow.attname = ''_Slony-I_ at CLUSTERNAME@_rowID'' then - v_attkind := v_attkind || ''k''; - v_have_serial := ''t''; - else - v_attkind := v_attkind || ''v''; - end if; - end loop; - - -- - -- A table must have at least one attribute, so not finding - -- anything means the table does not exist. - -- - if not found then - raise exception ''Slony-I: tableAddKey(): table % not found'', v_tab_fqname_quoted; - end if; - - -- - -- If it does not have the special serial column, we - -- have to add it. This will be only half way done. - -- The function to add the table to the set must finish - -- these definitions with NOT NULL and UNIQUE after - -- updating all existing rows. - -- - if not v_have_serial then - execute ''lock table '' || v_tab_fqname_quoted || - '' in access exclusive mode''; - execute ''alter table only '' || v_tab_fqname_quoted || - '' add column "_Slony-I_ at CLUSTERNAME@_rowID" bigint;''; - execute ''alter table only '' || v_tab_fqname_quoted || - '' alter column "_Slony-I_ at CLUSTERNAME@_rowID" '' || - '' set default "pg_catalog".nextval(''''@NAMESPACE at .sl_rowid_seq'''');''; - - v_attkind := v_attkind || ''k''; - end if; - - -- - -- Return the resulting Slony-I attkind - -- - return v_attkind; - end; - ' language plpgsql; - - comment on function @NAMESPACE at .tableAddKey(text) is - - 'tableAddKey (tab_fqname) - if the table has not got a column of the - form _Slony-I_<clustername>_rowID, then add it as a bigint, defaulted - to nextval() for a sequence created for the cluster.'; - - -- ---------------------------------------------------------------------- - -- FUNCTION tableDropKey (tab_id) - -- - -- If the specified table has a column - -- "_Slony-I_<clustername>_rowID", then drop it. - -- ---------------------------------------------------------------------- - create or replace function @NAMESPACE at .tableDropKey(int4) returns int4 - as ' - declare - p_tab_id alias for $1; - v_tab_fqname text; - v_tab_oid oid; - begin - -- ---- - -- Grab the central configuration lock - -- ---- - lock table @NAMESPACE at .sl_config_lock; - - -- ---- - -- Construct the tables fully qualified name and get its oid - -- ---- - select @NAMESPACE at .slon_quote_brute(PGN.nspname) || ''.'' || - @NAMESPACE at .slon_quote_brute(PGC.relname), - PGC.oid into v_tab_fqname, v_tab_oid - 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 ''Slony-I: tableDropKey(): table with ID % not found'', p_tab_id; - end if; - - -- ---- - -- Drop the special serial ID column if the table has it - -- ---- - if exists (select true from "pg_catalog".pg_attribute - where attrelid = v_tab_oid - and attname = ''_Slony-I_ at CLUSTERNAME@_rowID'') - then - execute ''lock table '' || v_tab_fqname || - '' in access exclusive mode''; - execute ''alter table '' || v_tab_fqname || - '' drop column "_Slony-I_ at CLUSTERNAME@_rowID"''; - end if; - - return p_tab_id; - end; - ' language plpgsql; - - comment on function @NAMESPACE at .tableDropKey(int4) is - 'tableDropKey (tab_id) - - If the specified table has a column "_Slony-I_<clustername>_rowID", - then drop it.'; -- ---------------------------------------------------------------------- --- 4647,4650 ---- *************** *** 5022,5109 **** primary key (if indexname is NULL).'; - -- ---------------------------------------------------------------------- - -- FUNCTION determineAttKindSerial (tab_fqname) - -- - -- A table was that was specified without a primary key is added - -- to the replication. Assume that tableAddKey() was called before - -- and finish the creation of the serial column. The return an - -- attkind according to that. - -- ---------------------------------------------------------------------- - create or replace function @NAMESPACE at .determineAttkindSerial(text) - returns text - as ' - declare - p_tab_fqname alias for $1; - v_tab_fqname_quoted text default ''''; - v_attkind text default ''''; - v_attrow record; - v_have_serial bool default ''f''; - begin - v_tab_fqname_quoted := @NAMESPACE at .slon_quote_input(p_tab_fqname); - -- - -- Loop over the attributes of this relation - -- and add a "v" for every user column, and a "k" - -- if we find the Slony-I special serial column. - -- - for v_attrow in select PGA.attnum, PGA.attname - from "pg_catalog".pg_class PGC, - "pg_catalog".pg_namespace PGN, - "pg_catalog".pg_attribute PGA - where @NAMESPACE at .slon_quote_brute(PGN.nspname) || ''.'' || - @NAMESPACE at .slon_quote_brute(PGC.relname) = v_tab_fqname_quoted - and PGN.oid = PGC.relnamespace - and PGA.attrelid = PGC.oid - and not PGA.attisdropped - and PGA.attnum > 0 - order by attnum - loop - if v_attrow.attname = ''_Slony-I_ at CLUSTERNAME@_rowID'' then - v_attkind := v_attkind || ''k''; - v_have_serial := ''t''; - else - v_attkind := v_attkind || ''v''; - end if; - end loop; - - -- - -- A table must have at least one attribute, so not finding - -- anything means the table does not exist. - -- - if not found then - raise exception ''Slony-I: table % not found'', v_tab_fqname_quoted; - end if; - - -- - -- If it does not have the special serial column, we - -- should not have been called in the first place. - -- - if not v_have_serial then - raise exception ''Slony-I: table % does not have the serial key'', - v_tab_fqname_quoted; - end if; - - execute ''update '' || v_tab_fqname_quoted || - '' set "_Slony-I_ at CLUSTERNAME@_rowID" ='' || - '' "pg_catalog".nextval(''''@NAMESPACE at .sl_rowid_seq'''');''; - execute ''alter table only '' || v_tab_fqname_quoted || - '' add unique ("_Slony-I_ at CLUSTERNAME@_rowID");''; - execute ''alter table only '' || v_tab_fqname_quoted || - '' alter column "_Slony-I_ at CLUSTERNAME@_rowID" '' || - '' set not null;''; - - -- - -- Return the resulting Slony-I attkind - -- - return v_attkind; - end; - ' language plpgsql; - - comment on function @NAMESPACE at .determineAttkindSerial(text) is - 'determineAttKindSerial (tab_fqname) - - A table was that was specified without a primary key is added to the - replication. Assume that tableAddKey() was called before and finish - the creation of the serial column. The return an attkind according to - that.'; -- ---------------------------------------------------------------------- --- 4882,4885 ---- *************** *** 5237,5275 **** -- ---------------------------------------------------------------------- - -- FUNCTION tableHasSerialKey (tab_fqname) - -- - -- Checks if a table has our special serial key column that is - -- used if the table has no natural unique constraint. - -- ---------------------------------------------------------------------- - create or replace function @NAMESPACE at .tableHasSerialKey(text) - returns bool - as ' - declare - p_tab_fqname alias for $1; - v_tab_fqname_quoted text default ''''; - v_attnum int2; - begin - v_tab_fqname_quoted := @NAMESPACE at .slon_quote_input(p_tab_fqname); - select PGA.attnum into v_attnum - from "pg_catalog".pg_class PGC, - "pg_catalog".pg_namespace PGN, - "pg_catalog".pg_attribute PGA - where @NAMESPACE at .slon_quote_brute(PGN.nspname) || ''.'' || - @NAMESPACE at .slon_quote_brute(PGC.relname) = v_tab_fqname_quoted - and PGC.relnamespace = PGN.oid - and PGA.attrelid = PGC.oid - and PGA.attname = ''_Slony-I_ at CLUSTERNAME@_rowID'' - and not PGA.attisdropped; - return found; - end; - ' language plpgsql; - - comment on function @NAMESPACE at .tableHasSerialKey(text) is - 'tableHasSerialKey (tab_fqname) - - Checks if a table has our special serial key column that is used if - the table has no natural unique constraint.'; - - -- ---------------------------------------------------------------------- -- FUNCTION updateRelname (set_id, only_on_node) -- --- 5013,5016 ---- *************** *** 5809,5813 **** -- Changes for 1.2 -- ---- ! if p_old IN (''1.0.2'', ''1.0.5'', ''1.0.6'', ''1.1.0'', ''1.1.1'', ''1.1.2'', ''1.1.3'', ''1.1.5'', ''1.1.6'', "1.1.7", "1.1.8") then -- Add new table sl_registry execute ''create table @NAMESPACE at .sl_registry ( --- 5550,5554 ---- -- Changes for 1.2 -- ---- ! if p_old IN (''1.0.2'', ''1.0.5'', ''1.0.6'', ''1.1.0'', ''1.1.1'', ''1.1.2'', ''1.1.3'', ''1.1.5'', ''1.1.6'', ''1.1.7'', ''1.1.8'', ''1.1.9'') then -- Add new table sl_registry execute ''create table @NAMESPACE at .sl_registry (
- Previous message: [Slony1-commit] slony1-engine/tests/test1 README init_add_tables.ik init_data.sql init_schema.sql schema.diff
- Next message: [Slony1-commit] slony1-engine/doc/adminguide addthings.sgml bestpractices.sgml defineset.sgml faq.sgml slonik_ref.sgml slonyupgrade.sgml
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Slony1-commit mailing list