1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00

Change CREATE TYPE to require datatype output and send functions to have

only one argument.  (Per recent discussion, the option to accept multiple
arguments is pretty useless for user-defined types, and would be a likely
source of security holes if it was used.)  Simplify call sites of
output/send functions to not bother passing more than one argument.
This commit is contained in:
Tom Lane
2005-05-01 18:56:19 +00:00
parent ae793ff63c
commit 6c412f0605
18 changed files with 102 additions and 216 deletions

View File

@@ -33,7 +33,7 @@
* ENHANCEMENTS, OR MODIFICATIONS.
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.71 2005/04/01 19:34:06 tgl Exp $
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.72 2005/05/01 18:56:19 tgl Exp $
*
**********************************************************************/
@@ -83,7 +83,6 @@ typedef struct plperl_proc_desc
Oid result_typioparam;
int nargs;
FmgrInfo arg_out_func[FUNC_MAX_ARGS];
Oid arg_typioparam[FUNC_MAX_ARGS];
bool arg_is_rowtype[FUNC_MAX_ARGS];
SV *reference;
} plperl_proc_desc;
@@ -707,10 +706,8 @@ plperl_call_perl_func(plperl_proc_desc *desc, FunctionCallInfo fcinfo)
{
char *tmp;
tmp = DatumGetCString(FunctionCall3(&(desc->arg_out_func[i]),
fcinfo->arg[i],
ObjectIdGetDatum(desc->arg_typioparam[i]),
Int32GetDatum(-1)));
tmp = DatumGetCString(FunctionCall1(&(desc->arg_out_func[i]),
fcinfo->arg[i]));
XPUSHs(sv_2mortal(newSVpv(tmp, 0)));
pfree(tmp);
}
@@ -1322,7 +1319,6 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
prodesc->arg_is_rowtype[i] = false;
perm_fmgr_info(typeStruct->typoutput,
&(prodesc->arg_out_func[i]));
prodesc->arg_typioparam[i] = getTypeIOParam(typeTup);
}
ReleaseSysCache(typeTup);
@@ -1386,7 +1382,6 @@ plperl_hash_from_tuple(HeapTuple tuple, TupleDesc tupdesc)
char *attname;
char *outputstr;
Oid typoutput;
Oid typioparam;
bool typisvarlena;
int namelen;
@@ -1406,12 +1401,10 @@ plperl_hash_from_tuple(HeapTuple tuple, TupleDesc tupdesc)
/* XXX should have a way to cache these lookups */
getTypeOutputInfo(tupdesc->attrs[i]->atttypid,
&typoutput, &typioparam, &typisvarlena);
&typoutput, &typisvarlena);
outputstr = DatumGetCString(OidFunctionCall3(typoutput,
attr,
ObjectIdGetDatum(typioparam),
Int32GetDatum(tupdesc->attrs[i]->atttypmod)));
outputstr = DatumGetCString(OidFunctionCall1(typoutput,
attr));
hv_store(hv, attname, namelen, newSVpv(outputstr, 0), 0);
}

View File

