<entry>port of the local connection</entry>
</row>
+ <row>
+ <entry><literal><function>pg_my_temp_schema</function>()</literal></entry>
+ <entry><type>oid</type></entry>
+ <entry>OID of session's temporary schema, or 0 if none</entry>
+ </row>
+
+ <row>
+ <entry><literal><function>pg_is_other_temp_schema</function>(<type>oid</type>)</literal></entry>
+ <entry><type>boolean</type></entry>
+ <entry>is schema another session's temporary schema?</entry>
+ </row>
+
<row>
<entry><literal><function>pg_postmaster_start_time</function>()</literal></entry>
<entry><type>timestamp with time zone</type></entry>
Unix-domain socket.
</para>
+ <indexterm zone="functions-info">
+ <primary>pg_my_temp_schema</primary>
+ </indexterm>
+
+ <indexterm zone="functions-info">
+ <primary>pg_is_other_temp_schema</primary>
+ </indexterm>
+
+ <para>
+ <function>pg_my_temp_schema</function> returns the OID of the current
+ session's temporary schema, or 0 if it has none (because it has not
+ created any temporary tables).
+ <function>pg_is_other_temp_schema</function> returns true if the
+ given OID is the OID of any other session's temporary schema.
+ (This can be useful, for example, to exclude other sessions' temporary
+ tables from a catalog display.)
+ </para>
+
<indexterm zone="functions-info">
<primary>pg_postmaster_start_time</primary>
</indexterm>
WHERE a.attrelid = c.oid
AND a.atttypid = t.oid
AND nc.oid = c.relnamespace
- AND (nc.nspname NOT LIKE 'pg!_temp!_%' ESCAPE '!' OR pg_catalog.pg_table_is_visible(c.oid))
+ AND (NOT pg_is_other_temp_schema(nc.oid))
+
AND a.attnum > 0 AND NOT a.attisdropped AND c.relkind in ('r', 'v')
AND (pg_has_role(c.relowner, 'USAGE')
AND nc.oid = c.connamespace
AND c.contype IN ('p', 'u', 'f')
AND r.relkind = 'r'
- AND (nr.nspname NOT LIKE 'pg!_temp!_%' ESCAPE '!' OR pg_catalog.pg_table_is_visible(r.oid))
+ AND (NOT pg_is_other_temp_schema(nr.oid))
AND (pg_has_role(r.relowner, 'USAGE')
OR has_table_privilege(c.oid, 'SELECT')
OR has_table_privilege(c.oid, 'INSERT')
FROM pg_namespace nc, pg_class c
WHERE c.relnamespace = nc.oid
AND c.relkind = 'S'
- AND (nc.nspname NOT LIKE 'pg!_temp!_%' ESCAPE '!' OR pg_catalog.pg_table_is_visible(c.oid))
+ AND (NOT pg_is_other_temp_schema(nc.oid))
AND (pg_has_role(c.relowner, 'USAGE')
OR has_table_privilege(c.oid, 'SELECT')
OR has_table_privilege(c.oid, 'UPDATE') );
WHERE nc.oid = c.connamespace AND nr.oid = r.relnamespace
AND c.conrelid = r.oid
AND r.relkind = 'r'
- AND (nr.nspname NOT LIKE 'pg!_temp!_%' ESCAPE '!' OR pg_catalog.pg_table_is_visible(r.oid))
+ AND (NOT pg_is_other_temp_schema(nr.oid))
AND (pg_has_role(r.relowner, 'USAGE')
-- SELECT privilege omitted, per SQL standard
OR has_table_privilege(r.oid, 'INSERT')
AND a.attnum > 0
AND NOT a.attisdropped
AND r.relkind = 'r'
- AND (nr.nspname NOT LIKE 'pg!_temp!_%' ESCAPE '!' OR pg_catalog.pg_table_is_visible(r.oid))
+ AND (NOT pg_is_other_temp_schema(nr.oid))
AND (pg_has_role(r.relowner, 'USAGE')
OR has_table_privilege(r.oid, 'SELECT')
OR has_table_privilege(r.oid, 'INSERT')
CAST(c.relname AS sql_identifier) AS table_name,
CAST(
- CASE WHEN nc.nspname LIKE 'pg!_temp!_%' ESCAPE '!' THEN 'LOCAL TEMPORARY'
+ CASE WHEN nc.oid = pg_my_temp_schema() THEN 'LOCAL TEMPORARY'
WHEN c.relkind = 'r' THEN 'BASE TABLE'
WHEN c.relkind = 'v' THEN 'VIEW'
ELSE null END
THEN 'YES' ELSE 'NO' END AS character_data) AS is_insertable_into,
CAST('NO' AS character_data) AS is_typed,
CAST(
- CASE WHEN nc.nspname LIKE 'pg!_temp!_%' ESCAPE '!' THEN 'PRESERVE'
+ CASE WHEN nc.oid = pg_my_temp_schema() THEN 'PRESERVE' -- FIXME
ELSE null END
AS character_data) AS commit_action
WHERE c.relnamespace = nc.oid
AND c.relkind IN ('r', 'v')
- AND (nc.nspname NOT LIKE 'pg!_temp!_%' ESCAPE '!' OR pg_catalog.pg_table_is_visible(c.oid))
+ AND (NOT pg_is_other_temp_schema(nc.oid))
AND (pg_has_role(c.relowner, 'USAGE')
OR has_table_privilege(c.oid, 'SELECT')
OR has_table_privilege(c.oid, 'INSERT')
AND c.oid = t.tgrelid
AND t.tgtype & em.num <> 0
AND NOT t.tgisconstraint
- AND (n.nspname NOT LIKE 'pg!_temp!_%' ESCAPE '!' OR pg_catalog.pg_table_is_visible(c.oid))
+ AND (NOT pg_is_other_temp_schema(n.oid))
AND (pg_has_role(c.relowner, 'USAGE')
-- SELECT privilege omitted, per SQL standard
OR has_table_privilege(c.oid, 'INSERT')
WHERE c.relnamespace = nc.oid
AND c.relkind = 'v'
- AND (nc.nspname NOT LIKE 'pg!_temp!_%' ESCAPE '!' OR pg_catalog.pg_table_is_visible(c.oid))
+ AND (NOT pg_is_other_temp_schema(nc.oid))
AND (pg_has_role(c.relowner, 'USAGE')
OR has_table_privilege(c.oid, 'SELECT')
OR has_table_privilege(c.oid, 'INSERT')