From ee5c88189de37d72a4c2f45953e8794b29c2c2f7 Mon Sep 17 00:00:00 2001 From: Steve Singer Date: Thu, 1 Aug 2013 16:03:48 -0400 Subject: [PATCH] Allow the apply trigger to work (ie not fail) on sl_log_script rows from earlier betas of 2.2.0 --- src/backend/slony1_funcs.c | 62 +++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/src/backend/slony1_funcs.c b/src/backend/slony1_funcs.c index cb783055..0051ea34 100644 --- a/src/backend/slony1_funcs.c +++ b/src/backend/slony1_funcs.c @@ -1013,44 +1013,44 @@ versionFunc(logApply)(PG_FUNCTION_ARGS) TEXTOID, -1, false, 'i', &cmdargs, &cmdargsnulls, &cmdargsn); - if( cmdargsn < 3 ) - { - elog(ERROR,"Slony-I: DDL_SCRIPT events require at least 3 elements"\ - "in the argument array"); - } - nodeargs=NULL; nodeargsn=0; - delim_text=DirectFunctionCall1(textin,CStringGetDatum(",")); - if ( (! cmdargsnulls[1]) ) - { - char * astr=DatumGetCString(DirectFunctionCall1(textout, - cmdargs[1])); - - if ( strcmp(astr,"")) - { - array_holder = DirectFunctionCall2(text_to_array,cmdargs[1], - delim_text); - deconstruct_array(DatumGetArrayTypeP(array_holder), - TEXTOID, -1, false, 'i', - &nodeargs, &nodeargsnulls, &nodeargsn); - } - } seqargs=NULL; seqargsn=0; - if ( (! cmdargsnulls[2]) ) + if( cmdargsn >= 2 ) { - char * astr=DatumGetCString(DirectFunctionCall1(textout, - cmdargs[2])); - if( strcmp(astr,"") ) - { - array_holder = DirectFunctionCall2(text_to_array,cmdargs[2], - delim_text); - deconstruct_array(DatumGetArrayTypeP(array_holder), - TEXTARRAYOID, -1, false, 'i', - &seqargs, &seqargsnulls, &seqargsn); + delim_text=DirectFunctionCall1(textin,CStringGetDatum(",")); + if ( (! cmdargsnulls[1]) ) + { + char * astr=DatumGetCString(DirectFunctionCall1(textout, + cmdargs[1])); + + if ( strcmp(astr,"")) + { + array_holder = DirectFunctionCall2(text_to_array,cmdargs[1], + delim_text); + deconstruct_array(DatumGetArrayTypeP(array_holder), + TEXTOID, -1, false, 'i', + &nodeargs, &nodeargsnulls, &nodeargsn); + } } } + if(cmdargsn >= 3) + { + if ( (! cmdargsnulls[2]) ) + { + char * astr=DatumGetCString(DirectFunctionCall1(textout, + cmdargs[2])); + if( strcmp(astr,"") ) + { + array_holder = DirectFunctionCall2(text_to_array,cmdargs[2], + delim_text); + deconstruct_array(DatumGetArrayTypeP(array_holder), + TEXTARRAYOID, -1, false, 'i', + &seqargs, &seqargsnulls, &seqargsn); + } + } + } /* * The first element is the DDL statement itself. */