Re: Which Schema I am working on?? - Mailing list pgsql-general

From Tom Lane
Subject Re: Which Schema I am working on??
Date
Msg-id 4336.1058293480@sss.pgh.pa.us
Whole thread Raw
In response to Which Schema I am working on??  (Harry Yau <harry@aurasound.com.hk>)
List pgsql-general
Harry Yau <harry@aurasound.com.hk> writes:
>   I am writing a pl/psql function with a temp table right now.
> It creates the temp table inside. Whenever I call this function in a
> session for the first time, it creates a shema, namely pg_temp_number,
> automatically and it creates the temp table within the schema. I've
> tried to add a check inside the function to check have the temp table
> been already existed.

Try something like

IF EXISTS(SELECT 1 FROM pg_class
          WHERE relname = 'tablexxx' AND pg_table_is_visible(oid))
THEN ... drop it ...

The visibility check will reject temp tables belonging to other
sessions.

            regards, tom lane

pgsql-general by date:

Previous
From: Frank Finner
Date:
Subject: Re: Are you frustrated with PostgreSQL
Next
From: "Vincent Hikida"
Date:
Subject: Re: Fw: select null + 0 question