diff options
-rw-r--r-- | src/pl/plpgsql/src/pl_exec.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c index 1071521d23b..147284aa1e9 100644 --- a/src/pl/plpgsql/src/pl_exec.c +++ b/src/pl/plpgsql/src/pl_exec.c @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.127.4.6 2007/01/30 18:02:40 tgl Exp $ + * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.127.4.7 2007/02/08 18:38:08 tgl Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -866,29 +866,29 @@ exec_stmt_block(PLpgSQL_execstate *estate, PLpgSQL_stmt_block *block) { PLpgSQL_var *var = (PLpgSQL_var *) (estate->datums[n]); + /* free any old value, in case re-entering block */ if (var->freeval) { pfree((void *) (var->value)); var->freeval = false; } - if (!var->isconst || var->isnull) + /* Initially it contains a NULL */ + var->value = (Datum) 0; + var->isnull = true; + + if (var->default_val == NULL) + { + if (var->notnull) + ereport(ERROR, + (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), + errmsg("variable \"%s\" declared NOT NULL cannot default to NULL", + var->refname))); + } + else { - if (var->default_val == NULL) - { - var->value = (Datum) 0; - var->isnull = true; - if (var->notnull) - ereport(ERROR, - (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), - errmsg("variable \"%s\" declared NOT NULL cannot default to NULL", - var->refname))); - } - else - { - exec_assign_expr(estate, (PLpgSQL_datum *) var, - var->default_val); - } + exec_assign_expr(estate, (PLpgSQL_datum *) var, + var->default_val); } } break; |