@@ -8,8 +8,8 @@ table/field names (as described below) while creating a trigger.
88
99check_primary_key () is to used for foreign keys of a table.
1010
11- Youare to create trigger (BEFORE INSERT OR UPDATE) using this
12- function on a table referencing another table. Youare to specify
11+ Youhave to create trigger (BEFORE INSERT OR UPDATE) using this
12+ function on a table referencing another table. Youhave to specify
1313as function arguments: triggered table column names which correspond
1414to foreign key, referenced table name and column names in referenced
1515table which correspond to primary/unique key.
@@ -18,8 +18,8 @@ one reference.
1818
1919check_foreign_key () is to used for primary/unique keys of a table.
2020
21- Youare to create trigger (BEFORE DELETE OR UPDATE) using this
22- function on a table referenced by another table(s). Youare to specify
21+ Youhave to create trigger (BEFORE DELETE OR UPDATE) using this
22+ function on a table referenced by another table(s). Youhave to specify
2323as function arguments: number of references for which function has to
2424performe checking, action if referencing key found ('cascade' - to delete
2525corresponding foreign key, 'restrict' - to abort transaction if foreign keys
@@ -42,20 +42,26 @@ refint.source).
4242
4343 Old internally supported time-travel (TT) used insert/delete
4444transaction commit times. To get the same feature using triggers
45- youare to add to a table two columns of abstime type to store
45+ youhave to add to a table two columns of abstime type to store
4646date when a tuple was inserted (start_date) and changed/deleted
4747(stop_date):
4848
4949CREATE TABLE XXX (
5050......
51- date_onabstime default currabstime() ,
52- date_offabstime default 'infinity'
51+ date_onabstime,
52+ date_offabstime
5353......
5454);
5555
56- - so, tuples being inserted with NULLs in date_on/date_off will get
57- _current_date_ in date_on (name of start_date column in XXX) and INFINITY in
58- date_off (name of stop_date column in XXX).
56+ CREATE TRIGGER timetravel
57+ BEFORE INSERT OR DELETE OR UPDATE ON tttest
58+ FOR EACH ROW
59+ EXECUTE PROCEDURE
60+ timetravel (date_on, date_off);
61+
62+ Tuples being inserted with NULLs in date_on/date_off will get current
63+ date in date_on (name of start_date column in XXX) and INFINITY in date_off
64+ (name of stop_date column in XXX).
5965
6066 Tuples with stop_date equal INFINITY are "valid now": when trigger will
6167be fired for UPDATE/DELETE of a tuple with stop_date NOT equal INFINITY then
@@ -72,7 +78,7 @@ DELETE: new tuple will be inserted with stop_date setted to current date
7278(and with the same data in other columns as in tuple being deleted).
7379
7480 NOTE:
75- 1. To get tuples "valid now" youare to add _stop_date_ = 'infinity'
81+ 1. To get tuples "valid now" youhave to add _stop_date_ = 'infinity'
7682 to WHERE. Internally supported TT allowed to avoid this...
7783 Fixed rewriting RULEs could help here...
7884 As work arround you may use VIEWs...
@@ -83,22 +89,36 @@ DELETE: new tuple will be inserted with stop_date setted to current date
8389
8490timetravel() is general trigger function.
8591
86- You are to create trigger BEFORE (!!!) UPDATE OR DELETE using this
87- function on a time-traveled table. You are to specify two arguments: name of
88- start_date column and name of stop_date column in triggered table.
89-
90- currabstime() may be used in DEFAULT for start_date column to get
91- current date.
92+ You have to create trigger BEFORE (!!!) INSERT OR UPDATE OR DELETE using
93+ this function on a time-traveled table. You have to specify two arguments:
94+ name of start_date column and name of stop_date column in triggered table.
9295
9396set_timetravel() allows you turn time-travel ON/OFF for a table:
9497
9598 set_timetravel('XXX', 1) will turn TT ON for table XXX (and report
9699old status).
97100 set_timetravel('XXX', 0) will turn TT OFF for table XXX (-"-).
98101
99- Turning TT OFF allows you do with a table ALL what you want.
102+ Turning TT OFF allows you do with a table ALL what you want!
100103
101104 There is example in timetravel.example.
102105
103106 To CREATE FUNCTIONs use timetravel.sql (will be made by gmake from
104107timetravel.source).
108+
109+
110+ 3. autoinc.c - function for implementing AUTOINCREMENT/IDENTITY feature.
111+
112+ You have to create BEFORE INSERT OR UPDATE trigger using function
113+ autoinc(). You have to specify as function arguments: column name
114+ (of int4 type) for which you want to get this feature and name of
115+ SEQUENCE from which next value has to be fetched when NULL or 0
116+ value is being inserted into column (, ... - you are able to specify
117+ as many column/sequence pairs as you need).
118+
119+ There is example in autoinc.example.
120+
121+ To CREATE FUNCTION use autoinc.sql (will be made by gmake from
122+ autoinc.source).
123+
124+