2014-05-06 16:18:38 +08:00
|
|
|
\set VERBOSITY terse
|
2014-05-12 19:07:47 +08:00
|
|
|
-- Set user quota to infinite
|
|
|
|
SELECT CDB_SetUserQuotaInBytes(0);
|
|
|
|
cdb_setuserquotainbytes
|
|
|
|
-------------------------
|
|
|
|
0
|
|
|
|
(1 row)
|
|
|
|
|
2014-05-22 17:40:01 +08:00
|
|
|
-- Enable ddl triggers
|
|
|
|
SELECT cartodb.cdb_enable_ddl_hooks();
|
|
|
|
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
|
|
|
|
cdb_enable_ddl_hooks
|
|
|
|
----------------------
|
|
|
|
|
|
|
|
(1 row)
|
|
|
|
|
2014-05-05 18:43:37 +08:00
|
|
|
create schema c;
|
2014-05-01 01:03:14 +08:00
|
|
|
CREATE USER cartodb_postgresql_unpriv_user;
|
2014-05-05 18:43:37 +08:00
|
|
|
GRANT ALL ON SCHEMA c to cartodb_postgresql_unpriv_user;
|
2014-05-01 01:03:14 +08:00
|
|
|
SET SESSION AUTHORIZATION 'cartodb_postgresql_unpriv_user';
|
|
|
|
--SELECT session_user, current_user;
|
2014-05-05 18:43:37 +08:00
|
|
|
----------------------
|
|
|
|
-- CREATE TABLE
|
|
|
|
----------------------
|
2014-05-01 01:03:14 +08:00
|
|
|
select 1 as i INTO c.t3;
|
2014-05-06 16:18:38 +08:00
|
|
|
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
|
2014-05-28 15:02:02 +08:00
|
|
|
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
|
2014-05-09 23:34:18 +08:00
|
|
|
NOTICE: cdb_invalidate_varnish(c.t3) called
|
2014-05-05 18:43:37 +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;
|
|
|
|
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
|
2014-05-28 15:02:02 +08:00
|
|
|
FROM CDB_TableMetadata WHERE tabname = 'c.t3'::regclass;
|
2014-05-05 18:43:37 +08:00
|
|
|
tabname | age
|
|
|
|
---------+-----
|
|
|
|
c.t3 | 0
|
|
|
|
(1 row)
|
|
|
|
|
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;
|
|
|
|
NOTICE: trigger "track_updates" for table "c.t4" does not exist, skipping
|
|
|
|
NOTICE: trigger "update_the_geom_webmercator_trigger" for table "c.t4" does not exist, skipping
|
|
|
|
NOTICE: trigger "update_updated_at_trigger" for table "c.t4" does not exist, skipping
|
|
|
|
NOTICE: trigger "test_quota" for table "c.t4" does not exist, skipping
|
|
|
|
NOTICE: trigger "test_quota_per_row" for table "c.t4" does not exist, skipping
|
|
|
|
NOTICE: Column cartodb_id already exists
|
2014-05-28 16:44:23 +08:00
|
|
|
NOTICE: Existing cartodb_id field does not have an associated sequence, renaming
|
2014-05-31 00:29:52 +08:00
|
|
|
NOTICE: Trying to recover data from _cartodb_id0 column
|
2014-05-28 15:02:02 +08:00
|
|
|
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.t4) called
|
|
|
|
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;
|
|
|
|
cartodb_id | c=u | u<1s | the_geom | the_geom_webmercator
|
|
|
|
------------+-----+------+----------+----------------------
|
|
|
|
1 | t | t | |
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
select
|
|
|
|
tabname::text,
|
|
|
|
round(extract('secs' from now() - updated_at)) as age
|
|
|
|
FROM CDB_TableMetadata WHERE tabname = 'c.t4'::regclass;
|
|
|
|
tabname | age
|
|
|
|
---------+-----
|
|
|
|
c.t4 | 0
|
|
|
|
(1 row)
|
|
|
|
|
2014-05-05 18:43:37 +08:00
|
|
|
----------------------------
|
|
|
|
-- ALTER TABLE RENAME COLUMN
|
|
|
|
----------------------------
|
2014-05-09 17:34:24 +08:00
|
|
|
select pg_sleep(.1);
|
2014-05-05 18:43:37 +08:00
|
|
|
pg_sleep
|
|
|
|
----------
|
|
|
|
|
|
|
|
(1 row)
|
|
|
|
|
2014-05-01 01:03:14 +08:00
|
|
|
alter table c.t3 rename column the_geom_webmercator to webmerc;
|
2014-05-06 16:18:38 +08:00
|
|
|
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
|
2014-05-09 23:34:18 +08:00
|
|
|
NOTICE: cdb_invalidate_varnish(c.t3) called
|
2014-05-05 18:43:37 +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;
|
|
|
|
cartodb_id | c=u | u<1s | the_geom | the_geom_webmercator | i | webmerc
|
|
|
|
------------+-----+------+----------+----------------------+---+---------
|
2014-05-09 17:34:24 +08:00
|
|
|
1 | t | t | | | 1 |
|
2014-05-05 18:43:37 +08:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
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-09 17:34:24 +08:00
|
|
|
tabname | agecs
|
|
|
|
---------+-------
|
|
|
|
c.t3 | 0
|
2014-05-05 18:43:37 +08:00
|
|
|
(1 row)
|
|
|
|
|
2014-05-09 17:34:24 +08:00
|
|
|
select pg_sleep(.1);
|
2014-05-05 18:43:37 +08:00
|
|
|
pg_sleep
|
|
|
|
----------
|
|
|
|
|
|
|
|
(1 row)
|
|
|
|
|
2014-05-01 01:03:14 +08:00
|
|
|
alter table c.t3 rename column the_geom_webmercator to webmerc2;
|
2014-05-06 16:18:38 +08:00
|
|
|
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
|
2014-05-09 23:34:18 +08:00
|
|
|
NOTICE: cdb_invalidate_varnish(c.t3) called
|
2014-05-05 18:43:37 +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;
|
|
|
|
cartodb_id | c=u | u<1s | the_geom | the_geom_webmercator | i | webmerc | webmerc2
|
|
|
|
------------+-----+------+----------+----------------------+---+---------+----------
|
2014-05-09 17:34:24 +08:00
|
|
|
1 | t | t | | | 1 | |
|
2014-05-05 18:43:37 +08:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
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-09 17:34:24 +08:00
|
|
|
tabname | agecs
|
|
|
|
---------+-------
|
|
|
|
c.t3 | 0
|
2014-05-05 18:43:37 +08:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
----------------------------
|
|
|
|
-- ALTER TABLE DROP COLUMN
|
|
|
|
----------------------------
|
2014-05-09 17:34:24 +08:00
|
|
|
select pg_sleep(.1);
|
2014-05-05 18:43:37 +08:00
|
|
|
pg_sleep
|
|
|
|
----------
|
|
|
|
|
|
|
|
(1 row)
|
|
|
|
|
2014-05-01 01:03:14 +08:00
|
|
|
alter table c.t3 drop column the_geom_webmercator;
|
2014-05-06 16:18:38 +08:00
|
|
|
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
|
2014-05-09 23:34:18 +08:00
|
|
|
NOTICE: cdb_invalidate_varnish(c.t3) called
|
2014-05-05 18:43:37 +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;
|
|
|
|
cartodb_id | c=u | u<1s | the_geom | the_geom_webmercator | i | webmerc | webmerc2
|
|
|
|
------------+-----+------+----------+----------------------+---+---------+----------
|
2014-05-09 17:34:24 +08:00
|
|
|
1 | t | t | | | 1 | |
|
2014-05-05 18:43:37 +08:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
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-09 17:34:24 +08:00
|
|
|
tabname | agecs
|
|
|
|
---------+-------
|
|
|
|
c.t3 | 0
|
2014-05-05 18:43:37 +08:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
----------------------------
|
|
|
|
-- ALTER TABLE ADD COLUMN
|
|
|
|
----------------------------
|
2014-05-09 17:34:24 +08:00
|
|
|
select pg_sleep(.1);
|
2014-05-05 18:43:37 +08:00
|
|
|
pg_sleep
|
|
|
|
----------
|
|
|
|
|
|
|
|
(1 row)
|
|
|
|
|
2014-05-01 01:03:14 +08:00
|
|
|
alter table c.t3 add column id2 int;
|
2014-05-09 23:34:18 +08:00
|
|
|
NOTICE: cdb_invalidate_varnish(c.t3) called
|
2014-05-05 18:43:37 +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;
|
|
|
|
cartodb_id | c=u | u<1s | the_geom | the_geom_webmercator | i | webmerc | webmerc2 | id2
|
|
|
|
------------+-----+------+----------+----------------------+---+---------+----------+-----
|
2014-05-09 17:34:24 +08:00
|
|
|
1 | t | t | | | 1 | | |
|
2014-05-05 18:43:37 +08:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
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-09 17:34:24 +08:00
|
|
|
tabname | agecs
|
|
|
|
---------+-------
|
|
|
|
c.t3 | 0
|
2014-05-05 18:43:37 +08:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
----------------------------
|
|
|
|
-- DROP TABLE
|
|
|
|
----------------------------
|
|
|
|
RESET SESSION AUTHORIZATION;
|
2014-05-01 01:03:14 +08:00
|
|
|
drop schema c cascade;
|
2014-05-28 15:02:02 +08:00
|
|
|
NOTICE: drop cascades to 2 other objects
|
|
|
|
select count(*) from CDB_TableMetadata;
|
2014-05-05 18:43:37 +08:00
|
|
|
count
|
|
|
|
-------
|
|
|
|
0
|
|
|
|
(1 row)
|
|
|
|
|
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();
|