Patches
Search the entire project
This project's trackers
This project's releases
Project
People
Skill
Advanced search
Log In
|
New Account
Home
My Page
Projects
Code Snippets
Project Openings
PL/Java
Summary
Activity
Tracker
Lists
Files
[#1010848] Cancelling a Trigger operation
View Trackers
|
Patches
|
Download .csv
|
Monitor
Date:
2010-06-23 07:54
Priority:
3
State:
Open
Submitted by:
Luca Ferrari (
fluca1978
)
Assigned to:
Nobody (None)
Category:
Group:
Summary:
Cancelling a Trigger operation
Detailed description
This patch can be used to cancel a trigger operation using the TriggerData Java object. The idea is that, since the method that will receive the TriggerData object can interact with the backend only with such object, the cancel request must be performed thru the TriggerData interface/object itself. So I've added methods to set and get the status of a "aborted" flag for the current request. If the trigger data object has the aborted flag set, than the getResultTrigger method will return a (long) 0, to indicate that the current operation has been aborted. The backend, in the functions.c file, will manage such zero as an abort and discard the current operation.
I've tested the patch against the following system:
- PostgreSQL 8.4.4 on x86_64-pc-linux-gnu, compiled by GCC gcc-4.4.real
(Ubuntu 4.4.3-4ubuntu5) 4.4.3, 64-bit
- the latest version of the pljava sources
- jdk 1.5.0_22 on Ubuntu 64 bit
- gcc 4.4.3
Step by step the patch works as follows:
1) the internal/TriggerData class now implements such methods using a simple
boolean flag to indicate if the current statement must be cancelled or not.
Please note that there is a utility method to check the conditions on which a
statement can be aborted.
2) the internal/TriggerData class when returning the tuple to apply, simply
returns 0 if the statement has been cancelled. Such 0 is interpreted as a NULL
result in the backend code (Functions.c) and therefore the trigger aborts the
current operation.
3) when asking for a newResultSet on TriggerData, the system checks if the
trigger has already been marked for cancelling the current statement, so that
the returned result set is set read-only. This is not the optimal solution,
since one can get the result set before cancelling the trigger, but in any
case the getTriggerResultTuple will avoid insertions/updates.
Followup
Message
Date: 2010-06-23 07:55
Sender:
Luca Ferrari
I attach also a Java trigger function to test the patch.
The trigger can be used from the sql frontend like the
following:
CREATE FUNCTION trigger_test() RETURNS trigger AS
'itpug.pljava.CancelStatementTriggerTest.triggerFunction'
LANGUAGE 'java';
CREATE TRIGGER trigger_test_impl BEFORE INSERT OR UPDATE OR
DELETE ON
java_table FOR
EACH ROW EXECUTE PROCEDURE trigger_test();
and it will abort each even operation executed on the table.
Attached Files:
Attachments:
triggerdata.patch
CancelStatementTriggerTest.java
Changes:
Field
Old Value
Date
By
File Added
493: CancelStatementTriggerTest.java
2010-06-23 07:55
fluca1978
File Added
492: triggerdata.patch
2010-06-23 07:54
fluca1978