*** ./contrib/xml2/expected/xml2.out.orig 2010-02-28 22:31:57.000000000 +0100 --- ./contrib/xml2/expected/xml2.out 2010-08-06 18:46:41.000000000 +0200 *************** *** 145,147 **** --- 145,215 ---- Value'); create index idx_xpath on t1 ( xpath_string ('/attributes/attribute[@name="attr_1"]/text()', xml_data::text)); + SELECT xslt_process('cim30400'::text, $$ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $$::text, 'n1="v1",n2="v2",n3="v3",n4="v4",n5="v5",n6="v6",n7="v7",n8="v8",n9="v9",n10="v10",n11="v11",n12="v12"'::text); + xslt_process + ------------------------ + + + v1 + + v2 + + v3 + + v4 + + v5 + + v6 + + v7 + + v8 + + v9 + + v10+ + v11+ + v12+ + + + + (1 row) + *** ./contrib/xml2/sql/xml2.sql.orig 2010-08-06 18:30:00.000000000 +0200 --- ./contrib/xml2/sql/xml2.sql 2010-08-06 18:30:57.000000000 +0200 *************** *** 80,82 **** --- 80,132 ---- create index idx_xpath on t1 ( xpath_string ('/attributes/attribute[@name="attr_1"]/text()', xml_data::text)); + + SELECT xslt_process('cim30400'::text, $$ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $$::text, 'n1="v1",n2="v2",n3="v3",n4="v4",n5="v5",n6="v6",n7="v7",n8="v8",n9="v9",n10="v10",n11="v11",n12="v12"'::text); *** ./contrib/xml2/xslt_proc.c.orig 2010-07-06 21:18:55.000000000 +0200 --- ./contrib/xml2/xslt_proc.c 2010-08-06 18:39:02.000000000 +0200 *************** *** 41,49 **** extern void pgxml_parser_init(void); /* local defs */ ! static void parse_params(const char **params, text *paramstr); ! #define MAXPARAMS 20 /* must be even, see parse_params() */ #endif /* USE_LIBXSLT */ --- 41,50 ---- extern void pgxml_parser_init(void); /* local defs */ ! const char **parse_params(text *paramstr); ! #define INIT_PARAMS 20 /* must be even, see parse_params() */ ! #define EXTEND_PARAMS 20 /* must be even, see parse_params() */ #endif /* USE_LIBXSLT */ *************** *** 57,63 **** text *doct = PG_GETARG_TEXT_P(0); text *ssheet = PG_GETARG_TEXT_P(1); text *paramstr; ! const char *params[MAXPARAMS + 1]; /* +1 for the terminator */ xsltStylesheetPtr stylesheet = NULL; xmlDocPtr doctree; xmlDocPtr restree; --- 58,64 ---- text *doct = PG_GETARG_TEXT_P(0); text *ssheet = PG_GETARG_TEXT_P(1); text *paramstr; ! const char **params; xsltStylesheetPtr stylesheet = NULL; xmlDocPtr doctree; xmlDocPtr restree; *************** *** 69,79 **** if (fcinfo->nargs == 3) { paramstr = PG_GETARG_TEXT_P(2); ! parse_params(params, paramstr); } else /* No parameters */ params[0] = NULL; /* Setup parser */ pgxml_parser_init(); --- 70,83 ---- if (fcinfo->nargs == 3) { paramstr = PG_GETARG_TEXT_P(2); ! params = parse_params(paramstr); } else + { /* No parameters */ + params = palloc(sizeof(char *)); params[0] = NULL; + } /* Setup parser */ pgxml_parser_init(); *************** *** 139,160 **** #ifdef USE_LIBXSLT ! static void ! parse_params(const char **params, text *paramstr) { char *pos; char *pstr; - int i; char *nvsep = "="; char *itsep = ","; ! pstr = text_to_cstring(paramstr); pos = pstr; ! ! for (i = 0; i < MAXPARAMS; i++) { ! params[i] = pos; pos = strstr(pos, nvsep); if (pos != NULL) { --- 143,175 ---- #ifdef USE_LIBXSLT ! const char ** ! parse_params(text *paramstr) { char *pos; char *pstr; char *nvsep = "="; char *itsep = ","; ! const char **params; ! int nparams; ! int max_params; /* max params */ ! pstr = text_to_cstring(paramstr); + + max_params = INIT_PARAMS; + params = (const char **) palloc(INIT_PARAMS * sizeof(char *) + 1); pos = pstr; ! nparams = 0; ! while (*pos != '\0') { ! if (nparams >= max_params) ! { ! /* extend params params */ ! max_params += EXTEND_PARAMS; ! params = (const char **) repalloc(params, max_params * sizeof(char *) + 1); ! } ! params[nparams++] = pos; pos = strstr(pos, nvsep); if (pos != NULL) { *************** *** 165,176 **** { /* No equal sign, so ignore this "parameter" */ /* We'll reset params[i] to NULL below the loop */ break; } ! /* Value */ ! i++; /* since MAXPARAMS is even, we still have i < MAXPARAMS */ ! params[i] = pos; pos = strstr(pos, itsep); if (pos != NULL) { --- 180,191 ---- { /* No equal sign, so ignore this "parameter" */ /* We'll reset params[i] to NULL below the loop */ + nparams--; break; } ! /* since MAXPARAMS is even, we still have i < MAXPARAMS */ ! params[nparams++] = pos; pos = strstr(pos, itsep); if (pos != NULL) { *************** *** 178,190 **** pos++; } else - { - i++; break; - } } ! params[i] = NULL; } #endif /* USE_LIBXSLT */ --- 193,204 ---- pos++; } else break; } ! params[nparams] = NULL; ! ! return params; } #endif /* USE_LIBXSLT */