Quota: Remove kb error from regress tests
This commit is contained in:
parent
21c319eb9a
commit
409b067721
@ -1,5 +1,19 @@
|
||||
set client_min_messages to error;
|
||||
\set VERBOSITY TERSE
|
||||
-- Runs a query and returns whether an error was thrown
|
||||
-- Useful when the error message depends on the execution plan or db settings
|
||||
-- The error message outputs the extra quota, and this might depend on the database setup and version
|
||||
CREATE OR REPLACE FUNCTION catch_error(query text)
|
||||
RETURNS bool
|
||||
AS $$
|
||||
BEGIN
|
||||
EXECUTE query;
|
||||
RETURN FALSE;
|
||||
EXCEPTION
|
||||
WHEN OTHERS THEN
|
||||
RETURN TRUE;
|
||||
END
|
||||
$$ LANGUAGE 'plpgsql';
|
||||
|
||||
CREATE TABLE big(a int);
|
||||
-- Try the legacy interface
|
||||
@ -7,7 +21,7 @@ CREATE TABLE big(a int);
|
||||
CREATE TRIGGER test_quota BEFORE UPDATE OR INSERT ON big
|
||||
EXECUTE PROCEDURE cartodb.CDB_CheckQuota(2, 1, 'public');
|
||||
INSERT INTO big VALUES (1); -- allowed, check runs before
|
||||
INSERT INTO big VALUES (2); -- disallowed, quota exceeds before
|
||||
SELECT 'excess1', catch_error($$INSERT INTO big VALUES (2); $$); -- disallowed, quota exceeds before
|
||||
SELECT cartodb.CDB_SetUserQuotaInBytes(0);
|
||||
SELECT cartodb.CDB_CartodbfyTable('big');
|
||||
-- Creating the trigger should fail as it was created by CDB_CartodbfyTable
|
||||
@ -21,12 +35,13 @@ INSERT INTO big SELECT generate_series(2049,4096);
|
||||
INSERT INTO big SELECT generate_series(4097,6144);
|
||||
INSERT INTO big SELECT generate_series(6145,8192);
|
||||
-- Test for #108: https://github.com/CartoDB/cartodb-postgresql/issues/108
|
||||
SELECT cartodb.CDB_UserDataSize();
|
||||
SELECT cartodb._CDB_total_relation_size('public', 'big');
|
||||
SELECT cartodb.CDB_UserDataSize() < 500000 AND cartodb.CDB_UserDataSize() > 0;
|
||||
SELECT cartodb._CDB_total_relation_size('public', 'big') < 1000000;
|
||||
SELECT cartodb._CDB_total_relation_size('public', 'nonexistent_table_name');
|
||||
-- END Test for #108
|
||||
|
||||
SELECT cartodb.CDB_SetUserQuotaInBytes(2);
|
||||
INSERT INTO big VALUES (8193);
|
||||
SELECT 'excess2', catch_error($$INSERT INTO big VALUES (8193);$$);
|
||||
SELECT cartodb.CDB_SetUserQuotaInBytes(0);
|
||||
INSERT INTO big VALUES (8194);
|
||||
DROP TABLE big;
|
||||
@ -41,10 +56,11 @@ CREATE TABLE analysis_2f13a3dbd7_41bd92976fc6dd97072afe4ee450054f4c0715d4(id int
|
||||
INSERT INTO analysis_2f13a3dbd7_41bd92976fc6dd97072afe4ee450054f4c0715d4(id) VALUES (1),(2),(3),(4),(5);
|
||||
INSERT INTO big VALUES (1); -- allowed, check runs before
|
||||
DROP TABLE analysis_2f13a3dbd7_41bd92976fc6dd97072afe4ee450054f4c0715d4;
|
||||
INSERT INTO big VALUES (2); -- disallowed, quota exceeds before
|
||||
SELECT 'excess3', catch_error($$INSERT INTO big VALUES (3);$$); -- disallowed, quota exceeds before
|
||||
DROP TABLE big;
|
||||
SELECT CDB_SetUserQuotaInBytes(0);
|
||||
|
||||
|
||||
set client_min_messages to NOTICE;
|
||||
DROP FUNCTION catch_error(text);
|
||||
DROP FUNCTION _CDB_UserQuotaInBytes();
|
||||
|
@ -1,8 +1,9 @@
|
||||
SET
|
||||
CREATE FUNCTION
|
||||
CREATE TABLE
|
||||
CREATE TRIGGER
|
||||
INSERT 0 1
|
||||
ERROR: Quota exceeded by 3.9990234375KB
|
||||
excess1|t
|
||||
0
|
||||
big
|
||||
ERROR: trigger "test_quota" for relation "big" already exists
|
||||
@ -11,11 +12,11 @@ CREATE TRIGGER
|
||||
INSERT 0 2048
|
||||
INSERT 0 2048
|
||||
INSERT 0 2048
|
||||
454656
|
||||
909312
|
||||
t
|
||||
t
|
||||
0
|
||||
2
|
||||
ERROR: Quota exceeded by 443.998046875KB
|
||||
excess2|t
|
||||
0
|
||||
INSERT 0 1
|
||||
DROP TABLE
|
||||
@ -26,8 +27,9 @@ CREATE TABLE
|
||||
INSERT 0 5
|
||||
INSERT 0 1
|
||||
DROP TABLE
|
||||
ERROR: Quota exceeded by 3.9990234375KB
|
||||
excess3|t
|
||||
DROP TABLE
|
||||
0
|
||||
SET
|
||||
DROP FUNCTION
|
||||
DROP FUNCTION
|
||||
|
Loading…
Reference in New Issue
Block a user