make pg_dump work on 9.6 by adding columns to getTables()
authorTomas Vondra <[email protected]>
Tue, 10 Jan 2017 19:06:32 +0000 (20:06 +0100)
committerTomas Vondra <[email protected]>
Tue, 10 Jan 2017 19:10:32 +0000 (20:10 +0100)
The 9.6 if-branch in getTables() was missing XL-specific columns,
namely pgxclocatortype, pgxcattnum and pgxc_node_names, resulting
in strange errors like this:

    pg_dump: column number -1 is out of range 0..33
    pg_dump: column number -1 is out of range 0..33
    cannot duplicate null pointer (internal error)

After adding the columns, everything seems to be working fine.

src/bin/pg_dump/pg_dump.c

index 06695f89342b0fd5ebd05d6fb72dabd85581be00..83c25234089bcb936d0d3f915adb35e29191f4e3 100644 (file)
@@ -5293,6 +5293,11 @@ getTables(Archive *fout, int *numTables)
                                                  "d.refobjid AS owning_tab, "
                                                  "d.refobjsubid AS owning_col, "
                                                  "(SELECT spcname FROM pg_tablespace t WHERE t.oid = c.reltablespace) AS reltablespace, "
+#ifdef PGXC
+                                                 "(SELECT pclocatortype from pgxc_class v where v.pcrelid = c.oid) AS pgxclocatortype,"
+                                                 "(SELECT pcattnum from pgxc_class v where v.pcrelid = c.oid) AS pgxcattnum,"
+                                                 "(SELECT string_agg(node_name,',') AS pgxc_node_names from pgxc_node n where n.oid in (select unnest(nodeoids) from pgxc_class v where v.pcrelid=c.oid) ) , "
+#endif
                                                  "array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
                                                  "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
                                                  "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, "