Refactor exec_cast_value() and exec_simple_cast_value(): since they do
not ever write through the `isnull' parameter, it does not need to be an out parameter. Therefore it can be declared a "bool" rather than a "bool *".
This commit is contained in:
parent
525e83bea3
commit
95cbfb5c7c
@ -3,7 +3,7 @@
|
|||||||
* procedural language
|
* procedural language
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.150 2005/07/28 00:26:30 tgl Exp $
|
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.151 2005/07/28 07:51:13 neilc Exp $
|
||||||
*
|
*
|
||||||
* This software is copyrighted by Jan Wieck - Hamburg.
|
* This software is copyrighted by Jan Wieck - Hamburg.
|
||||||
*
|
*
|
||||||
@ -173,10 +173,10 @@ static Datum exec_cast_value(Datum value, Oid valtype,
|
|||||||
FmgrInfo *reqinput,
|
FmgrInfo *reqinput,
|
||||||
Oid reqtypioparam,
|
Oid reqtypioparam,
|
||||||
int32 reqtypmod,
|
int32 reqtypmod,
|
||||||
bool *isnull);
|
bool isnull);
|
||||||
static Datum exec_simple_cast_value(Datum value, Oid valtype,
|
static Datum exec_simple_cast_value(Datum value, Oid valtype,
|
||||||
Oid reqtype, int32 reqtypmod,
|
Oid reqtype, int32 reqtypmod,
|
||||||
bool *isnull);
|
bool isnull);
|
||||||
static void exec_init_tuple_store(PLpgSQL_execstate *estate);
|
static void exec_init_tuple_store(PLpgSQL_execstate *estate);
|
||||||
static bool compatible_tupdesc(TupleDesc td1, TupleDesc td2);
|
static bool compatible_tupdesc(TupleDesc td1, TupleDesc td2);
|
||||||
static void exec_set_found(PLpgSQL_execstate *estate, bool state);
|
static void exec_set_found(PLpgSQL_execstate *estate, bool state);
|
||||||
@ -356,7 +356,7 @@ plpgsql_exec_function(PLpgSQL_function *func, FunctionCallInfo fcinfo)
|
|||||||
&(func->fn_retinput),
|
&(func->fn_retinput),
|
||||||
func->fn_rettypioparam,
|
func->fn_rettypioparam,
|
||||||
-1,
|
-1,
|
||||||
&fcinfo->isnull);
|
fcinfo->isnull);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the function's return type isn't by value, copy the value
|
* If the function's return type isn't by value, copy the value
|
||||||
@ -1348,7 +1348,7 @@ exec_stmt_fori(PLpgSQL_execstate *estate, PLpgSQL_stmt_fori *stmt)
|
|||||||
value = exec_cast_value(value, valtype, var->datatype->typoid,
|
value = exec_cast_value(value, valtype, var->datatype->typoid,
|
||||||
&(var->datatype->typinput),
|
&(var->datatype->typinput),
|
||||||
var->datatype->typioparam,
|
var->datatype->typioparam,
|
||||||
var->datatype->atttypmod, &isnull);
|
var->datatype->atttypmod, isnull);
|
||||||
if (isnull)
|
if (isnull)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
|
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
|
||||||
@ -1364,7 +1364,7 @@ exec_stmt_fori(PLpgSQL_execstate *estate, PLpgSQL_stmt_fori *stmt)
|
|||||||
value = exec_cast_value(value, valtype, var->datatype->typoid,
|
value = exec_cast_value(value, valtype, var->datatype->typoid,
|
||||||
&(var->datatype->typinput),
|
&(var->datatype->typinput),
|
||||||
var->datatype->typioparam,
|
var->datatype->typioparam,
|
||||||
var->datatype->atttypmod, &isnull);
|
var->datatype->atttypmod, isnull);
|
||||||
if (isnull)
|
if (isnull)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
|
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
|
||||||
@ -1868,7 +1868,7 @@ exec_stmt_return_next(PLpgSQL_execstate *estate,
|
|||||||
var->datatype->typoid,
|
var->datatype->typoid,
|
||||||
tupdesc->attrs[0]->atttypid,
|
tupdesc->attrs[0]->atttypid,
|
||||||
tupdesc->attrs[0]->atttypmod,
|
tupdesc->attrs[0]->atttypmod,
|
||||||
&isNull);
|
isNull);
|
||||||
|
|
||||||
tuple = heap_form_tuple(tupdesc, &retval, &isNull);
|
tuple = heap_form_tuple(tupdesc, &retval, &isNull);
|
||||||
|
|
||||||
@ -1934,7 +1934,7 @@ exec_stmt_return_next(PLpgSQL_execstate *estate,
|
|||||||
rettype,
|
rettype,
|
||||||
tupdesc->attrs[0]->atttypid,
|
tupdesc->attrs[0]->atttypid,
|
||||||
tupdesc->attrs[0]->atttypmod,
|
tupdesc->attrs[0]->atttypmod,
|
||||||
&isNull);
|
isNull);
|
||||||
|
|
||||||
tuple = heap_form_tuple(tupdesc, &retval, &isNull);
|
tuple = heap_form_tuple(tupdesc, &retval, &isNull);
|
||||||
|
|
||||||
@ -2995,7 +2995,7 @@ exec_assign_value(PLpgSQL_execstate *estate,
|
|||||||
&(var->datatype->typinput),
|
&(var->datatype->typinput),
|
||||||
var->datatype->typioparam,
|
var->datatype->typioparam,
|
||||||
var->datatype->atttypmod,
|
var->datatype->atttypmod,
|
||||||
isNull);
|
*isNull);
|
||||||
|
|
||||||
if (*isNull && var->notnull)
|
if (*isNull && var->notnull)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -3194,7 +3194,7 @@ exec_assign_value(PLpgSQL_execstate *estate,
|
|||||||
valtype,
|
valtype,
|
||||||
atttype,
|
atttype,
|
||||||
atttypmod,
|
atttypmod,
|
||||||
&attisnull);
|
attisnull);
|
||||||
if (attisnull)
|
if (attisnull)
|
||||||
nulls[fno] = 'n';
|
nulls[fno] = 'n';
|
||||||
else
|
else
|
||||||
@ -3340,7 +3340,7 @@ exec_assign_value(PLpgSQL_execstate *estate,
|
|||||||
valtype,
|
valtype,
|
||||||
arrayelemtypeid,
|
arrayelemtypeid,
|
||||||
-1,
|
-1,
|
||||||
isNull);
|
*isNull);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Build the modified array value.
|
* Build the modified array value.
|
||||||
@ -3564,7 +3564,7 @@ exec_eval_integer(PLpgSQL_execstate *estate,
|
|||||||
exprdatum = exec_eval_expr(estate, expr, isNull, &exprtypeid);
|
exprdatum = exec_eval_expr(estate, expr, isNull, &exprtypeid);
|
||||||
exprdatum = exec_simple_cast_value(exprdatum, exprtypeid,
|
exprdatum = exec_simple_cast_value(exprdatum, exprtypeid,
|
||||||
INT4OID, -1,
|
INT4OID, -1,
|
||||||
isNull);
|
*isNull);
|
||||||
return DatumGetInt32(exprdatum);
|
return DatumGetInt32(exprdatum);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3586,7 +3586,7 @@ exec_eval_boolean(PLpgSQL_execstate *estate,
|
|||||||
exprdatum = exec_eval_expr(estate, expr, isNull, &exprtypeid);
|
exprdatum = exec_eval_expr(estate, expr, isNull, &exprtypeid);
|
||||||
exprdatum = exec_simple_cast_value(exprdatum, exprtypeid,
|
exprdatum = exec_simple_cast_value(exprdatum, exprtypeid,
|
||||||
BOOLOID, -1,
|
BOOLOID, -1,
|
||||||
isNull);
|
*isNull);
|
||||||
return DatumGetBool(exprdatum);
|
return DatumGetBool(exprdatum);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4060,9 +4060,9 @@ exec_cast_value(Datum value, Oid valtype,
|
|||||||
FmgrInfo *reqinput,
|
FmgrInfo *reqinput,
|
||||||
Oid reqtypioparam,
|
Oid reqtypioparam,
|
||||||
int32 reqtypmod,
|
int32 reqtypmod,
|
||||||
bool *isnull)
|
bool isnull)
|
||||||
{
|
{
|
||||||
if (!*isnull)
|
if (!isnull)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* If the type of the queries return value isn't that of the
|
* If the type of the queries return value isn't that of the
|
||||||
@ -4095,9 +4095,9 @@ exec_cast_value(Datum value, Oid valtype,
|
|||||||
static Datum
|
static Datum
|
||||||
exec_simple_cast_value(Datum value, Oid valtype,
|
exec_simple_cast_value(Datum value, Oid valtype,
|
||||||
Oid reqtype, int32 reqtypmod,
|
Oid reqtype, int32 reqtypmod,
|
||||||
bool *isnull)
|
bool isnull)
|
||||||
{
|
{
|
||||||
if (!*isnull)
|
if (!isnull)
|
||||||
{
|
{
|
||||||
if (valtype != reqtype || reqtypmod != -1)
|
if (valtype != reqtype || reqtypmod != -1)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user