Merge pull request #320 from bloomberg/v0_18_5/cdb_tablemetadata_text_hotfix

Fix incorrect timestamps in CDB_TableMetadata_Text
This commit is contained in:
Eneko Lakasta 2018-07-23 16:00:19 +02:00 committed by GitHub
commit b209726b1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 2 deletions

View File

@ -7,7 +7,7 @@ CREATE TABLE IF NOT EXISTS
CREATE OR REPLACE VIEW public.CDB_TableMetadata_Text AS CREATE OR REPLACE VIEW public.CDB_TableMetadata_Text AS
SELECT FORMAT('%I.%I', n.nspname::text, c.relname::text) tabname, updated_at SELECT FORMAT('%I.%I', n.nspname::text, c.relname::text) tabname, updated_at
FROM public.CDB_TableMetadata, pg_catalog.pg_class c FROM public.CDB_TableMetadata m JOIN pg_catalog.pg_class c ON m.tabname::oid = c.oid
LEFT JOIN pg_catalog.pg_namespace n ON c.relnamespace = n.oid; LEFT JOIN pg_catalog.pg_namespace n ON c.relnamespace = n.oid;
-- No one can see this -- No one can see this

View File

@ -418,6 +418,36 @@ function test_cdb_tablemetadatatouch_fully_qualifies_names() {
sql postgres 'DROP TABLE touch_invalidations' 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() { 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_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);' sql cdb_testmember_2 'CREATE TABLE cdb_testmember_2.table_cnames(d int, b int);'
@ -543,7 +573,12 @@ END
DATABASE=fdw_target sql postgres "SELECT cdb_tablemetadatatouch('test_fdw.foo'::regclass);" DATABASE=fdw_target sql postgres "SELECT cdb_tablemetadatatouch('test_fdw.foo'::regclass);"
DATABASE=fdw_target sql postgres "SELECT cdb_tablemetadatatouch('test_fdw.foo2'::regclass);" DATABASE=fdw_target sql postgres "SELECT cdb_tablemetadatatouch('test_fdw.foo2'::regclass);"
sql postgres "SELECT cartodb.CDB_Conf_SetConf('fdws', '{\"test_fdw\": {\"server\": {\"host\": \"localhost\", \"dbname\": \"fdw_target\"}, # Add PGPORT to conf if it is set
PORT_SPEC=""
if [[ "$PGPORT" != "" ]] ; then
PORT_SPEC=", \"port\": \"$PGPORT\""
fi
sql postgres "SELECT cartodb.CDB_Conf_SetConf('fdws', '{\"test_fdw\": {\"server\": {\"host\": \"localhost\", \"dbname\": \"fdw_target\" $PORT_SPEC },
\"users\": {\"public\": {\"user\": \"fdw_user\", \"password\": \"foobarino\"}}}}')" \"users\": {\"public\": {\"user\": \"fdw_user\", \"password\": \"foobarino\"}}}}')"
sql postgres "SELECT cartodb._CDB_Setup_FDW('test_fdw')" sql postgres "SELECT cartodb._CDB_Setup_FDW('test_fdw')"