|
29 | 29 | * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
30 | 30 | *
|
31 | 31 | * IDENTIFICATION
|
32 |
| - *$Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.32 2003/05/27 17:49:47 momjian Exp $ |
| 32 | + *$Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.33 2003/06/11 18:33:39 tgl Exp $ |
33 | 33 | *
|
34 | 34 | *********************************************************************
|
35 | 35 | */
|
@@ -244,8 +244,8 @@ static void PLy_typeinfo_init(PLyTypeInfo *);
|
244 | 244 | staticvoidPLy_typeinfo_dealloc(PLyTypeInfo*);
|
245 | 245 | staticvoidPLy_output_datum_func(PLyTypeInfo*,Form_pg_type);
|
246 | 246 | staticvoidPLy_output_datum_func2(PLyObToDatum*,Form_pg_type);
|
247 |
| -staticvoidPLy_input_datum_func(PLyTypeInfo*,Form_pg_type); |
248 |
| -staticvoidPLy_input_datum_func2(PLyDatumToOb*,Form_pg_type); |
| 247 | +staticvoidPLy_input_datum_func(PLyTypeInfo*,Oid,Form_pg_type); |
| 248 | +staticvoidPLy_input_datum_func2(PLyDatumToOb*,Oid,Form_pg_type); |
249 | 249 | staticvoidPLy_output_tuple_funcs(PLyTypeInfo*,TupleDesc);
|
250 | 250 | staticvoidPLy_input_tuple_funcs(PLyTypeInfo*,TupleDesc);
|
251 | 251 |
|
@@ -1152,7 +1152,9 @@ PLy_procedure_create(FunctionCallInfo fcinfo, bool is_trigger,
|
1152 | 1152 | argTypeStruct= (Form_pg_type)GETSTRUCT(argTypeTup);
|
1153 | 1153 |
|
1154 | 1154 | if (argTypeStruct->typrelid==InvalidOid)
|
1155 |
| -PLy_input_datum_func(&(proc->args[i]),argTypeStruct); |
| 1155 | +PLy_input_datum_func(&(proc->args[i]), |
| 1156 | +procStruct->proargtypes[i], |
| 1157 | +argTypeStruct); |
1156 | 1158 | else
|
1157 | 1159 | {
|
1158 | 1160 | TupleTableSlot*slot= (TupleTableSlot*)fcinfo->arg[i];
|
@@ -1373,7 +1375,9 @@ PLy_input_tuple_funcs(PLyTypeInfo * arg, TupleDesc desc)
|
1373 | 1375 |
|
1374 | 1376 | typeStruct= (Form_pg_type)GETSTRUCT(typeTup);
|
1375 | 1377 |
|
1376 |
| -PLy_input_datum_func2(&(arg->in.r.atts[i]),typeStruct); |
| 1378 | +PLy_input_datum_func2(&(arg->in.r.atts[i]), |
| 1379 | +desc->attrs[i]->atttypid, |
| 1380 | +typeStruct); |
1377 | 1381 |
|
1378 | 1382 | ReleaseSysCache(typeTup);
|
1379 | 1383 | }
|
@@ -1439,85 +1443,46 @@ PLy_output_datum_func2(PLyObToDatum * arg, Form_pg_type typeStruct)
|
1439 | 1443 | }
|
1440 | 1444 |
|
1441 | 1445 | void
|
1442 |
| -PLy_input_datum_func(PLyTypeInfo*arg,Form_pg_typetypeStruct) |
| 1446 | +PLy_input_datum_func(PLyTypeInfo*arg,OidtypeOid,Form_pg_typetypeStruct) |
1443 | 1447 | {
|
1444 | 1448 | enter();
|
1445 | 1449 |
|
1446 | 1450 | if (arg->is_rel==1)
|
1447 | 1451 | elog(FATAL,"plpython: PLyTypeInfo struct is initialized for Tuple");
|
1448 | 1452 | arg->is_rel=0;
|
1449 |
| -PLy_input_datum_func2(&(arg->in.d),typeStruct); |
| 1453 | +PLy_input_datum_func2(&(arg->in.d),typeOid,typeStruct); |
1450 | 1454 | }
|
1451 | 1455 |
|
1452 | 1456 | void
|
1453 |
| -PLy_input_datum_func2(PLyDatumToOb*arg,Form_pg_typetypeStruct) |
| 1457 | +PLy_input_datum_func2(PLyDatumToOb*arg,OidtypeOid,Form_pg_typetypeStruct) |
1454 | 1458 | {
|
1455 |
| -char*type; |
1456 |
| - |
| 1459 | +/* Get the type's conversion information */ |
1457 | 1460 | perm_fmgr_info(typeStruct->typoutput,&arg->typfunc);
|
1458 | 1461 | arg->typelem=typeStruct->typelem;
|
1459 | 1462 | arg->typbyval=typeStruct->typbyval;
|
1460 | 1463 |
|
1461 |
| -/* |
1462 |
| - * hmmm, wierd. means this arg will always be converted to a python |
1463 |
| - * None |
1464 |
| - */ |
1465 |
| -if (!OidIsValid(typeStruct->typoutput)) |
1466 |
| -{ |
1467 |
| -elog(ERROR,"plpython: (FIXME) typeStruct->typoutput is invalid"); |
1468 |
| - |
1469 |
| -arg->func=NULL; |
1470 |
| -return; |
1471 |
| -} |
1472 |
| - |
1473 |
| -type=NameStr(typeStruct->typname); |
1474 |
| -switch (type[0]) |
| 1464 | +/* Determine which kind of Python object we will convert to */ |
| 1465 | +switch (typeOid) |
1475 | 1466 | {
|
1476 |
| -case'b': |
1477 |
| -{ |
1478 |
| -if (strcasecmp("bool",type)) |
1479 |
| -{ |
1480 |
| -arg->func=PLyBool_FromString; |
1481 |
| -return; |
1482 |
| -} |
1483 |
| -break; |
1484 |
| -} |
1485 |
| -case'f': |
1486 |
| -{ |
1487 |
| -if ((strncasecmp("float",type,5)==0)&& |
1488 |
| -((type[5]=='8')|| (type[5]=='4'))) |
1489 |
| -{ |
1490 |
| -arg->func=PLyFloat_FromString; |
1491 |
| -return; |
1492 |
| -} |
1493 |
| -break; |
1494 |
| -} |
1495 |
| -case'i': |
1496 |
| -{ |
1497 |
| -if ((strncasecmp("int",type,3)==0)&& |
1498 |
| -((type[3]=='4')|| (type[3]=='2'))&& |
1499 |
| -(type[4]=='\0')) |
1500 |
| -{ |
1501 |
| -arg->func=PLyInt_FromString; |
1502 |
| -return; |
1503 |
| -} |
1504 |
| -elseif (strcasecmp("int8",type)==0) |
1505 |
| -arg->func=PLyLong_FromString; |
1506 |
| -break; |
1507 |
| -} |
1508 |
| -case'n': |
1509 |
| -{ |
1510 |
| -if (strcasecmp("numeric",type)==0) |
1511 |
| -{ |
1512 |
| -arg->func=PLyFloat_FromString; |
1513 |
| -return; |
1514 |
| -} |
1515 |
| -break; |
1516 |
| -} |
| 1467 | +caseBOOLOID: |
| 1468 | +arg->func=PLyBool_FromString; |
| 1469 | +break; |
| 1470 | +caseFLOAT4OID: |
| 1471 | +caseFLOAT8OID: |
| 1472 | +caseNUMERICOID: |
| 1473 | +arg->func=PLyFloat_FromString; |
| 1474 | +break; |
| 1475 | +caseINT2OID: |
| 1476 | +caseINT4OID: |
| 1477 | +arg->func=PLyInt_FromString; |
| 1478 | +break; |
| 1479 | +caseINT8OID: |
| 1480 | +arg->func=PLyLong_FromString; |
| 1481 | +break; |
1517 | 1482 | default:
|
| 1483 | +arg->func=PLyString_FromString; |
1518 | 1484 | break;
|
1519 | 1485 | }
|
1520 |
| -arg->func=PLyString_FromString; |
1521 | 1486 | }
|
1522 | 1487 |
|
1523 | 1488 | void
|
|