在PostgreSQL函数中,我正在循环中创建一个名为table1
的临时表。
要检查该表在其他迭代中是否已经存在,我使用查询select * from pg_tables where tablename = '..'
。
但是,如果表在迭代过程中不存在(介于两者之间),它仍然表示该表存在。有什么方法可以检查表是否存在于查询中,而不是查询中?
查询样本
db=# select * from pg_tables where tablename = 'table1';
schemaname | tablename | tableowner | tablespace | hasindexes | hasrules | hastriggers |rowsecurity
------------+-----------+------------+------------+------------+----------+-------------+-------------
pg_temp_3 | table1 | user1 |user1 _data1 | t | f | f | f
(1 row)
db=# \d table1
Did not find any relation named "table1".
在函数被异常中断后引发此问题。有任何建议或发现吗?