OSDN Git Service

372c40194394781ee97fd26f8c1676aaf5833005
[pgdbmsstats/pg_dbms_stats.git] / output / ut_imp_exp-12.source
1 \pset null '(null)'
2 CREATE TABLE s0.st3();
3 /*
4  * No.16-1 export_plain_stats-12.sql.sample
5  */
6 -- No.16-1-1
7 ANALYZE;
8 DELETE FROM dbms_stats.column_stats_locked;
9 DELETE FROM dbms_stats.relation_stats_locked;
10 SELECT dbms_stats.lock_database_stats();
11  lock_database_stats 
12 ---------------------
13  pt0
14  pt0_idx
15  st0
16  st0_idx
17  st1
18  s0.st0
19  s0.st0_idx
20  s0.st1
21  s0.st1_idx
22  s0.st2
23  s0.st2_idx
24  st1_idx
25  st1_exp
26  s0.sft0
27  s0.smv0
28  s1.st0
29  s0.st3
30 (17 rows)
31
32 UPDATE dbms_stats.relation_stats_locked
33    SET (relpages, reltuples, relallvisible, curpages) = (0,0,0,0);
34 UPDATE dbms_stats.column_stats_locked SET
35     stanullfrac = -staattnum,
36     stawidth = -staattnum,
37     stadistinct = -staattnum,
38     stakind1 = 2,
39     stakind2 = 3,
40     stakind3 = 4,
41     stakind4 = 1,
42     stakind5 = 5,
43     staop1 = 22,
44     staop2 = 23,
45     staop3 = 24,
46     staop4 = 21,
47     staop5 = 25,
48     stacoll1 = 32,
49     stacoll2 = 33,
50     stacoll3 = 34,
51     stacoll4 = 31,
52     stacoll5 = 35,
53     stanumbers1 = ARRAY[-staattnum,22],
54     stanumbers2 = ARRAY[-staattnum,23],
55     stanumbers3 = ARRAY[-staattnum,24],
56     stanumbers4 = ARRAY[-staattnum,21],
57     stanumbers5 = ARRAY[-staattnum,25],
58     stavalues1 = stavalues3,
59     stavalues2 = stavalues2,
60     stavalues3 = stavalues1,
61     stavalues4 = stavalues4,
62     stavalues5 = stavalues5;
63 \i doc/export_plain_stats-12.sql.sample
64 /*
65  * If you want the statistics of per-relation or per-column, please modify
66  * nspname, relname, and attname in 'WHERE' clause.
67  */
68 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
69 /*
70  * If you want to chage the output file name, please modify the following name.
71  */
72 \o export_stats.dmp
73 COPY (SELECT n2.nspname,
74              c.relname,
75              c.relpages,
76              c.reltuples,
77              c.relallvisible,
78              (pg_relation_size(c.oid) / current_setting('block_size')::int4)::int4
79                  AS curpages,
80              pg_catalog.pg_stat_get_last_analyze_time(c.oid)
81                  AS last_analyze,
82              pg_catalog.pg_stat_get_last_autoanalyze_time(c.oid)
83                  AS last_autoanalyze,
84              COALESCE(a.attname, ''),
85              n1.nspname AS schemaname_of_atttype,
86              t.typname,
87              a.atttypmod,
88              s.stainherit,
89              s.stanullfrac,
90              s.stawidth,
91              s.stadistinct,
92              s.stakind1,
93              s.stakind2,
94              s.stakind3,
95              s.stakind4,
96              s.stakind5,
97              s.staop1,
98              s.staop2,
99              s.staop3,
100              s.staop4,
101              s.staop5,
102              s.stacoll1,
103              s.stacoll2,
104              s.stacoll3,
105              s.stacoll4,
106              s.stacoll5,
107              s.stanumbers1,
108              s.stanumbers2,
109              s.stanumbers3,
110              s.stanumbers4,
111              s.stanumbers5,
112              s.stavalues1,
113              s.stavalues2,
114              s.stavalues3,
115              s.stavalues4,
116              s.stavalues5
117         FROM pg_statistic s
118         JOIN pg_attribute a
119           ON (s.starelid = a.attrelid AND s.staattnum = a.attnum)
120         JOIN pg_type t
121           ON a.atttypid = t.oid
122         JOIN pg_namespace n1
123           ON t.typnamespace = n1.oid
124        RIGHT JOIN pg_catalog.pg_class c
125           ON s.starelid = c.oid
126         JOIN pg_catalog.pg_namespace n2
127           ON c.relnamespace = n2.oid
128        WHERE c.relkind IN ('r', 'i', 'f', 'm')
129          AND NOT n2.nspname IN ('pg_catalog',
130                                 'pg_toast',
131                                 'information_schema',
132                                 'dbms_stats')
133         -- AND n2.nspname = 'public'
134         -- AND c.relname = 'test'
135         -- AND a.attname = 'id'
136        ORDER BY starelid, staattnum)
137 TO STDOUT
138 (FORMAT 'binary');
139 \o
140 COMMIT;
141 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
142 SELECT * FROM work_v;
143  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 |      stanumbers1       | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 |       stavalues1       | stavalues2 | stavalues3 | stavalues4 | stavalues5 
144 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+------------------------+-------------+-------------+-------------+-------------+------------------------+------------+------------+------------+------------
145  public  | pt0     |        0 |         0 |             0 |        0 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)                 | (null)      | (null)      | (null)      | (null)      | (null)                 | (null)     | (null)     | (null)     | (null)
146  public  | pt0_idx |        2 |         0 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)                 | (null)      | (null)      | (null)      | (null)      | (null)                 | (null)     | (null)     | (null)     | (null)
147  public  | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)                 | {1}         | (null)      | (null)      | (null)      | {1,2}                  | (null)     | (null)     | (null)     | (null)
148  public  | st0     |        1 |         2 |             1 |        1 | name    | pg_catalog          | bpchar  |         9 | f          |           0 |        6 |        -0.5 |        1 |        3 |        0 |        0 |        0 |   1054 |   1058 |      0 |      0 |      0 | {1}                    | {1}         | (null)      | (null)      | (null)      | {"test "}              | (null)     | (null)     | (null)     | (null)
149  public  | st0_idx |        2 |         2 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)                 | (null)      | (null)      | (null)      | (null)      | (null)                 | (null)     | (null)     | (null)     | (null)
150  public  | st1     |       45 |     10000 |            45 |       45 | str     | pg_catalog          | text    |        -1 | f          |           0 |        2 |           3 |        1 |        3 |        0 |        0 |        0 |     98 |    664 |      0 |      0 |      0 | {0.3334,0.3333,0.3333} | {0.3332}    | (null)      | (null)      | (null)      | {1,0,2}                | (null)     | (null)     | (null)     | (null)
151  public  | st1     |       45 |     10000 |            45 |       45 | val     | pg_catalog          | int4    |        -1 | f          |           0 |        4 |           3 |        1 |        3 |        0 |        0 |        0 |     96 |     97 |      0 |      0 |      0 | {0.3334,0.3333,0.3333} | {0.3332}    | (null)      | (null)      | (null)      | {1,0,2}                | (null)     | (null)     | (null)     | (null)
152  public  | st1_exp |       30 |     10000 |             0 |       30 | lower   | pg_catalog          | text    |        -1 | f          |           0 |        5 |           3 |        1 |        3 |        0 |        0 |        0 |     98 |    664 |      0 |      0 |      0 | {0.3334,0.3333,0.3333} | {0.3332}    | (null)      | (null)      | (null)      | {1,0,2}                | (null)     | (null)     | (null)     | (null)
153  public  | st1_idx |       30 |     10000 |             0 |       30 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)                 | (null)      | (null)      | (null)      | (null)      | (null)                 | (null)     | (null)     | (null)     | (null)
154  s0      | sft0    |        1 |        10 |             0 |        0 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)                 | {1}         | (null)      | (null)      | (null)      | {1,2,3,4,5,6,7,8,9,10} | (null)     | (null)     | (null)     | (null)
155  s0      | smv0    |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)                 | {1}         | (null)      | (null)      | (null)      | {1,2}                  | (null)     | (null)     | (null)     | (null)
156  s0      | smv0    |        1 |         2 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)                 | {1}         | (null)      | (null)      | (null)      | {10,20}                | (null)     | (null)     | (null)     | (null)
157  s0      | smv0    |        1 |         2 |             1 |        1 | txt     | pg_catalog          | text    |        -1 | f          |           0 |        3 |          -1 |        2 |        3 |        0 |        0 |        0 |    664 |    664 |      0 |      0 |      0 | (null)                 | {1}         | (null)      | (null)      | (null)      | {1,test}               | (null)     | (null)     | (null)     | (null)
158  s0      | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)                 | {1}         | (null)      | (null)      | (null)      | {1,2}                  | (null)     | (null)     | (null)     | (null)
159  s0      | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | t          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)                 | {1}         | (null)      | (null)      | (null)      | {1,2,4,5,6}            | (null)     | (null)     | (null)     | (null)
160  s0      | st0     |        1 |         2 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)                 | {1}         | (null)      | (null)      | (null)      | {10,20}                | (null)     | (null)     | (null)     | (null)
161  s0      | st0     |        1 |         2 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | t          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)                 | {1}         | (null)      | (null)      | (null)      | {10,20,40,50,60}       | (null)     | (null)     | (null)     | (null)
162  s0      | st0_idx |        2 |         2 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)                 | (null)      | (null)      | (null)      | (null)      | (null)                 | (null)     | (null)     | (null)     | (null)
163  s0      | st1     |        1 |         3 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)                 | {1}         | (null)      | (null)      | (null)      | {4,5,6}                | (null)     | (null)     | (null)     | (null)
164  s0      | st1     |        1 |         3 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)                 | {1}         | (null)      | (null)      | (null)      | {40,50,60}             | (null)     | (null)     | (null)     | (null)
165  s0      | st1_idx |        2 |         3 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)                 | (null)      | (null)      | (null)      | (null)      | (null)                 | (null)     | (null)     | (null)     | (null)
166  s0      | st2     |        1 |         3 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)                 | {1}         | (null)      | (null)      | (null)      | {1,2,3}                | (null)     | (null)     | (null)     | (null)
167  s0      | st2     |        1 |         3 |             1 |        1 | txt     | pg_catalog          | text    |        -1 | f          |           0 |        5 |          -1 |        2 |        3 |        0 |        0 |        0 |    664 |    664 |      0 |      0 |      0 | (null)                 | {0.5}       | (null)      | (null)      | (null)      | {1,comment,test}       | (null)     | (null)     | (null)     | (null)
168  s0      | st2_idx |        2 |         3 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)                 | (null)      | (null)      | (null)      | (null)      | (null)                 | (null)     | (null)     | (null)     | (null)
169  s0      | st3     |        0 |         0 |             0 |        0 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)                 | (null)      | (null)      | (null)      | (null)      | (null)                 | (null)     | (null)     | (null)     | (null)
170  s1      | st0     |        1 |         4 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)                 | {1}         | (null)      | (null)      | (null)      | {1,2,3,4}              | (null)     | (null)     | (null)     | (null)
171  s1      | st0     |        1 |         4 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)                 | {1}         | (null)      | (null)      | (null)      | {15,25,35,45}          | (null)     | (null)     | (null)     | (null)
172 (27 rows)
173
174 TRUNCATE dbms_stats.work;
175 -- No.16-1-2
176 \! sed '/ORDER/i\\ AND n2.nspname = '"\'s0\'" doc/export_plain_stats-12.sql.sample > doc/export_plain_stats-12.sql.sample_test
177 \i doc/export_plain_stats-12.sql.sample_test
178 /*
179  * If you want the statistics of per-relation or per-column, please modify
180  * nspname, relname, and attname in 'WHERE' clause.
181  */
182 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
183 /*
184  * If you want to chage the output file name, please modify the following name.
185  */
186 \o export_stats.dmp
187 COPY (SELECT n2.nspname,
188              c.relname,
189              c.relpages,
190              c.reltuples,
191              c.relallvisible,
192              (pg_relation_size(c.oid) / current_setting('block_size')::int4)::int4
193                  AS curpages,
194              pg_catalog.pg_stat_get_last_analyze_time(c.oid)
195                  AS last_analyze,
196              pg_catalog.pg_stat_get_last_autoanalyze_time(c.oid)
197                  AS last_autoanalyze,
198              COALESCE(a.attname, ''),
199              n1.nspname AS schemaname_of_atttype,
200              t.typname,
201              a.atttypmod,
202              s.stainherit,
203              s.stanullfrac,
204              s.stawidth,
205              s.stadistinct,
206              s.stakind1,
207              s.stakind2,
208              s.stakind3,
209              s.stakind4,
210              s.stakind5,
211              s.staop1,
212              s.staop2,
213              s.staop3,
214              s.staop4,
215              s.staop5,
216              s.stacoll1,
217              s.stacoll2,
218              s.stacoll3,
219              s.stacoll4,
220              s.stacoll5,
221              s.stanumbers1,
222              s.stanumbers2,
223              s.stanumbers3,
224              s.stanumbers4,
225              s.stanumbers5,
226              s.stavalues1,
227              s.stavalues2,
228              s.stavalues3,
229              s.stavalues4,
230              s.stavalues5
231         FROM pg_statistic s
232         JOIN pg_attribute a
233           ON (s.starelid = a.attrelid AND s.staattnum = a.attnum)
234         JOIN pg_type t
235           ON a.atttypid = t.oid
236         JOIN pg_namespace n1
237           ON t.typnamespace = n1.oid
238        RIGHT JOIN pg_catalog.pg_class c
239           ON s.starelid = c.oid
240         JOIN pg_catalog.pg_namespace n2
241           ON c.relnamespace = n2.oid
242        WHERE c.relkind IN ('r', 'i', 'f', 'm')
243          AND NOT n2.nspname IN ('pg_catalog',
244                                 'pg_toast',
245                                 'information_schema',
246                                 'dbms_stats')
247         -- AND n2.nspname = 'public'
248         -- AND c.relname = 'test'
249         -- AND a.attname = 'id'
250  AND n2.nspname = 's0'
251        ORDER BY starelid, staattnum)
252 TO STDOUT
253 (FORMAT 'binary');
254 \o
255 COMMIT;
256 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
257 SELECT * FROM work_v;
258  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 |       stavalues1       | stavalues2 | stavalues3 | stavalues4 | stavalues5 
259 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------------+------------+------------+------------+------------
260  s0      | sft0    |        1 |        10 |             0 |        0 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2,3,4,5,6,7,8,9,10} | (null)     | (null)     | (null)     | (null)
261  s0      | smv0    |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2}                  | (null)     | (null)     | (null)     | (null)
262  s0      | smv0    |        1 |         2 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {10,20}                | (null)     | (null)     | (null)     | (null)
263  s0      | smv0    |        1 |         2 |             1 |        1 | txt     | pg_catalog          | text    |        -1 | f          |           0 |        3 |          -1 |        2 |        3 |        0 |        0 |        0 |    664 |    664 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,test}               | (null)     | (null)     | (null)     | (null)
264  s0      | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2}                  | (null)     | (null)     | (null)     | (null)
265  s0      | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | t          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2,4,5,6}            | (null)     | (null)     | (null)     | (null)
266  s0      | st0     |        1 |         2 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {10,20}                | (null)     | (null)     | (null)     | (null)
267  s0      | st0     |        1 |         2 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | t          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {10,20,40,50,60}       | (null)     | (null)     | (null)     | (null)
268  s0      | st0_idx |        2 |         2 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)                 | (null)     | (null)     | (null)     | (null)
269  s0      | st1     |        1 |         3 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {4,5,6}                | (null)     | (null)     | (null)     | (null)
270  s0      | st1     |        1 |         3 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {40,50,60}             | (null)     | (null)     | (null)     | (null)
271  s0      | st1_idx |        2 |         3 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)                 | (null)     | (null)     | (null)     | (null)
272  s0      | st2     |        1 |         3 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2,3}                | (null)     | (null)     | (null)     | (null)
273  s0      | st2     |        1 |         3 |             1 |        1 | txt     | pg_catalog          | text    |        -1 | f          |           0 |        5 |          -1 |        2 |        3 |        0 |        0 |        0 |    664 |    664 |      0 |      0 |      0 | (null)      | {0.5}       | (null)      | (null)      | (null)      | {1,comment,test}       | (null)     | (null)     | (null)     | (null)
274  s0      | st2_idx |        2 |         3 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)                 | (null)     | (null)     | (null)     | (null)
275  s0      | st3     |        0 |         0 |             0 |        0 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)                 | (null)     | (null)     | (null)     | (null)
276 (16 rows)
277
278 TRUNCATE dbms_stats.work;
279 \! rm doc/export_plain_stats-12.sql.sample_test
280 -- No.16-1-3
281 \! sed '/ORDER/i\\ AND c.relname = '"\'st0\'" doc/export_plain_stats-12.sql.sample > doc/export_plain_stats-12.sql.sample_test
282 \i doc/export_plain_stats-12.sql.sample_test
283 /*
284  * If you want the statistics of per-relation or per-column, please modify
285  * nspname, relname, and attname in 'WHERE' clause.
286  */
287 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
288 /*
289  * If you want to chage the output file name, please modify the following name.
290  */
291 \o export_stats.dmp
292 COPY (SELECT n2.nspname,
293              c.relname,
294              c.relpages,
295              c.reltuples,
296              c.relallvisible,
297              (pg_relation_size(c.oid) / current_setting('block_size')::int4)::int4
298                  AS curpages,
299              pg_catalog.pg_stat_get_last_analyze_time(c.oid)
300                  AS last_analyze,
301              pg_catalog.pg_stat_get_last_autoanalyze_time(c.oid)
302                  AS last_autoanalyze,
303              COALESCE(a.attname, ''),
304              n1.nspname AS schemaname_of_atttype,
305              t.typname,
306              a.atttypmod,
307              s.stainherit,
308              s.stanullfrac,
309              s.stawidth,
310              s.stadistinct,
311              s.stakind1,
312              s.stakind2,
313              s.stakind3,
314              s.stakind4,
315              s.stakind5,
316              s.staop1,
317              s.staop2,
318              s.staop3,
319              s.staop4,
320              s.staop5,
321              s.stacoll1,
322              s.stacoll2,
323              s.stacoll3,
324              s.stacoll4,
325              s.stacoll5,
326              s.stanumbers1,
327              s.stanumbers2,
328              s.stanumbers3,
329              s.stanumbers4,
330              s.stanumbers5,
331              s.stavalues1,
332              s.stavalues2,
333              s.stavalues3,
334              s.stavalues4,
335              s.stavalues5
336         FROM pg_statistic s
337         JOIN pg_attribute a
338           ON (s.starelid = a.attrelid AND s.staattnum = a.attnum)
339         JOIN pg_type t
340           ON a.atttypid = t.oid
341         JOIN pg_namespace n1
342           ON t.typnamespace = n1.oid
343        RIGHT JOIN pg_catalog.pg_class c
344           ON s.starelid = c.oid
345         JOIN pg_catalog.pg_namespace n2
346           ON c.relnamespace = n2.oid
347        WHERE c.relkind IN ('r', 'i', 'f', 'm')
348          AND NOT n2.nspname IN ('pg_catalog',
349                                 'pg_toast',
350                                 'information_schema',
351                                 'dbms_stats')
352         -- AND n2.nspname = 'public'
353         -- AND c.relname = 'test'
354         -- AND a.attname = 'id'
355  AND c.relname = 'st0'
356        ORDER BY starelid, staattnum)
357 TO STDOUT
358 (FORMAT 'binary');
359 \o
360 COMMIT;
361 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
362 SELECT * FROM work_v;
363  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 |    stavalues1    | stavalues2 | stavalues3 | stavalues4 | stavalues5 
364 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------+------------+------------
365  public  | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2}            | (null)     | (null)     | (null)     | (null)
366  public  | st0     |        1 |         2 |             1 |        1 | name    | pg_catalog          | bpchar  |         9 | f          |           0 |        6 |        -0.5 |        1 |        3 |        0 |        0 |        0 |   1054 |   1058 |      0 |      0 |      0 | {1}         | {1}         | (null)      | (null)      | (null)      | {"test "}        | (null)     | (null)     | (null)     | (null)
367  s0      | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2}            | (null)     | (null)     | (null)     | (null)
368  s0      | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | t          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2,4,5,6}      | (null)     | (null)     | (null)     | (null)
369  s0      | st0     |        1 |         2 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {10,20}          | (null)     | (null)     | (null)     | (null)
370  s0      | st0     |        1 |         2 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | t          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {10,20,40,50,60} | (null)     | (null)     | (null)     | (null)
371  s1      | st0     |        1 |         4 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2,3,4}        | (null)     | (null)     | (null)     | (null)
372  s1      | st0     |        1 |         4 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {15,25,35,45}    | (null)     | (null)     | (null)     | (null)
373 (8 rows)
374
375 TRUNCATE dbms_stats.work;
376 \! rm doc/export_plain_stats-12.sql.sample_test
377 -- No.16-1-3-1 Actual import test
378 select dbms_stats.import_database_stats('@abs_srcdir@/export_stats.dmp');
379  import_database_stats 
380 -----------------------
381  
382 (1 row)
383
384 -- No.16-1-4
385 \! sed '/ORDER/i\\ AND c.relname = '"\'pg_toast_1262\'" doc/export_plain_stats-12.sql.sample > doc/export_plain_stats-12.sql.sample_test
386 \i doc/export_plain_stats-12.sql.sample_test
387 /*
388  * If you want the statistics of per-relation or per-column, please modify
389  * nspname, relname, and attname in 'WHERE' clause.
390  */
391 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
392 /*
393  * If you want to chage the output file name, please modify the following name.
394  */
395 \o export_stats.dmp
396 COPY (SELECT n2.nspname,
397              c.relname,
398              c.relpages,
399              c.reltuples,
400              c.relallvisible,
401              (pg_relation_size(c.oid) / current_setting('block_size')::int4)::int4
402                  AS curpages,
403              pg_catalog.pg_stat_get_last_analyze_time(c.oid)
404                  AS last_analyze,
405              pg_catalog.pg_stat_get_last_autoanalyze_time(c.oid)
406                  AS last_autoanalyze,
407              COALESCE(a.attname, ''),
408              n1.nspname AS schemaname_of_atttype,
409              t.typname,
410              a.atttypmod,
411              s.stainherit,
412              s.stanullfrac,
413              s.stawidth,
414              s.stadistinct,
415              s.stakind1,
416              s.stakind2,
417              s.stakind3,
418              s.stakind4,
419              s.stakind5,
420              s.staop1,
421              s.staop2,
422              s.staop3,
423              s.staop4,
424              s.staop5,
425              s.stacoll1,
426              s.stacoll2,
427              s.stacoll3,
428              s.stacoll4,
429              s.stacoll5,
430              s.stanumbers1,
431              s.stanumbers2,
432              s.stanumbers3,
433              s.stanumbers4,
434              s.stanumbers5,
435              s.stavalues1,
436              s.stavalues2,
437              s.stavalues3,
438              s.stavalues4,
439              s.stavalues5
440         FROM pg_statistic s
441         JOIN pg_attribute a
442           ON (s.starelid = a.attrelid AND s.staattnum = a.attnum)
443         JOIN pg_type t
444           ON a.atttypid = t.oid
445         JOIN pg_namespace n1
446           ON t.typnamespace = n1.oid
447        RIGHT JOIN pg_catalog.pg_class c
448           ON s.starelid = c.oid
449         JOIN pg_catalog.pg_namespace n2
450           ON c.relnamespace = n2.oid
451        WHERE c.relkind IN ('r', 'i', 'f', 'm')
452          AND NOT n2.nspname IN ('pg_catalog',
453                                 'pg_toast',
454                                 'information_schema',
455                                 'dbms_stats')
456         -- AND n2.nspname = 'public'
457         -- AND c.relname = 'test'
458         -- AND a.attname = 'id'
459  AND c.relname = 'pg_toast_1262'
460        ORDER BY starelid, staattnum)
461 TO STDOUT
462 (FORMAT 'binary');
463 \o
464 COMMIT;
465 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
466 SELECT * FROM work_v;
467  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 
468 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------
469 (0 rows)
470
471 TRUNCATE dbms_stats.work;
472 \! rm doc/export_plain_stats-12.sql.sample_test
473 -- No.16-1-5
474 \! sed '/ORDER/i\\ AND c.relname = '"\'st0_idx\'" doc/export_plain_stats-12.sql.sample > doc/export_plain_stats-12.sql.sample_test
475 \i doc/export_plain_stats-12.sql.sample_test
476 /*
477  * If you want the statistics of per-relation or per-column, please modify
478  * nspname, relname, and attname in 'WHERE' clause.
479  */
480 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
481 /*
482  * If you want to chage the output file name, please modify the following name.
483  */
484 \o export_stats.dmp
485 COPY (SELECT n2.nspname,
486              c.relname,
487              c.relpages,
488              c.reltuples,
489              c.relallvisible,
490              (pg_relation_size(c.oid) / current_setting('block_size')::int4)::int4
491                  AS curpages,
492              pg_catalog.pg_stat_get_last_analyze_time(c.oid)
493                  AS last_analyze,
494              pg_catalog.pg_stat_get_last_autoanalyze_time(c.oid)
495                  AS last_autoanalyze,
496              COALESCE(a.attname, ''),
497              n1.nspname AS schemaname_of_atttype,
498              t.typname,
499              a.atttypmod,
500              s.stainherit,
501              s.stanullfrac,
502              s.stawidth,
503              s.stadistinct,
504              s.stakind1,
505              s.stakind2,
506              s.stakind3,
507              s.stakind4,
508              s.stakind5,
509              s.staop1,
510              s.staop2,
511              s.staop3,
512              s.staop4,
513              s.staop5,
514              s.stacoll1,
515              s.stacoll2,
516              s.stacoll3,
517              s.stacoll4,
518              s.stacoll5,
519              s.stanumbers1,
520              s.stanumbers2,
521              s.stanumbers3,
522              s.stanumbers4,
523              s.stanumbers5,
524              s.stavalues1,
525              s.stavalues2,
526              s.stavalues3,
527              s.stavalues4,
528              s.stavalues5
529         FROM pg_statistic s
530         JOIN pg_attribute a
531           ON (s.starelid = a.attrelid AND s.staattnum = a.attnum)
532         JOIN pg_type t
533           ON a.atttypid = t.oid
534         JOIN pg_namespace n1
535           ON t.typnamespace = n1.oid
536        RIGHT JOIN pg_catalog.pg_class c
537           ON s.starelid = c.oid
538         JOIN pg_catalog.pg_namespace n2
539           ON c.relnamespace = n2.oid
540        WHERE c.relkind IN ('r', 'i', 'f', 'm')
541          AND NOT n2.nspname IN ('pg_catalog',
542                                 'pg_toast',
543                                 'information_schema',
544                                 'dbms_stats')
545         -- AND n2.nspname = 'public'
546         -- AND c.relname = 'test'
547         -- AND a.attname = 'id'
548  AND c.relname = 'st0_idx'
549        ORDER BY starelid, staattnum)
550 TO STDOUT
551 (FORMAT 'binary');
552 \o
553 COMMIT;
554 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
555 SELECT * FROM work_v;
556  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 
557 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------
558  public  | st0_idx |        2 |         2 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)     | (null)     | (null)     | (null)     | (null)
559  s0      | st0_idx |        2 |         2 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)     | (null)     | (null)     | (null)     | (null)
560 (2 rows)
561
562 TRUNCATE dbms_stats.work;
563 \! rm doc/export_plain_stats-12.sql.sample_test
564 -- No.16-1-6
565 \! sed '/ORDER/i\\ AND c.relname = '"\'ss0\'" doc/export_plain_stats-12.sql.sample > doc/export_plain_stats-12.sql.sample_test
566 \i doc/export_plain_stats-12.sql.sample_test
567 /*
568  * If you want the statistics of per-relation or per-column, please modify
569  * nspname, relname, and attname in 'WHERE' clause.
570  */
571 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
572 /*
573  * If you want to chage the output file name, please modify the following name.
574  */
575 \o export_stats.dmp
576 COPY (SELECT n2.nspname,
577              c.relname,
578              c.relpages,
579              c.reltuples,
580              c.relallvisible,
581              (pg_relation_size(c.oid) / current_setting('block_size')::int4)::int4
582                  AS curpages,
583              pg_catalog.pg_stat_get_last_analyze_time(c.oid)
584                  AS last_analyze,
585              pg_catalog.pg_stat_get_last_autoanalyze_time(c.oid)
586                  AS last_autoanalyze,
587              COALESCE(a.attname, ''),
588              n1.nspname AS schemaname_of_atttype,
589              t.typname,
590              a.atttypmod,
591              s.stainherit,
592              s.stanullfrac,
593              s.stawidth,
594              s.stadistinct,
595              s.stakind1,
596              s.stakind2,
597              s.stakind3,
598              s.stakind4,
599              s.stakind5,
600              s.staop1,
601              s.staop2,
602              s.staop3,
603              s.staop4,
604              s.staop5,
605              s.stacoll1,
606              s.stacoll2,
607              s.stacoll3,
608              s.stacoll4,
609              s.stacoll5,
610              s.stanumbers1,
611              s.stanumbers2,
612              s.stanumbers3,
613              s.stanumbers4,
614              s.stanumbers5,
615              s.stavalues1,
616              s.stavalues2,
617              s.stavalues3,
618              s.stavalues4,
619              s.stavalues5
620         FROM pg_statistic s
621         JOIN pg_attribute a
622           ON (s.starelid = a.attrelid AND s.staattnum = a.attnum)
623         JOIN pg_type t
624           ON a.atttypid = t.oid
625         JOIN pg_namespace n1
626           ON t.typnamespace = n1.oid
627        RIGHT JOIN pg_catalog.pg_class c
628           ON s.starelid = c.oid
629         JOIN pg_catalog.pg_namespace n2
630           ON c.relnamespace = n2.oid
631        WHERE c.relkind IN ('r', 'i', 'f', 'm')
632          AND NOT n2.nspname IN ('pg_catalog',
633                                 'pg_toast',
634                                 'information_schema',
635                                 'dbms_stats')
636         -- AND n2.nspname = 'public'
637         -- AND c.relname = 'test'
638         -- AND a.attname = 'id'
639  AND c.relname = 'ss0'
640        ORDER BY starelid, staattnum)
641 TO STDOUT
642 (FORMAT 'binary');
643 \o
644 COMMIT;
645 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
646 SELECT * FROM work_v;
647  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 
648 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------
649 (0 rows)
650
651 TRUNCATE dbms_stats.work;
652 \! rm doc/export_plain_stats-12.sql.sample_test
653 -- No.16-1-7
654 \! sed '/ORDER/i\\ AND c.relname = '"\'sc0\'" doc/export_plain_stats-12.sql.sample > doc/export_plain_stats-12.sql.sample_test
655 \i doc/export_plain_stats-12.sql.sample_test
656 /*
657  * If you want the statistics of per-relation or per-column, please modify
658  * nspname, relname, and attname in 'WHERE' clause.
659  */
660 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
661 /*
662  * If you want to chage the output file name, please modify the following name.
663  */
664 \o export_stats.dmp
665 COPY (SELECT n2.nspname,
666              c.relname,
667              c.relpages,
668              c.reltuples,
669              c.relallvisible,
670              (pg_relation_size(c.oid) / current_setting('block_size')::int4)::int4
671                  AS curpages,
672              pg_catalog.pg_stat_get_last_analyze_time(c.oid)
673                  AS last_analyze,
674              pg_catalog.pg_stat_get_last_autoanalyze_time(c.oid)
675                  AS last_autoanalyze,
676              COALESCE(a.attname, ''),
677              n1.nspname AS schemaname_of_atttype,
678              t.typname,
679              a.atttypmod,
680              s.stainherit,
681              s.stanullfrac,
682              s.stawidth,
683              s.stadistinct,
684              s.stakind1,
685              s.stakind2,
686              s.stakind3,
687              s.stakind4,
688              s.stakind5,
689              s.staop1,
690              s.staop2,
691              s.staop3,
692              s.staop4,
693              s.staop5,
694              s.stacoll1,
695              s.stacoll2,
696              s.stacoll3,
697              s.stacoll4,
698              s.stacoll5,
699              s.stanumbers1,
700              s.stanumbers2,
701              s.stanumbers3,
702              s.stanumbers4,
703              s.stanumbers5,
704              s.stavalues1,
705              s.stavalues2,
706              s.stavalues3,
707              s.stavalues4,
708              s.stavalues5
709         FROM pg_statistic s
710         JOIN pg_attribute a
711           ON (s.starelid = a.attrelid AND s.staattnum = a.attnum)
712         JOIN pg_type t
713           ON a.atttypid = t.oid
714         JOIN pg_namespace n1
715           ON t.typnamespace = n1.oid
716        RIGHT JOIN pg_catalog.pg_class c
717           ON s.starelid = c.oid
718         JOIN pg_catalog.pg_namespace n2
719           ON c.relnamespace = n2.oid
720        WHERE c.relkind IN ('r', 'i', 'f', 'm')
721          AND NOT n2.nspname IN ('pg_catalog',
722                                 'pg_toast',
723                                 'information_schema',
724                                 'dbms_stats')
725         -- AND n2.nspname = 'public'
726         -- AND c.relname = 'test'
727         -- AND a.attname = 'id'
728  AND c.relname = 'sc0'
729        ORDER BY starelid, staattnum)
730 TO STDOUT
731 (FORMAT 'binary');
732 \o
733 COMMIT;
734 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
735 SELECT * FROM work_v;
736  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 
737 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------
738 (0 rows)
739
740 TRUNCATE dbms_stats.work;
741 \! rm doc/export_plain_stats-12.sql.sample_test
742 -- No.16-1-8
743 \! sed '/ORDER/i\\ AND c.relname = '"\'sft0\'" doc/export_plain_stats-12.sql.sample > doc/export_plain_stats-12.sql.sample_test
744 \i doc/export_plain_stats-12.sql.sample_test
745 /*
746  * If you want the statistics of per-relation or per-column, please modify
747  * nspname, relname, and attname in 'WHERE' clause.
748  */
749 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
750 /*
751  * If you want to chage the output file name, please modify the following name.
752  */
753 \o export_stats.dmp
754 COPY (SELECT n2.nspname,
755              c.relname,
756              c.relpages,
757              c.reltuples,
758              c.relallvisible,
759              (pg_relation_size(c.oid) / current_setting('block_size')::int4)::int4
760                  AS curpages,
761              pg_catalog.pg_stat_get_last_analyze_time(c.oid)
762                  AS last_analyze,
763              pg_catalog.pg_stat_get_last_autoanalyze_time(c.oid)
764                  AS last_autoanalyze,
765              COALESCE(a.attname, ''),
766              n1.nspname AS schemaname_of_atttype,
767              t.typname,
768              a.atttypmod,
769              s.stainherit,
770              s.stanullfrac,
771              s.stawidth,
772              s.stadistinct,
773              s.stakind1,
774              s.stakind2,
775              s.stakind3,
776              s.stakind4,
777              s.stakind5,
778              s.staop1,
779              s.staop2,
780              s.staop3,
781              s.staop4,
782              s.staop5,
783              s.stacoll1,
784              s.stacoll2,
785              s.stacoll3,
786              s.stacoll4,
787              s.stacoll5,
788              s.stanumbers1,
789              s.stanumbers2,
790              s.stanumbers3,
791              s.stanumbers4,
792              s.stanumbers5,
793              s.stavalues1,
794              s.stavalues2,
795              s.stavalues3,
796              s.stavalues4,
797              s.stavalues5
798         FROM pg_statistic s
799         JOIN pg_attribute a
800           ON (s.starelid = a.attrelid AND s.staattnum = a.attnum)
801         JOIN pg_type t
802           ON a.atttypid = t.oid
803         JOIN pg_namespace n1
804           ON t.typnamespace = n1.oid
805        RIGHT JOIN pg_catalog.pg_class c
806           ON s.starelid = c.oid
807         JOIN pg_catalog.pg_namespace n2
808           ON c.relnamespace = n2.oid
809        WHERE c.relkind IN ('r', 'i', 'f', 'm')
810          AND NOT n2.nspname IN ('pg_catalog',
811                                 'pg_toast',
812                                 'information_schema',
813                                 'dbms_stats')
814         -- AND n2.nspname = 'public'
815         -- AND c.relname = 'test'
816         -- AND a.attname = 'id'
817  AND c.relname = 'sft0'
818        ORDER BY starelid, staattnum)
819 TO STDOUT
820 (FORMAT 'binary');
821 \o
822 COMMIT;
823 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
824 SELECT * FROM work_v;
825  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 |       stavalues1       | stavalues2 | stavalues3 | stavalues4 | stavalues5 
826 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------------+------------+------------+------------+------------
827  s0      | sft0    |        1 |        10 |             0 |        0 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2,3,4,5,6,7,8,9,10} | (null)     | (null)     | (null)     | (null)
828 (1 row)
829
830 TRUNCATE dbms_stats.work;
831 \! rm doc/export_plain_stats-12.sql.sample_test
832 -- No.16-1-9
833 \! sed '/ORDER/i\\ AND c.relname = '"\'smv0\'" doc/export_plain_stats-12.sql.sample > doc/export_plain_stats-12.sql.sample_test
834 \i doc/export_plain_stats-12.sql.sample_test
835 /*
836  * If you want the statistics of per-relation or per-column, please modify
837  * nspname, relname, and attname in 'WHERE' clause.
838  */
839 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
840 /*
841  * If you want to chage the output file name, please modify the following name.
842  */
843 \o export_stats.dmp
844 COPY (SELECT n2.nspname,
845              c.relname,
846              c.relpages,
847              c.reltuples,
848              c.relallvisible,
849              (pg_relation_size(c.oid) / current_setting('block_size')::int4)::int4
850                  AS curpages,
851              pg_catalog.pg_stat_get_last_analyze_time(c.oid)
852                  AS last_analyze,
853              pg_catalog.pg_stat_get_last_autoanalyze_time(c.oid)
854                  AS last_autoanalyze,
855              COALESCE(a.attname, ''),
856              n1.nspname AS schemaname_of_atttype,
857              t.typname,
858              a.atttypmod,
859              s.stainherit,
860              s.stanullfrac,
861              s.stawidth,
862              s.stadistinct,
863              s.stakind1,
864              s.stakind2,
865              s.stakind3,
866              s.stakind4,
867              s.stakind5,
868              s.staop1,
869              s.staop2,
870              s.staop3,
871              s.staop4,
872              s.staop5,
873              s.stacoll1,
874              s.stacoll2,
875              s.stacoll3,
876              s.stacoll4,
877              s.stacoll5,
878              s.stanumbers1,
879              s.stanumbers2,
880              s.stanumbers3,
881              s.stanumbers4,
882              s.stanumbers5,
883              s.stavalues1,
884              s.stavalues2,
885              s.stavalues3,
886              s.stavalues4,
887              s.stavalues5
888         FROM pg_statistic s
889         JOIN pg_attribute a
890           ON (s.starelid = a.attrelid AND s.staattnum = a.attnum)
891         JOIN pg_type t
892           ON a.atttypid = t.oid
893         JOIN pg_namespace n1
894           ON t.typnamespace = n1.oid
895        RIGHT JOIN pg_catalog.pg_class c
896           ON s.starelid = c.oid
897         JOIN pg_catalog.pg_namespace n2
898           ON c.relnamespace = n2.oid
899        WHERE c.relkind IN ('r', 'i', 'f', 'm')
900          AND NOT n2.nspname IN ('pg_catalog',
901                                 'pg_toast',
902                                 'information_schema',
903                                 'dbms_stats')
904         -- AND n2.nspname = 'public'
905         -- AND c.relname = 'test'
906         -- AND a.attname = 'id'
907  AND c.relname = 'smv0'
908        ORDER BY starelid, staattnum)
909 TO STDOUT
910 (FORMAT 'binary');
911 \o
912 COMMIT;
913 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
914 SELECT * FROM work_v;
915  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 
916 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------
917  s0      | smv0    |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2}      | (null)     | (null)     | (null)     | (null)
918  s0      | smv0    |        1 |         2 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {10,20}    | (null)     | (null)     | (null)     | (null)
919  s0      | smv0    |        1 |         2 |             1 |        1 | txt     | pg_catalog          | text    |        -1 | f          |           0 |        3 |          -1 |        2 |        3 |        0 |        0 |        0 |    664 |    664 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,test}   | (null)     | (null)     | (null)     | (null)
920 (3 rows)
921
922 TRUNCATE dbms_stats.work;
923 \! rm doc/export_plain_stats-12.sql.sample_test
924 -- No.16-1-10
925 \! sed '/ORDER/i\\ AND n2.nspname = '"\'s0\'"' AND a.attname = '\'id\' doc/export_plain_stats-12.sql.sample > doc/export_plain_stats-12.sql.sample_test
926 \i doc/export_plain_stats-12.sql.sample_test
927 /*
928  * If you want the statistics of per-relation or per-column, please modify
929  * nspname, relname, and attname in 'WHERE' clause.
930  */
931 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
932 /*
933  * If you want to chage the output file name, please modify the following name.
934  */
935 \o export_stats.dmp
936 COPY (SELECT n2.nspname,
937              c.relname,
938              c.relpages,
939              c.reltuples,
940              c.relallvisible,
941              (pg_relation_size(c.oid) / current_setting('block_size')::int4)::int4
942                  AS curpages,
943              pg_catalog.pg_stat_get_last_analyze_time(c.oid)
944                  AS last_analyze,
945              pg_catalog.pg_stat_get_last_autoanalyze_time(c.oid)
946                  AS last_autoanalyze,
947              COALESCE(a.attname, ''),
948              n1.nspname AS schemaname_of_atttype,
949              t.typname,
950              a.atttypmod,
951              s.stainherit,
952              s.stanullfrac,
953              s.stawidth,
954              s.stadistinct,
955              s.stakind1,
956              s.stakind2,
957              s.stakind3,
958              s.stakind4,
959              s.stakind5,
960              s.staop1,
961              s.staop2,
962              s.staop3,
963              s.staop4,
964              s.staop5,
965              s.stacoll1,
966              s.stacoll2,
967              s.stacoll3,
968              s.stacoll4,
969              s.stacoll5,
970              s.stanumbers1,
971              s.stanumbers2,
972              s.stanumbers3,
973              s.stanumbers4,
974              s.stanumbers5,
975              s.stavalues1,
976              s.stavalues2,
977              s.stavalues3,
978              s.stavalues4,
979              s.stavalues5
980         FROM pg_statistic s
981         JOIN pg_attribute a
982           ON (s.starelid = a.attrelid AND s.staattnum = a.attnum)
983         JOIN pg_type t
984           ON a.atttypid = t.oid
985         JOIN pg_namespace n1
986           ON t.typnamespace = n1.oid
987        RIGHT JOIN pg_catalog.pg_class c
988           ON s.starelid = c.oid
989         JOIN pg_catalog.pg_namespace n2
990           ON c.relnamespace = n2.oid
991        WHERE c.relkind IN ('r', 'i', 'f', 'm')
992          AND NOT n2.nspname IN ('pg_catalog',
993                                 'pg_toast',
994                                 'information_schema',
995                                 'dbms_stats')
996         -- AND n2.nspname = 'public'
997         -- AND c.relname = 'test'
998         -- AND a.attname = 'id'
999  AND n2.nspname = 's0' AND a.attname = 'id'
1000        ORDER BY starelid, staattnum)
1001 TO STDOUT
1002 (FORMAT 'binary');
1003 \o
1004 COMMIT;
1005 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
1006 SELECT * FROM work_v;
1007  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 |       stavalues1       | stavalues2 | stavalues3 | stavalues4 | stavalues5 
1008 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------------+------------+------------+------------+------------
1009  s0      | sft0    |        1 |        10 |             0 |        0 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2,3,4,5,6,7,8,9,10} | (null)     | (null)     | (null)     | (null)
1010  s0      | smv0    |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2}                  | (null)     | (null)     | (null)     | (null)
1011  s0      | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2}                  | (null)     | (null)     | (null)     | (null)
1012  s0      | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | t          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2,4,5,6}            | (null)     | (null)     | (null)     | (null)
1013  s0      | st1     |        1 |         3 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {4,5,6}                | (null)     | (null)     | (null)     | (null)
1014  s0      | st2     |        1 |         3 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2,3}                | (null)     | (null)     | (null)     | (null)
1015 (6 rows)
1016
1017 TRUNCATE dbms_stats.work;
1018 \! rm doc/export_plain_stats-12.sql.sample_test
1019 -- No.16-1-11
1020 \! sed '/ORDER/i\\ AND n2.nspname = '"\'s0\'"' AND a.attname IS NULL' doc/export_plain_stats-12.sql.sample > doc/export_plain_stats-12.sql.sample_test
1021 \i doc/export_plain_stats-12.sql.sample_test
1022 /*
1023  * If you want the statistics of per-relation or per-column, please modify
1024  * nspname, relname, and attname in 'WHERE' clause.
1025  */
1026 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
1027 /*
1028  * If you want to chage the output file name, please modify the following name.
1029  */
1030 \o export_stats.dmp
1031 COPY (SELECT n2.nspname,
1032              c.relname,
1033              c.relpages,
1034              c.reltuples,
1035              c.relallvisible,
1036              (pg_relation_size(c.oid) / current_setting('block_size')::int4)::int4
1037                  AS curpages,
1038              pg_catalog.pg_stat_get_last_analyze_time(c.oid)
1039                  AS last_analyze,
1040              pg_catalog.pg_stat_get_last_autoanalyze_time(c.oid)
1041                  AS last_autoanalyze,
1042              COALESCE(a.attname, ''),
1043              n1.nspname AS schemaname_of_atttype,
1044              t.typname,
1045              a.atttypmod,
1046              s.stainherit,
1047              s.stanullfrac,
1048              s.stawidth,
1049              s.stadistinct,
1050              s.stakind1,
1051              s.stakind2,
1052              s.stakind3,
1053              s.stakind4,
1054              s.stakind5,
1055              s.staop1,
1056              s.staop2,
1057              s.staop3,
1058              s.staop4,
1059              s.staop5,
1060              s.stacoll1,
1061              s.stacoll2,
1062              s.stacoll3,
1063              s.stacoll4,
1064              s.stacoll5,
1065              s.stanumbers1,
1066              s.stanumbers2,
1067              s.stanumbers3,
1068              s.stanumbers4,
1069              s.stanumbers5,
1070              s.stavalues1,
1071              s.stavalues2,
1072              s.stavalues3,
1073              s.stavalues4,
1074              s.stavalues5
1075         FROM pg_statistic s
1076         JOIN pg_attribute a
1077           ON (s.starelid = a.attrelid AND s.staattnum = a.attnum)
1078         JOIN pg_type t
1079           ON a.atttypid = t.oid
1080         JOIN pg_namespace n1
1081           ON t.typnamespace = n1.oid
1082        RIGHT JOIN pg_catalog.pg_class c
1083           ON s.starelid = c.oid
1084         JOIN pg_catalog.pg_namespace n2
1085           ON c.relnamespace = n2.oid
1086        WHERE c.relkind IN ('r', 'i', 'f', 'm')
1087          AND NOT n2.nspname IN ('pg_catalog',
1088                                 'pg_toast',
1089                                 'information_schema',
1090                                 'dbms_stats')
1091         -- AND n2.nspname = 'public'
1092         -- AND c.relname = 'test'
1093         -- AND a.attname = 'id'
1094  AND n2.nspname = 's0' AND a.attname IS NULL
1095        ORDER BY starelid, staattnum)
1096 TO STDOUT
1097 (FORMAT 'binary');
1098 \o
1099 COMMIT;
1100 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
1101 SELECT * FROM work_v;
1102  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 
1103 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------
1104  s0      | st0_idx |        2 |         2 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)     | (null)     | (null)     | (null)     | (null)
1105  s0      | st1_idx |        2 |         3 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)     | (null)     | (null)     | (null)     | (null)
1106  s0      | st2_idx |        2 |         3 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)     | (null)     | (null)     | (null)     | (null)
1107  s0      | st3     |        0 |         0 |             0 |        0 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)     | (null)     | (null)     | (null)     | (null)
1108 (4 rows)
1109
1110 TRUNCATE dbms_stats.work;
1111 \! rm doc/export_plain_stats-12.sql.sample_test
1112 -- No.16-1-12
1113 \! sed '/ORDER/i\\ AND n2.nspname = '"\'s1\'"' AND c.relname IS NULL' doc/export_plain_stats-12.sql.sample > doc/export_plain_stats-12.sql.sample_test
1114 \i doc/export_plain_stats-12.sql.sample_test
1115 /*
1116  * If you want the statistics of per-relation or per-column, please modify
1117  * nspname, relname, and attname in 'WHERE' clause.
1118  */
1119 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
1120 /*
1121  * If you want to chage the output file name, please modify the following name.
1122  */
1123 \o export_stats.dmp
1124 COPY (SELECT n2.nspname,
1125              c.relname,
1126              c.relpages,
1127              c.reltuples,
1128              c.relallvisible,
1129              (pg_relation_size(c.oid) / current_setting('block_size')::int4)::int4
1130                  AS curpages,
1131              pg_catalog.pg_stat_get_last_analyze_time(c.oid)
1132                  AS last_analyze,
1133              pg_catalog.pg_stat_get_last_autoanalyze_time(c.oid)
1134                  AS last_autoanalyze,
1135              COALESCE(a.attname, ''),
1136              n1.nspname AS schemaname_of_atttype,
1137              t.typname,
1138              a.atttypmod,
1139              s.stainherit,
1140              s.stanullfrac,
1141              s.stawidth,
1142              s.stadistinct,
1143              s.stakind1,
1144              s.stakind2,
1145              s.stakind3,
1146              s.stakind4,
1147              s.stakind5,
1148              s.staop1,
1149              s.staop2,
1150              s.staop3,
1151              s.staop4,
1152              s.staop5,
1153              s.stacoll1,
1154              s.stacoll2,
1155              s.stacoll3,
1156              s.stacoll4,
1157              s.stacoll5,
1158              s.stanumbers1,
1159              s.stanumbers2,
1160              s.stanumbers3,
1161              s.stanumbers4,
1162              s.stanumbers5,
1163              s.stavalues1,
1164              s.stavalues2,
1165              s.stavalues3,
1166              s.stavalues4,
1167              s.stavalues5
1168         FROM pg_statistic s
1169         JOIN pg_attribute a
1170           ON (s.starelid = a.attrelid AND s.staattnum = a.attnum)
1171         JOIN pg_type t
1172           ON a.atttypid = t.oid
1173         JOIN pg_namespace n1
1174           ON t.typnamespace = n1.oid
1175        RIGHT JOIN pg_catalog.pg_class c
1176           ON s.starelid = c.oid
1177         JOIN pg_catalog.pg_namespace n2
1178           ON c.relnamespace = n2.oid
1179        WHERE c.relkind IN ('r', 'i', 'f', 'm')
1180          AND NOT n2.nspname IN ('pg_catalog',
1181                                 'pg_toast',
1182                                 'information_schema',
1183                                 'dbms_stats')
1184         -- AND n2.nspname = 'public'
1185         -- AND c.relname = 'test'
1186         -- AND a.attname = 'id'
1187  AND n2.nspname = 's1' AND c.relname IS NULL
1188        ORDER BY starelid, staattnum)
1189 TO STDOUT
1190 (FORMAT 'binary');
1191 \o
1192 COMMIT;
1193 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
1194 SELECT * FROM work_v;
1195  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 
1196 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------
1197 (0 rows)
1198
1199 TRUNCATE dbms_stats.work;
1200 \! rm doc/export_plain_stats-12.sql.sample_test
1201 /*
1202  * No.16-2 export_effective_stats-12.sql.sample
1203  */
1204 -- No.16-2-1
1205 VACUUM ANALYZE;
1206 SELECT dbms_stats.lock_database_stats();
1207  lock_database_stats 
1208 ---------------------
1209  pt0
1210  pt0_idx
1211  st0
1212  st0_idx
1213  st1
1214  s0.st0
1215  s0.st0_idx
1216  s0.st1
1217  s0.st1_idx
1218  s0.st2
1219  s0.st2_idx
1220  st1_idx
1221  st1_exp
1222  s0.sft0
1223  s0.smv0
1224  s1.st0
1225  s0.st3
1226 (17 rows)
1227
1228 UPDATE dbms_stats.relation_stats_locked
1229    SET (relpages, reltuples, relallvisible, curpages) = (NULL, NULL, NULL, NULL);
1230 UPDATE dbms_stats.column_stats_locked
1231    SET (stanullfrac, stawidth, stadistinct,
1232         stakind1, stakind2, stakind3, stakind4, stakind5,
1233         staop1, staop2, staop3, staop4, staop5,
1234         stacoll1, stacoll2, stacoll3, stacoll4, stacoll5,
1235         stanumbers1, stanumbers2, stanumbers3, stanumbers4, stanumbers5,
1236         stavalues1, stavalues2, stavalues3, stavalues4, stavalues5)
1237      = (NULL, NULL, NULL,
1238         NULL, NULL, NULL, NULL, NULL,
1239         NULL, NULL, NULL, NULL, NULL,
1240         NULL, NULL, NULL, NULL, NULL,
1241         NULL, NULL, NULL, NULL, NULL,
1242         NULL, NULL, NULL, NULL, NULL)
1243  WHERE starelid = 's0.st0'::regclass;
1244 \i doc/export_effective_stats-12.sql.sample
1245 /*
1246  * If you want the statistics of per-relation or per-column, please modify
1247  * nspname, relname, and attname in 'WHERE' clause.
1248  */
1249 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
1250 /*
1251  * If you want to chage the output file name, please modify the following name.
1252  */
1253 \o export_stats.dmp
1254 COPY (SELECT n2.nspname,
1255              cl.relname,
1256              r.relpages,
1257              r.reltuples,
1258              r.relallvisible,
1259              r.curpages,
1260              r.last_analyze,
1261              r.last_autoanalyze,
1262              COALESCE(a.attname, ''),
1263              n1.nspname AS schemaname_of_atttype,
1264              t.typname,
1265              a.atttypmod,
1266              co.stainherit,
1267              co.stanullfrac,
1268              co.stawidth,
1269              co.stadistinct,
1270              co.stakind1,
1271              co.stakind2,
1272              co.stakind3,
1273              co.stakind4,
1274              co.stakind5,
1275              co.staop1,
1276              co.staop2,
1277              co.staop3,
1278              co.staop4,
1279              co.staop5,
1280              co.stacoll1,
1281              co.stacoll2,
1282              co.stacoll3,
1283              co.stacoll4,
1284              co.stacoll5,
1285              co.stanumbers1,
1286              co.stanumbers2,
1287              co.stanumbers3,
1288              co.stanumbers4,
1289              co.stanumbers5,
1290              co.stavalues1,
1291              co.stavalues2,
1292              co.stavalues3,
1293              co.stavalues4,
1294              co.stavalues5
1295         FROM dbms_stats.column_stats_effective co
1296         JOIN pg_attribute a
1297           ON (co.starelid = a.attrelid AND co.staattnum = a.attnum)
1298         JOIN pg_type t
1299           ON a.atttypid = t.oid
1300         JOIN pg_namespace n1
1301           ON t.typnamespace = n1.oid
1302        RIGHT JOIN dbms_stats.relation_stats_effective r
1303           ON co.starelid = r.relid
1304         JOIN pg_catalog.pg_class cl
1305           ON r.relid = cl.oid
1306         JOIN pg_catalog.pg_namespace n2
1307           ON cl.relnamespace = n2.oid
1308        -- WHERE n2.nspname = 'public'
1309        -- AND cl.relname = 'test'
1310        -- AND a.attname = 'id'
1311        ORDER BY starelid, staattnum)
1312 TO STDOUT
1313 (FORMAT 'binary');
1314 \o
1315 COMMIT;
1316 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
1317 SELECT * FROM work_v;
1318  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 |    stavalues1    | stavalues2 |       stavalues3       | stavalues4 | stavalues5 
1319 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------------------+------------+------------
1320  public  | pt0     |        0 |         0 |             0 |        0 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)                 | (null)     | (null)
1321  public  | pt0_idx |        2 |         0 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)                 | (null)     | (null)
1322  public  | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2}            | (null)     | (null)                 | (null)     | (null)
1323  public  | st0     |        1 |         2 |             1 |        1 | name    | pg_catalog          | bpchar  |         9 | f          |           0 |        6 |        -0.5 |        1 |        3 |        0 |        0 |        0 |   1054 |   1058 |      0 |      0 |      0 | {1}         | {1}         | (null)      | (null)      | (null)      | {"test "}        | (null)     | (null)                 | (null)     | (null)
1324  public  | st0_idx |        2 |         2 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)                 | (null)     | (null)
1325  public  | st1     |       45 |     10000 |            45 |       45 | str     | pg_catalog          | text    |        -1 | f          |          -2 |       -2 |          -2 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-2,22}     | {-2,23}     | {-2,24}     | {-2,21}     | {-2,25}     | (null)           | (null)     | {1,0,2}                | (null)     | (null)
1326  public  | st1     |       45 |     10000 |            45 |       45 | val     | pg_catalog          | int4    |        -1 | f          |          -1 |       -1 |          -1 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-1,22}     | {-1,23}     | {-1,24}     | {-1,21}     | {-1,25}     | (null)           | (null)     | {1,0,2}                | (null)     | (null)
1327  public  | st1_exp |       30 |     10000 |             0 |       30 | lower   | pg_catalog          | text    |        -1 | f          |          -1 |       -1 |          -1 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-1,22}     | {-1,23}     | {-1,24}     | {-1,21}     | {-1,25}     | (null)           | (null)     | {1,0,2}                | (null)     | (null)
1328  public  | st1_idx |       30 |     10000 |             0 |       30 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)                 | (null)     | (null)
1329  s0      | sft0    |        1 |        10 |             0 |        0 | id      | pg_catalog          | int4    |        -1 | f          |          -1 |       -1 |          -1 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-1,22}     | {-1,23}     | {-1,24}     | {-1,21}     | {-1,25}     | (null)           | (null)     | {1,2,3,4,5,6,7,8,9,10} | (null)     | (null)
1330  s0      | smv0    |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |          -1 |       -1 |          -1 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-1,22}     | {-1,23}     | {-1,24}     | {-1,21}     | {-1,25}     | (null)           | (null)     | {1,2}                  | (null)     | (null)
1331  s0      | smv0    |        1 |         2 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | f          |          -2 |       -2 |          -2 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-2,22}     | {-2,23}     | {-2,24}     | {-2,21}     | {-2,25}     | (null)           | (null)     | {10,20}                | (null)     | (null)
1332  s0      | smv0    |        1 |         2 |             1 |        1 | txt     | pg_catalog          | text    |        -1 | f          |          -3 |       -3 |          -3 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-3,22}     | {-3,23}     | {-3,24}     | {-3,21}     | {-3,25}     | (null)           | (null)     | {1,test}               | (null)     | (null)
1333  s0      | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2}            | (null)     | (null)                 | (null)     | (null)
1334  s0      | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | t          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2,4,5,6}      | (null)     | (null)                 | (null)     | (null)
1335  s0      | st0     |        1 |         2 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {10,20}          | (null)     | (null)                 | (null)     | (null)
1336  s0      | st0     |        1 |         2 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | t          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {10,20,40,50,60} | (null)     | (null)                 | (null)     | (null)
1337  s0      | st0_idx |        2 |         2 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)                 | (null)     | (null)
1338  s0      | st1     |        1 |         3 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |          -1 |       -1 |          -1 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-1,22}     | {-1,23}     | {-1,24}     | {-1,21}     | {-1,25}     | (null)           | (null)     | {4,5,6}                | (null)     | (null)
1339  s0      | st1     |        1 |         3 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | f          |          -2 |       -2 |          -2 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-2,22}     | {-2,23}     | {-2,24}     | {-2,21}     | {-2,25}     | (null)           | (null)     | {40,50,60}             | (null)     | (null)
1340  s0      | st1_idx |        2 |         3 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)                 | (null)     | (null)
1341  s0      | st2     |        1 |         3 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |          -1 |       -1 |          -1 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-1,22}     | {-1,23}     | {-1,24}     | {-1,21}     | {-1,25}     | (null)           | (null)     | {1,2,3}                | (null)     | (null)
1342  s0      | st2     |        1 |         3 |             1 |        1 | txt     | pg_catalog          | text    |        -1 | f          |          -2 |       -2 |          -2 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-2,22}     | {-2,23}     | {-2,24}     | {-2,21}     | {-2,25}     | (null)           | (null)     | {1,comment,test}       | (null)     | (null)
1343  s0      | st2_idx |        2 |         3 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)                 | (null)     | (null)
1344  s0      | st3     |        0 |         0 |             0 |        0 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)                 | (null)     | (null)
1345  s1      | st0     |        1 |         4 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2,3,4}        | (null)     | (null)                 | (null)     | (null)
1346  s1      | st0     |        1 |         4 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {15,25,35,45}    | (null)     | (null)                 | (null)     | (null)
1347 (27 rows)
1348
1349 TRUNCATE dbms_stats.work;
1350 -- No.16-2-2
1351 \! sed '/ORDER/i\\ WHERE n2.nspname = '"\'s0\'" doc/export_effective_stats-12.sql.sample > doc/export_effective_stats-12.sql.sample_test
1352 \i doc/export_effective_stats-12.sql.sample_test
1353 /*
1354  * If you want the statistics of per-relation or per-column, please modify
1355  * nspname, relname, and attname in 'WHERE' clause.
1356  */
1357 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
1358 /*
1359  * If you want to chage the output file name, please modify the following name.
1360  */
1361 \o export_stats.dmp
1362 COPY (SELECT n2.nspname,
1363              cl.relname,
1364              r.relpages,
1365              r.reltuples,
1366              r.relallvisible,
1367              r.curpages,
1368              r.last_analyze,
1369              r.last_autoanalyze,
1370              COALESCE(a.attname, ''),
1371              n1.nspname AS schemaname_of_atttype,
1372              t.typname,
1373              a.atttypmod,
1374              co.stainherit,
1375              co.stanullfrac,
1376              co.stawidth,
1377              co.stadistinct,
1378              co.stakind1,
1379              co.stakind2,
1380              co.stakind3,
1381              co.stakind4,
1382              co.stakind5,
1383              co.staop1,
1384              co.staop2,
1385              co.staop3,
1386              co.staop4,
1387              co.staop5,
1388              co.stacoll1,
1389              co.stacoll2,
1390              co.stacoll3,
1391              co.stacoll4,
1392              co.stacoll5,
1393              co.stanumbers1,
1394              co.stanumbers2,
1395              co.stanumbers3,
1396              co.stanumbers4,
1397              co.stanumbers5,
1398              co.stavalues1,
1399              co.stavalues2,
1400              co.stavalues3,
1401              co.stavalues4,
1402              co.stavalues5
1403         FROM dbms_stats.column_stats_effective co
1404         JOIN pg_attribute a
1405           ON (co.starelid = a.attrelid AND co.staattnum = a.attnum)
1406         JOIN pg_type t
1407           ON a.atttypid = t.oid
1408         JOIN pg_namespace n1
1409           ON t.typnamespace = n1.oid
1410        RIGHT JOIN dbms_stats.relation_stats_effective r
1411           ON co.starelid = r.relid
1412         JOIN pg_catalog.pg_class cl
1413           ON r.relid = cl.oid
1414         JOIN pg_catalog.pg_namespace n2
1415           ON cl.relnamespace = n2.oid
1416        -- WHERE n2.nspname = 'public'
1417        -- AND cl.relname = 'test'
1418        -- AND a.attname = 'id'
1419  WHERE n2.nspname = 's0'
1420        ORDER BY starelid, staattnum)
1421 TO STDOUT
1422 (FORMAT 'binary');
1423 \o
1424 COMMIT;
1425 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
1426 SELECT * FROM work_v;
1427  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 |    stavalues1    | stavalues2 |       stavalues3       | stavalues4 | stavalues5 
1428 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------------------+------------+------------
1429  s0      | sft0    |        1 |        10 |             0 |        0 | id      | pg_catalog          | int4    |        -1 | f          |          -1 |       -1 |          -1 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-1,22}     | {-1,23}     | {-1,24}     | {-1,21}     | {-1,25}     | (null)           | (null)     | {1,2,3,4,5,6,7,8,9,10} | (null)     | (null)
1430  s0      | smv0    |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |          -1 |       -1 |          -1 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-1,22}     | {-1,23}     | {-1,24}     | {-1,21}     | {-1,25}     | (null)           | (null)     | {1,2}                  | (null)     | (null)
1431  s0      | smv0    |        1 |         2 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | f          |          -2 |       -2 |          -2 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-2,22}     | {-2,23}     | {-2,24}     | {-2,21}     | {-2,25}     | (null)           | (null)     | {10,20}                | (null)     | (null)
1432  s0      | smv0    |        1 |         2 |             1 |        1 | txt     | pg_catalog          | text    |        -1 | f          |          -3 |       -3 |          -3 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-3,22}     | {-3,23}     | {-3,24}     | {-3,21}     | {-3,25}     | (null)           | (null)     | {1,test}               | (null)     | (null)
1433  s0      | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2}            | (null)     | (null)                 | (null)     | (null)
1434  s0      | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | t          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2,4,5,6}      | (null)     | (null)                 | (null)     | (null)
1435  s0      | st0     |        1 |         2 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {10,20}          | (null)     | (null)                 | (null)     | (null)
1436  s0      | st0     |        1 |         2 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | t          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {10,20,40,50,60} | (null)     | (null)                 | (null)     | (null)
1437  s0      | st0_idx |        2 |         2 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)                 | (null)     | (null)
1438  s0      | st1     |        1 |         3 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |          -1 |       -1 |          -1 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-1,22}     | {-1,23}     | {-1,24}     | {-1,21}     | {-1,25}     | (null)           | (null)     | {4,5,6}                | (null)     | (null)
1439  s0      | st1     |        1 |         3 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | f          |          -2 |       -2 |          -2 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-2,22}     | {-2,23}     | {-2,24}     | {-2,21}     | {-2,25}     | (null)           | (null)     | {40,50,60}             | (null)     | (null)
1440  s0      | st1_idx |        2 |         3 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)                 | (null)     | (null)
1441  s0      | st2     |        1 |         3 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |          -1 |       -1 |          -1 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-1,22}     | {-1,23}     | {-1,24}     | {-1,21}     | {-1,25}     | (null)           | (null)     | {1,2,3}                | (null)     | (null)
1442  s0      | st2     |        1 |         3 |             1 |        1 | txt     | pg_catalog          | text    |        -1 | f          |          -2 |       -2 |          -2 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-2,22}     | {-2,23}     | {-2,24}     | {-2,21}     | {-2,25}     | (null)           | (null)     | {1,comment,test}       | (null)     | (null)
1443  s0      | st2_idx |        2 |         3 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)                 | (null)     | (null)
1444  s0      | st3     |        0 |         0 |             0 |        0 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)                 | (null)     | (null)
1445 (16 rows)
1446
1447 \! rm doc/export_effective_stats-12.sql.sample_test
1448 TRUNCATE dbms_stats.work;
1449 -- No.16-2-3
1450 \! sed '/ORDER/i\\ WHERE cl.relname = '"\'st0\'" doc/export_effective_stats-12.sql.sample > doc/export_effective_stats-12.sql.sample_test
1451 \i doc/export_effective_stats-12.sql.sample_test
1452 /*
1453  * If you want the statistics of per-relation or per-column, please modify
1454  * nspname, relname, and attname in 'WHERE' clause.
1455  */
1456 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
1457 /*
1458  * If you want to chage the output file name, please modify the following name.
1459  */
1460 \o export_stats.dmp
1461 COPY (SELECT n2.nspname,
1462              cl.relname,
1463              r.relpages,
1464              r.reltuples,
1465              r.relallvisible,
1466              r.curpages,
1467              r.last_analyze,
1468              r.last_autoanalyze,
1469              COALESCE(a.attname, ''),
1470              n1.nspname AS schemaname_of_atttype,
1471              t.typname,
1472              a.atttypmod,
1473              co.stainherit,
1474              co.stanullfrac,
1475              co.stawidth,
1476              co.stadistinct,
1477              co.stakind1,
1478              co.stakind2,
1479              co.stakind3,
1480              co.stakind4,
1481              co.stakind5,
1482              co.staop1,
1483              co.staop2,
1484              co.staop3,
1485              co.staop4,
1486              co.staop5,
1487              co.stacoll1,
1488              co.stacoll2,
1489              co.stacoll3,
1490              co.stacoll4,
1491              co.stacoll5,
1492              co.stanumbers1,
1493              co.stanumbers2,
1494              co.stanumbers3,
1495              co.stanumbers4,
1496              co.stanumbers5,
1497              co.stavalues1,
1498              co.stavalues2,
1499              co.stavalues3,
1500              co.stavalues4,
1501              co.stavalues5
1502         FROM dbms_stats.column_stats_effective co
1503         JOIN pg_attribute a
1504           ON (co.starelid = a.attrelid AND co.staattnum = a.attnum)
1505         JOIN pg_type t
1506           ON a.atttypid = t.oid
1507         JOIN pg_namespace n1
1508           ON t.typnamespace = n1.oid
1509        RIGHT JOIN dbms_stats.relation_stats_effective r
1510           ON co.starelid = r.relid
1511         JOIN pg_catalog.pg_class cl
1512           ON r.relid = cl.oid
1513         JOIN pg_catalog.pg_namespace n2
1514           ON cl.relnamespace = n2.oid
1515        -- WHERE n2.nspname = 'public'
1516        -- AND cl.relname = 'test'
1517        -- AND a.attname = 'id'
1518  WHERE cl.relname = 'st0'
1519        ORDER BY starelid, staattnum)
1520 TO STDOUT
1521 (FORMAT 'binary');
1522 \o
1523 COMMIT;
1524 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
1525 SELECT * FROM work_v;
1526  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 |    stavalues1    | stavalues2 | stavalues3 | stavalues4 | stavalues5 
1527 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------+------------+------------
1528  public  | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2}            | (null)     | (null)     | (null)     | (null)
1529  public  | st0     |        1 |         2 |             1 |        1 | name    | pg_catalog          | bpchar  |         9 | f          |           0 |        6 |        -0.5 |        1 |        3 |        0 |        0 |        0 |   1054 |   1058 |      0 |      0 |      0 | {1}         | {1}         | (null)      | (null)      | (null)      | {"test "}        | (null)     | (null)     | (null)     | (null)
1530  s0      | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2}            | (null)     | (null)     | (null)     | (null)
1531  s0      | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | t          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2,4,5,6}      | (null)     | (null)     | (null)     | (null)
1532  s0      | st0     |        1 |         2 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {10,20}          | (null)     | (null)     | (null)     | (null)
1533  s0      | st0     |        1 |         2 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | t          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {10,20,40,50,60} | (null)     | (null)     | (null)     | (null)
1534  s1      | st0     |        1 |         4 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2,3,4}        | (null)     | (null)     | (null)     | (null)
1535  s1      | st0     |        1 |         4 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {15,25,35,45}    | (null)     | (null)     | (null)     | (null)
1536 (8 rows)
1537
1538 \! rm doc/export_effective_stats-12.sql.sample_test
1539 TRUNCATE dbms_stats.work;
1540 -- No.16-2-4
1541 \! sed '/ORDER/i\\ WHERE cl.relname = '"\'pg_toast_1262\'" doc/export_effective_stats-12.sql.sample > doc/export_effective_stats-12.sql.sample_test
1542 \i doc/export_effective_stats-12.sql.sample_test
1543 /*
1544  * If you want the statistics of per-relation or per-column, please modify
1545  * nspname, relname, and attname in 'WHERE' clause.
1546  */
1547 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
1548 /*
1549  * If you want to chage the output file name, please modify the following name.
1550  */
1551 \o export_stats.dmp
1552 COPY (SELECT n2.nspname,
1553              cl.relname,
1554              r.relpages,
1555              r.reltuples,
1556              r.relallvisible,
1557              r.curpages,
1558              r.last_analyze,
1559              r.last_autoanalyze,
1560              COALESCE(a.attname, ''),
1561              n1.nspname AS schemaname_of_atttype,
1562              t.typname,
1563              a.atttypmod,
1564              co.stainherit,
1565              co.stanullfrac,
1566              co.stawidth,
1567              co.stadistinct,
1568              co.stakind1,
1569              co.stakind2,
1570              co.stakind3,
1571              co.stakind4,
1572              co.stakind5,
1573              co.staop1,
1574              co.staop2,
1575              co.staop3,
1576              co.staop4,
1577              co.staop5,
1578              co.stacoll1,
1579              co.stacoll2,
1580              co.stacoll3,
1581              co.stacoll4,
1582              co.stacoll5,
1583              co.stanumbers1,
1584              co.stanumbers2,
1585              co.stanumbers3,
1586              co.stanumbers4,
1587              co.stanumbers5,
1588              co.stavalues1,
1589              co.stavalues2,
1590              co.stavalues3,
1591              co.stavalues4,
1592              co.stavalues5
1593         FROM dbms_stats.column_stats_effective co
1594         JOIN pg_attribute a
1595           ON (co.starelid = a.attrelid AND co.staattnum = a.attnum)
1596         JOIN pg_type t
1597           ON a.atttypid = t.oid
1598         JOIN pg_namespace n1
1599           ON t.typnamespace = n1.oid
1600        RIGHT JOIN dbms_stats.relation_stats_effective r
1601           ON co.starelid = r.relid
1602         JOIN pg_catalog.pg_class cl
1603           ON r.relid = cl.oid
1604         JOIN pg_catalog.pg_namespace n2
1605           ON cl.relnamespace = n2.oid
1606        -- WHERE n2.nspname = 'public'
1607        -- AND cl.relname = 'test'
1608        -- AND a.attname = 'id'
1609  WHERE cl.relname = 'pg_toast_1262'
1610        ORDER BY starelid, staattnum)
1611 TO STDOUT
1612 (FORMAT 'binary');
1613 \o
1614 COMMIT;
1615 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
1616 SELECT * FROM work_v;
1617  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 
1618 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------
1619 (0 rows)
1620
1621 \! rm doc/export_effective_stats-12.sql.sample_test
1622 TRUNCATE dbms_stats.work;
1623 -- No.16-2-5
1624 \! sed '/ORDER/i\\ WHERE cl.relname = '"\'st0_idx\'" doc/export_effective_stats-12.sql.sample > doc/export_effective_stats-12.sql.sample_test
1625 \i doc/export_effective_stats-12.sql.sample_test
1626 /*
1627  * If you want the statistics of per-relation or per-column, please modify
1628  * nspname, relname, and attname in 'WHERE' clause.
1629  */
1630 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
1631 /*
1632  * If you want to chage the output file name, please modify the following name.
1633  */
1634 \o export_stats.dmp
1635 COPY (SELECT n2.nspname,
1636              cl.relname,
1637              r.relpages,
1638              r.reltuples,
1639              r.relallvisible,
1640              r.curpages,
1641              r.last_analyze,
1642              r.last_autoanalyze,
1643              COALESCE(a.attname, ''),
1644              n1.nspname AS schemaname_of_atttype,
1645              t.typname,
1646              a.atttypmod,
1647              co.stainherit,
1648              co.stanullfrac,
1649              co.stawidth,
1650              co.stadistinct,
1651              co.stakind1,
1652              co.stakind2,
1653              co.stakind3,
1654              co.stakind4,
1655              co.stakind5,
1656              co.staop1,
1657              co.staop2,
1658              co.staop3,
1659              co.staop4,
1660              co.staop5,
1661              co.stacoll1,
1662              co.stacoll2,
1663              co.stacoll3,
1664              co.stacoll4,
1665              co.stacoll5,
1666              co.stanumbers1,
1667              co.stanumbers2,
1668              co.stanumbers3,
1669              co.stanumbers4,
1670              co.stanumbers5,
1671              co.stavalues1,
1672              co.stavalues2,
1673              co.stavalues3,
1674              co.stavalues4,
1675              co.stavalues5
1676         FROM dbms_stats.column_stats_effective co
1677         JOIN pg_attribute a
1678           ON (co.starelid = a.attrelid AND co.staattnum = a.attnum)
1679         JOIN pg_type t
1680           ON a.atttypid = t.oid
1681         JOIN pg_namespace n1
1682           ON t.typnamespace = n1.oid
1683        RIGHT JOIN dbms_stats.relation_stats_effective r
1684           ON co.starelid = r.relid
1685         JOIN pg_catalog.pg_class cl
1686           ON r.relid = cl.oid
1687         JOIN pg_catalog.pg_namespace n2
1688           ON cl.relnamespace = n2.oid
1689        -- WHERE n2.nspname = 'public'
1690        -- AND cl.relname = 'test'
1691        -- AND a.attname = 'id'
1692  WHERE cl.relname = 'st0_idx'
1693        ORDER BY starelid, staattnum)
1694 TO STDOUT
1695 (FORMAT 'binary');
1696 \o
1697 COMMIT;
1698 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
1699 SELECT * FROM work_v;
1700  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 
1701 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------
1702  public  | st0_idx |        2 |         2 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)     | (null)     | (null)     | (null)     | (null)
1703  s0      | st0_idx |        2 |         2 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)     | (null)     | (null)     | (null)     | (null)
1704 (2 rows)
1705
1706 \! rm doc/export_effective_stats-12.sql.sample_test
1707 TRUNCATE dbms_stats.work;
1708 -- No.16-2-6
1709 \! sed '/ORDER/i\\ WHERE cl.relname = '"\'ss0\'" doc/export_effective_stats-12.sql.sample > doc/export_effective_stats-12.sql.sample_test
1710 \i doc/export_effective_stats-12.sql.sample_test
1711 /*
1712  * If you want the statistics of per-relation or per-column, please modify
1713  * nspname, relname, and attname in 'WHERE' clause.
1714  */
1715 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
1716 /*
1717  * If you want to chage the output file name, please modify the following name.
1718  */
1719 \o export_stats.dmp
1720 COPY (SELECT n2.nspname,
1721              cl.relname,
1722              r.relpages,
1723              r.reltuples,
1724              r.relallvisible,
1725              r.curpages,
1726              r.last_analyze,
1727              r.last_autoanalyze,
1728              COALESCE(a.attname, ''),
1729              n1.nspname AS schemaname_of_atttype,
1730              t.typname,
1731              a.atttypmod,
1732              co.stainherit,
1733              co.stanullfrac,
1734              co.stawidth,
1735              co.stadistinct,
1736              co.stakind1,
1737              co.stakind2,
1738              co.stakind3,
1739              co.stakind4,
1740              co.stakind5,
1741              co.staop1,
1742              co.staop2,
1743              co.staop3,
1744              co.staop4,
1745              co.staop5,
1746              co.stacoll1,
1747              co.stacoll2,
1748              co.stacoll3,
1749              co.stacoll4,
1750              co.stacoll5,
1751              co.stanumbers1,
1752              co.stanumbers2,
1753              co.stanumbers3,
1754              co.stanumbers4,
1755              co.stanumbers5,
1756              co.stavalues1,
1757              co.stavalues2,
1758              co.stavalues3,
1759              co.stavalues4,
1760              co.stavalues5
1761         FROM dbms_stats.column_stats_effective co
1762         JOIN pg_attribute a
1763           ON (co.starelid = a.attrelid AND co.staattnum = a.attnum)
1764         JOIN pg_type t
1765           ON a.atttypid = t.oid
1766         JOIN pg_namespace n1
1767           ON t.typnamespace = n1.oid
1768        RIGHT JOIN dbms_stats.relation_stats_effective r
1769           ON co.starelid = r.relid
1770         JOIN pg_catalog.pg_class cl
1771           ON r.relid = cl.oid
1772         JOIN pg_catalog.pg_namespace n2
1773           ON cl.relnamespace = n2.oid
1774        -- WHERE n2.nspname = 'public'
1775        -- AND cl.relname = 'test'
1776        -- AND a.attname = 'id'
1777  WHERE cl.relname = 'ss0'
1778        ORDER BY starelid, staattnum)
1779 TO STDOUT
1780 (FORMAT 'binary');
1781 \o
1782 COMMIT;
1783 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
1784 SELECT * FROM work_v;
1785  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 
1786 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------
1787 (0 rows)
1788
1789 \! rm doc/export_effective_stats-12.sql.sample_test
1790 TRUNCATE dbms_stats.work;
1791 -- No.16-2-7
1792 \! sed '/ORDER/i\\ WHERE cl.relname = '"\'sc0\'" doc/export_effective_stats-12.sql.sample > doc/export_effective_stats-12.sql.sample_test
1793 \i doc/export_effective_stats-12.sql.sample_test
1794 /*
1795  * If you want the statistics of per-relation or per-column, please modify
1796  * nspname, relname, and attname in 'WHERE' clause.
1797  */
1798 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
1799 /*
1800  * If you want to chage the output file name, please modify the following name.
1801  */
1802 \o export_stats.dmp
1803 COPY (SELECT n2.nspname,
1804              cl.relname,
1805              r.relpages,
1806              r.reltuples,
1807              r.relallvisible,
1808              r.curpages,
1809              r.last_analyze,
1810              r.last_autoanalyze,
1811              COALESCE(a.attname, ''),
1812              n1.nspname AS schemaname_of_atttype,
1813              t.typname,
1814              a.atttypmod,
1815              co.stainherit,
1816              co.stanullfrac,
1817              co.stawidth,
1818              co.stadistinct,
1819              co.stakind1,
1820              co.stakind2,
1821              co.stakind3,
1822              co.stakind4,
1823              co.stakind5,
1824              co.staop1,
1825              co.staop2,
1826              co.staop3,
1827              co.staop4,
1828              co.staop5,
1829              co.stacoll1,
1830              co.stacoll2,
1831              co.stacoll3,
1832              co.stacoll4,
1833              co.stacoll5,
1834              co.stanumbers1,
1835              co.stanumbers2,
1836              co.stanumbers3,
1837              co.stanumbers4,
1838              co.stanumbers5,
1839              co.stavalues1,
1840              co.stavalues2,
1841              co.stavalues3,
1842              co.stavalues4,
1843              co.stavalues5
1844         FROM dbms_stats.column_stats_effective co
1845         JOIN pg_attribute a
1846           ON (co.starelid = a.attrelid AND co.staattnum = a.attnum)
1847         JOIN pg_type t
1848           ON a.atttypid = t.oid
1849         JOIN pg_namespace n1
1850           ON t.typnamespace = n1.oid
1851        RIGHT JOIN dbms_stats.relation_stats_effective r
1852           ON co.starelid = r.relid
1853         JOIN pg_catalog.pg_class cl
1854           ON r.relid = cl.oid
1855         JOIN pg_catalog.pg_namespace n2
1856           ON cl.relnamespace = n2.oid
1857        -- WHERE n2.nspname = 'public'
1858        -- AND cl.relname = 'test'
1859        -- AND a.attname = 'id'
1860  WHERE cl.relname = 'sc0'
1861        ORDER BY starelid, staattnum)
1862 TO STDOUT
1863 (FORMAT 'binary');
1864 \o
1865 COMMIT;
1866 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
1867 SELECT * FROM work_v;
1868  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 
1869 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------
1870 (0 rows)
1871
1872 \! rm doc/export_effective_stats-12.sql.sample_test
1873 TRUNCATE dbms_stats.work;
1874 -- No.16-2-8
1875 \! sed '/ORDER/i\\ WHERE cl.relname = '"\'sft0\'" doc/export_effective_stats-12.sql.sample > doc/export_effective_stats-12.sql.sample_test
1876 \i doc/export_effective_stats-12.sql.sample_test
1877 /*
1878  * If you want the statistics of per-relation or per-column, please modify
1879  * nspname, relname, and attname in 'WHERE' clause.
1880  */
1881 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
1882 /*
1883  * If you want to chage the output file name, please modify the following name.
1884  */
1885 \o export_stats.dmp
1886 COPY (SELECT n2.nspname,
1887              cl.relname,
1888              r.relpages,
1889              r.reltuples,
1890              r.relallvisible,
1891              r.curpages,
1892              r.last_analyze,
1893              r.last_autoanalyze,
1894              COALESCE(a.attname, ''),
1895              n1.nspname AS schemaname_of_atttype,
1896              t.typname,
1897              a.atttypmod,
1898              co.stainherit,
1899              co.stanullfrac,
1900              co.stawidth,
1901              co.stadistinct,
1902              co.stakind1,
1903              co.stakind2,
1904              co.stakind3,
1905              co.stakind4,
1906              co.stakind5,
1907              co.staop1,
1908              co.staop2,
1909              co.staop3,
1910              co.staop4,
1911              co.staop5,
1912              co.stacoll1,
1913              co.stacoll2,
1914              co.stacoll3,
1915              co.stacoll4,
1916              co.stacoll5,
1917              co.stanumbers1,
1918              co.stanumbers2,
1919              co.stanumbers3,
1920              co.stanumbers4,
1921              co.stanumbers5,
1922              co.stavalues1,
1923              co.stavalues2,
1924              co.stavalues3,
1925              co.stavalues4,
1926              co.stavalues5
1927         FROM dbms_stats.column_stats_effective co
1928         JOIN pg_attribute a
1929           ON (co.starelid = a.attrelid AND co.staattnum = a.attnum)
1930         JOIN pg_type t
1931           ON a.atttypid = t.oid
1932         JOIN pg_namespace n1
1933           ON t.typnamespace = n1.oid
1934        RIGHT JOIN dbms_stats.relation_stats_effective r
1935           ON co.starelid = r.relid
1936         JOIN pg_catalog.pg_class cl
1937           ON r.relid = cl.oid
1938         JOIN pg_catalog.pg_namespace n2
1939           ON cl.relnamespace = n2.oid
1940        -- WHERE n2.nspname = 'public'
1941        -- AND cl.relname = 'test'
1942        -- AND a.attname = 'id'
1943  WHERE cl.relname = 'sft0'
1944        ORDER BY starelid, staattnum)
1945 TO STDOUT
1946 (FORMAT 'binary');
1947 \o
1948 COMMIT;
1949 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
1950 SELECT * FROM work_v;
1951  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 |       stavalues3       | stavalues4 | stavalues5 
1952 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------------------+------------+------------
1953  s0      | sft0    |        1 |        10 |             0 |        0 | id      | pg_catalog          | int4    |        -1 | f          |          -1 |       -1 |          -1 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-1,22}     | {-1,23}     | {-1,24}     | {-1,21}     | {-1,25}     | (null)     | (null)     | {1,2,3,4,5,6,7,8,9,10} | (null)     | (null)
1954 (1 row)
1955
1956 \! rm doc/export_effective_stats-12.sql.sample_test
1957 TRUNCATE dbms_stats.work;
1958 -- No.16-2-9
1959 \! sed '/ORDER/i\\ WHERE cl.relname = '"\'smv0\'" doc/export_effective_stats-12.sql.sample > doc/export_effective_stats-12.sql.sample_test
1960 \i doc/export_effective_stats-12.sql.sample_test
1961 /*
1962  * If you want the statistics of per-relation or per-column, please modify
1963  * nspname, relname, and attname in 'WHERE' clause.
1964  */
1965 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
1966 /*
1967  * If you want to chage the output file name, please modify the following name.
1968  */
1969 \o export_stats.dmp
1970 COPY (SELECT n2.nspname,
1971              cl.relname,
1972              r.relpages,
1973              r.reltuples,
1974              r.relallvisible,
1975              r.curpages,
1976              r.last_analyze,
1977              r.last_autoanalyze,
1978              COALESCE(a.attname, ''),
1979              n1.nspname AS schemaname_of_atttype,
1980              t.typname,
1981              a.atttypmod,
1982              co.stainherit,
1983              co.stanullfrac,
1984              co.stawidth,
1985              co.stadistinct,
1986              co.stakind1,
1987              co.stakind2,
1988              co.stakind3,
1989              co.stakind4,
1990              co.stakind5,
1991              co.staop1,
1992              co.staop2,
1993              co.staop3,
1994              co.staop4,
1995              co.staop5,
1996              co.stacoll1,
1997              co.stacoll2,
1998              co.stacoll3,
1999              co.stacoll4,
2000              co.stacoll5,
2001              co.stanumbers1,
2002              co.stanumbers2,
2003              co.stanumbers3,
2004              co.stanumbers4,
2005              co.stanumbers5,
2006              co.stavalues1,
2007              co.stavalues2,
2008              co.stavalues3,
2009              co.stavalues4,
2010              co.stavalues5
2011         FROM dbms_stats.column_stats_effective co
2012         JOIN pg_attribute a
2013           ON (co.starelid = a.attrelid AND co.staattnum = a.attnum)
2014         JOIN pg_type t
2015           ON a.atttypid = t.oid
2016         JOIN pg_namespace n1
2017           ON t.typnamespace = n1.oid
2018        RIGHT JOIN dbms_stats.relation_stats_effective r
2019           ON co.starelid = r.relid
2020         JOIN pg_catalog.pg_class cl
2021           ON r.relid = cl.oid
2022         JOIN pg_catalog.pg_namespace n2
2023           ON cl.relnamespace = n2.oid
2024        -- WHERE n2.nspname = 'public'
2025        -- AND cl.relname = 'test'
2026        -- AND a.attname = 'id'
2027  WHERE cl.relname = 'smv0'
2028        ORDER BY starelid, staattnum)
2029 TO STDOUT
2030 (FORMAT 'binary');
2031 \o
2032 COMMIT;
2033 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
2034 SELECT * FROM work_v;
2035  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 
2036 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------
2037  s0      | smv0    |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |          -1 |       -1 |          -1 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-1,22}     | {-1,23}     | {-1,24}     | {-1,21}     | {-1,25}     | (null)     | (null)     | {1,2}      | (null)     | (null)
2038  s0      | smv0    |        1 |         2 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | f          |          -2 |       -2 |          -2 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-2,22}     | {-2,23}     | {-2,24}     | {-2,21}     | {-2,25}     | (null)     | (null)     | {10,20}    | (null)     | (null)
2039  s0      | smv0    |        1 |         2 |             1 |        1 | txt     | pg_catalog          | text    |        -1 | f          |          -3 |       -3 |          -3 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-3,22}     | {-3,23}     | {-3,24}     | {-3,21}     | {-3,25}     | (null)     | (null)     | {1,test}   | (null)     | (null)
2040 (3 rows)
2041
2042 \! rm doc/export_effective_stats-12.sql.sample_test
2043 TRUNCATE dbms_stats.work;
2044 -- No.16-2-10
2045 \! sed '/ORDER/i\\ WHERE n2.nspname = '"\'s0\'"' AND a.attname = '"\'id\'" doc/export_effective_stats-12.sql.sample > doc/export_effective_stats-12.sql.sample_test
2046 \i doc/export_effective_stats-12.sql.sample_test
2047 /*
2048  * If you want the statistics of per-relation or per-column, please modify
2049  * nspname, relname, and attname in 'WHERE' clause.
2050  */
2051 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
2052 /*
2053  * If you want to chage the output file name, please modify the following name.
2054  */
2055 \o export_stats.dmp
2056 COPY (SELECT n2.nspname,
2057              cl.relname,
2058              r.relpages,
2059              r.reltuples,
2060              r.relallvisible,
2061              r.curpages,
2062              r.last_analyze,
2063              r.last_autoanalyze,
2064              COALESCE(a.attname, ''),
2065              n1.nspname AS schemaname_of_atttype,
2066              t.typname,
2067              a.atttypmod,
2068              co.stainherit,
2069              co.stanullfrac,
2070              co.stawidth,
2071              co.stadistinct,
2072              co.stakind1,
2073              co.stakind2,
2074              co.stakind3,
2075              co.stakind4,
2076              co.stakind5,
2077              co.staop1,
2078              co.staop2,
2079              co.staop3,
2080              co.staop4,
2081              co.staop5,
2082              co.stacoll1,
2083              co.stacoll2,
2084              co.stacoll3,
2085              co.stacoll4,
2086              co.stacoll5,
2087              co.stanumbers1,
2088              co.stanumbers2,
2089              co.stanumbers3,
2090              co.stanumbers4,
2091              co.stanumbers5,
2092              co.stavalues1,
2093              co.stavalues2,
2094              co.stavalues3,
2095              co.stavalues4,
2096              co.stavalues5
2097         FROM dbms_stats.column_stats_effective co
2098         JOIN pg_attribute a
2099           ON (co.starelid = a.attrelid AND co.staattnum = a.attnum)
2100         JOIN pg_type t
2101           ON a.atttypid = t.oid
2102         JOIN pg_namespace n1
2103           ON t.typnamespace = n1.oid
2104        RIGHT JOIN dbms_stats.relation_stats_effective r
2105           ON co.starelid = r.relid
2106         JOIN pg_catalog.pg_class cl
2107           ON r.relid = cl.oid
2108         JOIN pg_catalog.pg_namespace n2
2109           ON cl.relnamespace = n2.oid
2110        -- WHERE n2.nspname = 'public'
2111        -- AND cl.relname = 'test'
2112        -- AND a.attname = 'id'
2113  WHERE n2.nspname = 's0' AND a.attname = 'id'
2114        ORDER BY starelid, staattnum)
2115 TO STDOUT
2116 (FORMAT 'binary');
2117 \o
2118 COMMIT;
2119 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
2120 SELECT * FROM work_v;
2121  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1  | stavalues2 |       stavalues3       | stavalues4 | stavalues5 
2122 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+-------------+------------+------------------------+------------+------------
2123  s0      | sft0    |        1 |        10 |             0 |        0 | id      | pg_catalog          | int4    |        -1 | f          |          -1 |       -1 |          -1 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-1,22}     | {-1,23}     | {-1,24}     | {-1,21}     | {-1,25}     | (null)      | (null)     | {1,2,3,4,5,6,7,8,9,10} | (null)     | (null)
2124  s0      | smv0    |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |          -1 |       -1 |          -1 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-1,22}     | {-1,23}     | {-1,24}     | {-1,21}     | {-1,25}     | (null)      | (null)     | {1,2}                  | (null)     | (null)
2125  s0      | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2}       | (null)     | (null)                 | (null)     | (null)
2126  s0      | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | t          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2,4,5,6} | (null)     | (null)                 | (null)     | (null)
2127  s0      | st1     |        1 |         3 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |          -1 |       -1 |          -1 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-1,22}     | {-1,23}     | {-1,24}     | {-1,21}     | {-1,25}     | (null)      | (null)     | {4,5,6}                | (null)     | (null)
2128  s0      | st2     |        1 |         3 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |          -1 |       -1 |          -1 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-1,22}     | {-1,23}     | {-1,24}     | {-1,21}     | {-1,25}     | (null)      | (null)     | {1,2,3}                | (null)     | (null)
2129 (6 rows)
2130
2131 \! rm doc/export_effective_stats-12.sql.sample_test
2132 TRUNCATE dbms_stats.work;
2133 -- No.16-2-11
2134 \! sed '/ORDER/i\\ WHERE n2.nspname = '"\'s0\'"' AND a.attname IS NULL' doc/export_effective_stats-12.sql.sample > doc/export_effective_stats-12.sql.sample_test
2135 \i doc/export_effective_stats-12.sql.sample_test
2136 /*
2137  * If you want the statistics of per-relation or per-column, please modify
2138  * nspname, relname, and attname in 'WHERE' clause.
2139  */
2140 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
2141 /*
2142  * If you want to chage the output file name, please modify the following name.
2143  */
2144 \o export_stats.dmp
2145 COPY (SELECT n2.nspname,
2146              cl.relname,
2147              r.relpages,
2148              r.reltuples,
2149              r.relallvisible,
2150              r.curpages,
2151              r.last_analyze,
2152              r.last_autoanalyze,
2153              COALESCE(a.attname, ''),
2154              n1.nspname AS schemaname_of_atttype,
2155              t.typname,
2156              a.atttypmod,
2157              co.stainherit,
2158              co.stanullfrac,
2159              co.stawidth,
2160              co.stadistinct,
2161              co.stakind1,
2162              co.stakind2,
2163              co.stakind3,
2164              co.stakind4,
2165              co.stakind5,
2166              co.staop1,
2167              co.staop2,
2168              co.staop3,
2169              co.staop4,
2170              co.staop5,
2171              co.stacoll1,
2172              co.stacoll2,
2173              co.stacoll3,
2174              co.stacoll4,
2175              co.stacoll5,
2176              co.stanumbers1,
2177              co.stanumbers2,
2178              co.stanumbers3,
2179              co.stanumbers4,
2180              co.stanumbers5,
2181              co.stavalues1,
2182              co.stavalues2,
2183              co.stavalues3,
2184              co.stavalues4,
2185              co.stavalues5
2186         FROM dbms_stats.column_stats_effective co
2187         JOIN pg_attribute a
2188           ON (co.starelid = a.attrelid AND co.staattnum = a.attnum)
2189         JOIN pg_type t
2190           ON a.atttypid = t.oid
2191         JOIN pg_namespace n1
2192           ON t.typnamespace = n1.oid
2193        RIGHT JOIN dbms_stats.relation_stats_effective r
2194           ON co.starelid = r.relid
2195         JOIN pg_catalog.pg_class cl
2196           ON r.relid = cl.oid
2197         JOIN pg_catalog.pg_namespace n2
2198           ON cl.relnamespace = n2.oid
2199        -- WHERE n2.nspname = 'public'
2200        -- AND cl.relname = 'test'
2201        -- AND a.attname = 'id'
2202  WHERE n2.nspname = 's0' AND a.attname IS NULL
2203        ORDER BY starelid, staattnum)
2204 TO STDOUT
2205 (FORMAT 'binary');
2206 \o
2207 COMMIT;
2208 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
2209 SELECT * FROM work_v;
2210  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 
2211 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------
2212  s0      | st0_idx |        2 |         2 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)     | (null)     | (null)     | (null)     | (null)
2213  s0      | st1_idx |        2 |         3 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)     | (null)     | (null)     | (null)     | (null)
2214  s0      | st2_idx |        2 |         3 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)     | (null)     | (null)     | (null)     | (null)
2215  s0      | st3     |        0 |         0 |             0 |        0 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)     | (null)     | (null)     | (null)     | (null)
2216 (4 rows)
2217
2218 \! rm doc/export_effective_stats-12.sql.sample_test
2219 TRUNCATE dbms_stats.work;
2220 -- No.16-2-12
2221 \! sed '/ORDER/i\\ WHERE n2.nspname = '"\'s0\'"' AND cl.relname IS NULL' doc/export_effective_stats-12.sql.sample > doc/export_effective_stats-12.sql.sample_test
2222 \i doc/export_effective_stats-12.sql.sample_test
2223 /*
2224  * If you want the statistics of per-relation or per-column, please modify
2225  * nspname, relname, and attname in 'WHERE' clause.
2226  */
2227 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
2228 /*
2229  * If you want to chage the output file name, please modify the following name.
2230  */
2231 \o export_stats.dmp
2232 COPY (SELECT n2.nspname,
2233              cl.relname,
2234              r.relpages,
2235              r.reltuples,
2236              r.relallvisible,
2237              r.curpages,
2238              r.last_analyze,
2239              r.last_autoanalyze,
2240              COALESCE(a.attname, ''),
2241              n1.nspname AS schemaname_of_atttype,
2242              t.typname,
2243              a.atttypmod,
2244              co.stainherit,
2245              co.stanullfrac,
2246              co.stawidth,
2247              co.stadistinct,
2248              co.stakind1,
2249              co.stakind2,
2250              co.stakind3,
2251              co.stakind4,
2252              co.stakind5,
2253              co.staop1,
2254              co.staop2,
2255              co.staop3,
2256              co.staop4,
2257              co.staop5,
2258              co.stacoll1,
2259              co.stacoll2,
2260              co.stacoll3,
2261              co.stacoll4,
2262              co.stacoll5,
2263              co.stanumbers1,
2264              co.stanumbers2,
2265              co.stanumbers3,
2266              co.stanumbers4,
2267              co.stanumbers5,
2268              co.stavalues1,
2269              co.stavalues2,
2270              co.stavalues3,
2271              co.stavalues4,
2272              co.stavalues5
2273         FROM dbms_stats.column_stats_effective co
2274         JOIN pg_attribute a
2275           ON (co.starelid = a.attrelid AND co.staattnum = a.attnum)
2276         JOIN pg_type t
2277           ON a.atttypid = t.oid
2278         JOIN pg_namespace n1
2279           ON t.typnamespace = n1.oid
2280        RIGHT JOIN dbms_stats.relation_stats_effective r
2281           ON co.starelid = r.relid
2282         JOIN pg_catalog.pg_class cl
2283           ON r.relid = cl.oid
2284         JOIN pg_catalog.pg_namespace n2
2285           ON cl.relnamespace = n2.oid
2286        -- WHERE n2.nspname = 'public'
2287        -- AND cl.relname = 'test'
2288        -- AND a.attname = 'id'
2289  WHERE n2.nspname = 's0' AND cl.relname IS NULL
2290        ORDER BY starelid, staattnum)
2291 TO STDOUT
2292 (FORMAT 'binary');
2293 \o
2294 COMMIT;
2295 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
2296 SELECT * FROM work_v;
2297  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 
2298 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------
2299 (0 rows)
2300
2301 \! rm doc/export_effective_stats-12.sql.sample_test
2302 TRUNCATE dbms_stats.work;
2303 /*
2304  * Stab function dbms_stats.import
2305  */
2306 ALTER FUNCTION dbms_stats.import(
2307     nspname text,
2308     relid regclass,
2309     attname text,
2310     src text
2311 ) RENAME TO truth_import;
2312 CREATE FUNCTION dbms_stats.import(
2313     nspname text,
2314     relid regclass,
2315     attname text,
2316     src text
2317 ) RETURNS void AS
2318 $$
2319 BEGIN
2320     RAISE NOTICE 'arguments are "%", "%", "%", "%"', $1, $2, $3, $4;
2321     RETURN;
2322 END
2323 $$
2324 LANGUAGE plpgsql;
2325 /*
2326  * No.17-1 dbms_stats.import_database_stats(src)
2327  */
2328 -- No.17-1-1
2329 SELECT dbms_stats.import_database_stats('@abs_srcdir@/export_stats.dmp');
2330 NOTICE:  arguments are "<NULL>", "<NULL>", "<NULL>", "@abs_srcdir@/export_stats.dmp"
2331  import_database_stats 
2332 -----------------------
2333  
2334 (1 row)
2335
2336 /*
2337  * No.17-2 dbms_stats.import_schema_stats(schemaname, src)
2338  */
2339 -- No.17-2-1
2340 SELECT dbms_stats.import_schema_stats('s0', '@abs_srcdir@/export_stats.dmp');
2341 NOTICE:  arguments are "s0", "<NULL>", "<NULL>", "@abs_srcdir@/export_stats.dmp"
2342  import_schema_stats 
2343 ---------------------
2344  
2345 (1 row)
2346
2347 /*
2348  * No.17-3 dbms_stats.import_table_stats(relid, src)
2349  */
2350 -- No.17-3-1
2351 SELECT dbms_stats.import_table_stats('s0.st0', '@abs_srcdir@/export_stats.dmp');
2352 NOTICE:  arguments are "<NULL>", "s0.st0", "<NULL>", "@abs_srcdir@/export_stats.dmp"
2353  import_table_stats 
2354 --------------------
2355  
2356 (1 row)
2357
2358 /*
2359  * No.17-4 dbms_stats.import_table_stats(schemaname, tablename, src)
2360  */
2361 -- No.17-4-1
2362 SELECT dbms_stats.import_table_stats('s0', 'st0', '@abs_srcdir@/export_stats.dmp');
2363 NOTICE:  arguments are "<NULL>", "s0.st0", "<NULL>", "@abs_srcdir@/export_stats.dmp"
2364  import_table_stats 
2365 --------------------
2366  
2367 (1 row)
2368
2369 /*
2370  * No.17-5 dbms_stats.import_column_stats (relid, attname, src)
2371  */
2372 -- No.17-5-1
2373 SELECT dbms_stats.import_column_stats('s0.st0', 'id', '@abs_srcdir@/export_stats.dmp');
2374 NOTICE:  arguments are "<NULL>", "s0.st0", "id", "@abs_srcdir@/export_stats.dmp"
2375  import_column_stats 
2376 ---------------------
2377  
2378 (1 row)
2379
2380 /*
2381  * No.17-6 dbms_stats.import_column_stats (schemaname, tablename, attname, src)
2382  */
2383 -- No.17-6-1
2384 SELECT dbms_stats.import_column_stats('s0', 'st0', 'id','@abs_srcdir@/export_stats.dmp');
2385 NOTICE:  arguments are "<NULL>", "s0.st0", "id", "@abs_srcdir@/export_stats.dmp"
2386  import_column_stats 
2387 ---------------------
2388  
2389 (1 row)
2390
2391 /*
2392  * Delete stab function dbms_stats.import
2393  */
2394 DROP FUNCTION dbms_stats.import(
2395     nspname text,
2396     relid regclass,
2397     attname text,
2398     src text
2399 );
2400 ALTER FUNCTION dbms_stats.truth_import(
2401     nspname text,
2402     relid regclass,
2403     attname text,
2404     src text
2405 ) RENAME TO import;