Skip to content

Commit f22e84d

Browse files
committed
ecpg: avoid adding whitespace around '&' in connection URLs.
The preprocessor really should not have done this to begin with. The space after '&' was masked by ECPGconnect's skipping spaces before option keywords, and the space before by dint of libpq being (mostly) insensitive to trailing space in option values. We fixed the one known problem with that in 920d519. Hence this patch is mostly cosmetic, and we'll just change it in HEAD. Discussion: https://postgr.es/m/TY2PR01MB36286A7B97B9A15793335D18C1772@TY2PR01MB3628.jpnprd01.prod.outlook.com
1 parent ddbba3a commit f22e84d

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

src/interfaces/ecpg/ecpglib/connect.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,10 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
579579
* The options string contains "keyword=value" pairs separated by
580580
* '&'s. We must break this up into keywords and values to pass to
581581
* libpq (it's okay to scribble on the options string). We ignore
582-
* spaces just before each keyword or value.
582+
* spaces just before each keyword or value. (The preprocessor used
583+
* to add spaces around '&'s, making it necessary to ignore spaces
584+
* before keywords here. While it no longer does that, we still must
585+
* skip spaces to support code compiled with older preprocessors.)
583586
*/
584587
for (str = options; *str;)
585588
{

src/interfaces/ecpg/preproc/ecpg.trailer

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ connect_options: ColId opt_opt_value
348348
if (strcmp($3, "&") != 0)
349349
mmerror(PARSE_ERROR, ET_ERROR, "unrecognized token \"%s\"", $3);
350350

351-
$$ = cat_str(3, make2_str($1, $2), $3, $4);
351+
$$ = make3_str(make2_str($1, $2), $3, $4);
352352
}
353353
;
354354

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ main(void)
117117
#line 56 "test5.pgc"
118118

119119

120-
{ ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/ecpg2_regression?connect_timeout=180 & client_encoding=sql_ascii" , "regress_ecpg_user1" , "connectpw" , "main", 0); }
120+
{ ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/ecpg2_regression?connect_timeout=180&client_encoding=sql_ascii" , "regress_ecpg_user1" , "connectpw" , "main", 0); }
121121
#line 58 "test5.pgc"
122122

123123
{ ECPGdisconnect(__LINE__, "main");}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
[NO_PID]: sqlca: code: 0, state: 00000
5151
[NO_PID]: ecpg_finish: connection main closed
5252
[NO_PID]: sqlca: code: 0, state: 00000
53-
[NO_PID]: ECPGconnect: opening database ecpg2_regression on <DEFAULT> port <DEFAULT> with options connect_timeout=180 & client_encoding=sql_ascii for user regress_ecpg_user1
53+
[NO_PID]: ECPGconnect: opening database ecpg2_regression on <DEFAULT> port <DEFAULT> with options connect_timeout=180&client_encoding=sql_ascii for user regress_ecpg_user1
5454
[NO_PID]: sqlca: code: 0, state: 00000
5555
[NO_PID]: ecpg_finish: connection main closed
5656
[NO_PID]: sqlca: code: 0, state: 00000

0 commit comments

Comments
 (0)