From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | xslt_process with more than ten parameters - patch |
Date: | 2010-05-03 13:14:34 |
Message-ID: | u2y162867791005030614ua6178260rd21e09460e20e49f@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hello
One Czech pg user reported problems with function xslt_process. This
function is coded with ten parameters limit.
Attached patch add support to unlimited number of parameters.
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)
{
*pos = '\0';
pos++;
}
else
{
/* 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)
{
*pos = '\0';
pos++;
}
else
break;
}
params[nparams] = NULL;
return params;
}
Regards
Pavel Stehule
Attachment | Content-Type | Size |
---|---|---|
nolimit.diff | application/octet-stream | 3.7 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Aidan Van Dyk | 2010-05-03 14:03:24 | Re: missing file in git repo |
Previous Message | Andrew Dunstan | 2010-05-03 13:01:45 | Re: missing file in git repo |