Paste into your AI assistant to fix the article, then ask for a re-review.
Show the text
Fix the article with this report, then ask pgTrue for a re-review.
# pgTrue report: new row violates row-level security policy: the causes
Article title: new row violates row-level security policy: the causes
Article URL: https://now-next.nl/en/insights/postgresql-new-row-violates-row-level-security-policy
Report URL: https://pgtrue.postgres.ai/shared/brief/c8b29788-6fe2-48e5-8db9-35fe26e475eb
Audited revision: 3 of 3, 2026-10-19 07:59:09 UTC
Overall letter: A-
## Axes
- Factual: B+ · 1 wrong · 17 checked · 0 caveats · assessed
- Applicable: B+ · 1 wrong · 8 checked · 0 caveats · assessed
- Consistent: A · 0 wrong · 17 checked · 0 caveats · assessed
- Transparent: A · 0 wrong · 6 checked · 0 caveats · assessed
- Safe: — · 0 wrong · 0 checked · 0 caveats · assessed
ElephantSeal: A-.
## Report metadata
- Report: Technical fact-check, edition 3
- Issued: 2026-10-19
- Edition: Updated after review. Corrections are listed below.
- Submitted: Submitted by the PostgresAI team.
- Author response: No written reply from the author. The article changed 1 time after our first audit; we re-audited each version. See Revisions below. Policy: [right-of-reply and corrections policy](/pgtrue/security).
- pgTrue version: audited with v1.0.14 (approx.) · regraded with v1.1.0 (approx.)
## Findings needing a change (2)
### F17 · Inaccurate · Factual · Plain INSERT does not disclose which tenant owns the duplicate slug
Location: excerpt · section “What happens on a unique value that belongs to another tenant?” · as fetched 2026-10-19 · [open in article](https://now-next.nl/en/insights/postgresql-new-row-violates-row-level-security-policy#:~:text=three%20of%20them%20that%20it%20is%20not%20its%20own)
Article says:
```text
…three of them that it is not its own…
```
What is true:
Plain INSERT gives the same duplicate-key error for an existing own slug. PostgreSQL 17 documents uniqueness checks outside row policies. The error establishes existence, not ownership. The claimed 3 distinguishing statements must exclude plain INSERT too.
So what:
Query the slug under the tenant's SELECT policy before diagnosing a duplicate-key error as another tenant's ownership.
Charitable reading:
Separate knowledge that the tenant lacks the slug could establish ownership. The plain INSERT error alone cannot establish it.
Review: We considered the known tenant-1 fixture as charitable context. Plain INSERT still returns the same error for tenant-2 ownership. A tenant-filtered SELECT supplies the missing distinction and prevents wasted diagnosis. We considered the test's known cross-tenant ownership. That knowledge does not come from plain INSERT's error. The same constraint reports an own-tenant duplicate identically. The proposed SELECT distinguishes them.
Sources:
- [REL_17_11 · doc/src/sgml/ddl.sgml:2832-2836](https://github.com/postgres/postgres/blob/083ac033419f690758508e08c1736089384bbee8/doc/src/sgml/ddl.sgml#L2832-L2836)
Excerpt:
```text
Referential integrity checks, such as unique or primary key constraints
and foreign key references, always bypass row security to ensure that
data integrity is maintained. Care must be taken when developing
schemas and row level policies to avoid <quote>covert channel</quote> leaks of
information through such referential integrity checks.
```
- [REL_17_11 · src/backend/access/nbtree/nbtinsert.c:667-669](https://github.com/postgres/postgres/blob/083ac033419f690758508e08c1736089384bbee8/src/backend/access/nbtree/nbtinsert.c#L667-L669)
Excerpt:
```text
(errcode(ERRCODE_UNIQUE_VIOLATION),
errmsg("duplicate key value violates unique constraint \"%s\"",
RelationGetRelationName(rel)),
```
- [https://www.postgresql.org/docs/17/sql-createpolicy.html](https://www.postgresql.org/docs/17/sql-createpolicy.html)
Excerpt:
```text
they are not applied when the system is performing internal referential integrity checks or validating constraints. This means there are indirect ways to determine that a given value exists. An example of this is attempting to insert a duplicate value into a column that is a primary key or has a unique constraint. If the insert fails then the user can infer that the value already exists.
```
Finding URL: https://pgtrue.postgres.ai/shared/brief/c8b29788-6fe2-48e5-8db9-35fe26e475eb#F17
### F1 · Misleading · Applicable · The duplicate-key branch can misdiagnose a missing SELECT policy
Location: excerpt · section “The message has four forms” · as fetched 2026-10-19 · [open in article](https://now-next.nl/en/insights/postgresql-new-row-violates-row-level-security-policy#:~:text=A%20duplicate%2Dkey%20error%20on%20the%20plain%20INSERT%20counts%20as%20No.)
Article says:
```text
A duplicate-key error on the plain INSERT counts as No.
```
What is true:
A duplicate-key error does not exclude a missing SELECT policy. Setup C permits plain INSERT but rejects the explicit-target upsert's SELECT check. ExecInsert checks policies before constraints at nodeModifyTable.c:1018. An existing key then sends the tree toward the wrong cause.
So what:
Treat a duplicate-key result as inconclusive. Repeat the plain INSERT with a fresh key before excluding SELECT policies.
Charitable reading:
The tree covers only the measured tenant-policy setups. Setup C still provides a counterexample within that scope.
Review: We tested the tree's restricted scope against setup C. An existing key still routes a missing SELECT policy toward incorrect causes. Retrying with a fresh key addresses wasted diagnostic work. We tested the tree's stated scope against setup C. An existing key defeats the duplicate-key branch despite valid INSERT permission. Checking a fresh key avoids the documented misdiagnosis.
Sources:
- [REL_17_11 · src/backend/executor/nodeModifyTable.c:1018-1025](https://github.com/postgres/postgres/blob/083ac033419f690758508e08c1736089384bbee8/src/backend/executor/nodeModifyTable.c#L1018-L1025)
Excerpt:
```text
if (resultRelInfo->ri_WithCheckOptions != NIL)
ExecWithCheckOptions(wco_kind, resultRelInfo, slot, estate);
/*
* Check the constraints of the tuple.
*/
if (resultRelationDesc->rd_att->constr)
ExecConstraints(resultRelInfo, slot, estate);
```
- [REL_17_11 · src/backend/rewrite/rowsecurity.c:278-283](https://github.com/postgres/postgres/blob/083ac033419f690758508e08c1736089384bbee8/src/backend/rewrite/rowsecurity.c#L278-L283)
Excerpt:
```text
/*
* Get and add ALL/SELECT policies, if SELECT rights are required for
* this relation (eg: when RETURNING is used). These are added as WCO
* policies rather than security quals to ensure that an error is
* raised if a policy is violated; otherwise, we might end up silently
* dropping rows to be added.
```
- [REL_17_11 · doc/src/sgml/ref/create_policy.sgml:296-303](https://github.com/postgres/postgres/blob/083ac033419f690758508e08c1736089384bbee8/doc/src/sgml/ref/create_policy.sgml#L296-L303)
Excerpt:
```text
If an <literal>INSERT</literal> has an <literal>ON CONFLICT DO
UPDATE</literal> clause, or an <literal>ON CONFLICT DO
NOTHING</literal> clause with an arbiter index or constraint
specification, then <literal>SELECT</literal>
permissions are required on the relation, and the rows proposed for
insertion are checked using the relation's <literal>SELECT</literal>
policies. If a row proposed for insertion does not satisfy the
relation's <literal>SELECT</literal> policies, an error is thrown
```
- [REL_17_11 · doc/src/sgml/ddl.sgml:2832-2836](https://github.com/postgres/postgres/blob/083ac033419f690758508e08c1736089384bbee8/doc/src/sgml/ddl.sgml#L2832-L2836)
Excerpt:
```text
Referential integrity checks, such as unique or primary key constraints
and foreign key references, always bypass row security to ensure that
data integrity is maintained. Care must be taken when developing
schemas and row level policies to avoid <quote>covert channel</quote> leaks of
information through such referential integrity checks.
```
Finding URL: https://pgtrue.postgres.ai/shared/brief/c8b29788-6fe2-48e5-8db9-35fe26e475eb#F1
## Verified accurate claims (15)
### F3 · Accurate · Factual · Permissive failures omit names and restrictive failures can name policies
Location: excerpt · section “The message has four forms” · as fetched 2026-10-19 · [open in article](https://now-next.nl/en/insights/postgresql-new-row-violates-row-level-security-policy#:~:text=a%20row%20that%20no%20permissive%20policy%20lets%20through)
Article says:
```text
…a row that no permissive policy lets through…
```
What is true:
rowsecurity.c:839 combines permissive checks without a policy name. It adds named restrictive checks afterward at line 863. execMain.c:2199 reports SQLSTATE 42501 for a failed unnamed new-row check.
Charitable reading:
We checked the claim under the article's enforced-RLS, nonowner setup.
Review: We checked whether permissive failures could name individual policies. PostgreSQL combines them into an unnamed check before named restrictive checks. SQLSTATE 42501 matches. We checked whether failed permissive policies could supply a policy name. Their combined check omits names. Separate restrictive checks retain names. The executor uses SQLSTATE 42501.
Sources:
- [REL_17_11 · src/backend/rewrite/rowsecurity.c:839-843](https://github.com/postgres/postgres/blob/083ac033419f690758508e08c1736089384bbee8/src/backend/rewrite/rowsecurity.c#L839-L843)
Excerpt:
```text
* Add a single WithCheckOption for all the permissive policy clauses,
* combining them together using OR. This check has no policy name,
* since if the check fails it means that no policy granted permission
* to perform the update, rather than any particular policy being
* violated.
```
- [REL_17_11 · src/backend/rewrite/rowsecurity.c:863-866](https://github.com/postgres/postgres/blob/083ac033419f690758508e08c1736089384bbee8/src/backend/rewrite/rowsecurity.c#L863-L866)
Excerpt:
```text
* Now add WithCheckOptions for each of the restrictive policy clauses
* (which will be combined together using AND). We use a separate
* WithCheckOption for each restrictive policy to allow the policy
* name to be included in error reports if the policy is violated.
```
- [REL_17_11 · src/backend/utils/errcodes.txt:335-335](https://github.com/postgres/postgres/blob/083ac033419f690758508e08c1736089384bbee8/src/backend/utils/errcodes.txt#L335-L335)
Excerpt:
```text
42501 E ERRCODE_INSUFFICIENT_PRIVILEGE insufficient_privilege
```
- [REL_17_11 · src/backend/executor/execMain.c:2199-2202](https://github.com/postgres/postgres/blob/083ac033419f690758508e08c1736089384bbee8/src/backend/executor/execMain.c#L2199-L2202)
Excerpt:
```text
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("new row violates row-level security policy for table \"%s\"",
wco->relname)));
```
Finding URL: https://pgtrue.postgres.ai/shared/brief/c8b29788-6fe2-48e5-8db9-35fe26e475eb#F3
### F4 · Accurate · Factual · INSERT policies run before conflict detection
Location: excerpt · section “Why does an upsert fail when the row already exists?” · as fetched 2026-10-19 · [open in article](https://now-next.nl/en/insights/postgresql-new-row-violates-row-level-security-policy#:~:text=the%20insert%20policy%20is%20checked,whether%20there%20is%20a%20conflict)
Article says:
```text
…the insert policy is checked before PostgreSQL knows whether there is a conflict…
```
What is true:
nodeModifyTable.c:1018 checks the proposed row's policies. Its conflict-index check follows at line 1064. ON CONFLICT DO NOTHING and DO UPDATE cannot bypass an INSERT-policy failure.
Charitable reading:
The claim describes policy-check order within the shown INSERT execution path.
Review: We checked whether conflict detection precedes INSERT policy checks. ExecWithCheckOptions runs before ExecCheckIndexConstraints, including the DO NOTHING path. We checked whether conflict handling could precede policy acceptance. ExecWithCheckOptions runs before ExecCheckIndexConstraints in the cited INSERT path.
Sources:
- [REL_17_11 · src/backend/executor/nodeModifyTable.c:1018-1025](https://github.com/postgres/postgres/blob/083ac033419f690758508e08c1736089384bbee8/src/backend/executor/nodeModifyTable.c#L1018-L1025)
Excerpt:
```text
if (resultRelInfo->ri_WithCheckOptions != NIL)
ExecWithCheckOptions(wco_kind, resultRelInfo, slot, estate);
/*
* Check the constraints of the tuple.
*/
if (resultRelationDesc->rd_att->constr)
ExecConstraints(resultRelInfo, slot, estate);
```
- [REL_17_11 · src/backend/executor/nodeModifyTable.c:1063-1065](https://github.com/postgres/postgres/blob/083ac033419f690758508e08c1736089384bbee8/src/backend/executor/nodeModifyTable.c#L1063-L1065)
Excerpt:
```text
specConflict = false;
if (!ExecCheckIndexConstraints(resultRelInfo, slot, estate,
&conflictTid, arbiterIndexes))
```
Finding URL: https://pgtrue.postgres.ai/shared/brief/c8b29788-6fe2-48e5-8db9-35fe26e475eb#F4
### F5 · Accurate · Factual · The shown RETURNING and conflict-target writes require SELECT policies
Location: excerpt · section “The message has four forms” · as fetched 2026-10-19 · [open in article](https://now-next.nl/en/insights/postgresql-new-row-violates-row-level-security-policy#:~:text=RETURNING%20and%20ON%20CONFLICT%20with,to%20the%20new%20row%20too)
Article says:
```text
…RETURNING and ON CONFLICT with a conflict target apply those to the new row too…
```
What is true:
rowsecurity.c:278 adds SELECT policies as new-row checks when SELECT rights are required. create_policy.sgml:296 confirms explicit-target conflict handling. Column-reading WHERE clauses also apply SELECT filters to existing rows at rowsecurity.c:230.
Charitable reading:
RETURNING refers to the article's RETURNING id examples. Their expressions read target columns.
Review: We considered RETURNING expressions that require no target-column access. The finding explicitly covers RETURNING id and conditions checks on required SELECT rights. We considered RETURNING expressions that read no target columns. The finding limits its claim to the shown column-reading examples. Targeted conflict handling requires SELECT checks.
Sources:
- [REL_17_11 · src/backend/rewrite/rowsecurity.c:278-283](https://github.com/postgres/postgres/blob/083ac033419f690758508e08c1736089384bbee8/src/backend/rewrite/rowsecurity.c#L278-L283)
Excerpt:
```text
/*
* Get and add ALL/SELECT policies, if SELECT rights are required for
* this relation (eg: when RETURNING is used). These are added as WCO
* policies rather than security quals to ensure that an error is
* raised if a policy is violated; otherwise, we might end up silently
* dropping rows to be added.
```
- [REL_17_11 · doc/src/sgml/ref/create_policy.sgml:296-303](https://github.com/postgres/postgres/blob/083ac033419f690758508e08c1736089384bbee8/doc/src/sgml/ref/create_policy.sgml#L296-L303)
Excerpt:
```text
If an <literal>INSERT</literal> has an <literal>ON CONFLICT DO
UPDATE</literal> clause, or an <literal>ON CONFLICT DO
NOTHING</literal> clause with an arbiter index or constraint
specification, then <literal>SELECT</literal>
permissions are required on the relation, and the rows proposed for
insertion are checked using the relation's <literal>SELECT</literal>
policies. If a row proposed for insertion does not satisfy the
relation's <literal>SELECT</literal> policies, an error is thrown
```
- [REL_17_11 · src/backend/rewrite/rowsecurity.c:230-238](https://github.com/postgres/postgres/blob/083ac033419f690758508e08c1736089384bbee8/src/backend/rewrite/rowsecurity.c#L230-L238)
Excerpt:
```text
/*
* Similar to above, during an UPDATE, DELETE, or MERGE, if SELECT rights
* are also required (eg: when a RETURNING clause exists, or the user has
* provided a WHERE clause which involves columns from the relation), we
* collect up CMD_SELECT policies and add them via add_security_quals
* first.
*
* This way, we filter out any records which are not visible through an
* ALL or SELECT USING policy.
```
Finding URL: https://pgtrue.postgres.ai/shared/brief/c8b29788-6fe2-48e5-8db9-35fe26e475eb#F5
### F6 · Accurate · Factual · MERGE applies policies for the action it executes
Location: Article · exact quote · [open in article](https://now-next.nl/en/insights/postgresql-new-row-violates-row-level-security-policy#:~:text=No%20separate%20policy%20exists%20for%20MERGE.)
Article says:
```text
…No separate policy exists for MERGE.
```
What is true:
create_policy.sgml:743 defines no separate MERGE policy. nodeModifyTable.c:2992 checks action policies after WHEN conditions. SELECT filters can hide an existing target row before matching, so an INSERT action can encounter its unique key.
Charitable reading:
The matched-row explanation concerns the article's UPDATE action, not every possible MERGE action.
Review: We checked whether unexecuted MERGE actions trigger these checks. The executor evaluates WHEN conditions first. SELECT filtering explains hidden target rows. We checked whether MERGE applies every action's policies unconditionally. Action checks follow WHEN evaluation. SELECT filters separately determine which target rows remain visible.
Sources:
- [REL_17_11 · doc/src/sgml/ref/create_policy.sgml:743-747](https://github.com/postgres/postgres/blob/083ac033419f690758508e08c1736089384bbee8/doc/src/sgml/ref/create_policy.sgml#L743-L747)
Excerpt:
```text
No separate policy exists for <command>MERGE</command>. Instead, the policies
defined for <command>SELECT</command>, <command>INSERT</command>,
<command>UPDATE</command>, and <command>DELETE</command> are applied
while executing <command>MERGE</command>, depending on the actions that are
performed.
```
- [REL_17_11 · src/backend/executor/nodeModifyTable.c:2992-3001](https://github.com/postgres/postgres/blob/083ac033419f690758508e08c1736089384bbee8/src/backend/executor/nodeModifyTable.c#L2992-L3001)
Excerpt:
```text
* NOTE: We must do this after WHEN quals are evaluated, so that we
* check policies only when they matter.
*/
if (resultRelInfo->ri_WithCheckOptions && commandType != CMD_NOTHING)
{
ExecWithCheckOptions(commandType == CMD_UPDATE ?
WCO_RLS_MERGE_UPDATE_CHECK : WCO_RLS_MERGE_DELETE_CHECK,
resultRelInfo,
resultRelInfo->ri_oldTupleSlot,
context->mtstate->ps.state);
```
- [REL_17_11 · src/backend/rewrite/rowsecurity.c:230-238](https://github.com/postgres/postgres/blob/083ac033419f690758508e08c1736089384bbee8/src/backend/rewrite/rowsecurity.c#L230-L238)
Excerpt:
```text
/*
* Similar to above, during an UPDATE, DELETE, or MERGE, if SELECT rights
* are also required (eg: when a RETURNING clause exists, or the user has
* provided a WHERE clause which involves columns from the relation), we
* collect up CMD_SELECT policies and add them via add_security_quals
* first.
*
* This way, we filter out any records which are not visible through an
* ALL or SELECT USING policy.
```
- [https://www.postgresql.org/docs/17/sql-createpolicy.html](https://www.postgresql.org/docs/17/sql-createpolicy.html)
Excerpt:
```text
No separate policy exists for MERGE
```
Finding URL: https://pgtrue.postgres.ai/shared/brief/c8b29788-6fe2-48e5-8db9-35fe26e475eb#F6
### F7 · Accurate · Factual · BEFORE triggers precede policy and NOT NULL checks
Location: Article · exact quote · [open in article](https://now-next.nl/en/insights/postgresql-new-row-violates-row-level-security-policy#:~:text=WITH%20CHECK%20is%20enforced%20after%20BEFORE%20triggers)
Article says:
```text
…WITH CHECK is enforced after BEFORE triggers…
```
What is true:
nodeModifyTable.c:840 runs BEFORE INSERT triggers before policy checks at line 1018. Constraint checks follow at line 1024. The modified tenant value can change policy acceptance. A policy rejection can precede the column's NOT NULL error.
Charitable reading:
The trigger changes the proposed tenant before the policy expression examines that tuple.
Review: We checked whether NOT NULL validation could precede the stated policy failure. BEFORE INSERT triggers run first, policy checks second, constraints third. We checked whether NOT NULL enforcement precedes policy rejection. BEFORE INSERT triggers run first, policy checks follow, and ExecConstraints runs afterward.
Sources:
- [REL_17_11 · src/backend/executor/nodeModifyTable.c:1018-1025](https://github.com/postgres/postgres/blob/083ac033419f690758508e08c1736089384bbee8/src/backend/executor/nodeModifyTable.c#L1018-L1025)
Excerpt:
```text
if (resultRelInfo->ri_WithCheckOptions != NIL)
ExecWithCheckOptions(wco_kind, resultRelInfo, slot, estate);
/*
* Check the constraints of the tuple.
*/
if (resultRelationDesc->rd_att->constr)
ExecConstraints(resultRelInfo, slot, estate);
```
- [REL_17_11 · doc/src/sgml/ref/create_policy.sgml:62-67](https://github.com/postgres/postgres/blob/083ac033419f690758508e08c1736089384bbee8/doc/src/sgml/ref/create_policy.sgml#L62-L67)
Excerpt:
```text
<literal>WITH CHECK</literal> expressions are enforced after
<literal>BEFORE</literal> triggers are fired, and before any actual data
modifications are made. Thus a <literal>BEFORE ROW</literal> trigger may
modify the data to be inserted, affecting the result of the security
policy check. <literal>WITH CHECK</literal> expressions are enforced
before any other constraints.
```
- [REL_17_11 · src/backend/executor/nodeModifyTable.c:840-841](https://github.com/postgres/postgres/blob/083ac033419f690758508e08c1736089384bbee8/src/backend/executor/nodeModifyTable.c#L840-L841)
Excerpt:
```text
if (!ExecBRInsertTriggers(estate, resultRelInfo, slot))
return NULL; /* "do nothing" */
```
- [https://www.postgresql.org/docs/17/sql-createpolicy.html](https://www.postgresql.org/docs/17/sql-createpolicy.html)
Excerpt:
```text
WITH CHECK expressions are enforced after BEFORE triggers are fired
```
Finding URL: https://pgtrue.postgres.ai/shared/brief/c8b29788-6fe2-48e5-8db9-35fe26e475eb#F7
### F8 · Accurate · Factual · Verified accurate: “…Check pg_policies for the command and the role, then the row's tenant_id…”
Location: excerpt · section “The message has four forms” · as fetched 2026-10-19 · [open in article](https://now-next.nl/en/insights/postgresql-new-row-violates-row-level-security-policy#:~:text=Check%20pg_policies%20for%20the%20command,role%2C%20then%20the%20row%27s%20tenant_id)
Article says:
```text
…Check pg_policies for the command and the role, then the row's tenant_id…
```
What is true:
system_views.sql:95–103 exposes cmd, qual, and with_check. It maps command codes to SELECT, INSERT, UPDATE, DELETE, and ALL. rowsecurity.c:921–928 accepts PUBLIC and checks inherited role privileges.
Review: E-25 records three diagnostic fields, not every requested field. E-26 provides only the view description. We narrowed the endorsement to those fields and the recorded role checks.
Sources:
- [REL_17_11 · src/backend/catalog/system_views.sql:95-103](https://github.com/postgres/postgres/blob/083ac033419f690758508e08c1736089384bbee8/src/backend/catalog/system_views.sql#L95-L103)
Excerpt:
```text
CASE pol.polcmd
WHEN 'r' THEN 'SELECT'
WHEN 'a' THEN 'INSERT'
WHEN 'w' THEN 'UPDATE'
WHEN 'd' THEN 'DELETE'
WHEN '*' THEN 'ALL'
END AS cmd,
pg_catalog.pg_get_expr(pol.polqual, pol.polrelid) AS qual,
pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid) AS with_check
```
- [REL_17_11 · doc/src/sgml/system-views.sgml:1811-1813](https://github.com/postgres/postgres/blob/083ac033419f690758508e08c1736089384bbee8/doc/src/sgml/system-views.sgml#L1811-L1813)
Excerpt:
```text
<para>
The view <structname>pg_policies</structname> provides access to
useful information about each row-level security policy in the database.
```
- [REL_17_11 · src/backend/rewrite/rowsecurity.c:921-928](https://github.com/postgres/postgres/blob/083ac033419f690758508e08c1736089384bbee8/src/backend/rewrite/rowsecurity.c#L921-L928)
Excerpt:
```text
/* Quick fall-thru for policies applied to all roles */
if (roles[0] == ACL_ID_PUBLIC)
return true;
for (i = 0; i < ARR_DIMS(policy_roles)[0]; i++)
{
if (has_privs_of_role(user_id, roles[i]))
return true;
```
Finding URL: https://pgtrue.postgres.ai/shared/brief/c8b29788-6fe2-48e5-8db9-35fe26e475eb#F8
### F9 · Accurate · Factual · Verified accurate: “A bulk import under row-level security is INSERT statements, or a role that bypasses the…”
Location: Article · exact quote · [open in article](https://now-next.nl/en/insights/postgresql-new-row-violates-row-level-security-policy#:~:text=A%20bulk%20import%20under%20row%2Dlevel,role%20that%20bypasses%20the%20policy.)
Article says:
```text
A bulk import under row-level security is INSERT statements, or a role that bypasses the policy.
```
What is true:
copy.c:228–232 contains the COPY FROM rejection for row-level security. The error recommends INSERT statements. This range does not establish which roles avoid that rejection.
Review: E-27 contains the rejection and INSERT hint. It omits the enclosing RLS guard and role-exemption logic. We removed the exemption assertion from the evidence-backed conclusion.
Sources:
- [REL_17_11 · src/backend/commands/copy.c:228-232](https://github.com/postgres/postgres/blob/083ac033419f690758508e08c1736089384bbee8/src/backend/commands/copy.c#L228-L232)
Excerpt:
```text
if (is_from)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("COPY FROM not supported with row-level security"),
errhint("Use INSERT statements instead.")));
```
Finding URL: https://pgtrue.postgres.ai/shared/brief/c8b29788-6fe2-48e5-8db9-35fe26e475eb#F9
### F10 · Accurate · Factual · Ordinary table owners bypass RLS unless FORCE applies
Location: Article · exact quote · [open in article](https://now-next.nl/en/insights/postgresql-new-row-violates-row-level-security-policy#:~:text=If%20your%20application%20connects%20as,this%20error%20is%20the%20problem.)
Article says:
```text
If your application connects as the owner, the absence of this error is the problem.
```
What is true:
rls.c:91 documents the ordinary owner exemption and FORCE exception. Under the article's setup, connecting as the owner can admit a row that app would fail.
Charitable reading:
The immediately preceding sentences distinguish ordinary owner access from FORCE ROW LEVEL SECURITY.
Review: We considered FORCE, BYPASSRLS, and internal integrity checks. The finding limits its conclusion to ordinary owners under the article's setup. We considered FORCE and BYPASSRLS exceptions. The finding explicitly concerns ordinary owners and preserves the FORCE qualification stated beside the article quote.
Sources:
- [REL_17_11 · src/backend/utils/misc/rls.c:91-93](https://github.com/postgres/postgres/blob/083ac033419f690758508e08c1736089384bbee8/src/backend/utils/misc/rls.c#L91-L93)
Excerpt:
```text
* Table owners generally bypass RLS, except if the table has been set (by
* an owner) to FORCE ROW SECURITY, and this is not a referential
* integrity check.
```
Finding URL: https://pgtrue.postgres.ai/shared/brief/c8b29788-6fe2-48e5-8db9-35fe26e475eb#F10
### F11 · Accurate · Factual · Missing and empty tenant settings produce a NULL comparison
Location: Article · exact quote · [open in article](https://now-next.nl/en/insights/postgresql-new-row-violates-row-level-security-policy#:~:text=An%20empty%20or%20missing%20setting%20makes%20the%20comparison%20NULL)
Article says:
```text
An empty or missing setting makes the comparison NULL…
```
What is true:
guc_funcs.c:834 returns NULL for an absent setting with missing_ok. NULLIF converts an empty setting to NULL. func.sgml:645 confirms that ordinary comparisons with NULL yield NULL. The article's expression handles both cases as stated.
Charitable reading:
The comparison includes the article's NULLIF wrapper around current_setting.
Review: We distinguished an absent setting from an empty string. missing_ok handles absence, and the article's NULLIF handles emptiness before comparison. We checked whether an empty string would instead cause an integer-cast error. The article's NULLIF wrapper converts it to NULL first.
Sources:
- [REL_17_11 · src/backend/utils/misc/guc_funcs.c:834-839](https://github.com/postgres/postgres/blob/083ac033419f690758508e08c1736089384bbee8/src/backend/utils/misc/guc_funcs.c#L834-L839)
Excerpt:
```text
/* return NULL if no such variable */
if (varval == NULL)
PG_RETURN_NULL();
/* Convert to text */
PG_RETURN_TEXT_P(cstring_to_text(varval));
```
- [REL_17_11 · doc/src/sgml/func.sgml:19860-19862](https://github.com/postgres/postgres/blob/083ac033419f690758508e08c1736089384bbee8/doc/src/sgml/func.sgml#L19860-L19862)
Excerpt:
```text
The <function>NULLIF</function> function returns a null value if
<replaceable>value1</replaceable> equals <replaceable>value2</replaceable>;
otherwise it returns <replaceable>value1</replaceable>.
```
- [REL_17_11 · doc/src/sgml/func.sgml:645-646](https://github.com/postgres/postgres/blob/083ac033419f690758508e08c1736089384bbee8/doc/src/sgml/func.sgml#L645-L646)
Excerpt:
```text
Ordinary comparison operators yield null (signifying <quote>unknown</quote>),
not true or false, when either input is null. For example,
```
Finding URL: https://pgtrue.postgres.ai/shared/brief/c8b29788-6fe2-48e5-8db9-35fe26e475eb#F11
### F12 · Accurate · Factual · Run transaction-local diagnostics before the failing statement
Location: Article · exact quote · [open in article](https://now-next.nl/en/insights/postgresql-new-row-violates-row-level-security-policy#:~:text=run%20in%20the%20same%20transaction,before%20the%20write%20that%20fails)
Article says:
```text
…run in the same transaction just before the write that fails…
```
What is true:
postgres.c:1139 rejects ordinary commands while the transaction remains aborted. Running the diagnostic SELECT statements before the failing write preserves access to that transaction's tenant setting.
Charitable reading:
The diagnostic concerns an explicit transaction that has not recovered through a savepoint or rollback.
Review: We considered savepoint recovery and transaction-exit commands. The finding concerns ordinary diagnostics while the transaction remains aborted, which postgres.c rejects. We considered recovery through rollback or savepoints. The finding concerns commands issued while the transaction remains aborted. PostgreSQL rejects those diagnostic SELECT statements.
Sources:
- [REL_17_11 · src/backend/tcop/postgres.c:1139-1145](https://github.com/postgres/postgres/blob/083ac033419f690758508e08c1736089384bbee8/src/backend/tcop/postgres.c#L1139-L1145)
Excerpt:
```text
if (IsAbortedTransactionBlockState() &&
!IsTransactionExitStmt(parsetree->stmt))
ereport(ERROR,
(errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
errmsg("current transaction is aborted, "
"commands ignored until end of transaction block"),
errdetail_abort()));
```
Finding URL: https://pgtrue.postgres.ai/shared/brief/c8b29788-6fe2-48e5-8db9-35fe26e475eb#F12
### F13 · Accurate · Factual · ON CONFLICT still checks INSERT policies
Location: excerpt · section “Why does an upsert fail when the row already exists?” · as fetched 2026-10-19 · [open in article](https://now-next.nl/en/insights/postgresql-new-row-violates-row-level-security-policy#:~:text=regardless%20of%20whether%20or%20not%20they%20end%20up%20being%20inserted)
Article says:
```text
…regardless of whether or not they end up being inserted…
```
What is true:
PostgreSQL 17 CREATE POLICY documents INSERT policy checks for every proposed row. Conflict handling does not exempt existing rows.
Charitable reading:
The statement concerns rows proposed for insertion, including rows later handled by conflict actions.
Review: We checked the quotation's surrounding documentation for conflict-action exceptions. PostgreSQL 17 explicitly applies INSERT checks to every proposed row. We checked the documentation's proposed-row qualification. INSERT policy checks apply even when conflict handling prevents insertion. The finding does not verify execution history.
Sources:
- [https://www.postgresql.org/docs/17/sql-createpolicy.html](https://www.postgresql.org/docs/17/sql-createpolicy.html)
Excerpt:
```text
regardless of whether or not they end up being inserted
```
Finding URL: https://pgtrue.postgres.ai/shared/brief/c8b29788-6fe2-48e5-8db9-35fe26e475eb#F13
### F14 · Accurate · Factual · RETURNING id adds a SELECT policy check
Location: Article · exact quote · [open in article](https://now-next.nl/en/insights/postgresql-new-row-violates-row-level-security-policy#:~:text=must%20satisfy%20the%20relation%E2%80%99s%20SELECT%20policies)
Article says:
```text
…must satisfy the relation’s SELECT policies…
```
What is true:
PostgreSQL 17 CREATE POLICY requires returned inserted rows to satisfy SELECT policies. The article quotes that requirement accurately.
Charitable reading:
The examples return id, a column of the protected relation.
Review: We considered constant RETURNING expressions. The finding's title and stated scope concern RETURNING id, which reads the protected relation. We tested the scope against RETURNING expressions without target-column references. The finding specifically covers RETURNING id, which the documented SELECT-policy requirement supports.
Sources:
- [https://www.postgresql.org/docs/17/sql-createpolicy.html](https://www.postgresql.org/docs/17/sql-createpolicy.html)
Excerpt:
```text
must satisfy the relation's SELECT policies
```
Finding URL: https://pgtrue.postgres.ai/shared/brief/c8b29788-6fe2-48e5-8db9-35fe26e475eb#F14
### F15 · Accurate · Factual · Targeted ON CONFLICT checks SELECT policies
Location: Article · exact quote · [open in article](https://now-next.nl/en/insights/postgresql-new-row-violates-row-level-security-policy#:~:text=the%20rows%20proposed%20for%20insertion,using%20the%20relation%E2%80%99s%20SELECT%20policies)
Article says:
```text
…the rows proposed for insertion are checked using the relation’s SELECT policies…
```
What is true:
PostgreSQL 17 documents SELECT checks for DO UPDATE and DO NOTHING with an arbiter index or constraint specification.
Charitable reading:
The article limits DO NOTHING's additional check to statements with a conflict target.
Review: We checked whether the finding incorrectly includes bare DO NOTHING. It preserves the documentation's arbiter specification condition. We checked whether the finding extends SELECT checks to bare DO NOTHING. It preserves the documentation's arbiter-specification qualification.
Sources:
- [https://www.postgresql.org/docs/17/sql-createpolicy.html](https://www.postgresql.org/docs/17/sql-createpolicy.html)
Excerpt:
```text
the rows proposed for insertion are checked using the relation's SELECT policies
```
Finding URL: https://pgtrue.postgres.ai/shared/brief/c8b29788-6fe2-48e5-8db9-35fe26e475eb#F15
### F18 · Accurate · Factual · The matrix contains 11 writes across 5 setups
Location: Article · exact quote · [open in article](https://now-next.nl/en/insights/postgresql-new-row-violates-row-level-security-policy#:~:text=eleven%20writes%20against%20five%20policy%20setups)
Article says:
```text
…eleven writes against five policy setups…
```
What is true:
The full matrix uses A, B, C, D and F. Its 11 numbered writes give 55 displayed outcomes. Setup E belongs to the additional tests.
Charitable reading:
The 5 setups refer to the full matrix. Setup E and its variants receive additional tests.
Explanation: Checked for internal consistency: the evidence is the article itself.
Review: We counted 11 matrix rows and columns A, B, C, D, F. Setup E belongs to additional tests. The finding verifies 55 displayed outcomes, not execution history. We counted A, B, C, D and F as five matrix setups. Eleven numbered writes produce 55 displayed outcomes. Setup E belongs to the additional tests.
Finding URL: https://pgtrue.postgres.ai/shared/brief/c8b29788-6fe2-48e5-8db9-35fe26e475eb#F18
### F19 · Accurate · Factual · The stated starting population totals 15 rows
Location: Article · exact quote · [open in article](https://now-next.nl/en/insights/postgresql-new-row-violates-row-level-security-policy#:~:text=three%20tenants%20with%20five%20rows%20each)
Article says:
```text
…three tenants with five rows each…
```
What is true:
The stated population is 15 rows (derived: 3 tenants × 5 rows per tenant). The later starting-row count agrees.
Charitable reading:
The 15-row claim describes the initial population before each rolled-back write.
Explanation: Checked for internal consistency: the evidence is the article itself.
Review: We recalculated the population: 3 tenants × 5 rows per tenant equals 15 rows. The finding checks stated arithmetic without claiming independent execution evidence. We recalculated 3 tenants multiplied by 5 rows per tenant. The result matches the stated 15-row population. The finding expressly limits verification to arithmetic.
Finding URL: https://pgtrue.postgres.ai/shared/brief/c8b29788-6fe2-48e5-8db9-35fe26e475eb#F19
## Notes (not graded) (0)
None.
## Withdrawn findings (0)
None.
## Section checks
- Test setup · A · 1 verified-accurate · 100% of claims (15 of 15, plus 4 that need data we do not have)
- Message forms · A · 1 verified-accurate · 50% of claims (1 of 2, plus 8 that need data we do not have) provisional
- Decision tree · B+ · 1 misleading · 66% of claims (6 of 9, plus 2 that need data we do not have)
- Write results · A · 1 verified-accurate · 100% of claims (5 of 5, plus 59 that need data we do not have)
- Upsert and MERGE · A · 3 verified-accurate · 100% of claims (6 of 6, plus 2 that need data we do not have)
- SELECT policies on writes · A · 3 verified-accurate · 100% of claims (4 of 4, plus 2 that need data we do not have)
- Cross-tenant unique values · B+ · 1 inaccuracy · 50% of claims (2 of 4, plus 7 that need data we do not have) provisional
- Other outcomes · A · 3 verified-accurate · 75% of claims (6 of 8, plus 11 that need data we do not have)
- Database diagnostics · A · 3 verified-accurate · 75% of claims (9 of 12)
## Claim coverage
- Introduction: 4 of 7 Postgres claims checked, plus 6 that need data we do not have; not counted: 4 not a claim; not checked: 3 for other reasons
- Error meaning: 6 of 7 Postgres claims checked, plus 3 that need data we do not have; not counted: 3 duplicate, 1 not a claim; not checked: 1 for other reasons
- Test setup: 15 of 15 Postgres claims checked, plus 4 that need data we do not have; not counted: 1 not a claim
- Message forms: 1 of 2 Postgres claims checked, plus 8 that need data we do not have; not counted: 1 not a claim; not checked: 1 for other reasons
- Decision tree: 6 of 9 Postgres claims checked, plus 2 that need data we do not have; not counted: 1 product or opinion, 2 duplicate, 1 not a claim; not checked: 3 for other reasons
- Write results: 5 of 5 Postgres claims checked, plus 59 that need data we do not have; not counted: 1 not a claim
- Upsert and MERGE: 6 of 6 Postgres claims checked, plus 2 that need data we do not have; not counted: 1 not a claim
- SELECT policies on writes: 4 of 4 Postgres claims checked, plus 2 that need data we do not have; not counted: 1 duplicate, 1 not a claim
- Cross-tenant unique values: 2 of 4 Postgres claims checked, plus 7 that need data we do not have; not counted: 1 product or opinion, 1 duplicate, 2 not a claim; not checked: 2 for other reasons
- Other outcomes: 6 of 8 Postgres claims checked, plus 11 that need data we do not have; not counted: 1 duplicate, 3 not a claim; not checked: 2 for other reasons
- Database diagnostics: 9 of 12 Postgres claims checked; not counted: 1 product or opinion, 1 duplicate, 3 not a claim; not checked: 3 for other reasons
- Measurement scope: 1 of 2 Postgres claims checked; not counted: 1 product or opinion, 1 duplicate, 8 not a claim; not checked: 1 for other reasons
- Publisher and related reading: no checkable claims; not counted: 3 product or opinion, 9 not a claim
## What we did not check
- We did not reproduce the PostgreSQL 17.11 measurements or verify the original transaction logs.
- We did not evaluate the tenant_id index position against application workloads.
- We did not reproduce the article's result matrix or additional restrictive-policy tests.
- We could not verify the PostgreSQL 17.11 container or the reported execution date.
- We did not check every diagnostic, policy exception, or linked troubleshooting article against primary evidence.
- We did not establish release changes after the article's publication.
- We could not retrieve the services page.
- We did not reproduce the measurements the article displays.
- We could not compare the summarized writes with complete SQL statements and execution transcripts.
- Section “Message forms”: we checked 1 of 10 checkable claims.
- Section “Cross-tenant unique values”: we checked 2 of 11 checkable claims.
- Section “Introduction”: we checked 4 of 13 checkable claims.
- Section “Measurement scope”: we checked 1 of 2 checkable claims.
- We could not decide whether the article depends on finding F17.
## Notes
- A- — the findings address the article's main subject. What we did not check is listed below. We checked PostgreSQL 17.11 policy enforcement, message forms, write behavior, and diagnostic advice against source and documentation.
- We did not check everything in this article. What we did not check is listed below, in the words we recorded at the time. None of it moved the letter. We never charge our own limits to the article.
- Average of 4 axes: 3.65 · result A-
- Some explanatory text is not shown in this edition; the grade and findings are complete.
- Some checks did not happen for this edition, and each one we know of is listed above.
- Checked against: github.com/postgres/postgres REL_17_11 at commit 083ac033419f690758508e08c1736089384bbee8 (pinned target); github.com/pgbouncer/pgbouncer pgbouncer_1_26_1 at commit f03e9bf263d7ccd5d1d152a61811bf3258dd6b87 (pinned target); https://now-next.nl/en/ (fetched 2026-10-19T07:59:20.397281Z); https://now-next.nl/en/about/ (fetched 2026-10-19T07:59:22.117624Z); https://now-next.nl/en/insights/ (fetched 2026-10-19T07:59:21.319882Z); https://now-next.nl/en/insights/django-postgresql-row-level-security-tenant/ (fetched 2026-10-19T07:59:32.001511Z); https://now-next.nl/en/insights/drizzle-postgresql-row-level-security-tenant/ (fetched 2026-10-19T07:59:32.918757Z); https://now-next.nl/en/insights/pgbouncer-row-level-security-tenant-context/ (fetched 2026-10-19T07:59:25.512111Z); https://now-next.nl/en/insights/postgresql-debug-row-level-security-no-rows/ (fetched 2026-10-19T07:59:26.366581Z); https://now-next.nl/en/insights/postgresql-infinite-recursion-detected-in-policy-for-relation/ (fetched 2026-10-19T07:59:27.249678Z); https://now-next.nl/en/insights/postgresql-permission-denied-for-table-schema-sequence/ (fetched 2026-10-19T07:59:23.821913Z); https://now-next.nl/en/insights/postgresql-rls-using-vs-with-check-writes/ (fetched 2026-10-19T07:59:24.681954Z); https://now-next.nl/en/insights/postgresql-unique-constraint-per-tenant-soft-delete/ (fetched 2026-10-19T07:59:23.025969Z); https://www.postgresql.org/docs/17/sql-copy.html (fetched 2026-10-19T07:59:29.787137Z); https://www.postgresql.org/docs/17/sql-createpolicy.html (fetched 2026-10-19T07:59:28.570227Z).
- Article captured 2026-10-19T07:59:09.250782Z · SHA-256 3a875ee1ebfe302b8704104ea58de04c867d7b01fe372456b2951b49bf714151 · Text extracted from the article's HTML.
- Policy SHA-256 dbb4541317ecd9b40b53a6da5d64006a3f30d4e4d2a71cbeda5f6dd990d0b25c · Grading rules SHA-256 6fb334e79d6b9e7ed81d3238cc10d9de602ff87ed65ff2fa781f53bac5798765.
- We did not reproduce the PostgreSQL 17.11 measurements or verify the original transaction logs.
- We could not compare the summarized writes with complete SQL statements and execution transcripts.
- We could not verify the PostgreSQL 17.11 container or the reported execution date.
- We did not evaluate the tenant_id index position against application workloads.
- We did not check every diagnostic, policy exception, or linked troubleshooting article against primary evidence.
- We did not establish release changes after the article's publication.
- We could not retrieve the services page.
- The article gives a date without a time. We list that date at midnight UTC.
- source: pgbouncer names no release in the article, so it was read at 1.26.1, the latest at fetch time
- withheld: F16 — this finding failed a check this edition requires.
- review: the findings were written by one model and reviewed independently by a different model.
- 2026-10-27: Regraded under the current grading rules: the letter is the average of the axis letters, with every cap stated under it.
- 3 passages in this edition fell short of our own plain-English rules.
- Built from the article text captured above, 2 pinned source trees, and 13 fetched pages.
- 15 survived · 2 weakened · 0 withdrawn.
## Revision history
- [Revision 1](https://pgtrue.postgres.ai/shared/brief/c8b29788-6fe2-48e5-8db9-35fe26e475eb?v=1) · B · audit version not recorded
Details unavailable.
ElephantSeal: B.
- [Revision 2](https://pgtrue.postgres.ai/shared/brief/c8b29788-6fe2-48e5-8db9-35fe26e475eb?v=23) · 2026-10-11 06:38 UTC · A- · audit version not recorded · regrade version not recorded
Same article text, re-audited. 11 accurate · 2 wrong · 0 caveats.
ElephantSeal: A-.
Changes: Details unavailable.
- [Revision 3](https://pgtrue.postgres.ai/shared/brief/c8b29788-6fe2-48e5-8db9-35fe26e475eb?v=27) · this page · 2026-10-19 07:59 UTC · A- · audited with v1.0.14 (approx.) · regraded with v1.1.0 (approx.)
Article text changed. 15 accurate · 2 wrong · 0 caveats.
ElephantSeal: A-.
Changes: No longer reported: “All four tell tenant 2 that the slug is taken, and three of them that it is not its own…”; “…three of them that it is not its own…”. New: F17 “Plain INSERT does not disclose which tenant owns the duplicate slug” (false); F1 “The duplicate-key branch can misdiagnose a missing SELECT policy” (misleading).