historic-view #92

Merged
hsh-michaelhoennig merged 19 commits from historic-view into master 2024-08-29 17:00:20 +02:00
Showing only changes of commit 38121ad3dd - Show all commits

View File

@ -21,16 +21,26 @@ create or replace function tx_history_txid()
language plpgsql as $$ language plpgsql as $$
declare declare
historicalTxIdSetting text; historicalTxIdSetting text;
historicalTimestampSetting text;
historicalTxId xid8; historicalTxId xid8;
historicalTimestamp timestamp; historicalTimestamp timestamp;
begin begin
select current_setting('hsadminng.tx_history_txid', true) into historicalTxIdSetting; select coalesce(current_setting('hsadminng.tx_history_txid', true), '') into historicalTxIdSetting;
raise notice 'tx_history_txid(): historicalTxIdSetting=%', historicalTxIdSetting; select coalesce(current_setting('hsadminng.tx_history_timestamp', true), '') into historicalTimestampSetting;
if historicalTxIdSetting > '' and historicalTimestampSetting > '' then
raise exception 'either hsadminng.tx_history_txid or hsadminng.tx_history_timestamp must be set, but both are set: (%, %)',
historicalTxIdSetting, historicalTimestampSetting;
end if;
if historicalTxIdSetting = '' and historicalTimestampSetting = '' then
raise exception 'either hsadminng.tx_history_txid or hsadminng.tx_history_timestamp must be set, but both are unset or empty: (%, %)',
historicalTxIdSetting, historicalTimestampSetting;
end if;
-- just for debugging / making sure the function is only called once per query
-- raise notice 'tx_history_txid() called with: (%, %)', historicalTxIdSetting, historicalTimestampSetting;
if historicalTxIdSetting is null or historicalTxIdSetting = '' then if historicalTxIdSetting is null or historicalTxIdSetting = '' then
select current_setting('hsadminng.tx_history_timestamp', true)::timestamp into historicalTimestamp; select historicalTimestampSetting::timestamp into historicalTimestamp;
raise notice 'tx_history_txid(): historicalTimestamp=%', historicalTimestamp;
select max(txc.txid) from tx_context txc where txc.txtimestamp <= historicalTimestamp into historicalTxId; select max(txc.txid) from tx_context txc where txc.txtimestamp <= historicalTimestamp into historicalTxId;
raise notice 'tx_history_txid(): historicalTxId=%', historicalTxId;
else else
historicalTxId = historicalTxIdSetting::xid8; historicalTxId = historicalTxIdSetting::xid8;
end if; end if;
@ -169,7 +179,7 @@ commit;
-- single version at point in time -- single version at point in time
-- set hsadminng.tx_history_txid to (select max(txid) from tx_context where txtimestamp<='2024-08-27 12:13:13.450821'); -- set hsadminng.tx_history_txid to (select max(txid) from tx_context where txtimestamp<='2024-08-27 12:13:13.450821');
set hsadminng.tx_history_txid to '3249'; set hsadminng.tx_history_txid to '3249';
--set hsadminng.tx_history_timestamp to '2024-08-27 17:52:07.755407'; set hsadminng.tx_history_timestamp to '';
-- all versions -- all versions
select tx_history_txid(), txc.txtimestamp, txc.currentUser, txc.currentTask, haex.* select tx_history_txid(), txc.txtimestamp, txc.currentUser, txc.currentTask, haex.*
from hs_hosting_asset_ex haex from hs_hosting_asset_ex haex