Re: ERRCODE_READ_ONLY_SQL_TRANSACTION

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Simon Riggs <simon@2ndQuadrant.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2012-01-12T22:33:08Z
Lists: pgsql-hackers
Simon Riggs <simon@2ndQuadrant.com> writes:
> Hot Standby returns ERRCODE_READ_ONLY_SQL_TRANSACTION in most cases
> for illegal actions on a standby.

> There are two possible but not normally seen cases that give errors,
> but don't set the correct sqlstate, which makes it difficult to
> diagnose misdirected SQL from more normal SQL problems.

> *Patch corrects this. Thanks to Dimitri for the report.

I don't think I like this patch: you are promoting what are and ought to
be very low-level internal sanity checks into user-facing errors (which
among other things will require translation effort for the messages).
I note that you didn't bother even to adjust the adjacent comments
saying this should never happen.

What I want to know is what code path led to these and why the read-only
ereport did not occur at a far higher level.  If we have gaps in the RO
checking we should be fixing them somewhere else, not band-aiding here.

			regards, tom lane