pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedReturn value of CREATE TABLE
3+ messages / 3 participants
[nested] [flat]
* Return value of CREATE TABLE
@ 2020-09-10 12:06 Mike Martin <redtux1@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Mike Martin @ 2020-09-10 12:06 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Is this possible?
Basically I want to manage temp table status for use in a procedure.
The procedure looks at pg_catalog to get information for processing.
So basically I would like to be able to know what namespace a temp table is
created in, so that I can constrain lookup.
example
CREATE TEMP TABLE tagdata (test int,test2 numeric(10,2));
SELECT relname,relpersistence ,relnamespace
,pa.atttypid,attname,attnum
,nspname
FROM pg_catalog.pg_class pc
JOIN pg_attribute pa ON pc.oid=pa.attrelid
JOIN pg_namespace pn ON pn.oid=relnamespace
WHERE relname = 'tagdata' AND attnum>0
Which returns (when its run for the second time in different tabs in
pgadmin)
relname persistence namespace typeid colname colnum schema
"tagdata" "p" "2200" "23" "fileid" 1
"public"
"tagdata" "p" "2200" "25" "tagname" 2 "public"
"tagdata" "p" "2200" "1009" "tagvalue" 3 "public"
"tagdata" "t" "483934" "23" "test" 1
"pg_temp_10"
"tagdata" "t" "538079" "23" "test" 1
"pg_temp_13"
"tagdata" "t" "538079" "1700" "test2" 2
"pg_temp_13"
So I would like some way of knowing exactly which schema the temp table has
been created in, I cant see anything obvious
thanks
Mike
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Return value of CREATE TABLE
@ 2020-09-10 12:16 Christoph Moench-Tegeder <cmt@burggraben.net>
parent: Mike Martin <redtux1@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Christoph Moench-Tegeder @ 2020-09-10 12:16 UTC (permalink / raw)
To: Mike Martin <redtux1@gmail.com>; +Cc: pgsql-general@lists.postgresql.org
## Mike Martin (redtux1@gmail.com):
> So basically I would like to be able to know what namespace a temp table is
> created in, so that I can constrain lookup.
pg_my_temp_schema() returns the OID of the session's temporary schema
("or 0 if none", according to the docs).
Regards,
Christoph
--
Spare Space
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Return value of CREATE TABLE
@ 2020-09-10 12:36 Mike Martin <mike@redtux.plus.com>
parent: Christoph Moench-Tegeder <cmt@burggraben.net>
0 siblings, 0 replies; 3+ messages in thread
From: Mike Martin @ 2020-09-10 12:36 UTC (permalink / raw)
To: Christoph Moench-Tegeder <cmt@burggraben.net>; +Cc: pgsql-general@lists.postgresql.org
Thanks , exactly what I was looking for
On Thu, 10 Sep 2020 at 13:16, Christoph Moench-Tegeder <cmt@burggraben.net>
wrote:
> ## Mike Martin (redtux1@gmail.com):
>
> > So basically I would like to be able to know what namespace a temp table
> is
> > created in, so that I can constrain lookup.
>
> pg_my_temp_schema() returns the OID of the session's temporary schema
> ("or 0 if none", according to the docs).
>
> Regards,
> Christoph
>
> --
> Spare Space
>
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2020-09-10 12:36 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-09-10 12:06 Return value of CREATE TABLE Mike Martin <redtux1@gmail.com>
2020-09-10 12:16 ` Christoph Moench-Tegeder <cmt@burggraben.net>
2020-09-10 12:36 ` Mike Martin <mike@redtux.plus.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox