From 7a5ce833a405cf2d09dff9122a65984162911a42 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Mon, 5 May 2014 12:43:37 +0200 Subject: [PATCH] Fix expected result --- expected/test_ddl_triggers.out | 214 +++++++++++++++++++++++++-------- 1 file changed, 165 insertions(+), 49 deletions(-) diff --git a/expected/test_ddl_triggers.out b/expected/test_ddl_triggers.out index b34e709..f372219 100644 --- a/expected/test_ddl_triggers.out +++ b/expected/test_ddl_triggers.out @@ -1,59 +1,175 @@ ---\i cartodb_hooks.sql ---\set VERBOSITY terse -CREATE TABLE IF NOT EXISTS - public.CDB_TableMetadata ( - tabname regclass not null primary key, - updated_at timestamp with time zone not null default now() - ); +CREATE EXTENSION postgis; +CREATE EXTENSION schema_triggers; +CREATE EXTENSION cartodb; +set search_path to public,cartodb,schema_triggers; +--set client_min_messages to debug; +-- 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'; +--SELECT tmp(); +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 schema c; -ERROR: permission denied for database contrib_regression ---create table c.t3(a int); +---------------------- +-- CREATE TABLE +---------------------- select 1 as i INTO c.t3; -ERROR: schema "c" does not exist -select * from c.t3; -ERROR: relation "c.t3" does not exist -LINE 1: select * from c.t3; - ^ -select tabname::text, updated_at from CDB_TableMetadata; -ERROR: permission denied for relation cdb_tablemetadata +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; -ERROR: schema "c" does not exist -select * from c.t3; -ERROR: relation "c.t3" does not exist -LINE 1: select * from c.t3; - ^ -select tabname::text, updated_at from CDB_TableMetadata; -ERROR: permission denied for relation cdb_tablemetadata +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 | f | | | 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) + +select pg_sleep(1); + pg_sleep +---------- + +(1 row) + alter table c.t3 rename column the_geom_webmercator to webmerc2; -ERROR: schema "c" does not exist -select * from c.t3; -ERROR: relation "c.t3" does not exist -LINE 1: select * from c.t3; - ^ -select tabname::text, updated_at from CDB_TableMetadata; -ERROR: permission denied for relation cdb_tablemetadata +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 | f | | | 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 DROP COLUMN +---------------------------- +select pg_sleep(1); + pg_sleep +---------- + +(1 row) + alter table c.t3 drop column the_geom_webmercator; -ERROR: schema "c" does not exist -select * from c.t3; -ERROR: relation "c.t3" does not exist -LINE 1: select * from c.t3; - ^ -select tabname::text, updated_at from CDB_TableMetadata; -ERROR: permission denied for relation cdb_tablemetadata +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 | f | | | 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 ADD COLUMN +---------------------------- +select pg_sleep(1); + pg_sleep +---------- + +(1 row) + alter table c.t3 add column id2 int; -ERROR: schema "c" does not exist -select * from c.t3; -ERROR: relation "c.t3" does not exist -LINE 1: select * from c.t3; - ^ -select tabname::text, updated_at from CDB_TableMetadata; -ERROR: permission denied for relation cdb_tablemetadata +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 | f | | | 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) + +---------------------------- +-- DROP TABLE +---------------------------- +RESET SESSION AUTHORIZATION; drop schema c cascade; -ERROR: schema "c" does not exist -select tabname::text, updated_at from CDB_TableMetadata; -ERROR: permission denied for relation cdb_tablemetadata +select count(*) from CDB_TableMetadata; + count +------- + 0 +(1 row) + DROP USER cartodb_postgresql_unpriv_user; -ERROR: permission denied to drop role