postgres.git / summary / log / commit / refs
commit f318ee848c9a7c3dd289fe67245e4a12ba136bca
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: Thu Mar 22 18:13:17 2012 +0000
First released in: 9.2.0, 8.3.19, 8.4.12, 9.0.8, 9.1.4
Fix GET DIAGNOSTICS for case of assignment to function's first variable.
An incorrect and entirely unnecessary "safety check" in exec_stmt_getdiag()
caused the code to treat an assignment to a variable with dno zero as a
no-op. Unfortunately, that's a perfectly valid dno. This has been broken
since GET DIAGNOSTICS was invented. It's not terribly surprising that the
bug went unnoticed for so long, since in most cases you probably wouldn't
use the function's first-created variable (normally its first parameter)
as a GET DIAGNOSTICS target. Nonetheless, it's broken. Per bug #6551
from Adam Buraczewski.
src/pl/plpgsql/src/pl_exec.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c
index 2ad4bed0b6d..7f911b87710 100644
--- a/src/pl/plpgsql/src/pl_exec.c
+++ b/src/pl/plpgsql/src/pl_exec.c
@@ -1430,17 +1430,9 @@ exec_stmt_getdiag(PLpgSQL_execstate *estate, PLpgSQL_stmt_getdiag *stmt)
foreach(lc, stmt->diag_items)
{
PLpgSQL_diag_item *diag_item = (PLpgSQL_diag_item *) lfirst(lc);
- PLpgSQL_datum *var;
+ PLpgSQL_datum *var = estate->datums[diag_item->target];
bool isnull = false;
- if (diag_item->target <= 0)
- continue;
-
- var = estate->datums[diag_item->target];
-
- if (var == NULL)
- continue;
-
switch (diag_item->kind)
{
case PLPGSQL_GETDIAG_ROW_COUNT:
[parent: 5bd06e619c82]