Hi

When I fixed one plpgsql_check issue, I found another plpgsql issue. Now we
have field nstatements that hold a number of plpgsql statements in
function. Unfortunately I made an error when I wrote this functionality and
for FOR statements, this counter is incremented 2x. Higher number than a
real number is better than a lesser number, but it can be a source of
problems too (inside plpgsql_check I iterate over 0 .. nstatements stmtid,
and due this bug I had a problem with missing statements).

Attached patch is pretty simple:

Regards

Pavel
diff --git a/src/pl/plpgsql/src/pl_gram.y b/src/pl/plpgsql/src/pl_gram.y
index abf196d4be..34e0520719 100644
--- a/src/pl/plpgsql/src/pl_gram.y
+++ b/src/pl/plpgsql/src/pl_gram.y
@@ -1341,7 +1341,6 @@ stmt_for		: opt_loop_label K_FOR for_control loop_body
 
 							new = (PLpgSQL_stmt_fori *) $3;
 							new->lineno   = plpgsql_location_to_lineno(@2);
-							new->stmtid	  = ++plpgsql_curr_compile->nstatements;
 							new->label	  = $1;
 							new->body	  = $4.stmts;
 							$$ = (PLpgSQL_stmt *) new;
@@ -1356,7 +1355,6 @@ stmt_for		: opt_loop_label K_FOR for_control loop_body
 							/* forq is the common supertype of all three */
 							new = (PLpgSQL_stmt_forq *) $3;
 							new->lineno   = plpgsql_location_to_lineno(@2);
-							new->stmtid	  = ++plpgsql_curr_compile->nstatements;
 							new->label	  = $1;
 							new->body	  = $4.stmts;
 							$$ = (PLpgSQL_stmt *) new;

Reply via email to