pg_temp 101 question - Mailing list pgsql-general

From Konstantin Izmailov
Subject pg_temp 101 question
Date
Msg-id AANLkTi=Kz_EiwXezOZAjr9-v6_Rd=J+nq3z=nBWdkSKd@mail.gmail.com
Whole thread Raw
Responses Re: pg_temp 101 question  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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!

pgsql-general by date:

Previous
From: Craig Ringer
Date:
Subject: Re: Shit happens
Next
From: Tom Lane
Date:
Subject: Re: pg_temp 101 question