From 5c860290295567052f18ee479512c6dc38abef87 Mon Sep 17 00:00:00 2001 From: Tyler Parsons Date: Thu, 25 Jan 2018 22:55:41 -0500 Subject: [PATCH] Test for correct timestamps in cdb_tablemetadata_text --- test/extension/test.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/extension/test.sh b/test/extension/test.sh index a38bfac..d674e5f 100755 --- a/test/extension/test.sh +++ b/test/extension/test.sh @@ -388,6 +388,36 @@ function test_cdb_tablemetadatatouch_fully_qualifies_names() { sql postgres 'DROP TABLE touch_invalidations' } +function test_cdb_tablemetadata_text() { + + #create and touch tables + sql "CREATE TABLE touch_ex_a (id int);" + sql "CREATE TABLE touch_ex_b (id int);" + sql "CREATE TABLE touch_ex_c (id int);" + sql postgres "SELECT CDB_TableMetadataTouch('touch_ex_a');" + sql postgres "SELECT CDB_TableMetadataTouch('touch_ex_b');" + sql postgres "SELECT CDB_TableMetadataTouch('touch_ex_c');" + + #ensure there is 1 record per table + QUERY="SELECT COUNT(1) FROM (SELECT 1 FROM cdb_tablemetadata_text " + QUERY+="GROUP BY tabname HAVING COUNT(1) > 1) s;" + sql postgres "$QUERY" should "0" + + #ensure timestamps are distinct and properly ordered + QUERY="SELECT (SELECT updated_at FROM CDB_TableMetadata_Text WHERE tabname='public.touch_ex_a')" + QUERY+=" < (SELECT updated_at FROM CDB_TableMetadata_Text WHERE tabname='public.touch_ex_b');" + sql postgres "$QUERY" should "t" + QUERY="SELECT (SELECT updated_at FROM CDB_TableMetadata_Text WHERE tabname='public.touch_ex_b')" + QUERY+=" < (SELECT updated_at FROM CDB_TableMetadata_Text WHERE tabname='public.touch_ex_c');" + sql postgres "$QUERY" should "t" + + #cleanup + sql "DROP TABLE touch_ex_a;" + sql "DROP TABLE touch_ex_b;" + sql "DROP TABLE touch_ex_c;" + +} + function test_cdb_column_names() { sql cdb_testmember_1 'CREATE TABLE cdb_testmember_1.table_cnames(c int, a int, r int, t int, o int);' sql cdb_testmember_2 'CREATE TABLE cdb_testmember_2.table_cnames(d int, b int);'