BUG #16006: Update queries fail on a table having any policy with a function that takes a whole-row var as arg
The Post Office <noreply@postgresql.org>
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: vinay.s.banakar@gmail.com
Date: 2019-09-12T16:51:01Z
Lists: pgsql-bugs
The following bug has been logged on the website: Bug reference: 16006 Logged by: Vinay Banakar Email address: vinay.s.banakar@gmail.com PostgreSQL version: 9.5.19 Operating system: Ubuntu 16.04.6 LTS Description: Update queries fail on a table having any policy with a function that takes a whole-row var as argument: I stumbled upon this after I had enabled RLS on a table and have a policy that basically raises every row read to log at INFO level (a quick hack for benchmarking). Table: create table usertable(key VARCHAR PRIMARY KEY,field0 text,field1 text,field2 text,field3 text,field4 text,field5 text,field6 text,field7 text,field8 text,field9 text,timestamp timestamp NOT NULL DEFAULT NOW()); # This policy is to raise a row to INFO log when an operation is made on that. ALTER TABLE usertable enable ROW LEVEL SECURITY; ALTER TABLE usertable force ROW LEVEL SECURITY; create function log_record(_tbl usertable) returns boolean language plpgsql immutable as $$ begin raise info 'log: %', $1; return true; end; $$; CREATE POLICY loggerPolicy ON usertable USING (log_record(usertable)); Now any update queries on this table fail. This was working correctly on 9.5.15. Thanks to RhodiumToad from #postgresql for verifying the bug.
Commits
-
Fix usage of whole-row variables in WCO and RLS policy expressions.
- b54cff2bf32d 10.11 landed
- 64d926f2b073 11.6 landed
- 7f1f72c44400 13.0 landed
- ca08ea52bfbc 9.4.25 landed
- b00132b9a2b5 9.6.16 landed
- aee5736f1540 9.5.20 landed
- 5e9b18c78789 12.0 landed