@@ -414,6 +414,7 @@ pl_block: decl_sect K_BEGIN proc_sect exception_sect K_END opt_label
414414
415415new ->cmd_type= PLPGSQL_STMT_BLOCK;
416416new ->lineno= plpgsql_location_to_lineno(@2 );
417+ new ->stmtid= ++plpgsql_curr_compile->nstatements;
417418new ->label=$1 .label;
418419new ->n_initvars =$1 .n_initvars;
419420new ->initvarnos =$1 .initvarnos;
@@ -905,6 +906,7 @@ stmt_perform: K_PERFORM expr_until_semi
905906new =palloc0 (sizeof (PLpgSQL_stmt_perform));
906907new ->cmd_type = PLPGSQL_STMT_PERFORM;
907908new ->lineno =plpgsql_location_to_lineno (@1 );
909+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
908910new ->expr = $2 ;
909911
910912$$ = (PLpgSQL_stmt *)new ;
@@ -918,6 +920,7 @@ stmt_call: K_CALL
918920new =palloc0 (sizeof (PLpgSQL_stmt_call));
919921new ->cmd_type = PLPGSQL_STMT_CALL;
920922new ->lineno =plpgsql_location_to_lineno (@1 );
923+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
921924new ->expr =read_sql_stmt (" CALL" );
922925new ->is_call =true ;
923926
@@ -932,6 +935,7 @@ stmt_call: K_CALL
932935new =palloc0 (sizeof (PLpgSQL_stmt_call));
933936new ->cmd_type = PLPGSQL_STMT_CALL;
934937new ->lineno =plpgsql_location_to_lineno (@1 );
938+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
935939new ->expr =read_sql_stmt (" DO" );
936940new ->is_call =false ;
937941
@@ -947,6 +951,7 @@ stmt_assign: assign_var assign_operator expr_until_semi
947951new =palloc0 (sizeof (PLpgSQL_stmt_assign));
948952new ->cmd_type = PLPGSQL_STMT_ASSIGN;
949953new ->lineno =plpgsql_location_to_lineno (@1 );
954+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
950955new ->varno = $1 ->dno ;
951956new ->expr = $3 ;
952957
@@ -962,6 +967,7 @@ stmt_getdiag: K_GET getdiag_area_opt K_DIAGNOSTICS getdiag_list ';'
962967new =palloc0 (sizeof (PLpgSQL_stmt_getdiag));
963968new ->cmd_type = PLPGSQL_STMT_GETDIAG;
964969new ->lineno =plpgsql_location_to_lineno (@1 );
970+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
965971new ->is_stacked = $2 ;
966972new ->diag_items = $4 ;
967973
@@ -1149,6 +1155,7 @@ stmt_if: K_IF expr_until_then proc_sect stmt_elsifs stmt_else K_END K_IF ';'
11491155new =palloc0 (sizeof (PLpgSQL_stmt_if));
11501156new ->cmd_type = PLPGSQL_STMT_IF;
11511157new ->lineno =plpgsql_location_to_lineno (@1 );
1158+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
11521159new ->cond = $2 ;
11531160new ->then_body = $3 ;
11541161new ->elsif_list = $4 ;
@@ -1253,6 +1260,7 @@ stmt_loop: opt_loop_label K_LOOP loop_body
12531260new =palloc0 (sizeof (PLpgSQL_stmt_loop));
12541261new ->cmd_type = PLPGSQL_STMT_LOOP;
12551262new ->lineno =plpgsql_location_to_lineno (@2 );
1263+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
12561264new ->label = $1 ;
12571265new ->body = $3 .stmts ;
12581266
@@ -1270,6 +1278,7 @@ stmt_while: opt_loop_label K_WHILE expr_until_loop loop_body
12701278new =palloc0 (sizeof (PLpgSQL_stmt_while));
12711279new ->cmd_type = PLPGSQL_STMT_WHILE;
12721280new ->lineno =plpgsql_location_to_lineno (@2 );
1281+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
12731282new ->label = $1 ;
12741283new ->cond = $3 ;
12751284new ->body = $4 .stmts ;
@@ -1290,6 +1299,7 @@ stmt_for: opt_loop_label K_FOR for_control loop_body
12901299
12911300new = (PLpgSQL_stmt_fori *) $3 ;
12921301new ->lineno =plpgsql_location_to_lineno (@2 );
1302+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
12931303new ->label = $1 ;
12941304new ->body = $4 .stmts ;
12951305$$ = (PLpgSQL_stmt *)new ;
@@ -1304,6 +1314,7 @@ stmt_for: opt_loop_label K_FOR for_control loop_body
13041314/* forq is the common supertype of all three*/
13051315new = (PLpgSQL_stmt_forq *) $3 ;
13061316new ->lineno =plpgsql_location_to_lineno (@2 );
1317+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
13071318new ->label = $1 ;
13081319new ->body = $4 .stmts ;
13091320$$ = (PLpgSQL_stmt *)new ;
@@ -1333,6 +1344,7 @@ for_control: for_variable K_IN
13331344
13341345new =palloc0 (sizeof (PLpgSQL_stmt_dynfors));
13351346new ->cmd_type = PLPGSQL_STMT_DYNFORS;
1347+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
13361348if ($1 .row )
13371349{
13381350new ->var = (PLpgSQL_variable *) $1 .row ;
@@ -1378,6 +1390,7 @@ for_control: for_variable K_IN
13781390
13791391new = (PLpgSQL_stmt_forc *)palloc0 (sizeof (PLpgSQL_stmt_forc));
13801392new ->cmd_type = PLPGSQL_STMT_FORC;
1393+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
13811394new ->curvar = cursor->dno ;
13821395
13831396/* Should have had a single variable name*/
@@ -1492,6 +1505,7 @@ for_control: for_variable K_IN
14921505
14931506new =palloc0 (sizeof (PLpgSQL_stmt_fori));
14941507new ->cmd_type = PLPGSQL_STMT_FORI;
1508+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
14951509new ->var = fvar;
14961510new ->reverse = reverse;
14971511new ->lower = expr1;
@@ -1526,6 +1540,7 @@ for_control: for_variable K_IN
15261540
15271541new =palloc0 (sizeof (PLpgSQL_stmt_fors));
15281542new ->cmd_type = PLPGSQL_STMT_FORS;
1543+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
15291544if ($1 .row )
15301545{
15311546new ->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
16261641new =palloc0 (sizeof (PLpgSQL_stmt_foreach_a));
16271642new ->cmd_type = PLPGSQL_STMT_FOREACH_A;
16281643new ->lineno =plpgsql_location_to_lineno (@2 );
1644+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
16291645new ->label = $1 ;
16301646new ->slice = $4 ;
16311647new ->expr = $7 ;
@@ -1672,6 +1688,7 @@ stmt_exit: exit_type opt_label opt_exitcond
16721688
16731689new =palloc0 (sizeof (PLpgSQL_stmt_exit));
16741690new ->cmd_type = PLPGSQL_STMT_EXIT;
1691+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
16751692new ->is_exit = $1 ;
16761693new ->lineno =plpgsql_location_to_lineno (@1 );
16771694new ->label = $2 ;
@@ -1763,6 +1780,7 @@ stmt_raise: K_RAISE
17631780
17641781new ->cmd_type = PLPGSQL_STMT_RAISE;
17651782new ->lineno =plpgsql_location_to_lineno (@1 );
1783+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
17661784new ->elog_level = ERROR;/* default*/
17671785new ->condname =NULL ;
17681786new ->message =NULL ;
@@ -1907,6 +1925,7 @@ stmt_assert: K_ASSERT
19071925
19081926new ->cmd_type = PLPGSQL_STMT_ASSERT;
19091927new ->lineno =plpgsql_location_to_lineno (@1 );
1928+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
19101929
19111930new ->cond =read_sql_expression2 (' ,' ,' ;' ,
19121931" , or ;" ,
@@ -1984,6 +2003,7 @@ stmt_dynexecute : K_EXECUTE
19842003new =palloc (sizeof (PLpgSQL_stmt_dynexecute));
19852004new ->cmd_type = PLPGSQL_STMT_DYNEXECUTE;
19862005new ->lineno =plpgsql_location_to_lineno (@1 );
2006+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
19872007new ->query = expr;
19882008new ->into =false ;
19892009new ->strict =false ;
@@ -2040,6 +2060,7 @@ stmt_open: K_OPEN cursor_variable
20402060new =palloc0 (sizeof (PLpgSQL_stmt_open));
20412061new ->cmd_type = PLPGSQL_STMT_OPEN;
20422062new ->lineno =plpgsql_location_to_lineno (@1 );
2063+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
20432064new ->curvar = $2 ->dno ;
20442065new ->cursor_options = CURSOR_OPT_FAST_PLAN;
20452066
@@ -2164,6 +2185,7 @@ stmt_close: K_CLOSE cursor_variable ';'
21642185new =palloc (sizeof (PLpgSQL_stmt_close));
21652186new ->cmd_type = PLPGSQL_STMT_CLOSE;
21662187new ->lineno =plpgsql_location_to_lineno (@1 );
2188+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
21672189new ->curvar = $2 ->dno ;
21682190
21692191$$ = (PLpgSQL_stmt *)new ;
@@ -2184,6 +2206,7 @@ stmt_commit: K_COMMIT ';'
21842206new =palloc (sizeof (PLpgSQL_stmt_commit));
21852207new ->cmd_type = PLPGSQL_STMT_COMMIT;
21862208new ->lineno =plpgsql_location_to_lineno (@1 );
2209+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
21872210
21882211$$ = (PLpgSQL_stmt *)new ;
21892212}
@@ -2196,6 +2219,7 @@ stmt_rollback: K_ROLLBACK ';'
21962219new =palloc (sizeof (PLpgSQL_stmt_rollback));
21972220new ->cmd_type = PLPGSQL_STMT_ROLLBACK;
21982221new ->lineno =plpgsql_location_to_lineno (@1 );
2222+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
21992223
22002224$$ = (PLpgSQL_stmt *)new ;
22012225}
@@ -2208,6 +2232,8 @@ stmt_set: K_SET
22082232new =palloc0 (sizeof (PLpgSQL_stmt_set));
22092233new ->cmd_type = PLPGSQL_STMT_SET;
22102234new ->lineno =plpgsql_location_to_lineno (@1 );
2235+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
2236+
22112237new ->expr =read_sql_stmt (" SET" );
22122238
22132239$$ = (PLpgSQL_stmt *)new ;
@@ -2219,6 +2245,7 @@ stmt_set: K_SET
22192245new =palloc0 (sizeof (PLpgSQL_stmt_set));
22202246new ->cmd_type = PLPGSQL_STMT_SET;
22212247new ->lineno =plpgsql_location_to_lineno (@1 );
2248+ new ->stmtid = ++plpgsql_curr_compile->nstatements ;
22222249new ->expr =read_sql_stmt (" RESET" );
22232250
22242251$$ = (PLpgSQL_stmt *)new ;
@@ -3000,6 +3027,7 @@ make_execsql_stmt(int firsttoken, int location)
30003027execsql = palloc(sizeof(PLpgSQL_stmt_execsql));
30013028execsql->cmd_type = PLPGSQL_STMT_EXECSQL;
30023029execsql->lineno = plpgsql_location_to_lineno(location);
3030+ execsql->stmtid = ++plpgsql_curr_compile->nstatements;
30033031execsql->sqlstmt = expr;
30043032execsql->into = have_into;
30053033execsql->strict = have_strict;
@@ -3025,6 +3053,7 @@ read_fetch_direction(void)
30253053*/
30263054fetch = (PLpgSQL_stmt_fetch *) palloc0(sizeof(PLpgSQL_stmt_fetch));
30273055fetch->cmd_type = PLPGSQL_STMT_FETCH;
3056+ fetch->stmtid= ++plpgsql_curr_compile->nstatements;
30283057/* set direction defaults:*/
30293058fetch->direction = FETCH_FORWARD;
30303059fetch->how_many = 1;
@@ -3177,6 +3206,7 @@ make_return_stmt(int location)
31773206new = palloc0(sizeof(PLpgSQL_stmt_return));
31783207new->cmd_type = PLPGSQL_STMT_RETURN;
31793208new->lineno = plpgsql_location_to_lineno(location);
3209+ new->stmtid = ++plpgsql_curr_compile->nstatements;
31803210new->expr = NULL;
31813211new->retvarno = -1;
31823212
@@ -3264,6 +3294,7 @@ make_return_next_stmt(int location)
32643294new = palloc0(sizeof(PLpgSQL_stmt_return_next));
32653295new->cmd_type= PLPGSQL_STMT_RETURN_NEXT;
32663296new->lineno= plpgsql_location_to_lineno(location);
3297+ new->stmtid= ++plpgsql_curr_compile->nstatements;
32673298new->expr= NULL;
32683299new->retvarno= -1;
32693300
@@ -3327,6 +3358,7 @@ make_return_query_stmt(int location)
33273358new = palloc0(sizeof(PLpgSQL_stmt_return_query));
33283359new->cmd_type = PLPGSQL_STMT_RETURN_QUERY;
33293360new->lineno = plpgsql_location_to_lineno(location);
3361+ new->stmtid = ++plpgsql_curr_compile->nstatements;
33303362
33313363/* check for RETURN QUERY EXECUTE*/
33323364if ((tok = yylex()) != K_EXECUTE)
@@ -3997,6 +4029,7 @@ make_case(int location, PLpgSQL_expr *t_expr,
39974029new = palloc(sizeof(PLpgSQL_stmt_case));
39984030new->cmd_type = PLPGSQL_STMT_CASE;
39994031new->lineno = plpgsql_location_to_lineno(location);
4032+ new->stmtid = ++plpgsql_curr_compile->nstatements;
40004033new->t_expr = t_expr;
40014034new->t_varno = 0;
40024035new->case_when_list = case_when_list;