aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/interfaces/ecpg/ChangeLog4
-rw-r--r--src/interfaces/ecpg/preproc/preproc.y13
-rw-r--r--src/interfaces/ecpg/test/expected/sql-show.c50
-rw-r--r--src/interfaces/ecpg/test/expected/sql-show.stderr34
-rw-r--r--src/interfaces/ecpg/test/expected/sql-show.stdout1
-rw-r--r--src/interfaces/ecpg/test/sql/show.pgc6
6 files changed, 82 insertions, 26 deletions
diff --git a/src/interfaces/ecpg/ChangeLog b/src/interfaces/ecpg/ChangeLog
index e801b1a6a56..f5e14af46b4 100644
--- a/src/interfaces/ecpg/ChangeLog
+++ b/src/interfaces/ecpg/ChangeLog
@@ -2366,6 +2366,10 @@ Wed, 04 Jun 2008 14:22:30 +0200
Tue, 24 Jun 2008 13:30:51 +0200
- Synced parser.
+
+Tue, 19 Aug 2008 12:32:24 +0200
+
+ - Fixed incorrect argument handling in SET command if argument is a variable.
- Set pgtypes library version to 3.1.
- Set compat library version to 3.1.
- Set ecpg library version to 6.2.
diff --git a/src/interfaces/ecpg/preproc/preproc.y b/src/interfaces/ecpg/preproc/preproc.y
index 73ad1a577b8..884fbeecbec 100644
--- a/src/interfaces/ecpg/preproc/preproc.y
+++ b/src/interfaces/ecpg/preproc/preproc.y
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.369 2008/07/16 01:30:23 tgl Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.370 2008/08/19 10:40:32 meskes Exp $ */
/* Copyright comment */
%{
@@ -1247,7 +1247,16 @@ iso_level: READ UNCOMMITTED { $$ = make_str("read uncommitted"); }
;
var_value: opt_boolean { $$ = $1; }
- | AllConst { $$ = $1; }
+ | AllConst { /* we have to check for a variable here because it has to be
+ replaced with its value on the client side */
+ if ($1[1] == '$')
+ {
+ $$ = make_str("$0");
+ free($1);
+ }
+ else
+ $$ = $1;
+ }
| ColId { $$ = $1; }
;
diff --git a/src/interfaces/ecpg/test/expected/sql-show.c b/src/interfaces/ecpg/test/expected/sql-show.c
index 3433d30b096..daac7223393 100644
--- a/src/interfaces/ecpg/test/expected/sql-show.c
+++ b/src/interfaces/ecpg/test/expected/sql-show.c
@@ -24,10 +24,10 @@
int main(int argc, char* argv[]) {
/* exec sql begin declare section */
-
+
#line 9 "show.pgc"
- char var [ 25 ] ;
+ char var [ 25 ] = "public" ;
/* exec sql end declare section */
#line 10 "show.pgc"
@@ -44,7 +44,9 @@ int main(int argc, char* argv[]) {
#line 16 "show.pgc"
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set search_path to 'public'", ECPGt_EOIT, ECPGt_EORT);
+ { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set search_path to $0",
+ ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char),
+ ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 18 "show.pgc"
if (sqlca.sqlwarn[0] == 'W') sqlprint();
@@ -66,7 +68,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
printf("Var: Search path: %s\n", var);
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set standard_conforming_strings to off", ECPGt_EOIT, ECPGt_EORT);
+ { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set search_path to 'public'", ECPGt_EOIT, ECPGt_EORT);
#line 22 "show.pgc"
if (sqlca.sqlwarn[0] == 'W') sqlprint();
@@ -75,7 +77,7 @@ if (sqlca.sqlwarn[0] == 'W') sqlprint();
if (sqlca.sqlcode < 0) sqlprint();}
#line 22 "show.pgc"
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "show standard_conforming_strings", ECPGt_EOIT,
+ { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "show search_path", ECPGt_EOIT,
ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 23 "show.pgc"
@@ -86,9 +88,9 @@ if (sqlca.sqlwarn[0] == 'W') sqlprint();
if (sqlca.sqlcode < 0) sqlprint();}
#line 23 "show.pgc"
- printf("Var: Standard conforming strings: %s\n", var);
+ printf("Var: Search path: %s\n", var);
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set time zone PST8PDT", ECPGt_EOIT, ECPGt_EORT);
+ { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set standard_conforming_strings to off", ECPGt_EOIT, ECPGt_EORT);
#line 26 "show.pgc"
if (sqlca.sqlwarn[0] == 'W') sqlprint();
@@ -97,7 +99,7 @@ if (sqlca.sqlwarn[0] == 'W') sqlprint();
if (sqlca.sqlcode < 0) sqlprint();}
#line 26 "show.pgc"
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "show time zone", ECPGt_EOIT,
+ { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "show standard_conforming_strings", ECPGt_EOIT,
ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 27 "show.pgc"
@@ -108,9 +110,9 @@ if (sqlca.sqlwarn[0] == 'W') sqlprint();
if (sqlca.sqlcode < 0) sqlprint();}
#line 27 "show.pgc"
- printf("Time Zone: %s\n", var);
+ printf("Var: Standard conforming strings: %s\n", var);
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set transaction isolation level read committed", ECPGt_EOIT, ECPGt_EORT);
+ { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set time zone PST8PDT", ECPGt_EOIT, ECPGt_EORT);
#line 30 "show.pgc"
if (sqlca.sqlwarn[0] == 'W') sqlprint();
@@ -119,7 +121,7 @@ if (sqlca.sqlwarn[0] == 'W') sqlprint();
if (sqlca.sqlcode < 0) sqlprint();}
#line 30 "show.pgc"
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "show transaction isolation level", ECPGt_EOIT,
+ { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "show time zone", ECPGt_EOIT,
ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 31 "show.pgc"
@@ -130,9 +132,9 @@ if (sqlca.sqlwarn[0] == 'W') sqlprint();
if (sqlca.sqlcode < 0) sqlprint();}
#line 31 "show.pgc"
- printf("Transaction isolation level: %s\n", var);
+ printf("Time Zone: %s\n", var);
- { ECPGdisconnect(__LINE__, "ALL");
+ { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set transaction isolation level read committed", ECPGt_EOIT, ECPGt_EORT);
#line 34 "show.pgc"
if (sqlca.sqlwarn[0] == 'W') sqlprint();
@@ -141,6 +143,28 @@ if (sqlca.sqlwarn[0] == 'W') sqlprint();
if (sqlca.sqlcode < 0) sqlprint();}
#line 34 "show.pgc"
+ { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "show transaction isolation level", ECPGt_EOIT,
+ ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char),
+ ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 35 "show.pgc"
+
+if (sqlca.sqlwarn[0] == 'W') sqlprint();
+#line 35 "show.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 35 "show.pgc"
+
+ printf("Transaction isolation level: %s\n", var);
+
+ { ECPGdisconnect(__LINE__, "ALL");
+#line 38 "show.pgc"
+
+if (sqlca.sqlwarn[0] == 'W') sqlprint();
+#line 38 "show.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 38 "show.pgc"
+
return 0;
}
diff --git a/src/interfaces/ecpg/test/expected/sql-show.stderr b/src/interfaces/ecpg/test/expected/sql-show.stderr
index 44634d91732..b176903c209 100644
--- a/src/interfaces/ecpg/test/expected/sql-show.stderr
+++ b/src/interfaces/ecpg/test/expected/sql-show.stderr
@@ -2,7 +2,7 @@
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 18: query: set search_path to 'public'; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 18: query: set search_path to public; with 0 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 18: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
@@ -16,47 +16,61 @@
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 19: RESULT: public offset: -1; array: yes
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 22: query: set standard_conforming_strings to off; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 22: query: set search_path to 'public'; with 0 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 22: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 22: OK: SET
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 23: query: show standard_conforming_strings; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 23: query: show search_path; with 0 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 23: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 23: correctly got 1 tuples with 1 fields
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_get_data on line 23: RESULT: off offset: -1; array: yes
+[NO_PID]: ecpg_get_data on line 23: RESULT: public offset: -1; array: yes
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 26: query: set time zone PST8PDT; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 26: query: set standard_conforming_strings to off; with 0 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 26: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 26: OK: SET
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 27: query: show time zone; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 27: query: show standard_conforming_strings; with 0 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 27: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 27: correctly got 1 tuples with 1 fields
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_get_data on line 27: RESULT: PST8PDT offset: -1; array: yes
+[NO_PID]: ecpg_get_data on line 27: RESULT: off offset: -1; array: yes
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 30: query: set transaction isolation level read committed; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 30: query: set time zone PST8PDT; with 0 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 30: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 30: OK: SET
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 31: query: show transaction isolation level; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 31: query: show time zone; with 0 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 31: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 31: correctly got 1 tuples with 1 fields
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_get_data on line 31: RESULT: read committed offset: -1; array: yes
+[NO_PID]: ecpg_get_data on line 31: RESULT: PST8PDT offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 34: query: set transaction isolation level read committed; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 34: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 34: OK: SET
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 35: query: show transaction isolation level; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 35: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 35: correctly got 1 tuples with 1 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 35: RESULT: read committed offset: -1; array: yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: connection regress1 closed
[NO_PID]: sqlca: code: 0, state: 00000
diff --git a/src/interfaces/ecpg/test/expected/sql-show.stdout b/src/interfaces/ecpg/test/expected/sql-show.stdout
index 76f854b040d..9319c5d1135 100644
--- a/src/interfaces/ecpg/test/expected/sql-show.stdout
+++ b/src/interfaces/ecpg/test/expected/sql-show.stdout
@@ -1,4 +1,5 @@
Var: Search path: public
+Var: Search path: public
Var: Standard conforming strings: off
Time Zone: PST8PDT
Transaction isolation level: read committed
diff --git a/src/interfaces/ecpg/test/sql/show.pgc b/src/interfaces/ecpg/test/sql/show.pgc
index 8eb71a7262a..d3a888d5095 100644
--- a/src/interfaces/ecpg/test/sql/show.pgc
+++ b/src/interfaces/ecpg/test/sql/show.pgc
@@ -6,7 +6,7 @@ EXEC SQL INCLUDE ../regression;
int main(int argc, char* argv[]) {
EXEC SQL BEGIN DECLARE SECTION;
- char var[25];
+ char var[25] = "public";
EXEC SQL END DECLARE SECTION;
ECPGdebug(1, stderr);
@@ -15,6 +15,10 @@ int main(int argc, char* argv[]) {
EXEC SQL WHENEVER SQLWARNING SQLPRINT;
EXEC SQL WHENEVER SQLERROR SQLPRINT;
+ EXEC SQL SET search_path TO :var;
+ EXEC SQL SHOW search_path INTO :var;
+ printf("Var: Search path: %s\n", var);
+
EXEC SQL SET search_path TO 'public';
EXEC SQL SHOW search_path INTO :var;
printf("Var: Search path: %s\n", var);