When a transaction is read-only,the following sql commands are disallowed:INSERT,UPDATEDELETECOPY FROMif the table they would write to is not a temporary table; allCREATEALTERDROPcommands;COMMENTGRANTREVOKETRUNCATE; andEXPLAIN ANALYZEandEXECUTEif the command they would execute is among those listed. This is a high-level notion of read-only that does not prevent all writes to disk.
mydb=# begin;
BEGIN
mydb=# set transaction read only;
SET
--插入数据失败 mydb=# insert into t values(generate_series(1,10000),'rudy'); ERROR: cannot execute INSERT in a read-only transaction