diff options
| author | Tom Lane | 2012-04-06 19:02:35 +0000 |
|---|---|---|
| committer | Tom Lane | 2012-04-06 19:02:35 +0000 |
| commit | 263d9de66b867b7800fac82c222e004b795b724a (patch) | |
| tree | 4ecc70b6e75339304b2829a2ced3cb084f0aacdb /src/test | |
| parent | 8cb53654dbdb4c386369eb988062d0bbb6de725e (diff) | |
Allow statistics to be collected for foreign tables.
ANALYZE now accepts foreign tables and allows the table's FDW to control
how the sample rows are collected. (But only manual ANALYZEs will touch
foreign tables, for the moment, since among other things it's not very
clear how to handle remote permissions checks in an auto-analyze.)
contrib/file_fdw is extended to support this.
Etsuro Fujita, reviewed by Shigeru Hanada, some further tweaking by me.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/foreign_data.out | 39 | ||||
| -rw-r--r-- | src/test/regress/sql/foreign_data.sql | 3 |
2 files changed, 24 insertions, 18 deletions
diff --git a/src/test/regress/expected/foreign_data.out b/src/test/regress/expected/foreign_data.out index ba86883b867..b3165d59014 100644 --- a/src/test/regress/expected/foreign_data.out +++ b/src/test/regress/expected/foreign_data.out @@ -679,12 +679,12 @@ CREATE FOREIGN TABLE ft1 ( COMMENT ON FOREIGN TABLE ft1 IS 'ft1'; COMMENT ON COLUMN ft1.c1 IS 'ft1.c1'; \d+ ft1 - Foreign table "public.ft1" - Column | Type | Modifiers | FDW Options | Storage | Description ---------+---------+-----------+--------------------------------+----------+------------- - c1 | integer | not null | ("param 1" 'val1') | plain | ft1.c1 - c2 | text | | (param2 'val2', param3 'val3') | extended | - c3 | date | | | plain | + Foreign table "public.ft1" + Column | Type | Modifiers | FDW Options | Storage | Stats target | Description +--------+---------+-----------+--------------------------------+----------+--------------+------------- + c1 | integer | not null | ("param 1" 'val1') | plain | | ft1.c1 + c2 | text | | (param2 'val2', param3 'val3') | extended | | + c3 | date | | | plain | | Server: s0 FDW Options: (delimiter ',', quote '"', "be quoted" 'value') Has OIDs: no @@ -730,19 +730,22 @@ ERROR: cannot alter system column "xmin" ALTER FOREIGN TABLE ft1 ALTER COLUMN c7 OPTIONS (ADD p1 'v1', ADD p2 'v2'), ALTER COLUMN c8 OPTIONS (ADD p1 'v1', ADD p2 'v2'); ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 OPTIONS (SET p2 'V2', DROP p1); +ALTER FOREIGN TABLE ft1 ALTER COLUMN c1 SET STATISTICS 10000; +ALTER FOREIGN TABLE ft1 ALTER COLUMN c1 SET (n_distinct = 100); +ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 SET STATISTICS -1; \d+ ft1 - Foreign table "public.ft1" - Column | Type | Modifiers | FDW Options | Storage | Description ---------+---------+-----------+--------------------------------+----------+------------- - c1 | integer | not null | ("param 1" 'val1') | plain | - c2 | text | | (param2 'val2', param3 'val3') | extended | - c3 | date | | | plain | - c4 | integer | | | plain | - c6 | integer | not null | | plain | - c7 | integer | | (p1 'v1', p2 'v2') | plain | - c8 | text | | (p2 'V2') | extended | - c9 | integer | | | plain | - c10 | integer | | (p1 'v1') | plain | + Foreign table "public.ft1" + Column | Type | Modifiers | FDW Options | Storage | Stats target | Description +--------+---------+-----------+--------------------------------+----------+--------------+------------- + c1 | integer | not null | ("param 1" 'val1') | plain | 10000 | + c2 | text | | (param2 'val2', param3 'val3') | extended | | + c3 | date | | | plain | | + c4 | integer | | | plain | | + c6 | integer | not null | | plain | | + c7 | integer | | (p1 'v1', p2 'v2') | plain | | + c8 | text | | (p2 'V2') | extended | | + c9 | integer | | | plain | | + c10 | integer | | (p1 'v1') | plain | | Server: s0 FDW Options: (delimiter ',', quote '"', "be quoted" 'value') Has OIDs: no diff --git a/src/test/regress/sql/foreign_data.sql b/src/test/regress/sql/foreign_data.sql index 0c956727deb..4137969e7de 100644 --- a/src/test/regress/sql/foreign_data.sql +++ b/src/test/regress/sql/foreign_data.sql @@ -307,6 +307,9 @@ ALTER FOREIGN TABLE ft1 ALTER COLUMN xmin OPTIONS (ADD p1 'v1'); -- ERROR ALTER FOREIGN TABLE ft1 ALTER COLUMN c7 OPTIONS (ADD p1 'v1', ADD p2 'v2'), ALTER COLUMN c8 OPTIONS (ADD p1 'v1', ADD p2 'v2'); ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 OPTIONS (SET p2 'V2', DROP p1); +ALTER FOREIGN TABLE ft1 ALTER COLUMN c1 SET STATISTICS 10000; +ALTER FOREIGN TABLE ft1 ALTER COLUMN c1 SET (n_distinct = 100); +ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 SET STATISTICS -1; \d+ ft1 -- can't change the column type if it's used elsewhere CREATE TABLE use_ft1_column_type (x ft1); |
