2015-02-17 22:40:26 +08:00
|
|
|
set client_min_messages to error;
|
|
|
|
\set VERBOSITY default
|
|
|
|
|
2015-08-27 18:14:48 +08:00
|
|
|
-- See the dice
|
|
|
|
SELECT setseed(0.5);
|
|
|
|
|
2014-05-08 23:14:06 +08:00
|
|
|
CREATE TABLE big(a int);
|
2014-05-09 18:55:41 +08:00
|
|
|
-- Try the legacy interface
|
|
|
|
-- See https://github.com/CartoDB/cartodb-postgresql/issues/13
|
|
|
|
CREATE TRIGGER test_quota BEFORE UPDATE OR INSERT ON big
|
2014-07-04 21:55:08 +08:00
|
|
|
EXECUTE PROCEDURE CDB_CheckQuota(1, 1, 'public');
|
2014-05-09 18:55:41 +08:00
|
|
|
INSERT INTO big VALUES (1); -- allowed, check runs before
|
2015-08-14 06:59:45 +08:00
|
|
|
INSERT INTO big VALUES (2); -- disallowed, quota exceeds before
|
2014-05-12 19:07:47 +08:00
|
|
|
SELECT CDB_SetUserQuotaInBytes(0);
|
2014-05-08 23:14:06 +08:00
|
|
|
SELECT CDB_CartodbfyTable('big');
|
2015-08-14 06:59:45 +08:00
|
|
|
INSERT INTO big SELECT generate_series(2049,4096);
|
|
|
|
INSERT INTO big SELECT generate_series(4097,6144);
|
|
|
|
INSERT INTO big SELECT generate_series(6145,8192);
|
2015-08-13 19:23:35 +08:00
|
|
|
-- Test for #108: https://github.com/CartoDB/cartodb-postgresql/issues/108
|
|
|
|
SELECT CDB_UserDataSize();
|
|
|
|
SELECT cartodb._CDB_total_relation_size('public', 'big');
|
|
|
|
SELECT cartodb._CDB_total_relation_size('public', 'nonexistent_table_name');
|
|
|
|
-- END Test for #108
|
2015-08-27 18:14:48 +08:00
|
|
|
SELECT setseed(0.9);
|
2015-02-17 22:40:26 +08:00
|
|
|
SELECT CDB_SetUserQuotaInBytes(2);
|
2015-08-14 06:59:45 +08:00
|
|
|
INSERT INTO big VALUES (8193);
|
2014-05-08 23:14:06 +08:00
|
|
|
SELECT CDB_SetUserQuotaInBytes(0);
|
2015-08-14 06:59:45 +08:00
|
|
|
INSERT INTO big VALUES (8194);
|
2014-05-08 23:14:06 +08:00
|
|
|
DROP TABLE big;
|
|
|
|
set client_min_messages to NOTICE;
|
2014-05-12 19:07:47 +08:00
|
|
|
DROP FUNCTION _CDB_UserQuotaInBytes();
|