On Thu, Mar 27, 2014 at 02:54:26PM -0400, Stephen Frost wrote: > * Euler Taveira (eu...@timbira.com.br) wrote: > > On 27-03-2014 10:15, Bruce Momjian wrote: > > > When we made OIDs optional, we added an oid status display to \d+: > > > > > > test=> \d+ test > > > Table "public.test" > > > Column | Type | Modifiers | Storage | Stats target | Description > > > --------+---------+-----------+---------+--------------+------------- > > > x | integer | | plain | | > > > --> Has OIDs: no > > > > > > Do we want to continue displaying that OID line, or make it optional for > > > cases where the value doesn't match default_with_oids? > > > > > That line is still important for those tables that have oids. Once a > > while I see "with oids" set (mainly by mistake or misinformation). > > I believe Bruce was suggesting to show it when it is set to *not* the > default, which strikes me as perfectly reasonable.
We seem to be split on the idea of having "Has OIDs" display only when the oid status of the table does not match the default_with_oids default. I am attaching a patch which implements this, but given no consensus, I will not apply it unless we can be more definite. My motivation was that "Has OIDs" was important when we stopped having an oid column by default, but at this point many users don't even know what OIDs are and the line is potentially confusing and mostly useless. -- Bruce Momjian <br...@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com + Everyone has their own god. +
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c new file mode 100644 index 21bbdf8..367cb97 *** a/src/bin/psql/describe.c --- b/src/bin/psql/describe.c *************** describeOneTableDetails(const char *sche *** 1169,1174 **** --- 1169,1175 ---- bool hasrules; bool hastriggers; bool hasoids; + bool default_with_oids; Oid tablespace; char *reloptions; char *reloftype; *************** describeOneTableDetails(const char *sche *** 1194,1199 **** --- 1195,1201 ---- printfPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " "c.relhastriggers, c.relhasoids, " + "(SELECT setting FROM pg_settings WHERE name = 'default_with_oids') AS default_with_oids, " "%s, c.reltablespace, " "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " "c.relpersistence, c.relreplident\n" *************** describeOneTableDetails(const char *sche *** 1211,1216 **** --- 1213,1219 ---- printfPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " "c.relhastriggers, c.relhasoids, " + "(SELECT setting FROM pg_settings WHERE name = 'default_with_oids') AS default_with_oids, " "%s, c.reltablespace, " "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " "c.relpersistence\n" *************** describeOneTableDetails(const char *sche *** 1228,1233 **** --- 1231,1237 ---- printfPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " "c.relhastriggers, c.relhasoids, " + "(SELECT setting FROM pg_settings WHERE name = 'default_with_oids') AS default_with_oids, " "%s, c.reltablespace, " "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END\n" "FROM pg_catalog.pg_class c\n " *************** describeOneTableDetails(const char *sche *** 1244,1249 **** --- 1248,1254 ---- printfPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " "c.relhastriggers, c.relhasoids, " + "(SELECT setting FROM pg_settings WHERE name = 'default_with_oids') AS default_with_oids, " "%s, c.reltablespace\n" "FROM pg_catalog.pg_class c\n " "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" *************** describeOneTableDetails(const char *sche *** 1259,1264 **** --- 1264,1270 ---- printfPQExpBuffer(&buf, "SELECT relchecks, relkind, relhasindex, relhasrules, " "reltriggers <> 0, relhasoids, " + "(SELECT setting FROM pg_settings WHERE name = 'default_with_oids') AS default_with_oids, " "%s, reltablespace\n" "FROM pg_catalog.pg_class WHERE oid = '%s';", (verbose ? *************** describeOneTableDetails(const char *sche *** 1270,1275 **** --- 1276,1282 ---- printfPQExpBuffer(&buf, "SELECT relchecks, relkind, relhasindex, relhasrules, " "reltriggers <> 0, relhasoids, " + "(SELECT setting FROM pg_settings WHERE name = 'default_with_oids') AS default_with_oids, " "'', reltablespace\n" "FROM pg_catalog.pg_class WHERE oid = '%s';", oid); *************** describeOneTableDetails(const char *sche *** 1279,1284 **** --- 1286,1292 ---- printfPQExpBuffer(&buf, "SELECT relchecks, relkind, relhasindex, relhasrules, " "reltriggers <> 0, relhasoids, " + "(SELECT setting FROM pg_settings WHERE name = 'default_with_oids') AS default_with_oids, " "'', ''\n" "FROM pg_catalog.pg_class WHERE oid = '%s';", oid); *************** describeOneTableDetails(const char *sche *** 1302,1318 **** tableinfo.hasrules = strcmp(PQgetvalue(res, 0, 3), "t") == 0; tableinfo.hastriggers = strcmp(PQgetvalue(res, 0, 4), "t") == 0; tableinfo.hasoids = strcmp(PQgetvalue(res, 0, 5), "t") == 0; tableinfo.reloptions = (pset.sversion >= 80200) ? ! pg_strdup(PQgetvalue(res, 0, 6)) : NULL; tableinfo.tablespace = (pset.sversion >= 80000) ? ! atooid(PQgetvalue(res, 0, 7)) : 0; tableinfo.reloftype = (pset.sversion >= 90000 && ! strcmp(PQgetvalue(res, 0, 8), "") != 0) ? ! pg_strdup(PQgetvalue(res, 0, 8)) : NULL; tableinfo.relpersistence = (pset.sversion >= 90100) ? ! *(PQgetvalue(res, 0, 9)) : 0; tableinfo.relreplident = (pset.sversion >= 90400) ? ! *(PQgetvalue(res, 0, 10)) : 'd'; PQclear(res); res = NULL; --- 1310,1327 ---- tableinfo.hasrules = strcmp(PQgetvalue(res, 0, 3), "t") == 0; tableinfo.hastriggers = strcmp(PQgetvalue(res, 0, 4), "t") == 0; tableinfo.hasoids = strcmp(PQgetvalue(res, 0, 5), "t") == 0; + tableinfo.default_with_oids = strcmp(PQgetvalue(res, 0, 6), "t") == 0; tableinfo.reloptions = (pset.sversion >= 80200) ? ! pg_strdup(PQgetvalue(res, 0, 7)) : NULL; tableinfo.tablespace = (pset.sversion >= 80000) ? ! atooid(PQgetvalue(res, 0, 8)) : 0; tableinfo.reloftype = (pset.sversion >= 90000 && ! strcmp(PQgetvalue(res, 0, 9), "") != 0) ? ! pg_strdup(PQgetvalue(res, 0, 9)) : NULL; tableinfo.relpersistence = (pset.sversion >= 90100) ? ! *(PQgetvalue(res, 0, 10)) : 0; tableinfo.relreplident = (pset.sversion >= 90400) ? ! *(PQgetvalue(res, 0, 11)) : 'd'; PQclear(res); res = NULL; *************** describeOneTableDetails(const char *sche *** 2362,2368 **** } /* OIDs, if verbose and not a materialized view */ ! if (verbose && tableinfo.relkind != 'm') { const char *s = _("Has OIDs"); --- 2371,2378 ---- } /* OIDs, if verbose and not a materialized view */ ! if (verbose && tableinfo.relkind != 'm' && ! tableinfo.hasoids != tableinfo.default_with_oids) { const char *s = _("Has OIDs");
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers