Re: Creating temp tables inside read only transactions

From: Guillaume Lelarge <guillaume(at)lelarge(dot)info>
To: mike beeper <mbeeper(at)hotmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Creating temp tables inside read only transactions
Date: 2011-07-07 20:24:07
Message-ID: 1310070248.2046.6.camel@laptop
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Thu, 2011-07-07 at 16:01 +0000, mike beeper wrote:
> I have a function that creates a temp table, populate it with results
> during intermediate processing, and reads from it at the end. When
> the transaction is marked as read only, it does not allow creation of
> temp table, even though there are no permanent writes to the db. Are
> there any workarounds? The following block errors out.
>
> SET TRANSACTION ISOLATION LEVEL READ COMMITTED READ ONLY;
> create temp table test(test int);
>

When you create a temporary table, PostgreSQL needs to add rows in
pg_class, pg_attribute, and probably other system catalogs. So there are
writes, which aren't possible in a read-only transaction. Hence the
error. And no, there is no workaround.

--
Guillaume
http://blog.guillaume.lelarge.info
http://www.dalibo.com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Guillaume Lelarge 2011-07-07 20:26:45 Re: DELETE taking too much memory
Previous Message John R Pierce 2011-07-07 20:18:32 Re: Add Foreign Keys To Table

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2011-07-07 20:24:55 Re: SSI atomic commit
Previous Message Peter Eisentraut 2011-07-07 20:09:49 Re: spurious use of %m format in pg_upgrade