@@ -414,6 +414,7 @@ pl_block : decl_sect K_BEGIN proc_sect exception_sect K_END opt_label
414
414
415
415
new ->cmd_type = PLPGSQL_STMT_BLOCK;
416
416
new ->lineno = plpgsql_location_to_lineno(@2 );
417
+ new ->stmtid = ++plpgsql_curr_compile->nstatements;
417
418
new ->label = $1 .label;
418
419
new ->n_initvars = $1 .n_initvars;
419
420
new ->initvarnos = $1 .initvarnos;
@@ -905,6 +906,7 @@ stmt_perform : K_PERFORM expr_until_semi
905
906
new = palloc0 (sizeof (PLpgSQL_stmt_perform));
906
907
new ->cmd_type = PLPGSQL_STMT_PERFORM;
907
908
new ->lineno = plpgsql_location_to_lineno (@1 );
909
+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
908
910
new ->expr = $2 ;
909
911
910
912
$$ = (PLpgSQL_stmt *)new ;
@@ -918,6 +920,7 @@ stmt_call : K_CALL
918
920
new = palloc0 (sizeof (PLpgSQL_stmt_call));
919
921
new ->cmd_type = PLPGSQL_STMT_CALL;
920
922
new ->lineno = plpgsql_location_to_lineno (@1 );
923
+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
921
924
new ->expr = read_sql_stmt (" CALL " );
922
925
new ->is_call = true ;
923
926
@@ -932,6 +935,7 @@ stmt_call : K_CALL
932
935
new = palloc0 (sizeof (PLpgSQL_stmt_call));
933
936
new ->cmd_type = PLPGSQL_STMT_CALL;
934
937
new ->lineno = plpgsql_location_to_lineno (@1 );
938
+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
935
939
new ->expr = read_sql_stmt (" DO " );
936
940
new ->is_call = false ;
937
941
@@ -947,6 +951,7 @@ stmt_assign : assign_var assign_operator expr_until_semi
947
951
new = palloc0 (sizeof (PLpgSQL_stmt_assign));
948
952
new ->cmd_type = PLPGSQL_STMT_ASSIGN;
949
953
new ->lineno = plpgsql_location_to_lineno (@1 );
954
+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
950
955
new ->varno = $1 ->dno ;
951
956
new ->expr = $3 ;
952
957
@@ -962,6 +967,7 @@ stmt_getdiag : K_GET getdiag_area_opt K_DIAGNOSTICS getdiag_list ';'
962
967
new = palloc0 (sizeof (PLpgSQL_stmt_getdiag));
963
968
new ->cmd_type = PLPGSQL_STMT_GETDIAG;
964
969
new ->lineno = plpgsql_location_to_lineno (@1 );
970
+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
965
971
new ->is_stacked = $2 ;
966
972
new ->diag_items = $4 ;
967
973
@@ -1149,6 +1155,7 @@ stmt_if : K_IF expr_until_then proc_sect stmt_elsifs stmt_else K_END K_IF ';'
1149
1155
new = palloc0 (sizeof (PLpgSQL_stmt_if));
1150
1156
new ->cmd_type = PLPGSQL_STMT_IF;
1151
1157
new ->lineno = plpgsql_location_to_lineno (@1 );
1158
+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
1152
1159
new ->cond = $2 ;
1153
1160
new ->then_body = $3 ;
1154
1161
new ->elsif_list = $4 ;
@@ -1253,6 +1260,7 @@ stmt_loop : opt_loop_label K_LOOP loop_body
1253
1260
new = palloc0 (sizeof (PLpgSQL_stmt_loop));
1254
1261
new ->cmd_type = PLPGSQL_STMT_LOOP;
1255
1262
new ->lineno = plpgsql_location_to_lineno (@2 );
1263
+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
1256
1264
new ->label = $1 ;
1257
1265
new ->body = $3 .stmts ;
1258
1266
@@ -1270,6 +1278,7 @@ stmt_while : opt_loop_label K_WHILE expr_until_loop loop_body
1270
1278
new = palloc0 (sizeof (PLpgSQL_stmt_while));
1271
1279
new ->cmd_type = PLPGSQL_STMT_WHILE;
1272
1280
new ->lineno = plpgsql_location_to_lineno (@2 );
1281
+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
1273
1282
new ->label = $1 ;
1274
1283
new ->cond = $3 ;
1275
1284
new ->body = $4 .stmts ;
@@ -1290,6 +1299,7 @@ stmt_for : opt_loop_label K_FOR for_control loop_body
1290
1299
1291
1300
new = (PLpgSQL_stmt_fori *) $3 ;
1292
1301
new ->lineno = plpgsql_location_to_lineno (@2 );
1302
+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
1293
1303
new ->label = $1 ;
1294
1304
new ->body = $4 .stmts ;
1295
1305
$$ = (PLpgSQL_stmt *) new ;
@@ -1304,6 +1314,7 @@ stmt_for : opt_loop_label K_FOR for_control loop_body
1304
1314
/* forq is the common supertype of all three */
1305
1315
new = (PLpgSQL_stmt_forq *) $3 ;
1306
1316
new ->lineno = plpgsql_location_to_lineno (@2 );
1317
+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
1307
1318
new ->label = $1 ;
1308
1319
new ->body = $4 .stmts ;
1309
1320
$$ = (PLpgSQL_stmt *) new ;
@@ -1333,6 +1344,7 @@ for_control : for_variable K_IN
1333
1344
1334
1345
new = palloc0 (sizeof (PLpgSQL_stmt_dynfors));
1335
1346
new ->cmd_type = PLPGSQL_STMT_DYNFORS;
1347
+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
1336
1348
if ($1 .row )
1337
1349
{
1338
1350
new ->var = (PLpgSQL_variable *) $1 .row ;
@@ -1378,6 +1390,7 @@ for_control : for_variable K_IN
1378
1390
1379
1391
new = (PLpgSQL_stmt_forc *) palloc0 (sizeof (PLpgSQL_stmt_forc));
1380
1392
new ->cmd_type = PLPGSQL_STMT_FORC;
1393
+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
1381
1394
new ->curvar = cursor->dno ;
1382
1395
1383
1396
/* Should have had a single variable name */
@@ -1492,6 +1505,7 @@ for_control : for_variable K_IN
1492
1505
1493
1506
new = palloc0 (sizeof (PLpgSQL_stmt_fori));
1494
1507
new ->cmd_type = PLPGSQL_STMT_FORI;
1508
+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
1495
1509
new ->var = fvar;
1496
1510
new ->reverse = reverse;
1497
1511
new ->lower = expr1;
@@ -1526,6 +1540,7 @@ for_control : for_variable K_IN
1526
1540
1527
1541
new = palloc0 (sizeof (PLpgSQL_stmt_fors));
1528
1542
new ->cmd_type = PLPGSQL_STMT_FORS;
1543
+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
1529
1544
if ($1 .row )
1530
1545
{
1531
1546
new ->var = (PLpgSQL_variable *) $1 .row ;
@@ -1626,6 +1641,7 @@ stmt_foreach_a : opt_loop_label K_FOREACH for_variable foreach_slice K_IN K_ARRA
1626
1641
new = palloc0 (sizeof (PLpgSQL_stmt_foreach_a));
1627
1642
new ->cmd_type = PLPGSQL_STMT_FOREACH_A;
1628
1643
new ->lineno = plpgsql_location_to_lineno (@2 );
1644
+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
1629
1645
new ->label = $1 ;
1630
1646
new ->slice = $4 ;
1631
1647
new ->expr = $7 ;
@@ -1672,6 +1688,7 @@ stmt_exit : exit_type opt_label opt_exitcond
1672
1688
1673
1689
new = palloc0 (sizeof (PLpgSQL_stmt_exit));
1674
1690
new ->cmd_type = PLPGSQL_STMT_EXIT;
1691
+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
1675
1692
new ->is_exit = $1 ;
1676
1693
new ->lineno = plpgsql_location_to_lineno (@1 );
1677
1694
new ->label = $2 ;
@@ -1763,6 +1780,7 @@ stmt_raise : K_RAISE
1763
1780
1764
1781
new ->cmd_type = PLPGSQL_STMT_RAISE;
1765
1782
new ->lineno = plpgsql_location_to_lineno (@1 );
1783
+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
1766
1784
new ->elog_level = ERROR; /* default */
1767
1785
new ->condname = NULL ;
1768
1786
new ->message = NULL ;
@@ -1907,6 +1925,7 @@ stmt_assert : K_ASSERT
1907
1925
1908
1926
new ->cmd_type = PLPGSQL_STMT_ASSERT;
1909
1927
new ->lineno = plpgsql_location_to_lineno (@1 );
1928
+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
1910
1929
1911
1930
new ->cond = read_sql_expression2 (' ,' , ' ;' ,
1912
1931
" , or ;" ,
@@ -1984,6 +2003,7 @@ stmt_dynexecute : K_EXECUTE
1984
2003
new = palloc (sizeof (PLpgSQL_stmt_dynexecute));
1985
2004
new ->cmd_type = PLPGSQL_STMT_DYNEXECUTE;
1986
2005
new ->lineno = plpgsql_location_to_lineno (@1 );
2006
+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
1987
2007
new ->query = expr;
1988
2008
new ->into = false ;
1989
2009
new ->strict = false ;
@@ -2040,6 +2060,7 @@ stmt_open : K_OPEN cursor_variable
2040
2060
new = palloc0 (sizeof (PLpgSQL_stmt_open));
2041
2061
new ->cmd_type = PLPGSQL_STMT_OPEN;
2042
2062
new ->lineno = plpgsql_location_to_lineno (@1 );
2063
+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
2043
2064
new ->curvar = $2 ->dno ;
2044
2065
new ->cursor_options = CURSOR_OPT_FAST_PLAN;
2045
2066
@@ -2164,6 +2185,7 @@ stmt_close : K_CLOSE cursor_variable ';'
2164
2185
new = palloc (sizeof (PLpgSQL_stmt_close));
2165
2186
new ->cmd_type = PLPGSQL_STMT_CLOSE;
2166
2187
new ->lineno = plpgsql_location_to_lineno (@1 );
2188
+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
2167
2189
new ->curvar = $2 ->dno ;
2168
2190
2169
2191
$$ = (PLpgSQL_stmt *)new ;
@@ -2184,6 +2206,7 @@ stmt_commit : K_COMMIT ';'
2184
2206
new = palloc (sizeof (PLpgSQL_stmt_commit));
2185
2207
new ->cmd_type = PLPGSQL_STMT_COMMIT;
2186
2208
new ->lineno = plpgsql_location_to_lineno (@1 );
2209
+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
2187
2210
2188
2211
$$ = (PLpgSQL_stmt *)new ;
2189
2212
}
@@ -2196,6 +2219,7 @@ stmt_rollback : K_ROLLBACK ';'
2196
2219
new = palloc (sizeof (PLpgSQL_stmt_rollback));
2197
2220
new ->cmd_type = PLPGSQL_STMT_ROLLBACK;
2198
2221
new ->lineno = plpgsql_location_to_lineno (@1 );
2222
+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
2199
2223
2200
2224
$$ = (PLpgSQL_stmt *)new ;
2201
2225
}
@@ -2208,6 +2232,8 @@ stmt_set : K_SET
2208
2232
new = palloc0 (sizeof (PLpgSQL_stmt_set));
2209
2233
new ->cmd_type = PLPGSQL_STMT_SET;
2210
2234
new ->lineno = plpgsql_location_to_lineno (@1 );
2235
+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
2236
+
2211
2237
new ->expr = read_sql_stmt (" SET " );
2212
2238
2213
2239
$$ = (PLpgSQL_stmt *)new ;
@@ -2219,6 +2245,7 @@ stmt_set : K_SET
2219
2245
new = palloc0 (sizeof (PLpgSQL_stmt_set));
2220
2246
new ->cmd_type = PLPGSQL_STMT_SET;
2221
2247
new ->lineno = plpgsql_location_to_lineno (@1 );
2248
+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
2222
2249
new ->expr = read_sql_stmt (" RESET " );
2223
2250
2224
2251
$$ = (PLpgSQL_stmt *)new ;
@@ -3000,6 +3027,7 @@ make_execsql_stmt(int firsttoken, int location)
3000
3027
execsql = palloc(sizeof(PLpgSQL_stmt_execsql));
3001
3028
execsql->cmd_type = PLPGSQL_STMT_EXECSQL;
3002
3029
execsql->lineno = plpgsql_location_to_lineno(location);
3030
+ execsql->stmtid = ++plpgsql_curr_compile->nstatements;
3003
3031
execsql->sqlstmt = expr;
3004
3032
execsql->into = have_into;
3005
3033
execsql->strict = have_strict;
@@ -3025,6 +3053,7 @@ read_fetch_direction(void)
3025
3053
*/
3026
3054
fetch = (PLpgSQL_stmt_fetch *) palloc0(sizeof(PLpgSQL_stmt_fetch));
3027
3055
fetch->cmd_type = PLPGSQL_STMT_FETCH;
3056
+ fetch->stmtid = ++plpgsql_curr_compile->nstatements;
3028
3057
/* set direction defaults: */
3029
3058
fetch->direction = FETCH_FORWARD;
3030
3059
fetch->how_many = 1;
@@ -3177,6 +3206,7 @@ make_return_stmt(int location)
3177
3206
new = palloc0(sizeof(PLpgSQL_stmt_return));
3178
3207
new->cmd_type = PLPGSQL_STMT_RETURN;
3179
3208
new->lineno = plpgsql_location_to_lineno(location);
3209
+ new->stmtid = ++plpgsql_curr_compile->nstatements;
3180
3210
new->expr = NULL;
3181
3211
new->retvarno = -1;
3182
3212
@@ -3264,6 +3294,7 @@ make_return_next_stmt(int location)
3264
3294
new = palloc0(sizeof(PLpgSQL_stmt_return_next));
3265
3295
new->cmd_type = PLPGSQL_STMT_RETURN_NEXT;
3266
3296
new->lineno = plpgsql_location_to_lineno(location);
3297
+ new->stmtid = ++plpgsql_curr_compile->nstatements;
3267
3298
new->expr = NULL;
3268
3299
new->retvarno = -1;
3269
3300
@@ -3327,6 +3358,7 @@ make_return_query_stmt(int location)
3327
3358
new = palloc0(sizeof(PLpgSQL_stmt_return_query));
3328
3359
new->cmd_type = PLPGSQL_STMT_RETURN_QUERY;
3329
3360
new->lineno = plpgsql_location_to_lineno(location);
3361
+ new->stmtid = ++plpgsql_curr_compile->nstatements;
3330
3362
3331
3363
/* check for RETURN QUERY EXECUTE */
3332
3364
if ((tok = yylex()) != K_EXECUTE)
@@ -3997,6 +4029,7 @@ make_case(int location, PLpgSQL_expr *t_expr,
3997
4029
new = palloc(sizeof(PLpgSQL_stmt_case));
3998
4030
new->cmd_type = PLPGSQL_STMT_CASE;
3999
4031
new->lineno = plpgsql_location_to_lineno(location);
4032
+ new->stmtid = ++plpgsql_curr_compile->nstatements;
4000
4033
new->t_expr = t_expr;
4001
4034
new->t_varno = 0;
4002
4035
new->case_when_list = case_when_list;
0 commit comments