On 08/30/2017 02:26 PM, Alexander Korotkov wrote: > Patch rebased to current master is attached.
Hello, I reviewed this patch. It works as expected but I have few remarks : * There is a warning during compilation : gram.y: In function ‘base_yyparse’: gram.y:2090:6: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] AlterTableCmd *n = makeNode(AlterTableCmd); ^~~~~~~~~~~~~ If I understand we should declare AlterTableCmd *n [...] before "if"? * I propose to add "Stats target" information in psql verbose output command \d+ (patch attached with test) \d+ tmp_idx Index "public.tmp_idx" Column | Type | Definition | Storage | Stats target --------+------------------+------------+---------+-------------- a | integer | a | plain | expr | double precision | (d + e) | plain | 1000 b | cstring | b | plain | btree, for table "public.tmp" * psql completion is missing (added to previous patch) Regards, -- Adrien NAYRAT http://dalibo.com - http://dalibo.org
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index f6049cc9e5..6fb9bdd063 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -1742,6 +1742,7 @@ describeOneTableDetails(const char *schemaname, { headers[cols++] = gettext_noop("Storage"); if (tableinfo.relkind == RELKIND_RELATION || + tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_MATVIEW || tableinfo.relkind == RELKIND_FOREIGN_TABLE || tableinfo.relkind == RELKIND_PARTITIONED_TABLE) @@ -1841,6 +1842,7 @@ describeOneTableDetails(const char *schemaname, /* Statistics target, if the relkind supports this feature */ if (tableinfo.relkind == RELKIND_RELATION || + tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_MATVIEW || tableinfo.relkind == RELKIND_FOREIGN_TABLE || tableinfo.relkind == RELKIND_PARTITIONED_TABLE) diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 1583cfa998..baa739a8c0 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -1644,7 +1644,10 @@ psql_completion(const char *text, int start, int end) "UNION SELECT 'ALL IN TABLESPACE'"); /* ALTER INDEX <name> */ else if (Matches3("ALTER", "INDEX", MatchAny)) - COMPLETE_WITH_LIST4("OWNER TO", "RENAME TO", "SET", "RESET"); + COMPLETE_WITH_LIST5("ALTER COLUMN", "OWNER TO", "RENAME TO", "SET", "RESET"); + /* ALTER INDEX <name> ALTER COLUMN <colnum> */ + else if (Matches6("ALTER", "INDEX", MatchAny, "ALTER", "COLUMN", MatchAny)) + COMPLETE_WITH_CONST("SET STATISTICS"); /* ALTER INDEX <name> SET */ else if (Matches4("ALTER", "INDEX", MatchAny, "SET")) COMPLETE_WITH_LIST2("(", "TABLESPACE"); diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out index 64160a8b4d..0f36423163 100644 --- a/src/test/regress/expected/alter_table.out +++ b/src/test/regress/expected/alter_table.out @@ -103,6 +103,15 @@ ALTER INDEX tmp_idx ALTER COLUMN 1 SET STATISTICS 1000; ERROR: cannot alter statistics on non-expression column "a" of index "tmp_idx" HINT: Alter statistics on table column instead. ALTER INDEX tmp_idx ALTER COLUMN 2 SET STATISTICS 1000; +\d+ tmp_idx + Index "public.tmp_idx" + Column | Type | Definition | Storage | Stats target +--------+------------------+------------+---------+-------------- + a | integer | a | plain | + expr | double precision | (d + e) | plain | 1000 + b | cstring | b | plain | +btree, for table "public.tmp" + ALTER INDEX tmp_idx ALTER COLUMN 3 SET STATISTICS 1000; ERROR: cannot alter statistics on non-expression column "b" of index "tmp_idx" HINT: Alter statistics on table column instead. diff --git a/src/test/regress/expected/create_index.out b/src/test/regress/expected/create_index.out index 064adb4640..8450f2463e 100644 --- a/src/test/regress/expected/create_index.out +++ b/src/test/regress/expected/create_index.out @@ -2324,10 +2324,10 @@ DROP TABLE array_gin_test; CREATE INDEX gin_relopts_test ON array_index_op_test USING gin (i) WITH (FASTUPDATE=on, GIN_PENDING_LIST_LIMIT=128); \d+ gin_relopts_test - Index "public.gin_relopts_test" - Column | Type | Definition | Storage ---------+---------+------------+--------- - i | integer | i | plain + Index "public.gin_relopts_test" + Column | Type | Definition | Storage | Stats target +--------+---------+------------+---------+-------------- + i | integer | i | plain | gin, for table "public.array_index_op_test" Options: fastupdate=on, gin_pending_list_limit=128 diff --git a/src/test/regress/sql/alter_table.sql b/src/test/regress/sql/alter_table.sql index 57f44c445d..e6f6669880 100644 --- a/src/test/regress/sql/alter_table.sql +++ b/src/test/regress/sql/alter_table.sql @@ -150,6 +150,8 @@ ALTER INDEX tmp_idx ALTER COLUMN 1 SET STATISTICS 1000; ALTER INDEX tmp_idx ALTER COLUMN 2 SET STATISTICS 1000; +\d+ tmp_idx + ALTER INDEX tmp_idx ALTER COLUMN 3 SET STATISTICS 1000; ALTER INDEX tmp_idx ALTER COLUMN 4 SET STATISTICS 1000;
signature.asc
Description: OpenPGP digital signature