diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 63aecb0..1347869 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -602,6 +602,7 @@ pg_get_triggerdef(PG_FUNCTION_ARGS) * In the extended version, there is a colno argument as well as pretty bool. * if colno == 0, we want a complete index definition. * if colno > 0, we only want the Nth index key's variable or expression. + * if colno == -999, we only want the name of the variables that make up the index * * Note that the SQL-function versions of this omit any info about the * index tablespace; this is intentional because pg_dump wants it that way. @@ -763,8 +764,10 @@ pg_get_indexdef_worker(Oid indexrelid, int colno, bool showTblSpc, char *attname; attname = get_relid_attribute_name(indrelid, attnum); - if (!colno || colno == keyno + 1) + if (!colno || colno == keyno + 1 || colno == -999) appendStringInfoString(&buf, quote_identifier(attname)); + if (colno == -999 && keyno < idxrec->indnatts-1 ) + appendStringInfoString(&buf, sep); keycoltype = get_atttype(indrelid, attnum); } else diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 709e10e..c3fd222 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -2123,8 +2123,12 @@ listTables(const char *tabtypes, const char *pattern, bool verbose, bool showSys if (showIndexes) appendPQExpBuffer(&buf, - ",\n c2.relname as \"%s\"", - gettext_noop("Table")); + ",\n c2.relname as \"%s\"" + ",\n am.amname as \"%s\"" + ",\n COALESCE(pg_get_expr(i.indexprs,i.indrelid),pg_get_indexdef(i.indexrelid,-999,TRUE)) as \"%s\"", + gettext_noop("Table"), + gettext_noop("Method"), + gettext_noop("Expression")); if (verbose && pset.sversion >= 80100) appendPQExpBuffer(&buf, @@ -2141,7 +2145,9 @@ listTables(const char *tabtypes, const char *pattern, bool verbose, bool showSys if (showIndexes) appendPQExpBuffer(&buf, "\n LEFT JOIN pg_catalog.pg_index i ON i.indexrelid = c.oid" - "\n LEFT JOIN pg_catalog.pg_class c2 ON i.indrelid = c2.oid"); + "\n LEFT JOIN pg_catalog.pg_class c2 ON i.indrelid = c2.oid" + "\n LEFT JOIN pg_catalog.pg_am am ON am.oid = c.relam" + ); appendPQExpBuffer(&buf, "\nWHERE c.relkind IN ("); if (showTables)