mirror of
https://github.com/postgres/postgres.git
synced 2025-05-05 09:19:17 +03:00
Fix ancient oversight in psql's \d pattern processing code: when seeing two
quote chars inside quote marks, should emit one quote *and stay in inquotes mode*. No doubt the lack of reports of this have something to do with the poor documentation of the feature ...
This commit is contained in:
parent
9ddbbe95fe
commit
0629030962
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 2000-2006, PostgreSQL Global Development Group
|
* Copyright (c) 2000-2006, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.145 2006/10/04 00:30:05 momjian Exp $
|
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.146 2006/10/07 22:21:38 tgl Exp $
|
||||||
*/
|
*/
|
||||||
#include "postgres_fe.h"
|
#include "postgres_fe.h"
|
||||||
#include "describe.h"
|
#include "describe.h"
|
||||||
@ -1869,34 +1869,37 @@ processNamePattern(PQExpBuffer buf, const char *pattern,
|
|||||||
|
|
||||||
while (*cp)
|
while (*cp)
|
||||||
{
|
{
|
||||||
if (*cp == '"')
|
char ch = *cp;
|
||||||
|
|
||||||
|
if (ch == '"')
|
||||||
{
|
{
|
||||||
if (inquotes && cp[1] == '"')
|
if (inquotes && cp[1] == '"')
|
||||||
{
|
{
|
||||||
/* emit one quote */
|
/* emit one quote, stay in inquotes mode */
|
||||||
appendPQExpBufferChar(&namebuf, '"');
|
appendPQExpBufferChar(&namebuf, '"');
|
||||||
cp++;
|
cp++;
|
||||||
}
|
}
|
||||||
inquotes = !inquotes;
|
else
|
||||||
|
inquotes = !inquotes;
|
||||||
cp++;
|
cp++;
|
||||||
}
|
}
|
||||||
else if (!inquotes && isupper((unsigned char) *cp))
|
else if (!inquotes && isupper((unsigned char) ch))
|
||||||
{
|
{
|
||||||
appendPQExpBufferChar(&namebuf,
|
appendPQExpBufferChar(&namebuf,
|
||||||
pg_tolower((unsigned char) *cp));
|
pg_tolower((unsigned char) ch));
|
||||||
cp++;
|
cp++;
|
||||||
}
|
}
|
||||||
else if (!inquotes && *cp == '*')
|
else if (!inquotes && ch == '*')
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&namebuf, ".*");
|
appendPQExpBuffer(&namebuf, ".*");
|
||||||
cp++;
|
cp++;
|
||||||
}
|
}
|
||||||
else if (!inquotes && *cp == '?')
|
else if (!inquotes && ch == '?')
|
||||||
{
|
{
|
||||||
appendPQExpBufferChar(&namebuf, '.');
|
appendPQExpBufferChar(&namebuf, '.');
|
||||||
cp++;
|
cp++;
|
||||||
}
|
}
|
||||||
else if (!inquotes && *cp == '.')
|
else if (!inquotes && ch == '.')
|
||||||
{
|
{
|
||||||
/* Found schema/name separator, move current pattern to schema */
|
/* Found schema/name separator, move current pattern to schema */
|
||||||
resetPQExpBuffer(&schemabuf);
|
resetPQExpBuffer(&schemabuf);
|
||||||
@ -1917,7 +1920,7 @@ processNamePattern(PQExpBuffer buf, const char *pattern,
|
|||||||
* that are more powerful than shell-style patterns.
|
* that are more powerful than shell-style patterns.
|
||||||
*/
|
*/
|
||||||
if ((inquotes || force_escape) &&
|
if ((inquotes || force_escape) &&
|
||||||
strchr("|*+?()[]{}.^$\\", *cp))
|
strchr("|*+?()[]{}.^$\\", ch))
|
||||||
appendPQExpBufferChar(&namebuf, '\\');
|
appendPQExpBufferChar(&namebuf, '\\');
|
||||||
i = PQmblen(cp, pset.encoding);
|
i = PQmblen(cp, pset.encoding);
|
||||||
while (i-- && *cp)
|
while (i-- && *cp)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user