Fix expected result

This commit is contained in:
Sandro Santilli 2014-05-05 12:43:37 +02:00
parent 1a7fd8fd67
commit 7a5ce833a4

View File

@ -1,59 +1,175 @@
--\i cartodb_hooks.sql CREATE EXTENSION postgis;
--\set VERBOSITY terse CREATE EXTENSION schema_triggers;
CREATE TABLE IF NOT EXISTS CREATE EXTENSION cartodb;
public.CDB_TableMetadata ( set search_path to public,cartodb,schema_triggers;
tabname regclass not null primary key, --set client_min_messages to debug;
updated_at timestamp with time zone not null default now() -- 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; CREATE USER cartodb_postgresql_unpriv_user;
GRANT ALL ON SCHEMA c to cartodb_postgresql_unpriv_user;
SET SESSION AUTHORIZATION 'cartodb_postgresql_unpriv_user'; SET SESSION AUTHORIZATION 'cartodb_postgresql_unpriv_user';
--SELECT session_user, current_user; --SELECT session_user, current_user;
create schema c; ----------------------
ERROR: permission denied for database contrib_regression -- CREATE TABLE
--create table c.t3(a int); ----------------------
select 1 as i INTO c.t3; select 1 as i INTO c.t3;
ERROR: schema "c" does not exist select
select * from c.t3; cartodb_id, created_at=updated_at as "c=u",
ERROR: relation "c.t3" does not exist NOW() - updated_at < '1 secs' as "u<1s",
LINE 1: select * from c.t3; the_geom, the_geom_webmercator,
^ i
select tabname::text, updated_at from CDB_TableMetadata; from c.t3;
ERROR: permission denied for relation cdb_tablemetadata 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; alter table c.t3 rename column the_geom_webmercator to webmerc;
ERROR: schema "c" does not exist select
select * from c.t3; cartodb_id, created_at=updated_at as "c=u",
ERROR: relation "c.t3" does not exist NOW() - updated_at < '1 secs' as "u<1s",
LINE 1: select * from c.t3; the_geom, the_geom_webmercator,
^ i, webmerc
select tabname::text, updated_at from CDB_TableMetadata; from c.t3;
ERROR: permission denied for relation cdb_tablemetadata 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; alter table c.t3 rename column the_geom_webmercator to webmerc2;
ERROR: schema "c" does not exist select
select * from c.t3; cartodb_id, created_at=updated_at as "c=u",
ERROR: relation "c.t3" does not exist NOW() - updated_at < '1 secs' as "u<1s",
LINE 1: select * from c.t3; the_geom, the_geom_webmercator,
^ i, webmerc, webmerc2
select tabname::text, updated_at from CDB_TableMetadata; from c.t3;
ERROR: permission denied for relation cdb_tablemetadata 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; alter table c.t3 drop column the_geom_webmercator;
ERROR: schema "c" does not exist select
select * from c.t3; cartodb_id, created_at=updated_at as "c=u",
ERROR: relation "c.t3" does not exist NOW() - updated_at < '1 secs' as "u<1s",
LINE 1: select * from c.t3; the_geom, the_geom_webmercator,
^ i, webmerc, webmerc2
select tabname::text, updated_at from CDB_TableMetadata; from c.t3;
ERROR: permission denied for relation cdb_tablemetadata 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; alter table c.t3 add column id2 int;
ERROR: schema "c" does not exist select
select * from c.t3; cartodb_id, created_at=updated_at as "c=u",
ERROR: relation "c.t3" does not exist NOW() - updated_at < '1 secs' as "u<1s",
LINE 1: select * from c.t3; the_geom, the_geom_webmercator,
^ i, webmerc, webmerc2, id2
select tabname::text, updated_at from CDB_TableMetadata; from c.t3;
ERROR: permission denied for relation cdb_tablemetadata 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; drop schema c cascade;
ERROR: schema "c" does not exist select count(*) from CDB_TableMetadata;
select tabname::text, updated_at from CDB_TableMetadata; count
ERROR: permission denied for relation cdb_tablemetadata -------
0
(1 row)
DROP USER cartodb_postgresql_unpriv_user; DROP USER cartodb_postgresql_unpriv_user;
ERROR: permission denied to drop role