\set VERBOSITY terse -- Create a stub cdb_invalidate_varnish function if not available --CREATE FUNCTION tmp() returns void AS $$ DO $$ BEGIN PERFORM cdb_invalidate_varnish(0); EXCEPTION WHEN undefined_function THEN CREATE OR REPLACE FUNCTION cartodb.cdb_invalidate_varnish(tabname text) RETURNS void AS '' LANGUAGE 'sql'; END; $$ LANGUAGE 'plpgsql'; -- Set user quota to infinite SELECT CDB_SetUserQuotaInBytes(0); cdb_setuserquotainbytes ------------------------- 0 (1 row) create schema c; CREATE USER cartodb_postgresql_unpriv_user; GRANT ALL ON SCHEMA c to cartodb_postgresql_unpriv_user; SET SESSION AUTHORIZATION 'cartodb_postgresql_unpriv_user'; --SELECT session_user, current_user; ---------------------- -- CREATE TABLE ---------------------- select 1 as i INTO c.t3; NOTICE: trigger "track_updates" for table "c.t3" does not exist, skipping NOTICE: trigger "update_the_geom_webmercator_trigger" for table "c.t3" does not exist, skipping NOTICE: trigger "update_updated_at_trigger" for table "c.t3" does not exist, skipping NOTICE: trigger "test_quota" for table "c.t3" does not exist, skipping NOTICE: trigger "test_quota_per_row" for table "c.t3" does not exist, skipping NOTICE: cdb_invalidate_varnish(c.t3) called select cartodb_id, created_at=updated_at as "c=u", NOW() - updated_at < '1 secs' as "u<1s", the_geom, the_geom_webmercator, i from c.t3; cartodb_id | c=u | u<1s | the_geom | the_geom_webmercator | i ------------+-----+------+----------+----------------------+--- 1 | t | t | | | 1 (1 row) select tabname::text, round(extract('secs' from now() - updated_at)) as age FROM CDB_TableMetadata; tabname | age ---------+----- c.t3 | 0 (1 row) ---------------------------- -- ALTER TABLE RENAME COLUMN ---------------------------- select pg_sleep(.1); pg_sleep ---------- (1 row) alter table c.t3 rename column the_geom_webmercator to webmerc; NOTICE: Column cartodb_id already exists NOTICE: Column created_at already exists NOTICE: Column updated_at already exists NOTICE: Column the_geom already exists NOTICE: event trigger "cdb_on_relation_create" does not exist, skipping NOTICE: event trigger "cdb_on_relation_drop" does not exist, skipping NOTICE: event trigger "cdb_on_alter_column" does not exist, skipping NOTICE: event trigger "cdb_on_drop_column" does not exist, skipping NOTICE: event trigger "cdb_on_add_column" does not exist, skipping NOTICE: cdb_invalidate_varnish(c.t3) called select cartodb_id, created_at=updated_at as "c=u", NOW() - updated_at < '1 secs' as "u<1s", the_geom, the_geom_webmercator, i, webmerc from c.t3; cartodb_id | c=u | u<1s | the_geom | the_geom_webmercator | i | webmerc ------------+-----+------+----------+----------------------+---+--------- 1 | t | t | | | 1 | (1 row) select tabname::text, round(extract('secs' from now() - updated_at)*10) as agecs FROM CDB_TableMetadata; tabname | agecs ---------+------- c.t3 | 0 (1 row) select pg_sleep(.1); pg_sleep ---------- (1 row) alter table c.t3 rename column the_geom_webmercator to webmerc2; NOTICE: Column cartodb_id already exists NOTICE: Column created_at already exists NOTICE: Column updated_at already exists NOTICE: Column the_geom already exists NOTICE: event trigger "cdb_on_relation_create" does not exist, skipping NOTICE: event trigger "cdb_on_relation_drop" does not exist, skipping NOTICE: event trigger "cdb_on_alter_column" does not exist, skipping NOTICE: event trigger "cdb_on_drop_column" does not exist, skipping NOTICE: event trigger "cdb_on_add_column" does not exist, skipping NOTICE: cdb_invalidate_varnish(c.t3) called select cartodb_id, created_at=updated_at as "c=u", NOW() - updated_at < '1 secs' as "u<1s", the_geom, the_geom_webmercator, i, webmerc, webmerc2 from c.t3; cartodb_id | c=u | u<1s | the_geom | the_geom_webmercator | i | webmerc | webmerc2 ------------+-----+------+----------+----------------------+---+---------+---------- 1 | t | t | | | 1 | | (1 row) select tabname::text, round(extract('secs' from now() - updated_at)*10) as agecs FROM CDB_TableMetadata; tabname | agecs ---------+------- c.t3 | 0 (1 row) ---------------------------- -- ALTER TABLE DROP COLUMN ---------------------------- select pg_sleep(.1); pg_sleep ---------- (1 row) alter table c.t3 drop column the_geom_webmercator; NOTICE: Column cartodb_id already exists NOTICE: Column created_at already exists NOTICE: Column updated_at already exists NOTICE: Column the_geom already exists NOTICE: event trigger "cdb_on_relation_create" does not exist, skipping NOTICE: event trigger "cdb_on_relation_drop" does not exist, skipping NOTICE: event trigger "cdb_on_alter_column" does not exist, skipping NOTICE: event trigger "cdb_on_drop_column" does not exist, skipping NOTICE: event trigger "cdb_on_add_column" does not exist, skipping NOTICE: cdb_invalidate_varnish(c.t3) called select cartodb_id, created_at=updated_at as "c=u", NOW() - updated_at < '1 secs' as "u<1s", the_geom, the_geom_webmercator, i, webmerc, webmerc2 from c.t3; cartodb_id | c=u | u<1s | the_geom | the_geom_webmercator | i | webmerc | webmerc2 ------------+-----+------+----------+----------------------+---+---------+---------- 1 | t | t | | | 1 | | (1 row) select tabname::text, round(extract('secs' from now() - updated_at)*10) as agecs FROM CDB_TableMetadata; tabname | agecs ---------+------- c.t3 | 0 (1 row) ---------------------------- -- ALTER TABLE ADD COLUMN ---------------------------- select pg_sleep(.1); pg_sleep ---------- (1 row) alter table c.t3 add column id2 int; NOTICE: cdb_invalidate_varnish(c.t3) called select cartodb_id, created_at=updated_at as "c=u", NOW() - updated_at < '1 secs' as "u<1s", the_geom, the_geom_webmercator, i, webmerc, webmerc2, id2 from c.t3; cartodb_id | c=u | u<1s | the_geom | the_geom_webmercator | i | webmerc | webmerc2 | id2 ------------+-----+------+----------+----------------------+---+---------+----------+----- 1 | t | t | | | 1 | | | (1 row) select tabname::text, round(extract('secs' from now() - updated_at)*10) as agecs FROM CDB_TableMetadata; tabname | agecs ---------+------- c.t3 | 0 (1 row) ---------------------------- -- DROP TABLE ---------------------------- RESET SESSION AUTHORIZATION; drop schema c cascade; NOTICE: drop cascades to table c.t3 select count(*) from CDB_TableMetadata; count ------- 0 (1 row) DROP USER cartodb_postgresql_unpriv_user; DROP FUNCTION _CDB_UserQuotaInBytes();