pg_temp 101 question

From: Konstantin Izmailov <pgfizm(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: pg_temp 101 question
Date: 2011-01-04 03:14:16
Message-ID: AANLkTi=Kz_EiwXezOZAjr9-v6_Rd=J+nq3z=nBWdkSKd@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

My application creates/uses a temporary table "X" via multiple
connections at the same time. Is there a way to determine which
pg_temp_N belongs to the current connection?

I need this to obtain list of attributes for the temporary table...
All connections are using the same temp table name (by design made
long time ago for another DB). So if I query:
select T.schemaname, T.tablename, A.attname, A.atttypid, TY.typname, D.adsrc
from pg_attribute A
inner join pg_class C on (A.attrelid=C.oid)
inner join pg_tables T on (C.relname=T.tablename)
inner join pg_namespace NS on (NS.oid=C.relnamespace and
NS.nspname=T.schemaname)
inner join pg_type TY on (TY.oid=A.atttypid)
left outer join pg_attrdef D on (D.adrelid=C.oid and D.adnum=A.attnum)
where A.attnum>0 and A.attisdropped='f' and T.schemaname like
'pg_temp%' and T.tablename='X'

it returns list of all columns in all temporary tables. I just need
columns list for temp table for the current connection.

Thank you!

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2011-01-04 04:20:17 Re: pg_temp 101 question
Previous Message Craig Ringer 2011-01-03 23:56:40 Re: Shit happens