Re: AS OF queries

legrand legrand <legrand_legrand@hotmail.com>

From: legrand legrand <legrand_legrand@hotmail.com>
To: pgsql-hackers@postgresql.org
Date: 2018-01-03T20:49:03Z
Lists: pgsql-hackers
Maybe that a simple check of the asof_timestamp value like:

asof_timestamp >= now() - time_travel_period
AND 
asof_timestamp >= latest_table_ddl

would permit to raise a warning or an error message saying that query result
can not be garanteed with this asof_timestamp value.


latest_table_ddl being found with

SELECT greatest( max(pg_xact_commit_timestamp( rel.xmin )),
max(pg_xact_commit_timestamp( att.xmin ))) as latest_table_ddl 
FROM	  pg_catalog.pg_attribute att 	
INNER JOIN pg_catalog.pg_class rel	 
ON att.attrelid = rel.oid WHERE	rel.relname = '<asof_tablename>' and
rel.relowner= ...

(tested with add/alter/drop column and drop/create/truncate table)

Regards
PAscal



--
Sent from: http://www.postgresql-archive.org/PostgreSQL-hackers-f1928748.html