Hello 2010/8/2 Mike Fowler <m...@mlfowler.com>: > Hi Pavel, > > Currently your patch isn't applying to head, from the looks of things a > function signature has changed. Can you update your patch please? >
yes - see attachment > Also, having had a read through the patch itself I note that there are no > tests and no changes to documentation. Shouldn't the documentation advertise > that the there are no limits on the numbers of parameters? A couple of tests > will also help me to test your patch, > the limit of 10 parameters was not documented. With this patch, there are not limit - or limit comes from libxml2. Test are a problem - for me - I don't understand to xslt too much - so I am not able to write xslt template with more than 10 params. I looked there and I the params are not tested now - so it is necessary to write a new set of regress tests. But I am not able to do it :(. > Below is the results of running patch: > > patch -p0 < ../nolimits.diff > patching file ./contrib/xml2/xslt_proc.c > Hunk #1 FAILED at 42. > Hunk #2 succeeded at 57 (offset -2 lines). > Hunk #3 succeeded at 69 (offset -2 lines). > Hunk #4 succeeded at 142 (offset -4 lines). > Hunk #5 succeeded at 179 (offset -4 lines). > Hunk #6 succeeded at 192 with fuzz 1 (offset -4 lines). > 1 out of 6 hunks FAILED -- saving rejects to file > ./contrib/xml2/xslt_proc.c.rej > > The rejects were: > > > *** ./contrib/xml2/xslt_proc.c.orig 2010-03-03 20:10:22.000000000 +0100 > --- ./contrib/xml2/xslt_proc.c 2010-05-03 15:07:17.010918303 +0200 > *************** > *** 42,50 **** > 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 */ > > --- 42,51 ---- > 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 */ > > > Regards, > -- > Mike Fowler > Registered Linux user: 379787 > Regards Pavel Stehule
*** ./contrib/xml2/xslt_proc.c.orig 2010-07-06 21:18:55.000000000 +0200 --- ./contrib/xml2/xslt_proc.c 2010-08-02 09:31:32.410911283 +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 mparams; /* max params */ ! pstr = text_to_cstring(paramstr); + + mparams = INIT_PARAMS; + params = (const char **) palloc(INIT_PARAMS * sizeof(char *) + 1); pos = pstr; ! nparams = 0; ! while (*pos != '\0') { ! if (nparams >= mparams) ! { ! /* extend params params */ ! mparams += EXTEND_PARAMS; ! params = (const char **) repalloc(params, mparams * 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 */
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers