-<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.336 2006/09/10 19:03:57 tgl Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.337 2006/09/14 22:05:05 tgl Exp $ -->
<chapter id="functions">
<title>Functions and Operators</title>
<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>
*
* Copyright (c) 2003-2006, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/backend/catalog/information_schema.sql,v 1.36 2006/09/05 21:08:35 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/catalog/information_schema.sql,v 1.37 2006/09/14 22:05:06 tgl Exp $
*/
/*
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')
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/catalog/namespace.c,v 1.86 2006/07/14 14:52:17 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/catalog/namespace.c,v 1.87 2006/09/14 22:05:06 tgl Exp $
*
*-------------------------------------------------------------------------
*/
Datum pg_operator_is_visible(PG_FUNCTION_ARGS);
Datum pg_opclass_is_visible(PG_FUNCTION_ARGS);
Datum pg_conversion_is_visible(PG_FUNCTION_ARGS);
+Datum pg_my_temp_schema(PG_FUNCTION_ARGS);
+Datum pg_is_other_temp_schema(PG_FUNCTION_ARGS);
/*
PG_RETURN_BOOL(ConversionIsVisible(oid));
}
+
+Datum
+pg_my_temp_schema(PG_FUNCTION_ARGS)
+{
+ PG_RETURN_OID(myTempNamespace);
+}
+
+Datum
+pg_is_other_temp_schema(PG_FUNCTION_ARGS)
+{
+ Oid oid = PG_GETARG_OID(0);
+
+ PG_RETURN_BOOL(isOtherTempNamespace(oid));
+}
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.423 2006/09/10 00:29:34 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.424 2006/09/14 22:05:06 tgl Exp $
*
* NOTES
* The script catalog/genbki.sh reads this file and generates .bki
DESCR("is opclass visible in search path?");
DATA(insert OID = 2093 ( pg_conversion_is_visible PGNSP PGUID 12 f f t f s 1 16 "26" _null_ _null_ _null_ pg_conversion_is_visible - _null_ ));
DESCR("is conversion visible in search path?");
+DATA(insert OID = 2854 ( pg_my_temp_schema PGNSP PGUID 12 f f t f s 0 26 "" _null_ _null_ _null_ pg_my_temp_schema - _null_ ));
+DESCR("get OID of current session's temp schema, if any");
+DATA(insert OID = 2855 ( pg_is_other_temp_schema PGNSP PGUID 12 f f t f s 1 16 "26" _null_ _null_ _null_ pg_is_other_temp_schema - _null_ ));
+DESCR("is schema another session's temp schema?");
DATA(insert OID = 2171 ( pg_cancel_backend PGNSP PGUID 12 f f t f v 1 16 "23" _null_ _null_ _null_ pg_cancel_backend - _null_ ));
DESCR("Cancel a server process' current query");