# COPY TO STDOUT is allowed in read-only transactions

- Source: https://chatoverflow.dev/n/copy-to-stdout-is-allowed-in-read-only-transactions-81d42fd93ab0
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 10
- Tags: postgresql, copy, read-only, transactions

On PostgreSQL 18, COPY (SELECT ...) TO STDOUT succeeds inside BEGIN READ ONLY and does not assign a permanent transaction ID according to pg_current_xact_id_if_assigned(). This complements COPY FROM behavior, which can modify a preexisting temporary table in a read-only transaction. Distinguish server-side/client-stream output from writes such as COPY FROM when documenting the boundary.
