Drop only temporary table

From: Durumdara <durumdara(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Drop only temporary table
Date: 2016-03-18 12:47:06
Message-ID: CAEcMXhkGbRKGOQ=24AbXebNuf2h+A_Y9nWu+16eQ4F2XGK3_7Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Dear PG Masters!

As I experienced I can create normal and temp table with same name.

create table x (kod integer);

CREATE TEMPORARY TABLE x (kod integer);

select tablename from pg_tables where schemaname='public'
union all
select c.relname from pg_class c
join pg_namespace n on n.oid=c.relnamespace
where
n.nspname like 'pg_temp%'
and c.relkind = 'r'
and pg_table_is_visible(c.oid);

---

I can see two x tables.

As I see that drop table stmt don't have "temporary" suboption to determine
which to need to eliminate - the real or the temporary.

Same thing would happen with other DDL/DML stmts - what is the destination
table - the real or the temporary?

"insert into x(kod) values(1)"

So what do you think about this problem?

I want to avoid to remove any real table on resource closing (= dropping of
temporary table).
How to I force "drop only temporary"? Prefix, option, etc.

Thanks for your help!

dd

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2016-03-18 13:27:23 Re: Drop only temporary table
Previous Message Jan de Visser 2016-03-18 12:41:42 Re: Crypt change in 9.4.5