Re: [HACKERS] Changes in Trigger Firing

2013-12-05 Thread Sameer Kumar


  I read somewhere that the best editor is the
 one you master (1) :)
 1: http://www.postgresql.org/message-id/m2wrs6giyp@hi-media.com


Thanks, I am using eclipse now.


Any comments about the utility of this feature? Or is it just me who thinks
this can be useful? I think users/developers of trigger based replication
tools can benefit from this.

I am not sure how replication tools like slony handle a scenario where
replicated table is partitioned and I add a new partition to it.


Regards
Sameer


Re: [HACKERS] Changes in Trigger Firing

2013-12-05 Thread Sameer Kumar
I have been finally able to get the right set of files. I going with below
approach:


1) Add a new column in pg_trigger called tgiscascaded

2) Change pg_trigger.h for this

3) Made changes in trigger.c to insert this values

4) Corresponding changes made in
 - reltrigger.h
 - parsenode.h

5) Changed gram.y to understand a new key word in CREATE TRIGGER statement
CASCADED.
- The new option will be optional and will apply only to
non-constraint triggers
- If the option is specified trigger will CASCADE to child
tables

6) I just complied the source code (modified with above changes) and it
- Added a new column in pg_trigger
- The new column is able to derive its value from CREATE
TRIGGER statement based on whether CASDADED was specified or not
- The value is True if the option was specified
- The value is false if the option was not specified


7) Now I will work on trigger firing mechanism with below approach
   - Before firing triggers, check if it's an inherited table
   - First get CASCADED triggers for parents and fire them
   - Proceed as usual


Any suggestion on improving the approach or comments on need for this
feature are welcome.


Regards
Sameer


Re: [HACKERS] Changes in Trigger Firing

2013-12-05 Thread Sameer Kumar
One scenario where I can forsee an issue is when someone uses the tablename
with-in the trigger function on which the trigger was fired. I am not sure
how and what issue might crop up but this will be one of my test cases.



--
View this message in context: 
http://postgresql.1045698.n5.nabble.com/Hacker-RFC-Changes-in-Trigger-Firing-tp5781566p5781861.html
Sent from the PostgreSQL - hackers mailing list archive at Nabble.com.


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] Changes in Trigger Firing

2013-12-04 Thread Alvaro Herrera
Sameer Kumar wrote:

 
 CreateTrigStmt is passed to CreateTrigger function as an arguement. I am
 struggling to understand how the values for various members of trigger are
 set and where [which file] calls CreateTrigStmt.
 
 
 Can someone provide some help on this?

I think you need better tools to guide you in exploring the source code.
For example, you can use cscope to tell you where is CreateTrigStmt
used, and you would find gram.y; and use it to tell you where
CreateTrigger is used, and you would find utility.c.

Any half-decent code editor should be able to generate a database of
symbols and let you frolic around the various files quickly.  Without
that, anyone would be completely lost in developing new features of even
the lowest complexity.

-- 
Álvaro Herrerahttp://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training  Services


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] Changes in Trigger Firing

2013-12-04 Thread Sameer Kumar


 
  CreateTrigStmt is passed to CreateTrigger function as an arguement. I am
  struggling to understand how the values for various members of trigger
 are
  set and where [which file] calls CreateTrigStmt.
 
 
  Can someone provide some help on this?

 I think you need better tools to guide you in exploring the source code.
 For example, you can use cscope to tell you where is CreateTrigStmt
 used, and you would find gram.y; and use it to tell you where
 CreateTrigger is used, and you would find utility.c.

 Thanks for your advice. I was relying on PostgreSQL documentation which
was quite helpful so far. Let me try some development tool.


 Any half-decent code editor should be able to generate a database of
 symbols and let you frolic around the various files quickly.  Without
 that, anyone would be completely lost in developing new features of even
 the lowest complexity.


Got the point!


Re: [HACKERS] Changes in Trigger Firing

2013-12-04 Thread Michael Paquier
On Wed, Dec 4, 2013 at 11:16 PM, Alvaro Herrera
alvhe...@2ndquadrant.com wrote:
 Sameer Kumar wrote:
 I think you need better tools to guide you in exploring the source code.
 For example, you can use cscope to tell you where is CreateTrigStmt
 used, and you would find gram.y; and use it to tell you where
 CreateTrigger is used, and you would find utility.c.

 Any half-decent code editor should be able to generate a database of
 symbols and let you frolic around the various files quickly.  Without
 that, anyone would be completely lost in developing new features of even
 the lowest complexity.
Not always, other people find as well git grep quite useful when
coding a complex tree. I read somewhere that the best editor is the
one you master (1) :)
1: http://www.postgresql.org/message-id/m2wrs6giyp@hi-media.com
-- 
Michael


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


[HACKERS] Changes in Trigger Firing

2013-12-03 Thread Sameer Kumar
Hi all,

I am doing some changes in trigger firing mechanism (as a POC first, I will
share my work if people find it useful and if it works).

I am going to extend the trigger calls to child tables. So that in trigger
definition I can create triggers with CASCADED TRUE | FALSE option.

This will enable me to extend certain triggers to child tables and get over
the scenarios when a record gets inserted in child table and any *after
insert* triggers on parent tables never get fired.

I am right now trying to change pg_trigger and CreateTrigger function. I
have made changes in below files:
trigger.c:
 - Added a New Variable cascadedOption (bool)
 - Added a new statement in trigger.c to set the value:
 values[Anum_pg_trigger_tgiscascaded - 1] =
BoolGetDatum(stmt-cascadedOption);
 -  Added a new column in CATALOG definition of pg_trigger in
pg_trigger.h
   bool tgiscascaded;
 -  In pg_trigger.h, added a new position for values
#define Anum_pg_trigger_tgiscascaded16
 - Modified parsenode.h to add a new element in Structure for trigger
statement -CreateTrigStmt

 boolcascadedOption;

CreateTrigStmt is passed to CreateTrigger function as an arguement. I am
struggling to understand how the values for various members of trigger are
set and where [which file] calls CreateTrigStmt.


Can someone provide some help on this?


Best Regards,
*Sameer Kumar | Database Consultant*

*ASHNIK PTE. LTD. *101 Cecil Street, #11-11 Tong Eng Building, Singapore
069533
M : *+65 8110 0350* T: +65 6438 3504 | www.ashnik.com
www.facebook.com/ashnikbiz | www.twitter.com/ashnikbiz

[image: email patch]

This email may contain confidential, privileged or copyright material and
is solely for the use of the intended recipient(s).
image002.jpg