Fix brain damage in deciding which python input converter to use.
This commit is contained in:
parent
b952d61c54
commit
d2e028b1b0
@ -29,7 +29,7 @@
|
|||||||
* MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
* MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.32 2003/05/27 17:49:47 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.33 2003/06/11 18:33:39 tgl Exp $
|
||||||
*
|
*
|
||||||
*********************************************************************
|
*********************************************************************
|
||||||
*/
|
*/
|
||||||
@ -244,8 +244,8 @@ static void PLy_typeinfo_init(PLyTypeInfo *);
|
|||||||
static void PLy_typeinfo_dealloc(PLyTypeInfo *);
|
static void PLy_typeinfo_dealloc(PLyTypeInfo *);
|
||||||
static void PLy_output_datum_func(PLyTypeInfo *, Form_pg_type);
|
static void PLy_output_datum_func(PLyTypeInfo *, Form_pg_type);
|
||||||
static void PLy_output_datum_func2(PLyObToDatum *, Form_pg_type);
|
static void PLy_output_datum_func2(PLyObToDatum *, Form_pg_type);
|
||||||
static void PLy_input_datum_func(PLyTypeInfo *, Form_pg_type);
|
static void PLy_input_datum_func(PLyTypeInfo *, Oid, Form_pg_type);
|
||||||
static void PLy_input_datum_func2(PLyDatumToOb *, Form_pg_type);
|
static void PLy_input_datum_func2(PLyDatumToOb *, Oid, Form_pg_type);
|
||||||
static void PLy_output_tuple_funcs(PLyTypeInfo *, TupleDesc);
|
static void PLy_output_tuple_funcs(PLyTypeInfo *, TupleDesc);
|
||||||
static void PLy_input_tuple_funcs(PLyTypeInfo *, TupleDesc);
|
static void PLy_input_tuple_funcs(PLyTypeInfo *, TupleDesc);
|
||||||
|
|
||||||
@ -1152,7 +1152,9 @@ PLy_procedure_create(FunctionCallInfo fcinfo, bool is_trigger,
|
|||||||
argTypeStruct = (Form_pg_type) GETSTRUCT(argTypeTup);
|
argTypeStruct = (Form_pg_type) GETSTRUCT(argTypeTup);
|
||||||
|
|
||||||
if (argTypeStruct->typrelid == InvalidOid)
|
if (argTypeStruct->typrelid == InvalidOid)
|
||||||
PLy_input_datum_func(&(proc->args[i]), argTypeStruct);
|
PLy_input_datum_func(&(proc->args[i]),
|
||||||
|
procStruct->proargtypes[i],
|
||||||
|
argTypeStruct);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TupleTableSlot *slot = (TupleTableSlot *) fcinfo->arg[i];
|
TupleTableSlot *slot = (TupleTableSlot *) fcinfo->arg[i];
|
||||||
@ -1373,7 +1375,9 @@ PLy_input_tuple_funcs(PLyTypeInfo * arg, TupleDesc desc)
|
|||||||
|
|
||||||
typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
|
typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
|
||||||
|
|
||||||
PLy_input_datum_func2(&(arg->in.r.atts[i]), typeStruct);
|
PLy_input_datum_func2(&(arg->in.r.atts[i]),
|
||||||
|
desc->attrs[i]->atttypid,
|
||||||
|
typeStruct);
|
||||||
|
|
||||||
ReleaseSysCache(typeTup);
|
ReleaseSysCache(typeTup);
|
||||||
}
|
}
|
||||||
@ -1439,85 +1443,46 @@ PLy_output_datum_func2(PLyObToDatum * arg, Form_pg_type typeStruct)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PLy_input_datum_func(PLyTypeInfo * arg, Form_pg_type typeStruct)
|
PLy_input_datum_func(PLyTypeInfo * arg, Oid typeOid, Form_pg_type typeStruct)
|
||||||
{
|
{
|
||||||
enter();
|
enter();
|
||||||
|
|
||||||
if (arg->is_rel == 1)
|
if (arg->is_rel == 1)
|
||||||
elog(FATAL, "plpython: PLyTypeInfo struct is initialized for Tuple");
|
elog(FATAL, "plpython: PLyTypeInfo struct is initialized for Tuple");
|
||||||
arg->is_rel = 0;
|
arg->is_rel = 0;
|
||||||
PLy_input_datum_func2(&(arg->in.d), typeStruct);
|
PLy_input_datum_func2(&(arg->in.d), typeOid, typeStruct);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PLy_input_datum_func2(PLyDatumToOb * arg, Form_pg_type typeStruct)
|
PLy_input_datum_func2(PLyDatumToOb * arg, Oid typeOid, Form_pg_type typeStruct)
|
||||||
{
|
{
|
||||||
char *type;
|
/* Get the type's conversion information */
|
||||||
|
|
||||||
perm_fmgr_info(typeStruct->typoutput, &arg->typfunc);
|
perm_fmgr_info(typeStruct->typoutput, &arg->typfunc);
|
||||||
arg->typelem = typeStruct->typelem;
|
arg->typelem = typeStruct->typelem;
|
||||||
arg->typbyval = typeStruct->typbyval;
|
arg->typbyval = typeStruct->typbyval;
|
||||||
|
|
||||||
/*
|
/* Determine which kind of Python object we will convert to */
|
||||||
* hmmm, wierd. means this arg will always be converted to a python
|
switch (typeOid)
|
||||||
* None
|
|
||||||
*/
|
|
||||||
if (!OidIsValid(typeStruct->typoutput))
|
|
||||||
{
|
{
|
||||||
elog(ERROR, "plpython: (FIXME) typeStruct->typoutput is invalid");
|
case BOOLOID:
|
||||||
|
arg->func = PLyBool_FromString;
|
||||||
arg->func = NULL;
|
break;
|
||||||
return;
|
case FLOAT4OID:
|
||||||
}
|
case FLOAT8OID:
|
||||||
|
case NUMERICOID:
|
||||||
type = NameStr(typeStruct->typname);
|
arg->func = PLyFloat_FromString;
|
||||||
switch (type[0])
|
break;
|
||||||
{
|
case INT2OID:
|
||||||
case 'b':
|
case INT4OID:
|
||||||
{
|
arg->func = PLyInt_FromString;
|
||||||
if (strcasecmp("bool", type))
|
break;
|
||||||
{
|
case INT8OID:
|
||||||
arg->func = PLyBool_FromString;
|
arg->func = PLyLong_FromString;
|
||||||
return;
|
break;
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'f':
|
|
||||||
{
|
|
||||||
if ((strncasecmp("float", type, 5) == 0) &&
|
|
||||||
((type[5] == '8') || (type[5] == '4')))
|
|
||||||
{
|
|
||||||
arg->func = PLyFloat_FromString;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'i':
|
|
||||||
{
|
|
||||||
if ((strncasecmp("int", type, 3) == 0) &&
|
|
||||||
((type[3] == '4') || (type[3] == '2')) &&
|
|
||||||
(type[4] == '\0'))
|
|
||||||
{
|
|
||||||
arg->func = PLyInt_FromString;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (strcasecmp("int8", type) == 0)
|
|
||||||
arg->func = PLyLong_FromString;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'n':
|
|
||||||
{
|
|
||||||
if (strcasecmp("numeric", type) == 0)
|
|
||||||
{
|
|
||||||
arg->func = PLyFloat_FromString;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
|
arg->func = PLyString_FromString;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
arg->func = PLyString_FromString;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user