Search Postgresql Archives

Reliably finding temporary table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We have some functions which need to dynamically create a temporary
table if it does not already exist.  We use the following function:

CREATE OR REPLACE FUNCTION test_date_time_exists() RETURNS BOOLEAN AS '
    BEGIN
        RETURN EXISTS (
            SELECT * FROM pg_class 
            WHERE relname = ''test_date_time'' 
            AND pg_table_is_visible(oid)
        );
    END;
' LANGUAGE 'plpgsql' STABLE

However, this has been failing occassionally with errors like

ERROR: cache lookup failed for relation 3454264547

>From looking in the list archives, I found a description of
pg_table_is_visible failing because it has different snapshot
semantics than the SELECT.  Is there a solution for this problem?  Is
there another function I can use?  What is a better way to detect temp
tables visible to the  session?

 - Ian

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

               http://archives.postgresql.org


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux