diff options
| author | Simon Riggs | 2017-09-06 20:46:01 +0000 |
|---|---|---|
| committer | Simon Riggs | 2017-09-06 20:46:01 +0000 |
| commit | 5b6d13eec72b960eb0f78542199380e49c8583d4 (patch) | |
| tree | 8893caeb77015bb2502f3795954b6f59b5b04305 /src/test | |
| parent | e09db94c0a5f3b440d96c5c9e8e6c1638d1ec39f (diff) | |
Allow SET STATISTICS on expression indexes
Index columns are referenced by ordinal number rather than name, e.g.
CREATE INDEX coord_idx ON measured (x, y, (z + t));
ALTER INDEX coord_idx ALTER COLUMN 3 SET STATISTICS 1000;
Incompatibility note for release notes:
\d+ for indexes now also displays Stats Target
Authors: Alexander Korotkov, with contribution by Adrien NAYRAT
Review: Adrien NAYRAT, Simon Riggs
Wordsmith: Simon Riggs
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/alter_table.out | 24 | ||||
| -rw-r--r-- | src/test/regress/expected/create_index.out | 8 | ||||
| -rw-r--r-- | src/test/regress/sql/alter_table.sql | 16 |
3 files changed, 44 insertions, 4 deletions
diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out index ed03cb9c630..0f364231635 100644 --- a/src/test/regress/expected/alter_table.out +++ b/src/test/regress/expected/alter_table.out @@ -94,6 +94,30 @@ SELECT * FROM tmp; | 4 | name | text | 4.1 | 4.1 | 2 | ((4.1,4.1),(3.1,3.1)) | Mon May 01 00:30:30 1995 PDT | c | {"Mon May 01 00:30:30 1995 PDT","Mon Aug 24 14:43:07 1992 PDT","Wed Dec 31 16:00:00 1969 PST"} | 314159 | (1,1) | 512 | 1 2 3 4 5 6 7 8 | magnetic disk | (1.1,1.1) | [(4.1,4.1),(3.1,3.1)] | ((0,2),(4.1,4.1),(3.1,3.1)) | (4.1,4.1),(3.1,3.1) | ["Wed Dec 31 16:00:00 1969 PST" "infinity"] | Thu Jan 01 00:00:00 1970 | @ 1 hour 10 secs | {1,2,3,4} | {1,2,3,4} | {1,2,3,4} (1 row) +CREATE INDEX tmp_idx ON tmp (a, (d + e), b); +ALTER INDEX tmp_idx ALTER COLUMN 0 SET STATISTICS 1000; +ERROR: column number must be in range from 1 to 32767 +LINE 1: ALTER INDEX tmp_idx ALTER COLUMN 0 SET STATISTICS 1000; + ^ +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. +ALTER INDEX tmp_idx ALTER COLUMN 4 SET STATISTICS 1000; +ERROR: column number 4 of relation "tmp_idx" does not exist +ALTER INDEX tmp_idx ALTER COLUMN 2 SET STATISTICS -1; DROP TABLE tmp; -- -- rename - check on both non-temp and temp tables diff --git a/src/test/regress/expected/create_index.out b/src/test/regress/expected/create_index.out index 064adb4640b..8450f2463e8 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 9a20dd141a2..e6f6669880b 100644 --- a/src/test/regress/sql/alter_table.sql +++ b/src/test/regress/sql/alter_table.sql @@ -142,6 +142,22 @@ INSERT INTO tmp (a, b, c, d, e, f, g, h, i, j, k, l, m, n, p, q, r, s, t, u, SELECT * FROM tmp; +CREATE INDEX tmp_idx ON tmp (a, (d + e), b); + +ALTER INDEX tmp_idx ALTER COLUMN 0 SET STATISTICS 1000; + +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; + +ALTER INDEX tmp_idx ALTER COLUMN 2 SET STATISTICS -1; + DROP TABLE tmp; |