@@ -3,7 +3,7 @@
* procedural language
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.135 2005/04/07 14:53:04 tgl Exp $
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.136 2005/05/01 18:56:19 tgl Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
@@ -3881,15 +3881,11 @@ static char *
convert_value_to_string(Datum value, Oid valtype)
{
Oid typoutput;
Oid typioparam;
bool typIsVarlena;
getTypeOutputInfo(valtype, &typoutput, &typioparam, &typIsVarlena);
getTypeOutputInfo(valtype, &typoutput, &typIsVarlena);
return DatumGetCString(OidFunctionCall3(typoutput,
value,
ObjectIdGetDatum(typioparam),
Int32GetDatum(-1)));
return DatumGetCString(OidFunctionCall1(typoutput, value));
}
/* ----------

View File

@@ -31,7 +31,7 @@
* ENHANCEMENTS, OR MODIFICATIONS.
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.95 2005/03/29 00:17:25 tgl Exp $
* $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.96 2005/05/01 18:56:19 tgl Exp $
*
**********************************************************************/
@@ -112,7 +112,6 @@ typedef struct pltcl_proc_desc
Oid result_typioparam;
int nargs;
FmgrInfo arg_out_func[FUNC_MAX_ARGS];
Oid arg_typioparam[FUNC_MAX_ARGS];
bool arg_is_rowtype[FUNC_MAX_ARGS];
} pltcl_proc_desc;
@@ -555,10 +554,8 @@ pltcl_func_handler(PG_FUNCTION_ARGS)
{
char *tmp;
tmp = DatumGetCString(FunctionCall3(&prodesc->arg_out_func[i],
fcinfo->arg[i],
ObjectIdGetDatum(prodesc->arg_typioparam[i]),
Int32GetDatum(-1)));
tmp = DatumGetCString(FunctionCall1(&prodesc->arg_out_func[i],
fcinfo->arg[i]));
UTF_BEGIN;
Tcl_DStringAppendElement(&tcl_cmd, UTF_E2U(tmp));
UTF_END;
@@ -1160,7 +1157,6 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid)
prodesc->arg_is_rowtype[i] = false;
perm_fmgr_info(typeStruct->typoutput,
&(prodesc->arg_out_func[i]));
prodesc->arg_typioparam[i] = getTypeIOParam(typeTup);
snprintf(buf, sizeof(buf), "%d", i + 1);
}
@@ -2172,7 +2168,6 @@ pltcl_set_tuple_values(Tcl_Interp *interp, CONST84 char *arrayname,
CONST84 char *attname;
HeapTuple typeTup;
Oid typoutput;
Oid typioparam;
CONST84 char **arrptr;
CONST84 char **nameptr;
@@ -2223,7 +2218,6 @@ pltcl_set_tuple_values(Tcl_Interp *interp, CONST84 char *arrayname,
tupdesc->attrs[i]->atttypid);
typoutput = ((Form_pg_type) GETSTRUCT(typeTup))->typoutput;
typioparam = getTypeIOParam(typeTup);
ReleaseSysCache(typeTup);
/************************************************************
@@ -2236,10 +2230,8 @@ pltcl_set_tuple_values(Tcl_Interp *interp, CONST84 char *arrayname,
************************************************************/
if (!isnull && OidIsValid(typoutput))
{
outputstr = DatumGetCString(OidFunctionCall3(typoutput,
attr,
ObjectIdGetDatum(typioparam),
Int32GetDatum(tupdesc->attrs[i]->atttypmod)));
outputstr = DatumGetCString(OidFunctionCall1(typoutput,
attr));
UTF_BEGIN;
Tcl_SetVar2(interp, *arrptr, *nameptr, UTF_E2U(outputstr), 0);
UTF_END;
@@ -2267,7 +2259,6 @@ pltcl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc,
char *attname;
HeapTuple typeTup;
Oid typoutput;
Oid typioparam;
for (i = 0; i < tupdesc->natts; i++)
{
@@ -2297,7 +2288,6 @@ pltcl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc,
tupdesc->attrs[i]->atttypid);
typoutput = ((Form_pg_type) GETSTRUCT(typeTup))->typoutput;
typioparam = getTypeIOParam(typeTup);
ReleaseSysCache(typeTup);
/************************************************************
@@ -2310,10 +2300,8 @@ pltcl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc,
************************************************************/
if (!isnull && OidIsValid(typoutput))
{
outputstr = DatumGetCString(OidFunctionCall3(typoutput,
attr,
ObjectIdGetDatum(typioparam),
Int32GetDatum(tupdesc->attrs[i]->atttypmod)));
outputstr = DatumGetCString(OidFunctionCall1(typoutput,
attr));
Tcl_DStringAppendElement(retval, attname);
UTF_BEGIN;
Tcl_DStringAppendElement(retval, UTF_E2U(outputstr));