Make \d order a table's check constraints by constraint name instead
authorTom Lane <[email protected]>
Thu, 20 Oct 2005 05:15:09 +0000 (05:15 +0000)
committerTom Lane <[email protected]>
Thu, 20 Oct 2005 05:15:09 +0000 (05:15 +0000)
of the text of the constraint condition.  Per Chris K-L, though I didn't
use his patch exactly.

src/bin/psql/describe.c

index 8735ded23522da5453b8e741fe8d08dbe10f9125..96ab5e50e4e47d4dee4e94423d8b87b33d99a6bf 100644 (file)
@@ -1036,9 +1036,8 @@ describeOneTableDetails(const char *schemaname,
                if (tableinfo.checks)
                {
                        printfPQExpBuffer(&buf,
-                                                         "SELECT "
-                                                         "pg_catalog.pg_get_constraintdef(r.oid, true), "
-                                                         "conname\n"
+                                                         "SELECT r.conname, "
+                                                         "pg_catalog.pg_get_constraintdef(r.oid, true)\n"
                                                          "FROM pg_catalog.pg_constraint r\n"
                                        "WHERE r.conrelid = '%s' AND r.contype = 'c' ORDER BY 1",
                                                          oid);
@@ -1192,8 +1191,8 @@ describeOneTableDetails(const char *schemaname,
                        for (i = 0; i < check_count; i++)
                        {
                                printfPQExpBuffer(&buf, _("    \"%s\" %s"),
-                                                                 PQgetvalue(result2, i, 1),
-                                                                 PQgetvalue(result2, i, 0));
+                                                                 PQgetvalue(result2, i, 0),
+                                                                 PQgetvalue(result2, i, 1));
 
                                footers[count_footers++] = pg_strdup(buf.data);
                        }