summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2012-03-22 14:13:17 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2012-03-22 14:14:20 -0400
commit38350a496509d6aa4dc481b1f9f143a136e4c661 (patch)
tree5b28a339fe8326a1032f2241193365a79cebd4d5
parent596e16320e9638d46ae640b6fddde6cf9cadb93c (diff)
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.
-rw-r--r--src/pl/plpgsql/src/pl_exec.c10
1 files changed, 1 insertions, 9 deletions
diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c
index 8e8c85781ff..ad0441b5d5b 100644
--- a/src/pl/plpgsql/src/pl_exec.c
+++ b/src/pl/plpgsql/src/pl_exec.c
@@ -1351,17 +1351,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: