# or in the block
my %replace_string = (
'WITH_TIME' => 'with time',
+ 'WITH_ORDINALITY' => 'with ordinality',
'NULLS_FIRST' => 'nulls first',
'NULLS_LAST' => 'nulls last',
'TYPECAST' => '::',
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;
#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();
[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
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;