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

Commit86a0714

Browse files
committed
Tweak psql's \connect command to not downcase unquoted database and user
names. This is a temporary measure to allow backwards compatibility with7.2 and earlier pg_dump. 7.2.1 and later pg_dump will double-quote mixedcase names in \connect. Once we feel that older dumps are not a problemanymore, we can revert this change and treat \connect arguments as normalSQL identifiers.
1 parent7cfbbb2 commit86a0714

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

‎src/bin/psql/command.c

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright 2000 by PostgreSQL Global Development Group
55
*
6-
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.65 2002/02/20 22:47:12 tgl Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.66 2002/02/25 21:37:42 tgl Exp $
77
*/
88
#include"postgres_fe.h"
99
#include"command.h"
@@ -54,11 +54,17 @@ static backslashResult exec_command(const char *cmd,
5454
constchar**continue_parse,
5555
PQExpBufferquery_buf);
5656

57+
/* different ways for scan_option to handle parameter words */
5758
enumoption_type
5859
{
59-
OT_NORMAL,OT_SQLID,OT_FILEPIPE
60+
OT_NORMAL,/* normal case */
61+
OT_SQLID,/* treat as SQL identifier */
62+
OT_SQLIDHACK,/* SQL identifier, but don't downcase */
63+
OT_FILEPIPE/* it's a file or pipe */
6064
};
61-
staticchar*scan_option(char**string,enumoption_typetype,char*quote,boolsemicolon);
65+
66+
staticchar*scan_option(char**string,enumoption_typetype,
67+
char*quote,boolsemicolon);
6268
staticchar*unescape(constunsignedchar*source,size_tlen);
6369

6470
staticbooldo_edit(constchar*filename_arg,PQExpBufferquery_buf);
@@ -243,8 +249,17 @@ exec_command(const char *cmd,
243249
charopt1q,
244250
opt2q;
245251

246-
opt1=scan_option(&string,OT_SQLID,&opt1q, true);
247-
opt2=scan_option(&string,OT_SQLID,&opt2q, true);
252+
/*
253+
* Ideally we should treat the arguments as SQL identifiers. But for
254+
* backwards compatibility with 7.2 and older pg_dump files, we have
255+
* to take unquoted arguments verbatim (don't downcase them).
256+
* For now, double-quoted arguments may be stripped of double quotes
257+
* (as if SQL identifiers). By 7.4 or so, pg_dump files can be
258+
* expected to double-quote all mixed-case \connect arguments,
259+
* and then we can get rid of OT_SQLIDHACK.
260+
*/
261+
opt1=scan_option(&string,OT_SQLIDHACK,&opt1q, true);
262+
opt2=scan_option(&string,OT_SQLIDHACK,&opt2q, true);
248263

249264
if (opt2)
250265
/* gave username */
@@ -909,7 +924,7 @@ scan_option(char **string, enum option_type type, char *quote, bool semicolon)
909924
* then we strip out the double quotes
910925
*/
911926

912-
if (type==OT_SQLID)
927+
if (type==OT_SQLID||type==OT_SQLIDHACK)
913928
{
914929
unsignedintk,
915930
cc;
@@ -930,7 +945,6 @@ scan_option(char **string, enum option_type type, char *quote, bool semicolon)
930945
}
931946
return_val[cc]='\0';
932947
}
933-
934948
else
935949
{
936950
strncpy(return_val,&options_string[pos],jj-pos+1);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp