Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
e627dd2d
Commit
e627dd2d
authored
Aug 04, 2003
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix pltcl and plpython to support STATEMENT triggers.
Joe Conway
parent
e8e1d455
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
125 additions
and
86 deletions
+125
-86
src/pl/plpython/plpython.c
src/pl/plpython/plpython.c
+74
-46
src/pl/tcl/pltcl.c
src/pl/tcl/pltcl.c
+51
-40
No files found.
src/pl/plpython/plpython.c
View file @
e627dd2d
...
...
@@ -29,7 +29,7 @@
* MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.3
8 2003/08/04 01:57:58
tgl Exp $
* $Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.3
9 2003/08/04 18:40:50
tgl Exp $
*
*********************************************************************
*/
...
...
@@ -651,68 +651,96 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure * proc, HeapTuple *
Py_DECREF
(
pltrelid
);
pfree
(
stroid
);
if
(
TRIGGER_FIRED_BEFORE
(
tdata
->
tg_event
))
pltwhen
=
PyString_FromString
(
"BEFORE"
);
else
if
(
TRIGGER_FIRED_AFTER
(
tdata
->
tg_event
))
pltwhen
=
PyString_FromString
(
"AFTER"
);
else
pltwhen
=
PyString_FromString
(
"UNKNOWN"
);
{
elog
(
ERROR
,
"unrecognized WHEN tg_event: %u"
,
tdata
->
tg_event
);
pltwhen
=
NULL
;
/* keep compiler quiet */
}
PyDict_SetItemString
(
pltdata
,
"when"
,
pltwhen
);
Py_DECREF
(
pltwhen
);
if
(
TRIGGER_FIRED_FOR_ROW
(
tdata
->
tg_event
))
{
pltlevel
=
PyString_FromString
(
"ROW"
);
PyDict_SetItemString
(
pltdata
,
"level"
,
pltlevel
);
Py_DECREF
(
pltlevel
);
if
(
TRIGGER_FIRED_BY_INSERT
(
tdata
->
tg_event
))
{
pltevent
=
PyString_FromString
(
"INSERT"
);
PyDict_SetItemString
(
pltdata
,
"old"
,
Py_None
);
pytnew
=
PLyDict_FromTuple
(
&
(
proc
->
result
),
tdata
->
tg_trigtuple
,
tdata
->
tg_relation
->
rd_att
);
PyDict_SetItemString
(
pltdata
,
"new"
,
pytnew
);
Py_DECREF
(
pytnew
);
*
rv
=
tdata
->
tg_trigtuple
;
}
else
if
(
TRIGGER_FIRED_BY_DELETE
(
tdata
->
tg_event
))
{
pltevent
=
PyString_FromString
(
"DELETE"
);
PyDict_SetItemString
(
pltdata
,
"new"
,
Py_None
);
pytold
=
PLyDict_FromTuple
(
&
(
proc
->
result
),
tdata
->
tg_trigtuple
,
tdata
->
tg_relation
->
rd_att
);
PyDict_SetItemString
(
pltdata
,
"old"
,
pytold
);
Py_DECREF
(
pytold
);
*
rv
=
tdata
->
tg_trigtuple
;
}
else
if
(
TRIGGER_FIRED_BY_UPDATE
(
tdata
->
tg_event
))
{
pltevent
=
PyString_FromString
(
"UPDATE"
);
pytnew
=
PLyDict_FromTuple
(
&
(
proc
->
result
),
tdata
->
tg_newtuple
,
tdata
->
tg_relation
->
rd_att
);
PyDict_SetItemString
(
pltdata
,
"new"
,
pytnew
);
Py_DECREF
(
pytnew
);
pytold
=
PLyDict_FromTuple
(
&
(
proc
->
result
),
tdata
->
tg_trigtuple
,
tdata
->
tg_relation
->
rd_att
);
PyDict_SetItemString
(
pltdata
,
"old"
,
pytold
);
Py_DECREF
(
pytold
);
*
rv
=
tdata
->
tg_newtuple
;
}
else
{
elog
(
ERROR
,
"unrecognized OP tg_event: %u"
,
tdata
->
tg_event
);
pltevent
=
NULL
;
/* keep compiler quiet */
}
PyDict_SetItemString
(
pltdata
,
"event"
,
pltevent
);
Py_DECREF
(
pltevent
);
}
else
if
(
TRIGGER_FIRED_FOR_STATEMENT
(
tdata
->
tg_event
))
{
pltlevel
=
PyString_FromString
(
"STATEMENT"
);
else
pltlevel
=
PyString_FromString
(
"UNKNOWN"
);
PyDict_SetItemString
(
pltdata
,
"level"
,
pltlevel
);
Py_DECREF
(
pltlevel
);
PyDict_SetItemString
(
pltdata
,
"level"
,
pltlevel
);
Py_DECREF
(
pltlevel
);
if
(
TRIGGER_FIRED_BY_INSERT
(
tdata
->
tg_event
))
{
pltevent
=
PyString_FromString
(
"INSERT"
);
PyDict_SetItemString
(
pltdata
,
"old"
,
Py_None
);
pytnew
=
PLyDict_FromTuple
(
&
(
proc
->
result
),
tdata
->
tg_trigtuple
,
tdata
->
tg_relation
->
rd_att
);
PyDict_SetItemString
(
pltdata
,
"new"
,
pytnew
);
Py_DECREF
(
pytnew
);
*
rv
=
tdata
->
tg_trigtuple
;
}
else
if
(
TRIGGER_FIRED_BY_DELETE
(
tdata
->
tg_event
))
{
pltevent
=
PyString_FromString
(
"DELETE"
);
PyDict_SetItemString
(
pltdata
,
"new"
,
Py_None
);
pytold
=
PLyDict_FromTuple
(
&
(
proc
->
result
),
tdata
->
tg_trigtuple
,
tdata
->
tg_relation
->
rd_att
);
PyDict_SetItemString
(
pltdata
,
"old"
,
pytold
);
Py_DECREF
(
pytold
);
*
rv
=
tdata
->
tg_trigtuple
;
}
else
if
(
TRIGGER_FIRED_BY_UPDATE
(
tdata
->
tg_event
))
{
pltevent
=
PyString_FromString
(
"UPDATE"
);
pytnew
=
PLyDict_FromTuple
(
&
(
proc
->
result
),
tdata
->
tg_newtuple
,
tdata
->
tg_relation
->
rd_att
);
PyDict_SetItemString
(
pltdata
,
"new"
,
pytnew
);
Py_DECREF
(
pytnew
);
pytold
=
PLyDict_FromTuple
(
&
(
proc
->
result
),
tdata
->
tg_trigtuple
,
tdata
->
tg_relation
->
rd_att
);
PyDict_SetItemString
(
pltdata
,
"old"
,
pytold
);
Py_DECREF
(
pytold
);
*
rv
=
tdata
->
tg_newtuple
;
*
rv
=
(
HeapTuple
)
NULL
;
if
(
TRIGGER_FIRED_BY_INSERT
(
tdata
->
tg_event
))
pltevent
=
PyString_FromString
(
"INSERT"
);
else
if
(
TRIGGER_FIRED_BY_DELETE
(
tdata
->
tg_event
))
pltevent
=
PyString_FromString
(
"DELETE"
);
else
if
(
TRIGGER_FIRED_BY_UPDATE
(
tdata
->
tg_event
))
pltevent
=
PyString_FromString
(
"UPDATE"
);
else
{
elog
(
ERROR
,
"unrecognized OP tg_event: %u"
,
tdata
->
tg_event
);
pltevent
=
NULL
;
/* keep compiler quiet */
}
PyDict_SetItemString
(
pltdata
,
"event"
,
pltevent
);
Py_DECREF
(
pltevent
);
}
else
{
pltevent
=
PyString_FromString
(
"UNKNOWN"
);
PyDict_SetItemString
(
pltdata
,
"old"
,
Py_None
);
PyDict_SetItemString
(
pltdata
,
"new"
,
Py_None
);
*
rv
=
tdata
->
tg_trigtuple
;
}
PyDict_SetItemString
(
pltdata
,
"event"
,
pltevent
);
Py_DECREF
(
pltevent
);
elog
(
ERROR
,
"unrecognized LEVEL tg_event: %u"
,
tdata
->
tg_event
);
if
(
tdata
->
tg_trigger
->
tgnargs
)
{
...
...
src/pl/tcl/pltcl.c
View file @
e627dd2d
...
...
@@ -31,7 +31,7 @@
* ENHANCEMENTS, OR MODIFICATIONS.
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.7
4 2003/08/04 00:43:33 momjian
Exp $
* $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.7
5 2003/08/04 18:40:50 tgl
Exp $
*
**********************************************************************/
...
...
@@ -708,63 +708,74 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS)
else
if
(
TRIGGER_FIRED_AFTER
(
trigdata
->
tg_event
))
Tcl_DStringAppendElement
(
&
tcl_cmd
,
"AFTER"
);
else
Tcl_DStringAppendElement
(
&
tcl_cmd
,
"UNKNOWN"
);
elog
(
ERROR
,
"unrecognized WHEN tg_event: %u"
,
trigdata
->
tg_event
);
/* The level part of the event for TG_level */
if
(
TRIGGER_FIRED_FOR_ROW
(
trigdata
->
tg_event
))
{
Tcl_DStringAppendElement
(
&
tcl_cmd
,
"ROW"
);
else
if
(
TRIGGER_FIRED_FOR_STATEMENT
(
trigdata
->
tg_event
))
Tcl_DStringAppendElement
(
&
tcl_cmd
,
"STATEMENT"
);
else
Tcl_DStringAppendElement
(
&
tcl_cmd
,
"UNKNOWN"
);
/* Build the data list for the trigtuple */
pltcl_build_tuple_argument
(
trigdata
->
tg_trigtuple
,
tupdesc
,
&
tcl_trigtup
);
/* Build the data list for the trigtuple */
pltcl_build_tuple_argument
(
trigdata
->
tg_trigtuple
,
tupdesc
,
&
tcl_trigtup
);
/*
* Now the command part of the event for TG_op and data for NEW and
* OLD
*/
if
(
TRIGGER_FIRED_BY_INSERT
(
trigdata
->
tg_event
))
{
Tcl_DStringAppendElement
(
&
tcl_cmd
,
"INSERT"
);
/*
* Now the command part of the event for TG_op and data for NEW and
* OLD
*/
if
(
TRIGGER_FIRED_BY_INSERT
(
trigdata
->
tg_event
))
{
Tcl_DStringAppendElement
(
&
tcl_cmd
,
"INSERT"
);
Tcl_DStringAppendElement
(
&
tcl_cmd
,
Tcl_DStringValue
(
&
tcl_trigtup
));
Tcl_DStringAppendElement
(
&
tcl_cmd
,
""
);
Tcl_DStringAppendElement
(
&
tcl_cmd
,
Tcl_DStringValue
(
&
tcl_trigtup
));
Tcl_DStringAppendElement
(
&
tcl_cmd
,
""
);
rettup
=
trigdata
->
tg_trigtuple
;
}
else
if
(
TRIGGER_FIRED_BY_DELETE
(
trigdata
->
tg_event
))
{
Tcl_DStringAppendElement
(
&
tcl_cmd
,
"DELETE"
);
rettup
=
trigdata
->
tg_trigtuple
;
}
else
if
(
TRIGGER_FIRED_BY_DELETE
(
trigdata
->
tg_event
))
{
Tcl_DStringAppendElement
(
&
tcl_cmd
,
"DELETE"
);
Tcl_DStringAppendElement
(
&
tcl_cmd
,
""
);
Tcl_DStringAppendElement
(
&
tcl_cmd
,
Tcl_DStringValue
(
&
tcl_trigtup
));
Tcl_DStringAppendElement
(
&
tcl_cmd
,
""
);
Tcl_DStringAppendElement
(
&
tcl_cmd
,
Tcl_DStringValue
(
&
tcl_trigtup
));
rettup
=
trigdata
->
tg_trigtuple
;
}
else
if
(
TRIGGER_FIRED_BY_UPDATE
(
trigdata
->
tg_event
))
{
Tcl_DStringAppendElement
(
&
tcl_cmd
,
"UPDATE"
);
rettup
=
trigdata
->
tg_trigtuple
;
}
else
if
(
TRIGGER_FIRED_BY_UPDATE
(
trigdata
->
tg_event
))
{
Tcl_DStringAppendElement
(
&
tcl_cmd
,
"UPDATE"
);
pltcl_build_tuple_argument
(
trigdata
->
tg_newtuple
,
tupdesc
,
&
tcl_newtup
);
pltcl_build_tuple_argument
(
trigdata
->
tg_newtuple
,
tupdesc
,
&
tcl_newtup
);
Tcl_DStringAppendElement
(
&
tcl_cmd
,
Tcl_DStringValue
(
&
tcl_newtup
));
Tcl_DStringAppendElement
(
&
tcl_cmd
,
Tcl_DStringValue
(
&
tcl_trigtup
));
Tcl_DStringAppendElement
(
&
tcl_cmd
,
Tcl_DStringValue
(
&
tcl_newtup
));
Tcl_DStringAppendElement
(
&
tcl_cmd
,
Tcl_DStringValue
(
&
tcl_trigtup
));
rettup
=
trigdata
->
tg_newtuple
;
rettup
=
trigdata
->
tg_newtuple
;
}
else
elog
(
ERROR
,
"unrecognized OP tg_event: %u"
,
trigdata
->
tg_event
);
}
else
else
if
(
TRIGGER_FIRED_FOR_STATEMENT
(
trigdata
->
tg_event
))
{
Tcl_DStringAppendElement
(
&
tcl_cmd
,
"UNKNOWN"
);
Tcl_DStringAppendElement
(
&
tcl_cmd
,
"STATEMENT"
);
if
(
TRIGGER_FIRED_BY_INSERT
(
trigdata
->
tg_event
))
Tcl_DStringAppendElement
(
&
tcl_cmd
,
"INSERT"
);
else
if
(
TRIGGER_FIRED_BY_DELETE
(
trigdata
->
tg_event
))
Tcl_DStringAppendElement
(
&
tcl_cmd
,
"DELETE"
);
else
if
(
TRIGGER_FIRED_BY_UPDATE
(
trigdata
->
tg_event
))
Tcl_DStringAppendElement
(
&
tcl_cmd
,
"UPDATE"
);
else
elog
(
ERROR
,
"unrecognized OP tg_event: %u"
,
trigdata
->
tg_event
);
Tcl_DStringAppendElement
(
&
tcl_cmd
,
Tcl_DStringValue
(
&
tcl_trigtup
)
);
Tcl_DStringAppendElement
(
&
tcl_cmd
,
Tcl_DStringValue
(
&
tcl_trigtup
)
);
Tcl_DStringAppendElement
(
&
tcl_cmd
,
""
);
Tcl_DStringAppendElement
(
&
tcl_cmd
,
""
);
rettup
=
trigdata
->
tg_trigtuple
;
rettup
=
(
HeapTuple
)
NULL
;
}
else
elog
(
ERROR
,
"unrecognized LEVEL tg_event: %u"
,
trigdata
->
tg_event
);
memcpy
(
&
Warn_restart
,
&
save_restart
,
sizeof
(
Warn_restart
));
Tcl_DStringFree
(
&
tcl_trigtup
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment