Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 2f86ab7

Browse files
author
Michael Meskes
committed
*** empty log message ***
1 parent 79bb263 commit 2f86ab7

File tree

5 files changed

+53
-41
lines changed

5 files changed

+53
-41
lines changed

src/interfaces/ecpg/ChangeLog

+7
Original file line numberDiff line numberDiff line change
@@ -2272,6 +2272,13 @@ Tue, 06 Nov 2007 09:29:22 +0100
22722272
Fri, 21 Dec 2007 15:30:39 +0100
22732273

22742274
- Fixed a few minor glitches pointed out by splint.
2275+
2276+
Fri, 28 Dec 2007 12:15:38 +0100
2277+
2278+
- Applied patch send by ITAGAKI Takahiro
2279+
<itagaki.takahiro@oss.ntt.co.jp> to fix bug in connect statement if
2280+
user name is a variable.
2281+
- Also fixed test case that didn't detect this.
22752282
- Set pgtypes library version to 3.0.
22762283
- Set compat library version to 3.0.
22772284
- Set ecpg library version to 6.0.

src/interfaces/ecpg/preproc/preproc.y

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.356 2007/12/21 14:33:20 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.357 2007/12/28 11:25:21 meskes Exp $ */
22

33
/* Copyright comment */
44
%{
@@ -5114,7 +5114,7 @@ user_name: RoleId
51145114
{
51155115
if ($1[0] == '\"')
51165116
$$ = $1;
5117-
else if (strcmp($1, " ?") == 0) /* variable */
5117+
else if ($1[1] == '$') /* variable */
51185118
{
51195119
enum ECPGttype type = argsinsert->variable->type->type;
51205120

src/interfaces/ecpg/test/connect/test5.pgc

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ main(void)
1515
exec sql begin declare section;
1616
char db[200];
1717
char id[200];
18+
char *user="connectuser";
1819
exec sql end declare section;
1920

2021
ECPGdebug(1, stderr);
@@ -49,7 +50,7 @@ exec sql end declare section;
4950
exec sql connect to "unix:postgresql://localhost/connectdb" as main user connectuser;
5051
exec sql disconnect main;
5152

52-
exec sql connect to 'unix:postgresql://localhost/connectdb' as main user connectuser;
53+
exec sql connect to 'unix:postgresql://localhost/connectdb' as main user :user;
5354
exec sql disconnect main;
5455

5556
exec sql connect to "unix:postgresql://200.46.204.71/connectdb" as main user connectuser;

src/interfaces/ecpg/test/expected/connect-test5.c

+35-31
Original file line numberDiff line numberDiff line change
@@ -25,121 +25,125 @@ main(void)
2525
/* exec sql begin declare section */
2626

2727

28+
2829

2930
#line 16 "test5.pgc"
3031
char db [ 200 ] ;
3132

3233
#line 17 "test5.pgc"
3334
char id [ 200 ] ;
34-
/* exec sql end declare section */
35+
3536
#line 18 "test5.pgc"
37+
char * user = "connectuser" ;
38+
/* exec sql end declare section */
39+
#line 19 "test5.pgc"
3640

3741

3842
ECPGdebug(1, stderr);
3943

4044
{ ECPGconnect(__LINE__, 0, "connectdb" , NULL, NULL , "main", 0); }
41-
#line 22 "test5.pgc"
45+
#line 23 "test5.pgc"
4246

4347
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "alter user connectuser encrypted password 'connectpw'", ECPGt_EOIT, ECPGt_EORT);}
44-
#line 23 "test5.pgc"
48+
#line 24 "test5.pgc"
4549

4650
{ ECPGdisconnect(__LINE__, "CURRENT");}
47-
#line 24 "test5.pgc"
51+
#line 25 "test5.pgc"
4852
/* <-- "main" not specified */
4953

5054
strcpy(db, "connectdb");
5155
strcpy(id, "main");
5256
{ ECPGconnect(__LINE__, 0, db , NULL, NULL , id, 0); }
53-
#line 28 "test5.pgc"
57+
#line 29 "test5.pgc"
5458

5559
{ ECPGdisconnect(__LINE__, id);}
56-
#line 29 "test5.pgc"
60+
#line 30 "test5.pgc"
5761

5862

5963
{ ECPGconnect(__LINE__, 0, "connectdb" , NULL, NULL , "main", 0); }
60-
#line 31 "test5.pgc"
64+
#line 32 "test5.pgc"
6165

6266
{ ECPGdisconnect(__LINE__, "main");}
63-
#line 32 "test5.pgc"
67+
#line 33 "test5.pgc"
6468

6569

6670
{ ECPGconnect(__LINE__, 0, "connectdb" , NULL, NULL , "main", 0); }
67-
#line 34 "test5.pgc"
71+
#line 35 "test5.pgc"
6872

6973
{ ECPGdisconnect(__LINE__, "main");}
70-
#line 35 "test5.pgc"
74+
#line 36 "test5.pgc"
7175

7276

7377
{ ECPGconnect(__LINE__, 0, "connectdb" , NULL, NULL , "main", 0); }
74-
#line 37 "test5.pgc"
78+
#line 38 "test5.pgc"
7579

7680
{ ECPGdisconnect(__LINE__, "main");}
77-
#line 38 "test5.pgc"
81+
#line 39 "test5.pgc"
7882

7983

8084
{ ECPGconnect(__LINE__, 0, "" , "connectdb" , NULL , "main", 0); }
81-
#line 40 "test5.pgc"
85+
#line 41 "test5.pgc"
8286

8387
{ ECPGdisconnect(__LINE__, "main");}
84-
#line 41 "test5.pgc"
88+
#line 42 "test5.pgc"
8589

8690

8791
{ ECPGconnect(__LINE__, 0, "connectdb" , "connectuser" , "connectdb" , "main", 0); }
88-
#line 43 "test5.pgc"
92+
#line 44 "test5.pgc"
8993

9094
{ ECPGdisconnect(__LINE__, "main");}
91-
#line 44 "test5.pgc"
95+
#line 45 "test5.pgc"
9296

9397

9498
{ ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb" , "connectuser" , NULL , "main", 0); }
95-
#line 46 "test5.pgc"
99+
#line 47 "test5.pgc"
96100

97101
{ ECPGdisconnect(__LINE__, "main");}
98-
#line 47 "test5.pgc"
102+
#line 48 "test5.pgc"
99103

100104

101105
{ ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb" , "connectuser" , NULL , "main", 0); }
102-
#line 49 "test5.pgc"
106+
#line 50 "test5.pgc"
103107

104108
{ ECPGdisconnect(__LINE__, "main");}
105-
#line 50 "test5.pgc"
109+
#line 51 "test5.pgc"
106110

107111

108-
{ ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb" , "connectuser" , NULL , "main", 0); }
109-
#line 52 "test5.pgc"
112+
{ ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb" , user , NULL , "main", 0); }
113+
#line 53 "test5.pgc"
110114

111115
{ ECPGdisconnect(__LINE__, "main");}
112-
#line 53 "test5.pgc"
116+
#line 54 "test5.pgc"
113117

114118

115119
{ ECPGconnect(__LINE__, 0, "unix:postgresql://200.46.204.71/connectdb" , "connectuser" , NULL , "main", 0); }
116-
#line 55 "test5.pgc"
120+
#line 56 "test5.pgc"
117121

118122
{ ECPGdisconnect(__LINE__, "main");}
119-
#line 56 "test5.pgc"
123+
#line 57 "test5.pgc"
120124

121125

122126
{ ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/" , "connectdb" , NULL , "main", 0); }
123-
#line 58 "test5.pgc"
127+
#line 59 "test5.pgc"
124128

125129
{ ECPGdisconnect(__LINE__, "main");}
126-
#line 59 "test5.pgc"
130+
#line 60 "test5.pgc"
127131

128132

129133
/* connect twice */
130134
{ ECPGconnect(__LINE__, 0, "connectdb" , NULL, NULL , "main", 0); }
131-
#line 62 "test5.pgc"
135+
#line 63 "test5.pgc"
132136

133137
{ ECPGconnect(__LINE__, 0, "connectdb" , NULL, NULL , "main", 0); }
134-
#line 63 "test5.pgc"
138+
#line 64 "test5.pgc"
135139

136140
{ ECPGdisconnect(__LINE__, "main");}
137-
#line 64 "test5.pgc"
141+
#line 65 "test5.pgc"
138142

139143

140144
/* not connected */
141145
{ ECPGdisconnect(__LINE__, "nonexistant");}
142-
#line 67 "test5.pgc"
146+
#line 68 "test5.pgc"
143147

144148

145149
return (0);

src/interfaces/ecpg/test/expected/connect-test5.stderr

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
[NO_PID]: sqlca: code: 0, state: 00000
33
[NO_PID]: ECPGconnect: opening database connectdb on <DEFAULT> port <DEFAULT>
44
[NO_PID]: sqlca: code: 0, state: 00000
5-
[NO_PID]: ecpg_execute line 23: QUERY: alter user connectuser encrypted password 'connectpw' with 0 parameter on connection main
5+
[NO_PID]: ecpg_execute line 24: QUERY: alter user connectuser encrypted password 'connectpw' with 0 parameter on connection main
66
[NO_PID]: sqlca: code: 0, state: 00000
7-
[NO_PID]: ecpg_execute line 23: using PQexec
7+
[NO_PID]: ecpg_execute line 24: using PQexec
88
[NO_PID]: sqlca: code: 0, state: 00000
9-
[NO_PID]: ecpg_execute line 23 Ok: ALTER ROLE
9+
[NO_PID]: ecpg_execute line 24 Ok: ALTER ROLE
1010
[NO_PID]: sqlca: code: 0, state: 00000
1111
[NO_PID]: ecpg_finish: Connection main closed.
1212
[NO_PID]: sqlca: code: 0, state: 00000
@@ -46,11 +46,11 @@
4646
[NO_PID]: sqlca: code: 0, state: 00000
4747
[NO_PID]: ecpg_finish: Connection main closed.
4848
[NO_PID]: sqlca: code: 0, state: 00000
49-
[NO_PID]: ECPGconnect: non-localhost access via sockets in line 55
49+
[NO_PID]: ECPGconnect: non-localhost access via sockets in line 56
5050
[NO_PID]: sqlca: code: 0, state: 00000
51-
[NO_PID]: raising sqlcode -402 in line 55, 'Could not connect to database connectdb in line 55.'.
51+
[NO_PID]: raising sqlcode -402 in line 56, 'Could not connect to database connectdb in line 56.'.
5252
[NO_PID]: sqlca: code: -402, state: 08001
53-
[NO_PID]: raising sqlcode -220 in line 56, 'No such connection main in line 56.'.
53+
[NO_PID]: raising sqlcode -220 in line 57, 'No such connection main in line 57.'.
5454
[NO_PID]: sqlca: code: -220, state: 08003
5555
[NO_PID]: ECPGconnect: opening database on <DEFAULT> port <DEFAULT> for user connectdb
5656
[NO_PID]: sqlca: code: 0, state: 00000
@@ -62,5 +62,5 @@
6262
[NO_PID]: sqlca: code: 0, state: 00000
6363
[NO_PID]: ecpg_finish: Connection main closed.
6464
[NO_PID]: sqlca: code: 0, state: 00000
65-
[NO_PID]: raising sqlcode -220 in line 67, 'No such connection nonexistant in line 67.'.
65+
[NO_PID]: raising sqlcode -220 in line 68, 'No such connection nonexistant in line 68.'.
6666
[NO_PID]: sqlca: code: -220, state: 08003

0 commit comments

Comments
 (0)