Thu Nov 25 21:52:01 PST 2004
- Previous message: [Slony1-commit] By darcyb: supply missing arg to function comment, make function parse
- Next message: [Slony1-commit] By cbbrowne: Add in "generate_syncs.sh" script to use the new
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Log Message: ----------- Make cbbrowne's functions work as conceptualy intended Modified Files: -------------- slony1-engine/src/backend: slony1_funcs.sql (r1.45 -> r1.46) -------------- next part -------------- Index: slony1_funcs.sql =================================================================== RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/backend/slony1_funcs.sql,v retrieving revision 1.45 retrieving revision 1.46 diff -Lsrc/backend/slony1_funcs.sql -Lsrc/backend/slony1_funcs.sql -u -w -r1.45 -r1.46 --- src/backend/slony1_funcs.sql +++ src/backend/slony1_funcs.sql @@ -4708,23 +4708,12 @@ 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 .upgrade_sl_node () returns bool -as ' -DECLARE - v_row record; -BEGIN - if add_missing_table_field(@NAMESPACE@, ''sl_node'', ''no_spool'', ''boolean'') then - alter table @NAMESPACE at .sl_node - alter column no_spool set default = ''f''; - update @NAMESPACE at .sl_node set no_spool = ''f''; - return ''t''; - end if; - return ''t''; -END;' language plpgsql; - -comment on function @NAMESPACE at .upgrade_sl_node() is - 'Schema changes required to upgrade to version 1.1'; - +-- ---------------------------------------------------------------------- +-- FUNCTION add_missing_table_field(text, text, text, text) +-- +-- support function of only adding the fields to a table if they do not yet exist. +-- +-- ---------------------------------------------------------------------- create or replace function @NAMESPACE at .add_missing_table_field (text, text, text, text) returns bool as ' DECLARE @@ -4736,15 +4725,15 @@ v_query text; BEGIN select 1 into v_row from pg_namespace n, pg_class c, pg_attribute a - where n.nspname = p_namespace and - c.relname = n.oid and - c.relname = p_table and + where quote_ident(n.nspname) = p_namespace and + c.relnamespace = n.oid and + quote_ident(c.relname) = p_table and a.attrelid = c.oid and - a.attname = p_field; + quote_ident(a.attname) = p_field; if not found then raise notice ''Upgrade table %.% - add field %'', p_namespace, p_table, p_field; - v_query := ''alter table "'' || p_namespace || ''".'' || p_table || '' add column ''; - v_query := v_query || p_field || '' type '' || p_type || '';''; + v_query := ''alter table '' || p_namespace || ''.'' || p_table || '' add column ''; + v_query := v_query || p_field || '' '' || p_type || '';''; execute v_query; return ''t''; else @@ -4752,6 +4741,32 @@ end if; END;' language plpgsql; +comment on function @NAMESPACE at .add_missing_table_field(text,text,text,text) is + 'add_missing_table_field(namespace, table, field, type)'; + + +-- ---------------------------------------------------------------------- +-- FUNCTION upgrade_sl_node () +-- +-- adds the no_spool bool to sl_node +-- +-- ---------------------------------------------------------------------- +create or replace function @NAMESPACE at .upgrade_sl_node () returns bool +as ' +DECLARE + v_row record; + ret boolean; +BEGIN + select @NAMESPACE at .add_missing_table_field(''@NAMESPACE@'', ''sl_node'', ''no_spool'', ''boolean'') into ret; + return ret; + +END;' +language plpgsql; + +comment on function @NAMESPACE at .upgrade_sl_node() is + 'Schema changes required to upgrade to version 1.1'; + + -- ---------------------------------------------------------------------- -- VIEW sl_status --
- Previous message: [Slony1-commit] By darcyb: supply missing arg to function comment, make function parse
- Next message: [Slony1-commit] By cbbrowne: Add in "generate_syncs.sh" script to use the new
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Slony1-commit mailing list