Are temp table really invisible for existing table

Started by PostgreSQL Bugs Listover 24 years ago3 messagesbugs
Jump to latest
#1PostgreSQL Bugs List
pgsql-bugs@postgresql.org

Rahul Gade (Rahul_g@ip.eth.net) reports a bug with a severity of 3
The lower the number the more severe it is.

Short Description
Are temp table really invisible for existing table

Long Description
Ok !!
I know creating the temp table with the name of existing table don't create any problem.
but, when i try to create a new table (not temp) with the same name as that of name of temporary table recently created it gives me message as "the table already exists"

try this :

create temp table table1(idd int);
create table table1(idd int);

should it be happened ?

----------------------------------------------
Please help me in solving one problem :
my one function is creating or not creating a temp table based on condition. How the same function will recognise that the temp table with this name already exists(or created by previous execution of the same function), since the same procedure is executed in many times in a single connection session.
I don't want to close my connection, because it's not feasible for my application.

* Is there any function to check the existance of temporary table,
* is there any function which would check that the table exists or not without firing the message of "table does not exists"

Thanks for quick response in advance

Sample Code

No file was uploaded with this report

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: PostgreSQL Bugs List (#1)
Re: Are temp table really invisible for existing table

pgsql-bugs@postgresql.org writes:

but, when i try to create a new table (not temp) with the same name
as that of name of temporary table recently created it gives me
message as "the table already exists"

This is the intended behavior...

should it be happened ?

Dunno. As things currently stand, the only thing we could do
differently is to automatically drop the temp table when we see a
regular create for the same name. (If we don't, the existence of
the temp table creates naming conflicts that will cause problems
for the regular create.) That doesn't seem like a great idea to me.

* Is there any function to check the existance of temporary table,

Not at the moment. You might consider creating the temp table at the
start of a client session, and letting the function just assume that
it exists. (Once we implement schemas it should be possible to look
in the system catalogs to check existence of a temp table, but the
way it's done right now is a kluge that's not reflected in the
catalogs.)

regards, tom lane

#3Bruce Momjian
bruce@momjian.us
In reply to: PostgreSQL Bugs List (#1)
Re: Are temp table really invisible for existing table

This is the way it is supposed to work, I think. You can layer a temp
on top of a real, but not a real on top of a temp.

Rahul Gade (Rahul_g@ip.eth.net) reports a bug with a severity of 3
The lower the number the more severe it is.

Short Description
Are temp table really invisible for existing table

Long Description
Ok !!
I know creating the temp table with the name of existing table don't create any problem.
but, when i try to create a new table (not temp) with the same name as that of name of temporary table recently created it gives me message as "the table already exists"

try this :

create temp table table1(idd int);
create table table1(idd int);

should it be happened ?

----------------------------------------------
Please help me in solving one problem :
my one function is creating or not creating a temp table based on condition. How the same function will recognise that the temp table with this name already exists(or created by previous execution of the same function), since the same procedure is executed in many times in a single connection session.
I don't want to close my connection, because it's not feasible for my application.

* Is there any function to check the existance of temporary table,
* is there any function which would check that the table exists or not without firing the message of "table does not exists"

Thanks for quick response in advance

Sample Code

No file was uploaded with this report

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026