aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2015-04-06 11:40:55 -0300
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2015-04-06 11:40:55 -0300
commite9a077cad3799b41e8deef6fd8cb87e50164a791 (patch)
tree7f0794bc0faacc9eb8d62b1f5c07fd82790a1474 /src/backend/utils
parent70dc2db7f1dfdecdacf595bf00964cb20ad5a835 (diff)
downloadpostgresql-e9a077cad3799b41e8deef6fd8cb87e50164a791.tar.gz
postgresql-e9a077cad3799b41e8deef6fd8cb87e50164a791.zip
pg_event_trigger_dropped_objects: add is_temp column
It now also reports temporary objects dropped that are local to the backend. Previously we weren't reporting any temp objects because it was deemed unnecessary; but as it turns out, it is necessary if we want to keep close track of DDL command execution inside one session. Temp objects are reported as living in schema pg_temp, which works because such a schema-qualification always refers to the temp objects of the current session.
Diffstat (limited to 'src/backend/utils')
-rw-r--r--src/backend/utils/adt/format_type.c2
-rw-r--r--src/backend/utils/adt/regproc.c4
-rw-r--r--src/backend/utils/cache/lsyscache.c15
3 files changed, 18 insertions, 3 deletions
diff --git a/src/backend/utils/adt/format_type.c b/src/backend/utils/adt/format_type.c
index fc816cef852..2f0f0a1d895 100644
--- a/src/backend/utils/adt/format_type.c
+++ b/src/backend/utils/adt/format_type.c
@@ -305,7 +305,7 @@ format_type_internal(Oid type_oid, int32 typemod,
if (!force_qualify && TypeIsVisible(type_oid))
nspname = NULL;
else
- nspname = get_namespace_name(typeform->typnamespace);
+ nspname = get_namespace_name_or_temp(typeform->typnamespace);
typname = NameStr(typeform->typname);
diff --git a/src/backend/utils/adt/regproc.c b/src/backend/utils/adt/regproc.c
index 3d1bb32030e..11d663b295d 100644
--- a/src/backend/utils/adt/regproc.c
+++ b/src/backend/utils/adt/regproc.c
@@ -460,7 +460,7 @@ format_procedure_parts(Oid procedure_oid, List **objnames, List **objargs)
procform = (Form_pg_proc) GETSTRUCT(proctup);
nargs = procform->pronargs;
- *objnames = list_make2(get_namespace_name(procform->pronamespace),
+ *objnames = list_make2(get_namespace_name_or_temp(procform->pronamespace),
pstrdup(NameStr(procform->proname)));
*objargs = NIL;
for (i = 0; i < nargs; i++)
@@ -922,7 +922,7 @@ format_operator_parts(Oid operator_oid, List **objnames, List **objargs)
operator_oid);
oprForm = (Form_pg_operator) GETSTRUCT(opertup);
- *objnames = list_make2(get_namespace_name(oprForm->oprnamespace),
+ *objnames = list_make2(get_namespace_name_or_temp(oprForm->oprnamespace),
pstrdup(NameStr(oprForm->oprname)));
*objargs = NIL;
if (oprForm->oprleft)
diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c
index 818c2f619ba..6a398638906 100644
--- a/src/backend/utils/cache/lsyscache.c
+++ b/src/backend/utils/cache/lsyscache.c
@@ -19,6 +19,7 @@
#include "access/htup_details.h"
#include "access/nbtree.h"
#include "bootstrap/bootstrap.h"
+#include "catalog/namespace.h"
#include "catalog/pg_amop.h"
#include "catalog/pg_amproc.h"
#include "catalog/pg_collation.h"
@@ -2884,6 +2885,20 @@ get_namespace_name(Oid nspid)
return NULL;
}
+/*
+ * get_namespace_name_or_temp
+ * As above, but if it is this backend's temporary namespace, return
+ * "pg_temp" instead.
+ */
+char *
+get_namespace_name_or_temp(Oid nspid)
+{
+ if (isTempNamespace(nspid))
+ return "pg_temp";
+ else
+ return get_namespace_name(nspid);
+}
+
/* ---------- PG_RANGE CACHE ---------- */
/*