sequence_owned_by.patch
text/x-patch
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
| File | + | − |
|---|---|---|
| src/bin/psql/describe.c | 37 | 0 |
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index d5466f8..746f18e 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -1609,6 +1609,43 @@ describeOneTableDetails(const char *schemaname,
PQclear(result);
}
}
+ else if (tableinfo.relkind == 'S')
+ {
+ /* Footer information about a sequence */
+ PGresult *result = NULL;
+
+ /* Get the column that owns this sequence */
+ printfPQExpBuffer(&buf, "SELECT quote_ident(nspname) || '.' ||"
+ "\n quote_ident(relname) || '.' ||"
+ "\n quote_ident(attname)"
+ "\nFROM pg_catalog.pg_class"
+ "\nINNER JOIN pg_catalog.pg_depend ON pg_class.oid=pg_depend.refobjid"
+ "\nINNER JOIN pg_catalog.pg_namespace ON pg_namespace.oid=pg_class.relnamespace"
+ "\nINNER JOIN pg_catalog.pg_attribute ON ("
+ "\n pg_attribute.attrelid=pg_class.oid AND"
+ "\n pg_attribute.attnum=pg_depend.refobjsubid)"
+ "\nWHERE classid='pg_catalog.pg_class'::regclass"
+ "\n AND refclassid='pg_catalog.pg_class'::regclass"
+ "\n AND objid=%s"
+ "\n AND deptype='a'",
+ oid);
+
+ result = PSQLexec(buf.data, false);
+ if (!result)
+ goto error_return;
+ else if (PQntuples(result) == 1)
+ {
+ printfPQExpBuffer(&buf, _("Owned by: %s"),
+ PQgetvalue(result, 0, 0));
+ printTableAddFooter(&cont, buf.data);
+ }
+ /*
+ * If we get no rows back, don't show anything (obviously).
+ * We should never get more than one row back, but if we do,
+ * just ignore it and don't print anything.
+ */
+ PQclear(result);
+ }
else if (tableinfo.relkind == 'r' || tableinfo.relkind == 'f')
{
/* Footer information about a table */