mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Infrastructure for I/O of composite types: arrange for the I/O routines
of a composite type to get that type's OID as their second parameter, in place of typelem which is useless. The actual changes are mostly centralized in getTypeInputInfo and siblings, but I had to fix a few places that were fetching pg_type.typelem for themselves instead of using the lsyscache.c routines. Also, I renamed all the related variables from 'typelem' to 'typioparam' to discourage people from assuming that they necessarily contain array element types.
This commit is contained in:
@@ -33,7 +33,7 @@
|
||||
* ENHANCEMENTS, OR MODIFICATIONS.
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.43 2004/04/01 21:28:46 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.44 2004/06/06 00:41:28 tgl Exp $
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
@@ -79,10 +79,10 @@ typedef struct plperl_proc_desc
|
||||
CommandId fn_cmin;
|
||||
bool lanpltrusted;
|
||||
FmgrInfo result_in_func;
|
||||
Oid result_in_elem;
|
||||
Oid result_typioparam;
|
||||
int nargs;
|
||||
FmgrInfo arg_out_func[FUNC_MAX_ARGS];
|
||||
Oid arg_out_elem[FUNC_MAX_ARGS];
|
||||
Oid arg_typioparam[FUNC_MAX_ARGS];
|
||||
bool arg_is_rowtype[FUNC_MAX_ARGS];
|
||||
SV *reference;
|
||||
} plperl_proc_desc;
|
||||
@@ -428,7 +428,7 @@ plperl_call_perl_func(plperl_proc_desc * desc, FunctionCallInfo fcinfo)
|
||||
|
||||
tmp = DatumGetCString(FunctionCall3(&(desc->arg_out_func[i]),
|
||||
fcinfo->arg[i],
|
||||
ObjectIdGetDatum(desc->arg_out_elem[i]),
|
||||
ObjectIdGetDatum(desc->arg_typioparam[i]),
|
||||
Int32GetDatum(-1)));
|
||||
XPUSHs(sv_2mortal(newSVpv(tmp, 0)));
|
||||
pfree(tmp);
|
||||
@@ -506,7 +506,7 @@ plperl_func_handler(PG_FUNCTION_ARGS)
|
||||
{
|
||||
retval = FunctionCall3(&prodesc->result_in_func,
|
||||
PointerGetDatum(SvPV(perlret, PL_na)),
|
||||
ObjectIdGetDatum(prodesc->result_in_elem),
|
||||
ObjectIdGetDatum(prodesc->result_typioparam),
|
||||
Int32GetDatum(-1));
|
||||
}
|
||||
|
||||
@@ -671,7 +671,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
|
||||
}
|
||||
|
||||
perm_fmgr_info(typeStruct->typinput, &(prodesc->result_in_func));
|
||||
prodesc->result_in_elem = typeStruct->typelem;
|
||||
prodesc->result_typioparam = getTypeIOParam(typeTup);
|
||||
|
||||
ReleaseSysCache(typeTup);
|
||||
}
|
||||
@@ -715,7 +715,7 @@ 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_out_elem[i] = typeStruct->typelem;
|
||||
prodesc->arg_typioparam[i] = getTypeIOParam(typeTup);
|
||||
}
|
||||
|
||||
ReleaseSysCache(typeTup);
|
||||
@@ -776,7 +776,7 @@ plperl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc)
|
||||
char *outputstr;
|
||||
HeapTuple typeTup;
|
||||
Oid typoutput;
|
||||
Oid typelem;
|
||||
Oid typioparam;
|
||||
|
||||
output = sv_2mortal(newSVpv("{", 0));
|
||||
|
||||
@@ -817,7 +817,7 @@ plperl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc)
|
||||
tupdesc->attrs[i]->atttypid);
|
||||
|
||||
typoutput = ((Form_pg_type) GETSTRUCT(typeTup))->typoutput;
|
||||
typelem = ((Form_pg_type) GETSTRUCT(typeTup))->typelem;
|
||||
typioparam = getTypeIOParam(typeTup);
|
||||
ReleaseSysCache(typeTup);
|
||||
|
||||
/************************************************************
|
||||
@@ -825,7 +825,7 @@ plperl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc)
|
||||
************************************************************/
|
||||
outputstr = DatumGetCString(OidFunctionCall3(typoutput,
|
||||
attr,
|
||||
ObjectIdGetDatum(typelem),
|
||||
ObjectIdGetDatum(typioparam),
|
||||
Int32GetDatum(tupdesc->attrs[i]->atttypmod)));
|
||||
sv_catpvf(output, "'%s' => '%s',", attname, outputstr);
|
||||
pfree(outputstr);
|
||||
|
@@ -3,7 +3,7 @@
|
||||
* procedural language
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.76 2004/06/03 22:56:43 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.77 2004/06/06 00:41:28 tgl Exp $
|
||||
*
|
||||
* This software is copyrighted by Jan Wieck - Hamburg.
|
||||
*
|
||||
@@ -383,7 +383,7 @@ do_compile(FunctionCallInfo fcinfo,
|
||||
{
|
||||
function->fn_retbyval = typeStruct->typbyval;
|
||||
function->fn_rettyplen = typeStruct->typlen;
|
||||
function->fn_rettypelem = typeStruct->typelem;
|
||||
function->fn_rettypioparam = getTypeIOParam(typeTup);
|
||||
perm_fmgr_info(typeStruct->typinput, &(function->fn_retinput));
|
||||
|
||||
/*
|
||||
@@ -1704,7 +1704,7 @@ build_datatype(HeapTuple typeTup, int32 typmod)
|
||||
typ->typlen = typeStruct->typlen;
|
||||
typ->typbyval = typeStruct->typbyval;
|
||||
typ->typrelid = typeStruct->typrelid;
|
||||
typ->typelem = typeStruct->typelem;
|
||||
typ->typioparam = getTypeIOParam(typeTup);
|
||||
perm_fmgr_info(typeStruct->typinput, &(typ->typinput));
|
||||
typ->atttypmod = typmod;
|
||||
|
||||
|
@@ -3,7 +3,7 @@
|
||||
* procedural language
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.105 2004/06/05 19:48:09 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.106 2004/06/06 00:41:28 tgl Exp $
|
||||
*
|
||||
* This software is copyrighted by Jan Wieck - Hamburg.
|
||||
*
|
||||
@@ -171,7 +171,7 @@ static char *convert_value_to_string(Datum value, Oid valtype);
|
||||
static Datum exec_cast_value(Datum value, Oid valtype,
|
||||
Oid reqtype,
|
||||
FmgrInfo *reqinput,
|
||||
Oid reqtypelem,
|
||||
Oid reqtypioparam,
|
||||
int32 reqtypmod,
|
||||
bool *isnull);
|
||||
static Datum exec_simple_cast_value(Datum value, Oid valtype,
|
||||
@@ -393,7 +393,7 @@ plpgsql_exec_function(PLpgSQL_function * func, FunctionCallInfo fcinfo)
|
||||
estate.retval = exec_cast_value(estate.retval, estate.rettype,
|
||||
func->fn_rettype,
|
||||
&(func->fn_retinput),
|
||||
func->fn_rettypelem,
|
||||
func->fn_rettypioparam,
|
||||
-1,
|
||||
&fcinfo->isnull);
|
||||
|
||||
@@ -1268,7 +1268,7 @@ exec_stmt_fori(PLpgSQL_execstate * estate, PLpgSQL_stmt_fori * stmt)
|
||||
value = exec_eval_expr(estate, stmt->lower, &isnull, &valtype);
|
||||
value = exec_cast_value(value, valtype, var->datatype->typoid,
|
||||
&(var->datatype->typinput),
|
||||
var->datatype->typelem,
|
||||
var->datatype->typioparam,
|
||||
var->datatype->atttypmod, &isnull);
|
||||
if (isnull)
|
||||
ereport(ERROR,
|
||||
@@ -1284,7 +1284,7 @@ exec_stmt_fori(PLpgSQL_execstate * estate, PLpgSQL_stmt_fori * stmt)
|
||||
value = exec_eval_expr(estate, stmt->upper, &isnull, &valtype);
|
||||
value = exec_cast_value(value, valtype, var->datatype->typoid,
|
||||
&(var->datatype->typinput),
|
||||
var->datatype->typelem,
|
||||
var->datatype->typioparam,
|
||||
var->datatype->atttypmod, &isnull);
|
||||
if (isnull)
|
||||
ereport(ERROR,
|
||||
@@ -2674,7 +2674,7 @@ exec_assign_value(PLpgSQL_execstate * estate,
|
||||
|
||||
newvalue = exec_cast_value(value, valtype, var->datatype->typoid,
|
||||
&(var->datatype->typinput),
|
||||
var->datatype->typelem,
|
||||
var->datatype->typioparam,
|
||||
var->datatype->atttypmod,
|
||||
isNull);
|
||||
|
||||
@@ -2917,8 +2917,7 @@ exec_assign_value(PLpgSQL_execstate * estate,
|
||||
bool havenullsubscript,
|
||||
oldarrayisnull;
|
||||
Oid arraytypeid,
|
||||
arrayelemtypeid,
|
||||
arrayInputFn;
|
||||
arrayelemtypeid;
|
||||
int16 elemtyplen;
|
||||
bool elemtypbyval;
|
||||
char elemtypalign;
|
||||
@@ -2954,7 +2953,7 @@ exec_assign_value(PLpgSQL_execstate * estate,
|
||||
exec_eval_datum(estate, target, InvalidOid,
|
||||
&arraytypeid, &oldarrayval, &oldarrayisnull);
|
||||
|
||||
getTypeInputInfo(arraytypeid, &arrayInputFn, &arrayelemtypeid);
|
||||
arrayelemtypeid = get_element_type(arraytypeid);
|
||||
if (!OidIsValid(arrayelemtypeid))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
@@ -3672,19 +3671,16 @@ make_tuple_from_row(PLpgSQL_execstate * estate,
|
||||
static char *
|
||||
convert_value_to_string(Datum value, Oid valtype)
|
||||
{
|
||||
Oid typOutput;
|
||||
Oid typElem;
|
||||
Oid typoutput;
|
||||
Oid typioparam;
|
||||
bool typIsVarlena;
|
||||
FmgrInfo finfo_output;
|
||||
|
||||
getTypeOutputInfo(valtype, &typOutput, &typElem, &typIsVarlena);
|
||||
getTypeOutputInfo(valtype, &typoutput, &typioparam, &typIsVarlena);
|
||||
|
||||
fmgr_info(typOutput, &finfo_output);
|
||||
|
||||
return DatumGetCString(FunctionCall3(&finfo_output,
|
||||
value,
|
||||
ObjectIdGetDatum(typElem),
|
||||
Int32GetDatum(-1)));
|
||||
return DatumGetCString(OidFunctionCall3(typoutput,
|
||||
value,
|
||||
ObjectIdGetDatum(typioparam),
|
||||
Int32GetDatum(-1)));
|
||||
}
|
||||
|
||||
/* ----------
|
||||
@@ -3695,7 +3691,7 @@ static Datum
|
||||
exec_cast_value(Datum value, Oid valtype,
|
||||
Oid reqtype,
|
||||
FmgrInfo *reqinput,
|
||||
Oid reqtypelem,
|
||||
Oid reqtypioparam,
|
||||
int32 reqtypmod,
|
||||
bool *isnull)
|
||||
{
|
||||
@@ -3712,7 +3708,7 @@ exec_cast_value(Datum value, Oid valtype,
|
||||
extval = convert_value_to_string(value, valtype);
|
||||
value = FunctionCall3(reqinput,
|
||||
CStringGetDatum(extval),
|
||||
ObjectIdGetDatum(reqtypelem),
|
||||
ObjectIdGetDatum(reqtypioparam),
|
||||
Int32GetDatum(reqtypmod));
|
||||
pfree(extval);
|
||||
}
|
||||
@@ -3738,19 +3734,19 @@ exec_simple_cast_value(Datum value, Oid valtype,
|
||||
{
|
||||
if (valtype != reqtype || reqtypmod != -1)
|
||||
{
|
||||
Oid typInput;
|
||||
Oid typElem;
|
||||
Oid typinput;
|
||||
Oid typioparam;
|
||||
FmgrInfo finfo_input;
|
||||
|
||||
getTypeInputInfo(reqtype, &typInput, &typElem);
|
||||
getTypeInputInfo(reqtype, &typinput, &typioparam);
|
||||
|
||||
fmgr_info(typInput, &finfo_input);
|
||||
fmgr_info(typinput, &finfo_input);
|
||||
|
||||
value = exec_cast_value(value,
|
||||
valtype,
|
||||
reqtype,
|
||||
&finfo_input,
|
||||
typElem,
|
||||
typioparam,
|
||||
reqtypmod,
|
||||
isnull);
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@
|
||||
* procedural language
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.46 2004/06/03 22:56:43 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.47 2004/06/06 00:41:28 tgl Exp $
|
||||
*
|
||||
* This software is copyrighted by Jan Wieck - Hamburg.
|
||||
*
|
||||
@@ -160,7 +160,7 @@ typedef struct
|
||||
int16 typlen; /* stuff copied from its pg_type entry */
|
||||
bool typbyval;
|
||||
Oid typrelid;
|
||||
Oid typelem;
|
||||
Oid typioparam;
|
||||
FmgrInfo typinput; /* lookup info for typinput function */
|
||||
int32 atttypmod; /* typmod (taken from someplace else) */
|
||||
} PLpgSQL_type;
|
||||
@@ -557,7 +557,7 @@ typedef struct PLpgSQL_function
|
||||
int fn_rettyplen;
|
||||
bool fn_retbyval;
|
||||
FmgrInfo fn_retinput;
|
||||
Oid fn_rettypelem;
|
||||
Oid fn_rettypioparam;
|
||||
bool fn_retistuple;
|
||||
bool fn_retset;
|
||||
|
||||
|
@@ -29,7 +29,7 @@
|
||||
* MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.48 2004/06/05 19:48:09 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.49 2004/06/06 00:41:28 tgl Exp $
|
||||
*
|
||||
*********************************************************************
|
||||
*/
|
||||
@@ -51,6 +51,7 @@
|
||||
#include "nodes/makefuncs.h"
|
||||
#include "parser/parse_type.h"
|
||||
#include "tcop/tcopprot.h"
|
||||
#include "utils/lsyscache.h"
|
||||
#include "utils/syscache.h"
|
||||
#include "utils/typcache.h"
|
||||
|
||||
@@ -70,7 +71,7 @@ typedef struct PLyDatumToOb
|
||||
{
|
||||
PLyDatumToObFunc func;
|
||||
FmgrInfo typfunc;
|
||||
Oid typelem;
|
||||
Oid typioparam;
|
||||
bool typbyval;
|
||||
} PLyDatumToOb;
|
||||
|
||||
@@ -92,7 +93,7 @@ typedef union PLyTypeInput
|
||||
typedef struct PLyObToDatum
|
||||
{
|
||||
FmgrInfo typfunc;
|
||||
Oid typelem;
|
||||
Oid typioparam;
|
||||
bool typbyval;
|
||||
} PLyObToDatum;
|
||||
|
||||
@@ -238,10 +239,10 @@ static void PLy_procedure_delete(PLyProcedure *);
|
||||
|
||||
static void PLy_typeinfo_init(PLyTypeInfo *);
|
||||
static void PLy_typeinfo_dealloc(PLyTypeInfo *);
|
||||
static void PLy_output_datum_func(PLyTypeInfo *, Form_pg_type);
|
||||
static void PLy_output_datum_func2(PLyObToDatum *, Form_pg_type);
|
||||
static void PLy_input_datum_func(PLyTypeInfo *, Oid, Form_pg_type);
|
||||
static void PLy_input_datum_func2(PLyDatumToOb *, Oid, Form_pg_type);
|
||||
static void PLy_output_datum_func(PLyTypeInfo *, HeapTuple);
|
||||
static void PLy_output_datum_func2(PLyObToDatum *, HeapTuple);
|
||||
static void PLy_input_datum_func(PLyTypeInfo *, Oid, HeapTuple);
|
||||
static void PLy_input_datum_func2(PLyDatumToOb *, Oid, HeapTuple);
|
||||
static void PLy_output_tuple_funcs(PLyTypeInfo *, TupleDesc);
|
||||
static void PLy_input_tuple_funcs(PLyTypeInfo *, TupleDesc);
|
||||
|
||||
@@ -565,7 +566,7 @@ PLy_modify_tuple(PLyProcedure * proc, PyObject * pltd, TriggerData *tdata,
|
||||
|
||||
modvalues[i] = FunctionCall3(&proc->result.out.r.atts[atti].typfunc,
|
||||
CStringGetDatum(src),
|
||||
ObjectIdGetDatum(proc->result.out.r.atts[atti].typelem),
|
||||
ObjectIdGetDatum(proc->result.out.r.atts[atti].typioparam),
|
||||
Int32GetDatum(tupdesc->attrs[atti]->atttypmod));
|
||||
modnulls[i] = ' ';
|
||||
|
||||
@@ -850,7 +851,7 @@ PLy_function_handler(FunctionCallInfo fcinfo, PLyProcedure * proc)
|
||||
plrv_sc = PyString_AsString(plrv_so);
|
||||
rv = FunctionCall3(&proc->result.out.d.typfunc,
|
||||
PointerGetDatum(plrv_sc),
|
||||
ObjectIdGetDatum(proc->result.out.d.typelem),
|
||||
ObjectIdGetDatum(proc->result.out.d.typioparam),
|
||||
Int32GetDatum(-1));
|
||||
}
|
||||
|
||||
@@ -956,7 +957,7 @@ PLy_function_build_args(FunctionCallInfo fcinfo, PLyProcedure * proc)
|
||||
|
||||
dt = FunctionCall3(&(proc->args[i].in.d.typfunc),
|
||||
fcinfo->arg[i],
|
||||
ObjectIdGetDatum(proc->args[i].in.d.typelem),
|
||||
ObjectIdGetDatum(proc->args[i].in.d.typioparam),
|
||||
Int32GetDatum(-1));
|
||||
ct = DatumGetCString(dt);
|
||||
arg = (proc->args[i].in.d.func) (ct);
|
||||
@@ -1119,7 +1120,7 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid,
|
||||
|
||||
rvTypeStruct = (Form_pg_type) GETSTRUCT(rvTypeTup);
|
||||
if (rvTypeStruct->typtype != 'c')
|
||||
PLy_output_datum_func(&proc->result, rvTypeStruct);
|
||||
PLy_output_datum_func(&proc->result, rvTypeTup);
|
||||
else
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
@@ -1160,7 +1161,7 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid,
|
||||
if (argTypeStruct->typtype != 'c')
|
||||
PLy_input_datum_func(&(proc->args[i]),
|
||||
procStruct->proargtypes[i],
|
||||
argTypeStruct);
|
||||
argTypeTup);
|
||||
else
|
||||
proc->args[i].is_rowtype = 2; /* still need to set I/O funcs */
|
||||
|
||||
@@ -1327,7 +1328,6 @@ PLy_input_tuple_funcs(PLyTypeInfo * arg, TupleDesc desc)
|
||||
for (i = 0; i < desc->natts; i++)
|
||||
{
|
||||
HeapTuple typeTup;
|
||||
Form_pg_type typeStruct;
|
||||
|
||||
if (desc->attrs[i]->attisdropped)
|
||||
continue;
|
||||
@@ -1338,11 +1338,10 @@ PLy_input_tuple_funcs(PLyTypeInfo * arg, TupleDesc desc)
|
||||
if (!HeapTupleIsValid(typeTup))
|
||||
elog(ERROR, "cache lookup failed for type %u",
|
||||
desc->attrs[i]->atttypid);
|
||||
typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
|
||||
|
||||
PLy_input_datum_func2(&(arg->in.r.atts[i]),
|
||||
desc->attrs[i]->atttypid,
|
||||
typeStruct);
|
||||
typeTup);
|
||||
|
||||
ReleaseSysCache(typeTup);
|
||||
}
|
||||
@@ -1365,7 +1364,6 @@ PLy_output_tuple_funcs(PLyTypeInfo * arg, TupleDesc desc)
|
||||
for (i = 0; i < desc->natts; i++)
|
||||
{
|
||||
HeapTuple typeTup;
|
||||
Form_pg_type typeStruct;
|
||||
|
||||
if (desc->attrs[i]->attisdropped)
|
||||
continue;
|
||||
@@ -1376,52 +1374,55 @@ PLy_output_tuple_funcs(PLyTypeInfo * arg, TupleDesc desc)
|
||||
if (!HeapTupleIsValid(typeTup))
|
||||
elog(ERROR, "cache lookup failed for type %u",
|
||||
desc->attrs[i]->atttypid);
|
||||
typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
|
||||
|
||||
PLy_output_datum_func2(&(arg->out.r.atts[i]), typeStruct);
|
||||
PLy_output_datum_func2(&(arg->out.r.atts[i]), typeTup);
|
||||
|
||||
ReleaseSysCache(typeTup);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PLy_output_datum_func(PLyTypeInfo * arg, Form_pg_type typeStruct)
|
||||
PLy_output_datum_func(PLyTypeInfo * arg, HeapTuple typeTup)
|
||||
{
|
||||
enter();
|
||||
|
||||
if (arg->is_rowtype > 0)
|
||||
elog(ERROR, "PLyTypeInfo struct is initialized for a Tuple");
|
||||
arg->is_rowtype = 0;
|
||||
PLy_output_datum_func2(&(arg->out.d), typeStruct);
|
||||
PLy_output_datum_func2(&(arg->out.d), typeTup);
|
||||
}
|
||||
|
||||
void
|
||||
PLy_output_datum_func2(PLyObToDatum * arg, Form_pg_type typeStruct)
|
||||
PLy_output_datum_func2(PLyObToDatum * arg, HeapTuple typeTup)
|
||||
{
|
||||
Form_pg_type typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
|
||||
|
||||
enter();
|
||||
|
||||
perm_fmgr_info(typeStruct->typinput, &arg->typfunc);
|
||||
arg->typelem = typeStruct->typelem;
|
||||
arg->typioparam = getTypeIOParam(typeTup);
|
||||
arg->typbyval = typeStruct->typbyval;
|
||||
}
|
||||
|
||||
void
|
||||
PLy_input_datum_func(PLyTypeInfo * arg, Oid typeOid, Form_pg_type typeStruct)
|
||||
PLy_input_datum_func(PLyTypeInfo * arg, Oid typeOid, HeapTuple typeTup)
|
||||
{
|
||||
enter();
|
||||
|
||||
if (arg->is_rowtype > 0)
|
||||
elog(ERROR, "PLyTypeInfo struct is initialized for Tuple");
|
||||
arg->is_rowtype = 0;
|
||||
PLy_input_datum_func2(&(arg->in.d), typeOid, typeStruct);
|
||||
PLy_input_datum_func2(&(arg->in.d), typeOid, typeTup);
|
||||
}
|
||||
|
||||
void
|
||||
PLy_input_datum_func2(PLyDatumToOb * arg, Oid typeOid, Form_pg_type typeStruct)
|
||||
PLy_input_datum_func2(PLyDatumToOb * arg, Oid typeOid, HeapTuple typeTup)
|
||||
{
|
||||
Form_pg_type typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
|
||||
|
||||
/* Get the type's conversion information */
|
||||
perm_fmgr_info(typeStruct->typoutput, &arg->typfunc);
|
||||
arg->typelem = typeStruct->typelem;
|
||||
arg->typioparam = getTypeIOParam(typeTup);
|
||||
arg->typbyval = typeStruct->typbyval;
|
||||
|
||||
/* Determine which kind of Python object we will convert to */
|
||||
@@ -1569,7 +1570,7 @@ PLyDict_FromTuple(PLyTypeInfo * info, HeapTuple tuple, TupleDesc desc)
|
||||
{
|
||||
vdat = FunctionCall3(&info->in.r.atts[i].typfunc,
|
||||
vattr,
|
||||
ObjectIdGetDatum(info->in.r.atts[i].typelem),
|
||||
ObjectIdGetDatum(info->in.r.atts[i].typioparam),
|
||||
Int32GetDatum(desc->attrs[i]->atttypmod));
|
||||
vsrc = DatumGetCString(vdat);
|
||||
|
||||
@@ -2027,7 +2028,7 @@ PLy_spi_prepare(PyObject * self, PyObject * args)
|
||||
plan->types[i] = HeapTupleGetOid(typeTup);
|
||||
typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
|
||||
if (typeStruct->typtype != 'c')
|
||||
PLy_output_datum_func(&plan->args[i], typeStruct);
|
||||
PLy_output_datum_func(&plan->args[i], typeTup);
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PLy_exc_spi_error,
|
||||
@@ -2193,7 +2194,7 @@ PLy_spi_execute_plan(PyObject * ob, PyObject * list, int limit)
|
||||
plan->values[i] =
|
||||
FunctionCall3(&(plan->args[i].out.d.typfunc),
|
||||
CStringGetDatum(sv),
|
||||
ObjectIdGetDatum(plan->args[i].out.d.typelem),
|
||||
ObjectIdGetDatum(plan->args[i].out.d.typioparam),
|
||||
Int32GetDatum(-1));
|
||||
|
||||
Py_DECREF(so);
|
||||
|
@@ -31,7 +31,7 @@
|
||||
* ENHANCEMENTS, OR MODIFICATIONS.
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.85 2004/05/30 23:40:41 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.86 2004/06/06 00:41:28 tgl Exp $
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
@@ -51,7 +51,6 @@
|
||||
#include "access/heapam.h"
|
||||
#include "catalog/pg_language.h"
|
||||
#include "catalog/pg_proc.h"
|
||||
#include "catalog/pg_type.h"
|
||||
#include "commands/trigger.h"
|
||||
#include "executor/spi.h"
|
||||
#include "fmgr.h"
|
||||
@@ -59,6 +58,7 @@
|
||||
#include "parser/parse_type.h"
|
||||
#include "tcop/tcopprot.h"
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/lsyscache.h"
|
||||
#include "utils/syscache.h"
|
||||
#include "utils/typcache.h"
|
||||
|
||||
@@ -105,10 +105,10 @@ typedef struct pltcl_proc_desc
|
||||
CommandId fn_cmin;
|
||||
bool lanpltrusted;
|
||||
FmgrInfo result_in_func;
|
||||
Oid result_in_elem;
|
||||
Oid result_typioparam;
|
||||
int nargs;
|
||||
FmgrInfo arg_out_func[FUNC_MAX_ARGS];
|
||||
Oid arg_out_elem[FUNC_MAX_ARGS];
|
||||
Oid arg_typioparam[FUNC_MAX_ARGS];
|
||||
bool arg_is_rowtype[FUNC_MAX_ARGS];
|
||||
} pltcl_proc_desc;
|
||||
|
||||
@@ -123,7 +123,7 @@ typedef struct pltcl_query_desc
|
||||
int nargs;
|
||||
Oid *argtypes;
|
||||
FmgrInfo *arginfuncs;
|
||||
Oid *argtypelems;
|
||||
Oid *argtypioparams;
|
||||
} pltcl_query_desc;
|
||||
|
||||
|
||||
@@ -543,7 +543,7 @@ pltcl_func_handler(PG_FUNCTION_ARGS)
|
||||
|
||||
tmp = DatumGetCString(FunctionCall3(&prodesc->arg_out_func[i],
|
||||
fcinfo->arg[i],
|
||||
ObjectIdGetDatum(prodesc->arg_out_elem[i]),
|
||||
ObjectIdGetDatum(prodesc->arg_typioparam[i]),
|
||||
Int32GetDatum(-1)));
|
||||
UTF_BEGIN;
|
||||
Tcl_DStringAppendElement(&tcl_cmd, UTF_E2U(tmp));
|
||||
@@ -622,7 +622,7 @@ pltcl_func_handler(PG_FUNCTION_ARGS)
|
||||
UTF_BEGIN;
|
||||
retval = FunctionCall3(&prodesc->result_in_func,
|
||||
PointerGetDatum(UTF_U2E(interp->result)),
|
||||
ObjectIdGetDatum(prodesc->result_in_elem),
|
||||
ObjectIdGetDatum(prodesc->result_typioparam),
|
||||
Int32GetDatum(-1));
|
||||
UTF_END;
|
||||
}
|
||||
@@ -908,7 +908,7 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS)
|
||||
int attnum;
|
||||
HeapTuple typeTup;
|
||||
Oid typinput;
|
||||
Oid typelem;
|
||||
Oid typioparam;
|
||||
FmgrInfo finfo;
|
||||
|
||||
/************************************************************
|
||||
@@ -943,7 +943,7 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS)
|
||||
elog(ERROR, "cache lookup failed for type %u",
|
||||
tupdesc->attrs[attnum - 1]->atttypid);
|
||||
typinput = ((Form_pg_type) GETSTRUCT(typeTup))->typinput;
|
||||
typelem = ((Form_pg_type) GETSTRUCT(typeTup))->typelem;
|
||||
typioparam = getTypeIOParam(typeTup);
|
||||
ReleaseSysCache(typeTup);
|
||||
|
||||
/************************************************************
|
||||
@@ -955,7 +955,7 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS)
|
||||
modvalues[attnum - 1] =
|
||||
FunctionCall3(&finfo,
|
||||
CStringGetDatum(UTF_U2E(ret_value)),
|
||||
ObjectIdGetDatum(typelem),
|
||||
ObjectIdGetDatum(typioparam),
|
||||
Int32GetDatum(tupdesc->attrs[attnum - 1]->atttypmod));
|
||||
UTF_END;
|
||||
}
|
||||
@@ -1150,7 +1150,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid)
|
||||
}
|
||||
|
||||
perm_fmgr_info(typeStruct->typinput, &(prodesc->result_in_func));
|
||||
prodesc->result_in_elem = typeStruct->typelem;
|
||||
prodesc->result_typioparam = getTypeIOParam(typeTup);
|
||||
|
||||
ReleaseSysCache(typeTup);
|
||||
}
|
||||
@@ -1198,7 +1198,7 @@ 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_out_elem[i] = typeStruct->typelem;
|
||||
prodesc->arg_typioparam[i] = getTypeIOParam(typeTup);
|
||||
snprintf(buf, sizeof(buf), "%d", i + 1);
|
||||
}
|
||||
|
||||
@@ -1820,7 +1820,7 @@ pltcl_SPI_prepare(ClientData cdata, Tcl_Interp *interp,
|
||||
qdesc->nargs = nargs;
|
||||
qdesc->argtypes = (Oid *) malloc(nargs * sizeof(Oid));
|
||||
qdesc->arginfuncs = (FmgrInfo *) malloc(nargs * sizeof(FmgrInfo));
|
||||
qdesc->argtypelems = (Oid *) malloc(nargs * sizeof(Oid));
|
||||
qdesc->argtypioparams = (Oid *) malloc(nargs * sizeof(Oid));
|
||||
|
||||
/************************************************************
|
||||
* Prepare to start a controlled return through all
|
||||
@@ -1833,7 +1833,7 @@ pltcl_SPI_prepare(ClientData cdata, Tcl_Interp *interp,
|
||||
pltcl_restart_in_progress = 1;
|
||||
free(qdesc->argtypes);
|
||||
free(qdesc->arginfuncs);
|
||||
free(qdesc->argtypelems);
|
||||
free(qdesc->argtypioparams);
|
||||
free(qdesc);
|
||||
ckfree((char *) args);
|
||||
return TCL_ERROR;
|
||||
@@ -1865,7 +1865,7 @@ pltcl_SPI_prepare(ClientData cdata, Tcl_Interp *interp,
|
||||
qdesc->argtypes[i] = HeapTupleGetOid(typeTup);
|
||||
perm_fmgr_info(((Form_pg_type) GETSTRUCT(typeTup))->typinput,
|
||||
&(qdesc->arginfuncs[i]));
|
||||
qdesc->argtypelems[i] = ((Form_pg_type) GETSTRUCT(typeTup))->typelem;
|
||||
qdesc->argtypioparams[i] = getTypeIOParam(typeTup);
|
||||
ReleaseSysCache(typeTup);
|
||||
|
||||
list_free(typename->names);
|
||||
@@ -2117,7 +2117,7 @@ pltcl_SPI_execp(ClientData cdata, Tcl_Interp *interp,
|
||||
argvalues[j] =
|
||||
FunctionCall3(&qdesc->arginfuncs[j],
|
||||
CStringGetDatum(UTF_U2E(callargs[j])),
|
||||
ObjectIdGetDatum(qdesc->argtypelems[j]),
|
||||
ObjectIdGetDatum(qdesc->argtypioparams[j]),
|
||||
Int32GetDatum(-1));
|
||||
UTF_END;
|
||||
}
|
||||
@@ -2339,7 +2339,7 @@ pltcl_set_tuple_values(Tcl_Interp *interp, CONST84 char *arrayname,
|
||||
CONST84 char *attname;
|
||||
HeapTuple typeTup;
|
||||
Oid typoutput;
|
||||
Oid typelem;
|
||||
Oid typioparam;
|
||||
|
||||
CONST84 char **arrptr;
|
||||
CONST84 char **nameptr;
|
||||
@@ -2390,7 +2390,7 @@ pltcl_set_tuple_values(Tcl_Interp *interp, CONST84 char *arrayname,
|
||||
tupdesc->attrs[i]->atttypid);
|
||||
|
||||
typoutput = ((Form_pg_type) GETSTRUCT(typeTup))->typoutput;
|
||||
typelem = ((Form_pg_type) GETSTRUCT(typeTup))->typelem;
|
||||
typioparam = getTypeIOParam(typeTup);
|
||||
ReleaseSysCache(typeTup);
|
||||
|
||||
/************************************************************
|
||||
@@ -2405,7 +2405,7 @@ pltcl_set_tuple_values(Tcl_Interp *interp, CONST84 char *arrayname,
|
||||
{
|
||||
outputstr = DatumGetCString(OidFunctionCall3(typoutput,
|
||||
attr,
|
||||
ObjectIdGetDatum(typelem),
|
||||
ObjectIdGetDatum(typioparam),
|
||||
Int32GetDatum(tupdesc->attrs[i]->atttypmod)));
|
||||
UTF_BEGIN;
|
||||
Tcl_SetVar2(interp, *arrptr, *nameptr, UTF_E2U(outputstr), 0);
|
||||
@@ -2434,7 +2434,7 @@ pltcl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc,
|
||||
char *attname;
|
||||
HeapTuple typeTup;
|
||||
Oid typoutput;
|
||||
Oid typelem;
|
||||
Oid typioparam;
|
||||
|
||||
for (i = 0; i < tupdesc->natts; i++)
|
||||
{
|
||||
@@ -2464,7 +2464,7 @@ pltcl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc,
|
||||
tupdesc->attrs[i]->atttypid);
|
||||
|
||||
typoutput = ((Form_pg_type) GETSTRUCT(typeTup))->typoutput;
|
||||
typelem = ((Form_pg_type) GETSTRUCT(typeTup))->typelem;
|
||||
typioparam = getTypeIOParam(typeTup);
|
||||
ReleaseSysCache(typeTup);
|
||||
|
||||
/************************************************************
|
||||
@@ -2479,7 +2479,7 @@ pltcl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc,
|
||||
{
|
||||
outputstr = DatumGetCString(OidFunctionCall3(typoutput,
|
||||
attr,
|
||||
ObjectIdGetDatum(typelem),
|
||||
ObjectIdGetDatum(typioparam),
|
||||
Int32GetDatum(tupdesc->attrs[i]->atttypmod)));
|
||||
Tcl_DStringAppendElement(retval, attname);
|
||||
UTF_BEGIN;
|
||||
|
Reference in New Issue
Block a user