Sync ECPG with WITH ORDINALITY changes

This commit is contained in:
Greg Stark 2013-07-29 23:43:44 +01:00
parent c62736cc37
commit 69b7d59a74
5 changed files with 10 additions and 36 deletions

View File

@ -43,6 +43,7 @@ my %replace_token = (
# or in the block
my %replace_string = (
'WITH_TIME' => 'with time',
'WITH_ORDINALITY' => 'with ordinality',
'NULLS_FIRST' => 'nulls first',
'NULLS_LAST' => 'nulls last',
'TYPECAST' => '::',

View File

@ -108,6 +108,9 @@ filtered_base_yylex(void)
case TIME:
cur_token = WITH_TIME;
break;
case ORDINALITY:
cur_token = WITH_ORDINALITY;
break;
default:
/* save the lookahead token for next time */
lookahead_token = next_token;

View File

@ -58,25 +58,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
#line 20 "parser.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into T values ( 1 , null )", ECPGt_EOIT, ECPGt_EORT);
#line 22 "parser.pgc"
if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 22 "parser.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 22 "parser.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into T values ( 1 , 1 )", ECPGt_EOIT, ECPGt_EORT);
#line 23 "parser.pgc"
if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 23 "parser.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 23 "parser.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into T values ( 1 , 2 )", ECPGt_EOIT, ECPGt_EORT);
{ 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);
#line 24 "parser.pgc"
if (sqlca.sqlwarn[0] == 'W') sqlprint();

View File

@ -10,23 +10,11 @@
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 20: OK: CREATE TABLE
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 22: query: insert into T values ( 1 , null ); with 0 parameter(s) on connection regress1
[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
[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: INSERT 0 1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 23: query: insert into T values ( 1 , 1 ); 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: OK: INSERT 0 1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 24: query: insert into T values ( 1 , 2 ); with 0 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 24: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 24: OK: INSERT 0 1
[NO_PID]: ecpg_execute on line 22: OK: INSERT 0 3
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 26: query: select Item2 from T order by Item2 nulls last; with 0 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000

View File

@ -19,9 +19,9 @@ int main() {
EXEC SQL CREATE TABLE T ( Item1 int, Item2 int );
EXEC SQL INSERT INTO T VALUES ( 1, null );
EXEC SQL INSERT INTO T VALUES ( 1, 1 );
EXEC SQL INSERT INTO T VALUES ( 1, 2 );
EXEC SQL INSERT INTO t
SELECT 1,nullif(y-1,0)
FROM generate_series(1,3) WITH ORDINALITY AS series(x,y);
EXEC SQL SELECT Item2 INTO :item:ind FROM T ORDER BY Item2 NULLS LAST;