CDB_SetUserQuotaInBytes returning set value instead of previous value.
This commit is contained in:
@@ -84,26 +84,18 @@ CREATE OR REPLACE FUNCTION CDB_SetUserQuotaInBytes(schema_name text, bytes int8)
|
|||||||
RETURNS int8 AS
|
RETURNS int8 AS
|
||||||
$$
|
$$
|
||||||
DECLARE
|
DECLARE
|
||||||
current_quota int8;
|
|
||||||
schema_ok boolean;
|
|
||||||
sql text;
|
sql text;
|
||||||
BEGIN
|
BEGIN
|
||||||
IF cartodb.schema_exists(schema_name::text) = false THEN
|
IF cartodb.schema_exists(schema_name::text) = false THEN
|
||||||
RAISE EXCEPTION 'Invalid schema name "%"', schema_name::text;
|
RAISE EXCEPTION 'Invalid schema name "%"', schema_name::text;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
BEGIN
|
|
||||||
EXECUTE FORMAT('SELECT %I._CDB_UserQuotaInBytes();', schema_name::text) INTO current_quota;
|
|
||||||
EXCEPTION WHEN undefined_function THEN
|
|
||||||
current_quota := 0;
|
|
||||||
END;
|
|
||||||
|
|
||||||
sql := 'CREATE OR REPLACE FUNCTION "' || schema_name::text || '"._CDB_UserQuotaInBytes() '
|
sql := 'CREATE OR REPLACE FUNCTION "' || schema_name::text || '"._CDB_UserQuotaInBytes() '
|
||||||
|| 'RETURNS int8 AS $X$ SELECT ' || bytes
|
|| 'RETURNS int8 AS $X$ SELECT ' || bytes
|
||||||
|| '::int8 $X$ LANGUAGE sql IMMUTABLE';
|
|| '::int8 $X$ LANGUAGE sql IMMUTABLE';
|
||||||
EXECUTE sql;
|
EXECUTE sql;
|
||||||
|
|
||||||
return current_quota;
|
return bytes;
|
||||||
END
|
END
|
||||||
$$
|
$$
|
||||||
LANGUAGE 'plpgsql' VOLATILE STRICT;
|
LANGUAGE 'plpgsql' VOLATILE STRICT;
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ ERROR: Quota exceeded by 3.9990234375KB
|
|||||||
0
|
0
|
||||||
|
|
||||||
INSERT 0 1024
|
INSERT 0 1024
|
||||||
0
|
|
||||||
ERROR: Quota exceeded by 103.9921875KB
|
|
||||||
8
|
8
|
||||||
|
ERROR: Quota exceeded by 103.9921875KB
|
||||||
|
0
|
||||||
INSERT 0 1
|
INSERT 0 1
|
||||||
DROP TABLE
|
DROP TABLE
|
||||||
SET
|
SET
|
||||||
|
|||||||
Reference in New Issue
Block a user