Fix a bug that pg_reorg cannot parse index definitions with reserved named columns,

i.e, it failed to parse quoted column names. (bug #1010828)
This commit is contained in:
Takahiro Itagaki
2010-06-14 05:11:26 +00:00
parent 79757ccb62
commit 67a5d7b786
4 changed files with 24 additions and 63 deletions

View File

@ -360,7 +360,6 @@ skip_until(Oid index, char *sql, char end)
char instr = 0;
int nopen = 0;
sql++;
for (; *sql && (nopen > 0 || instr != 0 || *sql != end); sql++)
{
if (instr)
@ -491,29 +490,8 @@ reorg_get_index_keys(PG_FUNCTION_ARGS)
while (isspace((unsigned char) *token))
token++;
next = skip_until(index, next, ',');
opcname = token + strlen(token);
if (opcname[-1] == '"')
{
opcname--;
for (;;)
{
char *beg = strrchr(opcname, '"');
if (beg == NULL)
parse_error(index);
else if (beg[-1] != '"')
break;
else /* escaped quote ("") */
opcname = beg - 1;
}
}
else
{
while (opcname > token && IsToken(opcname[-1]))
opcname--;
}
if (opcname > token && *opcname)
opcname = skip_until(index, token, ' ');
if (opcname)
{
/* lookup default operator name from operator class */