diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c new file mode 100644 index 9b6b9c2..bd2519c *** a/src/bin/psql/describe.c --- b/src/bin/psql/describe.c *************** describeOneTableDetails(const char *sche *** 1149,1154 **** --- 1149,1155 ---- char *reloptions; char *reloftype; char relpersistence; + bool updatable; } tableinfo; bool show_modifiers = false; bool retval; *************** describeOneTableDetails(const char *sche *** 1164,1170 **** initPQExpBuffer(&tmpbuf); /* Get general table info */ ! if (pset.sversion >= 90100) { printfPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " --- 1165,1189 ---- initPQExpBuffer(&tmpbuf); /* Get general table info */ ! if (pset.sversion >= 90300) ! { ! printfPQExpBuffer(&buf, ! "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " ! "c.relhastriggers, c.relhasoids, " ! "%s, c.reltablespace, " ! "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " ! "c.relpersistence, " ! "c.relkind = 'r' OR (c.relkind IN ('f', 'v') AND pg_catalog.pg_relation_is_updatable(c.oid, true) <> 0)\n" ! "FROM pg_catalog.pg_class c\n " ! "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" ! "WHERE c.oid = '%s';", ! (verbose ? ! "pg_catalog.array_to_string(c.reloptions || " ! "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" ! : "''"), ! oid); ! } ! else if (pset.sversion >= 90100) { printfPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " *************** describeOneTableDetails(const char *sche *** 1269,1274 **** --- 1288,1295 ---- pg_strdup(PQgetvalue(res, 0, 8)) : NULL; tableinfo.relpersistence = (pset.sversion >= 90100) ? *(PQgetvalue(res, 0, 9)) : 0; + tableinfo.updatable = (pset.sversion >= 90300) ? + strcmp(PQgetvalue(res, 0, 10), "t") == 0 : false; PQclear(res); res = NULL; *************** describeOneTableDetails(const char *sche *** 2291,2296 **** --- 2312,2331 ---- printTableAddFooter(&cont, buf.data); } + /* + * starting from 9.3, foreign tables may be updatable and views may be + * auto-updatable (in addition to being updatable using rules or triggers). + */ + if (verbose && pset.sversion >= 90300 && + (tableinfo.relkind == 'f' || tableinfo.relkind == 'v')) + { + const char *s = _("Updatable"); + + printfPQExpBuffer(&buf, "%s: %s", s, + (tableinfo.updatable ? _("yes") : _("no"))); + printTableAddFooter(&cont, buf.data); + } + printTable(&cont, pset.queryFout, pset.logfile); printTableCleanup(&cont);