regclass, \d command and temp tables

Started by Tatsuo Ishiiover 15 years ago3 messages
#1Tatsuo Ishii
ishii@postgresql.org

Hi,

I have created regular table t1 and temp table t1. Regclass and \d
command do not seem to distinguish them. Is this normal?

test=# create table t1(i int);
CREATE TABLE
test=# select 't1'::regclass::oid;
oid
---------
1470776
(1 row)

test=# create temp table t1(i int, j int);
CREATE TABLE
test=# select 't1'::regclass::oid;
oid
---------
1470776 <-- why same oid?
(1 row)

test=# \d t1 <-- \d finds regular table, not temporary table?

Table "public.t1"
Column | Type | Modifiers
--------+---------+-----------
i | integer |

test=# insert into t1 values(1,2); <-- insert command works as expected of course.
INSERT 0 1
test=# select * from t1;
i | j
---+---
1 | 2
(1 row)
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese: http://www.sraoss.co.jp

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Tatsuo Ishii (#1)
Re: regclass, \d command and temp tables

Tatsuo Ishii <ishii@postgresql.org> writes:

I have created regular table t1 and temp table t1. Regclass and \d
command do not seem to distinguish them. Is this normal?

It works for me. Are you using clean sources?

regression=# create table t1(i int);
CREATE TABLE
regression=# select 't1'::regclass::oid;
oid
--------
127671
(1 row)

regression=# create temp table t1(i int, j int);
CREATE TABLE
regression=# select 't1'::regclass::oid;
oid
--------
127674
(1 row)

regards, tom lane

#3Tatsuo Ishii
ishii@postgresql.org
In reply to: Tom Lane (#2)
Re: regclass, \d command and temp tables

It works for me. Are you using clean sources?

regression=# create table t1(i int);
CREATE TABLE
regression=# select 't1'::regclass::oid;
oid
--------
127671
(1 row)

regression=# create temp table t1(i int, j int);
CREATE TABLE
regression=# select 't1'::regclass::oid;
oid
--------
127674
(1 row)

Oops. Sorry for noise. I accidentaly accessed through pgpool and it load
balanced the SELECT to different PostgreSQL server. Pgpool should have
remebered that temporary tables are created in the session.
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese: http://www.sraoss.co.jp