Have _CDB_UserQuotaInBytes() take precedence over parameter-based quota

Closes #16
This commit is contained in:
Sandro Santilli 2014-05-12 13:37:47 +02:00
parent f98071cdac
commit 8d6188e282

View File

@ -35,17 +35,16 @@ BEGIN
IF dice < pbfact THEN
RAISE DEBUG 'Checking quota on table % (dice:%, needed:<%)', TG_RELID::text, dice, pbfact;
IF TG_NARGS > 1 THEN
RAISE NOTICE 'Using quota specified via trigger parameter';
qmax := TG_ARGV[1];
ELSE
BEGIN
qmax := public._CDB_UserQuotaInBytes();
EXCEPTION WHEN undefined_function THEN
RAISE WARNING 'Missing _CDB_UserQuotaInBytes(), assuming no quota';
qmax := 0;
END;
END IF;
BEGIN
qmax := public._CDB_UserQuotaInBytes();
EXCEPTION WHEN undefined_function THEN
IF TG_NARGS > 1 THEN
RAISE NOTICE 'Using quota specified via trigger parameter';
qmax := TG_ARGV[1];
ELSE
RAISE EXCEPTION 'Missing _CDB_UserQuotaInBytes(), and no quota provided as parameter';
END IF;
END;
IF qmax = 0 THEN
RETURN NEW;