Do not allow cartodbfying tables while no user quota is set
Closes #17 Updates tests
This commit is contained in:
@@ -10,7 +10,13 @@ EXCEPTION
|
|||||||
RETURNS void AS '' LANGUAGE 'sql';
|
RETURNS void AS '' LANGUAGE 'sql';
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE 'plpgsql';
|
$$ LANGUAGE 'plpgsql';
|
||||||
--SELECT tmp();
|
-- Set user quota to infinite
|
||||||
|
SELECT CDB_SetUserQuotaInBytes(0);
|
||||||
|
cdb_setuserquotainbytes
|
||||||
|
-------------------------
|
||||||
|
0
|
||||||
|
(1 row)
|
||||||
|
|
||||||
create schema c;
|
create schema c;
|
||||||
CREATE USER cartodb_postgresql_unpriv_user;
|
CREATE USER cartodb_postgresql_unpriv_user;
|
||||||
GRANT ALL ON SCHEMA c to cartodb_postgresql_unpriv_user;
|
GRANT ALL ON SCHEMA c to cartodb_postgresql_unpriv_user;
|
||||||
@@ -207,3 +213,4 @@ select count(*) from CDB_TableMetadata;
|
|||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
DROP USER cartodb_postgresql_unpriv_user;
|
DROP USER cartodb_postgresql_unpriv_user;
|
||||||
|
DROP FUNCTION _CDB_UserQuotaInBytes();
|
||||||
|
|||||||
@@ -40,6 +40,13 @@ DECLARE
|
|||||||
exists_geom_cols BOOLEAN[];
|
exists_geom_cols BOOLEAN[];
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
|
-- TODO: Check that user quota is set ?
|
||||||
|
BEGIN
|
||||||
|
PERFORM public._CDB_UserQuotaInBytes();
|
||||||
|
EXCEPTION WHEN undefined_function THEN
|
||||||
|
RAISE EXCEPTION 'Please set user quota before cartodbfying tables.';
|
||||||
|
END;
|
||||||
|
|
||||||
-- Drop cartodb triggers (might prevent changing columns)
|
-- Drop cartodb triggers (might prevent changing columns)
|
||||||
|
|
||||||
-- "track_updates"
|
-- "track_updates"
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ EXCEPTION
|
|||||||
END;
|
END;
|
||||||
$$ LANGUAGE 'plpgsql';
|
$$ LANGUAGE 'plpgsql';
|
||||||
|
|
||||||
--SELECT tmp();
|
-- Set user quota to infinite
|
||||||
|
SELECT CDB_SetUserQuotaInBytes(0);
|
||||||
|
|
||||||
create schema c;
|
create schema c;
|
||||||
|
|
||||||
@@ -121,3 +121,4 @@ drop schema c cascade;
|
|||||||
select count(*) from CDB_TableMetadata;
|
select count(*) from CDB_TableMetadata;
|
||||||
|
|
||||||
DROP USER cartodb_postgresql_unpriv_user;
|
DROP USER cartodb_postgresql_unpriv_user;
|
||||||
|
DROP FUNCTION _CDB_UserQuotaInBytes();
|
||||||
|
|||||||
@@ -132,6 +132,8 @@ LANGUAGE 'plpgsql';
|
|||||||
|
|
||||||
-- table with single non-geometrical column
|
-- table with single non-geometrical column
|
||||||
CREATE TABLE t AS SELECT 1::int as a;
|
CREATE TABLE t AS SELECT 1::int as a;
|
||||||
|
SELECT CDB_CartodbfyTable('t'); -- should fail
|
||||||
|
SELECT CDB_SetUserQuotaInBytes(0); -- Set user quota to infinite
|
||||||
SELECT CDB_CartodbfyTableCheck('t', 'single non-geometrical column');
|
SELECT CDB_CartodbfyTableCheck('t', 'single non-geometrical column');
|
||||||
DROP TABLE t;
|
DROP TABLE t;
|
||||||
|
|
||||||
@@ -171,3 +173,4 @@ DROP TABLE t;
|
|||||||
-- TODO: table with existing custom-triggered the_geom
|
-- TODO: table with existing custom-triggered the_geom
|
||||||
|
|
||||||
DROP FUNCTION CDB_CartodbfyTableCheck(regclass, text);
|
DROP FUNCTION CDB_CartodbfyTableCheck(regclass, text);
|
||||||
|
DROP FUNCTION _CDB_UserQuotaInBytes();
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
SET
|
SET
|
||||||
CREATE FUNCTION
|
CREATE FUNCTION
|
||||||
SELECT 1
|
SELECT 1
|
||||||
|
ERROR: Please set user quota before cartodbfying tables.
|
||||||
|
0
|
||||||
single non-geometrical column cartodbfied fine
|
single non-geometrical column cartodbfied fine
|
||||||
DROP TABLE
|
DROP TABLE
|
||||||
SELECT 1
|
SELECT 1
|
||||||
@@ -24,3 +26,4 @@ trigger-protected the_geom cartodbfied fine
|
|||||||
extent|BOX(1 1,2 2)
|
extent|BOX(1 1,2 2)
|
||||||
DROP TABLE
|
DROP TABLE
|
||||||
DROP FUNCTION
|
DROP FUNCTION
|
||||||
|
DROP FUNCTION
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ CREATE TRIGGER test_quota BEFORE UPDATE OR INSERT ON big
|
|||||||
EXECUTE PROCEDURE CDB_CheckQuota(1,1);
|
EXECUTE PROCEDURE CDB_CheckQuota(1,1);
|
||||||
INSERT INTO big VALUES (1); -- allowed, check runs before
|
INSERT INTO big VALUES (1); -- allowed, check runs before
|
||||||
INSERT INTO big VALUES (1); -- disallowed, quota exceeds before
|
INSERT INTO big VALUES (1); -- disallowed, quota exceeds before
|
||||||
|
SELECT CDB_SetUserQuotaInBytes(0);
|
||||||
SELECT CDB_CartodbfyTable('big');
|
SELECT CDB_CartodbfyTable('big');
|
||||||
INSERT INTO big SELECT generate_series(1,1024);
|
INSERT INTO big SELECT generate_series(1,1024);
|
||||||
SELECT CDB_SetUserQuotaInBytes(8);
|
SELECT CDB_SetUserQuotaInBytes(8);
|
||||||
@@ -15,3 +16,4 @@ SELECT CDB_SetUserQuotaInBytes(0);
|
|||||||
INSERT INTO big VALUES (1);
|
INSERT INTO big VALUES (1);
|
||||||
DROP TABLE big;
|
DROP TABLE big;
|
||||||
set client_min_messages to NOTICE;
|
set client_min_messages to NOTICE;
|
||||||
|
DROP FUNCTION _CDB_UserQuotaInBytes();
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ CREATE TABLE
|
|||||||
CREATE TRIGGER
|
CREATE TRIGGER
|
||||||
INSERT 0 1
|
INSERT 0 1
|
||||||
ERROR: Quota exceeded by 3.9990234375KB
|
ERROR: Quota exceeded by 3.9990234375KB
|
||||||
|
0
|
||||||
|
|
||||||
INSERT 0 1024
|
INSERT 0 1024
|
||||||
0
|
0
|
||||||
@@ -11,3 +12,4 @@ ERROR: Quota exceeded by 103.9921875KB
|
|||||||
INSERT 0 1
|
INSERT 0 1
|
||||||
DROP TABLE
|
DROP TABLE
|
||||||
SET
|
SET
|
||||||
|
DROP FUNCTION
|
||||||
|
|||||||
Reference in New Issue
Block a user