-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
These are columns for which updates do not cause `GENERATED ALWAYS AS ROW START` to change, and historical rows will not be generated. This is not in the standard, but was requested by several people.
- Loading branch information
Vik Fearing
committed
Sep 12, 2019
1 parent
a658893
commit 47353c1
Showing
19 changed files
with
1,315 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
CREATE TABLE excl ( | ||
value text NOT NULL, | ||
null_value integer, | ||
flap text NOT NULL | ||
); | ||
SELECT periods.add_system_time_period('excl', excluded_column_names => ARRAY['flap']); | ||
add_system_time_period | ||
------------------------ | ||
t | ||
(1 row) | ||
|
||
SELECT periods.add_system_versioning('excl'); | ||
NOTICE: history table "excl_history" created for "excl", be sure to index it properly | ||
add_system_versioning | ||
----------------------- | ||
|
||
(1 row) | ||
|
||
TABLE periods.periods; | ||
table_name | period_name | start_column_name | end_column_name | range_type | bounds_check_constraint | ||
------------+-------------+-------------------+-----------------+------------+------------------------- | ||
excl | system_time | system_time_start | system_time_end | tstzrange | excl_system_time_check | ||
(1 row) | ||
|
||
TABLE periods.system_time_periods; | ||
table_name | period_name | infinity_check_constraint | generated_always_trigger | write_history_trigger | truncate_trigger | excluded_column_names | ||
------------+-------------+-------------------------------------+-----------------------------------+--------------------------------+------------------+----------------------- | ||
excl | system_time | excl_system_time_end_infinity_check | excl_system_time_generated_always | excl_system_time_write_history | excl_truncate | {flap} | ||
(1 row) | ||
|
||
TABLE periods.system_versioning; | ||
table_name | period_name | history_table_name | view_name | func_as_of | func_between | func_between_symmetric | func_from_to | ||
------------+-------------+--------------------+-------------------+---------------------------------------+------------------------------------------------------------------+----------------------------------------------------------------------------+------------------------------------------------------------------ | ||
excl | system_time | excl_history | excl_with_history | excl__as_of(timestamp with time zone) | excl__between(timestamp with time zone,timestamp with time zone) | excl__between_symmetric(timestamp with time zone,timestamp with time zone) | excl__from_to(timestamp with time zone,timestamp with time zone) | ||
(1 row) | ||
|
||
BEGIN; | ||
SELECT CURRENT_TIMESTAMP AS now \gset | ||
INSERT INTO excl (value, flap) VALUES ('hello world', 'off'); | ||
COMMIT; | ||
SELECT value, null_value, flap, system_time_start <> :'now' AS changed FROM excl; | ||
value | null_value | flap | changed | ||
-------------+------------+------+--------- | ||
hello world | | off | f | ||
(1 row) | ||
|
||
UPDATE excl SET flap = 'off'; | ||
UPDATE excl SET flap = 'on'; | ||
UPDATE excl SET flap = 'off'; | ||
UPDATE excl SET flap = 'on'; | ||
SELECT value, null_value, flap, system_time_start <> :'now' AS changed FROM excl; | ||
value | null_value | flap | changed | ||
-------------+------------+------+--------- | ||
hello world | | on | f | ||
(1 row) | ||
|
||
BEGIN; | ||
SELECT CURRENT_TIMESTAMP AS now2 \gset | ||
UPDATE excl SET value = 'howdy folks!'; | ||
COMMIT; | ||
SELECT value, null_value, flap, system_time_start <> :'now' AS changed FROM excl; | ||
value | null_value | flap | changed | ||
--------------+------------+------+--------- | ||
howdy folks! | | on | t | ||
(1 row) | ||
|
||
UPDATE excl SET null_value = 0; | ||
SELECT value, null_value, flap, system_time_start <> :'now2' AS changed FROM excl; | ||
value | null_value | flap | changed | ||
--------------+------------+------+--------- | ||
howdy folks! | 0 | on | t | ||
(1 row) | ||
|
||
SELECT periods.drop_system_versioning('excl'); | ||
drop_system_versioning | ||
------------------------ | ||
t | ||
(1 row) | ||
|
||
SELECT periods.drop_system_time_period('excl'); | ||
drop_system_time_period | ||
------------------------- | ||
t | ||
(1 row) | ||
|
||
DROP TABLE excl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.