]> granicus.if.org Git - postgresql/commitdiff
Fix Assert failure in PushOverrideSearchPath when trying to restore a search
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 13 Aug 2010 16:27:28 +0000 (16:27 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 13 Aug 2010 16:27:28 +0000 (16:27 +0000)
path that specifies useTemp, but there is no active temp schema in the
current session.  (This can happen if the path was saved during a transaction
that created a temp schema and was later rolled back.)  For existing callers
it's sufficient to ignore the useTemp flag in this case, though we might
later want to offer an option to create a fresh temp schema.  So far as I can
tell this is just an Assert failure: in a non-assert build, the code would
push a zero onto the new search path, which is useless but not very harmful.
Per bug report from Heikki.

Back-patch to 8.3; prior versions don't have this code.

src/backend/catalog/namespace.c
src/backend/utils/cache/plancache.c

index 12cb1720cde5bb9260708b525bf2c76206f09976..2b6d95807dc833be1cb89f2f7c6b1853e6f8c40b 100644 (file)
@@ -13,7 +13,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/catalog/namespace.c,v 1.118 2009/06/11 14:48:55 momjian Exp $
+ *       $PostgreSQL: pgsql/src/backend/catalog/namespace.c,v 1.118.2.1 2010/08/13 16:27:28 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -2486,6 +2486,17 @@ GetOverrideSearchPath(MemoryContext context)
  *
  * We allow nested overrides, hence the push/pop terminology.  The GUC
  * search_path variable is ignored while an override is active.
+ *
+ * It's possible that newpath->useTemp is set but there is no longer any
+ * active temp namespace, if the path was saved during a transaction that
+ * created a temp namespace and was later rolled back.  In that case we just
+ * ignore useTemp.  A plausible alternative would be to create a new temp
+ * namespace, but for existing callers that's not necessary because an empty
+ * temp namespace wouldn't affect their results anyway.
+ *
+ * It's also worth noting that other schemas listed in newpath might not
+ * exist anymore either.  We don't worry about this because OIDs that match
+ * no existing namespace will simply not produce any hits during searches.
  */
 void
 PushOverrideSearchPath(OverrideSearchPath *newpath)
@@ -2519,11 +2530,8 @@ PushOverrideSearchPath(OverrideSearchPath *newpath)
        if (newpath->addCatalog)
                oidlist = lcons_oid(PG_CATALOG_NAMESPACE, oidlist);
 
-       if (newpath->addTemp)
-       {
-               Assert(OidIsValid(myTempNamespace));
+       if (newpath->addTemp && OidIsValid(myTempNamespace))
                oidlist = lcons_oid(myTempNamespace, oidlist);
-       }
 
        /*
         * Build the new stack entry, then insert it at the head of the list.
index 3b22f406132c5ed786d8296f75b14bc89cf90b61..6c3082d34fce535598bebc5a59bc5496841a4d66 100644 (file)
@@ -35,7 +35,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/utils/cache/plancache.c,v 1.27.2.2 2010/01/13 16:57:03 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/utils/cache/plancache.c,v 1.27.2.3 2010/08/13 16:27:28 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -470,6 +470,8 @@ RevalidateCachedPlan(CachedPlanSource *plansource, bool useResOwner)
 
                /*
                 * Restore the search_path that was in use when the plan was made.
+                * See comments for PushOverrideSearchPath about limitations of this.
+                *
                 * (XXX is there anything else we really need to restore?)
                 */
                PushOverrideSearchPath(plansource->search_path);