2014-05-06 16:18:38 +08:00
|
|
|
\set VERBOSITY terse
|
2014-05-01 01:03:14 +08:00
|
|
|
|
2014-05-12 19:07:47 +08:00
|
|
|
-- Set user quota to infinite
|
|
|
|
SELECT CDB_SetUserQuotaInBytes(0);
|
2014-05-01 01:03:14 +08:00
|
|
|
|
2014-05-22 17:40:01 +08:00
|
|
|
-- Enable ddl triggers
|
|
|
|
SELECT cartodb.cdb_enable_ddl_hooks();
|
|
|
|
|
2014-05-01 01:03:14 +08:00
|
|
|
create schema c;
|
|
|
|
|
2014-11-19 17:00:04 +08:00
|
|
|
SELECT CDB_SetUserQuotaInBytes('c', 0);
|
|
|
|
|
2014-05-01 01:03:14 +08:00
|
|
|
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;
|
|
|
|
|
2014-05-05 18:20:38 +08:00
|
|
|
----------------------
|
|
|
|
-- CREATE TABLE
|
|
|
|
----------------------
|
2015-02-10 22:27:42 +08:00
|
|
|
SET SESSION AUTHORIZATION 'cartodb_postgresql_unpriv_user';
|
2014-05-01 01:03:14 +08:00
|
|
|
select 1 as i INTO c.t3;
|
2014-05-05 18:20:38 +08:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2015-02-10 22:27:42 +08:00
|
|
|
RESET SESSION AUTHORIZATION;
|
2014-05-05 18:20:38 +08:00
|
|
|
select
|
|
|
|
tabname::text,
|
|
|
|
round(extract('secs' from now() - updated_at)) as age
|
2014-05-28 15:02:02 +08:00
|
|
|
FROM CDB_TableMetadata WHERE tabname = 'c.t3'::regclass;
|
|
|
|
|
2015-02-10 22:27:42 +08:00
|
|
|
SET SESSION AUTHORIZATION 'cartodb_postgresql_unpriv_user';
|
2014-05-28 15:02:02 +08:00
|
|
|
-- Table with cartodb_id field, see
|
|
|
|
-- http://github.com/CartoDB/cartodb-postgresql/issues/32
|
|
|
|
select 1 as cartodb_id INTO c.t4;
|
|
|
|
select
|
|
|
|
cartodb_id, created_at=updated_at as "c=u",
|
|
|
|
NOW() - updated_at < '1 secs' as "u<1s",
|
|
|
|
the_geom, the_geom_webmercator
|
|
|
|
from c.t4;
|
2015-02-10 22:27:42 +08:00
|
|
|
|
|
|
|
RESET SESSION AUTHORIZATION;
|
2014-05-28 15:02:02 +08:00
|
|
|
select
|
|
|
|
tabname::text,
|
|
|
|
round(extract('secs' from now() - updated_at)) as age
|
|
|
|
FROM CDB_TableMetadata WHERE tabname = 'c.t4'::regclass;
|
2014-05-05 18:20:38 +08:00
|
|
|
|
|
|
|
----------------------------
|
|
|
|
-- ALTER TABLE RENAME COLUMN
|
|
|
|
----------------------------
|
2015-02-10 22:27:42 +08:00
|
|
|
SET SESSION AUTHORIZATION 'cartodb_postgresql_unpriv_user';
|
2014-05-05 18:20:38 +08:00
|
|
|
|
2014-05-09 17:34:24 +08:00
|
|
|
select pg_sleep(.1);
|
2014-05-01 01:03:14 +08:00
|
|
|
alter table c.t3 rename column the_geom_webmercator to webmerc;
|
2014-05-05 18:20:38 +08:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2015-02-10 22:27:42 +08:00
|
|
|
RESET SESSION AUTHORIZATION;
|
2014-05-05 18:20:38 +08:00
|
|
|
select
|
|
|
|
tabname::text,
|
2014-05-09 17:34:24 +08:00
|
|
|
round(extract('secs' from now() - updated_at)*10) as agecs
|
2014-05-28 15:02:02 +08:00
|
|
|
FROM CDB_TableMetadata WHERE tabname = 'c.t3'::regclass;
|
2014-05-05 18:20:38 +08:00
|
|
|
|
2015-02-10 22:27:42 +08:00
|
|
|
SET SESSION AUTHORIZATION 'cartodb_postgresql_unpriv_user';
|
2014-05-09 17:34:24 +08:00
|
|
|
select pg_sleep(.1);
|
2014-05-01 01:03:14 +08:00
|
|
|
alter table c.t3 rename column the_geom_webmercator to webmerc2;
|
2014-05-05 18:20:38 +08:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2015-02-10 22:27:42 +08:00
|
|
|
RESET SESSION AUTHORIZATION;
|
2014-05-05 18:20:38 +08:00
|
|
|
select
|
|
|
|
tabname::text,
|
2014-05-09 17:34:24 +08:00
|
|
|
round(extract('secs' from now() - updated_at)*10) as agecs
|
2014-05-28 15:02:02 +08:00
|
|
|
FROM CDB_TableMetadata WHERE tabname = 'c.t3'::regclass;
|
2014-05-05 18:20:38 +08:00
|
|
|
|
|
|
|
----------------------------
|
|
|
|
-- ALTER TABLE DROP COLUMN
|
|
|
|
----------------------------
|
2015-02-10 22:27:42 +08:00
|
|
|
SET SESSION AUTHORIZATION 'cartodb_postgresql_unpriv_user';
|
2014-05-09 17:34:24 +08:00
|
|
|
select pg_sleep(.1);
|
2014-05-01 01:03:14 +08:00
|
|
|
alter table c.t3 drop column the_geom_webmercator;
|
2014-05-05 18:20:38 +08:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2015-02-10 22:27:42 +08:00
|
|
|
RESET SESSION AUTHORIZATION;
|
2014-05-05 18:20:38 +08:00
|
|
|
select
|
|
|
|
tabname::text,
|
2014-05-09 17:34:24 +08:00
|
|
|
round(extract('secs' from now() - updated_at)*10) as agecs
|
2014-05-28 15:02:02 +08:00
|
|
|
FROM CDB_TableMetadata WHERE tabname = 'c.t3'::regclass;
|
2014-05-05 18:20:38 +08:00
|
|
|
|
|
|
|
----------------------------
|
|
|
|
-- ALTER TABLE ADD COLUMN
|
|
|
|
----------------------------
|
2015-02-10 22:27:42 +08:00
|
|
|
SET SESSION AUTHORIZATION 'cartodb_postgresql_unpriv_user';
|
2014-05-09 17:34:24 +08:00
|
|
|
select pg_sleep(.1);
|
2014-05-01 01:03:14 +08:00
|
|
|
alter table c.t3 add column id2 int;
|
2014-05-05 18:20:38 +08:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2015-02-10 22:27:42 +08:00
|
|
|
RESET SESSION AUTHORIZATION;
|
2014-05-05 18:20:38 +08:00
|
|
|
select
|
|
|
|
tabname::text,
|
2014-05-09 17:34:24 +08:00
|
|
|
round(extract('secs' from now() - updated_at)*10) as agecs
|
2014-05-28 15:02:02 +08:00
|
|
|
FROM CDB_TableMetadata WHERE tabname = 'c.t3'::regclass;
|
2014-05-05 18:20:38 +08:00
|
|
|
|
|
|
|
----------------------------
|
|
|
|
-- DROP TABLE
|
|
|
|
----------------------------
|
2014-05-01 01:03:14 +08:00
|
|
|
|
|
|
|
RESET SESSION AUTHORIZATION;
|
|
|
|
drop schema c cascade;
|
2014-05-28 15:02:02 +08:00
|
|
|
select count(*) from CDB_TableMetadata;
|
2014-05-01 01:03:14 +08:00
|
|
|
|
|
|
|
DROP USER cartodb_postgresql_unpriv_user;
|
2014-05-12 19:07:47 +08:00
|
|
|
DROP FUNCTION _CDB_UserQuotaInBytes();
|