xslt_process with more than ten parameters - patch
| От | Pavel Stehule |
|---|---|
| Тема | xslt_process with more than ten parameters - patch |
| Дата | |
| Msg-id | u2y162867791005030614ua6178260rd21e09460e20e49f@mail.gmail.com обсуждение исходный текст |
| Список | 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
Вложения
В списке pgsql-hackers по дате отправления: