Fix the RTE_NAMEDTUPLESTORE case in get_rte_attribute_is_dropped().
authorKevin Grittner <kgrittn@postgresql.org>
Thu, 6 Apr 2017 22:32:53 +0000 (17:32 -0500)
committerKevin Grittner <kgrittn@postgresql.org>
Thu, 6 Apr 2017 22:32:53 +0000 (17:32 -0500)
Problems pointed out by Andres Freund and Thomas Munro.

src/backend/parser/parse_relation.c

index 7db13f37f729511cd73381be257871b54ba9572b..062b8a1d22efaac9da29ededc5808a058a53920e 100644 (file)
@@ -2891,12 +2891,12 @@ get_rte_attribute_is_dropped(RangeTblEntry *rte, AttrNumber attnum)
                Assert(rte->enrname);
 
                /*
-                * We checked when we loaded ctecoltypes for the tuplestore
-                * that InvalidOid was only used for dropped columns, so it is
-                * safe to count on that here.
+                * We checked when we loaded coltypes for the tuplestore that
+                * InvalidOid was only used for dropped columns, so it is safe
+                * to count on that here.
                 */
                result =
-                   (list_nth(rte->coltypes, attnum - 1) != InvalidOid);
+                   ((list_nth_oid(rte->coltypes, attnum - 1) == InvalidOid));
            }
            break;
        case RTE_JOIN: