From 038c4114b555cc5a0560a5ddef6c86bf9ffc7679 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 7 Oct 2006 22:21:50 +0000 Subject: [PATCH] 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 ... --- src/bin/psql/describe.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 266d321653..37b3e00ea5 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -1815,34 +1815,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); -- 2.39.5