Skip to content

Commit 69b7d59

Browse files
committed
Sync ECPG with WITH ORDINALITY changes
1 parent c62736c commit 69b7d59

File tree

5 files changed

+10
-36
lines changed

5 files changed

+10
-36
lines changed

src/interfaces/ecpg/preproc/parse.pl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
# or in the block
4444
my %replace_string = (
4545
'WITH_TIME' => 'with time',
46+
'WITH_ORDINALITY' => 'with ordinality',
4647
'NULLS_FIRST' => 'nulls first',
4748
'NULLS_LAST' => 'nulls last',
4849
'TYPECAST' => '::',

src/interfaces/ecpg/preproc/parser.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ filtered_base_yylex(void)
108108
case TIME:
109109
cur_token = WITH_TIME;
110110
break;
111+
case ORDINALITY:
112+
cur_token = WITH_ORDINALITY;
113+
break;
111114
default:
112115
/* save the lookahead token for next time */
113116
lookahead_token = next_token;

src/interfaces/ecpg/test/expected/sql-parser.c

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -58,25 +58,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
5858
#line 20 "parser.pgc"
5959

6060

61-
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into T values ( 1 , null )", ECPGt_EOIT, ECPGt_EORT);
62-
#line 22 "parser.pgc"
63-
64-
if (sqlca.sqlwarn[0] == 'W') sqlprint();
65-
#line 22 "parser.pgc"
66-
67-
if (sqlca.sqlcode < 0) sqlprint();}
68-
#line 22 "parser.pgc"
69-
70-
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into T values ( 1 , 1 )", ECPGt_EOIT, ECPGt_EORT);
71-
#line 23 "parser.pgc"
72-
73-
if (sqlca.sqlwarn[0] == 'W') sqlprint();
74-
#line 23 "parser.pgc"
75-
76-
if (sqlca.sqlcode < 0) sqlprint();}
77-
#line 23 "parser.pgc"
78-
79-
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into T values ( 1 , 2 )", ECPGt_EOIT, ECPGt_EORT);
61+
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t select 1 , nullif ( y - 1 , 0 ) from generate_series ( 1 , 3 ) with ordinality as series ( x , y )", ECPGt_EOIT, ECPGt_EORT);
8062
#line 24 "parser.pgc"
8163

8264
if (sqlca.sqlwarn[0] == 'W') sqlprint();

src/interfaces/ecpg/test/expected/sql-parser.stderr

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,11 @@
1010
[NO_PID]: sqlca: code: 0, state: 00000
1111
[NO_PID]: ecpg_execute on line 20: OK: CREATE TABLE
1212
[NO_PID]: sqlca: code: 0, state: 00000
13-
[NO_PID]: ecpg_execute on line 22: query: insert into T values ( 1 , null ); with 0 parameter(s) on connection regress1
13+
[NO_PID]: ecpg_execute on line 22: query: insert into t select 1 , nullif ( y - 1 , 0 ) from generate_series ( 1 , 3 ) with ordinality as series ( x , y ); with 0 parameter(s) on connection regress1
1414
[NO_PID]: sqlca: code: 0, state: 00000
1515
[NO_PID]: ecpg_execute on line 22: using PQexec
1616
[NO_PID]: sqlca: code: 0, state: 00000
17-
[NO_PID]: ecpg_execute on line 22: OK: INSERT 0 1
18-
[NO_PID]: sqlca: code: 0, state: 00000
19-
[NO_PID]: ecpg_execute on line 23: query: insert into T values ( 1 , 1 ); with 0 parameter(s) on connection regress1
20-
[NO_PID]: sqlca: code: 0, state: 00000
21-
[NO_PID]: ecpg_execute on line 23: using PQexec
22-
[NO_PID]: sqlca: code: 0, state: 00000
23-
[NO_PID]: ecpg_execute on line 23: OK: INSERT 0 1
24-
[NO_PID]: sqlca: code: 0, state: 00000
25-
[NO_PID]: ecpg_execute on line 24: query: insert into T values ( 1 , 2 ); with 0 parameter(s) on connection regress1
26-
[NO_PID]: sqlca: code: 0, state: 00000
27-
[NO_PID]: ecpg_execute on line 24: using PQexec
28-
[NO_PID]: sqlca: code: 0, state: 00000
29-
[NO_PID]: ecpg_execute on line 24: OK: INSERT 0 1
17+
[NO_PID]: ecpg_execute on line 22: OK: INSERT 0 3
3018
[NO_PID]: sqlca: code: 0, state: 00000
3119
[NO_PID]: ecpg_execute on line 26: query: select Item2 from T order by Item2 nulls last; with 0 parameter(s) on connection regress1
3220
[NO_PID]: sqlca: code: 0, state: 00000

src/interfaces/ecpg/test/sql/parser.pgc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ int main() {
1919

2020
EXEC SQL CREATE TABLE T ( Item1 int, Item2 int );
2121

22-
EXEC SQL INSERT INTO T VALUES ( 1, null );
23-
EXEC SQL INSERT INTO T VALUES ( 1, 1 );
24-
EXEC SQL INSERT INTO T VALUES ( 1, 2 );
22+
EXEC SQL INSERT INTO t
23+
SELECT 1,nullif(y-1,0)
24+
FROM generate_series(1,3) WITH ORDINALITY AS series(x,y);
2525

2626
EXEC SQL SELECT Item2 INTO :item:ind FROM T ORDER BY Item2 NULLS LAST;
2727

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy