Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
ef0dcf0e
Commit
ef0dcf0e
authored
Aug 19, 2008
by
Michael Meskes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed incorrect argument handling in SET command if argument is a variable.
parent
a3faf37f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
82 additions
and
26 deletions
+82
-26
src/interfaces/ecpg/ChangeLog
src/interfaces/ecpg/ChangeLog
+4
-0
src/interfaces/ecpg/preproc/preproc.y
src/interfaces/ecpg/preproc/preproc.y
+11
-2
src/interfaces/ecpg/test/expected/sql-show.c
src/interfaces/ecpg/test/expected/sql-show.c
+37
-13
src/interfaces/ecpg/test/expected/sql-show.stderr
src/interfaces/ecpg/test/expected/sql-show.stderr
+24
-10
src/interfaces/ecpg/test/expected/sql-show.stdout
src/interfaces/ecpg/test/expected/sql-show.stdout
+1
-0
src/interfaces/ecpg/test/sql/show.pgc
src/interfaces/ecpg/test/sql/show.pgc
+5
-1
No files found.
src/interfaces/ecpg/ChangeLog
View file @
ef0dcf0e
...
...
@@ -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.
...
...
src/interfaces/ecpg/preproc/preproc.y
View file @
ef0dcf0e
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.3
69 2008/07/16 01:30:23 tgl
Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.3
70 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; }
;
...
...
src/interfaces/ecpg/test/expected/sql-show.c
View file @
ef0dcf0e
...
...
@@ -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 s
tandard_conforming_strings to off
"
,
ECPGt_EOIT
,
ECPGt_EORT
);
{
ECPGdo
(
__LINE__
,
0
,
1
,
NULL
,
0
,
ECPGst_normal
,
"set s
earch_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 s
tandard_conforming_strings
"
,
ECPGt_EOIT
,
{
ECPGdo
(
__LINE__
,
0
,
1
,
NULL
,
0
,
ECPGst_normal
,
"show s
earch_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: S
tandard conforming strings
: %s
\n
"
,
var
);
printf
(
"Var: S
earch 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 t
ransaction isolation level read committed
"
,
ECPGt_EOIT
,
ECPGt_EORT
);
{
ECPGdo
(
__LINE__
,
0
,
1
,
NULL
,
0
,
ECPGst_normal
,
"set t
ime 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 t
ransaction isolation level
"
,
ECPGt_EOIT
,
{
ECPGdo
(
__LINE__
,
0
,
1
,
NULL
,
0
,
ECPGst_normal
,
"show t
ime 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
(
"T
ransaction isolation level
: %s
\n
"
,
var
);
printf
(
"T
ime Zone
: %s
\n
"
,
var
);
{
ECPGd
isconnect
(
__LINE__
,
"ALL"
);
{
ECPGd
o
(
__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
;
}
src/interfaces/ecpg/test/expected/sql-show.stderr
View file @
ef0dcf0e
...
...
@@ -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 s
tandard_conforming_strings to off
; with 0 parameter(s) on connection regress1
[NO_PID]: ecpg_execute on line 22: query: set s
earch_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 s
tandard_conforming_strings
; with 0 parameter(s) on connection regress1
[NO_PID]: ecpg_execute on line 23: query: show s
earch_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 t
ransaction isolation level read committed
; with 0 parameter(s) on connection regress1
[NO_PID]: ecpg_execute on line 30: query: set t
ime 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 t
ransaction isolation level
; with 0 parameter(s) on connection regress1
[NO_PID]: ecpg_execute on line 31: query: show t
ime 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
src/interfaces/ecpg/test/expected/sql-show.stdout
View file @
ef0dcf0e
Var: Search path: public
Var: Search path: public
Var: Standard conforming strings: off
Time Zone: PST8PDT
Transaction isolation level: read committed
src/interfaces/ecpg/test/sql/show.pgc
View file @
ef0dcf0e
...
...
@@ -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);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment