aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2006-10-07 22:21:38 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2006-10-07 22:21:38 +0000
commit06290309622e3330b58ad5e07b194032649496ae (patch)
tree1713f59a807ac4dba28ddc89fbc702ce47548420 /src
parent9ddbbe95fe4e32e86adc028800c848c74a132375 (diff)
downloadpostgresql-06290309622e3330b58ad5e07b194032649496ae.tar.gz
postgresql-06290309622e3330b58ad5e07b194032649496ae.zip
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 ...
Diffstat (limited to 'src')
-rw-r--r--src/bin/psql/describe.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 0adc99091d7..d83a6aa45ee 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -3,7 +3,7 @@
*
* 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 "describe.h"
@@ -1869,34 +1869,37 @@ processNamePattern(PQExpBuffer buf, const char *pattern,
while (*cp)
{
- if (*cp == '"')
+ char ch = *cp;
+
+ if (ch == '"')
{
if (inquotes && cp[1] == '"')
{
- /* emit one quote */
+ /* emit one quote, stay in inquotes mode */
appendPQExpBufferChar(&namebuf, '"');
cp++;
}
- inquotes = !inquotes;
+ else
+ inquotes = !inquotes;
cp++;
}
- else if (!inquotes && isupper((unsigned char) *cp))
+ else if (!inquotes && isupper((unsigned char) ch))
{
appendPQExpBufferChar(&namebuf,
- pg_tolower((unsigned char) *cp));
+ pg_tolower((unsigned char) ch));
cp++;
}
- else if (!inquotes && *cp == '*')
+ else if (!inquotes && ch == '*')
{
appendPQExpBuffer(&namebuf, ".*");
cp++;
}
- else if (!inquotes && *cp == '?')
+ else if (!inquotes && ch == '?')
{
appendPQExpBufferChar(&namebuf, '.');
cp++;
}
- else if (!inquotes && *cp == '.')
+ else if (!inquotes && ch == '.')
{
/* Found schema/name separator, move current pattern to schema */
resetPQExpBuffer(&schemabuf);
@@ -1917,7 +1920,7 @@ processNamePattern(PQExpBuffer buf, const char *pattern,
* that are more powerful than shell-style patterns.
*/
if ((inquotes || force_escape) &&
- strchr("|*+?()[]{}.^$\\", *cp))
+ strchr("|*+?()[]{}.^$\\", ch))
appendPQExpBufferChar(&namebuf, '\\');
i = PQmblen(cp, pset.encoding);
while (i-- && *cp)