2014-05-06 16:18:38 +08:00
|
|
|
\set VERBOSITY terse
|
2014-05-01 01:03:14 +08:00
|
|
|
|
|
|
|
-- 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
|
2014-05-05 18:20:38 +08:00
|
|
|
CREATE OR REPLACE FUNCTION cartodb.cdb_invalidate_varnish(tabname text)
|
2014-05-01 01:03:14 +08:00
|
|
|
RETURNS void AS '' LANGUAGE 'sql';
|
|
|
|
END;
|
|
|
|
$$ LANGUAGE 'plpgsql';
|
|
|
|
|
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
|
|
|
|
|
|
|
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;
|
|
|
|
|
2014-05-05 18:20:38 +08:00
|
|
|
----------------------
|
|
|
|
-- CREATE TABLE
|
|
|
|
----------------------
|
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;
|
|
|
|
|
|
|
|
select
|
|
|
|
tabname::text,
|
|
|
|
round(extract('secs' from now() - updated_at)) as age
|
|
|
|
FROM CDB_TableMetadata;
|
|
|
|
|
|
|
|
----------------------------
|
|
|
|
-- ALTER TABLE RENAME COLUMN
|
|
|
|
----------------------------
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
select
|
|
|
|
tabname::text,
|
2014-05-09 17:34:24 +08:00
|
|
|
round(extract('secs' from now() - updated_at)*10) as agecs
|
2014-05-05 18:20:38 +08:00
|
|
|
FROM CDB_TableMetadata;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
select
|
|
|
|
tabname::text,
|
2014-05-09 17:34:24 +08:00
|
|
|
round(extract('secs' from now() - updated_at)*10) as agecs
|
2014-05-05 18:20:38 +08:00
|
|
|
FROM CDB_TableMetadata;
|
|
|
|
|
|
|
|
----------------------------
|
|
|
|
-- ALTER TABLE DROP COLUMN
|
|
|
|
----------------------------
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
select
|
|
|
|
tabname::text,
|
2014-05-09 17:34:24 +08:00
|
|
|
round(extract('secs' from now() - updated_at)*10) as agecs
|
2014-05-05 18:20:38 +08:00
|
|
|
FROM CDB_TableMetadata;
|
|
|
|
|
|
|
|
----------------------------
|
|
|
|
-- ALTER TABLE ADD COLUMN
|
|
|
|
----------------------------
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
select
|
|
|
|
tabname::text,
|
2014-05-09 17:34:24 +08:00
|
|
|
round(extract('secs' from now() - updated_at)*10) as agecs
|
2014-05-05 18:20:38 +08:00
|
|
|
FROM CDB_TableMetadata;
|
|
|
|
|
|
|
|
----------------------------
|
|
|
|
-- DROP TABLE
|
|
|
|
----------------------------
|
2014-05-01 01:03:14 +08:00
|
|
|
|
|
|
|
RESET SESSION AUTHORIZATION;
|
|
|
|
drop schema c cascade;
|
2014-05-05 18:20:38 +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();
|