Complain politely about access temp/unlogged tables during recovery.
authorRobert Haas <[email protected]>
Wed, 8 Jun 2011 02:12:44 +0000 (22:12 -0400)
committerRobert Haas <[email protected]>
Wed, 8 Jun 2011 02:17:08 +0000 (22:17 -0400)
This has never been supported, but we previously let md.c issue the
complaint for us at whatever point we tried to examine the backing file.
Now we print a nicer error message.

Per bug #6041, reported by Emanuel, and extensive discussion with Tom
Lane over where to put the check.

src/backend/optimizer/util/plancat.c

index fd8ea45b4a7bfb391e7bb003c2d34b7645826e81..b28681630b380d2b6df215978fb835ae922519f4 100644 (file)
@@ -90,6 +90,12 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
         */
        relation = heap_open(relationObjectId, NoLock);
 
+       /* Temporary and unlogged relations are inaccessible during recovery. */
+       if (!RelationNeedsWAL(relation) && RecoveryInProgress())
+               ereport(ERROR,
+                               (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+                                errmsg("cannot access temporary or unlogged relations during recovery")));
+
        rel->min_attr = FirstLowInvalidHeapAttributeNumber + 1;
        rel->max_attr = RelationGetNumberOfAttributes(relation);
        rel->reltablespace = RelationGetForm(relation)->reltablespace;