1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
SELECT setting::integer < 90600 AS pre_96
FROM pg_settings WHERE name = 'server_version_num';
pre_96
--------
t
(1 row)
/* Run tests as unprivileged user */
SET ROLE TO periods_unprivileged_user;
/* Ensure tables with periods are persistent */
CREATE UNLOGGED TABLE log (id bigint, s date, e date);
SELECT periods.add_period('log', 'p', 's', 'e'); -- fails
ERROR: table "log" must be persistent
SELECT periods.add_system_time_period('log'); -- fails
ERROR: table "log" must be persistent
ALTER TABLE log SET LOGGED;
SELECT periods.add_period('log', 'p', 's', 'e'); -- passes
add_period
------------
t
(1 row)
SELECT periods.add_system_time_period('log'); -- passes
add_system_time_period
------------------------
t
(1 row)
ALTER TABLE log SET UNLOGGED; -- fails
ERROR: table "log" must remain persistent because it has periods
SELECT periods.add_system_versioning('log');
NOTICE: history table "log_history" created for "log", be sure to index it properly
add_system_versioning
-----------------------
(1 row)
ALTER TABLE log_history SET UNLOGGED; -- fails
ERROR: history table "log" must remain persistent because it has periods
SELECT periods.drop_system_versioning('log', purge => true);
drop_system_versioning
------------------------
t
(1 row)
DROP TABLE log;
|