Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0629030

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 inquotesmode*. No doubt the lack of reports of this have something to do with thepoor documentation of the feature ...
1 parent9ddbbe9 commit0629030

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+
charch=*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-
elseif (!inquotes&&isupper((unsignedchar)*cp))
1886+
elseif (!inquotes&&isupper((unsignedchar)ch))
18841887
{
18851888
appendPQExpBufferChar(&namebuf,
1886-
pg_tolower((unsignedchar)*cp));
1889+
pg_tolower((unsignedchar)ch));
18871890
cp++;
18881891
}
1889-
elseif (!inquotes&&*cp=='*')
1892+
elseif (!inquotes&&ch=='*')
18901893
{
18911894
appendPQExpBuffer(&namebuf,".*");
18921895
cp++;
18931896
}
1894-
elseif (!inquotes&&*cp=='?')
1897+
elseif (!inquotes&&ch=='?')
18951898
{
18961899
appendPQExpBufferChar(&namebuf,'.');
18971900
cp++;
18981901
}
1899-
elseif (!inquotes&&*cp=='.')
1902+
elseif (!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
i=PQmblen(cp,pset.encoding);
19231926
while (i--&&*cp)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp