@@ -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- Youhave to create trigger (BEFORE INSERT OR UPDATE) using this
12- function on a table referencing another table. Youhave to specify
11+ Youare to create trigger (BEFORE INSERT OR UPDATE) using this
12+ function on a table referencing another table. Youare 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- Youhave to create trigger (BEFORE DELETE OR UPDATE) using this
22- function on a table referenced by another table(s). Youhave to specify
21+ Youare to create trigger (BEFORE DELETE OR UPDATE) using this
22+ function on a table referenced by another table(s). Youare 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,26 +42,20 @@ refint.source).
4242
4343 Old internally supported time-travel (TT) used insert/delete
4444transaction commit times. To get the same feature using triggers
45- youhave to add to a table two columns of abstime type to store
45+ youare 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,
52- date_offabstime
51+ date_onabstime default currabstime() ,
52+ date_offabstime default 'infinity'
5353......
5454);
5555
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).
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).
6559
6660 Tuples with stop_date equal INFINITY are "valid now": when trigger will
6761be fired for UPDATE/DELETE of a tuple with stop_date NOT equal INFINITY then
@@ -78,7 +72,7 @@ DELETE: new tuple will be inserted with stop_date setted to current date
7872(and with the same data in other columns as in tuple being deleted).
7973
8074 NOTE:
81- 1. To get tuples "valid now" youhave to add _stop_date_ = 'infinity'
75+ 1. To get tuples "valid now" youare to add _stop_date_ = 'infinity'
8276 to WHERE. Internally supported TT allowed to avoid this...
8377 Fixed rewriting RULEs could help here...
8478 As work arround you may use VIEWs...
@@ -89,61 +83,22 @@ DELETE: new tuple will be inserted with stop_date setted to current date
8983
9084timetravel() is general trigger function.
9185
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.
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.
9592
9693set_timetravel() allows you turn time-travel ON/OFF for a table:
9794
9895 set_timetravel('XXX', 1) will turn TT ON for table XXX (and report
9996old status).
10097 set_timetravel('XXX', 0) will turn TT OFF for table XXX (-"-).
10198
102- Turning TT OFF allows you do with a table ALL what you want!
99+ Turning TT OFF allows you do with a table ALL what you want.
103100
104101 There is example in timetravel.example.
105102
106103 To CREATE FUNCTIONs use timetravel.sql (will be made by gmake from
107104timetravel.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-
125- 4. insert_username.c - function for inserting user names.
126-
127- You have to create BEFORE INSERT OR UPDATE trigger using the function
128- insert_username(). You have to specify as a function argument: the column
129- name (of text type) in which user names will be inserted. Note that user
130- names will be inserted irregardless of the initial value of the field, so
131- that users cannot bypass this functionality by simply defining the field to
132- be NOT NULL.
133-
134- There is an example in insert_username.example.
135-
136- To CREATE FUNCTION use insert_username.sql (will be made by gmake from
137- insert_username.source).
138-
139-
140- 5. moddatetime.c - function for maintaining a modification datetime stamp.
141-
142- You have to create a BEFORE UPDATE trigger using the function moddatetime().
143- One argument must be given, that is the name of the field that is of type
144- datetime that is to be used as the modification time stamp.
145-
146- There is an example in moddatetime.example.
147-
148- To CREATE FUNCTION use moddatetime.sql ( will be made by gmake from
149- moddatetime.source).