]> granicus.if.org Git - postgresql/commitdiff
psql: have \d show FKs on partitioned tables
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Mon, 14 May 2018 15:43:14 +0000 (11:43 -0400)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Mon, 14 May 2018 16:14:17 +0000 (12:14 -0400)
Commit 3de241dba86f missed to update psql to display foreign keys on
partitioned tables.  Add that.

Reported-by: Amit Langote
Author: Amit Langote
Reviewed-by: Álvaro Herrera
Discussion: https://postgr.es/m/a66879e5-636f-d4dd-b4a4-92bdca5a828f@lab.ntt.co.jp

src/bin/psql/describe.c

index 410131e5c726fdde229fe39c1941d4353a64dc9c..e5b3c1ebf9a6962c0a807adb1021636938665dac 100644 (file)
@@ -2311,8 +2311,13 @@ describeOneTableDetails(const char *schemaname,
                        PQclear(result);
                }
 
-               /* print foreign-key constraints (there are none if no triggers) */
-               if (tableinfo.hastriggers)
+               /*
+                * Print foreign-key constraints (there are none if no triggers,
+                * except if the table is partitioned, in which case the triggers
+                * appear in the partitions)
+                */
+               if (tableinfo.hastriggers ||
+                       tableinfo.relkind == RELKIND_PARTITIONED_TABLE)
                {
                        printfPQExpBuffer(&buf,
                                                          "SELECT conname,\n"