Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 682b128

Browse files
committed
Fix NOT NULL option for plpgsql variables (doesn't look like it
could ever have worked...)
1 parent 0ad5e43 commit 682b128

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/pl/plpgsql/src/pl_exec.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* procedural language
44
*
55
* IDENTIFICATION
6-
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.34 2001/01/04 02:38:02 tgl Exp $
6+
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.35 2001/01/06 01:43:01 tgl Exp $
77
*
88
* This software is copyrighted by Jan Wieck - Hamburg.
99
*
@@ -2210,6 +2210,7 @@ exec_assign_value(PLpgSQL_execstate * estate,
22102210
int natts;
22112211
Datum *values;
22122212
char *nulls;
2213+
Datum newvalue;
22132214
bool attisnull;
22142215
Oid atttype;
22152216
int32 atttypmod;
@@ -2225,15 +2226,16 @@ exec_assign_value(PLpgSQL_execstate * estate,
22252226
* ----------
22262227
*/
22272228
var = (PLpgSQL_var *) target;
2228-
var->value = exec_cast_value(value, valtype, var->datatype->typoid,
2229-
&(var->datatype->typinput),
2230-
var->datatype->typelem,
2231-
var->datatype->atttypmod,
2232-
isNull);
2229+
newvalue = exec_cast_value(value, valtype, var->datatype->typoid,
2230+
&(var->datatype->typinput),
2231+
var->datatype->typelem,
2232+
var->datatype->atttypmod,
2233+
isNull);
22332234

2234-
if (isNull && var->notnull)
2235+
if (*isNull && var->notnull)
22352236
elog(ERROR, "NULL assignment to variable '%s' declared NOT NULL", var->refname);
22362237

2238+
var->value = newvalue;
22372239
var->isnull = *isNull;
22382240
break;
22392241

0 commit comments

Comments
 (0)