@ -294,7 +294,7 @@ PLy_exec_function(FunctionCallInfo fcinfo, PLyProcedure *proc)
/* trigger subhandler
*
* the python function is expected to return Py_None if the tuple is
* acceptable and unmodified . Otherwise it should return a PyString
* acceptable and unmodified . Otherwise it should return a PyUnicode
* object who ' s value is SKIP , or MODIFY . SKIP means don ' t perform
* this action . MODIFY means the tuple has been modified , so update
* tuple and perform action . SKIP and MODIFY assume the trigger fires
@ -360,9 +360,7 @@ PLy_exec_trigger(FunctionCallInfo fcinfo, PLyProcedure *proc)
{
char * srv ;
if ( PyString_Check ( plrv ) )
srv = PyString_AsString ( plrv ) ;
else if ( PyUnicode_Check ( plrv ) )
if ( PyUnicode_Check ( plrv ) )
srv = PLyUnicode_AsString ( plrv ) ;
else
{
@ -700,35 +698,35 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc, HeapTuple *r
if ( ! pltdata )
return NULL ;
pltname = PyString _FromString ( tdata - > tg_trigger - > tgname ) ;
pltname = PLyUnicode _FromString ( tdata - > tg_trigger - > tgname ) ;
PyDict_SetItemString ( pltdata , " name " , pltname ) ;
Py_DECREF ( pltname ) ;
stroid = DatumGetCString ( DirectFunctionCall1 ( oidout ,
ObjectIdGetDatum ( tdata - > tg_relation - > rd_id ) ) ) ;
pltrelid = PyString _FromString ( stroid ) ;
pltrelid = PLyUnicode _FromString ( stroid ) ;
PyDict_SetItemString ( pltdata , " relid " , pltrelid ) ;
Py_DECREF ( pltrelid ) ;
pfree ( stroid ) ;
stroid = SPI_getrelname ( tdata - > tg_relation ) ;
plttablename = PyString _FromString ( stroid ) ;
plttablename = PLyUnicode _FromString ( stroid ) ;
PyDict_SetItemString ( pltdata , " table_name " , plttablename ) ;
Py_DECREF ( plttablename ) ;
pfree ( stroid ) ;
stroid = SPI_getnspname ( tdata - > tg_relation ) ;
plttableschema = PyString _FromString ( stroid ) ;
plttableschema = PLyUnicode _FromString ( stroid ) ;
PyDict_SetItemString ( pltdata , " table_schema " , plttableschema ) ;
Py_DECREF ( plttableschema ) ;
pfree ( stroid ) ;
if ( TRIGGER_FIRED_BEFORE ( tdata - > tg_event ) )
pltwhen = PyString _FromString ( " BEFORE " ) ;
pltwhen = PLyUnicode _FromString ( " BEFORE " ) ;
else if ( TRIGGER_FIRED_AFTER ( tdata - > tg_event ) )
pltwhen = PyString _FromString ( " AFTER " ) ;
pltwhen = PLyUnicode _FromString ( " AFTER " ) ;
else if ( TRIGGER_FIRED_INSTEAD ( tdata - > tg_event ) )
pltwhen = PyString _FromString ( " INSTEAD OF " ) ;
pltwhen = PLyUnicode _FromString ( " INSTEAD OF " ) ;
else
{
elog ( ERROR , " unrecognized WHEN tg_event: %u " , tdata - > tg_event ) ;
@ -739,7 +737,7 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc, HeapTuple *r
if ( TRIGGER_FIRED_FOR_ROW ( tdata - > tg_event ) )
{
pltlevel = PyString _FromString ( " ROW " ) ;
pltlevel = PLyUnicode _FromString ( " ROW " ) ;
PyDict_SetItemString ( pltdata , " level " , pltlevel ) ;
Py_DECREF ( pltlevel ) ;
@ -750,7 +748,7 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc, HeapTuple *r
if ( TRIGGER_FIRED_BY_INSERT ( tdata - > tg_event ) )
{
pltevent = PyString _FromString ( " INSERT " ) ;
pltevent = PLyUnicode _FromString ( " INSERT " ) ;
PyDict_SetItemString ( pltdata , " old " , Py_None ) ;
pytnew = PLy_input_from_tuple ( & proc - > result_in ,
@ -763,7 +761,7 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc, HeapTuple *r
}
else if ( TRIGGER_FIRED_BY_DELETE ( tdata - > tg_event ) )
{
pltevent = PyString _FromString ( " DELETE " ) ;
pltevent = PLyUnicode _FromString ( " DELETE " ) ;
PyDict_SetItemString ( pltdata , " new " , Py_None ) ;
pytold = PLy_input_from_tuple ( & proc - > result_in ,
@ -776,7 +774,7 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc, HeapTuple *r
}
else if ( TRIGGER_FIRED_BY_UPDATE ( tdata - > tg_event ) )
{
pltevent = PyString _FromString ( " UPDATE " ) ;
pltevent = PLyUnicode _FromString ( " UPDATE " ) ;
pytnew = PLy_input_from_tuple ( & proc - > result_in ,
tdata - > tg_newtuple ,
@ -803,7 +801,7 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc, HeapTuple *r
}
else if ( TRIGGER_FIRED_FOR_STATEMENT ( tdata - > tg_event ) )
{
pltlevel = PyString _FromString ( " STATEMENT " ) ;
pltlevel = PLyUnicode _FromString ( " STATEMENT " ) ;
PyDict_SetItemString ( pltdata , " level " , pltlevel ) ;
Py_DECREF ( pltlevel ) ;
@ -812,13 +810,13 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc, HeapTuple *r
* rv = NULL ;
if ( TRIGGER_FIRED_BY_INSERT ( tdata - > tg_event ) )
pltevent = PyString _FromString ( " INSERT " ) ;
pltevent = PLyUnicode _FromString ( " INSERT " ) ;
else if ( TRIGGER_FIRED_BY_DELETE ( tdata - > tg_event ) )
pltevent = PyString _FromString ( " DELETE " ) ;
pltevent = PLyUnicode _FromString ( " DELETE " ) ;
else if ( TRIGGER_FIRED_BY_UPDATE ( tdata - > tg_event ) )
pltevent = PyString _FromString ( " UPDATE " ) ;
pltevent = PLyUnicode _FromString ( " UPDATE " ) ;
else if ( TRIGGER_FIRED_BY_TRUNCATE ( tdata - > tg_event ) )
pltevent = PyString _FromString ( " TRUNCATE " ) ;
pltevent = PLyUnicode _FromString ( " TRUNCATE " ) ;
else
{
elog ( ERROR , " unrecognized OP tg_event: %u " , tdata - > tg_event ) ;
@ -847,7 +845,7 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc, HeapTuple *r
}
for ( i = 0 ; i < tdata - > tg_trigger - > tgnargs ; i + + )
{
pltarg = PyString _FromString ( tdata - > tg_trigger - > tgargs [ i ] ) ;
pltarg = PLyUnicode _FromString ( tdata - > tg_trigger - > tgargs [ i ] ) ;
/*
* stolen , don ' t Py_DECREF
@ -931,9 +929,7 @@ PLy_modify_tuple(PLyProcedure *proc, PyObject *pltd, TriggerData *tdata,
PLyObToDatum * att ;
platt = PyList_GetItem ( plkeys , i ) ;
if ( PyString_Check ( platt ) )
plattstr = PyString_AsString ( platt ) ;
else if ( PyUnicode_Check ( platt ) )
if ( PyUnicode_Check ( platt ) )
plattstr = PLyUnicode_AsString ( platt ) ;
else
{