From: Tom Lane Date: Sat, 7 Oct 2006 22:21:50 +0000 (+0000) Subject: Fix ancient oversight in psql's \d pattern processing code: when seeing two X-Git-Tag: REL8_0_9~10 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=536174382695ddea59482b4210a3dacfabd39bb9;p=thirdparty%2Fpostgresql.git 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 ... --- diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 8bf21bcc7ca..03df20b95e9 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.111 2005/01/01 05:43:08 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.111.4.1 2006/10/07 22:21:50 tgl Exp $ */ #include "postgres_fe.h" #include "describe.h" @@ -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);