fix(supabase): V1-2.1 owner self-review grant and the text size measure
M6 option A: grant_catalog_right no longer refuses an owner granting itself sheet_reviewer; authors stay refused at acknowledgment, approval and publication. The document cap is the UTF-8 bytes of the JSON text: check_document_structure drops pg_column_size and M5 replaces the base table CHECK by octet_length(content::text). pgTAP 015 and 017 cover the owner-reviewer journey and cap - 1, cap, cap + 1, multi-byte, dense.
This commit is contained in:
1 parent
2af61e72cc
commit
b1de87b5d0
6 files changed
+131
-34
No files matched your search
@@ -43,6 +43,15 @@ alter table public.anatomical_sheet_versions
|
||||
add constraint anatomical_sheet_versions_published_fingerprint
|
||||
check (status <> 'published' or document_fingerprint is not null);
|
||||
|
||||
-- The document cap is the contract's measure (§12.2): the UTF-8 bytes of the
|
||||
-- document's JSON text, `octet_length(content::text)`. The base CHECK measured
|
||||
-- the binary jsonb (`pg_column_size`), larger than the text for a document of
|
||||
-- many small values, so a conforming draft could hit a raw constraint error.
|
||||
alter table public.anatomical_sheet_versions
|
||||
drop constraint anatomical_sheet_versions_content_size,
|
||||
add constraint anatomical_sheet_versions_content_size
|
||||
check (octet_length(content::text) <= 2097152);
|
||||
|
||||
alter table public.anatomical_sheets
|
||||
add column working_copy_source_version_id uuid references public.anatomical_sheet_versions (id) on delete set null;
|
||||
|
||||
@@ -392,11 +401,9 @@ $$;
|
||||
|
||||
-- The structural guards a stored document passes at creation, save and
|
||||
-- working copy (contract §12.2): an object whose id-bearing collections are
|
||||
-- arrays, schema version 2, at most 2 MiB serialised. The table's own size
|
||||
-- CHECK (`pg_column_size(content)`, base migration) measures the binary jsonb,
|
||||
-- which a document of many small objects makes larger than its text: both
|
||||
-- measures are checked here, so either limit answers the closed code rather
|
||||
-- than a raw constraint error.
|
||||
-- arrays, schema version 2, at most 2 MiB as the UTF-8 bytes of its JSON text
|
||||
-- (the table CHECK of section 1 uses the same measure; checked here first so
|
||||
-- the caller gets the closed code, never a raw constraint error).
|
||||
create or replace function private.check_document_structure(p_doc jsonb)
|
||||
returns void
|
||||
language plpgsql
|
||||
@@ -410,7 +417,7 @@ begin
|
||||
if (p_doc -> 'schema_version') is distinct from '2'::jsonb then
|
||||
raise exception 'document.schema_version' using errcode = '23514';
|
||||
end if;
|
||||
if octet_length(p_doc::text) > 2097152 or pg_column_size(p_doc) > 2097152 then
|
||||
if octet_length(p_doc::text) > 2097152 then
|
||||
raise exception 'document.too_large' using errcode = '23514';
|
||||
end if;
|
||||
end;
|
||||
|
||||
Reference in new issue
Block a user