]> granicus.if.org Git - postgresql/commitdiff
Fix another test for RELKIND_RELATION that should allow foreign tables now.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 28 Apr 2015 19:34:35 +0000 (12:34 -0700)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 28 Apr 2015 19:34:35 +0000 (12:34 -0700)
I thought I'd gone through all of these before, but a fresh review found
this one too.  (Perhaps it would be better to just delete this test and
let the failure occur later, but for the moment I'll preserve the logic.)

The case that this was rejecting is like
CREATE FOREIGN TABLE ft (f1 int ...) ...;
CREATE TABLE c1 (UNIQUE(f1)) INHERITS(ft);

src/backend/parser/parse_utilcmd.c

index 73924ae12e6338d87a670be005560f8f2933e94b..0a55db4a82368cdb185ffac07d44fa46741708c8 100644 (file)
@@ -1799,10 +1799,12 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt)
 
                                Assert(IsA(inh, RangeVar));
                                rel = heap_openrv(inh, AccessShareLock);
-                               if (rel->rd_rel->relkind != RELKIND_RELATION)
+                               /* check user requested inheritance from valid relkind */
+                               if (rel->rd_rel->relkind != RELKIND_RELATION &&
+                                       rel->rd_rel->relkind != RELKIND_FOREIGN_TABLE)
                                        ereport(ERROR,
                                                        (errcode(ERRCODE_WRONG_OBJECT_TYPE),
-                                                  errmsg("inherited relation \"%s\" is not a table",
+                                                  errmsg("inherited relation \"%s\" is not a table or foreign table",
                                                                  inh->relname)));
                                for (count = 0; count < rel->rd_att->natts; count++)
                                {