Re: Prevent writes on large objects in read-only transactions

Yugo Nagata <nagata@sraoss.co.jp>

From: Yugo NAGATA <nagata@sraoss.co.jp>
To: Michael Paquier <michael@paquier.xyz>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Robert Haas <robertmhaas@gmail.com>, "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2022-06-29T08:29:50Z
Lists: pgsql-hackers

Attachments

Hello Michael-san,

Thank you for reviewing the patch. I attached the updated patch.

On Thu, 16 Jun 2022 17:31:22 +0900
Michael Paquier <michael@paquier.xyz> wrote:

> Looking at the docs of large objects, as of "Client Interfaces", we
> mention that any action must take place in a transaction block.
> Shouldn't we add a note that no write operations are allowed in a
> read-only transaction?

I added a description about read-only transaction to the doc.

> +   if (mode & INV_WRITE)
> +       PreventCommandIfReadOnly("lo_open() in write mode");
> Nit.  This breaks translation.  I think that it could be switched to
> "lo_open(INV_WRITE)" instead as the flag name is documented.

Changed it as you suggested.
 
> The patch is forgetting a refresh for largeobject_1.out.

I added changes for largeobject_1.out.

> ---   INV_READ  = 0x20000
> ---   INV_WRITE = 0x40000
> +--   INV_READ  = 0x40000
> +--   INV_WRITE = 0x20000
> Good catch!  This one is kind of independent, so I have fixed it
> separately, in all the expected output files.

Thanks!

-- 
Yugo NAGATA <nagata@sraoss.co.jp>

Commits

  1. Prevent write operations on large objects in read-only transactions

  2. Fix comment in regression tests for large objects