#69 now using pg_relation_size
This commit is contained in:
parent
d43e141291
commit
6c7706672f
4
Makefile
4
Makefile
@ -91,14 +91,14 @@ legacy_regress: $(REGRESS_OLD) Makefile
|
|||||||
for f in $(REGRESS_OLD); do \
|
for f in $(REGRESS_OLD); do \
|
||||||
tn=`basename $${f} .sql`; \
|
tn=`basename $${f} .sql`; \
|
||||||
of=sql/test/$${tn}.sql; \
|
of=sql/test/$${tn}.sql; \
|
||||||
echo '\\set ECHO off' > $${of}; \
|
echo '\\set ECHO none' > $${of}; \
|
||||||
echo '\\a' >> $${of}; \
|
echo '\\a' >> $${of}; \
|
||||||
echo '\\t' >> $${of}; \
|
echo '\\t' >> $${of}; \
|
||||||
echo '\\set QUIET off' >> $${of}; \
|
echo '\\set QUIET off' >> $${of}; \
|
||||||
cat $${f} | \
|
cat $${f} | \
|
||||||
$(SED) -e 's/public\./cartodb./g' >> $${of}; \
|
$(SED) -e 's/public\./cartodb./g' >> $${of}; \
|
||||||
exp=expected/test/$${tn}.out; \
|
exp=expected/test/$${tn}.out; \
|
||||||
echo '\\set ECHO off' > $${exp}; \
|
echo '\\set ECHO none' > $${exp}; \
|
||||||
cat test/$${tn}_expect >> $${exp}; \
|
cat test/$${tn}_expect >> $${exp}; \
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ BEGIN
|
|||||||
FROM user_tables
|
FROM user_tables
|
||||||
),
|
),
|
||||||
sizes AS (
|
sizes AS (
|
||||||
SELECT COALESCE(INT8(SUM(pg_total_relation_size('"' || schema_name || '"."' || table_name || '"')))) table_size,
|
SELECT COALESCE(INT8(SUM(pg_relation_size('"' || schema_name || '"."' || table_name || '"')))) table_size,
|
||||||
CASE
|
CASE
|
||||||
WHEN is_overview THEN 0
|
WHEN is_overview THEN 0
|
||||||
WHEN is_raster THEN 1
|
WHEN is_raster THEN 1
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
SET client_min_messages TO error;
|
SET client_min_messages TO error;
|
||||||
\set VERBOSITY terse;
|
\set VERBOSITY default
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION CDB_CartodbfyTableCheck(tabname regclass, label text)
|
CREATE OR REPLACE FUNCTION CDB_CartodbfyTableCheck(tabname regclass, label text)
|
||||||
RETURNS text AS
|
RETURNS text AS
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
set client_min_messages to ERROR;
|
set client_min_messages to error;
|
||||||
\set VERBOSITY terse
|
\set VERBOSITY default
|
||||||
|
|
||||||
CREATE TABLE big(a int);
|
CREATE TABLE big(a int);
|
||||||
-- Try the legacy interface
|
-- Try the legacy interface
|
||||||
-- See https://github.com/CartoDB/cartodb-postgresql/issues/13
|
-- See https://github.com/CartoDB/cartodb-postgresql/issues/13
|
||||||
@ -9,8 +10,10 @@ 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_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,2048);
|
||||||
SELECT CDB_SetUserQuotaInBytes(8);
|
INSERT INTO big SELECT generate_series(1,2048);
|
||||||
|
INSERT INTO big SELECT generate_series(1,2048);
|
||||||
|
SELECT CDB_SetUserQuotaInBytes(2);
|
||||||
INSERT INTO big VALUES (1);
|
INSERT INTO big VALUES (1);
|
||||||
SELECT CDB_SetUserQuotaInBytes(0);
|
SELECT CDB_SetUserQuotaInBytes(0);
|
||||||
INSERT INTO big VALUES (1);
|
INSERT INTO big VALUES (1);
|
||||||
|
@ -5,9 +5,11 @@ INSERT 0 1
|
|||||||
ERROR: Quota exceeded by 3.9990234375KB
|
ERROR: Quota exceeded by 3.9990234375KB
|
||||||
0
|
0
|
||||||
|
|
||||||
INSERT 0 1024
|
INSERT 0 2048
|
||||||
8
|
INSERT 0 2048
|
||||||
ERROR: Quota exceeded by 123.9921875KB
|
INSERT 0 2048
|
||||||
|
2
|
||||||
|
ERROR: Quota exceeded by 159.998046875KB
|
||||||
0
|
0
|
||||||
INSERT 0 1
|
INSERT 0 1
|
||||||
DROP TABLE
|
DROP TABLE
|
||||||
|
@ -253,7 +253,7 @@ function run_tests() {
|
|||||||
# Tests quota checking taking into account both geom and raster tables
|
# Tests quota checking taking into account both geom and raster tables
|
||||||
function test_quota_for_each_user() {
|
function test_quota_for_each_user() {
|
||||||
# Normal tables add 4096 bytes
|
# Normal tables add 4096 bytes
|
||||||
# Raster tables with overview constraints add 16384 bytes
|
# Raster tables no longer add anything so also count as 4096
|
||||||
|
|
||||||
sql cdb_testmember_1 "SELECT cartodb.CDB_UserDataSize('cdb_testmember_1'::TEXT);" should 4096
|
sql cdb_testmember_1 "SELECT cartodb.CDB_UserDataSize('cdb_testmember_1'::TEXT);" should 4096
|
||||||
sql cdb_testmember_2 "SELECT cartodb.CDB_UserDataSize('cdb_testmember_2'::TEXT);" should 4096
|
sql cdb_testmember_2 "SELECT cartodb.CDB_UserDataSize('cdb_testmember_2'::TEXT);" should 4096
|
||||||
@ -261,13 +261,13 @@ function test_quota_for_each_user() {
|
|||||||
create_raster_table cdb_testmember_1 raster_1
|
create_raster_table cdb_testmember_1 raster_1
|
||||||
create_raster_table cdb_testmember_2 raster_2
|
create_raster_table cdb_testmember_2 raster_2
|
||||||
|
|
||||||
sql cdb_testmember_1 "SELECT cartodb.CDB_UserDataSize('cdb_testmember_1'::TEXT);" should 20480
|
sql cdb_testmember_1 "SELECT cartodb.CDB_UserDataSize('cdb_testmember_1'::TEXT);" should 4096
|
||||||
sql cdb_testmember_2 "SELECT cartodb.CDB_UserDataSize('cdb_testmember_2'::TEXT);" should 20480
|
sql cdb_testmember_2 "SELECT cartodb.CDB_UserDataSize('cdb_testmember_2'::TEXT);" should 4096
|
||||||
|
|
||||||
create_raster_table cdb_testmember_1 raster_3
|
create_raster_table cdb_testmember_1 raster_3
|
||||||
|
|
||||||
sql cdb_testmember_1 "SELECT cartodb.CDB_UserDataSize('cdb_testmember_1'::TEXT);" should 36864
|
sql cdb_testmember_1 "SELECT cartodb.CDB_UserDataSize('cdb_testmember_1'::TEXT);" should 4096
|
||||||
sql cdb_testmember_2 "SELECT cartodb.CDB_UserDataSize('cdb_testmember_2'::TEXT);" should 20480
|
sql cdb_testmember_2 "SELECT cartodb.CDB_UserDataSize('cdb_testmember_2'::TEXT);" should 4096
|
||||||
|
|
||||||
drop_raster_table cdb_testmember_1 raster_1
|
drop_raster_table cdb_testmember_1 raster_1
|
||||||
drop_raster_table cdb_testmember_2 raster_2
|
drop_raster_table cdb_testmember_2 raster_2
|
||||||
|
Loading…
Reference in New Issue
Block a user