8000 Fix ancient oversight in psql's \d pattern processing code: when seei… · postgrespro/postgres_cluster@0629030 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0629030

Browse files
committed
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 ...
1 parent 9ddbbe9 commit 0629030

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/bin/psql/describe.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2006, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.145 2006/10/04 00:30:05 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.146 2006/10/07 22:21:38 tgl Exp $
77
*/
88
#include "postgres_fe.h"
99
#include "describe.h"
@@ -1869,34 +1869,37 @@ processNamePattern(PQExpBuffer buf, const char *pattern,
18691869

18701870
while (*cp)
18711871
{
1872-
if (*cp == '"')
1872+
char ch = *cp;
1873+
1874+
if (ch == '"')
18731875
{
18741876
if (inquotes && cp[1] == '"')
18751877
{
1876-
/* emit one quote */
1878+
/* emit one quote, stay in inquotes mode */
18771879
appendPQExpBufferChar(&namebuf, '"');
18781880
cp++;
18791881
}
1880-
inquotes = !inquotes;
1882+
else
1883+
inquotes = !inquotes;
18811884
cp++;
18821885
}
1883-
else if (!inquotes && isupper((unsigned char) *cp))
1886+
else if (!inquotes && isupper((unsigned char) ch))
18841887
{
18851888
appendPQExpBufferChar(&namebuf,
1886-
pg_tolower((unsigned char) *cp));
1889+
pg_tolower((unsigned char) ch));
18871890
cp++;
18881891
}
1889-
else if (!inquotes && *cp == '*')
1892+
else if (!inquotes && ch == '*')
18901893
{
18911894
appendPQExpBuffer(&namebuf, ".*");
18921895
cp++;
18931896
}
1894-
else if (!inquotes && *cp == '?')
1897+
else if (!inquotes && ch == '?')
18951898
{
18961899
appendPQExpBufferChar(&namebuf, '.');
18971900
cp++;
18981901
}
1899-
else if (!inquotes && *cp == '.')
1902+
else if (!inquotes && ch == '.')
19001903
{
19011904
/* Found schema/name separator, move current pattern to schema */
19021905
resetPQExpBuffer(&schemabuf);
@@ -1917,7 +1920,7 @@ processNamePattern(PQExpBuffer buf, const char *pattern,
19171920
* that are more powerful than shell-style patterns.
19181921
*/
19191922
if ((inquotes || force_escape) &&
1920-
strchr("|*+?()[]{}.^$\\", *cp))
1923+
strchr("|*+?()[]{}.^$\\", ch))
19211924
appendPQExpBufferChar(&namebuf, '\\');
19221925 3FA1
i = PQmblen(cp, pset.encoding);
19231926
while (i-- && *cp)

0 commit comments

Comments
 (0)
0