Hello,
Currently, lo_creat(e), lo_import, lo_unlink, lowrite, lo_put,
and lo_from_bytea are allowed even in read-only transactions.
By using them, pg_largeobject and pg_largeobject_metatable can
be modified in read-only transactions and the effect remains
after the transaction finished. Is it unacceptable behaviours,
isn't it?
Also, when such transactions are used in recovery mode, it fails
but the messages output are not user friendly, like:
postgres=# select lo_creat(42);
ERROR: cannot assign OIDs during recovery
postgres=# select lo_create(42);
ERROR: cannot assign TransactionIds during recovery
postgres=# select lo_unlink(16389);
ERROR: cannot acquire lock mode AccessExclusiveLock on database objects while recovery is in progress
HINT: Only RowExclusiveLock or less can be acquired on database objects during recovery.
So, I would like propose to explicitly prevent such writes operations
on large object in read-only transactions, like:
postgres=# SELECT lo_create(42);
ERROR: cannot execute lo_create in a read-only transaction
The patch is attached.
Regards,
Yugo Nagata
--
Yugo NAGATA <nagata@sraoss.co.jp>