From 668127de797bf0fce9aa31100276e2dd964a6b37 Mon Sep 17 00:00:00 2001 From: kato_s Date: Wed, 20 Nov 2019 07:57:57 +0000 Subject: [PATCH 1/2] fix build for PG12 --- doc/export_effective_stats-12.sql.sample | 73 + doc/export_plain_stats-12.sql.sample | 79 + expected/init-12.out | 118 + expected/init-common.out | 1 - expected/ut-12.out | 10125 +++++++++++++++++++++ ext_scripts/pg_dbms_stats--1.3.11-12.sql | 1613 ++++ import.c | 6 + input/ut_imp_exp-12.source | 295 + output/ut_imp_exp-12.source | 2398 +++++ pg_dbms_stats.c | 12 +- sql/init-12.sql | 118 + sql/init-common.sql | 1 - sql/ut-12.sql | 2829 ++++++ 13 files changed, 17661 insertions(+), 7 deletions(-) create mode 100644 doc/export_effective_stats-12.sql.sample create mode 100644 doc/export_plain_stats-12.sql.sample create mode 100644 expected/init-12.out create mode 100644 expected/ut-12.out create mode 100644 ext_scripts/pg_dbms_stats--1.3.11-12.sql create mode 100644 input/ut_imp_exp-12.source create mode 100644 output/ut_imp_exp-12.source create mode 100644 sql/init-12.sql create mode 100644 sql/ut-12.sql diff --git a/doc/export_effective_stats-12.sql.sample b/doc/export_effective_stats-12.sql.sample new file mode 100644 index 0000000..0b84cd1 --- /dev/null +++ b/doc/export_effective_stats-12.sql.sample @@ -0,0 +1,73 @@ +/* + * If you want the statistics of per-relation or per-column, please modify + * nspname, relname, and attname in 'WHERE' clause. + */ + +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE; +/* + * If you want to chage the output file name, please modify the following name. + */ +\o export_stats.dmp + +COPY (SELECT n2.nspname, + cl.relname, + r.relpages, + r.reltuples, + r.relallvisible, + r.curpages, + r.last_analyze, + r.last_autoanalyze, + COALESCE(a.attname, ''), + n1.nspname AS schemaname_of_atttype, + t.typname, + a.atttypmod, + co.stainherit, + co.stanullfrac, + co.stawidth, + co.stadistinct, + co.stakind1, + co.stakind2, + co.stakind3, + co.stakind4, + co.stakind5, + co.staop1, + co.staop2, + co.staop3, + co.staop4, + co.staop5, + co.stacoll1, + co.stacoll2, + co.stacoll3, + co.stacoll4, + co.stacoll5, + co.stanumbers1, + co.stanumbers2, + co.stanumbers3, + co.stanumbers4, + co.stanumbers5, + co.stavalues1, + co.stavalues2, + co.stavalues3, + co.stavalues4, + co.stavalues5 + FROM dbms_stats.column_stats_effective co + JOIN pg_attribute a + ON (co.starelid = a.attrelid AND co.staattnum = a.attnum) + JOIN pg_type t + ON a.atttypid = t.oid + JOIN pg_namespace n1 + ON t.typnamespace = n1.oid + RIGHT JOIN dbms_stats.relation_stats_effective r + ON co.starelid = r.relid + JOIN pg_catalog.pg_class cl + ON r.relid = cl.oid + JOIN pg_catalog.pg_namespace n2 + ON cl.relnamespace = n2.oid + -- WHERE n2.nspname = 'public' + -- AND cl.relname = 'test' + -- AND a.attname = 'id' + ORDER BY starelid, staattnum) +TO STDOUT +(FORMAT 'binary'); +\o +COMMIT; diff --git a/doc/export_plain_stats-12.sql.sample b/doc/export_plain_stats-12.sql.sample new file mode 100644 index 0000000..5f553e4 --- /dev/null +++ b/doc/export_plain_stats-12.sql.sample @@ -0,0 +1,79 @@ +/* + * If you want the statistics of per-relation or per-column, please modify + * nspname, relname, and attname in 'WHERE' clause. + */ + +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE; +/* + * If you want to chage the output file name, please modify the following name. + */ +\o export_stats.dmp + +COPY (SELECT n2.nspname, + c.relname, + c.relpages, + c.reltuples, + c.relallvisible, + (pg_relation_size(c.oid) / current_setting('block_size')::int4)::int4 + AS curpages, + pg_catalog.pg_stat_get_last_analyze_time(c.oid) + AS last_analyze, + pg_catalog.pg_stat_get_last_autoanalyze_time(c.oid) + AS last_autoanalyze, + COALESCE(a.attname, ''), + n1.nspname AS schemaname_of_atttype, + t.typname, + a.atttypmod, + s.stainherit, + s.stanullfrac, + s.stawidth, + s.stadistinct, + s.stakind1, + s.stakind2, + s.stakind3, + s.stakind4, + s.stakind5, + s.staop1, + s.staop2, + s.staop3, + s.staop4, + s.staop5, + s.stacoll1, + s.stacoll2, + s.stacoll3, + s.stacoll4, + s.stacoll5, + s.stanumbers1, + s.stanumbers2, + s.stanumbers3, + s.stanumbers4, + s.stanumbers5, + s.stavalues1, + s.stavalues2, + s.stavalues3, + s.stavalues4, + s.stavalues5 + FROM pg_statistic s + JOIN pg_attribute a + ON (s.starelid = a.attrelid AND s.staattnum = a.attnum) + JOIN pg_type t + ON a.atttypid = t.oid + JOIN pg_namespace n1 + ON t.typnamespace = n1.oid + RIGHT JOIN pg_catalog.pg_class c + ON s.starelid = c.oid + JOIN pg_catalog.pg_namespace n2 + ON c.relnamespace = n2.oid + WHERE c.relkind IN ('r', 'i', 'f', 'm') + AND NOT n2.nspname IN ('pg_catalog', + 'pg_toast', + 'information_schema', + 'dbms_stats') + -- AND n2.nspname = 'public' + -- AND c.relname = 'test' + -- AND a.attname = 'id' + ORDER BY starelid, staattnum) +TO STDOUT +(FORMAT 'binary'); +\o +COMMIT; diff --git a/expected/init-12.out b/expected/init-12.out new file mode 100644 index 0000000..477d194 --- /dev/null +++ b/expected/init-12.out @@ -0,0 +1,118 @@ +CREATE MATERIALIZED VIEW s0.smv0 AS +SELECT st0.id, + st0.num, + st2.txt + FROM s0.st0,s0.st2 + WHERE st0.id = st2.id + ORDER BY id; +CREATE VIEW plain_relations_statistic_v AS +SELECT oid::regclass, + relpages, + reltuples, + relallvisible, + pg_relation_size(oid) / 8192 curpages + FROM pg_class + ORDER BY oid::regclass::text; +CREATE VIEW relations_locked_v AS +SELECT relid::regclass, + relname, + relpages, + reltuples, + relallvisible, + curpages + FROM dbms_stats.relation_stats_locked + ORDER BY relid; +CREATE VIEW relations_backup_v AS +SELECT id, + relid::regclass, + relname, + relpages, + reltuples, + relallvisible, + curpages + FROM dbms_stats.relation_stats_backup + ORDER BY id, relid; +CREATE VIEW plain_columns_statistic_v AS +SELECT starelid::regclass, staattnum, stainherit, + stanullfrac, stawidth, stadistinct, + stakind1, stakind2, stakind3, stakind4, stakind5, + staop1, staop2, staop3, staop4, staop5, + stanumbers1, stanumbers2, stanumbers3, stanumbers4, stanumbers5, + stavalues1::text, stavalues2::text, stavalues3::text, stavalues4::text, stavalues5::text + FROM pg_statistic + ORDER BY starelid, staattnum, stainherit; +CREATE VIEW columns_locked_v AS +SELECT starelid::regclass, staattnum, attname, stainherit, + stanullfrac, stawidth, stadistinct, + stakind1, stakind2, stakind3, stakind4, stakind5, + staop1, staop2, staop3, staop4, staop5, + stanumbers1, stanumbers2, stanumbers3, stanumbers4, stanumbers5, + stavalues1, stavalues2, stavalues3, stavalues4, stavalues5 + FROM dbms_stats.column_stats_locked c + JOIN pg_attribute a + ON (c.starelid = a.attrelid AND c.staattnum = a.attnum) + ORDER BY starelid, staattnum, stainherit; +CREATE VIEW columns_backup_v AS +SELECT id, statypid, + starelid::regclass, staattnum, stainherit, + stanullfrac, stawidth, stadistinct, + stakind1, stakind2, stakind3, stakind4, stakind5, + staop1, staop2, staop3, staop4, staop5, + stanumbers1, stanumbers2, stanumbers3, stanumbers4, stanumbers5, + stavalues1, stavalues2, stavalues3, stavalues4, stavalues5 + FROM dbms_stats.column_stats_backup + ORDER BY id, starelid, staattnum, stainherit; +CREATE TABLE dbms_stats.work ( + nspname name NOT NULL, + relname name NOT NULL, + relpages int4 NOT NULL, + reltuples float4 NOT NULL, + relallvisible int4 NOT NULL, + curpages int4 NOT NULL, + last_analyze timestamp with time zone, + last_autoanalyze timestamp with time zone, + attname name, + nspname_of_typename name, + typname name, + atttypmod int4, + stainherit bool, + stanullfrac float4, + stawidth int4, + stadistinct float4, + stakind1 int2, + stakind2 int2, + stakind3 int2, + stakind4 int2, + stakind5 int2, + staop1 oid, + staop2 oid, + staop3 oid, + staop4 oid, + staop5 oid, + stacoll1 oid, + stacoll2 oid, + stacoll3 oid, + stacoll4 oid, + stacoll5 oid, + stanumbers1 float4[], + stanumbers2 float4[], + stanumbers3 float4[], + stanumbers4 float4[], + stanumbers5 float4[], + stavalues1 dbms_stats.anyarray, + stavalues2 dbms_stats.anyarray, + stavalues3 dbms_stats.anyarray, + stavalues4 dbms_stats.anyarray + ,stavalues5 dbms_stats.anyarray +) WITH (autovacuum_enabled = 'false'); +CREATE VIEW work_v AS +SELECT 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 + FROM dbms_stats.work + ORDER BY nspname, relname, attname, stainherit; +ANALYZE s0.sft0; diff --git a/expected/init-common.out b/expected/init-common.out index 0b93da8..1929f1b 100644 --- a/expected/init-common.out +++ b/expected/init-common.out @@ -10,7 +10,6 @@ CREATE EXTENSION pg_dbms_stats; SET client_min_messages = warning; DROP ROLE IF EXISTS regular_user; CREATE ROLE regular_user LOGIN; -SET client_min_messages = fatal; DROP ROLE IF EXISTS super_user; CREATE ROLE super_user SUPERUSER CREATEDB CREATEROLE INHERIT LOGIN; -- create object diff --git a/expected/ut-12.out b/expected/ut-12.out new file mode 100644 index 0000000..7e75dde --- /dev/null +++ b/expected/ut-12.out @@ -0,0 +1,10125 @@ +\pset null '(null)' +/* + * No.2-1 table definitions. + */ +-- No.2-1-1 +\d dbms_stats.backup_history + Table "dbms_stats.backup_history" + Column | Type | Collation | Nullable | Default +---------+--------------------------+-----------+----------+------------------------------------------------------- + id | bigint | | not null | nextval('dbms_stats.backup_history_id_seq'::regclass) + time | timestamp with time zone | | not null | + unit | character(1) | | not null | + comment | text | | | +Indexes: + "backup_history_pkey" PRIMARY KEY, btree (id) +Referenced by: + TABLE "dbms_stats.column_stats_backup" CONSTRAINT "column_stats_backup_id_fkey" FOREIGN KEY (id) REFERENCES dbms_stats.backup_history(id) ON DELETE CASCADE + TABLE "dbms_stats.relation_stats_backup" CONSTRAINT "relation_stats_backup_id_fkey" FOREIGN KEY (id) REFERENCES dbms_stats.backup_history(id) ON DELETE CASCADE + +-- No.2-1-2 +\d dbms_stats.column_stats_backup + Table "dbms_stats.column_stats_backup" + Column | Type | Collation | Nullable | Default +-------------+---------------------+-----------+----------+--------- + id | bigint | | not null | + statypid | oid | | not null | + starelid | oid | | not null | + staattnum | smallint | | not null | + stainherit | boolean | | not null | + stanullfrac | real | | not null | + stawidth | integer | | not null | + stadistinct | real | | not null | + stakind1 | smallint | | not null | + stakind2 | smallint | | not null | + stakind3 | smallint | | not null | + stakind4 | smallint | | not null | + stakind5 | smallint | | not null | + staop1 | oid | | not null | + staop2 | oid | | not null | + staop3 | oid | | not null | + staop4 | oid | | not null | + staop5 | oid | | not null | + stacoll1 | oid | | not null | + stacoll2 | oid | | not null | + stacoll3 | oid | | not null | + stacoll4 | oid | | not null | + stacoll5 | oid | | not null | + stanumbers1 | real[] | | | + stanumbers2 | real[] | | | + stanumbers3 | real[] | | | + stanumbers4 | real[] | | | + stanumbers5 | real[] | | | + stavalues1 | dbms_stats.anyarray | | | + stavalues2 | dbms_stats.anyarray | | | + stavalues3 | dbms_stats.anyarray | | | + stavalues4 | dbms_stats.anyarray | | | + stavalues5 | dbms_stats.anyarray | | | +Indexes: + "column_stats_backup_pkey" PRIMARY KEY, btree (id, starelid, staattnum, stainherit) +Foreign-key constraints: + "column_stats_backup_id_fkey" FOREIGN KEY (id) REFERENCES dbms_stats.backup_history(id) ON DELETE CASCADE + "column_stats_backup_id_starelid_fkey" FOREIGN KEY (id, starelid) REFERENCES dbms_stats.relation_stats_backup(id, relid) ON DELETE CASCADE + +-- No.2-1-3 +\d dbms_stats.column_stats_locked + Table "dbms_stats.column_stats_locked" + Column | Type | Collation | Nullable | Default +-------------+---------------------+-----------+----------+--------- + starelid | oid | | not null | + staattnum | smallint | | not null | + stainherit | boolean | | not null | + stanullfrac | real | | | + stawidth | integer | | | + stadistinct | real | | | + stakind1 | smallint | | | + stakind2 | smallint | | | + stakind3 | smallint | | | + stakind4 | smallint | | | + stakind5 | smallint | | | + staop1 | oid | | | + staop2 | oid | | | + staop3 | oid | | | + staop4 | oid | | | + staop5 | oid | | | + stacoll1 | oid | | | + stacoll2 | oid | | | + stacoll3 | oid | | | + stacoll4 | oid | | | + stacoll5 | oid | | | + stanumbers1 | real[] | | | + stanumbers2 | real[] | | | + stanumbers3 | real[] | | | + stanumbers4 | real[] | | | + stanumbers5 | real[] | | | + stavalues1 | dbms_stats.anyarray | | | + stavalues2 | dbms_stats.anyarray | | | + stavalues3 | dbms_stats.anyarray | | | + stavalues4 | dbms_stats.anyarray | | | + stavalues5 | dbms_stats.anyarray | | | +Indexes: + "column_stats_locked_pkey" PRIMARY KEY, btree (starelid, staattnum, stainherit) +Foreign-key constraints: + "column_stats_locked_starelid_fkey" FOREIGN KEY (starelid) REFERENCES dbms_stats.relation_stats_locked(relid) ON DELETE CASCADE +Triggers: + invalidate_column_cache BEFORE INSERT OR DELETE OR UPDATE ON dbms_stats.column_stats_locked FOR EACH ROW EXECUTE FUNCTION dbms_stats.invalidate_column_cache() + +-- No.2-1-4 +\d dbms_stats.relation_stats_backup + Table "dbms_stats.relation_stats_backup" + Column | Type | Collation | Nullable | Default +------------------+--------------------------+-----------+----------+--------- + id | bigint | | not null | + relid | oid | | not null | + relname | text | | not null | + relpages | integer | | not null | + reltuples | real | | not null | + relallvisible | integer | | not null | + curpages | integer | | not null | + last_analyze | timestamp with time zone | | | + last_autoanalyze | timestamp with time zone | | | +Indexes: + "relation_stats_backup_pkey" PRIMARY KEY, btree (id, relid) +Foreign-key constraints: + "relation_stats_backup_id_fkey" FOREIGN KEY (id) REFERENCES dbms_stats.backup_history(id) ON DELETE CASCADE +Referenced by: + TABLE "dbms_stats.column_stats_backup" CONSTRAINT "column_stats_backup_id_starelid_fkey" FOREIGN KEY (id, starelid) REFERENCES dbms_stats.relation_stats_backup(id, relid) ON DELETE CASCADE + +-- No.2-1-5 +\d dbms_stats.relation_stats_locked + Table "dbms_stats.relation_stats_locked" + Column | Type | Collation | Nullable | Default +------------------+--------------------------+-----------+----------+--------- + relid | oid | | not null | + relname | text | | not null | + relpages | integer | | | + reltuples | real | | | + relallvisible | integer | | | + curpages | integer | | | + last_analyze | timestamp with time zone | | | + last_autoanalyze | timestamp with time zone | | | +Indexes: + "relation_stats_locked_pkey" PRIMARY KEY, btree (relid) +Referenced by: + TABLE "dbms_stats.column_stats_locked" CONSTRAINT "column_stats_locked_starelid_fkey" FOREIGN KEY (starelid) REFERENCES dbms_stats.relation_stats_locked(relid) ON DELETE CASCADE +Triggers: + invalidate_relation_cache BEFORE INSERT OR DELETE OR UPDATE ON dbms_stats.relation_stats_locked FOR EACH ROW EXECUTE FUNCTION dbms_stats.invalidate_relation_cache() + +/* + * No.2-2 view definitions. + */ +-- No.2-2-1 +\dS+ dbms_stats.column_stats_effective + View "dbms_stats.column_stats_effective" + Column | Type | Collation | Nullable | Default | Storage | Description +-------------+---------------------+-----------+----------+---------+----------+------------- + starelid | oid | | | | plain | + staattnum | smallint | | | | plain | + stainherit | boolean | | | | plain | + stanullfrac | real | | | | plain | + stawidth | integer | | | | plain | + stadistinct | real | | | | plain | + stakind1 | smallint | | | | plain | + stakind2 | smallint | | | | plain | + stakind3 | smallint | | | | plain | + stakind4 | smallint | | | | plain | + stakind5 | smallint | | | | plain | + staop1 | oid | | | | plain | + staop2 | oid | | | | plain | + staop3 | oid | | | | plain | + staop4 | oid | | | | plain | + staop5 | oid | | | | plain | + stacoll1 | oid | | | | plain | + stacoll2 | oid | | | | plain | + stacoll3 | oid | | | | plain | + stacoll4 | oid | | | | plain | + stacoll5 | oid | | | | plain | + stanumbers1 | real[] | | | | extended | + stanumbers2 | real[] | | | | extended | + stanumbers3 | real[] | | | | extended | + stanumbers4 | real[] | | | | extended | + stanumbers5 | real[] | | | | extended | + stavalues1 | dbms_stats.anyarray | | | | extended | + stavalues2 | dbms_stats.anyarray | | | | extended | + stavalues3 | dbms_stats.anyarray | | | | extended | + stavalues4 | dbms_stats.anyarray | | | | extended | + stavalues5 | dbms_stats.anyarray | | | | extended | +View definition: + SELECT m.starelid, + m.staattnum, + m.stainherit, + m.stanullfrac, + m.stawidth, + m.stadistinct, + m.stakind1, + m.stakind2, + m.stakind3, + m.stakind4, + m.stakind5, + m.staop1, + m.staop2, + m.staop3, + m.staop4, + m.staop5, + m.stacoll1, + m.stacoll2, + m.stacoll3, + m.stacoll4, + m.stacoll5, + m.stanumbers1, + m.stanumbers2, + m.stanumbers3, + m.stanumbers4, + m.stanumbers5, + m.stavalues1, + m.stavalues2, + m.stavalues3, + m.stavalues4, + m.stavalues5 + FROM ( SELECT (dbms_stats.merge(v.*, s.*)).starelid AS starelid, + (dbms_stats.merge(v.*, s.*)).staattnum AS staattnum, + (dbms_stats.merge(v.*, s.*)).stainherit AS stainherit, + (dbms_stats.merge(v.*, s.*)).stanullfrac AS stanullfrac, + (dbms_stats.merge(v.*, s.*)).stawidth AS stawidth, + (dbms_stats.merge(v.*, s.*)).stadistinct AS stadistinct, + (dbms_stats.merge(v.*, s.*)).stakind1 AS stakind1, + (dbms_stats.merge(v.*, s.*)).stakind2 AS stakind2, + (dbms_stats.merge(v.*, s.*)).stakind3 AS stakind3, + (dbms_stats.merge(v.*, s.*)).stakind4 AS stakind4, + (dbms_stats.merge(v.*, s.*)).stakind5 AS stakind5, + (dbms_stats.merge(v.*, s.*)).staop1 AS staop1, + (dbms_stats.merge(v.*, s.*)).staop2 AS staop2, + (dbms_stats.merge(v.*, s.*)).staop3 AS staop3, + (dbms_stats.merge(v.*, s.*)).staop4 AS staop4, + (dbms_stats.merge(v.*, s.*)).staop5 AS staop5, + (dbms_stats.merge(v.*, s.*)).stacoll1 AS stacoll1, + (dbms_stats.merge(v.*, s.*)).stacoll2 AS stacoll2, + (dbms_stats.merge(v.*, s.*)).stacoll3 AS stacoll3, + (dbms_stats.merge(v.*, s.*)).stacoll4 AS stacoll4, + (dbms_stats.merge(v.*, s.*)).stacoll5 AS stacoll5, + (dbms_stats.merge(v.*, s.*)).stanumbers1 AS stanumbers1, + (dbms_stats.merge(v.*, s.*)).stanumbers2 AS stanumbers2, + (dbms_stats.merge(v.*, s.*)).stanumbers3 AS stanumbers3, + (dbms_stats.merge(v.*, s.*)).stanumbers4 AS stanumbers4, + (dbms_stats.merge(v.*, s.*)).stanumbers5 AS stanumbers5, + (dbms_stats.merge(v.*, s.*)).stavalues1 AS stavalues1, + (dbms_stats.merge(v.*, s.*)).stavalues2 AS stavalues2, + (dbms_stats.merge(v.*, s.*)).stavalues3 AS stavalues3, + (dbms_stats.merge(v.*, s.*)).stavalues4 AS stavalues4, + (dbms_stats.merge(v.*, s.*)).stavalues5 AS stavalues5 + FROM pg_statistic s + FULL JOIN dbms_stats.column_stats_locked v USING (starelid, staattnum, stainherit) + WHERE NOT dbms_stats.is_system_catalog(starelid::regclass) AND (EXISTS ( SELECT NULL::text + FROM pg_attribute a + WHERE a.attrelid = starelid AND a.attnum = staattnum AND a.attisdropped = false))) m + WHERE m.starelid IS NOT NULL; + +-- No.2-2-2 +\dS+ dbms_stats.relation_stats_effective + View "dbms_stats.relation_stats_effective" + Column | Type | Collation | Nullable | Default | Storage | Description +------------------+--------------------------+-----------+----------+---------+----------+------------- + relid | oid | | | | plain | + relname | text | C | | | extended | + relpages | integer | | | | plain | + reltuples | real | | | | plain | + relallvisible | integer | | | | plain | + curpages | integer | | | | plain | + last_analyze | timestamp with time zone | | | | plain | + last_autoanalyze | timestamp with time zone | | | | plain | +View definition: + SELECT c.oid AS relid, + dbms_stats.relname(n.nspname::text, c.relname::text) AS relname, + COALESCE(v.relpages, c.relpages) AS relpages, + COALESCE(v.reltuples, c.reltuples) AS reltuples, + COALESCE(v.relallvisible, c.relallvisible) AS relallvisible, + COALESCE(v.curpages, (pg_relation_size(c.oid::regclass) / current_setting('block_size'::text)::integer)::integer) AS curpages, + COALESCE(v.last_analyze, pg_stat_get_last_analyze_time(c.oid)) AS last_analyze, + COALESCE(v.last_autoanalyze, pg_stat_get_last_autoanalyze_time(c.oid)) AS last_autoanalyze + FROM pg_class c + JOIN pg_namespace n ON c.relnamespace = n.oid + LEFT JOIN dbms_stats.relation_stats_locked v ON v.relid = c.oid + WHERE dbms_stats.is_target_relkind(c.relkind) AND NOT dbms_stats.is_system_schema(n.nspname::text); + +-- No.2-2-3 +\dS+ dbms_stats.stats + View "dbms_stats.stats" + Column | Type | Collation | Nullable | Default | Storage | Description +------------------------+---------------------+-----------+----------+---------+----------+------------- + schemaname | name | | | | plain | + tablename | name | | | | plain | + attname | name | | | | plain | + inherited | boolean | | | | plain | + null_frac | real | | | | plain | + avg_width | integer | | | | plain | + n_distinct | real | | | | plain | + most_common_vals | dbms_stats.anyarray | | | | extended | + most_common_freqs | real[] | | | | extended | + histogram_bounds | dbms_stats.anyarray | | | | extended | + correlation | real | | | | plain | + most_common_elems | dbms_stats.anyarray | | | | extended | + most_common_elem_freqs | real[] | | | | extended | + elem_count_histogram | real[] | | | | extended | +View definition: + SELECT n.nspname AS schemaname, + c.relname AS tablename, + a.attname, + s.stainherit AS inherited, + s.stanullfrac AS null_frac, + s.stawidth AS avg_width, + s.stadistinct AS n_distinct, + CASE + WHEN s.stakind1 = 1 THEN s.stavalues1 + WHEN s.stakind2 = 1 THEN s.stavalues2 + WHEN s.stakind3 = 1 THEN s.stavalues3 + WHEN s.stakind4 = 1 THEN s.stavalues4 + WHEN s.stakind5 = 1 THEN s.stavalues5 + ELSE NULL::dbms_stats.anyarray + END AS most_common_vals, + CASE + WHEN s.stakind1 = 1 THEN s.stanumbers1 + WHEN s.stakind2 = 1 THEN s.stanumbers2 + WHEN s.stakind3 = 1 THEN s.stanumbers3 + WHEN s.stakind4 = 1 THEN s.stanumbers4 + WHEN s.stakind5 = 1 THEN s.stanumbers5 + ELSE NULL::real[] + END AS most_common_freqs, + CASE + WHEN s.stakind1 = 2 THEN s.stavalues1 + WHEN s.stakind2 = 2 THEN s.stavalues2 + WHEN s.stakind3 = 2 THEN s.stavalues3 + WHEN s.stakind4 = 2 THEN s.stavalues4 + WHEN s.stakind5 = 2 THEN s.stavalues5 + ELSE NULL::dbms_stats.anyarray + END AS histogram_bounds, + CASE + WHEN s.stakind1 = 3 THEN s.stanumbers1[1] + WHEN s.stakind2 = 3 THEN s.stanumbers2[1] + WHEN s.stakind3 = 3 THEN s.stanumbers3[1] + WHEN s.stakind4 = 3 THEN s.stanumbers4[1] + WHEN s.stakind5 = 3 THEN s.stanumbers5[1] + ELSE NULL::real + END AS correlation, + CASE + WHEN s.stakind1 = 4 THEN s.stavalues1 + WHEN s.stakind2 = 4 THEN s.stavalues2 + WHEN s.stakind3 = 4 THEN s.stavalues3 + WHEN s.stakind4 = 4 THEN s.stavalues4 + WHEN s.stakind5 = 4 THEN s.stavalues5 + ELSE NULL::dbms_stats.anyarray + END AS most_common_elems, + CASE + WHEN s.stakind1 = 4 THEN s.stanumbers1 + WHEN s.stakind2 = 4 THEN s.stanumbers2 + WHEN s.stakind3 = 4 THEN s.stanumbers3 + WHEN s.stakind4 = 4 THEN s.stanumbers4 + WHEN s.stakind5 = 4 THEN s.stanumbers5 + ELSE NULL::real[] + END AS most_common_elem_freqs, + CASE + WHEN s.stakind1 = 5 THEN s.stanumbers1 + WHEN s.stakind2 = 5 THEN s.stanumbers2 + WHEN s.stakind3 = 5 THEN s.stanumbers3 + WHEN s.stakind4 = 5 THEN s.stanumbers4 + WHEN s.stakind5 = 5 THEN s.stanumbers5 + ELSE NULL::real[] + END AS elem_count_histogram + FROM dbms_stats.column_stats_effective s + JOIN pg_class c ON c.oid = s.starelid + JOIN pg_attribute a ON c.oid = a.attrelid AND a.attnum = s.staattnum + LEFT JOIN pg_namespace n ON n.oid = c.relnamespace + WHERE NOT a.attisdropped AND has_column_privilege(c.oid, a.attnum, 'select'::text) AND (c.relrowsecurity = false OR NOT row_security_active(c.oid)); +Options: security_barrier=true + +-- No.2-2-4 +\dS+ dbms_stats.column_stats_locked + Table "dbms_stats.column_stats_locked" + Column | Type | Collation | Nullable | Default | Storage | Stats target | Description +-------------+---------------------+-----------+----------+---------+----------+--------------+------------- + starelid | oid | | not null | | plain | | + staattnum | smallint | | not null | | plain | | + stainherit | boolean | | not null | | plain | | + stanullfrac | real | | | | plain | | + stawidth | integer | | | | plain | | + stadistinct | real | | | | plain | | + stakind1 | smallint | | | | plain | | + stakind2 | smallint | | | | plain | | + stakind3 | smallint | | | | plain | | + stakind4 | smallint | | | | plain | | + stakind5 | smallint | | | | plain | | + staop1 | oid | | | | plain | | + staop2 | oid | | | | plain | | + staop3 | oid | | | | plain | | + staop4 | oid | | | | plain | | + staop5 | oid | | | | plain | | + stacoll1 | oid | | | | plain | | + stacoll2 | oid | | | | plain | | + stacoll3 | oid | | | | plain | | + stacoll4 | oid | | | | plain | | + stacoll5 | oid | | | | plain | | + stanumbers1 | real[] | | | | extended | | + stanumbers2 | real[] | | | | extended | | + stanumbers3 | real[] | | | | extended | | + stanumbers4 | real[] | | | | extended | | + stanumbers5 | real[] | | | | extended | | + stavalues1 | dbms_stats.anyarray | | | | extended | | + stavalues2 | dbms_stats.anyarray | | | | extended | | + stavalues3 | dbms_stats.anyarray | | | | extended | | + stavalues4 | dbms_stats.anyarray | | | | extended | | + stavalues5 | dbms_stats.anyarray | | | | extended | | +Indexes: + "column_stats_locked_pkey" PRIMARY KEY, btree (starelid, staattnum, stainherit) +Foreign-key constraints: + "column_stats_locked_starelid_fkey" FOREIGN KEY (starelid) REFERENCES dbms_stats.relation_stats_locked(relid) ON DELETE CASCADE +Triggers: + invalidate_column_cache BEFORE INSERT OR DELETE OR UPDATE ON dbms_stats.column_stats_locked FOR EACH ROW EXECUTE FUNCTION dbms_stats.invalidate_column_cache() + +-- No.2-2-5 +\dS+ dbms_stats.relation_stats_locked + Table "dbms_stats.relation_stats_locked" + Column | Type | Collation | Nullable | Default | Storage | Stats target | Description +------------------+--------------------------+-----------+----------+---------+----------+--------------+------------- + relid | oid | | not null | | plain | | + relname | text | | not null | | extended | | + relpages | integer | | | | plain | | + reltuples | real | | | | plain | | + relallvisible | integer | | | | plain | | + curpages | integer | | | | plain | | + last_analyze | timestamp with time zone | | | | plain | | + last_autoanalyze | timestamp with time zone | | | | plain | | +Indexes: + "relation_stats_locked_pkey" PRIMARY KEY, btree (relid) +Referenced by: + TABLE "dbms_stats.column_stats_locked" CONSTRAINT "column_stats_locked_starelid_fkey" FOREIGN KEY (starelid) REFERENCES dbms_stats.relation_stats_locked(relid) ON DELETE CASCADE +Triggers: + invalidate_relation_cache BEFORE INSERT OR DELETE OR UPDATE ON dbms_stats.relation_stats_locked FOR EACH ROW EXECUTE FUNCTION dbms_stats.invalidate_relation_cache() + +/* + * No.2-4 dbms_stats.anyarray + */ +-- No.2-4-1 +SELECT n.nspname, t.typname, t.typlen, t.typbyval, t.typtype, + t.typcategory, t.typispreferred, t.typisdefined, t.typdelim, + t.typrelid, t.typelem, t.typinput, t.typoutput, t.typreceive, + t.typsend, t.typmodin, t.typmodout, t.typanalyze, t.typalign, + t.typstorage, t.typnotnull, t.typbasetype, t.typtypmod, t.typndims, + t.typcollation, t.typdefaultbin, t.typdefault, t.typacl + FROM pg_type t, pg_namespace n + WHERE t.typnamespace = n.oid + AND n.nspname = 'dbms_stats' + AND t.typname = 'anyarray'; + nspname | typname | typlen | typbyval | typtype | typcategory | typispreferred | typisdefined | typdelim | typrelid | typelem | typinput | typoutput | typreceive | typsend | typmodin | typmodout | typanalyze | typalign | typstorage | typnotnull | typbasetype | typtypmod | typndims | typcollation | typdefaultbin | typdefault | typacl +------------+----------+--------+----------+---------+-------------+----------------+--------------+----------+----------+---------+------------------------+-------------------------+--------------------------+--------------------------+----------+-----------+------------+----------+------------+------------+-------------+-----------+----------+--------------+---------------+------------+-------- + dbms_stats | anyarray | -1 | f | b | P | f | t | , | 0 | 0 | dbms_stats.anyarray_in | dbms_stats.anyarray_out | dbms_stats.anyarray_recv | dbms_stats.anyarray_send | - | - | - | d | x | f | 0 | -1 | 0 | 0 | (null) | (null) | (null) +(1 row) + +/* + * No.5-1 dbms_stats.merge + */ +UPDATE pg_statistic SET + stanullfrac = staattnum, + stawidth = staattnum, + stadistinct = staattnum, + stakind1 = 4, + stakind2 = 1, + stakind3 = 2, + stakind4 = 3, + stakind5 = 5, + staop1 = 14, + staop2 = 11, + staop3 = 12, + staop4 = 13, + staop5 = 15, + stanumbers1 = ARRAY[staattnum,4], + stanumbers2 = ARRAY[staattnum,1], + stanumbers3 = ARRAY[staattnum,2], + stanumbers4 = ARRAY[staattnum,3], + stanumbers5 = ARRAY[staattnum,5], + stavalues2 = array_cat(stavalues1,stavalues1), + stavalues3 = array_cat(array_cat(stavalues1,stavalues1),stavalues1), + stavalues4 = array_cat(array_cat(array_cat(stavalues1,stavalues1),stavalues1),stavalues1) + ,stavalues5 = array_cat(array_cat(array_cat(array_cat(stavalues1,stavalues1),stavalues1),stavalues1),stavalues1) + WHERE starelid = 'st0'::regclass; +SELECT dbms_stats.lock_table_stats('st0'); + lock_table_stats +------------------ + st0 +(1 row) + +UPDATE dbms_stats.column_stats_locked SET + stainherit = 't', + stanullfrac = -staattnum, + stawidth = -staattnum, + stadistinct = -staattnum, + stakind1 = 2, + stakind2 = 3, + stakind3 = 4, + stakind4 = 1, + stakind5 = 5, + staop1 = 22, + staop2 = 23, + staop3 = 24, + staop4 = 21, + staop5 = 25, + stanumbers1 = ARRAY[-staattnum,22], + stanumbers2 = ARRAY[-staattnum,23], + stanumbers3 = ARRAY[-staattnum,24], + stanumbers4 = ARRAY[-staattnum,21], + stanumbers5 = ARRAY[-staattnum,25], + stavalues1 = stavalues3, + stavalues2 = stavalues2, + stavalues3 = stavalues1, + stavalues4 = stavalues4 + ,stavalues5 = stavalues5 +; +/* + * Driver function dbms_stats.merge1 + */ +CREATE FUNCTION dbms_stats.merge1( + lhs dbms_stats.column_stats_locked, + rhs pg_catalog.pg_statistic +) RETURNS integer AS +'$libdir/pg_dbms_stats', 'dbms_stats_merge' +LANGUAGE C STABLE; +SELECT * FROM columns_locked_v + WHERE starelid = 'st0'::regclass; + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+---------------------------+-------------------+------------+-----------------------------------+------------------------------------------- + st0 | 1 | id | t | -1 | -1 | -1 | 2 | 3 | 4 | 1 | 5 | 22 | 23 | 24 | 21 | 25 | {-1,22} | {-1,23} | {-1,24} | {-1,21} | {-1,25} | {1,2,1,2,1,2} | {1,2,1,2} | {1,2} | {1,2,1,2,1,2,1,2} | {1,2,1,2,1,2,1,2,1,2} + st0 | 2 | name | t | -2 | -2 | -2 | 2 | 3 | 4 | 1 | 5 | 22 | 23 | 24 | 21 | 25 | {-2,22} | {-2,23} | {-2,24} | {-2,21} | {-2,25} | {"test ","test ","test "} | {"test ","test "} | {"test "} | {"test ","test ","test ","test "} | {"test ","test ","test ","test ","test "} +(2 rows) + +SELECT * FROM plain_columns_statistic_v + WHERE starelid = 'st0'::regclass; + starelid | staattnum | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+-------------------+---------------------------+-----------------------------------+------------------------------------------- + st0 | 1 | f | 1 | 1 | 1 | 4 | 1 | 2 | 3 | 5 | 14 | 11 | 12 | 13 | 15 | {1,4} | {1,1} | {1,2} | {1,3} | {1,5} | {1,2} | {1,2,1,2} | {1,2,1,2,1,2} | {1,2,1,2,1,2,1,2} | {1,2,1,2,1,2,1,2,1,2} + st0 | 2 | f | 2 | 2 | 2 | 4 | 1 | 2 | 3 | 5 | 14 | 11 | 12 | 13 | 15 | {2,4} | {2,1} | {2,2} | {2,3} | {2,5} | {"test "} | {"test ","test "} | {"test ","test ","test "} | {"test ","test ","test ","test "} | {"test ","test ","test ","test ","test "} +(2 rows) + +SET client_min_messages TO LOG; +-- No.5-1-1 +SELECT (m.merge).starelid::regclass, + (m.merge).staattnum, + (m.merge).stainherit, + (m.merge).stanullfrac, + (m.merge).stawidth, + (m.merge).stadistinct, + (m.merge).stakind1, + (m.merge).stakind2, + (m.merge).stakind3, + (m.merge).stakind4, + (m.merge).stakind5, + (m.merge).staop1, + (m.merge).staop2, + (m.merge).staop3, + (m.merge).staop4, + (m.merge).staop5, + (m.merge).stanumbers1, + (m.merge).stanumbers2, + (m.merge).stanumbers3, + (m.merge).stanumbers4, + (m.merge).stanumbers5, + (m.merge).stavalues1, + (m.merge).stavalues2, + (m.merge).stavalues3, + (m.merge).stavalues4 + ,(m.merge).stavalues5 + FROM (SELECT dbms_stats.merge(NULL, s) + FROM pg_statistic s + WHERE starelid = 'st0'::regclass + AND staattnum = '1'::int2) m; + starelid | staattnum | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+---------------+-------------------+----------------------- + st0 | 1 | f | 1 | 1 | 1 | 4 | 1 | 2 | 3 | 5 | 14 | 11 | 12 | 13 | 15 | {1,4} | {1,1} | {1,2} | {1,3} | {1,5} | {1,2} | {1,2,1,2} | {1,2,1,2,1,2} | {1,2,1,2,1,2,1,2} | {1,2,1,2,1,2,1,2,1,2} +(1 row) + +-- No.5-1-2 +SELECT (m.merge).starelid::regclass, + (m.merge).staattnum, + (m.merge).stainherit, + (m.merge).stanullfrac, + (m.merge).stawidth, + (m.merge).stadistinct, + (m.merge).stakind1, + (m.merge).stakind2, + (m.merge).stakind3, + (m.merge).stakind4, + (m.merge).stakind5, + (m.merge).staop1, + (m.merge).staop2, + (m.merge).staop3, + (m.merge).staop4, + (m.merge).staop5, + (m.merge).stanumbers1, + (m.merge).stanumbers2, + (m.merge).stanumbers3, + (m.merge).stanumbers4, + (m.merge).stanumbers5, + (m.merge).stavalues1, + (m.merge).stavalues2, + (m.merge).stavalues3, + (m.merge).stavalues4 + ,(m.merge).stavalues5 + FROM (SELECT dbms_stats.merge(v, NULL) + FROM dbms_stats.column_stats_locked v + WHERE starelid = 'st0'::regclass + AND staattnum = '2'::int2) m; + starelid | staattnum | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+---------------------------+-------------------+------------+-----------------------------------+------------------------------------------- + st0 | 2 | t | -2 | -2 | -2 | 2 | 3 | 4 | 1 | 5 | 22 | 23 | 24 | 21 | 25 | {-2,22} | {-2,23} | {-2,24} | {-2,21} | {-2,25} | {"test ","test ","test "} | {"test ","test "} | {"test "} | {"test ","test ","test ","test "} | {"test ","test ","test ","test ","test "} +(1 row) + +-- No.5-1-3 +SELECT dbms_stats.merge(NULL, NULL); + merge +-------- + (null) +(1 row) + +-- No.5-1-4 +SELECT (m.merge).starelid::regclass, + (m.merge).staattnum, + (m.merge).stainherit, + (m.merge).stanullfrac, + (m.merge).stawidth, + (m.merge).stadistinct, + (m.merge).stakind1, + (m.merge).stakind2, + (m.merge).stakind3, + (m.merge).stakind4, + (m.merge).stakind5, + (m.merge).staop1, + (m.merge).staop2, + (m.merge).staop3, + (m.merge).staop4, + (m.merge).staop5, + (m.merge).stanumbers1, + (m.merge).stanumbers2, + (m.merge).stanumbers3, + (m.merge).stanumbers4, + (m.merge).stanumbers5, + (m.merge).stavalues1, + (m.merge).stavalues2, + (m.merge).stavalues3, + (m.merge).stavalues4 + ,(m.merge).stavalues5 + FROM (SELECT dbms_stats.merge(v, s) + FROM dbms_stats.column_stats_locked v, + pg_statistic s + WHERE v.starelid = 'st0'::regclass + AND v.staattnum = '2'::int2 + AND s.starelid = 'st0'::regclass + AND s.staattnum = '1'::int2) m; + starelid | staattnum | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+---------------------------+-------------------+------------+-----------------------------------+------------------------------------------- + st0 | 2 | t | -2 | -2 | -2 | 2 | 3 | 4 | 1 | 5 | 22 | 23 | 24 | 21 | 25 | {-2,22} | {-2,23} | {-2,24} | {-2,21} | {-2,25} | {"test ","test ","test "} | {"test ","test "} | {"test "} | {"test ","test ","test ","test "} | {"test ","test ","test ","test ","test "} +(1 row) + +-- No.5-1-5 +SELECT (m.merge).starelid::regclass, + (m.merge).staattnum, + (m.merge).stainherit, + (m.merge).stanullfrac, + (m.merge).stawidth, + (m.merge).stadistinct, + (m.merge).stakind1, + (m.merge).stakind2, + (m.merge).stakind3, + (m.merge).stakind4, + (m.merge).stakind5, + (m.merge).staop1, + (m.merge).staop2, + (m.merge).staop3, + (m.merge).staop4, + (m.merge).staop5, + (m.merge).stanumbers1, + (m.merge).stanumbers2, + (m.merge).stanumbers3, + (m.merge).stanumbers4, + (m.merge).stanumbers5, + (m.merge).stavalues1, + (m.merge).stavalues2, + (m.merge).stavalues3, + (m.merge).stavalues4 + ,(m.merge).stavalues5 + FROM (SELECT dbms_stats.merge(v, s) + FROM dbms_stats.column_stats_locked v, + pg_statistic s + WHERE v.starelid = 'st0'::regclass + AND v.staattnum = '2'::int2 + AND s.starelid = 'st0'::regclass + AND s.staattnum = '1'::int2) m; + starelid | staattnum | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+---------------------------+-------------------+------------+-----------------------------------+------------------------------------------- + st0 | 2 | t | -2 | -2 | -2 | 2 | 3 | 4 | 1 | 5 | 22 | 23 | 24 | 21 | 25 | {-2,22} | {-2,23} | {-2,24} | {-2,21} | {-2,25} | {"test ","test ","test "} | {"test ","test "} | {"test "} | {"test ","test ","test ","test "} | {"test ","test ","test ","test ","test "} +(1 row) + +-- No.5-1-6 +SELECT dbms_stats.merge1(v, s) + FROM dbms_stats.column_stats_locked v, + pg_statistic s + WHERE v.starelid = 'st0'::regclass + AND v.staattnum = '2'::int2 + AND s.starelid = 'st0'::regclass + AND s.staattnum = '1'::int2; +ERROR: return type must be a row type +-- No.5-1-7 +SELECT dbms_stats.merge(NULL, ( + s.starelid::regclass, s.staattnum, s.stainherit, + s.stanullfrac, s.stawidth, s.stadistinct, + s.stakind1, s.stakind2, s.stakind3, s.stakind4, + s.stakind5, + s.staop1, s.staop2, s.staop3, + s.staop4, + NULL, s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, + s.stanumbers5, + s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 + ,s.stavalues5 + )) + FROM pg_statistic s + WHERE s.starelid = 'st0'::regclass + AND s.staattnum = '1'::int2; +ERROR: cannot cast type record to pg_statistic +LINE 8: NULL, s.stanumbers1, s.stanumbers2, s.stanumbers3, s.... + ^ +DETAIL: Cannot cast type real[] to oid in column 17. +-- No.5-1-8 +SELECT (m.merge).starelid::regclass, + (m.merge).staattnum, + (m.merge).stainherit, + (m.merge).stanullfrac, + (m.merge).stawidth, + (m.merge).stadistinct, + (m.merge).stakind1, + (m.merge).stakind2, + (m.merge).stakind3, + (m.merge).stakind4, + (m.merge).stakind5, + (m.merge).staop1, + (m.merge).staop2, + (m.merge).staop3, + (m.merge).staop4, + (m.merge).staop5, + (m.merge).stanumbers1, + (m.merge).stanumbers2, + (m.merge).stanumbers3, + (m.merge).stanumbers4, + (m.merge).stanumbers5, + (m.merge).stavalues1, + (m.merge).stavalues2, + (m.merge).stavalues3, + (m.merge).stavalues4 + ,(m.merge).stavalues5 + FROM (SELECT dbms_stats.merge(NULL, ( + s.starelid::regclass, s.staattnum, s.stainherit, + s.stanullfrac, s.stawidth, s.stadistinct, + s.stakind1, s.stakind2, s.stakind3, s.stakind4, + s.stakind5, + s.staop1, s.staop2, s.staop3, s.staop4, + s.staop5, + NULL, s.stanumbers2, s.stanumbers3, s.stanumbers4, + s.stanumbers5, + s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 + ,s.stavalues5 + )) + FROM pg_statistic s + WHERE s.starelid = 'st0'::regclass + AND s.staattnum = '1'::int2) m; +ERROR: cannot cast type record to pg_statistic +LINE 34: NULL, s.stanumbers2, s.stanumbers3, s.stanumbe... + ^ +DETAIL: Cannot cast type real[] to oid in column 18. +-- No.5-1-9 +SELECT dbms_stats.merge(( + v.starelid::regclass, v.staattnum, v.stainherit, + v.stanullfrac, v.stawidth, v.stadistinct, + v.stakind1, v.stakind2, v.stakind3, v.stakind4, + v.stakind5, + v.staop1, v.staop2, v.staop3, + v.staop4, + NULL, v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, + v.stanumbers5, + v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 + ,v.stavalues5 + ), NULL) + FROM dbms_stats.column_stats_locked v + WHERE v.starelid = 'st0'::regclass + AND v.staattnum = '2'::int2; +ERROR: cannot cast type record to dbms_stats.column_stats_locked +LINE 8: NULL, v.stanumbers1, v.stanumbers2, v.stanumbers3, v.... + ^ +DETAIL: Cannot cast type real[] to oid in column 17. +-- No.5-1-10 +SELECT (m.merge).starelid::regclass, + (m.merge).staattnum, + (m.merge).stainherit, + (m.merge).stanullfrac, + (m.merge).stawidth, + (m.merge).stadistinct, + (m.merge).stakind1, + (m.merge).stakind2, + (m.merge).stakind3, + (m.merge).stakind4, + (m.merge).stakind5, + (m.merge).staop1, + (m.merge).staop2, + (m.merge).staop3, + (m.merge).staop4, + (m.merge).staop5, + (m.merge).stanumbers1, + (m.merge).stanumbers2, + (m.merge).stanumbers3, + (m.merge).stanumbers4, + (m.merge).stanumbers5, + (m.merge).stavalues1, + (m.merge).stavalues2, + (m.merge).stavalues3, + (m.merge).stavalues4 + ,(m.merge).stavalues5 + FROM (SELECT dbms_stats.merge(( + v.starelid::regclass, v.staattnum, v.stainherit, + v.stanullfrac, v.stawidth, v.stadistinct, + v.stakind1, v.stakind2, v.stakind3, v.stakind4, + v.stakind5, + v.staop1, v.staop2, v.staop3, v.staop4, + v.staop5, + NULL, v.stanumbers2, v.stanumbers3, v.stanumbers4, + v.stanumbers5, + v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 + ,v.stavalues5 + ), NULL) + FROM dbms_stats.column_stats_locked v + WHERE v.starelid = 'st0'::regclass + AND v.staattnum = '2'::int2) m; +ERROR: cannot cast type record to dbms_stats.column_stats_locked +LINE 34: NULL, v.stanumbers2, v.stanumbers3, v.stanumbe... + ^ +DETAIL: Cannot cast type real[] to oid in column 18. +-- No.5-1-11 +SELECT dbms_stats.merge(( + v.starelid::regclass, v.staattnum, v.stainherit, + v.stanullfrac, v.stawidth, v.stadistinct, + v.stakind1, v.stakind2, v.stakind3, v.stakind4, + v.stakind5, + v.staop1, v.staop2, v.staop3, + v.staop4, + NULL, v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, + v.stanumbers5, + v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 + ,v.stavalues5 + ), ( + s.starelid::regclass, s.staattnum, s.stainherit, + s.stanullfrac, s.stawidth, s.stadistinct, + s.stakind1, s.stakind2, s.stakind3, s.stakind4, + s.stakind5, + s.staop1, s.staop2, s.staop3, + s.staop4, + NULL, s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, + s.stanumbers5, + s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 + ,s.stavalues5 + )) + FROM dbms_stats.column_stats_locked v, + pg_statistic s + WHERE v.starelid = 'st0'::regclass + AND v.staattnum = '2'::int2 + AND s.starelid = 'st0'::regclass + AND s.staattnum = '1'::int2; +ERROR: cannot cast type record to dbms_stats.column_stats_locked +LINE 8: NULL, v.stanumbers1, v.stanumbers2, v.stanumbers3, v.... + ^ +DETAIL: Cannot cast type real[] to oid in column 17. +-- No.5-1-12 +SELECT (m.merge).starelid::regclass, + (m.merge).staattnum, + (m.merge).stainherit, + (m.merge).stanullfrac, + (m.merge).stawidth, + (m.merge).stadistinct, + (m.merge).stakind1, + (m.merge).stakind2, + (m.merge).stakind3, + (m.merge).stakind4, + (m.merge).stakind5, + (m.merge).staop1, + (m.merge).staop2, + (m.merge).staop3, + (m.merge).staop4, + (m.merge).staop5, + (m.merge).stanumbers1, + (m.merge).stanumbers2, + (m.merge).stanumbers3, + (m.merge).stanumbers4, + (m.merge).stanumbers5, + (m.merge).stavalues1, + (m.merge).stavalues2, + (m.merge).stavalues3, + (m.merge).stavalues4 + ,(m.merge).stavalues5 + FROM (SELECT dbms_stats.merge(( + v.starelid::regclass, v.staattnum, v.stainherit, + v.stanullfrac, v.stawidth, v.stadistinct, + v.stakind1, v.stakind2, v.stakind3, v.stakind4, + v.stakind5, + v.staop1, v.staop2, v.staop3, v.staop4, + v.staop5, + NULL, v.stanumbers2, v.stanumbers3, v.stanumbers4, + v.stanumbers5, + v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 + ,v.stavalues5 + ), ( + s.starelid::regclass, s.staattnum, s.stainherit, + s.stanullfrac, s.stawidth, s.stadistinct, + s.stakind1, s.stakind2, s.stakind3, s.stakind4, + s.stakind5, + s.staop1, s.staop2, s.staop3, s.staop4, + s.staop5, + NULL, s.stanumbers2, s.stanumbers3, s.stanumbers4, + s.stanumbers5, + s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 + ,s.stavalues5 + )) + FROM dbms_stats.column_stats_locked v, + pg_statistic s + WHERE v.starelid = 'st0'::regclass + AND v.staattnum = '2'::int2 + AND s.starelid = 'st0'::regclass + AND s.staattnum = '1'::int2) m; +ERROR: cannot cast type record to dbms_stats.column_stats_locked +LINE 34: NULL, v.stanumbers2, v.stanumbers3, v.stanumbe... + ^ +DETAIL: Cannot cast type real[] to oid in column 18. +-- No.5-1-13 +SELECT (m.merge).starelid::regclass, + (m.merge).staattnum, + (m.merge).stainherit, + (m.merge).stanullfrac, + (m.merge).stawidth, + (m.merge).stadistinct, + (m.merge).stakind1, + (m.merge).stakind2, + (m.merge).stakind3, + (m.merge).stakind4, + (m.merge).stakind5, + (m.merge).staop1, + (m.merge).staop2, + (m.merge).staop3, + (m.merge).staop4, + (m.merge).staop5, + (m.merge).stanumbers1, + (m.merge).stanumbers2, + (m.merge).stanumbers3, + (m.merge).stanumbers4, + (m.merge).stanumbers5, + (m.merge).stavalues1, + (m.merge).stavalues2, + (m.merge).stavalues3, + (m.merge).stavalues4 + ,(m.merge).stavalues5 + FROM (SELECT dbms_stats.merge(( + 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 + ), s) + FROM pg_statistic s + WHERE s.starelid = 'st0'::regclass + AND s.staattnum = '1'::int2) m; +ERROR: cannot cast type record to dbms_stats.column_stats_locked +LINE 27: FROM (SELECT dbms_stats.merge(( + ^ +DETAIL: Input has too few columns. +-- No.5-1-14 +SELECT (m.merge).starelid::regclass, + (m.merge).staattnum, + (m.merge).stainherit, + (m.merge).stanullfrac, + (m.merge).stawidth, + (m.merge).stadistinct, + (m.merge).stakind1, + (m.merge).stakind2, + (m.merge).stakind3, + (m.merge).stakind4, + (m.merge).stakind5, + (m.merge).staop1, + (m.merge).staop2, + (m.merge).staop3, + (m.merge).staop4, + (m.merge).staop5, + (m.merge).stanumbers1, + (m.merge).stanumbers2, + (m.merge).stanumbers3, + (m.merge).stanumbers4, + (m.merge).stanumbers5, + (m.merge).stavalues1, + (m.merge).stavalues2, + (m.merge).stavalues3, + (m.merge).stavalues4 + ,(m.merge).stavalues5 + FROM (SELECT dbms_stats.merge(v, ( + 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)) + FROM dbms_stats.column_stats_locked v + WHERE v.starelid = 'st0'::regclass + AND v.staattnum = '2'::int2) m; +ERROR: cannot cast type record to pg_statistic +LINE 27: FROM (SELECT dbms_stats.merge(v, ( + ^ +DETAIL: Input has too few columns. +-- No.5-1-15 +SELECT (m.merge).starelid::regclass, + (m.merge).staattnum, + (m.merge).stainherit, + (m.merge).stanullfrac, + (m.merge).stawidth, + (m.merge).stadistinct, + (m.merge).stakind1, + (m.merge).stakind2, + (m.merge).stakind3, + (m.merge).stakind4, + (m.merge).stakind5, + (m.merge).staop1, + (m.merge).staop2, + (m.merge).staop3, + (m.merge).staop4, + (m.merge).staop5, + (m.merge).stanumbers1, + (m.merge).stanumbers2, + (m.merge).stanumbers3, + (m.merge).stanumbers4, + (m.merge).stanumbers5, + (m.merge).stavalues1, + (m.merge).stavalues2, + (m.merge).stavalues3, + (m.merge).stavalues4 + ,(m.merge).stavalues5 + FROM (SELECT dbms_stats.merge(v, s) + FROM dbms_stats.column_stats_locked v, + pg_statistic s + WHERE v.starelid = 'st0'::regclass + AND v.staattnum = '2'::int2 + AND s.starelid = 'st0'::regclass + AND s.staattnum = '1'::int2) m; + starelid | staattnum | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+---------------------------+-------------------+------------+-----------------------------------+------------------------------------------- + st0 | 2 | t | -2 | -2 | -2 | 2 | 3 | 4 | 1 | 5 | 22 | 23 | 24 | 21 | 25 | {-2,22} | {-2,23} | {-2,24} | {-2,21} | {-2,25} | {"test ","test ","test "} | {"test ","test "} | {"test "} | {"test ","test ","test ","test "} | {"test ","test ","test ","test ","test "} +(1 row) + +-- No.5-1-16 +SELECT dbms_stats.merge(( + v.starelid::regclass, v.staattnum, v.stainherit, + v.stanullfrac, v.stawidth, v.stadistinct, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL + ,NULL, NULL, NULL, NULL + ), ( + s.starelid::regclass, s.staattnum, s.stainherit, + s.stanullfrac, s.stawidth, s.stadistinct, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL)) + FROM dbms_stats.column_stats_locked v, + pg_statistic s + WHERE v.starelid = 'st0'::regclass + AND v.staattnum = '2'::int2 + AND s.starelid = 'st0'::regclass + AND s.staattnum = '1'::int2; +ERROR: cannot cast type record to dbms_stats.column_stats_locked +LINE 1: SELECT dbms_stats.merge(( + ^ +DETAIL: Input has too few columns. +-- No.5-1-17 +SELECT (m.merge).starelid::regclass, + (m.merge).staattnum, + (m.merge).stainherit, + (m.merge).stanullfrac, + (m.merge).stawidth, + (m.merge).stadistinct, + (m.merge).stakind1, + (m.merge).stakind2, + (m.merge).stakind3, + (m.merge).stakind4, + (m.merge).stakind5, + (m.merge).staop1, + (m.merge).staop2, + (m.merge).staop3, + (m.merge).staop4, + (m.merge).staop5, + (m.merge).stanumbers1, + (m.merge).stanumbers2, + (m.merge).stanumbers3, + (m.merge).stanumbers4, + (m.merge).stanumbers5, + (m.merge).stavalues1, + (m.merge).stavalues2, + (m.merge).stavalues3, + (m.merge).stavalues4 + ,(m.merge).stavalues5 + FROM (SELECT dbms_stats.merge(( + v.starelid::regclass, v.staattnum, v.stainherit, + v.stanullfrac, v.stawidth, v.stadistinct, + v.stakind1, v.stakind2, v.stakind3, v.stakind4, + v.stakind5, + v.staop1, v.staop2, v.staop3, + v.staop4, + NULL, v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, + v.stanumbers5, + v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 + ,v.stavalues5 + ), ( + s.starelid::regclass, s.staattnum, s.stainherit, + s.stanullfrac, s.stawidth, s.stadistinct, + s.stakind1, s.stakind2, s.stakind3, s.stakind4, + s.stakind5, + s.staop1, s.staop2, s.staop3, s.staop4, + s.staop5, + s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, + s.stanumbers5, + s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 + ,s.stavalues5 + )) + FROM dbms_stats.column_stats_locked v, + pg_statistic s + WHERE v.starelid = 'st0'::regclass + AND v.staattnum = '1'::int2 + AND s.starelid = 'st0'::regclass + AND s.staattnum = '1'::int2) m; +ERROR: cannot cast type record to dbms_stats.column_stats_locked +LINE 34: NULL, v.stanumbers1, v.stanumbers2, v.stanumbe... + ^ +DETAIL: Cannot cast type real[] to oid in column 17. +-- No.5-1-18 +SELECT dbms_stats.merge(( + v.starelid::regclass, v.staattnum, v.stainherit, + v.stanullfrac, v.stawidth, v.stadistinct, + v.stakind1, v.stakind2, v.stakind3, v.stakind4, + v.stakind5, + v.staop1, v.staop2, v.staop3, + v.staop4, + NULL, v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, + v.stanumbers5, + v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 + ,v.stavalues5 + ), ( + s.starelid::regclass, s.staattnum, s.stainherit, + s.stanullfrac, s.stawidth, s.stadistinct, + s.stakind1, s.stakind2, s.stakind3, s.stakind4, + s.stakind5, + s.staop1, s.staop2, s.staop3, + s.staop4, + NULL, s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, + s.stanumbers5, + s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 + ,s.stavalues5 + )) + FROM dbms_stats.column_stats_locked v, + pg_statistic s + WHERE v.starelid = 'st0'::regclass + AND v.staattnum = '1'::int2 + AND s.starelid = 'st0'::regclass + AND s.staattnum = '1'::int2; +ERROR: cannot cast type record to dbms_stats.column_stats_locked +LINE 8: NULL, v.stanumbers1, v.stanumbers2, v.stanumbers3, v.... + ^ +DETAIL: Cannot cast type real[] to oid in column 17. +-- No.5-1-19 +SELECT (m.merge).starelid::regclass, + (m.merge).staattnum, + (m.merge).stainherit, + (m.merge).stanullfrac, + (m.merge).stawidth, + (m.merge).stadistinct, + (m.merge).stakind1, + (m.merge).stakind2, + (m.merge).stakind3, + (m.merge).stakind4, + (m.merge).stakind5, + (m.merge).staop1, + (m.merge).staop2, + (m.merge).staop3, + (m.merge).staop4, + (m.merge).staop5, + (m.merge).stanumbers1, + (m.merge).stanumbers2, + (m.merge).stanumbers3, + (m.merge).stanumbers4, + (m.merge).stanumbers5, + (m.merge).stavalues1, + (m.merge).stavalues2, + (m.merge).stavalues3, + (m.merge).stavalues4 + ,(m.merge).stavalues5 + FROM (SELECT dbms_stats.merge(( + v.starelid::regclass, v.staattnum, v.stainherit, + v.stanullfrac, v.stawidth, v.stadistinct, + '1', '1', '1', '1', + '1', + v.staop1, v.staop2, v.staop3, v.staop4, + v.staop5, + v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, + v.stanumbers5, + v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 + ,v.stavalues5 + ), ( + s.starelid::regclass, s.staattnum, s.stainherit, + s.stanullfrac, s.stawidth, s.stadistinct, + '1', '1', '1', '1', + '1', + s.staop1, s.staop2, s.staop3, s.staop4, + s.staop5, + s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, + s.stanumbers5, + s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 + ,s.stavalues5 + )) + FROM dbms_stats.column_stats_locked v, + pg_statistic s + WHERE v.starelid = 'st0'::regclass + AND v.staattnum = '2'::int2 + AND s.starelid = 'st0'::regclass + AND s.staattnum = '1'::int2) m; +ERROR: cannot cast type record to dbms_stats.column_stats_locked +LINE 34: v.stanumbers1, v.stanumbers2, v.stanumbers3, v... + ^ +DETAIL: Cannot cast type real[] to oid in column 17. +-- No.5-1-20 +SELECT (m.merge).starelid::regclass, + (m.merge).staattnum, + (m.merge).stainherit, + (m.merge).stanullfrac, + (m.merge).stawidth, + (m.merge).stadistinct, + (m.merge).stakind1, + (m.merge).stakind2, + (m.merge).stakind3, + (m.merge).stakind4, + (m.merge).stakind5, + (m.merge).staop1, + (m.merge).staop2, + (m.merge).staop3, + (m.merge).staop4, + (m.merge).staop5, + (m.merge).stanumbers1, + (m.merge).stanumbers2, + (m.merge).stanumbers3, + (m.merge).stanumbers4, + (m.merge).stanumbers5, + (m.merge).stavalues1, + (m.merge).stavalues2, + (m.merge).stavalues3, + (m.merge).stavalues4 + ,(m.merge).stavalues5 + FROM (SELECT dbms_stats.merge((v.starelid::regclass, v.staattnum, v.stainherit, + v.stanullfrac, v.stawidth, v.stadistinct, + '2', '2', '2', '2', + '2', + v.staop1, v.staop2, v.staop3, v.staop4, + v.staop5, + v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, + v.stanumbers5, + v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 + ,v.stavalues5 + ), ( + s.starelid::regclass, s.staattnum, s.stainherit, + s.stanullfrac, s.stawidth, s.stadistinct, + '2', '2', '2', '2', + '2', + s.staop1, s.staop2, s.staop3, s.staop4, + s.staop5, + s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, + s.stanumbers5, + s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 + ,s.stavalues5 + )) + FROM dbms_stats.column_stats_locked v, + pg_statistic s + WHERE v.starelid = 'st0'::regclass + AND v.staattnum = '2'::int2 + AND s.starelid = 'st0'::regclass + AND s.staattnum = '1'::int2) m; +ERROR: cannot cast type record to dbms_stats.column_stats_locked +LINE 33: v.stanumbers1, v.stanumbers2, v.stanumbers3, v... + ^ +DETAIL: Cannot cast type real[] to oid in column 17. +-- No.5-1-21 +SELECT dbms_stats.merge((v.starelid::regclass, '2', v.stainherit, + v.stanullfrac, v.stawidth, v.stadistinct, + '1', '1', '1', '1', + '1', + v.staop1, v.staop2, v.staop3, v.staop4, + v.staop5, + v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, + v.stanumbers5, + v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 + ,v.stavalues5 + ), ( + s.starelid::regclass, s.staattnum, s.stainherit, + s.stanullfrac, s.stawidth, s.stadistinct, + '1', '1', '1', '1', + '1', + s.staop1, s.staop2, s.staop3, s.staop4, + s.staop5, + s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, + s.stanumbers5, + s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 + ,s.stavalues5 + )) + FROM dbms_stats.column_stats_locked v, + pg_statistic s + WHERE v.starelid = 'st0'::regclass + AND v.staattnum = '1'::int2 + AND s.starelid = 'st0'::regclass + AND s.staattnum = '1'::int2; +ERROR: cannot cast type record to dbms_stats.column_stats_locked +LINE 7: v.stanumbers1, v.stanumbers2, v.stanumbers3, v... + ^ +DETAIL: Cannot cast type real[] to oid in column 17. +-- No.5-1-22 +SELECT dbms_stats.merge((v.starelid::regclass, '2', v.stainherit, + v.stanullfrac, v.stawidth, v.stadistinct, + '2', '2', '2', '2', + '2', + v.staop1, v.staop2, v.staop3, v.staop4, + v.staop5, + v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, + v.stanumbers5, + v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 + ,v.stavalues5 + ), ( + s.starelid::regclass, s.staattnum, s.stainherit, + s.stanullfrac, s.stawidth, s.stadistinct, + '2', '2', '2', '2', + '2', + s.staop1, s.staop2, s.staop3, s.staop4, + s.staop5, + s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, + s.stanumbers5, + s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 + ,s.stavalues5 + )) + FROM dbms_stats.column_stats_locked v, + pg_statistic s + WHERE v.starelid = 'st0'::regclass + AND v.staattnum = '1'::int2 + AND s.starelid = 'st0'::regclass + AND s.staattnum = '1'::int2; +ERROR: cannot cast type record to dbms_stats.column_stats_locked +LINE 7: v.stanumbers1, v.stanumbers2, v.stanumbers3, v... + ^ +DETAIL: Cannot cast type real[] to oid in column 17. +RESET client_min_messages; +SELECT dbms_stats.unlock_database_stats(); + unlock_database_stats +----------------------- + st0 +(1 row) + +/* + * No.6-4 dbms_stats.is_target_relkind + */ +-- No.6-4- 10-11 +SELECT dbms_stats.is_target_relkind(k::"char") + FROM (VALUES ('r'), ('i'), ('f'), ('m'), + ('S'), ('t'), ('v'), ('c')) t(k); + is_target_relkind +------------------- + t + t + t + t + f + f + f + f +(8 rows) + +/* + * No.7-1 dbms_stats.backup + */ +DELETE FROM dbms_stats.backup_history; +INSERT INTO dbms_stats.backup_history(id, time, unit) values(1, '2012-01-01', 'd'); +-- No.7-1-9 +SELECT dbms_stats.backup(1, 's0.sft0'::regclass, NULL); + backup +-------- + 1 +(1 row) + +SELECT count(*) FROM dbms_stats.relation_stats_backup; + count +------- + 1 +(1 row) + +SELECT count(*) FROM dbms_stats.column_stats_backup; + count +------- + 1 +(1 row) + +-- No.7-1-10 +DELETE FROM dbms_stats.relation_stats_backup; +SELECT dbms_stats.backup(1, 's0.smv0'::regclass, NULL); + backup +-------- + 1 +(1 row) + +SELECT count(*) FROM dbms_stats.relation_stats_backup; + count +------- + 1 +(1 row) + +SELECT count(*) FROM dbms_stats.column_stats_backup; + count +------- + 3 +(1 row) + +-- No.7-1-12 +DELETE FROM dbms_stats.relation_stats_backup; +SELECT dbms_stats.backup(1, NULL, 1::int2); + backup +-------- + 1 +(1 row) + +SELECT relid::regclass FROM dbms_stats.relation_stats_backup + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + s1.st0 + st1_idx + st1_exp + s0.sft0 + s0.smv0 +(16 rows) + +SELECT starelid::regclass, staattnum FROM dbms_stats.column_stats_backup + GROUP BY starelid, staattnum + ORDER BY starelid, staattnum; + starelid | staattnum +----------+----------- + st0 | 1 + st1 | 1 + s0.st0 | 1 + s0.st1 | 1 + s0.st2 | 1 + s1.st0 | 1 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 1 +(9 rows) + +-- No.7-1-14 +DELETE FROM dbms_stats.relation_stats_backup; +SELECT dbms_stats.backup(1, NULL::regclass, NULL); + backup +-------- + 1 +(1 row) + +SELECT relid::regclass FROM dbms_stats.relation_stats_backup + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + s1.st0 + st1_idx + st1_exp + s0.sft0 + s0.smv0 +(16 rows) + +SELECT starelid::regclass, staattnum FROM dbms_stats.column_stats_backup + GROUP BY starelid, staattnum + ORDER BY starelid, staattnum; + starelid | staattnum +----------+----------- + st0 | 1 + st0 | 2 + st1 | 1 + st1 | 2 + s0.st0 | 1 + s0.st0 | 2 + s0.st1 | 1 + s0.st1 | 2 + s0.st2 | 1 + s0.st2 | 2 + s1.st0 | 1 + s1.st0 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 1 + s0.smv0 | 2 + s0.smv0 | 3 +(17 rows) + +-- No.7-1-18 +DELETE FROM dbms_stats.relation_stats_backup; +\! psql contrib_regression -c "SELECT dbms_stats.backup(NULL, 's0.st0'::regclass, NULL)" > results/ut_no2_1_17.out 2>&1 +SELECT count(*) FROM dbms_stats.relation_stats_backup; + count +------- + 0 +(1 row) + +SELECT count(*) FROM dbms_stats.column_stats_backup; + count +------- + 0 +(1 row) + +/* + * No.8-1 dbms_stats.backup + */ +SELECT setval('dbms_stats.backup_history_id_seq',1, false); + setval +-------- + 1 +(1 row) + +/* + * Stab function dbms_stats.backup + */ +ALTER FUNCTION dbms_stats.backup( + backup_id int8, + relid regclass, + attnum int2) + RENAME TO truth_func_backup; +CREATE OR REPLACE FUNCTION dbms_stats.backup( + backup_id int8, + regclass, + attnum int2) +RETURNS int8 AS +$$ +BEGIN + RAISE NOTICE 'arguments are %, %, %', $1, $2, $3; + RETURN 1; +END; +$$ +LANGUAGE plpgsql; +-- No.8-1-1 +DELETE FROM dbms_stats.backup_history; +SELECT dbms_stats.backup('s0.st0'::regclass, 'id', 'dummy comment'); +NOTICE: arguments are 1, s0.st0, 1 + backup +-------- + 1 +(1 row) + +SELECT id, unit, comment FROM dbms_stats.backup_history; + id | unit | comment +----+------+--------------- + 1 | c | dummy comment +(1 row) + +-- No.8-1-2 +DELETE FROM dbms_stats.backup_history; +SELECT dbms_stats.backup('s0.st0'::regclass, NULL, 'dummy comment'); +NOTICE: arguments are 2, s0.st0, + backup +-------- + 1 +(1 row) + +SELECT id, unit, comment FROM dbms_stats.backup_history; + id | unit | comment +----+------+--------------- + 2 | t | dummy comment +(1 row) + +-- No.8-1-3 +DELETE FROM dbms_stats.backup_history; +SELECT dbms_stats.backup(NULL::regclass, 'id', 'dummy comment'); +ERROR: relation required +CONTEXT: PL/pgSQL function dbms_stats.backup(regclass,text,text) line 9 at RAISE +SELECT id, unit, comment FROM dbms_stats.backup_history; + id | unit | comment +----+------+--------- +(0 rows) + +-- No.8-1-4 +DELETE FROM dbms_stats.backup_history; +SELECT dbms_stats.backup(NULL::regclass, NULL, 'dummy comment'); +NOTICE: arguments are 3, , + backup +-------- + 1 +(1 row) + +SELECT id, unit, comment FROM dbms_stats.backup_history; + id | unit | comment +----+------+--------------- + 3 | d | dummy comment +(1 row) + +-- No.8-1-5 +DELETE FROM dbms_stats.backup_history; +SELECT dbms_stats.backup(0, NULL, 'dummy comment'); +ERROR: relation "-" not found +CONTEXT: PL/pgSQL function dbms_stats.backup(regclass,text,text) line 15 at RAISE +SELECT id, unit, comment FROM dbms_stats.backup_history; + id | unit | comment +----+------+--------- +(0 rows) + +-- No.8-1-6 +DELETE FROM dbms_stats.backup_history; +SELECT dbms_stats.backup('s0.st0'::regclass, NULL, 'dummy comment'); +NOTICE: arguments are 4, s0.st0, + backup +-------- + 1 +(1 row) + +SELECT id, unit, comment FROM dbms_stats.backup_history; + id | unit | comment +----+------+--------------- + 4 | t | dummy comment +(1 row) + +-- No.8-1-7 +DELETE FROM dbms_stats.backup_history; +SELECT dbms_stats.backup( + 'pg_toast.pg_toast_2618'::regclass, + NULL, + 'dummy comment'); +ERROR: relation of relkind "t" cannot have statistics to backup: "pg_toast.pg_toast_2618" +HINT: Only tables(r), materialized views(m), foreign tables(f) and indexes(i) are allowed. +CONTEXT: PL/pgSQL function dbms_stats.backup(regclass,text,text) line 18 at RAISE +SELECT id, unit, comment FROM dbms_stats.backup_history; + id | unit | comment +----+------+--------- +(0 rows) + +-- No.8-1-8 +DELETE FROM dbms_stats.backup_history; +SELECT dbms_stats.backup('s0.st0_idx'::regclass, NULL, 'dummy comment'); +NOTICE: arguments are 5, s0.st0_idx, + backup +-------- + 1 +(1 row) + +SELECT id, unit, comment FROM dbms_stats.backup_history; + id | unit | comment +----+------+--------------- + 5 | t | dummy comment +(1 row) + +-- No.8-1-9 +DELETE FROM dbms_stats.backup_history; +SELECT dbms_stats.backup('s0.ss0'::regclass, NULL, 'dummy comment'); +ERROR: relation of relkind "S" cannot have statistics to backup: "s0.ss0" +HINT: Only tables(r), materialized views(m), foreign tables(f) and indexes(i) are allowed. +CONTEXT: PL/pgSQL function dbms_stats.backup(regclass,text,text) line 18 at RAISE +SELECT id, unit, comment FROM dbms_stats.backup_history; + id | unit | comment +----+------+--------- +(0 rows) + +-- No.8-1-10 +DELETE FROM dbms_stats.backup_history; +SELECT dbms_stats.backup('s0.sc0'::regclass, NULL, 'dummy comment'); +ERROR: relation of relkind "c" cannot have statistics to backup: "s0.sc0" +HINT: Only tables(r), materialized views(m), foreign tables(f) and indexes(i) are allowed. +CONTEXT: PL/pgSQL function dbms_stats.backup(regclass,text,text) line 18 at RAISE +SELECT id, unit, comment FROM dbms_stats.backup_history; + id | unit | comment +----+------+--------- +(0 rows) + +-- No.8-1-11 +DELETE FROM dbms_stats.backup_history; +SELECT dbms_stats.backup('s0.sft0'::regclass, NULL, 'dummy comment'); +NOTICE: arguments are 6, s0.sft0, + backup +-------- + 1 +(1 row) + +SELECT id, unit, comment FROM dbms_stats.backup_history; + id | unit | comment +----+------+--------------- + 6 | t | dummy comment +(1 row) + +-- No.8-1-12 +DELETE FROM dbms_stats.backup_history; +SELECT dbms_stats.backup('s0.smv0'::regclass, NULL, 'dummy comment'); +NOTICE: arguments are 7, s0.smv0, + backup +-------- + 1 +(1 row) + +SELECT id, unit, comment FROM dbms_stats.backup_history; + id | unit | comment +----+------+--------------- + 7 | t | dummy comment +(1 row) + +-- No.8-1-13 +DELETE FROM dbms_stats.backup_history; +SELECT dbms_stats.backup('pg_catalog.pg_class'::regclass, NULL, 'dummy comment'); +ERROR: backing up statistics is inhibited for system catalogs: "pg_class" +CONTEXT: PL/pgSQL function dbms_stats.backup(regclass,text,text) line 23 at RAISE +SELECT id, unit, comment FROM dbms_stats.backup_history; + id | unit | comment +----+------+--------- +(0 rows) + +-- No.8-1-14 +DELETE FROM dbms_stats.backup_history; +SELECT dbms_stats.backup('s0.st0'::regclass, 'dummy', 'dummy comment'); +ERROR: column "dummy" not found in relation "s0.st0" +CONTEXT: PL/pgSQL function dbms_stats.backup(regclass,text,text) line 29 at RAISE +SELECT id, unit, comment FROM dbms_stats.backup_history; + id | unit | comment +----+------+--------- +(0 rows) + +-- No.8-1-15 +DELETE FROM dbms_stats.backup_history; +DELETE FROM pg_statistic + WHERE starelid = 's0.st0'::regclass + AND staattnum = 1::int2; +SELECT count(*) FROM dbms_stats.column_stats_effective + WHERE starelid = 's0.st0'::regclass + AND staattnum = 1::int2; + count +------- + 0 +(1 row) + +SELECT dbms_stats.backup('s0.st0'::regclass, 'id', 'dummy comment'); +ERROR: no statistics available for column "id" of relation "s0.st0" +CONTEXT: PL/pgSQL function dbms_stats.backup(regclass,text,text) line 32 at RAISE +SELECT id, unit, comment FROM dbms_stats.backup_history; + id | unit | comment +----+------+--------- +(0 rows) + +/* + * Stab function dbms_stats.backup + */ +ALTER FUNCTION dbms_stats.backup( + relid regclass, + attname text, + comment text) + RENAME TO truth_func_backup; +CREATE OR REPLACE FUNCTION dbms_stats.backup( + relid regclass DEFAULT NULL, + attname text DEFAULT NULL, + comment text DEFAULT NULL) +RETURNS int8 AS +$$ +BEGIN + IF $3 = '' THEN + RAISE NOTICE 'third argument is not NULL but string ""'; + END IF; + RAISE NOTICE 'arguments are %, %, %', $1, $2, $3; + RETURN 1; +END; +$$ +LANGUAGE plpgsql; +/* + * No.8-3 dbms_stats.backup_schema_stats + */ +SELECT setval('dbms_stats.backup_history_id_seq',9, false); + setval +-------- + 9 +(1 row) + +-- No.8-3-1 +SELECT dbms_stats.backup_schema_stats('s0', 'comment'); +NOTICE: arguments are 9, s0.st0, +NOTICE: arguments are 9, s0.st0_idx, +NOTICE: arguments are 9, s0.st1, +NOTICE: arguments are 9, s0.st1_idx, +NOTICE: arguments are 9, s0.st2, +NOTICE: arguments are 9, s0.st2_idx, +NOTICE: arguments are 9, s0.sft0, +NOTICE: arguments are 9, s0.smv0, + backup_schema_stats +--------------------- + 9 +(1 row) + +SELECT id, unit, comment FROM dbms_stats.backup_history + ORDER BY id DESC + LIMIT 1; + id | unit | comment +----+------+--------- + 9 | s | comment +(1 row) + +-- No.8-3-2 +SELECT dbms_stats.backup_schema_stats('s00', 'comment'); +ERROR: schema "s00" not found +CONTEXT: PL/pgSQL function dbms_stats.backup_schema_stats(text,text) line 7 at RAISE +SELECT id, unit, comment FROM dbms_stats.backup_history + ORDER BY id DESC + LIMIT 1; + id | unit | comment +----+------+--------- + 9 | s | comment +(1 row) + +-- No.8-3-3 +SELECT dbms_stats.backup_schema_stats('pg_catalog', 'comment'); +ERROR: backing up statistics is inhibited for system schemas: "pg_catalog" +CONTEXT: PL/pgSQL function dbms_stats.backup_schema_stats(text,text) line 10 at RAISE +SELECT id, unit, comment FROM dbms_stats.backup_history + ORDER BY id DESC + LIMIT 1; + id | unit | comment +----+------+--------- + 9 | s | comment +(1 row) + +/* + * Delete stab function dbms_stats.backup + */ +DROP FUNCTION dbms_stats.backup( + backup_id int8, + regclass, + attnum int2); +ALTER FUNCTION dbms_stats.truth_func_backup( + backup_id int8, + regclass, + attnum int2) + RENAME TO backup; +DROP FUNCTION dbms_stats.backup( + regclass, + attname text, + comment text); +ALTER FUNCTION dbms_stats.truth_func_backup( + regclass, + attname text, + comment text) + RENAME TO backup; +VACUUM ANALYZE; +/* + * create backup statistics state A + */ +DELETE FROM dbms_stats.backup_history; +INSERT INTO dbms_stats.backup_history(id, time, unit) + VALUES (1, '2012-02-29 23:59:56.999999', 'd'); +SELECT setval('dbms_stats.backup_history_id_seq',1); + setval +-------- + 1 +(1 row) + +SELECT dbms_stats.backup(); + backup +-------- + 2 +(1 row) + +UPDATE dbms_stats.backup_history + SET time = '2012-02-29 23:59:57' + WHERE id = 2; +SELECT dbms_stats.backup('s0.st0'); + backup +-------- + 3 +(1 row) + +UPDATE dbms_stats.backup_history + SET time = '2012-02-29 23:59:57.000001' + WHERE id = 3; +SELECT dbms_stats.backup(); + backup +-------- + 4 +(1 row) + +UPDATE dbms_stats.backup_history + SET time = '2012-02-29 23:59:58' + WHERE id = 4; +DELETE FROM dbms_stats.relation_stats_backup + WHERE id = 4; +SELECT dbms_stats.backup('s0.st0', 'id'); + backup +-------- + 5 +(1 row) + +UPDATE dbms_stats.backup_history + SET time = '2012-03-01 00:00:00' + WHERE id = 5; +SELECT dbms_stats.backup('s0.st0'); + backup +-------- + 6 +(1 row) + +UPDATE dbms_stats.backup_history + SET time = '2012-03-01 00:00:02' + WHERE id = 6; +SELECT dbms_stats.backup('public.st0'); + backup +-------- + 7 +(1 row) + +UPDATE dbms_stats.backup_history + SET time = '2012-03-01 00:00:04' + WHERE id = 7; +INSERT INTO dbms_stats.backup_history(time, unit) + VALUES ('2012-03-01 00:00:06', 's'); +SELECT dbms_stats.backup(8, c.oid, NULL) + FROM pg_catalog.pg_class c, + pg_catalog.pg_namespace n + WHERE n.nspname = 's0' + AND c.relnamespace = n.oid + AND c.relkind IN ('r', 'i'); + backup +-------- + 8 + 8 + 8 + 8 + 8 + 8 +(6 rows) + +SELECT * FROM dbms_stats.backup_history + ORDER BY id; + id | time | unit | comment +----+-------------------------------------+------+--------- + 1 | Wed Feb 29 23:59:56.999999 2012 PST | d | (null) + 2 | Wed Feb 29 23:59:57 2012 PST | d | (null) + 3 | Wed Feb 29 23:59:57.000001 2012 PST | t | (null) + 4 | Wed Feb 29 23:59:58 2012 PST | d | (null) + 5 | Thu Mar 01 00:00:00 2012 PST | c | (null) + 6 | Thu Mar 01 00:00:02 2012 PST | t | (null) + 7 | Thu Mar 01 00:00:04 2012 PST | t | (null) + 8 | Thu Mar 01 00:00:06 2012 PST | s | (null) +(8 rows) + +SELECT * FROM relations_backup_v; + id | relid | relname | relpages | reltuples | relallvisible | curpages +----+------------+----------------+----------+-----------+---------------+---------- + 2 | pt0 | public.pt0 | 0 | 0 | 0 | 0 + 2 | pt0_idx | public.pt0_idx | 2 | 0 | 0 | 2 + 2 | st0 | public.st0 | 1 | 2 | 1 | 1 + 2 | st0_idx | public.st0_idx | 2 | 2 | 0 | 2 + 2 | st1 | public.st1 | 45 | 10000 | 45 | 45 + 2 | s0.st0 | s0.st0 | 1 | 2 | 1 | 1 + 2 | s0.st0_idx | s0.st0_idx | 2 | 2 | 0 | 2 + 2 | s0.st1 | s0.st1 | 1 | 3 | 1 | 1 + 2 | s0.st1_idx | s0.st1_idx | 2 | 3 | 0 | 2 + 2 | s0.st2 | s0.st2 | 1 | 3 | 1 | 1 + 2 | s0.st2_idx | s0.st2_idx | 2 | 3 | 0 | 2 + 2 | s1.st0 | s1.st0 | 1 | 4 | 1 | 1 + 2 | st1_idx | public.st1_idx | 30 | 10000 | 0 | 30 + 2 | st1_exp | public.st1_exp | 30 | 10000 | 0 | 30 + 2 | s0.sft0 | s0.sft0 | 1 | 10 | 0 | 0 + 2 | s0.smv0 | s0.smv0 | 1 | 2 | 1 | 1 + 3 | s0.st0 | s0.st0 | 1 | 2 | 1 | 1 + 5 | s0.st0 | s0.st0 | 1 | 2 | 1 | 1 + 6 | s0.st0 | s0.st0 | 1 | 2 | 1 | 1 + 7 | st0 | public.st0 | 1 | 2 | 1 | 1 + 8 | s0.st0 | s0.st0 | 1 | 2 | 1 | 1 + 8 | s0.st0_idx | s0.st0_idx | 2 | 2 | 0 | 2 + 8 | s0.st1 | s0.st1 | 1 | 3 | 1 | 1 + 8 | s0.st1_idx | s0.st1_idx | 2 | 3 | 0 | 2 + 8 | s0.st2 | s0.st2 | 1 | 3 | 1 | 1 + 8 | s0.st2_idx | s0.st2_idx | 2 | 3 | 0 | 2 +(26 rows) + +SELECT * FROM columns_backup_v; + id | statypid | starelid | staattnum | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----+----------+----------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+------------------------+-------------+-------------+-------------+-------------+------------------------+------------+------------+------------+------------ + 2 | 23 | st0 | 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) + 2 | 1042 | st0 | 2 | 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) + 2 | 23 | st1 | 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) + 2 | 25 | st1 | 2 | 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) + 2 | 23 | s0.st0 | 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) + 2 | 23 | s0.st0 | 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) + 2 | 23 | s0.st0 | 2 | 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) + 2 | 23 | s0.st0 | 2 | 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) + 2 | 23 | s0.st1 | 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) + 2 | 23 | s0.st1 | 2 | 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) + 2 | 23 | s0.st2 | 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) + 2 | 25 | s0.st2 | 2 | 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) + 2 | 23 | s1.st0 | 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) + 2 | 23 | s1.st0 | 2 | 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) + 2 | 25 | st1_exp | 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) + 2 | 23 | s0.sft0 | 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) + 2 | 23 | s0.smv0 | 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) + 2 | 23 | s0.smv0 | 2 | 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) + 2 | 25 | s0.smv0 | 3 | 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) + 3 | 23 | s0.st0 | 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) + 3 | 23 | s0.st0 | 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) + 3 | 23 | s0.st0 | 2 | 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) + 3 | 23 | s0.st0 | 2 | 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) + 5 | 23 | s0.st0 | 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) + 5 | 23 | s0.st0 | 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) + 6 | 23 | s0.st0 | 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) + 6 | 23 | s0.st0 | 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) + 6 | 23 | s0.st0 | 2 | 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) + 6 | 23 | s0.st0 | 2 | 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) + 7 | 23 | st0 | 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) + 7 | 1042 | st0 | 2 | 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) + 8 | 23 | s0.st0 | 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) + 8 | 23 | s0.st0 | 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) + 8 | 23 | s0.st0 | 2 | 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) + 8 | 23 | s0.st0 | 2 | 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) + 8 | 23 | s0.st1 | 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) + 8 | 23 | s0.st1 | 2 | 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) + 8 | 23 | s0.st2 | 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) + 8 | 25 | s0.st2 | 2 | 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) +(39 rows) + +VACUUM ANALYZE; +/* + * No.9-1 dbms_stats.restore + */ +-- No.9-1-1 +DELETE FROM dbms_stats.relation_stats_locked; +VACUUM dbms_stats.relation_stats_locked; -- in order to avoid auto vacuum +BEGIN; +SELECT * FROM internal_locks; + relation | mode +----------+------ +(0 rows) + +SELECT dbms_stats.restore(2, 's0.st0', NULL); + restore +--------- + s0.st0 +(1 row) + +SELECT * FROM internal_locks; + relation | mode +----------------------------------+------------------ + dbms_stats.backup_history | RowShareLock + dbms_stats.column_stats_backup | AccessShareLock + dbms_stats.column_stats_locked | RowExclusiveLock + dbms_stats.relation_stats_backup | AccessShareLock + dbms_stats.relation_stats_backup | RowShareLock + dbms_stats.relation_stats_locked | RowExclusiveLock + dbms_stats.relation_stats_locked | RowShareLock +(7 rows) + +COMMIT; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +-------- + s0.st0 +(1 row) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + s0.st0 | id | f + s0.st0 | id | t + s0.st0 | num | f + s0.st0 | num | t +(4 rows) + +-- No.9-1-2 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.restore(2, 'st0', NULL); + restore +--------- + st0 +(1 row) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------- + st0 +(1 row) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + st0 | id | f + st0 | name | f +(2 rows) + +-- No.9-1-3 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.restore(2, 's00.s0', NULL); +ERROR: schema "s00" does not exist +LINE 1: SELECT dbms_stats.restore(2, 's00.s0', NULL); + ^ +SELECT count(*) FROM dbms_stats.column_stats_locked; + count +------- + 0 +(1 row) + +SELECT count(*) FROM dbms_stats.relation_stats_locked; + count +------- + 0 +(1 row) + +-- No.9-1-4 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.restore(NULL, 's0.st0', NULL); +ERROR: backup id required +CONTEXT: PL/pgSQL function dbms_stats.restore(bigint,regclass,text) line 12 at RAISE +SELECT count(*) FROM dbms_stats.column_stats_locked; + count +------- + 0 +(1 row) + +SELECT count(*) FROM dbms_stats.relation_stats_locked; + count +------- + 0 +(1 row) + +-- No.9-1-5 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.restore(2, 's0.st0', 'id'); + restore +--------- + s0.st0 +(1 row) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +-------- + s0.st0 +(1 row) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + s0.st0 | id | f + s0.st0 | id | t +(2 rows) + +-- No.9-1-6 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.restore(2, NULL, 'id'); +ERROR: relation required +CONTEXT: PL/pgSQL function dbms_stats.restore(bigint,regclass,text) line 15 at RAISE +SELECT count(*) FROM dbms_stats.column_stats_locked; + count +------- + 0 +(1 row) + +SELECT count(*) FROM dbms_stats.relation_stats_locked; + count +------- + 0 +(1 row) + +-- No.9-1-7 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.restore(2, 's0.st0', NULL); + restore +--------- + s0.st0 +(1 row) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +-------- + s0.st0 +(1 row) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + s0.st0 | id | f + s0.st0 | id | t + s0.st0 | num | f + s0.st0 | num | t +(4 rows) + +-- No.9-1-8 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.restore(2, NULL, NULL); + restore +------------ + pt0 + pt0_idx + s0.sft0 + s0.smv0 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + s1.st0 + st0 + st0_idx + st1 + st1_exp + st1_idx +(16 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + s1.st0 + st1_idx + st1_exp + s0.sft0 + s0.smv0 +(16 rows) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + st0 | id | f + st0 | name | f + st1 | val | f + st1 | str | f + s0.st0 | id | f + s0.st0 | id | t + s0.st0 | num | f + s0.st0 | num | t + s0.st1 | id | f + s0.st1 | num | f + s0.st2 | id | f + s0.st2 | txt | f + s1.st0 | id | f + s1.st0 | num | f + st1_exp | lower | f + s0.sft0 | id | f + s0.smv0 | id | f + s0.smv0 | num | f + s0.smv0 | txt | f +(19 rows) + +-- No.9-1-9 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.restore(0, 's0.st0', NULL); +ERROR: backup id 0 not found +CONTEXT: PL/pgSQL function dbms_stats.restore(bigint,regclass,text) line 19 at RAISE +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------- +(0 rows) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ +(0 rows) + +-- No.9-1-10 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.restore(2, 0, 'id'); +ERROR: relation "-" not found +CONTEXT: PL/pgSQL function dbms_stats.restore(bigint,regclass,text) line 24 at RAISE +SELECT count(*) FROM dbms_stats.column_stats_locked; + count +------- + 0 +(1 row) + +SELECT count(*) FROM dbms_stats.relation_stats_locked; + count +------- + 0 +(1 row) + +-- No.9-1-11 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.restore(1, 's0.st0', NULL); +ERROR: statistics of relation "s0.st0" not found in any backups before backup id = 1 +CONTEXT: PL/pgSQL function dbms_stats.restore(bigint,regclass,text) line 29 at RAISE +SELECT count(*) FROM dbms_stats.column_stats_locked; + count +------- + 0 +(1 row) + +SELECT count(*) FROM dbms_stats.relation_stats_locked; + count +------- + 0 +(1 row) + +-- No.9-1-12 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.restore(2, 's0.st0', 'dummy'); +ERROR: column "dummy" not found in relation s0.st0 +CONTEXT: PL/pgSQL function dbms_stats.restore(bigint,regclass,text) line 35 at RAISE +SELECT count(*) FROM dbms_stats.column_stats_locked; + count +------- + 0 +(1 row) + +SELECT count(*) FROM dbms_stats.relation_stats_locked; + count +------- + 0 +(1 row) + +-- No.9-1-13 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.restore(1, 's0.st0', 'id'); +ERROR: statistics of relation "s0.st0" not found in any backups before backup id = 1 +CONTEXT: PL/pgSQL function dbms_stats.restore(bigint,regclass,text) line 29 at RAISE +SELECT count(*) FROM dbms_stats.column_stats_locked; + count +------- + 0 +(1 row) + +SELECT count(*) FROM dbms_stats.relation_stats_locked; + count +------- + 0 +(1 row) + +-- No.9-1-15 +DELETE FROM dbms_stats.relation_stats_locked; +ALTER TABLE s1.st0 DROP COLUMN id; +SELECT dbms_stats.restore(2, 's1.st0', 'id'); +ERROR: column "id" not found in relation s1.st0 +CONTEXT: PL/pgSQL function dbms_stats.restore(bigint,regclass,text) line 35 at RAISE +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------- +(0 rows) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ +(0 rows) + +-- No.9-1-14 +DELETE FROM dbms_stats.relation_stats_locked; +\set s1_st0_oid `psql contrib_regression -tA -c "SELECT c.oid FROM pg_class c, pg_namespace n WHERE c.relnamespace = n.oid AND n.nspname = 's1' AND c.relname = 'st0';"` +DROP TABLE s1.st0; +-- SELECT dbms_stats.restore(2, :s1_st0_oid, NULL); +-- To avoid test unstability caused by relation id alloction, the test +-- above is omitted. +SELECT count(*) FROM dbms_stats.relation_stats_locked; + count +------- + 0 +(1 row) + +SELECT count(*) FROM dbms_stats.column_stats_locked; + count +------- + 0 +(1 row) + +CREATE TABLE s1.st0(id integer, num integer) WITH (autovacuum_enabled = 'false'); +INSERT INTO s1.st0 VALUES (1, 15), (2, 25), (3, 35), (4, 45); +VACUUM ANALYZE; +-- No.9-1-16 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.restore(2, 's0.st0', NULL); + restore +--------- + s0.st0 +(1 row) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +-------- + s0.st0 +(1 row) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + s0.st0 | id | f + s0.st0 | id | t + s0.st0 | num | f + s0.st0 | num | t +(4 rows) + +-- No.9-1-17 +DELETE FROM dbms_stats.relation_stats_locked; +INSERT INTO dbms_stats.relation_stats_backup( + id, relid, relname, relpages, reltuples, + relallvisible, + curpages) + VALUES (2, + 'pg_toast.pg_toast_2618'::regclass, + 'pg_toast.pg_toast_2618', 1, 1, + 1, + 1); +SELECT * FROM relations_backup_v + WHERE id = 2 + AND relname = 'pg_toast.pg_toast_2618'; + id | relid | relname | relpages | reltuples | relallvisible | curpages +----+------------------------+------------------------+----------+-----------+---------------+---------- + 2 | pg_toast.pg_toast_2618 | pg_toast.pg_toast_2618 | 1 | 1 | 1 | 1 +(1 row) + +SELECT dbms_stats.restore(2, 'pg_toast.pg_toast_2618', NULL); + restore +--------- +(0 rows) + +SELECT count(*) FROM dbms_stats.column_stats_locked; + count +------- + 0 +(1 row) + +SELECT count(*) FROM dbms_stats.relation_stats_locked; + count +------- + 0 +(1 row) + +DELETE FROM dbms_stats.relation_stats_backup + WHERE id = 2 + AND relname = 'pg_toast.pg_toast_2618'; +-- No.9-1-18 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.restore(2, 's0.st0_idx', NULL); + restore +------------ + s0.st0_idx +(1 row) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + s0.st0_idx +(1 row) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ +(0 rows) + +-- No.9-1-19 +DELETE FROM dbms_stats.relation_stats_locked; +INSERT INTO dbms_stats.relation_stats_backup( + id, relid, relname, relpages, reltuples, + relallvisible, + curpages) + VALUES (2, 's0.ss0'::regclass, 's0.ss0', 1, 1, + 1, + 1); +SELECT * FROM relations_backup_v + WHERE id = 2 + AND relname = 's0.ss0'; + id | relid | relname | relpages | reltuples | relallvisible | curpages +----+--------+---------+----------+-----------+---------------+---------- + 2 | s0.ss0 | s0.ss0 | 1 | 1 | 1 | 1 +(1 row) + +SELECT dbms_stats.restore(2, 's0.ss0', NULL); + restore +--------- +(0 rows) + +SELECT count(*) FROM dbms_stats.column_stats_locked; + count +------- + 0 +(1 row) + +SELECT count(*) FROM dbms_stats.relation_stats_locked; + count +------- + 0 +(1 row) + +DELETE FROM dbms_stats.relation_stats_backup + WHERE id = 2 + AND relname = 's0.ss0'; +-- No.9-1-20 +DELETE FROM dbms_stats.relation_stats_locked; +INSERT INTO dbms_stats.relation_stats_backup( + id, relid, relname, relpages, reltuples, + relallvisible, + curpages) + VALUES (2, 's0.sc0'::regclass, 's0.sc0', 1, 1, + 1, + 1); +SELECT * FROM relations_backup_v + WHERE id = 2 + AND relname = 's0.sc0'; + id | relid | relname | relpages | reltuples | relallvisible | curpages +----+--------+---------+----------+-----------+---------------+---------- + 2 | s0.sc0 | s0.sc0 | 1 | 1 | 1 | 1 +(1 row) + +SELECT dbms_stats.restore(2, 's0.sc0', NULL); + restore +--------- +(0 rows) + +SELECT count(*) FROM dbms_stats.column_stats_locked; + count +------- + 0 +(1 row) + +SELECT count(*) FROM dbms_stats.relation_stats_locked; + count +------- + 0 +(1 row) + +DELETE FROM dbms_stats.relation_stats_backup + WHERE id = 2 + AND relname = 's0.sc0'; +-- No.9-1-21 +DELETE FROM dbms_stats.relation_stats_locked; +INSERT INTO dbms_stats.relation_stats_backup( + id, relid, relname, relpages, reltuples, + relallvisible, + curpages) + VALUES (3, 's0.sft0'::regclass, 's0.sft0', 1, 1, + 1, + 1); +SELECT * FROM relations_backup_v + WHERE id = 3 + AND relname = 's0.sft0'; + id | relid | relname | relpages | reltuples | relallvisible | curpages +----+---------+---------+----------+-----------+---------------+---------- + 3 | s0.sft0 | s0.sft0 | 1 | 1 | 1 | 1 +(1 row) + +SELECT dbms_stats.restore(2, 's0.sft0', NULL); + restore +--------- + s0.sft0 +(1 row) + +SELECT count(*) FROM dbms_stats.column_stats_locked; + count +------- + 1 +(1 row) + +SELECT count(*) FROM dbms_stats.relation_stats_locked; + count +------- + 1 +(1 row) + +DELETE FROM dbms_stats.relation_stats_backup + WHERE id = 3 + AND relname = 's0.sft0'; +-- No.9-1-22 +DELETE FROM dbms_stats.relation_stats_locked; +INSERT INTO dbms_stats.relation_stats_backup( + id, relid, relname, relpages, reltuples, + relallvisible, + curpages) + VALUES (3, 's0.smv0'::regclass, 's0.smv0', 1, 1, + 1, + 1); +SELECT * FROM relations_backup_v + WHERE id = 3 + AND relname = 's0.smv0'; + id | relid | relname | relpages | reltuples | relallvisible | curpages +----+---------+---------+----------+-----------+---------------+---------- + 3 | s0.smv0 | s0.smv0 | 1 | 1 | 1 | 1 +(1 row) + +SELECT dbms_stats.restore(2, 's0.smv0', NULL); + restore +--------- + s0.smv0 +(1 row) + +SELECT count(*) FROM dbms_stats.column_stats_locked; + count +------- + 3 +(1 row) + +SELECT count(*) FROM dbms_stats.relation_stats_locked; + count +------- + 1 +(1 row) + +DELETE FROM dbms_stats.relation_stats_backup + WHERE id = 3 + AND relname = 's0.smv0'; +-- No.9-1-23 +DELETE FROM dbms_stats.relation_stats_locked; +INSERT INTO dbms_stats.relation_stats_backup( + id, relid, relname, relpages, reltuples, + relallvisible, + curpages) + VALUES (2, 'pg_catalog.pg_class'::regclass, 'pg_catalog.pg_class', 1, 1, + 1, + 1); +SELECT * FROM relations_backup_v + WHERE id = 2 + AND relname = 'pg_catalog.pg_class'; + id | relid | relname | relpages | reltuples | relallvisible | curpages +----+----------+---------------------+----------+-----------+---------------+---------- + 2 | pg_class | pg_catalog.pg_class | 1 | 1 | 1 | 1 +(1 row) + +SELECT dbms_stats.restore(2, 'pg_catalog.pg_class', NULL); + restore +--------- +(0 rows) + +SELECT count(*) FROM dbms_stats.column_stats_locked; + count +------- + 0 +(1 row) + +SELECT count(*) FROM dbms_stats.relation_stats_locked; + count +------- + 0 +(1 row) + +DELETE FROM dbms_stats.relation_stats_backup + WHERE id = 2 + AND relname = 'pg_catalog.pg_class'; +-- No.9-1-24 +DELETE FROM dbms_stats.relation_stats_locked; +INSERT INTO dbms_stats.relation_stats_locked(relid, relname) + VALUES ('s0.st0'::regclass, 's0.st0'); +INSERT INTO dbms_stats.column_stats_locked(starelid, staattnum, stainherit) + SELECT starelid::regclass, staattnum, stainherit + FROM dbms_stats.column_stats_effective + WHERE starelid = 's0.st0'::regclass; +SELECT id, unit, comment FROM dbms_stats.backup_history + WHERE id = 2; + id | unit | comment +----+------+--------- + 2 | d | (null) +(1 row) + +SELECT * FROM columns_locked_v; + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ + s0.st0 | 1 | id | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) + s0.st0 | 1 | id | t | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) + s0.st0 | 2 | num | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) + s0.st0 | 2 | num | t | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) +(4 rows) + +SELECT * FROM relations_locked_v; + relid | relname | relpages | reltuples | relallvisible | curpages +--------+---------+----------+-----------+---------------+---------- + s0.st0 | s0.st0 | (null) | (null) | (null) | (null) +(1 row) + +SELECT dbms_stats.restore(2, 's0.st0', NULL); + restore +--------- + s0.st0 +(1 row) + +SELECT * FROM relations_locked_v; + relid | relname | relpages | reltuples | relallvisible | curpages +--------+---------+----------+-----------+---------------+---------- + s0.st0 | s0.st0 | 1 | 2 | 1 | 1 +(1 row) + +SELECT * FROM columns_locked_v; + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------+------------+------------ + s0.st0 | 1 | id | 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) + s0.st0 | 1 | id | 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) + s0.st0 | 2 | num | 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) + s0.st0 | 2 | num | 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) +(4 rows) + +-- No.9-1-25 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT id, unit, comment FROM dbms_stats.backup_history + WHERE id = 2; + id | unit | comment +----+------+--------- + 2 | d | (null) +(1 row) + +SELECT dbms_stats.restore(2, 's0.st0', NULL); + restore +--------- + s0.st0 +(1 row) + +SELECT * FROM relations_locked_v; + relid | relname | relpages | reltuples | relallvisible | curpages +--------+---------+----------+-----------+---------------+---------- + s0.st0 | s0.st0 | 1 | 2 | 1 | 1 +(1 row) + +SELECT * FROM columns_locked_v; + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------+------------+------------ + s0.st0 | 1 | id | 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) + s0.st0 | 1 | id | 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) + s0.st0 | 2 | num | 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) + s0.st0 | 2 | num | 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) +(4 rows) + +/* + * Stab function dbms_stats.restore + */ +CREATE OR REPLACE FUNCTION dbms_stats.restore( + backup_id int8, + relid regclass DEFAULT NULL, + attname text DEFAULT NULL) +RETURNS SETOF regclass AS +$$ +BEGIN + RAISE NOTICE 'arguments are "%, %, %"', $1, $2, $3; + RETURN QUERY + SELECT c.oid::regclass + FROM pg_class c, dbms_stats.relation_stats_backup b + WHERE (c.oid = $2 OR $2 IS NULL) + AND c.oid = b.relid + AND c.relkind IN ('r', 'i') + AND (b.id <= $1 OR $1 IS NOT NULL) + GROUP BY c.oid + ORDER BY c.oid::regclass::text; +END; +$$ +LANGUAGE plpgsql; +/* + * No.10-1 dbms_stats.restore_database_stats + */ +-- No.10-1-1 +SELECT dbms_stats.restore_database_stats('2012-02-29 23:59:57'); +NOTICE: arguments are "2, pt0, " +NOTICE: arguments are "2, pt0_idx, " +NOTICE: arguments are "2, st0, " +NOTICE: arguments are "2, st0_idx, " +NOTICE: arguments are "2, st1, " +NOTICE: arguments are "2, s0.st0, " +NOTICE: arguments are "2, s0.st0_idx, " +NOTICE: arguments are "2, s0.st1, " +NOTICE: arguments are "2, s0.st1_idx, " +NOTICE: arguments are "2, s0.st2, " +NOTICE: arguments are "2, s0.st2_idx, " +NOTICE: arguments are "2, st1_idx, " +NOTICE: arguments are "2, st1_exp, " +NOTICE: arguments are "2, s0.sft0, " +NOTICE: arguments are "2, s0.smv0, " + restore_database_stats +------------------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp +(13 rows) + +-- No.10-1-2 +SELECT dbms_stats.restore_database_stats('2012-02-29 23:59:57.000002'); +NOTICE: arguments are "2, pt0, " +NOTICE: arguments are "2, pt0_idx, " +NOTICE: arguments are "2, st0, " +NOTICE: arguments are "2, st0_idx, " +NOTICE: arguments are "2, st1, " +NOTICE: arguments are "3, s0.st0, " +NOTICE: arguments are "2, s0.st0_idx, " +NOTICE: arguments are "2, s0.st1, " +NOTICE: arguments are "2, s0.st1_idx, " +NOTICE: arguments are "2, s0.st2, " +NOTICE: arguments are "2, s0.st2_idx, " +NOTICE: arguments are "2, st1_idx, " +NOTICE: arguments are "2, st1_exp, " +NOTICE: arguments are "2, s0.sft0, " +NOTICE: arguments are "2, s0.smv0, " + restore_database_stats +------------------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp +(13 rows) + +-- No.10-1-3 +SELECT dbms_stats.restore_database_stats('2012-01-01 00:00:00'); + restore_database_stats +------------------------ +(0 rows) + +--#No.10-1-4 is skipped after lock tests +--#No.10-1-5 is skipped after lock tests +-- No.10-1-6 +SELECT dbms_stats.restore_database_stats('2012-02-29 23:59:57'); +NOTICE: arguments are "2, pt0, " +NOTICE: arguments are "2, pt0_idx, " +NOTICE: arguments are "2, st0, " +NOTICE: arguments are "2, st0_idx, " +NOTICE: arguments are "2, st1, " +NOTICE: arguments are "2, s0.st0, " +NOTICE: arguments are "2, s0.st0_idx, " +NOTICE: arguments are "2, s0.st1, " +NOTICE: arguments are "2, s0.st1_idx, " +NOTICE: arguments are "2, s0.st2, " +NOTICE: arguments are "2, s0.st2_idx, " +NOTICE: arguments are "2, st1_idx, " +NOTICE: arguments are "2, st1_exp, " +NOTICE: arguments are "2, s0.sft0, " +NOTICE: arguments are "2, s0.smv0, " + restore_database_stats +------------------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp +(13 rows) + +/* + * No.10-2 dbms_stats.restore_schema_stats + */ +-- No.10-2-1 +SELECT dbms_stats.restore_schema_stats('s0', '2012-02-29 23:59:57'); +NOTICE: arguments are "2, s0.st0, " +NOTICE: arguments are "2, s0.st0_idx, " +NOTICE: arguments are "2, s0.st1, " +NOTICE: arguments are "2, s0.st1_idx, " +NOTICE: arguments are "2, s0.st2, " +NOTICE: arguments are "2, s0.st2_idx, " +NOTICE: arguments are "2, s0.sft0, " +NOTICE: arguments are "2, s0.smv0, " + restore_schema_stats +---------------------- + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx +(6 rows) + +-- No.10-2-2 +SELECT dbms_stats.restore_schema_stats('s0', '2012-02-29 23:59:57.000002'); +NOTICE: arguments are "3, s0.st0, " +NOTICE: arguments are "2, s0.st0_idx, " +NOTICE: arguments are "2, s0.st1, " +NOTICE: arguments are "2, s0.st1_idx, " +NOTICE: arguments are "2, s0.st2, " +NOTICE: arguments are "2, s0.st2_idx, " +NOTICE: arguments are "2, s0.sft0, " +NOTICE: arguments are "2, s0.smv0, " + restore_schema_stats +---------------------- + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx +(6 rows) + +-- No.10-2-3 +SELECT dbms_stats.restore_schema_stats('s0', '2012-01-01 00:00:00'); + restore_schema_stats +---------------------- +(0 rows) + +--#No.10-2-4 is skipped after lock tests +--#No.10-2-5 is skipped after lock tests +-- No.10-2-6 +SELECT dbms_stats.restore_schema_stats('s0', '2012-02-29 23:59:57'); +NOTICE: arguments are "2, s0.st0, " +NOTICE: arguments are "2, s0.st0_idx, " +NOTICE: arguments are "2, s0.st1, " +NOTICE: arguments are "2, s0.st1_idx, " +NOTICE: arguments are "2, s0.st2, " +NOTICE: arguments are "2, s0.st2_idx, " +NOTICE: arguments are "2, s0.sft0, " +NOTICE: arguments are "2, s0.smv0, " + restore_schema_stats +---------------------- + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx +(6 rows) + +-- No.10-2-7 +SELECT dbms_stats.restore_schema_stats('s0', '2012-02-29 23:59:57'); +NOTICE: arguments are "2, s0.st0, " +NOTICE: arguments are "2, s0.st0_idx, " +NOTICE: arguments are "2, s0.st1, " +NOTICE: arguments are "2, s0.st1_idx, " +NOTICE: arguments are "2, s0.st2, " +NOTICE: arguments are "2, s0.st2_idx, " +NOTICE: arguments are "2, s0.sft0, " +NOTICE: arguments are "2, s0.smv0, " + restore_schema_stats +---------------------- + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx +(6 rows) + +--#No.10-2-8 is skipped after lock tests +-- No.10-2-9 +SELECT dbms_stats.restore_schema_stats('s00', '2012-02-29 23:59:57'); +ERROR: schema "s00" not found +CONTEXT: PL/pgSQL function dbms_stats.restore_schema_stats(text,timestamp with time zone) line 4 at RAISE +-- No.10-2-10 +SELECT dbms_stats.restore_schema_stats('pg_catalog', '2012-02-29 23:59:57'); +ERROR: restoring statistics is inhibited for system schemas: "pg_catalog" +CONTEXT: PL/pgSQL function dbms_stats.restore_schema_stats(text,timestamp with time zone) line 7 at RAISE +/* + * No.10-7 dbms_stats.restore_stats + */ +-- No.10-7-1 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.restore_stats(NULL); + restore_stats +--------------- +(0 rows) + +-- No.10-7-2 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.restore_stats(0); +ERROR: backup id 0 not found +CONTEXT: PL/pgSQL function dbms_stats.restore_stats(bigint) line 10 at RAISE +-- No.10-7-3 +DELETE FROM dbms_stats.relation_stats_locked; +VACUUM dbms_stats.relation_stats_locked; -- in order to avoid auto vacuum +BEGIN; +SELECT * FROM internal_locks; + relation | mode +----------+------ +(0 rows) + +SELECT dbms_stats.restore_stats(2); + restore_stats +--------------- + pt0 + pt0_idx + s0.sft0 + s0.smv0 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st0 + st0_idx + st1 + st1_exp + st1_idx +(15 rows) + +SELECT * FROM internal_locks; + relation | mode +----------------------------------+------------------ + dbms_stats.backup_history | AccessShareLock + dbms_stats.column_stats_backup | AccessShareLock + dbms_stats.column_stats_locked | RowExclusiveLock + dbms_stats.relation_stats_backup | AccessShareLock + dbms_stats.relation_stats_backup | RowShareLock + dbms_stats.relation_stats_locked | ExclusiveLock + dbms_stats.relation_stats_locked | RowExclusiveLock + dbms_stats.relation_stats_locked | RowShareLock +(8 rows) + +COMMIT; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 +(15 rows) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + st0 | id | f + st0 | name | f + st1 | val | f + st1 | str | f + s0.st0 | id | f + s0.st0 | id | t + s0.st0 | num | f + s0.st0 | num | t + s0.st1 | id | f + s0.st1 | num | f + s0.st2 | id | f + s0.st2 | txt | f + st1_exp | lower | f + s0.sft0 | id | f + s0.smv0 | id | f + s0.smv0 | num | f + s0.smv0 | txt | f +(17 rows) + +-- No.10-7-4 +DELETE FROM dbms_stats.relation_stats_locked; +INSERT INTO dbms_stats.relation_stats_locked(relid, relname) + SELECT relid::regclass, relname + FROM dbms_stats.relation_stats_effective; +INSERT INTO dbms_stats.column_stats_locked(starelid, staattnum, stainherit) + SELECT starelid::regclass, staattnum, stainherit + FROM dbms_stats.column_stats_effective; +SELECT id, unit, comment FROM dbms_stats.backup_history + WHERE id = 8; + id | unit | comment +----+------+--------- + 8 | s | (null) +(1 row) + +SELECT * FROM columns_locked_v; + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ + st0 | 1 | id | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) + st0 | 2 | name | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) + st1 | 1 | val | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) + st1 | 2 | str | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) + s0.st0 | 1 | id | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) + s0.st0 | 1 | id | t | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) + s0.st0 | 2 | num | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) + s0.st0 | 2 | num | t | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) + s0.st1 | 1 | id | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) + s0.st1 | 2 | num | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) + s0.st2 | 1 | id | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) + s0.st2 | 2 | txt | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) + st1_exp | 1 | lower | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) + s0.sft0 | 1 | id | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) + s0.smv0 | 1 | id | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) + s0.smv0 | 2 | num | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) + s0.smv0 | 3 | txt | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) + s1.st0 | 1 | id | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) + s1.st0 | 2 | num | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) +(19 rows) + +SELECT * FROM relations_locked_v; + relid | relname | relpages | reltuples | relallvisible | curpages +------------+----------------+----------+-----------+---------------+---------- + pt0 | public.pt0 | (null) | (null) | (null) | (null) + pt0_idx | public.pt0_idx | (null) | (null) | (null) | (null) + st0 | public.st0 | (null) | (null) | (null) | (null) + st0_idx | public.st0_idx | (null) | (null) | (null) | (null) + st1 | public.st1 | (null) | (null) | (null) | (null) + s0.st0 | s0.st0 | (null) | (null) | (null) | (null) + s0.st0_idx | s0.st0_idx | (null) | (null) | (null) | (null) + s0.st1 | s0.st1 | (null) | (null) | (null) | (null) + s0.st1_idx | s0.st1_idx | (null) | (null) | (null) | (null) + s0.st2 | s0.st2 | (null) | (null) | (null) | (null) + s0.st2_idx | s0.st2_idx | (null) | (null) | (null) | (null) + st1_idx | public.st1_idx | (null) | (null) | (null) | (null) + st1_exp | public.st1_exp | (null) | (null) | (null) | (null) + s0.sft0 | s0.sft0 | (null) | (null) | (null) | (null) + s0.smv0 | s0.smv0 | (null) | (null) | (null) | (null) + s1.st0 | s1.st0 | (null) | (null) | (null) | (null) +(16 rows) + +SELECT dbms_stats.restore_stats(8); + restore_stats +--------------- + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx +(6 rows) + +SELECT * FROM relations_locked_v; + relid | relname | relpages | reltuples | relallvisible | curpages +------------+----------------+----------+-----------+---------------+---------- + pt0 | public.pt0 | (null) | (null) | (null) | (null) + pt0_idx | public.pt0_idx | (null) | (null) | (null) | (null) + st0 | public.st0 | (null) | (null) | (null) | (null) + st0_idx | public.st0_idx | (null) | (null) | (null) | (null) + st1 | public.st1 | (null) | (null) | (null) | (null) + s0.st0 | s0.st0 | 1 | 2 | 1 | 1 + s0.st0_idx | s0.st0_idx | 2 | 2 | 0 | 2 + s0.st1 | s0.st1 | 1 | 3 | 1 | 1 + s0.st1_idx | s0.st1_idx | 2 | 3 | 0 | 2 + s0.st2 | s0.st2 | 1 | 3 | 1 | 1 + s0.st2_idx | s0.st2_idx | 2 | 3 | 0 | 2 + st1_idx | public.st1_idx | (null) | (null) | (null) | (null) + st1_exp | public.st1_exp | (null) | (null) | (null) | (null) + s0.sft0 | s0.sft0 | (null) | (null) | (null) | (null) + s0.smv0 | s0.smv0 | (null) | (null) | (null) | (null) + s1.st0 | s1.st0 | (null) | (null) | (null) | (null) +(16 rows) + +SELECT * FROM columns_locked_v; + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------+------------+------------ + st0 | 1 | id | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) + st0 | 2 | name | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) + st1 | 1 | val | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) + st1 | 2 | str | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) + s0.st0 | 1 | id | 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) + s0.st0 | 1 | id | 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) + s0.st0 | 2 | num | 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) + s0.st0 | 2 | num | 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) + s0.st1 | 1 | id | 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) + s0.st1 | 2 | num | 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) + s0.st2 | 1 | id | 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) + s0.st2 | 2 | txt | 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) + st1_exp | 1 | lower | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) + s0.sft0 | 1 | id | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) + s0.smv0 | 1 | id | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) + s0.smv0 | 2 | num | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) + s0.smv0 | 3 | txt | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) + s1.st0 | 1 | id | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) + s1.st0 | 2 | num | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) +(19 rows) + +-- No.10-7-5 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT id, unit, comment FROM dbms_stats.backup_history + WHERE id = 8; + id | unit | comment +----+------+--------- + 8 | s | (null) +(1 row) + +SELECT dbms_stats.restore_stats(8); + restore_stats +--------------- + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx +(6 rows) + +SELECT * FROM relations_locked_v; + relid | relname | relpages | reltuples | relallvisible | curpages +------------+------------+----------+-----------+---------------+---------- + s0.st0 | s0.st0 | 1 | 2 | 1 | 1 + s0.st0_idx | s0.st0_idx | 2 | 2 | 0 | 2 + s0.st1 | s0.st1 | 1 | 3 | 1 | 1 + s0.st1_idx | s0.st1_idx | 2 | 3 | 0 | 2 + s0.st2 | s0.st2 | 1 | 3 | 1 | 1 + s0.st2_idx | s0.st2_idx | 2 | 3 | 0 | 2 +(6 rows) + +SELECT * FROM columns_locked_v; + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------+------------+------------ + s0.st0 | 1 | id | 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) + s0.st0 | 1 | id | 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) + s0.st0 | 2 | num | 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) + s0.st0 | 2 | num | 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) + s0.st1 | 1 | id | 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) + s0.st1 | 2 | num | 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) + s0.st2 | 1 | id | 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) + s0.st2 | 2 | txt | 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) +(8 rows) + +/* + * No.11-1 dbms_stats.lock(relid, attname) + */ +-- No.11-1-1 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock(NULL, NULL); +ERROR: relation required +CONTEXT: PL/pgSQL function dbms_stats.lock(regclass,text) line 8 at RAISE +-- No.11-1-2 +ALTER FUNCTION dbms_stats.lock(relid regclass) + RENAME TO truth_lock; +CREATE FUNCTION dbms_stats.lock(relid regclass) +RETURNS regclass AS +$$ +BEGIN + RAISE NOTICE 'arguments are %', $1; + RETURN $1; +END +$$ +LANGUAGE plpgsql; +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('s0.st0', NULL); +NOTICE: arguments are s0.st0 + lock +-------- + s0.st0 +(1 row) + +DROP FUNCTION dbms_stats.lock(relid regclass); +ALTER FUNCTION dbms_stats.truth_lock(relid regclass) + RENAME TO lock; +-- No.11-1-3 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock(NULL, 'id'); +ERROR: relation required +CONTEXT: PL/pgSQL function dbms_stats.lock(regclass,text) line 8 at RAISE +-- No.11-1-4 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('s0.st0', 'id'); + lock +-------- + s0.st0 +(1 row) + +SELECT * FROM relations_locked_v; + relid | relname | relpages | reltuples | relallvisible | curpages +--------+---------+----------+-----------+---------------+---------- + s0.st0 | s0.st0 | (null) | (null) | (null) | (null) +(1 row) + +SELECT * FROM columns_locked_v c; + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------ + s0.st0 | 1 | id | 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) + s0.st0 | 1 | id | 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) +(2 rows) + +-- No.11-1-5 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock(0, 'id'); +ERROR: relation "-" not found +CONTEXT: PL/pgSQL function dbms_stats.lock(regclass,text) line 15 at RAISE +-- No.11-1-6 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('s0.st0', 'id'); + lock +-------- + s0.st0 +(1 row) + +SELECT * FROM relations_locked_v; + relid | relname | relpages | reltuples | relallvisible | curpages +--------+---------+----------+-----------+---------------+---------- + s0.st0 | s0.st0 | (null) | (null) | (null) | (null) +(1 row) + +SELECT * FROM columns_locked_v c; + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------ + s0.st0 | 1 | id | 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) + s0.st0 | 1 | id | 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) +(2 rows) + +-- No.11-1-7 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('pg_toast.pg_toast_2618', 'id'); +ERROR: "pg_toast.pg_toast_2618" must be a table or an index +CONTEXT: PL/pgSQL function dbms_stats.lock(regclass,text) line 18 at RAISE +-- No.11-1-8 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('s0.st0_idx', 'id'); +ERROR: "s0.st0_idx" must be an expression index +CONTEXT: PL/pgSQL function dbms_stats.lock(regclass,text) line 21 at RAISE +-- No.11-1-9 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('st1_exp', 'lower'); + lock +--------- + st1_exp +(1 row) + +SELECT * FROM relations_locked_v; + relid | relname | relpages | reltuples | relallvisible | curpages +---------+----------------+----------+-----------+---------------+---------- + st1_exp | public.st1_exp | (null) | (null) | (null) | (null) +(1 row) + +SELECT * FROM columns_locked_v c; + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+------------------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ + st1_exp | 1 | lower | 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) +(1 row) + +DELETE FROM dbms_stats.relation_stats_locked; +-- No.11-1-10 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('s0.ss0', 'id'); +ERROR: "s0.ss0" must be a table or an index +CONTEXT: PL/pgSQL function dbms_stats.lock(regclass,text) line 18 at RAISE +-- No.11-1-11 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('s0.sc0', 'id'); +ERROR: "s0.sc0" must be a table or an index +CONTEXT: PL/pgSQL function dbms_stats.lock(regclass,text) line 18 at RAISE +-- No.11-1-12 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('s0.sft0', 'id'); + lock +--------- + s0.sft0 +(1 row) + +SELECT * FROM relations_locked_v; + relid | relname | relpages | reltuples | relallvisible | curpages +---------+---------+----------+-----------+---------------+---------- + s0.sft0 | s0.sft0 | (null) | (null) | (null) | (null) +(1 row) + +SELECT * FROM columns_locked_v c; + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------------+------------+------------+------------+------------ + s0.sft0 | 1 | id | 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) +(1 row) + +-- No.11-1-13 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('s0.smv0', 'id'); + lock +--------- + s0.smv0 +(1 row) + +SELECT * FROM relations_locked_v; + relid | relname | relpages | reltuples | relallvisible | curpages +---------+---------+----------+-----------+---------------+---------- + s0.smv0 | s0.smv0 | (null) | (null) | (null) | (null) +(1 row) + +SELECT * FROM columns_locked_v c; + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ + s0.smv0 | 1 | id | 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) +(1 row) + +-- No.11-1-14 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('pg_catalog.pg_class', 'id'); +ERROR: locking statistics is inhibited for system catalogs: "pg_class" +CONTEXT: PL/pgSQL function dbms_stats.lock(regclass,text) line 24 at RAISE +-- No.11-1-15 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('s0.st0', 'dummy'); +ERROR: column "dummy" not found in relation "s0.st0" +CONTEXT: PL/pgSQL function dbms_stats.lock(regclass,text) line 29 at RAISE +-- No.11-1-16 +DELETE FROM dbms_stats.relation_stats_locked; +DELETE FROM pg_statistic + WHERE starelid = 's0.st0'::regclass; +SELECT dbms_stats.lock('s0.st0', 'id'); +ERROR: no statistics available for column "id" of relation "s0.st0" +CONTEXT: PL/pgSQL function dbms_stats.lock(regclass,text) line 131 at RAISE +VACUUM ANALYZE; +-- No.11-1-17 +DELETE FROM dbms_stats.relation_stats_locked; +INSERT INTO dbms_stats.relation_stats_locked( + relid, relname, relpages, reltuples, + relallvisible, + curpages) + VALUES('s0.st0'::regclass, 's0.st0', 1, 1640, + 1, + 1); +SELECT dbms_stats.lock_column_stats('s0.st0','id'); + lock_column_stats +------------------- + s0.st0 +(1 row) + +UPDATE dbms_stats.column_stats_locked + SET (stanullfrac, stawidth, stadistinct, + stakind1, stakind2, stakind3, stakind4, + stakind5, + staop1, staop2, staop3, staop4, + staop5, + stanumbers1, stanumbers2, stanumbers3, stanumbers4, + stanumbers5, + stavalues1, stavalues2, stavalues3, stavalues4 + ,stavalues5 + ) = ( + NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL) + WHERE starelid = 's0.st0'::regclass; +SELECT dbms_stats.lock('s0.st0', 'id'); + lock +-------- + s0.st0 +(1 row) + +SELECT * FROM relations_locked_v; + relid | relname | relpages | reltuples | relallvisible | curpages +--------+---------+----------+-----------+---------------+---------- + s0.st0 | s0.st0 | 1 | 1640 | 1 | 1 +(1 row) + +SELECT * FROM columns_locked_v c; + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------ + s0.st0 | 1 | id | 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) + s0.st0 | 1 | id | 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) +(2 rows) + +-- No.11-1-18 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('s0.st0', 'id'); + lock +-------- + s0.st0 +(1 row) + +SELECT * FROM relations_locked_v + WHERE relid = 's0.st0'::regclass; + relid | relname | relpages | reltuples | relallvisible | curpages +--------+---------+----------+-----------+---------------+---------- + s0.st0 | s0.st0 | (null) | (null) | (null) | (null) +(1 row) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + s0.st0 | id | f + s0.st0 | id | t +(2 rows) + +/* + * No.11-2 dbms_stats.lock(relid) + */ +-- No.11-2-1 +DELETE FROM dbms_stats.relation_stats_locked; +VACUUM dbms_stats.relation_stats_locked; -- in order to avoid auto vacuum +BEGIN; +SELECT * FROM internal_locks; + relation | mode +----------+------ +(0 rows) + +SELECT dbms_stats.lock('s0.st0'); + lock +-------- + s0.st0 +(1 row) + +SELECT * FROM relations_locked_v; + relid | relname | relpages | reltuples | relallvisible | curpages +--------+---------+----------+-----------+---------------+---------- + s0.st0 | s0.st0 | 1 | 2 | 1 | 1 +(1 row) + +SELECT * FROM columns_locked_v c; + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------+------------+------------ + s0.st0 | 1 | id | 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) + s0.st0 | 1 | id | 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) + s0.st0 | 2 | num | 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) + s0.st0 | 2 | num | 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) +(4 rows) + +SELECT * FROM internal_locks; + relation | mode +----------------------------------+------------------ + dbms_stats.column_stats_locked | AccessShareLock + dbms_stats.column_stats_locked | RowExclusiveLock + dbms_stats.relation_stats_locked | AccessShareLock + dbms_stats.relation_stats_locked | RowExclusiveLock + dbms_stats.relation_stats_locked | RowShareLock +(5 rows) + +COMMIT; +-- No.11-2-2 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock(NULL); +ERROR: relation required +CONTEXT: PL/pgSQL function dbms_stats.lock(regclass) line 7 at RAISE +-- No.11-2-3 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('0'); +ERROR: relation "-" not found +CONTEXT: PL/pgSQL function dbms_stats.lock(regclass) line 11 at RAISE +-- No.11-2-4 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('s0.st0'); + lock +-------- + s0.st0 +(1 row) + +SELECT * FROM relations_locked_v; + relid | relname | relpages | reltuples | relallvisible | curpages +--------+---------+----------+-----------+---------------+---------- + s0.st0 | s0.st0 | 1 | 2 | 1 | 1 +(1 row) + +SELECT * FROM columns_locked_v c; + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------+------------+------------ + s0.st0 | 1 | id | 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) + s0.st0 | 1 | id | 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) + s0.st0 | 2 | num | 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) + s0.st0 | 2 | num | 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) +(4 rows) + +-- No.11-2-5 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('pg_toast.pg_toast_2618'); +ERROR: locking statistics is not allowed for relations with relkind "t": "pg_toast.pg_toast_2618" +HINT: Only tables(r, m, f) and indexes(i) are lockable. +CONTEXT: PL/pgSQL function dbms_stats.lock(regclass) line 14 at RAISE +-- No.11-2-6 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('s0.st0_idx'); + lock +------------ + s0.st0_idx +(1 row) + +SELECT * FROM relations_locked_v; + relid | relname | relpages | reltuples | relallvisible | curpages +------------+------------+----------+-----------+---------------+---------- + s0.st0_idx | s0.st0_idx | 2 | 2 | 0 | 2 +(1 row) + +SELECT * FROM columns_locked_v c; + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ +(0 rows) + +-- No.11-2-7 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('s0.ss0'); +ERROR: locking statistics is not allowed for relations with relkind "S": "s0.ss0" +HINT: Only tables(r, m, f) and indexes(i) are lockable. +CONTEXT: PL/pgSQL function dbms_stats.lock(regclass) line 14 at RAISE +-- No.11-2-8 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('s0.sc0'); +ERROR: locking statistics is not allowed for relations with relkind "c": "s0.sc0" +HINT: Only tables(r, m, f) and indexes(i) are lockable. +CONTEXT: PL/pgSQL function dbms_stats.lock(regclass) line 14 at RAISE +-- No.11-2-9 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('s0.sft0'); + lock +--------- + s0.sft0 +(1 row) + +SELECT * FROM relations_locked_v; + relid | relname | relpages | reltuples | relallvisible | curpages +---------+---------+----------+-----------+---------------+---------- + s0.sft0 | s0.sft0 | 1 | 10 | 0 | 0 +(1 row) + +SELECT * FROM columns_locked_v c; + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------------+------------+------------+------------+------------ + s0.sft0 | 1 | id | 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) +(1 row) + +-- No.11-2-10 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('s0.smv0'); + lock +--------- + s0.smv0 +(1 row) + +SELECT * FROM relations_locked_v; + relid | relname | relpages | reltuples | relallvisible | curpages +---------+---------+----------+-----------+---------------+---------- + s0.smv0 | s0.smv0 | 1 | 2 | 1 | 1 +(1 row) + +SELECT * FROM columns_locked_v c; + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ + s0.smv0 | 1 | id | 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) + s0.smv0 | 2 | num | 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) + s0.smv0 | 3 | txt | 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) +(3 rows) + +-- No.11-2-11 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('pg_catalog.pg_class'); +ERROR: locking statistics is not allowed for system catalogs: "pg_class" +CONTEXT: PL/pgSQL function dbms_stats.lock(regclass) line 18 at RAISE +-- No.11-2-12 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_table_stats('s0.st0'); + lock_table_stats +------------------ + s0.st0 +(1 row) + +UPDATE dbms_stats.relation_stats_locked + SET (relpages, reltuples, + relallvisible, + curpages) + = (NULL, NULL, NULL + ,NULL + ) + WHERE relid = 's0.st0'::regclass; +SELECT dbms_stats.lock('s0.st0'); + lock +-------- + s0.st0 +(1 row) + +SELECT * FROM relations_locked_v; + relid | relname | relpages | reltuples | relallvisible | curpages +--------+---------+----------+-----------+---------------+---------- + s0.st0 | s0.st0 | 1 | 2 | 1 | 1 +(1 row) + +SELECT * FROM columns_locked_v c; + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------+------------+------------ + s0.st0 | 1 | id | 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) + s0.st0 | 1 | id | 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) + s0.st0 | 2 | num | 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) + s0.st0 | 2 | num | 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) +(4 rows) + +-- No.11-2-13 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('s0.st0'); + lock +-------- + s0.st0 +(1 row) + +SELECT * FROM relations_locked_v; + relid | relname | relpages | reltuples | relallvisible | curpages +--------+---------+----------+-----------+---------------+---------- + s0.st0 | s0.st0 | 1 | 2 | 1 | 1 +(1 row) + +SELECT * FROM columns_locked_v c; + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------+------------+------------ + s0.st0 | 1 | id | 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) + s0.st0 | 1 | id | 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) + s0.st0 | 2 | num | 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) + s0.st0 | 2 | num | 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) +(4 rows) + +/* + * Stab function dbms_stats.lock + */ +ALTER FUNCTION dbms_stats.lock(relid regclass) + RENAME TO truth_lock; +CREATE FUNCTION dbms_stats.lock(relid regclass) +RETURNS regclass AS +$$ +BEGIN + RAISE NOTICE 'arguments are %', $1; + RETURN $1; +END +$$ +LANGUAGE plpgsql; +ALTER FUNCTION dbms_stats.lock(relid regclass, attname text) + RENAME TO truth_lock; +CREATE FUNCTION dbms_stats.lock( + relid regclass, + attname text) +RETURNS regclass AS +$$ +BEGIN + RAISE NOTICE 'arguments are %, %', $1, $2; + RETURN $1; +END +$$ +LANGUAGE plpgsql; +/* + * No.12-1 dbms_stats.lock_database_stats + */ +-- No.12-1-1 +SELECT dbms_stats.lock_database_stats(); +NOTICE: arguments are pt0 +NOTICE: arguments are pt0_idx +NOTICE: arguments are st0 +NOTICE: arguments are st0_idx +NOTICE: arguments are st1 +NOTICE: arguments are s0.st0 +NOTICE: arguments are s0.st0_idx +NOTICE: arguments are s0.st1 +NOTICE: arguments are s0.st1_idx +NOTICE: arguments are s0.st2 +NOTICE: arguments are s0.st2_idx +NOTICE: arguments are st1_idx +NOTICE: arguments are st1_exp +NOTICE: arguments are s0.sft0 +NOTICE: arguments are s0.smv0 +NOTICE: arguments are s1.st0 + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +/* + * No.12-2 dbms_stats.lock_schema_stats + */ +-- No.12-2-1 +SELECT dbms_stats.lock_schema_stats('s0'); +NOTICE: arguments are s0.st0 +NOTICE: arguments are s0.st0_idx +NOTICE: arguments are s0.st1 +NOTICE: arguments are s0.st1_idx +NOTICE: arguments are s0.st2 +NOTICE: arguments are s0.st2_idx +NOTICE: arguments are s0.sft0 +NOTICE: arguments are s0.smv0 + lock_schema_stats +------------------- + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + s0.sft0 + s0.smv0 +(8 rows) + +-- No.12-2-2 +SELECT dbms_stats.lock_schema_stats('s00'); +ERROR: schema "s00" not found +CONTEXT: PL/pgSQL function dbms_stats.lock_schema_stats(text) line 4 at RAISE +-- No.12-2-3 +SELECT dbms_stats.lock_schema_stats('pg_catalog'); +ERROR: locking statistics is not allowed for system schemas: "pg_catalog" +CONTEXT: PL/pgSQL function dbms_stats.lock_schema_stats(text) line 7 at RAISE +/* + * No.12-3 dbms_stats.lock_table_stats(regclass) + */ +-- No.12-3-1 +SELECT dbms_stats.lock_table_stats('s0.st0'); +NOTICE: arguments are s0.st0 + lock_table_stats +------------------ + s0.st0 +(1 row) + +-- No.12-3-2 +SELECT dbms_stats.lock_table_stats('st0'); +NOTICE: arguments are st0 + lock_table_stats +------------------ + st0 +(1 row) + +-- No.12-3-3 +SELECT dbms_stats.lock_table_stats('s00.s0'); +ERROR: schema "s00" does not exist +LINE 1: SELECT dbms_stats.lock_table_stats('s00.s0'); + ^ +/* + * No.12-4 dbms_stats.lock_table_stats(schemaname, tablename) + */ +-- No.12-4-1 +SELECT dbms_stats.lock_table_stats('s0', 'st0'); +NOTICE: arguments are s0.st0 + lock_table_stats +------------------ + s0.st0 +(1 row) + +/* + * No.12-5 dbms_stats.lock_column_stats(regclass, attname) + */ +-- No.12-5-1 +SELECT dbms_stats.lock_column_stats('s0.st0', 'id'); +NOTICE: arguments are s0.st0, id + lock_column_stats +------------------- + s0.st0 +(1 row) + +-- No.12-5-2 +SELECT dbms_stats.lock_column_stats('st0', 'id'); +NOTICE: arguments are st0, id + lock_column_stats +------------------- + st0 +(1 row) + +-- No.12-5-3 +SELECT dbms_stats.lock_column_stats('s00.s0', 'id'); +ERROR: schema "s00" does not exist +LINE 1: SELECT dbms_stats.lock_column_stats('s00.s0', 'id'); + ^ +/* + * No.12-6 dbms_stats.lock_column_stats(schemaname, tablename, int2) + */ +-- No.12-6-1 +SELECT dbms_stats.lock_column_stats('s0', 'st0', 'id'); +NOTICE: arguments are s0.st0, id + lock_column_stats +------------------- + s0.st0 +(1 row) + +/* + * Delete Stab function lock + */ +DROP FUNCTION dbms_stats.lock(relid regclass); +ALTER FUNCTION dbms_stats.truth_lock(relid regclass) + RENAME TO lock; +DROP FUNCTION dbms_stats.lock(relid regclass, attname text); +ALTER FUNCTION dbms_stats.truth_lock(relid regclass, attname text) + RENAME TO lock; +/* + * No.13-1 dbms_stats.unlock + */ +-- No.13-1-1 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT * FROM dbms_stats.backup_history + ORDER BY id; + id | time | unit | comment +----+-------------------------------------+------+--------- + 1 | Wed Feb 29 23:59:56.999999 2012 PST | d | (null) + 2 | Wed Feb 29 23:59:57 2012 PST | d | (null) + 3 | Wed Feb 29 23:59:57.000001 2012 PST | t | (null) + 4 | Wed Feb 29 23:59:58 2012 PST | d | (null) + 5 | Thu Mar 01 00:00:00 2012 PST | c | (null) + 6 | Thu Mar 01 00:00:02 2012 PST | t | (null) + 7 | Thu Mar 01 00:00:04 2012 PST | t | (null) + 8 | Thu Mar 01 00:00:06 2012 PST | s | (null) +(8 rows) + +SELECT count(*) FROM dbms_stats.relation_stats_backup; + count +------- + 26 +(1 row) + +SELECT count(*) FROM dbms_stats.column_stats_backup; + count +------- + 39 +(1 row) + +SELECT dbms_stats.unlock(); + unlock +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT count(*) FROM dbms_stats.relation_stats_locked; + count +------- + 0 +(1 row) + +SELECT count(*) FROM dbms_stats.column_stats_locked; + count +------- + 0 +(1 row) + +SELECT * FROM dbms_stats.backup_history + ORDER BY id; + id | time | unit | comment +----+-------------------------------------+------+--------- + 1 | Wed Feb 29 23:59:56.999999 2012 PST | d | (null) + 2 | Wed Feb 29 23:59:57 2012 PST | d | (null) + 3 | Wed Feb 29 23:59:57.000001 2012 PST | t | (null) + 4 | Wed Feb 29 23:59:58 2012 PST | d | (null) + 5 | Thu Mar 01 00:00:00 2012 PST | c | (null) + 6 | Thu Mar 01 00:00:02 2012 PST | t | (null) + 7 | Thu Mar 01 00:00:04 2012 PST | t | (null) + 8 | Thu Mar 01 00:00:06 2012 PST | s | (null) +(8 rows) + +SELECT count(*) FROM dbms_stats.relation_stats_backup; + count +------- + 26 +(1 row) + +SELECT count(*) FROM dbms_stats.column_stats_backup; + count +------- + 39 +(1 row) + +-- No.13-1-2 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT dbms_stats.unlock(); + unlock +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT count(*) FROM dbms_stats.relation_stats_locked; + count +------- + 0 +(1 row) + +SELECT count(*) FROM dbms_stats.column_stats_locked; + count +------- + 0 +(1 row) + +-- No.13-1-3 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +DELETE FROM dbms_stats.column_stats_locked; +SELECT dbms_stats.unlock(); + unlock +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT count(*) FROM dbms_stats.relation_stats_locked; + count +------- + 0 +(1 row) + +SELECT count(*) FROM dbms_stats.column_stats_locked; + count +------- + 0 +(1 row) + +-- No.13-1-4 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.unlock(); + unlock +-------- +(0 rows) + +SELECT count(*) FROM dbms_stats.relation_stats_locked; + count +------- + 0 +(1 row) + +SELECT count(*) FROM dbms_stats.column_stats_locked; + count +------- + 0 +(1 row) + +-- No.13-1-5 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + s0.st0 | 4 + s0.st1 | 2 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 3 + s1.st0 | 2 +(9 rows) + +SELECT dbms_stats.unlock('s0.st0'); + unlock +-------- + s0.st0 +(1 row) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(15 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + s0.st1 | 2 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 3 + s1.st0 | 2 +(8 rows) + +-- No.13-1-6 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + s0.st0 | 4 + s0.st1 | 2 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 3 + s1.st0 | 2 +(9 rows) + +SELECT dbms_stats.unlock('st0'); + unlock +-------- + st0 +(1 row) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(15 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st1 | 2 + s0.st0 | 4 + s0.st1 | 2 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 3 + s1.st0 | 2 +(8 rows) + +-- No.13-1-7 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT count(*) FROM dbms_stats.relation_stats_locked; + count +------- + 16 +(1 row) + +SELECT count(*) FROM dbms_stats.column_stats_locked; + count +------- + 19 +(1 row) + +SELECT dbms_stats.unlock('s00.s0'); +ERROR: schema "s00" does not exist +LINE 1: SELECT dbms_stats.unlock('s00.s0'); + ^ +SELECT count(*) FROM dbms_stats.relation_stats_locked; + count +------- + 16 +(1 row) + +SELECT count(*) FROM dbms_stats.column_stats_locked; + count +------- + 19 +(1 row) + +-- No.13-1-8 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + st0 | id | f + st0 | name | f + st1 | val | f + st1 | str | f + s0.st0 | id | f + s0.st0 | id | t + s0.st0 | num | f + s0.st0 | num | t + s0.st1 | id | f + s0.st1 | num | f + s0.st2 | id | f + s0.st2 | txt | f + st1_exp | lower | f + s0.sft0 | id | f + s0.smv0 | id | f + s0.smv0 | num | f + s0.smv0 | txt | f + s1.st0 | id | f + s1.st0 | num | f +(19 rows) + +SELECT dbms_stats.unlock('s0.st0', 'id'); + unlock +-------- + s0.st0 +(1 row) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + st0 | id | f + st0 | name | f + st1 | val | f + st1 | str | f + s0.st0 | num | f + s0.st0 | num | t + s0.st1 | id | f + s0.st1 | num | f + s0.st2 | id | f + s0.st2 | txt | f + st1_exp | lower | f + s0.sft0 | id | f + s0.smv0 | id | f + s0.smv0 | num | f + s0.smv0 | txt | f + s1.st0 | id | f + s1.st0 | num | f +(17 rows) + +-- No.13-1-9 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + st0 | id | f + st0 | name | f + st1 | val | f + st1 | str | f + s0.st0 | id | f + s0.st0 | id | t + s0.st0 | num | f + s0.st0 | num | t + s0.st1 | id | f + s0.st1 | num | f + s0.st2 | id | f + s0.st2 | txt | f + st1_exp | lower | f + s0.sft0 | id | f + s0.smv0 | id | f + s0.smv0 | num | f + s0.smv0 | txt | f + s1.st0 | id | f + s1.st0 | num | f +(19 rows) + +SELECT dbms_stats.unlock('s0.st0', 'dummy'); +ERROR: column "dummy" not found in relation "s0.st0" +CONTEXT: PL/pgSQL function dbms_stats.unlock(regclass,text) line 19 at RAISE +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + st0 | id | f + st0 | name | f + st1 | val | f + st1 | str | f + s0.st0 | id | f + s0.st0 | id | t + s0.st0 | num | f + s0.st0 | num | t + s0.st1 | id | f + s0.st1 | num | f + s0.st2 | id | f + s0.st2 | txt | f + st1_exp | lower | f + s0.sft0 | id | f + s0.smv0 | id | f + s0.smv0 | num | f + s0.smv0 | txt | f + s1.st0 | id | f + s1.st0 | num | f +(19 rows) + +-- No.13-1-10 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +DELETE FROM dbms_stats.column_stats_locked; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT dbms_stats.unlock('s0.st0', 'id'); + unlock +-------- + s0.st0 +(1 row) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid::regclass, staattnum FROM dbms_stats.column_stats_locked + GROUP BY starelid, staattnum + ORDER BY starelid, staattnum; + starelid | staattnum +----------+----------- +(0 rows) + +-- No.13-1-11 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid::regclass, staattnum FROM dbms_stats.column_stats_locked + GROUP BY starelid, staattnum + ORDER BY starelid, staattnum; + starelid | staattnum +----------+----------- + st0 | 1 + st0 | 2 + st1 | 1 + st1 | 2 + s0.st0 | 1 + s0.st0 | 2 + s0.st1 | 1 + s0.st1 | 2 + s0.st2 | 1 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 1 + s0.smv0 | 2 + s0.smv0 | 3 + s1.st0 | 1 + s1.st0 | 2 +(17 rows) + +SELECT dbms_stats.unlock(NULL, 'id'); +ERROR: relation required +CONTEXT: PL/pgSQL function dbms_stats.unlock(regclass,text) line 7 at RAISE +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid::regclass, staattnum FROM dbms_stats.column_stats_locked + GROUP BY starelid, staattnum + ORDER BY starelid, staattnum; + starelid | staattnum +----------+----------- + st0 | 1 + st0 | 2 + st1 | 1 + st1 | 2 + s0.st0 | 1 + s0.st0 | 2 + s0.st1 | 1 + s0.st1 | 2 + s0.st2 | 1 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 1 + s0.smv0 | 2 + s0.smv0 | 3 + s1.st0 | 1 + s1.st0 | 2 +(17 rows) + +-- No.13-1-12 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid::regclass, staattnum FROM dbms_stats.column_stats_locked + GROUP BY starelid, staattnum + ORDER BY starelid, staattnum; + starelid | staattnum +----------+----------- + st0 | 1 + st0 | 2 + st1 | 1 + st1 | 2 + s0.st0 | 1 + s0.st0 | 2 + s0.st1 | 1 + s0.st1 | 2 + s0.st2 | 1 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 1 + s0.smv0 | 2 + s0.smv0 | 3 + s1.st0 | 1 + s1.st0 | 2 +(17 rows) + +SELECT dbms_stats.unlock('s0.st0', NULL); + unlock +-------- + s0.st0 +(1 row) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(15 rows) + +SELECT starelid::regclass, staattnum FROM dbms_stats.column_stats_locked + GROUP BY starelid, staattnum + ORDER BY starelid, staattnum; + starelid | staattnum +----------+----------- + st0 | 1 + st0 | 2 + st1 | 1 + st1 | 2 + s0.st1 | 1 + s0.st1 | 2 + s0.st2 | 1 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 1 + s0.smv0 | 2 + s0.smv0 | 3 + s1.st0 | 1 + s1.st0 | 2 +(15 rows) + +-- No.13-1-13 +DELETE FROM dbms_stats.relation_stats_locked; +VACUUM dbms_stats.relation_stats_locked; -- in order to avoid auto vacuum +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT count(*) FROM dbms_stats.relation_stats_locked; + count +------- + 16 +(1 row) + +SELECT count(*) FROM dbms_stats.column_stats_locked; + count +------- + 19 +(1 row) + +BEGIN; +SELECT * FROM internal_locks; + relation | mode +----------+------ +(0 rows) + +SELECT dbms_stats.unlock(); + unlock +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT * FROM internal_locks; + relation | mode +----------------------------------+------------------ + dbms_stats.column_stats_locked | RowExclusiveLock + dbms_stats.relation_stats_locked | AccessShareLock + dbms_stats.relation_stats_locked | RowExclusiveLock + dbms_stats.relation_stats_locked | RowShareLock +(4 rows) + +COMMIT; +SELECT count(*) FROM dbms_stats.relation_stats_locked; + count +------- + 0 +(1 row) + +SELECT count(*) FROM dbms_stats.column_stats_locked; + count +------- + 0 +(1 row) + +/* + * No.14-1 dbms_stats.unlock_database_stats + */ +-- No.14-1-1 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT * FROM dbms_stats.backup_history + ORDER BY id; + id | time | unit | comment +----+-------------------------------------+------+--------- + 1 | Wed Feb 29 23:59:56.999999 2012 PST | d | (null) + 2 | Wed Feb 29 23:59:57 2012 PST | d | (null) + 3 | Wed Feb 29 23:59:57.000001 2012 PST | t | (null) + 4 | Wed Feb 29 23:59:58 2012 PST | d | (null) + 5 | Thu Mar 01 00:00:00 2012 PST | c | (null) + 6 | Thu Mar 01 00:00:02 2012 PST | t | (null) + 7 | Thu Mar 01 00:00:04 2012 PST | t | (null) + 8 | Thu Mar 01 00:00:06 2012 PST | s | (null) +(8 rows) + +SELECT count(*) FROM dbms_stats.relation_stats_backup; + count +------- + 26 +(1 row) + +SELECT count(*) FROM dbms_stats.column_stats_backup; + count +------- + 39 +(1 row) + +SELECT count(*) FROM dbms_stats.relation_stats_locked; + count +------- + 16 +(1 row) + +SELECT count(*) FROM dbms_stats.column_stats_locked; + count +------- + 19 +(1 row) + +SELECT dbms_stats.unlock_database_stats(); + unlock_database_stats +----------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT count(*) FROM dbms_stats.relation_stats_locked; + count +------- + 0 +(1 row) + +SELECT count(*) FROM dbms_stats.column_stats_locked; + count +------- + 0 +(1 row) + +SELECT * FROM dbms_stats.backup_history + ORDER BY id; + id | time | unit | comment +----+-------------------------------------+------+--------- + 1 | Wed Feb 29 23:59:56.999999 2012 PST | d | (null) + 2 | Wed Feb 29 23:59:57 2012 PST | d | (null) + 3 | Wed Feb 29 23:59:57.000001 2012 PST | t | (null) + 4 | Wed Feb 29 23:59:58 2012 PST | d | (null) + 5 | Thu Mar 01 00:00:00 2012 PST | c | (null) + 6 | Thu Mar 01 00:00:02 2012 PST | t | (null) + 7 | Thu Mar 01 00:00:04 2012 PST | t | (null) + 8 | Thu Mar 01 00:00:06 2012 PST | s | (null) +(8 rows) + +SELECT count(*) FROM dbms_stats.relation_stats_backup; + count +------- + 26 +(1 row) + +SELECT count(*) FROM dbms_stats.column_stats_backup; + count +------- + 39 +(1 row) + +-- No.14-1-2 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +DELETE FROM dbms_stats.column_stats_locked; +SELECT count(*) FROM dbms_stats.relation_stats_locked; + count +------- + 16 +(1 row) + +SELECT dbms_stats.unlock_database_stats(); + unlock_database_stats +----------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT count(*) FROM dbms_stats.relation_stats_locked; + count +------- + 0 +(1 row) + +SELECT count(*) FROM dbms_stats.column_stats_locked; + count +------- + 0 +(1 row) + +-- No.14-1-3 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.unlock_database_stats(); + unlock_database_stats +----------------------- +(0 rows) + +SELECT count(*) FROM dbms_stats.relation_stats_locked; + count +------- + 0 +(1 row) + +SELECT count(*) FROM dbms_stats.column_stats_locked; + count +------- + 0 +(1 row) + +-- No.14-1-4 +DELETE FROM dbms_stats.relation_stats_locked; +VACUUM dbms_stats.relation_stats_locked; -- in order to avoid auto vacuum +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT count(*) FROM dbms_stats.relation_stats_locked; + count +------- + 16 +(1 row) + +SELECT count(*) FROM dbms_stats.column_stats_locked; + count +------- + 19 +(1 row) + +BEGIN; +SELECT * FROM internal_locks; + relation | mode +----------+------ +(0 rows) + +SELECT dbms_stats.unlock_database_stats(); + unlock_database_stats +----------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT * FROM internal_locks; + relation | mode +----------------------------------+------------------ + dbms_stats.column_stats_locked | RowExclusiveLock + dbms_stats.relation_stats_locked | AccessShareLock + dbms_stats.relation_stats_locked | ExclusiveLock + dbms_stats.relation_stats_locked | RowExclusiveLock +(4 rows) + +COMMIT; +SELECT count(*) FROM dbms_stats.relation_stats_locked; + count +------- + 0 +(1 row) + +SELECT count(*) FROM dbms_stats.column_stats_locked; + count +------- + 0 +(1 row) + +/* + * No.14-2 dbms_stats.unlock_schema_stats + */ +-- No.14-2-1 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT * FROM dbms_stats.backup_history + ORDER BY id; + id | time | unit | comment +----+-------------------------------------+------+--------- + 1 | Wed Feb 29 23:59:56.999999 2012 PST | d | (null) + 2 | Wed Feb 29 23:59:57 2012 PST | d | (null) + 3 | Wed Feb 29 23:59:57.000001 2012 PST | t | (null) + 4 | Wed Feb 29 23:59:58 2012 PST | d | (null) + 5 | Thu Mar 01 00:00:00 2012 PST | c | (null) + 6 | Thu Mar 01 00:00:02 2012 PST | t | (null) + 7 | Thu Mar 01 00:00:04 2012 PST | t | (null) + 8 | Thu Mar 01 00:00:06 2012 PST | s | (null) +(8 rows) + +SELECT count(*) FROM dbms_stats.relation_stats_backup; + count +------- + 26 +(1 row) + +SELECT count(*) FROM dbms_stats.column_stats_backup; + count +------- + 39 +(1 row) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + s0.st0 | 4 + s0.st1 | 2 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 3 + s1.st0 | 2 +(9 rows) + +SELECT dbms_stats.unlock_schema_stats('s0'); + unlock_schema_stats +--------------------- + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + s0.sft0 + s0.smv0 +(8 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +--------- + pt0 + pt0_idx + st0 + st0_idx + st1 + st1_idx + st1_exp + s1.st0 +(8 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + st1_exp | 1 + s1.st0 | 2 +(4 rows) + +SELECT * FROM dbms_stats.backup_history + ORDER BY id; + id | time | unit | comment +----+-------------------------------------+------+--------- + 1 | Wed Feb 29 23:59:56.999999 2012 PST | d | (null) + 2 | Wed Feb 29 23:59:57 2012 PST | d | (null) + 3 | Wed Feb 29 23:59:57.000001 2012 PST | t | (null) + 4 | Wed Feb 29 23:59:58 2012 PST | d | (null) + 5 | Thu Mar 01 00:00:00 2012 PST | c | (null) + 6 | Thu Mar 01 00:00:02 2012 PST | t | (null) + 7 | Thu Mar 01 00:00:04 2012 PST | t | (null) + 8 | Thu Mar 01 00:00:06 2012 PST | s | (null) +(8 rows) + +SELECT count(*) FROM dbms_stats.relation_stats_backup; + count +------- + 26 +(1 row) + +SELECT count(*) FROM dbms_stats.column_stats_backup; + count +------- + 39 +(1 row) + +-- No.14-2-2 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +DELETE FROM dbms_stats.column_stats_locked; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- +(0 rows) + +SELECT dbms_stats.unlock_schema_stats('s0'); + unlock_schema_stats +--------------------- + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + s0.sft0 + s0.smv0 +(8 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +--------- + pt0 + pt0_idx + st0 + st0_idx + st1 + st1_idx + st1_exp + s1.st0 +(8 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- +(0 rows) + +-- No.14-2-3 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------- +(0 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- +(0 rows) + +SELECT dbms_stats.unlock_schema_stats('s0'); + unlock_schema_stats +--------------------- +(0 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------- +(0 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- +(0 rows) + +-- No.14-2-4 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + s0.st0 | 4 + s0.st1 | 2 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 3 + s1.st0 | 2 +(9 rows) + +SELECT dbms_stats.unlock_schema_stats('s0'); + unlock_schema_stats +--------------------- + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + s0.sft0 + s0.smv0 +(8 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +--------- + pt0 + pt0_idx + st0 + st0_idx + st1 + st1_idx + st1_exp + s1.st0 +(8 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + st1_exp | 1 + s1.st0 | 2 +(4 rows) + +-- No.14-2-5 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + s0.st0 | 4 + s0.st1 | 2 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 3 + s1.st0 | 2 +(9 rows) + +SELECT dbms_stats.unlock_schema_stats('s00'); +ERROR: schema "s00" not found +CONTEXT: PL/pgSQL function dbms_stats.unlock_schema_stats(text) line 6 at RAISE +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + s0.st0 | 4 + s0.st1 | 2 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 3 + s1.st0 | 2 +(9 rows) + +-- No.14-2-6 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + s0.st0 | 4 + s0.st1 | 2 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 3 + s1.st0 | 2 +(9 rows) + +SELECT dbms_stats.unlock_schema_stats('pg_catalog'); +ERROR: unlocking statistics is not allowed for system schemas: "pg_catalog" +CONTEXT: PL/pgSQL function dbms_stats.unlock_schema_stats(text) line 9 at RAISE +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + s0.st0 | 4 + s0.st1 | 2 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 3 + s1.st0 | 2 +(9 rows) + +-- No.14-2-7 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + s0.st0 | 4 + s0.st1 | 2 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 3 + s1.st0 | 2 +(9 rows) + +SELECT dbms_stats.unlock_schema_stats(NULL); + unlock_schema_stats +--------------------- +(0 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + s0.st0 | 4 + s0.st1 | 2 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 3 + s1.st0 | 2 +(9 rows) + +-- No.14-2-8 +DELETE FROM dbms_stats.relation_stats_locked; +VACUUM dbms_stats.relation_stats_locked; -- in order to avoid auto vacuum +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + s0.st0 | 4 + s0.st1 | 2 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 3 + s1.st0 | 2 +(9 rows) + +BEGIN; +SELECT * FROM internal_locks; + relation | mode +----------+------ +(0 rows) + +SELECT dbms_stats.unlock_schema_stats('s0'); + unlock_schema_stats +--------------------- + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + s0.sft0 + s0.smv0 +(8 rows) + +SELECT * FROM internal_locks; + relation | mode +----------------------------------+------------------ + dbms_stats.column_stats_locked | RowExclusiveLock + dbms_stats.relation_stats_locked | RowExclusiveLock + dbms_stats.relation_stats_locked | RowShareLock +(3 rows) + +COMMIT; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +--------- + pt0 + pt0_idx + st0 + st0_idx + st1 + st1_idx + st1_exp + s1.st0 +(8 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + st1_exp | 1 + s1.st0 | 2 +(4 rows) + +/* + * No.14-3 dbms_stats.unlock_table_stats(regclass) + */ +-- No.14-3-1 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT * FROM dbms_stats.backup_history + ORDER BY id; + id | time | unit | comment +----+-------------------------------------+------+--------- + 1 | Wed Feb 29 23:59:56.999999 2012 PST | d | (null) + 2 | Wed Feb 29 23:59:57 2012 PST | d | (null) + 3 | Wed Feb 29 23:59:57.000001 2012 PST | t | (null) + 4 | Wed Feb 29 23:59:58 2012 PST | d | (null) + 5 | Thu Mar 01 00:00:00 2012 PST | c | (null) + 6 | Thu Mar 01 00:00:02 2012 PST | t | (null) + 7 | Thu Mar 01 00:00:04 2012 PST | t | (null) + 8 | Thu Mar 01 00:00:06 2012 PST | s | (null) +(8 rows) + +SELECT count(*) FROM dbms_stats.relation_stats_backup; + count +------- + 26 +(1 row) + +SELECT count(*) FROM dbms_stats.column_stats_backup; + count +------- + 39 +(1 row) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + s0.st0 | 4 + s0.st1 | 2 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 3 + s1.st0 | 2 +(9 rows) + +SELECT dbms_stats.unlock_table_stats('s0.st0'); + unlock_table_stats +-------------------- + s0.st0 +(1 row) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(15 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + s0.st1 | 2 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 3 + s1.st0 | 2 +(8 rows) + +SELECT * FROM dbms_stats.backup_history + ORDER BY id; + id | time | unit | comment +----+-------------------------------------+------+--------- + 1 | Wed Feb 29 23:59:56.999999 2012 PST | d | (null) + 2 | Wed Feb 29 23:59:57 2012 PST | d | (null) + 3 | Wed Feb 29 23:59:57.000001 2012 PST | t | (null) + 4 | Wed Feb 29 23:59:58 2012 PST | d | (null) + 5 | Thu Mar 01 00:00:00 2012 PST | c | (null) + 6 | Thu Mar 01 00:00:02 2012 PST | t | (null) + 7 | Thu Mar 01 00:00:04 2012 PST | t | (null) + 8 | Thu Mar 01 00:00:06 2012 PST | s | (null) +(8 rows) + +SELECT count(*) FROM dbms_stats.relation_stats_backup; + count +------- + 26 +(1 row) + +SELECT count(*) FROM dbms_stats.column_stats_backup; + count +------- + 39 +(1 row) + +-- No.14-3-2 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +DELETE FROM dbms_stats.column_stats_locked; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- +(0 rows) + +SELECT dbms_stats.unlock_table_stats('s0.st0'); + unlock_table_stats +-------------------- + s0.st0 +(1 row) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(15 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- +(0 rows) + +-- No.14-3-3 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------- +(0 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- +(0 rows) + +SELECT dbms_stats.unlock_table_stats('s0.st0'); + unlock_table_stats +-------------------- +(0 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------- +(0 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- +(0 rows) + +-- No.14-3-4 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + s0.st0 | 4 + s0.st1 | 2 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 3 + s1.st0 | 2 +(9 rows) + +SELECT dbms_stats.unlock_table_stats('s0.st0'); + unlock_table_stats +-------------------- + s0.st0 +(1 row) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(15 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + s0.st1 | 2 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 3 + s1.st0 | 2 +(8 rows) + +-- No.14-3-5 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + s0.st0 | 4 + s0.st1 | 2 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 3 + s1.st0 | 2 +(9 rows) + +SELECT dbms_stats.unlock_table_stats('st0'); + unlock_table_stats +-------------------- + st0 +(1 row) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(15 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st1 | 2 + s0.st0 | 4 + s0.st1 | 2 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 3 + s1.st0 | 2 +(8 rows) + +-- No.14-3-6 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + s0.st0 | 4 + s0.st1 | 2 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 3 + s1.st0 | 2 +(9 rows) + +SELECT dbms_stats.unlock_table_stats('s00.s0'); +ERROR: schema "s00" does not exist +LINE 1: SELECT dbms_stats.unlock_table_stats('s00.s0'); + ^ +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + s0.st0 | 4 + s0.st1 | 2 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 3 + s1.st0 | 2 +(9 rows) + +-- No.14-3-7 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + s0.st0 | 4 + s0.st1 | 2 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 3 + s1.st0 | 2 +(9 rows) + +SELECT dbms_stats.unlock_table_stats(NULL); + unlock_table_stats +-------------------- +(0 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + s0.st0 | 4 + s0.st1 | 2 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 3 + s1.st0 | 2 +(9 rows) + +-- No.14-3-8 +DELETE FROM dbms_stats.relation_stats_locked; +VACUUM dbms_stats.relation_stats_locked; -- in order to avoid auto vacuum +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + s0.st0 | 4 + s0.st1 | 2 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 3 + s1.st0 | 2 +(9 rows) + +BEGIN; +SELECT * FROM internal_locks; + relation | mode +----------+------ +(0 rows) + +SELECT dbms_stats.unlock_table_stats('s0.st0'); + unlock_table_stats +-------------------- + s0.st0 +(1 row) + +SELECT * FROM internal_locks; + relation | mode +----------------------------------+------------------ + dbms_stats.column_stats_locked | RowExclusiveLock + dbms_stats.relation_stats_locked | RowExclusiveLock +(2 rows) + +COMMIT; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(15 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + s0.st1 | 2 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 3 + s1.st0 | 2 +(8 rows) + +/* + * No.14-4 dbms_stats.unlock_table_stats(schemaname, tablename) + */ +-- No.14-4-1 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT * FROM dbms_stats.backup_history + ORDER BY id; + id | time | unit | comment +----+-------------------------------------+------+--------- + 1 | Wed Feb 29 23:59:56.999999 2012 PST | d | (null) + 2 | Wed Feb 29 23:59:57 2012 PST | d | (null) + 3 | Wed Feb 29 23:59:57.000001 2012 PST | t | (null) + 4 | Wed Feb 29 23:59:58 2012 PST | d | (null) + 5 | Thu Mar 01 00:00:00 2012 PST | c | (null) + 6 | Thu Mar 01 00:00:02 2012 PST | t | (null) + 7 | Thu Mar 01 00:00:04 2012 PST | t | (null) + 8 | Thu Mar 01 00:00:06 2012 PST | s | (null) +(8 rows) + +SELECT count(*) FROM dbms_stats.relation_stats_backup; + count +------- + 26 +(1 row) + +SELECT count(*) FROM dbms_stats.column_stats_backup; + count +------- + 39 +(1 row) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + s0.st0 | 4 + s0.st1 | 2 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 3 + s1.st0 | 2 +(9 rows) + +SELECT dbms_stats.unlock_table_stats('s0','st0'); + unlock_table_stats +-------------------- + s0.st0 +(1 row) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(15 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + s0.st1 | 2 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 3 + s1.st0 | 2 +(8 rows) + +SELECT * FROM dbms_stats.backup_history + ORDER BY id; + id | time | unit | comment +----+-------------------------------------+------+--------- + 1 | Wed Feb 29 23:59:56.999999 2012 PST | d | (null) + 2 | Wed Feb 29 23:59:57 2012 PST | d | (null) + 3 | Wed Feb 29 23:59:57.000001 2012 PST | t | (null) + 4 | Wed Feb 29 23:59:58 2012 PST | d | (null) + 5 | Thu Mar 01 00:00:00 2012 PST | c | (null) + 6 | Thu Mar 01 00:00:02 2012 PST | t | (null) + 7 | Thu Mar 01 00:00:04 2012 PST | t | (null) + 8 | Thu Mar 01 00:00:06 2012 PST | s | (null) +(8 rows) + +SELECT count(*) FROM dbms_stats.relation_stats_backup; + count +------- + 26 +(1 row) + +SELECT count(*) FROM dbms_stats.column_stats_backup; + count +------- + 39 +(1 row) + +-- No.14-4-2 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +DELETE FROM dbms_stats.column_stats_locked; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- +(0 rows) + +SELECT dbms_stats.unlock_table_stats('s0', 'st0'); + unlock_table_stats +-------------------- + s0.st0 +(1 row) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(15 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- +(0 rows) + +-- No.14-4-3 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------- +(0 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- +(0 rows) + +SELECT dbms_stats.unlock_table_stats('s0', 'st0'); + unlock_table_stats +-------------------- +(0 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------- +(0 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- +(0 rows) + +-- No.14-4-4 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + s0.st0 | 4 + s0.st1 | 2 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 3 + s1.st0 | 2 +(9 rows) + +SELECT dbms_stats.unlock_table_stats('s0', 'st0'); + unlock_table_stats +-------------------- + s0.st0 +(1 row) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(15 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + s0.st1 | 2 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 3 + s1.st0 | 2 +(8 rows) + +-- No.14-4-5 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + s0.st0 | 4 + s0.st1 | 2 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 3 + s1.st0 | 2 +(9 rows) + +SELECT dbms_stats.unlock_table_stats('s00', 's0'); +ERROR: schema "s00" does not exist +CONTEXT: SQL function "unlock_table_stats" statement 1 +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + s0.st0 | 4 + s0.st1 | 2 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 3 + s1.st0 | 2 +(9 rows) + +-- No.14-4-6 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + s0.st0 | 4 + s0.st1 | 2 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 3 + s1.st0 | 2 +(9 rows) + +SELECT dbms_stats.unlock_table_stats(NULL, 'st0'); + unlock_table_stats +-------------------- +(0 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + s0.st0 | 4 + s0.st1 | 2 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 3 + s1.st0 | 2 +(9 rows) + +-- No.14-4-7 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + s0.st0 | 4 + s0.st1 | 2 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 3 + s1.st0 | 2 +(9 rows) + +SELECT dbms_stats.unlock_table_stats('s0', NULL); + unlock_table_stats +-------------------- +(0 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + s0.st0 | 4 + s0.st1 | 2 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 3 + s1.st0 | 2 +(9 rows) + +-- No.14-4-8 +DELETE FROM dbms_stats.relation_stats_locked; +VACUUM dbms_stats.relation_stats_locked; -- in order to avoid auto vacuum +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + s0.st0 | 4 + s0.st1 | 2 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 3 + s1.st0 | 2 +(9 rows) + +BEGIN; +SELECT * FROM internal_locks; + relation | mode +----------+------ +(0 rows) + +SELECT dbms_stats.unlock_table_stats('s0', 'st0'); + unlock_table_stats +-------------------- + s0.st0 +(1 row) + +SELECT * FROM internal_locks; + relation | mode +----------------------------------+------------------ + dbms_stats.column_stats_locked | RowExclusiveLock + dbms_stats.relation_stats_locked | RowExclusiveLock +(2 rows) + +COMMIT; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(15 rows) + +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + starelid | count +----------+------- + st0 | 2 + st1 | 2 + s0.st1 | 2 + s0.st2 | 2 + st1_exp | 1 + s0.sft0 | 1 + s0.smv0 | 3 + s1.st0 | 2 +(8 rows) + +/* + * No.14-5 dbms_stats.unlock_column_stats(regclass, attname) + */ +-- No.14-5-1 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT * FROM dbms_stats.backup_history + ORDER BY id; + id | time | unit | comment +----+-------------------------------------+------+--------- + 1 | Wed Feb 29 23:59:56.999999 2012 PST | d | (null) + 2 | Wed Feb 29 23:59:57 2012 PST | d | (null) + 3 | Wed Feb 29 23:59:57.000001 2012 PST | t | (null) + 4 | Wed Feb 29 23:59:58 2012 PST | d | (null) + 5 | Thu Mar 01 00:00:00 2012 PST | c | (null) + 6 | Thu Mar 01 00:00:02 2012 PST | t | (null) + 7 | Thu Mar 01 00:00:04 2012 PST | t | (null) + 8 | Thu Mar 01 00:00:06 2012 PST | s | (null) +(8 rows) + +SELECT count(*) FROM dbms_stats.relation_stats_backup; + count +------- + 26 +(1 row) + +SELECT count(*) FROM dbms_stats.column_stats_backup; + count +------- + 39 +(1 row) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + st0 | id | f + st0 | name | f + st1 | val | f + st1 | str | f + s0.st0 | id | f + s0.st0 | id | t + s0.st0 | num | f + s0.st0 | num | t + s0.st1 | id | f + s0.st1 | num | f + s0.st2 | id | f + s0.st2 | txt | f + st1_exp | lower | f + s0.sft0 | id | f + s0.smv0 | id | f + s0.smv0 | num | f + s0.smv0 | txt | f + s1.st0 | id | f + s1.st0 | num | f +(19 rows) + +SELECT dbms_stats.unlock_column_stats('s0.st0', 'id'); + unlock_column_stats +--------------------- + s0.st0 +(1 row) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + st0 | id | f + st0 | name | f + st1 | val | f + st1 | str | f + s0.st0 | num | f + s0.st0 | num | t + s0.st1 | id | f + s0.st1 | num | f + s0.st2 | id | f + s0.st2 | txt | f + st1_exp | lower | f + s0.sft0 | id | f + s0.smv0 | id | f + s0.smv0 | num | f + s0.smv0 | txt | f + s1.st0 | id | f + s1.st0 | num | f +(17 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT * FROM dbms_stats.backup_history + ORDER BY id; + id | time | unit | comment +----+-------------------------------------+------+--------- + 1 | Wed Feb 29 23:59:56.999999 2012 PST | d | (null) + 2 | Wed Feb 29 23:59:57 2012 PST | d | (null) + 3 | Wed Feb 29 23:59:57.000001 2012 PST | t | (null) + 4 | Wed Feb 29 23:59:58 2012 PST | d | (null) + 5 | Thu Mar 01 00:00:00 2012 PST | c | (null) + 6 | Thu Mar 01 00:00:02 2012 PST | t | (null) + 7 | Thu Mar 01 00:00:04 2012 PST | t | (null) + 8 | Thu Mar 01 00:00:06 2012 PST | s | (null) +(8 rows) + +SELECT count(*) FROM dbms_stats.relation_stats_backup; + count +------- + 26 +(1 row) + +SELECT count(*) FROM dbms_stats.column_stats_backup; + count +------- + 39 +(1 row) + +-- No.14-5-2 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +DELETE FROM dbms_stats.column_stats_locked; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT dbms_stats.unlock_column_stats('s0.st0', 'id'); + unlock_column_stats +--------------------- + s0.st0 +(1 row) + +SELECT count(*) FROM dbms_stats.column_stats_locked; + count +------- + 0 +(1 row) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +-- No.14-5-3 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + st0 | id | f + st0 | name | f + st1 | val | f + st1 | str | f + s0.st0 | id | f + s0.st0 | id | t + s0.st0 | num | f + s0.st0 | num | t + s0.st1 | id | f + s0.st1 | num | f + s0.st2 | id | f + s0.st2 | txt | f + st1_exp | lower | f + s0.sft0 | id | f + s0.smv0 | id | f + s0.smv0 | num | f + s0.smv0 | txt | f + s1.st0 | id | f + s1.st0 | num | f +(19 rows) + +SELECT dbms_stats.unlock_column_stats('s0.st0', 'id'); + unlock_column_stats +--------------------- + s0.st0 +(1 row) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + st0 | id | f + st0 | name | f + st1 | val | f + st1 | str | f + s0.st0 | num | f + s0.st0 | num | t + s0.st1 | id | f + s0.st1 | num | f + s0.st2 | id | f + s0.st2 | txt | f + st1_exp | lower | f + s0.sft0 | id | f + s0.smv0 | id | f + s0.smv0 | num | f + s0.smv0 | txt | f + s1.st0 | id | f + s1.st0 | num | f +(17 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +-- No.14-5-4 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + st0 | id | f + st0 | name | f + st1 | val | f + st1 | str | f + s0.st0 | id | f + s0.st0 | id | t + s0.st0 | num | f + s0.st0 | num | t + s0.st1 | id | f + s0.st1 | num | f + s0.st2 | id | f + s0.st2 | txt | f + st1_exp | lower | f + s0.sft0 | id | f + s0.smv0 | id | f + s0.smv0 | num | f + s0.smv0 | txt | f + s1.st0 | id | f + s1.st0 | num | f +(19 rows) + +SELECT dbms_stats.unlock_column_stats('st0', 'id'); + unlock_column_stats +--------------------- + st0 +(1 row) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + st0 | name | f + st1 | val | f + st1 | str | f + s0.st0 | id | f + s0.st0 | id | t + s0.st0 | num | f + s0.st0 | num | t + s0.st1 | id | f + s0.st1 | num | f + s0.st2 | id | f + s0.st2 | txt | f + st1_exp | lower | f + s0.sft0 | id | f + s0.smv0 | id | f + s0.smv0 | num | f + s0.smv0 | txt | f + s1.st0 | id | f + s1.st0 | num | f +(18 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +-- No.14-5-5 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + st0 | id | f + st0 | name | f + st1 | val | f + st1 | str | f + s0.st0 | id | f + s0.st0 | id | t + s0.st0 | num | f + s0.st0 | num | t + s0.st1 | id | f + s0.st1 | num | f + s0.st2 | id | f + s0.st2 | txt | f + st1_exp | lower | f + s0.sft0 | id | f + s0.smv0 | id | f + s0.smv0 | num | f + s0.smv0 | txt | f + s1.st0 | id | f + s1.st0 | num | f +(19 rows) + +SELECT dbms_stats.unlock_column_stats('s0.st0', 'dummy'); +ERROR: column "dummy" not found in relation "s0.st0" +CONTEXT: PL/pgSQL function dbms_stats.unlock_column_stats(regclass,text) line 8 at RAISE +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + st0 | id | f + st0 | name | f + st1 | val | f + st1 | str | f + s0.st0 | id | f + s0.st0 | id | t + s0.st0 | num | f + s0.st0 | num | t + s0.st1 | id | f + s0.st1 | num | f + s0.st2 | id | f + s0.st2 | txt | f + st1_exp | lower | f + s0.sft0 | id | f + s0.smv0 | id | f + s0.smv0 | num | f + s0.smv0 | txt | f + s1.st0 | id | f + s1.st0 | num | f +(19 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +-- No.14-5-6 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + st0 | id | f + st0 | name | f + st1 | val | f + st1 | str | f + s0.st0 | id | f + s0.st0 | id | t + s0.st0 | num | f + s0.st0 | num | t + s0.st1 | id | f + s0.st1 | num | f + s0.st2 | id | f + s0.st2 | txt | f + st1_exp | lower | f + s0.sft0 | id | f + s0.smv0 | id | f + s0.smv0 | num | f + s0.smv0 | txt | f + s1.st0 | id | f + s1.st0 | num | f +(19 rows) + +SELECT dbms_stats.unlock_column_stats('s00.s0', 'id'); +ERROR: schema "s00" does not exist +LINE 1: SELECT dbms_stats.unlock_column_stats('s00.s0', 'id'); + ^ +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + st0 | id | f + st0 | name | f + st1 | val | f + st1 | str | f + s0.st0 | id | f + s0.st0 | id | t + s0.st0 | num | f + s0.st0 | num | t + s0.st1 | id | f + s0.st1 | num | f + s0.st2 | id | f + s0.st2 | txt | f + st1_exp | lower | f + s0.sft0 | id | f + s0.smv0 | id | f + s0.smv0 | num | f + s0.smv0 | txt | f + s1.st0 | id | f + s1.st0 | num | f +(19 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +-- No.14-5-7 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + st0 | id | f + st0 | name | f + st1 | val | f + st1 | str | f + s0.st0 | id | f + s0.st0 | id | t + s0.st0 | num | f + s0.st0 | num | t + s0.st1 | id | f + s0.st1 | num | f + s0.st2 | id | f + s0.st2 | txt | f + st1_exp | lower | f + s0.sft0 | id | f + s0.smv0 | id | f + s0.smv0 | num | f + s0.smv0 | txt | f + s1.st0 | id | f + s1.st0 | num | f +(19 rows) + +SELECT dbms_stats.unlock_column_stats(NULL, 'id'); + unlock_column_stats +--------------------- +(0 rows) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + st0 | id | f + st0 | name | f + st1 | val | f + st1 | str | f + s0.st0 | id | f + s0.st0 | id | t + s0.st0 | num | f + s0.st0 | num | t + s0.st1 | id | f + s0.st1 | num | f + s0.st2 | id | f + s0.st2 | txt | f + st1_exp | lower | f + s0.sft0 | id | f + s0.smv0 | id | f + s0.smv0 | num | f + s0.smv0 | txt | f + s1.st0 | id | f + s1.st0 | num | f +(19 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +-- No.14-5-8 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + st0 | id | f + st0 | name | f + st1 | val | f + st1 | str | f + s0.st0 | id | f + s0.st0 | id | t + s0.st0 | num | f + s0.st0 | num | t + s0.st1 | id | f + s0.st1 | num | f + s0.st2 | id | f + s0.st2 | txt | f + st1_exp | lower | f + s0.sft0 | id | f + s0.smv0 | id | f + s0.smv0 | num | f + s0.smv0 | txt | f + s1.st0 | id | f + s1.st0 | num | f +(19 rows) + +SELECT dbms_stats.unlock_column_stats('s0.st0', NULL); + unlock_column_stats +--------------------- +(0 rows) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + st0 | id | f + st0 | name | f + st1 | val | f + st1 | str | f + s0.st0 | id | f + s0.st0 | id | t + s0.st0 | num | f + s0.st0 | num | t + s0.st1 | id | f + s0.st1 | num | f + s0.st2 | id | f + s0.st2 | txt | f + st1_exp | lower | f + s0.sft0 | id | f + s0.smv0 | id | f + s0.smv0 | num | f + s0.smv0 | txt | f + s1.st0 | id | f + s1.st0 | num | f +(19 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +-- No.14-5-9 +DELETE FROM dbms_stats.relation_stats_locked; +VACUUM dbms_stats.relation_stats_locked; -- in order to avoid auto vacuum +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + st0 | id | f + st0 | name | f + st1 | val | f + st1 | str | f + s0.st0 | id | f + s0.st0 | id | t + s0.st0 | num | f + s0.st0 | num | t + s0.st1 | id | f + s0.st1 | num | f + s0.st2 | id | f + s0.st2 | txt | f + st1_exp | lower | f + s0.sft0 | id | f + s0.smv0 | id | f + s0.smv0 | num | f + s0.smv0 | txt | f + s1.st0 | id | f + s1.st0 | num | f +(19 rows) + +BEGIN; +SELECT * FROM internal_locks; + relation | mode +----------+------ +(0 rows) + +SELECT dbms_stats.unlock_column_stats('s0.st0', 'id'); + unlock_column_stats +--------------------- + s0.st0 +(1 row) + +SELECT * FROM internal_locks; + relation | mode +----------------------------------+------------------ + dbms_stats.column_stats_locked | RowExclusiveLock + dbms_stats.relation_stats_locked | RowShareLock +(2 rows) + +COMMIT; +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + st0 | id | f + st0 | name | f + st1 | val | f + st1 | str | f + s0.st0 | num | f + s0.st0 | num | t + s0.st1 | id | f + s0.st1 | num | f + s0.st2 | id | f + s0.st2 | txt | f + st1_exp | lower | f + s0.sft0 | id | f + s0.smv0 | id | f + s0.smv0 | num | f + s0.smv0 | txt | f + s1.st0 | id | f + s1.st0 | num | f +(17 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +/* + * No.14-6 dbms_stats.unlock_column_stats(schemaname, tablename, attname) + */ +-- No.14-6-1 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT * FROM dbms_stats.backup_history + ORDER BY id; + id | time | unit | comment +----+-------------------------------------+------+--------- + 1 | Wed Feb 29 23:59:56.999999 2012 PST | d | (null) + 2 | Wed Feb 29 23:59:57 2012 PST | d | (null) + 3 | Wed Feb 29 23:59:57.000001 2012 PST | t | (null) + 4 | Wed Feb 29 23:59:58 2012 PST | d | (null) + 5 | Thu Mar 01 00:00:00 2012 PST | c | (null) + 6 | Thu Mar 01 00:00:02 2012 PST | t | (null) + 7 | Thu Mar 01 00:00:04 2012 PST | t | (null) + 8 | Thu Mar 01 00:00:06 2012 PST | s | (null) +(8 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + st0 | id | f + st0 | name | f + st1 | val | f + st1 | str | f + s0.st0 | id | f + s0.st0 | id | t + s0.st0 | num | f + s0.st0 | num | t + s0.st1 | id | f + s0.st1 | num | f + s0.st2 | id | f + s0.st2 | txt | f + st1_exp | lower | f + s0.sft0 | id | f + s0.smv0 | id | f + s0.smv0 | num | f + s0.smv0 | txt | f + s1.st0 | id | f + s1.st0 | num | f +(19 rows) + +SELECT dbms_stats.unlock_column_stats('s0', 'st0', 'id'); + unlock_column_stats +--------------------- + s0.st0 +(1 row) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + st0 | id | f + st0 | name | f + st1 | val | f + st1 | str | f + s0.st0 | num | f + s0.st0 | num | t + s0.st1 | id | f + s0.st1 | num | f + s0.st2 | id | f + s0.st2 | txt | f + st1_exp | lower | f + s0.sft0 | id | f + s0.smv0 | id | f + s0.smv0 | num | f + s0.smv0 | txt | f + s1.st0 | id | f + s1.st0 | num | f +(17 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT * FROM dbms_stats.backup_history + ORDER BY id; + id | time | unit | comment +----+-------------------------------------+------+--------- + 1 | Wed Feb 29 23:59:56.999999 2012 PST | d | (null) + 2 | Wed Feb 29 23:59:57 2012 PST | d | (null) + 3 | Wed Feb 29 23:59:57.000001 2012 PST | t | (null) + 4 | Wed Feb 29 23:59:58 2012 PST | d | (null) + 5 | Thu Mar 01 00:00:00 2012 PST | c | (null) + 6 | Thu Mar 01 00:00:02 2012 PST | t | (null) + 7 | Thu Mar 01 00:00:04 2012 PST | t | (null) + 8 | Thu Mar 01 00:00:06 2012 PST | s | (null) +(8 rows) + +SELECT count(*) FROM dbms_stats.relation_stats_backup; + count +------- + 26 +(1 row) + +SELECT count(*) FROM dbms_stats.column_stats_backup; + count +------- + 39 +(1 row) + +-- No.14-6-2 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +DELETE FROM dbms_stats.column_stats_locked; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT dbms_stats.unlock_column_stats('s0', 'st0', 'id'); + unlock_column_stats +--------------------- + s0.st0 +(1 row) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ +(0 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +-- No.14-6-3 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + st0 | id | f + st0 | name | f + st1 | val | f + st1 | str | f + s0.st0 | id | f + s0.st0 | id | t + s0.st0 | num | f + s0.st0 | num | t + s0.st1 | id | f + s0.st1 | num | f + s0.st2 | id | f + s0.st2 | txt | f + st1_exp | lower | f + s0.sft0 | id | f + s0.smv0 | id | f + s0.smv0 | num | f + s0.smv0 | txt | f + s1.st0 | id | f + s1.st0 | num | f +(19 rows) + +SELECT dbms_stats.unlock_column_stats('s0', 'st0', 'id'); + unlock_column_stats +--------------------- + s0.st0 +(1 row) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + st0 | id | f + st0 | name | f + st1 | val | f + st1 | str | f + s0.st0 | num | f + s0.st0 | num | t + s0.st1 | id | f + s0.st1 | num | f + s0.st2 | id | f + s0.st2 | txt | f + st1_exp | lower | f + s0.sft0 | id | f + s0.smv0 | id | f + s0.smv0 | num | f + s0.smv0 | txt | f + s1.st0 | id | f + s1.st0 | num | f +(17 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +-- No.14-6-4 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + st0 | id | f + st0 | name | f + st1 | val | f + st1 | str | f + s0.st0 | id | f + s0.st0 | id | t + s0.st0 | num | f + s0.st0 | num | t + s0.st1 | id | f + s0.st1 | num | f + s0.st2 | id | f + s0.st2 | txt | f + st1_exp | lower | f + s0.sft0 | id | f + s0.smv0 | id | f + s0.smv0 | num | f + s0.smv0 | txt | f + s1.st0 | id | f + s1.st0 | num | f +(19 rows) + +SELECT dbms_stats.unlock_column_stats('s0', 'st0', 'dummy'); +ERROR: column "dummy" not found in relation "s0.st0" +CONTEXT: PL/pgSQL function dbms_stats.unlock_column_stats(text,text,text) line 9 at RAISE +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + st0 | id | f + st0 | name | f + st1 | val | f + st1 | str | f + s0.st0 | id | f + s0.st0 | id | t + s0.st0 | num | f + s0.st0 | num | t + s0.st1 | id | f + s0.st1 | num | f + s0.st2 | id | f + s0.st2 | txt | f + st1_exp | lower | f + s0.sft0 | id | f + s0.smv0 | id | f + s0.smv0 | num | f + s0.smv0 | txt | f + s1.st0 | id | f + s1.st0 | num | f +(19 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +-- No.14-6-5 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + st0 | id | f + st0 | name | f + st1 | val | f + st1 | str | f + s0.st0 | id | f + s0.st0 | id | t + s0.st0 | num | f + s0.st0 | num | t + s0.st1 | id | f + s0.st1 | num | f + s0.st2 | id | f + s0.st2 | txt | f + st1_exp | lower | f + s0.sft0 | id | f + s0.smv0 | id | f + s0.smv0 | num | f + s0.smv0 | txt | f + s1.st0 | id | f + s1.st0 | num | f +(19 rows) + +SELECT dbms_stats.unlock_column_stats(NULL, 'st0', 'id'); + unlock_column_stats +--------------------- +(0 rows) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + st0 | id | f + st0 | name | f + st1 | val | f + st1 | str | f + s0.st0 | id | f + s0.st0 | id | t + s0.st0 | num | f + s0.st0 | num | t + s0.st1 | id | f + s0.st1 | num | f + s0.st2 | id | f + s0.st2 | txt | f + st1_exp | lower | f + s0.sft0 | id | f + s0.smv0 | id | f + s0.smv0 | num | f + s0.smv0 | txt | f + s1.st0 | id | f + s1.st0 | num | f +(19 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +-- No.14-6-6 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + st0 | id | f + st0 | name | f + st1 | val | f + st1 | str | f + s0.st0 | id | f + s0.st0 | id | t + s0.st0 | num | f + s0.st0 | num | t + s0.st1 | id | f + s0.st1 | num | f + s0.st2 | id | f + s0.st2 | txt | f + st1_exp | lower | f + s0.sft0 | id | f + s0.smv0 | id | f + s0.smv0 | num | f + s0.smv0 | txt | f + s1.st0 | id | f + s1.st0 | num | f +(19 rows) + +SELECT dbms_stats.unlock_column_stats('s0', NULL, 'id'); + unlock_column_stats +--------------------- +(0 rows) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + st0 | id | f + st0 | name | f + st1 | val | f + st1 | str | f + s0.st0 | id | f + s0.st0 | id | t + s0.st0 | num | f + s0.st0 | num | t + s0.st1 | id | f + s0.st1 | num | f + s0.st2 | id | f + s0.st2 | txt | f + st1_exp | lower | f + s0.sft0 | id | f + s0.smv0 | id | f + s0.smv0 | num | f + s0.smv0 | txt | f + s1.st0 | id | f + s1.st0 | num | f +(19 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +-- No.14-6-7 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + st0 | id | f + st0 | name | f + st1 | val | f + st1 | str | f + s0.st0 | id | f + s0.st0 | id | t + s0.st0 | num | f + s0.st0 | num | t + s0.st1 | id | f + s0.st1 | num | f + s0.st2 | id | f + s0.st2 | txt | f + st1_exp | lower | f + s0.sft0 | id | f + s0.smv0 | id | f + s0.smv0 | num | f + s0.smv0 | txt | f + s1.st0 | id | f + s1.st0 | num | f +(19 rows) + +SELECT dbms_stats.unlock_column_stats('s0', 'st0', NULL); + unlock_column_stats +--------------------- +(0 rows) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + st0 | id | f + st0 | name | f + st1 | val | f + st1 | str | f + s0.st0 | id | f + s0.st0 | id | t + s0.st0 | num | f + s0.st0 | num | t + s0.st1 | id | f + s0.st1 | num | f + s0.st2 | id | f + s0.st2 | txt | f + st1_exp | lower | f + s0.sft0 | id | f + s0.smv0 | id | f + s0.smv0 | num | f + s0.smv0 | txt | f + s1.st0 | id | f + s1.st0 | num | f +(19 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +-- No.14-6-8 +DELETE FROM dbms_stats.relation_stats_locked; +VACUUM dbms_stats.relation_stats_locked; -- in order to avoid auto vacuum +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + st0 | id | f + st0 | name | f + st1 | val | f + st1 | str | f + s0.st0 | id | f + s0.st0 | id | t + s0.st0 | num | f + s0.st0 | num | t + s0.st1 | id | f + s0.st1 | num | f + s0.st2 | id | f + s0.st2 | txt | f + st1_exp | lower | f + s0.sft0 | id | f + s0.smv0 | id | f + s0.smv0 | num | f + s0.smv0 | txt | f + s1.st0 | id | f + s1.st0 | num | f +(19 rows) + +BEGIN; +SELECT * FROM internal_locks; + relation | mode +----------+------ +(0 rows) + +SELECT dbms_stats.unlock_column_stats('s0', 'st0', 'id'); + unlock_column_stats +--------------------- + s0.st0 +(1 row) + +SELECT * FROM internal_locks; + relation | mode +----------------------------------+------------------ + dbms_stats.column_stats_locked | RowExclusiveLock + dbms_stats.relation_stats_locked | RowShareLock +(2 rows) + +COMMIT; +SELECT starelid, attname, stainherit FROM columns_locked_v c; + starelid | attname | stainherit +----------+---------+------------ + st0 | id | f + st0 | name | f + st1 | val | f + st1 | str | f + s0.st0 | num | f + s0.st0 | num | t + s0.st1 | id | f + s0.st1 | num | f + s0.st2 | id | f + s0.st2 | txt | f + st1_exp | lower | f + s0.sft0 | id | f + s0.smv0 | id | f + s0.smv0 | num | f + s0.smv0 | txt | f + s1.st0 | id | f + s1.st0 | num | f +(17 rows) + +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + relid +------------ + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 +(16 rows) + +-- No.15 Make sure that the stats given by pg_dbms_stats doesn't +-- ignored by ACL check +CREATE FUNCTION testfunc() RETURNS TEXT AS $$ +DECLARE + ret text; + v text; +BEGIN + ret = ''; + FOR v IN EXPLAIN SELECT * FROM s0.st4 WHERE a < '000' LOOP + -- mask unnecessary values + v = regexp_replace(v, '(cost|width)=[0-9.]+', E'\\1=xxx', 'g'); + ret = ret || v || E'\n'; + END LOOP; + RETURN ret; +END; +$$ LANGUAGE plpgsql; +SET pg_dbms_stats.use_locked_stats TO on; +CREATE TABLE s0.st4 (a text) WITH (autovacuum_enabled = 'false'); +INSERT INTO s0.st4 SELECT '1' || md5(g::text) FROM generate_series(1, 10000) as g; +VACUUM ANALYZE s0.st4; +-- should estimate that rows = 1, not 5000 +SELECT testfunc(); + testfunc +---------------------------------------------- + Seq Scan on st4 (cost=xxx rows=1 width=xxx)+ + Filter: (a < '000'::text) + + +(1 row) + +SET pg_dbms_stats.use_locked_stats TO off; +SELECT dbms_stats.lock_table_stats('s0.st4'); + lock_table_stats +------------------ + s0.st4 +(1 row) + +SET pg_dbms_stats.use_locked_stats TO on; +-- should estimate that rows = 1, not 5000 +SELECT testfunc(); + testfunc +---------------------------------------------- + Seq Scan on st4 (cost=xxx rows=1 width=xxx)+ + Filter: (a < '000'::text) + + +(1 row) + +DROP TABLE s0.st4; +SELECT dbms_stats.clean_up_stats(); + clean_up_stats +---------------- + s0.st4, 1 + s0.st4, +(2 rows) + +/* + * No.15-2 Ditto for index stats + */ +CREATE TABLE s0.st4 (a double precision) WITH (autovacuum_enabled = 'false'); +CREATE INDEX on s0.st4 (floor(log(a))); +SELECT dbms_stats.lock_table_stats('s0.st4'); + lock_table_stats +------------------ + s0.st4 +(1 row) + +INSERT INTO s0.st4 (SELECT a from GENERATE_SERIES(1, 99999) a); +ANALYZE t1; +ERROR: relation "t1" does not exist +SET pg_dbms_stats.use_locked_stats TO off; +SELECT testfunc(); + testfunc +-------------------------------------------------- + Seq Scan on st4 (cost=xxx rows=33373 width=xxx)+ + Filter: (a < '0'::double precision) + + +(1 row) + +SET pg_dbms_stats.use_locked_stats TO on; +SELECT testfunc(); + testfunc +------------------------------------------------ + Seq Scan on st4 (cost=xxx rows=713 width=xxx)+ + Filter: (a < '0'::double precision) + + +(1 row) + +DROP TABLE s0.st4; +DROP FUNCTION testfunc(); +SELECT dbms_stats.clean_up_stats(); + clean_up_stats +---------------- + s0.st4, +(1 row) + +-- No.16 error description. -- abnormal case. +RESET SESSION AUTHORIZATION; +CREATE TABLE s0.st4 (a int, b text) WITH (autovacuum_enabled = 'false'); +CREATE VIEW s0.vst4 AS select * FROM s0.st4; +GRANT SELECT ON s0.vst4 TO regular_user; +ALTER TABLE dbms_stats.relation_stats_locked OWNER TO regular_user; +/* reconnection needed to flush cache */ +\c - regular_user +EXPLAIN (COSTS OFF) SELECT * FROM s0.vst4 WHERE a = 1; +ERROR: permission denied for schema dbms_stats +LINE 1: SELECT * FROM dbms_stats.column_stats_locked WHERE stareli... + ^ +DETAIL: dbms_stats could not access the object as the role "regular_user". +HINT: Check your settings of pg_dbms_stats. +QUERY: SELECT * FROM dbms_stats.column_stats_locked WHERE starelid = $1 AND staattnum = $2 AND stainherit = $3 +\c - super_user +ALTER TABLE dbms_stats.relation_stats_locked OWNER TO super_user; +DROP TABLE s0.st4 CASCADE; +NOTICE: drop cascades to view s0.vst4 +/* + * No.20-1 confirm change at 1.3.5. Moved from ut-common.sql at 1.3.11 + */ +SELECT CURRENT_USER; + current_user +-------------- + super_user +(1 row) + +CREATE TABLE s0.st4 (a int, b text) WITH (autovacuum_enabled = 'false'); +CREATE INDEX i_st4_a on s0.st4 (a); +CREATE VIEW s0.vst4 AS select * FROM s0.st4; +GRANT SELECT ON s0.vst4 TO regular_user; +INSERT INTO s0.st4 (SELECT a, a::text FROM generate_series(0, 999) a); +ANALYZE s0.st4; +SELECT dbms_stats.lock('s0.st4'); + lock +-------- + s0.st4 +(1 row) + +DELETE FROM s0.st4; +INSERT INTO s0.st4 (SELECT 1, a::text FROM generate_series(0, 999) a); +ANALYZE s0.st4; +EXPLAIN (COSTS OFF) SELECT * FROM s0.vst4 WHERE a = 1; + QUERY PLAN +--------------------------------- + Index Scan using i_st4_a on st4 + Index Cond: (a = 1) +(2 rows) + +EXPLAIN (COSTS OFF) SELECT * FROM s0.st4 WHERE a = 1; + QUERY PLAN +--------------------------------- + Index Scan using i_st4_a on st4 + Index Cond: (a = 1) +(2 rows) + +SET SESSION AUTHORIZATION regular_user; +EXPLAIN (COSTS OFF) SELECT * FROM s0.st4 WHERE a = 1; +ERROR: permission denied for table st4 +EXPLAIN (COSTS OFF) SELECT * FROM s0.vst4 WHERE a = 1; + QUERY PLAN +--------------------------------- + Index Scan using i_st4_a on st4 + Index Cond: (a = 1) +(2 rows) + +SET pg_dbms_stats.use_locked_stats TO off; +EXPLAIN (COSTS OFF) SELECT * FROM s0.vst4 WHERE a = 1; + QUERY PLAN +------------------- + Seq Scan on st4 + Filter: (a = 1) +(2 rows) + +\c - super_user +ALTER TABLE dbms_stats.relation_stats_locked OWNER TO super_user; +SELECT dbms_stats.unlock('s0.st4'); + unlock +-------- + s0.st4 +(1 row) + +DROP TABLE s0.st4 CASCADE; +NOTICE: drop cascades to view s0.vst4 diff --git a/ext_scripts/pg_dbms_stats--1.3.11-12.sql b/ext_scripts/pg_dbms_stats--1.3.11-12.sql new file mode 100644 index 0000000..626dcab --- /dev/null +++ b/ext_scripts/pg_dbms_stats--1.3.11-12.sql @@ -0,0 +1,1613 @@ +/* pg_dbms_stats/pg_dbms_stats--1.3.11.sql */ + +-- complain if script is sourced in psql, rather than via CREATE EXTENSION +\echo Use "CREATE EXTENSION pg_dbms_stats" to load this file. \quit + +-- define alias of anyarray type because parser does not allow to use +-- anyarray in type definitions. +-- +CREATE FUNCTION dbms_stats.anyarray_in(cstring) RETURNS dbms_stats.anyarray + AS 'anyarray_in' LANGUAGE internal STRICT IMMUTABLE; +CREATE FUNCTION dbms_stats.anyarray_out(dbms_stats.anyarray) RETURNS cstring + AS 'anyarray_out' LANGUAGE internal STRICT IMMUTABLE; +CREATE FUNCTION dbms_stats.anyarray_recv(internal) RETURNS dbms_stats.anyarray + AS 'MODULE_PATHNAME', 'dbms_stats_array_recv' LANGUAGE C STRICT IMMUTABLE; +CREATE FUNCTION dbms_stats.anyarray_send(dbms_stats.anyarray) RETURNS bytea + AS 'anyarray_send' LANGUAGE internal STRICT IMMUTABLE; +CREATE TYPE dbms_stats.anyarray ( + INPUT = dbms_stats.anyarray_in, + OUTPUT = dbms_stats.anyarray_out, + RECEIVE = dbms_stats.anyarray_recv, + SEND = dbms_stats.anyarray_send, + INTERNALLENGTH = VARIABLE, + ALIGNMENT = double, + STORAGE = extended, + CATEGORY = 'P' +); + +-- +-- User defined stats tables +-- + +CREATE TABLE dbms_stats.relation_stats_locked ( + relid oid NOT NULL, + relname text NOT NULL, + relpages int4, + reltuples float4, + relallvisible int4, + curpages int4, + last_analyze timestamp with time zone, + last_autoanalyze timestamp with time zone, + PRIMARY KEY (relid) +); + +CREATE TABLE dbms_stats.column_stats_locked ( + starelid oid NOT NULL, + staattnum int2 NOT NULL, + stainherit bool NOT NULL, + stanullfrac float4, + stawidth int4, + stadistinct float4, + stakind1 int2, + stakind2 int2, + stakind3 int2, + stakind4 int2, + stakind5 int2, + staop1 oid, + staop2 oid, + staop3 oid, + staop4 oid, + staop5 oid, + stacoll1 oid, + stacoll2 oid, + stacoll3 oid, + stacoll4 oid, + stacoll5 oid, + stanumbers1 float4[], + stanumbers2 float4[], + stanumbers3 float4[], + stanumbers4 float4[], + stanumbers5 float4[], + stavalues1 dbms_stats.anyarray, + stavalues2 dbms_stats.anyarray, + stavalues3 dbms_stats.anyarray, + stavalues4 dbms_stats.anyarray, + stavalues5 dbms_stats.anyarray, + PRIMARY KEY (starelid, staattnum, stainherit), + FOREIGN KEY (starelid) REFERENCES dbms_stats.relation_stats_locked (relid) ON DELETE CASCADE +); + +-- +-- Statistics backup tables +-- + +CREATE TABLE dbms_stats.backup_history ( + id serial8 PRIMARY KEY, + time timestamp with time zone NOT NULL, + unit char(1) NOT NULL, + comment text +); + +CREATE TABLE dbms_stats.relation_stats_backup ( + id int8 NOT NULL, + relid oid NOT NULL, + relname text NOT NULL, + relpages int4 NOT NULL, + reltuples float4 NOT NULL, + relallvisible int4 NOT NULL, + curpages int4 NOT NULL, + last_analyze timestamp with time zone, + last_autoanalyze timestamp with time zone, + PRIMARY KEY (id, relid), + FOREIGN KEY (id) REFERENCES dbms_stats.backup_history (id) ON DELETE CASCADE +); + +CREATE TABLE dbms_stats.column_stats_backup ( + id int8 NOT NULL, + statypid oid NOT NULL, + starelid oid NOT NULL, + staattnum int2 NOT NULL, + stainherit bool NOT NULL, + stanullfrac float4 NOT NULL, + stawidth int4 NOT NULL, + stadistinct float4 NOT NULL, + stakind1 int2 NOT NULL, + stakind2 int2 NOT NULL, + stakind3 int2 NOT NULL, + stakind4 int2 NOT NULL, + stakind5 int2 NOT NULL, + staop1 oid NOT NULL, + staop2 oid NOT NULL, + staop3 oid NOT NULL, + staop4 oid NOT NULL, + staop5 oid NOT NULL, + stacoll1 oid NOT NULL, + stacoll2 oid NOT NULL, + stacoll3 oid NOT NULL, + stacoll4 oid NOT NULL, + stacoll5 oid NOT NULL, + stanumbers1 float4[], + stanumbers2 float4[], + stanumbers3 float4[], + stanumbers4 float4[], + stanumbers5 float4[], + stavalues1 dbms_stats.anyarray, + stavalues2 dbms_stats.anyarray, + stavalues3 dbms_stats.anyarray, + stavalues4 dbms_stats.anyarray, + stavalues5 dbms_stats.anyarray, + PRIMARY KEY (id, starelid, staattnum, stainherit), + FOREIGN KEY (id) REFERENCES dbms_stats.backup_history (id) ON DELETE CASCADE, + FOREIGN KEY (id, starelid) REFERENCES dbms_stats.relation_stats_backup (id, relid) ON DELETE CASCADE +); + +-- +-- Functions +-- + +CREATE FUNCTION dbms_stats.relname(nspname text, relname text) +RETURNS text AS +$$SELECT quote_ident($1) || '.' || quote_ident($2)$$ +LANGUAGE sql STABLE STRICT; + +CREATE FUNCTION dbms_stats.is_system_schema(schemaname text) +RETURNS boolean AS +'MODULE_PATHNAME', 'dbms_stats_is_system_schema' +LANGUAGE C IMMUTABLE STRICT; + +CREATE FUNCTION dbms_stats.is_system_catalog(relid regclass) +RETURNS boolean AS +'MODULE_PATHNAME', 'dbms_stats_is_system_catalog' +LANGUAGE C STABLE; + +CREATE FUNCTION dbms_stats.is_target_relkind(relkind "char") +RETURNS boolean AS +$$SELECT $1 IN ('r', 'i', 'f', 'm')$$ +LANGUAGE sql STABLE; + +CREATE FUNCTION dbms_stats.merge( + lhs dbms_stats.column_stats_locked, + rhs pg_catalog.pg_statistic +) RETURNS dbms_stats.column_stats_locked AS +'MODULE_PATHNAME', 'dbms_stats_merge' +LANGUAGE C STABLE; + +CREATE VIEW dbms_stats.relation_stats_effective AS + SELECT + c.oid AS relid, + dbms_stats.relname(nspname, c.relname) AS relname, + COALESCE(v.relpages, c.relpages) AS relpages, + COALESCE(v.reltuples, c.reltuples) AS reltuples, + COALESCE(v.relallvisible, c.relallvisible) AS relallvisible, + COALESCE(v.curpages, + (pg_relation_size(c.oid) / current_setting('block_size')::int4)::int4) + AS curpages, + COALESCE(v.last_analyze, + pg_catalog.pg_stat_get_last_analyze_time(c.oid)) + AS last_analyze, + COALESCE(v.last_autoanalyze, + pg_catalog.pg_stat_get_last_autoanalyze_time(c.oid)) + AS last_autoanalyze + FROM pg_catalog.pg_class c + JOIN pg_catalog.pg_namespace n + ON c.relnamespace = n.oid + LEFT JOIN dbms_stats.relation_stats_locked v + ON v.relid = c.oid + WHERE dbms_stats.is_target_relkind(c.relkind) + AND NOT dbms_stats.is_system_schema(nspname); + +CREATE VIEW dbms_stats.column_stats_effective AS + SELECT * FROM ( + SELECT (dbms_stats.merge(v, s)).* + FROM pg_catalog.pg_statistic s + FULL JOIN dbms_stats.column_stats_locked v + USING (starelid, staattnum, stainherit) + WHERE NOT dbms_stats.is_system_catalog(starelid) + AND EXISTS ( + SELECT NULL + FROM pg_attribute a + WHERE a.attrelid = starelid + AND a.attnum = staattnum + AND a.attisdropped = false + ) + ) m + WHERE starelid IS NOT NULL; + +-- +-- Note: This view is copied from pg_stats in +-- src/backend/catalog/system_views.sql in core source tree of version +-- 9.5, and customized for pg_dbms_stats. Changes from orignal one are: +-- - rename from pg_stats to dbms_stats.stats by a view name. +-- - changed the table name from pg_statistic to dbms_stats.column_stats_effective. +-- +CREATE VIEW dbms_stats.stats with (security_barrier) AS + SELECT + nspname AS schemaname, + relname AS tablename, + attname AS attname, + stainherit AS inherited, + stanullfrac AS null_frac, + stawidth AS avg_width, + stadistinct AS n_distinct, + CASE + WHEN stakind1 = 1 THEN stavalues1 + WHEN stakind2 = 1 THEN stavalues2 + WHEN stakind3 = 1 THEN stavalues3 + WHEN stakind4 = 1 THEN stavalues4 + WHEN stakind5 = 1 THEN stavalues5 + END AS most_common_vals, + CASE + WHEN stakind1 = 1 THEN stanumbers1 + WHEN stakind2 = 1 THEN stanumbers2 + WHEN stakind3 = 1 THEN stanumbers3 + WHEN stakind4 = 1 THEN stanumbers4 + WHEN stakind5 = 1 THEN stanumbers5 + END AS most_common_freqs, + CASE + WHEN stakind1 = 2 THEN stavalues1 + WHEN stakind2 = 2 THEN stavalues2 + WHEN stakind3 = 2 THEN stavalues3 + WHEN stakind4 = 2 THEN stavalues4 + WHEN stakind5 = 2 THEN stavalues5 + END AS histogram_bounds, + CASE + WHEN stakind1 = 3 THEN stanumbers1[1] + WHEN stakind2 = 3 THEN stanumbers2[1] + WHEN stakind3 = 3 THEN stanumbers3[1] + WHEN stakind4 = 3 THEN stanumbers4[1] + WHEN stakind5 = 3 THEN stanumbers5[1] + END AS correlation, + CASE + WHEN stakind1 = 4 THEN stavalues1 + WHEN stakind2 = 4 THEN stavalues2 + WHEN stakind3 = 4 THEN stavalues3 + WHEN stakind4 = 4 THEN stavalues4 + WHEN stakind5 = 4 THEN stavalues5 + END AS most_common_elems, + CASE + WHEN stakind1 = 4 THEN stanumbers1 + WHEN stakind2 = 4 THEN stanumbers2 + WHEN stakind3 = 4 THEN stanumbers3 + WHEN stakind4 = 4 THEN stanumbers4 + WHEN stakind5 = 4 THEN stanumbers5 + END AS most_common_elem_freqs, + CASE + WHEN stakind1 = 5 THEN stanumbers1 + WHEN stakind2 = 5 THEN stanumbers2 + WHEN stakind3 = 5 THEN stanumbers3 + WHEN stakind4 = 5 THEN stanumbers4 + WHEN stakind5 = 5 THEN stanumbers5 + END AS elem_count_histogram + FROM dbms_stats.column_stats_effective s JOIN pg_class c ON (c.oid = s.starelid) + JOIN pg_attribute a ON (c.oid = attrelid AND attnum = s.staattnum) + LEFT JOIN pg_namespace n ON (n.oid = c.relnamespace) + WHERE NOT attisdropped + AND has_column_privilege(c.oid, a.attnum, 'select') + AND (c.relrowsecurity = false OR NOT row_security_active(c.oid)); + +-- +-- Utility functions +-- + +CREATE FUNCTION dbms_stats.invalidate_relation_cache() + RETURNS trigger AS + 'MODULE_PATHNAME', 'dbms_stats_invalidate_relation_cache' + LANGUAGE C; + +-- Invalidate cached plans when dbms_stats.relation_stats_locked is modified. +CREATE TRIGGER invalidate_relation_cache + BEFORE INSERT OR DELETE OR UPDATE + ON dbms_stats.relation_stats_locked + FOR EACH ROW EXECUTE PROCEDURE dbms_stats.invalidate_relation_cache(); + +CREATE FUNCTION dbms_stats.invalidate_column_cache() + RETURNS trigger AS + 'MODULE_PATHNAME', 'dbms_stats_invalidate_column_cache' + LANGUAGE C; + +-- Invalidate cached plans when dbms_stats.column_stats_locked is modified. +CREATE TRIGGER invalidate_column_cache + BEFORE INSERT OR DELETE OR UPDATE + ON dbms_stats.column_stats_locked + FOR EACH ROW EXECUTE PROCEDURE dbms_stats.invalidate_column_cache(); + +-- +-- BACKUP_STATS: Statistics backup functions +-- + +CREATE FUNCTION dbms_stats.backup( + backup_id int8, + relid regclass, + attnum int2 +) RETURNS int8 AS +$$ +/* Lock the backup id */ +SELECT * from dbms_stats.backup_history + WHERE id = $1 FOR UPDATE; + +INSERT INTO dbms_stats.relation_stats_backup + SELECT $1, v.relid, v.relname, v.relpages, v.reltuples, v.relallvisible, + v.curpages, v.last_analyze, v.last_autoanalyze + FROM pg_catalog.pg_class c, + dbms_stats.relation_stats_effective v + WHERE c.oid = v.relid + AND dbms_stats.is_target_relkind(relkind) + AND NOT dbms_stats.is_system_catalog(v.relid) + AND (v.relid = $2 OR $2 IS NULL); + +INSERT INTO dbms_stats.column_stats_backup + SELECT $1, atttypid, s.* + FROM pg_catalog.pg_class c, + dbms_stats.column_stats_effective s, + pg_catalog.pg_attribute a + WHERE c.oid = starelid + AND starelid = attrelid + AND staattnum = attnum + AND dbms_stats.is_target_relkind(relkind) + AND NOT dbms_stats.is_system_catalog(c.oid) + AND ($2 IS NULL OR starelid = $2) + AND ($3 IS NULL OR staattnum = $3); + +SELECT $1; +$$ +LANGUAGE sql; + +CREATE FUNCTION dbms_stats.backup( + relid regclass DEFAULT NULL, + attname text DEFAULT NULL, + comment text DEFAULT NULL +) RETURNS int8 AS +$$ +DECLARE + backup_id int8; + backup_relkind "char"; + set_attnum int2; + unit_type char; +BEGIN + IF $1 IS NULL AND $2 IS NOT NULL THEN + RAISE EXCEPTION 'relation required'; + END IF; + IF $1 IS NOT NULL THEN + SELECT relkind INTO backup_relkind + FROM pg_catalog.pg_class WHERE oid = $1 FOR SHARE; + IF NOT FOUND THEN + RAISE EXCEPTION 'relation "%" not found', $1; + END IF; + IF NOT dbms_stats.is_target_relkind(backup_relkind) THEN + RAISE EXCEPTION 'relation of relkind "%" cannot have statistics to backup: "%"', + backup_relkind, $1 + USING HINT = 'Only tables(r), materialized views(m), foreign tables(f) and indexes(i) are allowed.'; + END IF; + IF dbms_stats.is_system_catalog($1) THEN + RAISE EXCEPTION 'backing up statistics is inhibited for system catalogs: "%"', $1; + END IF; + IF $2 IS NOT NULL THEN + SELECT a.attnum INTO set_attnum FROM pg_catalog.pg_attribute a + WHERE a.attrelid = $1 AND a.attname = $2 FOR SHARE; + IF set_attnum IS NULL THEN + RAISE EXCEPTION 'column "%" not found in relation "%"', $2, $1; + END IF; + IF NOT EXISTS(SELECT * FROM dbms_stats.column_stats_effective WHERE starelid = $1 AND staattnum = set_attnum) THEN + RAISE EXCEPTION 'no statistics available for column "%" of relation "%"', $2, $1; + END IF; + unit_type = 'c'; + ELSE + unit_type = 't'; + END IF; + ELSE + unit_type = 'd'; + END IF; + + INSERT INTO dbms_stats.backup_history(time, unit, comment) + VALUES (current_timestamp, unit_type, $3) + RETURNING dbms_stats.backup(id, $1, set_attnum) INTO backup_id; + RETURN backup_id; +END; +$$ +LANGUAGE plpgsql; + +CREATE FUNCTION dbms_stats.backup_database_stats( + comment text +) RETURNS int8 AS +$$ +SELECT dbms_stats.backup(NULL, NULL, $1) +$$ +LANGUAGE sql; + +CREATE FUNCTION dbms_stats.backup_schema_stats( + schemaname text, + comment text +) RETURNS int8 AS +$$ +DECLARE + backup_id int8; +BEGIN + IF NOT EXISTS(SELECT * FROM pg_namespace WHERE nspname = $1 FOR SHARE) + THEN + RAISE EXCEPTION 'schema "%" not found', $1; + END IF; + IF dbms_stats.is_system_schema($1) THEN + RAISE EXCEPTION 'backing up statistics is inhibited for system schemas: "%"', $1; + END IF; + + INSERT INTO dbms_stats.backup_history(time, unit, comment) + VALUES (current_timestamp, 's', comment) + RETURNING id INTO backup_id; + + PERFORM dbms_stats.backup(backup_id, cn.oid, NULL) + FROM (SELECT c.oid + FROM pg_catalog.pg_class c, + pg_catalog.pg_namespace n + WHERE n.nspname = schemaname + AND c.relnamespace = n.oid + AND dbms_stats.is_target_relkind(c.relkind) + ORDER BY c.oid + ) cn; + + RETURN backup_id; +END; +$$ +LANGUAGE plpgsql; + +CREATE FUNCTION dbms_stats.backup_table_stats( + relid regclass, + comment text +) RETURNS int8 AS +$$ +SELECT dbms_stats.backup($1, NULL, $2) +$$ +LANGUAGE sql; + +CREATE FUNCTION dbms_stats.backup_table_stats( + schemaname text, + tablename text, + comment text +) RETURNS int8 AS +$$ +SELECT dbms_stats.backup(dbms_stats.relname($1, $2)::regclass, NULL, $3) +$$ +LANGUAGE sql; + +CREATE FUNCTION dbms_stats.backup_column_stats( + relid regclass, + attname text, + comment text +) RETURNS int8 AS +$$ +SELECT dbms_stats.backup($1, $2, $3) +$$ +LANGUAGE sql; + +CREATE FUNCTION dbms_stats.backup_column_stats( + schemaname text, + tablename text, + attname text, + comment text +) RETURNS int8 AS +$$ +SELECT dbms_stats.backup(dbms_stats.relname($1, $2)::regclass, $3, $4) +$$ +LANGUAGE sql; + +-- +-- RESTORE_STATS: Statistics restore functions +-- +CREATE FUNCTION dbms_stats.restore( + backup_id int8, + relid regclass DEFAULT NULL, + attname text DEFAULT NULL +) RETURNS SETOF regclass AS +$$ +DECLARE + restore_id int8; + restore_relid regclass; + restore_attnum int2; + set_attnum int2; + restore_attname text; + restore_type regtype; + cur_type regtype; +BEGIN + IF $1 IS NULL THEN + RAISE EXCEPTION 'backup id required'; + END IF; + IF $2 IS NULL AND $3 IS NOT NULL THEN + RAISE EXCEPTION 'relation required'; + END IF; + IF NOT EXISTS(SELECT * FROM dbms_stats.backup_history + WHERE id <= $1 FOR SHARE) THEN + RAISE EXCEPTION 'backup id % not found', $1; + END IF; + IF $2 IS NOT NULL THEN + IF NOT EXISTS(SELECT * FROM pg_catalog.pg_class + WHERE oid = $2 FOR SHARE) THEN + RAISE EXCEPTION 'relation "%" not found', $2; + END IF; + -- Grabbing all backups for the relation which is not used in restore. + IF NOT EXISTS(SELECT * FROM dbms_stats.relation_stats_backup b + WHERE b.id <= $1 AND b.relid = $2 FOR SHARE) THEN + RAISE EXCEPTION 'statistics of relation "%" not found in any backups before backup id = %', $2, $1; + END IF; + IF $3 IS NOT NULL THEN + SELECT a.attnum INTO set_attnum FROM pg_catalog.pg_attribute a + WHERE a.attrelid = $2 AND a.attname = $3; + IF set_attnum IS NULL THEN + RAISE EXCEPTION 'column "%" not found in relation %', $3, $2; + END IF; + IF NOT EXISTS(SELECT * FROM dbms_stats.column_stats_backup WHERE id <= $1 AND starelid = $2 AND staattnum = set_attnum) THEN + RAISE EXCEPTION 'statistics of column "%" of relation "%" are not found in any backups before backup id = %',$3, $2, $1; + END IF; + END IF; + PERFORM * FROM dbms_stats.relation_stats_locked r + WHERE r.relid = $2 FOR UPDATE; + ELSE + /* Lock the whole relation stats if relation is not specified.*/ + LOCK dbms_stats.relation_stats_locked IN EXCLUSIVE MODE; + END IF; + + FOR restore_id, restore_relid IN + SELECT max(id), coid FROM + (SELECT b.id as id, c.oid as coid + FROM pg_class c, dbms_stats.relation_stats_backup b + WHERE (c.oid = $2 OR $2 IS NULL) + AND c.oid = b.relid + AND dbms_stats.is_target_relkind(c.relkind) + AND NOT dbms_stats.is_system_catalog(c.oid) + AND b.id <= $1 + FOR SHARE) t + GROUP BY coid + ORDER BY coid::regclass::text + LOOP + UPDATE dbms_stats.relation_stats_locked r + SET relid = b.relid, + relname = b.relname, + relpages = b.relpages, + reltuples = b.reltuples, + relallvisible = b.relallvisible, + curpages = b.curpages, + last_analyze = b.last_analyze, + last_autoanalyze = b.last_autoanalyze + FROM dbms_stats.relation_stats_backup b + WHERE r.relid = restore_relid + AND b.id = restore_id + AND b.relid = restore_relid; + IF NOT FOUND THEN + INSERT INTO dbms_stats.relation_stats_locked + SELECT b.relid, + b.relname, + b.relpages, + b.reltuples, + b.relallvisible, + b.curpages, + b.last_analyze, + b.last_autoanalyze + FROM dbms_stats.relation_stats_backup b + WHERE b.id = restore_id + AND b.relid = restore_relid; + END IF; + RETURN NEXT restore_relid; + END LOOP; + + FOR restore_id, restore_relid, restore_attnum, restore_type, cur_type IN + SELECT t.id, t.oid, t.attnum, b.statypid, a.atttypid + FROM pg_attribute a, + dbms_stats.column_stats_backup b, + (SELECT max(b.id) AS id, c.oid, a.attnum + FROM pg_class c, pg_attribute a, dbms_stats.column_stats_backup b + WHERE (c.oid = $2 OR $2 IS NULL) + AND c.oid = a.attrelid + AND c.oid = b.starelid + AND (a.attnum = set_attnum OR set_attnum IS NULL) + AND a.attnum = b.staattnum + AND NOT a.attisdropped + AND dbms_stats.is_target_relkind(c.relkind) + AND b.id <= $1 + GROUP BY c.oid, a.attnum) t + WHERE a.attrelid = t.oid + AND a.attnum = t.attnum + AND b.id = t.id + AND b.starelid = t.oid + AND b.staattnum = t.attnum + LOOP + IF restore_type <> cur_type THEN + SELECT a.attname INTO restore_attname + FROM pg_catalog.pg_attribute a + WHERE a.attrelid = restore_relid + AND a.attnum = restore_attnum; + RAISE WARNING 'data type of column "%.%" is inconsistent between database(%) and backup (%). Skip.', + restore_relid, restore_attname, cur_type, restore_type; + ELSE + DELETE FROM dbms_stats.column_stats_locked + WHERE starelid = restore_relid + AND staattnum = restore_attnum; + INSERT INTO dbms_stats.column_stats_locked + SELECT starelid, staattnum, stainherit, + stanullfrac, stawidth, stadistinct, + stakind1, stakind2, stakind3, stakind4, stakind5, + staop1, staop2, staop3, staop4, staop5, + stacoll1, stacoll2, stacoll3, stacoll4, stacoll5, + stanumbers1, stanumbers2, stanumbers3, stanumbers4, stanumbers5, + stavalues1, stavalues2, stavalues3, stavalues4, stavalues5 + FROM dbms_stats.column_stats_backup + WHERE id = restore_id + AND starelid = restore_relid + AND staattnum = restore_attnum; + END IF; + END LOOP; +EXCEPTION + WHEN unique_violation THEN + RAISE EXCEPTION 'This operation is canceled by simultaneous lock or restore operation on the same relation.'; +END; +$$ +LANGUAGE plpgsql; + +CREATE FUNCTION dbms_stats.restore_database_stats( + as_of_timestamp timestamp with time zone +) RETURNS SETOF regclass AS +$$ +SELECT dbms_stats.restore(m.id, m.relid) + FROM (SELECT max(id) AS id, relid + FROM (SELECT r.id, r.relid + FROM pg_class c, dbms_stats.relation_stats_backup r, + dbms_stats.backup_history b + WHERE c.oid = r.relid + AND r.id = b.id + AND b.time <= $1 + FOR SHARE) t1 + GROUP BY t1.relid + ORDER BY t1.relid) m; +$$ +LANGUAGE sql STRICT; + +CREATE FUNCTION dbms_stats.restore_schema_stats( + schemaname text, + as_of_timestamp timestamp with time zone +) RETURNS SETOF regclass AS +$$ +BEGIN + IF NOT EXISTS(SELECT * FROM pg_namespace WHERE nspname = $1) THEN + RAISE EXCEPTION 'schema "%" not found', $1; + END IF; + IF dbms_stats.is_system_schema($1) THEN + RAISE EXCEPTION 'restoring statistics is inhibited for system schemas: "%"', $1; + END IF; + + RETURN QUERY + SELECT dbms_stats.restore(m.id, m.relid) + FROM (SELECT max(id) AS id, relid + FROM (SELECT r.id, r.relid + FROM pg_class c, pg_namespace n, + dbms_stats.relation_stats_backup r, + dbms_stats.backup_history b + WHERE c.oid = r.relid + AND c.relnamespace = n.oid + AND n.nspname = $1 + AND r.id = b.id + AND b.time <= $2 + FOR SHARE) t1 + GROUP BY t1.relid + ORDER BY t1.relid) m; +END; +$$ +LANGUAGE plpgsql STRICT; + +CREATE FUNCTION dbms_stats.restore_table_stats( + relid regclass, + as_of_timestamp timestamp with time zone +) RETURNS SETOF regclass AS +$$ +SELECT dbms_stats.restore(max(id), $1, NULL) + FROM dbms_stats.backup_history WHERE time <= $2 +$$ +LANGUAGE sql STRICT; + +CREATE FUNCTION dbms_stats.restore_table_stats( + schemaname text, + tablename text, + as_of_timestamp timestamp with time zone +) RETURNS SETOF regclass AS +$$ +SELECT dbms_stats.restore_table_stats(dbms_stats.relname($1, $2)::regclass, $3) +$$ +LANGUAGE sql STRICT; + +CREATE FUNCTION dbms_stats.restore_column_stats( + relid regclass, + attname text, + as_of_timestamp timestamp with time zone +) RETURNS SETOF regclass AS +$$ +SELECT dbms_stats.restore(max(id), $1, $2) + FROM dbms_stats.backup_history WHERE time <= $3 +$$ +LANGUAGE sql STRICT; + +CREATE FUNCTION dbms_stats.restore_column_stats( + schemaname text, + tablename text, + attname text, + as_of_timestamp timestamp with time zone +) RETURNS SETOF regclass AS +$$ +SELECT dbms_stats.restore(max(id), dbms_stats.relname($1, $2)::regclass, $3) + FROM dbms_stats.backup_history WHERE time <= $4 +$$ +LANGUAGE sql STRICT; + +CREATE FUNCTION dbms_stats.restore_stats( + backup_id int8 +) RETURNS SETOF regclass AS +$$ +DECLARE + restore_relid regclass; + restore_attnum int2; + restore_attname text; + restore_type regtype; + cur_type regtype; +BEGIN + IF NOT EXISTS(SELECT * FROM dbms_stats.backup_history WHERE id = $1) THEN + RAISE EXCEPTION 'backup id % not found', $1; + END IF; + + /* Lock the backup */ + PERFORM * from dbms_stats.relation_stats_backup b + WHERE id = $1 FOR SHARE; + + /* Locking only relation_stats_locked is sufficient */ + LOCK dbms_stats.relation_stats_locked IN EXCLUSIVE MODE; + + FOR restore_relid IN + SELECT b.relid + FROM pg_class c + JOIN dbms_stats.relation_stats_backup b ON (c.oid = b.relid) + WHERE b.id = $1 + ORDER BY c.oid::regclass::text + LOOP + UPDATE dbms_stats.relation_stats_locked r + SET relid = b.relid, + relname = b.relname, + relpages = b.relpages, + reltuples = b.reltuples, + relallvisible = b.relallvisible, + curpages = b.curpages, + last_analyze = b.last_analyze, + last_autoanalyze = b.last_autoanalyze + FROM dbms_stats.relation_stats_backup b + WHERE r.relid = restore_relid + AND b.id = $1 + AND b.relid = restore_relid; + IF NOT FOUND THEN + INSERT INTO dbms_stats.relation_stats_locked + SELECT b.relid, + b.relname, + b.relpages, + b.reltuples, + b.relallvisible, + b.curpages, + b.last_analyze, + b.last_autoanalyze + FROM dbms_stats.relation_stats_backup b + WHERE b.id = $1 + AND b.relid = restore_relid; + END IF; + RETURN NEXT restore_relid; + END LOOP; + + FOR restore_relid, restore_attnum, restore_type, cur_type IN + SELECT c.oid, a.attnum, b.statypid, a.atttypid + FROM pg_class c + JOIN dbms_stats.column_stats_backup b ON (c.oid = b.starelid) + JOIN pg_attribute a ON (b.starelid = attrelid + AND b.staattnum = a.attnum) + WHERE b.id = $1 + LOOP + IF restore_type <> cur_type THEN + SELECT attname INTO restore_attname + FROM pg_catalog.pg_attribute + WHERE attrelid = restore_relid + AND attnum = restore_attnum; + RAISE WARNING 'data type of column "%.%" is inconsistent between database(%) and backup (%). Skip.', + restore_relid, restore_attname, cur_type, restore_type; + ELSE + DELETE FROM dbms_stats.column_stats_locked + WHERE starelid = restore_relid + AND staattnum = restore_attnum; + INSERT INTO dbms_stats.column_stats_locked + SELECT starelid, staattnum, stainherit, + stanullfrac, stawidth, stadistinct, + stakind1, stakind2, stakind3, stakind4, stakind5, + staop1, staop2, staop3, staop4, staop5, + stacoll1, stacoll2, stacoll3, stacoll4, stacoll5, + stanumbers1, stanumbers2, stanumbers3, stanumbers4, stanumbers5, + stavalues1, stavalues2, stavalues3, stavalues4, stavalues5 + FROM dbms_stats.column_stats_backup + WHERE id = $1 + AND starelid = restore_relid + AND staattnum = restore_attnum; + END IF; + END LOOP; + +END; +$$ +LANGUAGE plpgsql STRICT; + +-- +-- LOCK_STATS: Statistics lock functions +-- + +CREATE FUNCTION dbms_stats.lock( + relid regclass, + attname text +) RETURNS regclass AS +$$ +DECLARE + lock_relkind "char"; + set_attnum int2; + r record; +BEGIN + IF $1 IS NULL THEN + RAISE EXCEPTION 'relation required'; + END IF; + IF $2 IS NULL THEN + RETURN dbms_stats.lock($1); + END IF; + SELECT relkind INTO lock_relkind FROM pg_catalog.pg_class WHERE oid = $1; + IF NOT FOUND THEN + RAISE EXCEPTION 'relation "%" not found', $1; + END IF; + IF NOT dbms_stats.is_target_relkind(lock_relkind) THEN + RAISE EXCEPTION '"%" must be a table or an index', $1; + END IF; + IF EXISTS(SELECT * FROM pg_catalog.pg_index WHERE lock_relkind = 'i' AND indexrelid = $1 AND indexprs IS NULL) THEN + RAISE EXCEPTION '"%" must be an expression index', $1; + END IF; + IF dbms_stats.is_system_catalog($1) THEN + RAISE EXCEPTION 'locking statistics is inhibited for system catalogs: "%"', $1; + END IF; + SELECT a.attnum INTO set_attnum FROM pg_catalog.pg_attribute a + WHERE a.attrelid = $1 AND a.attname = $2; + IF set_attnum IS NULL THEN + RAISE EXCEPTION 'column "%" not found in relation "%"', $2, $1; + END IF; + + /* + * If we don't have per-table statistics, create new one which has NULL for + * every statistic value for column_stats_effective. + */ + IF NOT EXISTS(SELECT * FROM dbms_stats.relation_stats_locked ru + WHERE ru.relid = $1 FOR SHARE) THEN + INSERT INTO dbms_stats.relation_stats_locked + SELECT $1, dbms_stats.relname(nspname, relname), + NULL, NULL, NULL, NULL, NULL + FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n + WHERE c.relnamespace = n.oid + AND c.oid = $1; + END IF; + + /* + * Process for per-column statistics + */ + FOR r IN + SELECT stainherit, stanullfrac, stawidth, stadistinct, + stakind1, stakind2, stakind3, stakind4, stakind5, + staop1, staop2, staop3, staop4, staop5, + stacoll1, stacoll2, stacoll3, stacoll4, stacoll5, + stanumbers1, stanumbers2, stanumbers3, stanumbers4, stanumbers5, + stavalues1, stavalues2, stavalues3, stavalues4, stavalues5 + FROM dbms_stats.column_stats_effective + WHERE starelid = $1 + AND staattnum = set_attnum + LOOP + UPDATE dbms_stats.column_stats_locked c + SET stanullfrac = r.stanullfrac, + stawidth = r.stawidth, + stadistinct = r.stadistinct, + stakind1 = r.stakind1, + stakind2 = r.stakind2, + stakind3 = r.stakind3, + stakind4 = r.stakind4, + stakind5 = r.stakind5, + staop1 = r.staop1, + staop2 = r.staop2, + staop3 = r.staop3, + staop4 = r.staop4, + staop5 = r.staop5, + stacoll1 = r.stacoll1, + stacoll2 = r.stacoll2, + stacoll3 = r.stacoll3, + stacoll4 = r.stacoll4, + stacoll5 = r.stacoll5, + stanumbers1 = r.stanumbers1, + stanumbers2 = r.stanumbers2, + stanumbers3 = r.stanumbers3, + stanumbers4 = r.stanumbers4, + stanumbers5 = r.stanumbers5, + stavalues1 = r.stavalues1, + stavalues2 = r.stavalues2, + stavalues3 = r.stavalues3, + stavalues4 = r.stavalues4, + stavalues5 = r.stavalues5 + WHERE c.starelid = $1 + AND c.staattnum = set_attnum + AND c.stainherit = r.stainherit; + + IF NOT FOUND THEN + INSERT INTO dbms_stats.column_stats_locked + VALUES ($1, + set_attnum, + r.stainherit, + r.stanullfrac, + r.stawidth, + r.stadistinct, + r.stakind1, + r.stakind2, + r.stakind3, + r.stakind4, + r.stakind5, + r.staop1, + r.staop2, + r.staop3, + r.staop4, + r.staop5, + r.stacoll1, + r.stacoll2, + r.stacoll3, + r.stacoll4, + r.stacoll5, + r.stanumbers1, + r.stanumbers2, + r.stanumbers3, + r.stanumbers4, + r.stanumbers5, + r.stavalues1, + r.stavalues2, + r.stavalues3, + r.stavalues4, + r.stavalues5); + END IF; + END LOOP; + + /* If we don't have statistics at all, raise error. */ + IF NOT FOUND THEN + RAISE EXCEPTION 'no statistics available for column "%" of relation "%"', $2, $1::regclass; + END IF; + + RETURN $1; +EXCEPTION + WHEN unique_violation THEN + RAISE EXCEPTION 'This operation is canceled by simultaneous lock or restore operation on the same relation.'; +END; +$$ +LANGUAGE plpgsql; + +CREATE FUNCTION dbms_stats.lock(relid regclass) + RETURNS regclass AS +$$ +DECLARE + lock_relkind "char"; + i record; +BEGIN + IF $1 IS NULL THEN + RAISE EXCEPTION 'relation required'; + END IF; + SELECT relkind INTO lock_relkind FROM pg_catalog.pg_class WHERE oid = $1; + IF NOT FOUND THEN + RAISE EXCEPTION 'relation "%" not found', $1; + END IF; + IF NOT dbms_stats.is_target_relkind(lock_relkind) THEN + RAISE EXCEPTION 'locking statistics is not allowed for relations with relkind "%": "%"', lock_relkind, $1 + USING HINT = 'Only tables(r, m, f) and indexes(i) are lockable.'; + END IF; + IF dbms_stats.is_system_catalog($1) THEN + RAISE EXCEPTION 'locking statistics is not allowed for system catalogs: "%"', $1; + END IF; + + UPDATE dbms_stats.relation_stats_locked r + SET relname = dbms_stats.relname(nspname, c.relname), + relpages = v.relpages, + reltuples = v.reltuples, + relallvisible = v.relallvisible, + curpages = v.curpages, + last_analyze = v.last_analyze, + last_autoanalyze = v.last_autoanalyze + FROM pg_catalog.pg_class c, + pg_catalog.pg_namespace n, + dbms_stats.relation_stats_effective v + WHERE r.relid = $1 + AND c.oid = $1 + AND c.relnamespace = n.oid + AND v.relid = $1; + IF NOT FOUND THEN + INSERT INTO dbms_stats.relation_stats_locked + SELECT $1, dbms_stats.relname(nspname, c.relname), + v.relpages, v.reltuples, v.relallvisible, v.curpages, + v.last_analyze, v.last_autoanalyze + FROM pg_catalog.pg_class c, + pg_catalog.pg_namespace n, + dbms_stats.relation_stats_effective v + WHERE c.oid = $1 + AND c.relnamespace = n.oid + AND v.relid = $1; + END IF; + + IF EXISTS(SELECT * + FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_index ind + ON c.oid = ind.indexrelid + WHERE c.oid = $1 + AND c.relkind = 'i' + AND ind.indexprs IS NULL) THEN + RETURN $1; + END IF; + + FOR i IN + SELECT staattnum, stainherit, stanullfrac, + stawidth, stadistinct, + stakind1, stakind2, stakind3, stakind4, stakind5, + staop1, staop2, staop3, staop4, staop5, + stacoll1, stacoll2, stacoll3, stacoll4, stacoll5, + stanumbers1, stanumbers2, stanumbers3, stanumbers4, stanumbers5, + stavalues1, stavalues2, stavalues3, stavalues4, stavalues5 + FROM dbms_stats.column_stats_effective + WHERE starelid = $1 + LOOP + UPDATE dbms_stats.column_stats_locked c + SET stanullfrac = i.stanullfrac, + stawidth = i.stawidth, + stadistinct = i.stadistinct, + stakind1 = i.stakind1, + stakind2 = i.stakind2, + stakind3 = i.stakind3, + stakind4 = i.stakind4, + stakind5 = i.stakind5, + staop1 = i.staop1, + staop2 = i.staop2, + staop3 = i.staop3, + staop4 = i.staop4, + staop5 = i.staop5, + stacoll1 = i.stacoll1, + stacoll2 = i.stacoll2, + stacoll3 = i.stacoll3, + stacoll4 = i.stacoll4, + stacoll5 = i.stacoll5, + stanumbers1 = i.stanumbers1, + stanumbers2 = i.stanumbers2, + stanumbers3 = i.stanumbers3, + stanumbers4 = i.stanumbers4, + stanumbers5 = i.stanumbers5, + stavalues1 = i.stavalues1, + stavalues2 = i.stavalues2, + stavalues3 = i.stavalues3, + stavalues4 = i.stavalues4, + stavalues5 = i.stavalues5 + WHERE c.starelid = $1 + AND c.staattnum = i.staattnum + AND c.stainherit = i.stainherit; + + IF NOT FOUND THEN + INSERT INTO dbms_stats.column_stats_locked + VALUES ($1, + i.staattnum, + i.stainherit, + i.stanullfrac, + i.stawidth, + i.stadistinct, + i.stakind1, + i.stakind2, + i.stakind3, + i.stakind4, + i.stakind5, + i.staop1, + i.staop2, + i.staop3, + i.staop4, + i.staop5, + i.stacoll1, + i.stacoll2, + i.stacoll3, + i.stacoll4, + i.stacoll5, + i.stanumbers1, + i.stanumbers2, + i.stanumbers3, + i.stanumbers4, + i.stanumbers5, + i.stavalues1, + i.stavalues2, + i.stavalues3, + i.stavalues4, + i.stavalues5); + END IF; + END LOOP; + + RETURN $1; +EXCEPTION + WHEN unique_violation THEN + RAISE EXCEPTION 'This operation is canceled by simultaneous lock operation on the same relation.'; +END; +$$ +LANGUAGE plpgsql; + +CREATE FUNCTION dbms_stats.lock_database_stats() + RETURNS SETOF regclass AS +$$ +SELECT dbms_stats.lock(c.oid) + FROM (SELECT oid + FROM pg_catalog.pg_class + WHERE NOT dbms_stats.is_system_catalog(oid) + AND dbms_stats.is_target_relkind(relkind) + ORDER BY pg_class.oid + ) c; +$$ +LANGUAGE sql; + +CREATE FUNCTION dbms_stats.lock_schema_stats( + schemaname text +) RETURNS SETOF regclass AS +$$ +BEGIN + IF NOT EXISTS(SELECT * FROM pg_namespace WHERE nspname = $1) THEN + RAISE EXCEPTION 'schema "%" not found', $1; + END IF; + IF dbms_stats.is_system_schema($1) THEN + RAISE EXCEPTION 'locking statistics is not allowed for system schemas: "%"', $1; + END IF; + + RETURN QUERY + SELECT dbms_stats.lock(cn.oid) + FROM (SELECT c.oid + FROM pg_class c, pg_namespace n + WHERE c.relnamespace = n.oid + AND dbms_stats.is_target_relkind(c.relkind) + AND n.nspname = $1 + ORDER BY c.oid + ) cn; +END; +$$ +LANGUAGE plpgsql STRICT; + +CREATE FUNCTION dbms_stats.lock_table_stats(relid regclass) + RETURNS regclass AS +$$ +SELECT dbms_stats.lock($1) +$$ +LANGUAGE sql STRICT; + +CREATE FUNCTION dbms_stats.lock_table_stats( + schemaname text, + tablename text +) RETURNS regclass AS +$$ +SELECT dbms_stats.lock(dbms_stats.relname($1, $2)::regclass) +$$ +LANGUAGE sql STRICT; + +CREATE FUNCTION dbms_stats.lock_column_stats( + relid regclass, + attname text +) RETURNS regclass AS +$$ +SELECT dbms_stats.lock($1, $2) +$$ +LANGUAGE sql STRICT; + +CREATE FUNCTION dbms_stats.lock_column_stats( + schemaname text, + tablename text, + attname text +) RETURNS regclass AS +$$ +SELECT dbms_stats.lock(dbms_stats.relname($1, $2)::regclass, $3) +$$ +LANGUAGE sql STRICT; + +-- +-- UNLOCK_STATS: Statistics unlock functions +-- + +CREATE FUNCTION dbms_stats.unlock( + relid regclass DEFAULT NULL, + attname text DEFAULT NULL +) RETURNS SETOF regclass AS +$$ +DECLARE + set_attnum int2; + unlock_id int8; +BEGIN + IF $1 IS NULL AND $2 IS NOT NULL THEN + RAISE EXCEPTION 'relation required'; + END IF; + + /* + * Lock the target relation to prevent conflicting with stats lock/restore + */ + PERFORM * FROM dbms_stats.relation_stats_locked ru + WHERE (ru.relid = $1 OR $1 IS NULL) FOR UPDATE; + + SELECT a.attnum INTO set_attnum FROM pg_catalog.pg_attribute a + WHERE a.attrelid = $1 AND a.attname = $2; + IF $2 IS NOT NULL AND set_attnum IS NULL THEN + RAISE EXCEPTION 'column "%" not found in relation "%"', $2, $1; + END IF; + + DELETE FROM dbms_stats.column_stats_locked + WHERE (starelid = $1 OR $1 IS NULL) + AND (staattnum = set_attnum OR $2 IS NULL); + + IF $1 IS NOT NULL AND $2 IS NOT NULL THEN + RETURN QUERY + SELECT $1; + END IF; + FOR unlock_id IN + SELECT ru.relid + FROM dbms_stats.relation_stats_locked ru + WHERE (ru.relid = $1 OR $1 IS NULL) AND ($2 IS NULL) + ORDER BY ru.relid + LOOP + DELETE FROM dbms_stats.relation_stats_locked ru + WHERE ru.relid = unlock_id; + RETURN NEXT unlock_id; + END LOOP; +END; +$$ +LANGUAGE plpgsql; + +CREATE FUNCTION dbms_stats.unlock_database_stats() + RETURNS SETOF regclass AS +$$ +DECLARE + unlock_id int8; +BEGIN + LOCK dbms_stats.relation_stats_locked IN EXCLUSIVE MODE; + + FOR unlock_id IN + SELECT relid + FROM dbms_stats.relation_stats_locked + ORDER BY relid + LOOP + DELETE FROM dbms_stats.relation_stats_locked + WHERE relid = unlock_id; + RETURN NEXT unlock_id; + END LOOP; +END; +$$ +LANGUAGE plpgsql STRICT; + +CREATE FUNCTION dbms_stats.unlock_schema_stats( + schemaname text +) RETURNS SETOF regclass AS +$$ +DECLARE + unlock_id int8; +BEGIN + IF NOT EXISTS(SELECT * FROM pg_namespace WHERE nspname = $1) THEN + RAISE EXCEPTION 'schema "%" not found', $1; + END IF; + IF dbms_stats.is_system_schema($1) THEN + RAISE EXCEPTION 'unlocking statistics is not allowed for system schemas: "%"', $1; + END IF; + + FOR unlock_id IN + SELECT r.relid + FROM dbms_stats.relation_stats_locked r, pg_class c, pg_namespace n + WHERE relid = c.oid + AND c.relnamespace = n.oid + AND n.nspname = $1 + ORDER BY relid + FOR UPDATE + LOOP + DELETE FROM dbms_stats.relation_stats_locked + WHERE relid = unlock_id; + RETURN NEXT unlock_id; + END LOOP; +END; +$$ +LANGUAGE plpgsql STRICT; + +CREATE FUNCTION dbms_stats.unlock_table_stats(relid regclass) + RETURNS SETOF regclass AS +$$ +DELETE FROM dbms_stats.relation_stats_locked + WHERE relid = $1 + RETURNING relid::regclass +$$ +LANGUAGE sql STRICT; + +CREATE FUNCTION dbms_stats.unlock_table_stats( + schemaname text, + tablename text +) RETURNS SETOF regclass AS +$$ +DELETE FROM dbms_stats.relation_stats_locked + WHERE relid = dbms_stats.relname($1, $2)::regclass + RETURNING relid::regclass +$$ +LANGUAGE sql STRICT; + +CREATE FUNCTION dbms_stats.unlock_column_stats( + relid regclass, + attname text +) RETURNS SETOF regclass AS +$$ +DECLARE + set_attnum int2; +BEGIN + SELECT a.attnum INTO set_attnum FROM pg_catalog.pg_attribute a + WHERE a.attrelid = $1 AND a.attname = $2; + IF $2 IS NOT NULL AND set_attnum IS NULL THEN + RAISE EXCEPTION 'column "%" not found in relation "%"', $2, $1; + END IF; + + /* Lock the locked table stats */ + PERFORM * from dbms_stats.relation_stats_locked r + WHERE r.relid = $1 FOR SHARE; + + DELETE FROM dbms_stats.column_stats_locked + WHERE starelid = $1 + AND staattnum = set_attnum; + + RETURN QUERY + SELECT $1; +END; +$$ +LANGUAGE plpgsql STRICT; + +CREATE FUNCTION dbms_stats.unlock_column_stats( + schemaname text, + tablename text, + attname text +) RETURNS SETOF regclass AS +$$ +DECLARE + set_attnum int2; +BEGIN + SELECT a.attnum INTO set_attnum FROM pg_catalog.pg_attribute a + WHERE a.attrelid = dbms_stats.relname($1, $2)::regclass + AND a.attname = $3; + IF $3 IS NOT NULL AND set_attnum IS NULL THEN + RAISE EXCEPTION 'column "%" not found in relation "%.%"', $3, $1, $2; + END IF; + + /* Lock the locked table stats */ + PERFORM * from dbms_stats.relation_stats_locked r + WHERE relid = dbms_stats.relname($1, $2)::regclass FOR SHARE; + + DELETE FROM dbms_stats.column_stats_locked + WHERE starelid = dbms_stats.relname($1, $2)::regclass + AND staattnum = set_attnum; + + RETURN QUERY + SELECT dbms_stats.relname($1, $2)::regclass; +END; +$$ +LANGUAGE plpgsql STRICT; + +-- +-- IMPORT_STATS: Statistics import functions +-- + +CREATE FUNCTION dbms_stats.import( + nspname text DEFAULT NULL, + relid regclass DEFAULT NULL, + attname text DEFAULT NULL, + src text DEFAULT NULL +) RETURNS void AS +'MODULE_PATHNAME', 'dbms_stats_import' +LANGUAGE C; + +CREATE FUNCTION dbms_stats.import_database_stats(src text) + RETURNS void AS +$$ +SELECT dbms_stats.import(NULL, NULL, NULL, $1) +$$ +LANGUAGE sql; + +CREATE FUNCTION dbms_stats.import_schema_stats( + schemaname text, + src text +) RETURNS void AS +$$ +SELECT dbms_stats.import($1, NULL, NULL, $2) +$$ +LANGUAGE sql; + +CREATE FUNCTION dbms_stats.import_table_stats( + relid regclass, + src text +) RETURNS void AS +$$ +SELECT dbms_stats.import(NULL, $1, NULL, $2) +$$ +LANGUAGE sql; + +CREATE FUNCTION dbms_stats.import_table_stats( + schemaname text, + tablename text, + src text +) RETURNS void AS +$$ +SELECT dbms_stats.import(NULL, dbms_stats.relname($1, $2)::regclass, NULL, $3) +$$ +LANGUAGE sql; + +CREATE FUNCTION dbms_stats.import_column_stats( + relid regclass, + attname text, + src text +) RETURNS void AS +$$ +SELECT dbms_stats.import(NULL, $1, $2, $3) +$$ +LANGUAGE sql; + +CREATE FUNCTION dbms_stats.import_column_stats( + schemaname text, + tablename text, + attname text, + src text +) RETURNS void AS +$$ +SELECT dbms_stats.import(NULL, dbms_stats.relname($1, $2)::regclass, $3, $4) +$$ +LANGUAGE sql; + +-- +-- PURGE_STATS: Statistics purge function +-- +CREATE FUNCTION dbms_stats.purge_stats( + backup_id int8, + force bool DEFAULT false +) RETURNS SETOF dbms_stats.backup_history AS +$$ +DECLARE + delete_id int8; + todelete dbms_stats.backup_history; +BEGIN + IF $1 IS NULL THEN + RAISE EXCEPTION 'backup id required'; + END IF; + IF $2 IS NULL THEN + RAISE EXCEPTION 'NULL is not allowed as the second parameter'; + END IF; + + IF NOT EXISTS(SELECT * FROM dbms_stats.backup_history + WHERE id = $1 FOR UPDATE) THEN + RAISE EXCEPTION 'backup id % not found', $1; + END IF; + IF NOT $2 AND NOT EXISTS(SELECT * + FROM dbms_stats.backup_history + WHERE unit = 'd' + AND id > $1) THEN + RAISE WARNING 'no database-wide backup will remain after purge' + USING HINT = 'Give true for second parameter to purge forcibly.'; + RETURN; + END IF; + + FOR todelete IN + SELECT * FROM dbms_stats.backup_history + WHERE id <= $1 + ORDER BY id FOR UPDATE + LOOP + DELETE FROM dbms_stats.backup_history + WHERE id = todelete.id; + RETURN NEXT todelete; + END LOOP; +END; +$$ +LANGUAGE plpgsql; + +-- +-- CLEAN_STATS: Clean orphan dummy statistics +-- +CREATE FUNCTION dbms_stats.clean_up_stats() RETURNS SETOF text AS +$$ +DECLARE + clean_relid Oid; + clean_attnum int2; + clean_inherit bool; + clean_rel_col text; +BEGIN + -- We don't have to check that table-level dummy statistics of the table + -- exists here, because the foreign key constraints defined on column-level + -- dummy static table ensures that. + FOR clean_rel_col, clean_relid, clean_attnum, clean_inherit IN + SELECT r.relname || ', ' || v.staattnum::text, + v.starelid, v.staattnum, v.stainherit + FROM dbms_stats.column_stats_locked v + JOIN dbms_stats.relation_stats_locked r ON (v.starelid = r.relid) + WHERE NOT EXISTS ( + SELECT NULL + FROM pg_attribute a + WHERE a.attrelid = v.starelid + AND a.attnum = v.staattnum + AND a.attisdropped = false + FOR UPDATE + ) + LOOP + DELETE FROM dbms_stats.column_stats_locked + WHERE starelid = clean_relid + AND staattnum = clean_attnum + AND stainherit = clean_inherit; + RETURN NEXT clean_rel_col; + END LOOP; + + RETURN QUERY + DELETE FROM dbms_stats.relation_stats_locked r + WHERE NOT EXISTS ( + SELECT NULL + FROM pg_class c + WHERE c.oid = r.relid) + RETURNING relname || ','; + RETURN; +END +$$ +LANGUAGE plpgsql; +-- +/* + * Stuff for manipulating statistics + */ + +/* Primitive functions for tweaking statistics */ +CREATE FUNCTION dbms_stats.anyarray_basetype(dbms_stats.anyarray) + RETURNS name + AS 'MODULE_PATHNAME', 'dbms_stats_anyarray_basetype' + LANGUAGE C STABLE; + +CREATE FUNCTION dbms_stats.type_is_analyzable(oid) returns bool + AS 'MODULE_PATHNAME', 'dbms_stats_type_is_analyzable' + LANGUAGE C STRICT STABLE; + +/* + * Create and drop a cast necessary to set column values of dbms_stats.anyarray + * type. + */ +CREATE OR REPLACE FUNCTION dbms_stats.prepare_statstweak(regtype) +RETURNS text AS $$ +DECLARE + srctypname varchar; + funcname varchar; + funcdef varchar; + castdef varchar; +BEGIN + srctypname := $1 || '[]'; + funcname := 'dbms_stats._' || replace($1::text, ' ', '_') || '_ary_anyarray'; + funcdef := funcname || '(' || srctypname || ')'; + castdef := '(' || srctypname || ' AS dbms_stats.anyarray)'; + + IF (NOT dbms_stats.type_is_analyzable($1::regtype)) THEN + RAISE 'the type can not have statistics'; + END IF; + + EXECUTE 'CREATE FUNCTION ' || funcdef || + ' RETURNS dbms_stats.anyarray ' || + ' AS ''pg_dbms_stats'', ''dbms_stats_anyary_anyary'''|| + ' LANGUAGE C STRICT IMMUTABLE'; + EXECUTE 'CREATE CAST '|| castdef || + ' WITH FUNCTION ' || funcdef || + ' AS ASSIGNMENT'; + RETURN '(func ' || funcdef || ', cast ' || castdef || ')'; +EXCEPTION + WHEN duplicate_function THEN + RAISE 'run dbms_stats.drop_statstweak() for the type before this'; +END; +$$ LANGUAGE plpgsql; + +CREATE OR REPLACE FUNCTION dbms_stats.drop_statstweak(regtype) +RETURNS text AS $$ +DECLARE + srctypname varchar; + funcname varchar; + funcdef varchar; + castdef varchar; +BEGIN + srctypname := $1 || '[]'; + funcname := 'dbms_stats._' || replace($1::text, ' ', '_') || '_ary_anyarray'; + funcdef := funcname || '(' || srctypname || ')'; + castdef := '(' || srctypname || ' AS dbms_stats.anyarray)'; + + EXECUTE 'DROP CAST ' || castdef; + EXECUTE 'DROP FUNCTION ' || funcdef; + RETURN '(func ' || funcdef || ', cast ' || castdef || ')'; +EXCEPTION + WHEN undefined_function OR undefined_object THEN + RAISE 'function % or cast % does not exist', funcdef, castdef; +END; +$$ LANGUAGE plpgsql; diff --git a/import.c b/import.c index fb9aa82..961166a 100644 --- a/import.c +++ b/import.c @@ -119,6 +119,11 @@ dbms_stats_import(PG_FUNCTION_ARGS) "staop3 oid," "staop4 oid," "staop5 oid," + "stacoll1 oid," + "stacoll2 oid," + "stacoll3 oid," + "stacoll4 oid," + "stacoll5 oid," "stanumbers1 float4[]," "stanumbers2 float4[]," "stanumbers3 float4[]," @@ -351,6 +356,7 @@ dbms_stats_import(PG_FUNCTION_ARGS) "stainherit, stanullfrac, stawidth, stadistinct, " "stakind1, stakind2, stakind3, stakind4, stakind5, " "staop1, staop2, staop3, staop4, staop5, " + "stacoll1, stacoll2, stacoll3, stacoll4, stacoll5, " "stanumbers1, stanumbers2, stanumbers3, stanumbers4, " "stanumbers5, " "stavalues1, stavalues2, stavalues3, stavalues4 , stavalues5 " diff --git a/input/ut_imp_exp-12.source b/input/ut_imp_exp-12.source new file mode 100644 index 0000000..f895947 --- /dev/null +++ b/input/ut_imp_exp-12.source @@ -0,0 +1,295 @@ +\pset null '(null)' +CREATE TABLE s0.st3(); +/* + * No.16-1 export_plain_stats-12.sql.sample + */ +-- No.16-1-1 +ANALYZE; +DELETE FROM dbms_stats.column_stats_locked; +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +UPDATE dbms_stats.relation_stats_locked + SET (relpages, reltuples, relallvisible, curpages) = (0,0,0,0); +UPDATE dbms_stats.column_stats_locked SET + stanullfrac = -staattnum, + stawidth = -staattnum, + stadistinct = -staattnum, + stakind1 = 2, + stakind2 = 3, + stakind3 = 4, + stakind4 = 1, + stakind5 = 5, + staop1 = 22, + staop2 = 23, + staop3 = 24, + staop4 = 21, + staop5 = 25, + stanumbers1 = ARRAY[-staattnum,22], + stanumbers2 = ARRAY[-staattnum,23], + stanumbers3 = ARRAY[-staattnum,24], + stanumbers4 = ARRAY[-staattnum,21], + stanumbers5 = ARRAY[-staattnum,25], + stavalues1 = stavalues3, + stavalues2 = stavalues2, + stavalues3 = stavalues1, + stavalues4 = stavalues4, + stavalues5 = stavalues5; +\i doc/export_plain_stats-12.sql.sample +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; +TRUNCATE dbms_stats.work; +-- No.16-1-2 +\! sed '/ORDER/i\\ AND n2.nspname = '"\'s0\'" doc/export_plain_stats-12.sql.sample > doc/export_plain_stats-12.sql.sample_test +\i doc/export_plain_stats-12.sql.sample_test +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; +TRUNCATE dbms_stats.work; +\! rm doc/export_plain_stats-12.sql.sample_test +-- No.16-1-3 +\! sed '/ORDER/i\\ AND c.relname = '"\'st0\'" doc/export_plain_stats-12.sql.sample > doc/export_plain_stats-12.sql.sample_test +\i doc/export_plain_stats-12.sql.sample_test +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; +TRUNCATE dbms_stats.work; +\! rm doc/export_plain_stats-12.sql.sample_test +-- No.16-1-3-1 Actual import test +select dbms_stats.import_database_stats('@abs_srcdir@/export_stats.dmp'); +-- No.16-1-4 +\! sed '/ORDER/i\\ AND c.relname = '"\'pg_toast_1262\'" doc/export_plain_stats-12.sql.sample > doc/export_plain_stats-12.sql.sample_test +\i doc/export_plain_stats-12.sql.sample_test +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; +TRUNCATE dbms_stats.work; +\! rm doc/export_plain_stats-12.sql.sample_test +-- No.16-1-5 +\! sed '/ORDER/i\\ AND c.relname = '"\'st0_idx\'" doc/export_plain_stats-12.sql.sample > doc/export_plain_stats-12.sql.sample_test +\i doc/export_plain_stats-12.sql.sample_test +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; +TRUNCATE dbms_stats.work; +\! rm doc/export_plain_stats-12.sql.sample_test +-- No.16-1-6 +\! sed '/ORDER/i\\ AND c.relname = '"\'ss0\'" doc/export_plain_stats-12.sql.sample > doc/export_plain_stats-12.sql.sample_test +\i doc/export_plain_stats-12.sql.sample_test +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; +TRUNCATE dbms_stats.work; +\! rm doc/export_plain_stats-12.sql.sample_test +-- No.16-1-7 +\! sed '/ORDER/i\\ AND c.relname = '"\'sc0\'" doc/export_plain_stats-12.sql.sample > doc/export_plain_stats-12.sql.sample_test +\i doc/export_plain_stats-12.sql.sample_test +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; +TRUNCATE dbms_stats.work; +\! rm doc/export_plain_stats-12.sql.sample_test +-- No.16-1-8 +\! sed '/ORDER/i\\ AND c.relname = '"\'sft0\'" doc/export_plain_stats-12.sql.sample > doc/export_plain_stats-12.sql.sample_test +\i doc/export_plain_stats-12.sql.sample_test +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; +TRUNCATE dbms_stats.work; +\! rm doc/export_plain_stats-12.sql.sample_test +-- No.16-1-9 +\! sed '/ORDER/i\\ AND c.relname = '"\'smv0\'" doc/export_plain_stats-12.sql.sample > doc/export_plain_stats-12.sql.sample_test +\i doc/export_plain_stats-12.sql.sample_test +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; +TRUNCATE dbms_stats.work; +\! rm doc/export_plain_stats-12.sql.sample_test +-- No.16-1-10 +\! 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 +\i doc/export_plain_stats-12.sql.sample_test +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; +TRUNCATE dbms_stats.work; +\! rm doc/export_plain_stats-12.sql.sample_test +-- No.16-1-11 +\! 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 +\i doc/export_plain_stats-12.sql.sample_test +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; +TRUNCATE dbms_stats.work; +\! rm doc/export_plain_stats-12.sql.sample_test +-- No.16-1-12 +\! 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 +\i doc/export_plain_stats-12.sql.sample_test +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; +TRUNCATE dbms_stats.work; +\! rm doc/export_plain_stats-12.sql.sample_test + +/* + * No.16-2 export_effective_stats-12.sql.sample + */ +-- No.16-2-1 +VACUUM ANALYZE; +SELECT dbms_stats.lock_database_stats(); +UPDATE dbms_stats.relation_stats_locked + SET (relpages, reltuples, relallvisible, curpages) = (NULL, NULL, NULL, NULL); +UPDATE dbms_stats.column_stats_locked + SET (stanullfrac, stawidth, stadistinct, + stakind1, stakind2, stakind3, stakind4, stakind5, + staop1, staop2, staop3, staop4, staop5, + stanumbers1, stanumbers2, stanumbers3, stanumbers4, stanumbers5, + stavalues1, stavalues2, stavalues3, stavalues4, stavalues5) + = (NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL) + WHERE starelid = 's0.st0'::regclass; +\i doc/export_effective_stats-12.sql.sample +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; +TRUNCATE dbms_stats.work; +-- No.16-2-2 +\! sed '/ORDER/i\\ WHERE n2.nspname = '"\'s0\'" doc/export_effective_stats-12.sql.sample > doc/export_effective_stats-12.sql.sample_test +\i doc/export_effective_stats-12.sql.sample_test +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; +\! rm doc/export_effective_stats-12.sql.sample_test +TRUNCATE dbms_stats.work; +-- No.16-2-3 +\! sed '/ORDER/i\\ WHERE cl.relname = '"\'st0\'" doc/export_effective_stats-12.sql.sample > doc/export_effective_stats-12.sql.sample_test +\i doc/export_effective_stats-12.sql.sample_test +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; +\! rm doc/export_effective_stats-12.sql.sample_test +TRUNCATE dbms_stats.work; +-- No.16-2-4 +\! sed '/ORDER/i\\ WHERE cl.relname = '"\'pg_toast_1262\'" doc/export_effective_stats-12.sql.sample > doc/export_effective_stats-12.sql.sample_test +\i doc/export_effective_stats-12.sql.sample_test +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; +\! rm doc/export_effective_stats-12.sql.sample_test +TRUNCATE dbms_stats.work; +-- No.16-2-5 +\! sed '/ORDER/i\\ WHERE cl.relname = '"\'st0_idx\'" doc/export_effective_stats-12.sql.sample > doc/export_effective_stats-12.sql.sample_test +\i doc/export_effective_stats-12.sql.sample_test +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; +\! rm doc/export_effective_stats-12.sql.sample_test +TRUNCATE dbms_stats.work; +-- No.16-2-6 +\! sed '/ORDER/i\\ WHERE cl.relname = '"\'ss0\'" doc/export_effective_stats-12.sql.sample > doc/export_effective_stats-12.sql.sample_test +\i doc/export_effective_stats-12.sql.sample_test +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; +\! rm doc/export_effective_stats-12.sql.sample_test +TRUNCATE dbms_stats.work; +-- No.16-2-7 +\! sed '/ORDER/i\\ WHERE cl.relname = '"\'sc0\'" doc/export_effective_stats-12.sql.sample > doc/export_effective_stats-12.sql.sample_test +\i doc/export_effective_stats-12.sql.sample_test +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; +\! rm doc/export_effective_stats-12.sql.sample_test +TRUNCATE dbms_stats.work; +-- No.16-2-8 +\! sed '/ORDER/i\\ WHERE cl.relname = '"\'sft0\'" doc/export_effective_stats-12.sql.sample > doc/export_effective_stats-12.sql.sample_test +\i doc/export_effective_stats-12.sql.sample_test +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; +\! rm doc/export_effective_stats-12.sql.sample_test +TRUNCATE dbms_stats.work; +-- No.16-2-9 +\! sed '/ORDER/i\\ WHERE cl.relname = '"\'smv0\'" doc/export_effective_stats-12.sql.sample > doc/export_effective_stats-12.sql.sample_test +\i doc/export_effective_stats-12.sql.sample_test +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; +\! rm doc/export_effective_stats-12.sql.sample_test +TRUNCATE dbms_stats.work; +-- No.16-2-10 +\! 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 +\i doc/export_effective_stats-12.sql.sample_test +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; +\! rm doc/export_effective_stats-12.sql.sample_test +TRUNCATE dbms_stats.work; +-- No.16-2-11 +\! 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 +\i doc/export_effective_stats-12.sql.sample_test +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; +\! rm doc/export_effective_stats-12.sql.sample_test +TRUNCATE dbms_stats.work; +-- No.16-2-12 +\! 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 +\i doc/export_effective_stats-12.sql.sample_test +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; +\! rm doc/export_effective_stats-12.sql.sample_test +TRUNCATE dbms_stats.work; + +/* + * Stab function dbms_stats.import + */ +ALTER FUNCTION dbms_stats.import( + nspname text, + relid regclass, + attname text, + src text +) RENAME TO truth_import; +CREATE FUNCTION dbms_stats.import( + nspname text, + relid regclass, + attname text, + src text +) RETURNS void AS +$$ +BEGIN + RAISE NOTICE 'arguments are "%", "%", "%", "%"', $1, $2, $3, $4; + RETURN; +END +$$ +LANGUAGE plpgsql; +/* + * No.17-1 dbms_stats.import_database_stats(src) + */ +-- No.17-1-1 +SELECT dbms_stats.import_database_stats('@abs_srcdir@/export_stats.dmp'); + +/* + * No.17-2 dbms_stats.import_schema_stats(schemaname, src) + */ +-- No.17-2-1 +SELECT dbms_stats.import_schema_stats('s0', '@abs_srcdir@/export_stats.dmp'); + +/* + * No.17-3 dbms_stats.import_table_stats(relid, src) + */ +-- No.17-3-1 +SELECT dbms_stats.import_table_stats('s0.st0', '@abs_srcdir@/export_stats.dmp'); + +/* + * No.17-4 dbms_stats.import_table_stats(schemaname, tablename, src) + */ +-- No.17-4-1 +SELECT dbms_stats.import_table_stats('s0', 'st0', '@abs_srcdir@/export_stats.dmp'); + +/* + * No.17-5 dbms_stats.import_column_stats (relid, attname, src) + */ +-- No.17-5-1 +SELECT dbms_stats.import_column_stats('s0.st0', 'id', '@abs_srcdir@/export_stats.dmp'); + +/* + * No.17-6 dbms_stats.import_column_stats (schemaname, tablename, attname, src) + */ +-- No.17-6-1 +SELECT dbms_stats.import_column_stats('s0', 'st0', 'id','@abs_srcdir@/export_stats.dmp'); + +/* + * Delete stab function dbms_stats.import + */ +DROP FUNCTION dbms_stats.import( + nspname text, + relid regclass, + attname text, + src text +); +ALTER FUNCTION dbms_stats.truth_import( + nspname text, + relid regclass, + attname text, + src text +) RENAME TO import; diff --git a/output/ut_imp_exp-12.source b/output/ut_imp_exp-12.source new file mode 100644 index 0000000..0b0ea9a --- /dev/null +++ b/output/ut_imp_exp-12.source @@ -0,0 +1,2398 @@ +\pset null '(null)' +CREATE TABLE s0.st3(); +/* + * No.16-1 export_plain_stats-12.sql.sample + */ +-- No.16-1-1 +ANALYZE; +DELETE FROM dbms_stats.column_stats_locked; +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 + s0.st3 +(17 rows) + +UPDATE dbms_stats.relation_stats_locked + SET (relpages, reltuples, relallvisible, curpages) = (0,0,0,0); +UPDATE dbms_stats.column_stats_locked SET + stanullfrac = -staattnum, + stawidth = -staattnum, + stadistinct = -staattnum, + stakind1 = 2, + stakind2 = 3, + stakind3 = 4, + stakind4 = 1, + stakind5 = 5, + staop1 = 22, + staop2 = 23, + staop3 = 24, + staop4 = 21, + staop5 = 25, + stanumbers1 = ARRAY[-staattnum,22], + stanumbers2 = ARRAY[-staattnum,23], + stanumbers3 = ARRAY[-staattnum,24], + stanumbers4 = ARRAY[-staattnum,21], + stanumbers5 = ARRAY[-staattnum,25], + stavalues1 = stavalues3, + stavalues2 = stavalues2, + stavalues3 = stavalues1, + stavalues4 = stavalues4, + stavalues5 = stavalues5; +\i doc/export_plain_stats-12.sql.sample +/* + * If you want the statistics of per-relation or per-column, please modify + * nspname, relname, and attname in 'WHERE' clause. + */ +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE; +/* + * If you want to chage the output file name, please modify the following name. + */ +\o export_stats.dmp +COPY (SELECT n2.nspname, + c.relname, + c.relpages, + c.reltuples, + c.relallvisible, + (pg_relation_size(c.oid) / current_setting('block_size')::int4)::int4 + AS curpages, + pg_catalog.pg_stat_get_last_analyze_time(c.oid) + AS last_analyze, + pg_catalog.pg_stat_get_last_autoanalyze_time(c.oid) + AS last_autoanalyze, + COALESCE(a.attname, ''), + n1.nspname AS schemaname_of_atttype, + t.typname, + a.atttypmod, + s.stainherit, + s.stanullfrac, + s.stawidth, + s.stadistinct, + s.stakind1, + s.stakind2, + s.stakind3, + s.stakind4, + s.stakind5, + s.staop1, + s.staop2, + s.staop3, + s.staop4, + s.staop5, + s.stacoll1, + s.stacoll2, + s.stacoll3, + s.stacoll4, + s.stacoll5, + s.stanumbers1, + s.stanumbers2, + s.stanumbers3, + s.stanumbers4, + s.stanumbers5, + s.stavalues1, + s.stavalues2, + s.stavalues3, + s.stavalues4, + s.stavalues5 + FROM pg_statistic s + JOIN pg_attribute a + ON (s.starelid = a.attrelid AND s.staattnum = a.attnum) + JOIN pg_type t + ON a.atttypid = t.oid + JOIN pg_namespace n1 + ON t.typnamespace = n1.oid + RIGHT JOIN pg_catalog.pg_class c + ON s.starelid = c.oid + JOIN pg_catalog.pg_namespace n2 + ON c.relnamespace = n2.oid + WHERE c.relkind IN ('r', 'i', 'f', 'm') + AND NOT n2.nspname IN ('pg_catalog', + 'pg_toast', + 'information_schema', + 'dbms_stats') + -- AND n2.nspname = 'public' + -- AND c.relname = 'test' + -- AND a.attname = 'id' + ORDER BY starelid, staattnum) +TO STDOUT +(FORMAT 'binary'); +\o +COMMIT; +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; + 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 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+------------------------+-------------+-------------+-------------+-------------+------------------------+------------+------------+------------+------------ + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) +(27 rows) + +TRUNCATE dbms_stats.work; +-- No.16-1-2 +\! sed '/ORDER/i\\ AND n2.nspname = '"\'s0\'" doc/export_plain_stats-12.sql.sample > doc/export_plain_stats-12.sql.sample_test +\i doc/export_plain_stats-12.sql.sample_test +/* + * If you want the statistics of per-relation or per-column, please modify + * nspname, relname, and attname in 'WHERE' clause. + */ +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE; +/* + * If you want to chage the output file name, please modify the following name. + */ +\o export_stats.dmp +COPY (SELECT n2.nspname, + c.relname, + c.relpages, + c.reltuples, + c.relallvisible, + (pg_relation_size(c.oid) / current_setting('block_size')::int4)::int4 + AS curpages, + pg_catalog.pg_stat_get_last_analyze_time(c.oid) + AS last_analyze, + pg_catalog.pg_stat_get_last_autoanalyze_time(c.oid) + AS last_autoanalyze, + COALESCE(a.attname, ''), + n1.nspname AS schemaname_of_atttype, + t.typname, + a.atttypmod, + s.stainherit, + s.stanullfrac, + s.stawidth, + s.stadistinct, + s.stakind1, + s.stakind2, + s.stakind3, + s.stakind4, + s.stakind5, + s.staop1, + s.staop2, + s.staop3, + s.staop4, + s.staop5, + s.stacoll1, + s.stacoll2, + s.stacoll3, + s.stacoll4, + s.stacoll5, + s.stanumbers1, + s.stanumbers2, + s.stanumbers3, + s.stanumbers4, + s.stanumbers5, + s.stavalues1, + s.stavalues2, + s.stavalues3, + s.stavalues4, + s.stavalues5 + FROM pg_statistic s + JOIN pg_attribute a + ON (s.starelid = a.attrelid AND s.staattnum = a.attnum) + JOIN pg_type t + ON a.atttypid = t.oid + JOIN pg_namespace n1 + ON t.typnamespace = n1.oid + RIGHT JOIN pg_catalog.pg_class c + ON s.starelid = c.oid + JOIN pg_catalog.pg_namespace n2 + ON c.relnamespace = n2.oid + WHERE c.relkind IN ('r', 'i', 'f', 'm') + AND NOT n2.nspname IN ('pg_catalog', + 'pg_toast', + 'information_schema', + 'dbms_stats') + -- AND n2.nspname = 'public' + -- AND c.relname = 'test' + -- AND a.attname = 'id' + AND n2.nspname = 's0' + ORDER BY starelid, staattnum) +TO STDOUT +(FORMAT 'binary'); +\o +COMMIT; +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; + 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 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------------+------------+------------+------------+------------ + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) +(16 rows) + +TRUNCATE dbms_stats.work; +\! rm doc/export_plain_stats-12.sql.sample_test +-- No.16-1-3 +\! sed '/ORDER/i\\ AND c.relname = '"\'st0\'" doc/export_plain_stats-12.sql.sample > doc/export_plain_stats-12.sql.sample_test +\i doc/export_plain_stats-12.sql.sample_test +/* + * If you want the statistics of per-relation or per-column, please modify + * nspname, relname, and attname in 'WHERE' clause. + */ +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE; +/* + * If you want to chage the output file name, please modify the following name. + */ +\o export_stats.dmp +COPY (SELECT n2.nspname, + c.relname, + c.relpages, + c.reltuples, + c.relallvisible, + (pg_relation_size(c.oid) / current_setting('block_size')::int4)::int4 + AS curpages, + pg_catalog.pg_stat_get_last_analyze_time(c.oid) + AS last_analyze, + pg_catalog.pg_stat_get_last_autoanalyze_time(c.oid) + AS last_autoanalyze, + COALESCE(a.attname, ''), + n1.nspname AS schemaname_of_atttype, + t.typname, + a.atttypmod, + s.stainherit, + s.stanullfrac, + s.stawidth, + s.stadistinct, + s.stakind1, + s.stakind2, + s.stakind3, + s.stakind4, + s.stakind5, + s.staop1, + s.staop2, + s.staop3, + s.staop4, + s.staop5, + s.stacoll1, + s.stacoll2, + s.stacoll3, + s.stacoll4, + s.stacoll5, + s.stanumbers1, + s.stanumbers2, + s.stanumbers3, + s.stanumbers4, + s.stanumbers5, + s.stavalues1, + s.stavalues2, + s.stavalues3, + s.stavalues4, + s.stavalues5 + FROM pg_statistic s + JOIN pg_attribute a + ON (s.starelid = a.attrelid AND s.staattnum = a.attnum) + JOIN pg_type t + ON a.atttypid = t.oid + JOIN pg_namespace n1 + ON t.typnamespace = n1.oid + RIGHT JOIN pg_catalog.pg_class c + ON s.starelid = c.oid + JOIN pg_catalog.pg_namespace n2 + ON c.relnamespace = n2.oid + WHERE c.relkind IN ('r', 'i', 'f', 'm') + AND NOT n2.nspname IN ('pg_catalog', + 'pg_toast', + 'information_schema', + 'dbms_stats') + -- AND n2.nspname = 'public' + -- AND c.relname = 'test' + -- AND a.attname = 'id' + AND c.relname = 'st0' + ORDER BY starelid, staattnum) +TO STDOUT +(FORMAT 'binary'); +\o +COMMIT; +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; + 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 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------+------------+------------ + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) +(8 rows) + +TRUNCATE dbms_stats.work; +\! rm doc/export_plain_stats-12.sql.sample_test +-- No.16-1-3-1 Actual import test +select dbms_stats.import_database_stats('@abs_srcdir@/export_stats.dmp'); + import_database_stats +----------------------- + +(1 row) + +-- No.16-1-4 +\! sed '/ORDER/i\\ AND c.relname = '"\'pg_toast_1262\'" doc/export_plain_stats-12.sql.sample > doc/export_plain_stats-12.sql.sample_test +\i doc/export_plain_stats-12.sql.sample_test +/* + * If you want the statistics of per-relation or per-column, please modify + * nspname, relname, and attname in 'WHERE' clause. + */ +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE; +/* + * If you want to chage the output file name, please modify the following name. + */ +\o export_stats.dmp +COPY (SELECT n2.nspname, + c.relname, + c.relpages, + c.reltuples, + c.relallvisible, + (pg_relation_size(c.oid) / current_setting('block_size')::int4)::int4 + AS curpages, + pg_catalog.pg_stat_get_last_analyze_time(c.oid) + AS last_analyze, + pg_catalog.pg_stat_get_last_autoanalyze_time(c.oid) + AS last_autoanalyze, + COALESCE(a.attname, ''), + n1.nspname AS schemaname_of_atttype, + t.typname, + a.atttypmod, + s.stainherit, + s.stanullfrac, + s.stawidth, + s.stadistinct, + s.stakind1, + s.stakind2, + s.stakind3, + s.stakind4, + s.stakind5, + s.staop1, + s.staop2, + s.staop3, + s.staop4, + s.staop5, + s.stacoll1, + s.stacoll2, + s.stacoll3, + s.stacoll4, + s.stacoll5, + s.stanumbers1, + s.stanumbers2, + s.stanumbers3, + s.stanumbers4, + s.stanumbers5, + s.stavalues1, + s.stavalues2, + s.stavalues3, + s.stavalues4, + s.stavalues5 + FROM pg_statistic s + JOIN pg_attribute a + ON (s.starelid = a.attrelid AND s.staattnum = a.attnum) + JOIN pg_type t + ON a.atttypid = t.oid + JOIN pg_namespace n1 + ON t.typnamespace = n1.oid + RIGHT JOIN pg_catalog.pg_class c + ON s.starelid = c.oid + JOIN pg_catalog.pg_namespace n2 + ON c.relnamespace = n2.oid + WHERE c.relkind IN ('r', 'i', 'f', 'm') + AND NOT n2.nspname IN ('pg_catalog', + 'pg_toast', + 'information_schema', + 'dbms_stats') + -- AND n2.nspname = 'public' + -- AND c.relname = 'test' + -- AND a.attname = 'id' + AND c.relname = 'pg_toast_1262' + ORDER BY starelid, staattnum) +TO STDOUT +(FORMAT 'binary'); +\o +COMMIT; +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; + 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 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ +(0 rows) + +TRUNCATE dbms_stats.work; +\! rm doc/export_plain_stats-12.sql.sample_test +-- No.16-1-5 +\! sed '/ORDER/i\\ AND c.relname = '"\'st0_idx\'" doc/export_plain_stats-12.sql.sample > doc/export_plain_stats-12.sql.sample_test +\i doc/export_plain_stats-12.sql.sample_test +/* + * If you want the statistics of per-relation or per-column, please modify + * nspname, relname, and attname in 'WHERE' clause. + */ +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE; +/* + * If you want to chage the output file name, please modify the following name. + */ +\o export_stats.dmp +COPY (SELECT n2.nspname, + c.relname, + c.relpages, + c.reltuples, + c.relallvisible, + (pg_relation_size(c.oid) / current_setting('block_size')::int4)::int4 + AS curpages, + pg_catalog.pg_stat_get_last_analyze_time(c.oid) + AS last_analyze, + pg_catalog.pg_stat_get_last_autoanalyze_time(c.oid) + AS last_autoanalyze, + COALESCE(a.attname, ''), + n1.nspname AS schemaname_of_atttype, + t.typname, + a.atttypmod, + s.stainherit, + s.stanullfrac, + s.stawidth, + s.stadistinct, + s.stakind1, + s.stakind2, + s.stakind3, + s.stakind4, + s.stakind5, + s.staop1, + s.staop2, + s.staop3, + s.staop4, + s.staop5, + s.stacoll1, + s.stacoll2, + s.stacoll3, + s.stacoll4, + s.stacoll5, + s.stanumbers1, + s.stanumbers2, + s.stanumbers3, + s.stanumbers4, + s.stanumbers5, + s.stavalues1, + s.stavalues2, + s.stavalues3, + s.stavalues4, + s.stavalues5 + FROM pg_statistic s + JOIN pg_attribute a + ON (s.starelid = a.attrelid AND s.staattnum = a.attnum) + JOIN pg_type t + ON a.atttypid = t.oid + JOIN pg_namespace n1 + ON t.typnamespace = n1.oid + RIGHT JOIN pg_catalog.pg_class c + ON s.starelid = c.oid + JOIN pg_catalog.pg_namespace n2 + ON c.relnamespace = n2.oid + WHERE c.relkind IN ('r', 'i', 'f', 'm') + AND NOT n2.nspname IN ('pg_catalog', + 'pg_toast', + 'information_schema', + 'dbms_stats') + -- AND n2.nspname = 'public' + -- AND c.relname = 'test' + -- AND a.attname = 'id' + AND c.relname = 'st0_idx' + ORDER BY starelid, staattnum) +TO STDOUT +(FORMAT 'binary'); +\o +COMMIT; +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; + 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 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ + 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) + 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) +(2 rows) + +TRUNCATE dbms_stats.work; +\! rm doc/export_plain_stats-12.sql.sample_test +-- No.16-1-6 +\! sed '/ORDER/i\\ AND c.relname = '"\'ss0\'" doc/export_plain_stats-12.sql.sample > doc/export_plain_stats-12.sql.sample_test +\i doc/export_plain_stats-12.sql.sample_test +/* + * If you want the statistics of per-relation or per-column, please modify + * nspname, relname, and attname in 'WHERE' clause. + */ +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE; +/* + * If you want to chage the output file name, please modify the following name. + */ +\o export_stats.dmp +COPY (SELECT n2.nspname, + c.relname, + c.relpages, + c.reltuples, + c.relallvisible, + (pg_relation_size(c.oid) / current_setting('block_size')::int4)::int4 + AS curpages, + pg_catalog.pg_stat_get_last_analyze_time(c.oid) + AS last_analyze, + pg_catalog.pg_stat_get_last_autoanalyze_time(c.oid) + AS last_autoanalyze, + COALESCE(a.attname, ''), + n1.nspname AS schemaname_of_atttype, + t.typname, + a.atttypmod, + s.stainherit, + s.stanullfrac, + s.stawidth, + s.stadistinct, + s.stakind1, + s.stakind2, + s.stakind3, + s.stakind4, + s.stakind5, + s.staop1, + s.staop2, + s.staop3, + s.staop4, + s.staop5, + s.stacoll1, + s.stacoll2, + s.stacoll3, + s.stacoll4, + s.stacoll5, + s.stanumbers1, + s.stanumbers2, + s.stanumbers3, + s.stanumbers4, + s.stanumbers5, + s.stavalues1, + s.stavalues2, + s.stavalues3, + s.stavalues4, + s.stavalues5 + FROM pg_statistic s + JOIN pg_attribute a + ON (s.starelid = a.attrelid AND s.staattnum = a.attnum) + JOIN pg_type t + ON a.atttypid = t.oid + JOIN pg_namespace n1 + ON t.typnamespace = n1.oid + RIGHT JOIN pg_catalog.pg_class c + ON s.starelid = c.oid + JOIN pg_catalog.pg_namespace n2 + ON c.relnamespace = n2.oid + WHERE c.relkind IN ('r', 'i', 'f', 'm') + AND NOT n2.nspname IN ('pg_catalog', + 'pg_toast', + 'information_schema', + 'dbms_stats') + -- AND n2.nspname = 'public' + -- AND c.relname = 'test' + -- AND a.attname = 'id' + AND c.relname = 'ss0' + ORDER BY starelid, staattnum) +TO STDOUT +(FORMAT 'binary'); +\o +COMMIT; +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; + 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 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ +(0 rows) + +TRUNCATE dbms_stats.work; +\! rm doc/export_plain_stats-12.sql.sample_test +-- No.16-1-7 +\! sed '/ORDER/i\\ AND c.relname = '"\'sc0\'" doc/export_plain_stats-12.sql.sample > doc/export_plain_stats-12.sql.sample_test +\i doc/export_plain_stats-12.sql.sample_test +/* + * If you want the statistics of per-relation or per-column, please modify + * nspname, relname, and attname in 'WHERE' clause. + */ +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE; +/* + * If you want to chage the output file name, please modify the following name. + */ +\o export_stats.dmp +COPY (SELECT n2.nspname, + c.relname, + c.relpages, + c.reltuples, + c.relallvisible, + (pg_relation_size(c.oid) / current_setting('block_size')::int4)::int4 + AS curpages, + pg_catalog.pg_stat_get_last_analyze_time(c.oid) + AS last_analyze, + pg_catalog.pg_stat_get_last_autoanalyze_time(c.oid) + AS last_autoanalyze, + COALESCE(a.attname, ''), + n1.nspname AS schemaname_of_atttype, + t.typname, + a.atttypmod, + s.stainherit, + s.stanullfrac, + s.stawidth, + s.stadistinct, + s.stakind1, + s.stakind2, + s.stakind3, + s.stakind4, + s.stakind5, + s.staop1, + s.staop2, + s.staop3, + s.staop4, + s.staop5, + s.stacoll1, + s.stacoll2, + s.stacoll3, + s.stacoll4, + s.stacoll5, + s.stanumbers1, + s.stanumbers2, + s.stanumbers3, + s.stanumbers4, + s.stanumbers5, + s.stavalues1, + s.stavalues2, + s.stavalues3, + s.stavalues4, + s.stavalues5 + FROM pg_statistic s + JOIN pg_attribute a + ON (s.starelid = a.attrelid AND s.staattnum = a.attnum) + JOIN pg_type t + ON a.atttypid = t.oid + JOIN pg_namespace n1 + ON t.typnamespace = n1.oid + RIGHT JOIN pg_catalog.pg_class c + ON s.starelid = c.oid + JOIN pg_catalog.pg_namespace n2 + ON c.relnamespace = n2.oid + WHERE c.relkind IN ('r', 'i', 'f', 'm') + AND NOT n2.nspname IN ('pg_catalog', + 'pg_toast', + 'information_schema', + 'dbms_stats') + -- AND n2.nspname = 'public' + -- AND c.relname = 'test' + -- AND a.attname = 'id' + AND c.relname = 'sc0' + ORDER BY starelid, staattnum) +TO STDOUT +(FORMAT 'binary'); +\o +COMMIT; +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; + 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 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ +(0 rows) + +TRUNCATE dbms_stats.work; +\! rm doc/export_plain_stats-12.sql.sample_test +-- No.16-1-8 +\! sed '/ORDER/i\\ AND c.relname = '"\'sft0\'" doc/export_plain_stats-12.sql.sample > doc/export_plain_stats-12.sql.sample_test +\i doc/export_plain_stats-12.sql.sample_test +/* + * If you want the statistics of per-relation or per-column, please modify + * nspname, relname, and attname in 'WHERE' clause. + */ +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE; +/* + * If you want to chage the output file name, please modify the following name. + */ +\o export_stats.dmp +COPY (SELECT n2.nspname, + c.relname, + c.relpages, + c.reltuples, + c.relallvisible, + (pg_relation_size(c.oid) / current_setting('block_size')::int4)::int4 + AS curpages, + pg_catalog.pg_stat_get_last_analyze_time(c.oid) + AS last_analyze, + pg_catalog.pg_stat_get_last_autoanalyze_time(c.oid) + AS last_autoanalyze, + COALESCE(a.attname, ''), + n1.nspname AS schemaname_of_atttype, + t.typname, + a.atttypmod, + s.stainherit, + s.stanullfrac, + s.stawidth, + s.stadistinct, + s.stakind1, + s.stakind2, + s.stakind3, + s.stakind4, + s.stakind5, + s.staop1, + s.staop2, + s.staop3, + s.staop4, + s.staop5, + s.stacoll1, + s.stacoll2, + s.stacoll3, + s.stacoll4, + s.stacoll5, + s.stanumbers1, + s.stanumbers2, + s.stanumbers3, + s.stanumbers4, + s.stanumbers5, + s.stavalues1, + s.stavalues2, + s.stavalues3, + s.stavalues4, + s.stavalues5 + FROM pg_statistic s + JOIN pg_attribute a + ON (s.starelid = a.attrelid AND s.staattnum = a.attnum) + JOIN pg_type t + ON a.atttypid = t.oid + JOIN pg_namespace n1 + ON t.typnamespace = n1.oid + RIGHT JOIN pg_catalog.pg_class c + ON s.starelid = c.oid + JOIN pg_catalog.pg_namespace n2 + ON c.relnamespace = n2.oid + WHERE c.relkind IN ('r', 'i', 'f', 'm') + AND NOT n2.nspname IN ('pg_catalog', + 'pg_toast', + 'information_schema', + 'dbms_stats') + -- AND n2.nspname = 'public' + -- AND c.relname = 'test' + -- AND a.attname = 'id' + AND c.relname = 'sft0' + ORDER BY starelid, staattnum) +TO STDOUT +(FORMAT 'binary'); +\o +COMMIT; +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; + 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 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------------+------------+------------+------------+------------ + 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) +(1 row) + +TRUNCATE dbms_stats.work; +\! rm doc/export_plain_stats-12.sql.sample_test +-- No.16-1-9 +\! sed '/ORDER/i\\ AND c.relname = '"\'smv0\'" doc/export_plain_stats-12.sql.sample > doc/export_plain_stats-12.sql.sample_test +\i doc/export_plain_stats-12.sql.sample_test +/* + * If you want the statistics of per-relation or per-column, please modify + * nspname, relname, and attname in 'WHERE' clause. + */ +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE; +/* + * If you want to chage the output file name, please modify the following name. + */ +\o export_stats.dmp +COPY (SELECT n2.nspname, + c.relname, + c.relpages, + c.reltuples, + c.relallvisible, + (pg_relation_size(c.oid) / current_setting('block_size')::int4)::int4 + AS curpages, + pg_catalog.pg_stat_get_last_analyze_time(c.oid) + AS last_analyze, + pg_catalog.pg_stat_get_last_autoanalyze_time(c.oid) + AS last_autoanalyze, + COALESCE(a.attname, ''), + n1.nspname AS schemaname_of_atttype, + t.typname, + a.atttypmod, + s.stainherit, + s.stanullfrac, + s.stawidth, + s.stadistinct, + s.stakind1, + s.stakind2, + s.stakind3, + s.stakind4, + s.stakind5, + s.staop1, + s.staop2, + s.staop3, + s.staop4, + s.staop5, + s.stacoll1, + s.stacoll2, + s.stacoll3, + s.stacoll4, + s.stacoll5, + s.stanumbers1, + s.stanumbers2, + s.stanumbers3, + s.stanumbers4, + s.stanumbers5, + s.stavalues1, + s.stavalues2, + s.stavalues3, + s.stavalues4, + s.stavalues5 + FROM pg_statistic s + JOIN pg_attribute a + ON (s.starelid = a.attrelid AND s.staattnum = a.attnum) + JOIN pg_type t + ON a.atttypid = t.oid + JOIN pg_namespace n1 + ON t.typnamespace = n1.oid + RIGHT JOIN pg_catalog.pg_class c + ON s.starelid = c.oid + JOIN pg_catalog.pg_namespace n2 + ON c.relnamespace = n2.oid + WHERE c.relkind IN ('r', 'i', 'f', 'm') + AND NOT n2.nspname IN ('pg_catalog', + 'pg_toast', + 'information_schema', + 'dbms_stats') + -- AND n2.nspname = 'public' + -- AND c.relname = 'test' + -- AND a.attname = 'id' + AND c.relname = 'smv0' + ORDER BY starelid, staattnum) +TO STDOUT +(FORMAT 'binary'); +\o +COMMIT; +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; + 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 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ + 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) + 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) + 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) +(3 rows) + +TRUNCATE dbms_stats.work; +\! rm doc/export_plain_stats-12.sql.sample_test +-- No.16-1-10 +\! 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 +\i doc/export_plain_stats-12.sql.sample_test +/* + * If you want the statistics of per-relation or per-column, please modify + * nspname, relname, and attname in 'WHERE' clause. + */ +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE; +/* + * If you want to chage the output file name, please modify the following name. + */ +\o export_stats.dmp +COPY (SELECT n2.nspname, + c.relname, + c.relpages, + c.reltuples, + c.relallvisible, + (pg_relation_size(c.oid) / current_setting('block_size')::int4)::int4 + AS curpages, + pg_catalog.pg_stat_get_last_analyze_time(c.oid) + AS last_analyze, + pg_catalog.pg_stat_get_last_autoanalyze_time(c.oid) + AS last_autoanalyze, + COALESCE(a.attname, ''), + n1.nspname AS schemaname_of_atttype, + t.typname, + a.atttypmod, + s.stainherit, + s.stanullfrac, + s.stawidth, + s.stadistinct, + s.stakind1, + s.stakind2, + s.stakind3, + s.stakind4, + s.stakind5, + s.staop1, + s.staop2, + s.staop3, + s.staop4, + s.staop5, + s.stacoll1, + s.stacoll2, + s.stacoll3, + s.stacoll4, + s.stacoll5, + s.stanumbers1, + s.stanumbers2, + s.stanumbers3, + s.stanumbers4, + s.stanumbers5, + s.stavalues1, + s.stavalues2, + s.stavalues3, + s.stavalues4, + s.stavalues5 + FROM pg_statistic s + JOIN pg_attribute a + ON (s.starelid = a.attrelid AND s.staattnum = a.attnum) + JOIN pg_type t + ON a.atttypid = t.oid + JOIN pg_namespace n1 + ON t.typnamespace = n1.oid + RIGHT JOIN pg_catalog.pg_class c + ON s.starelid = c.oid + JOIN pg_catalog.pg_namespace n2 + ON c.relnamespace = n2.oid + WHERE c.relkind IN ('r', 'i', 'f', 'm') + AND NOT n2.nspname IN ('pg_catalog', + 'pg_toast', + 'information_schema', + 'dbms_stats') + -- AND n2.nspname = 'public' + -- AND c.relname = 'test' + -- AND a.attname = 'id' + AND n2.nspname = 's0' AND a.attname = 'id' + ORDER BY starelid, staattnum) +TO STDOUT +(FORMAT 'binary'); +\o +COMMIT; +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; + 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 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------------+------------+------------+------------+------------ + 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) + 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) + 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) + 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) + 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) + 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) +(6 rows) + +TRUNCATE dbms_stats.work; +\! rm doc/export_plain_stats-12.sql.sample_test +-- No.16-1-11 +\! 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 +\i doc/export_plain_stats-12.sql.sample_test +/* + * If you want the statistics of per-relation or per-column, please modify + * nspname, relname, and attname in 'WHERE' clause. + */ +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE; +/* + * If you want to chage the output file name, please modify the following name. + */ +\o export_stats.dmp +COPY (SELECT n2.nspname, + c.relname, + c.relpages, + c.reltuples, + c.relallvisible, + (pg_relation_size(c.oid) / current_setting('block_size')::int4)::int4 + AS curpages, + pg_catalog.pg_stat_get_last_analyze_time(c.oid) + AS last_analyze, + pg_catalog.pg_stat_get_last_autoanalyze_time(c.oid) + AS last_autoanalyze, + COALESCE(a.attname, ''), + n1.nspname AS schemaname_of_atttype, + t.typname, + a.atttypmod, + s.stainherit, + s.stanullfrac, + s.stawidth, + s.stadistinct, + s.stakind1, + s.stakind2, + s.stakind3, + s.stakind4, + s.stakind5, + s.staop1, + s.staop2, + s.staop3, + s.staop4, + s.staop5, + s.stacoll1, + s.stacoll2, + s.stacoll3, + s.stacoll4, + s.stacoll5, + s.stanumbers1, + s.stanumbers2, + s.stanumbers3, + s.stanumbers4, + s.stanumbers5, + s.stavalues1, + s.stavalues2, + s.stavalues3, + s.stavalues4, + s.stavalues5 + FROM pg_statistic s + JOIN pg_attribute a + ON (s.starelid = a.attrelid AND s.staattnum = a.attnum) + JOIN pg_type t + ON a.atttypid = t.oid + JOIN pg_namespace n1 + ON t.typnamespace = n1.oid + RIGHT JOIN pg_catalog.pg_class c + ON s.starelid = c.oid + JOIN pg_catalog.pg_namespace n2 + ON c.relnamespace = n2.oid + WHERE c.relkind IN ('r', 'i', 'f', 'm') + AND NOT n2.nspname IN ('pg_catalog', + 'pg_toast', + 'information_schema', + 'dbms_stats') + -- AND n2.nspname = 'public' + -- AND c.relname = 'test' + -- AND a.attname = 'id' + AND n2.nspname = 's0' AND a.attname IS NULL + ORDER BY starelid, staattnum) +TO STDOUT +(FORMAT 'binary'); +\o +COMMIT; +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; + 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 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ + 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) + 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) + 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) + 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) +(4 rows) + +TRUNCATE dbms_stats.work; +\! rm doc/export_plain_stats-12.sql.sample_test +-- No.16-1-12 +\! 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 +\i doc/export_plain_stats-12.sql.sample_test +/* + * If you want the statistics of per-relation or per-column, please modify + * nspname, relname, and attname in 'WHERE' clause. + */ +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE; +/* + * If you want to chage the output file name, please modify the following name. + */ +\o export_stats.dmp +COPY (SELECT n2.nspname, + c.relname, + c.relpages, + c.reltuples, + c.relallvisible, + (pg_relation_size(c.oid) / current_setting('block_size')::int4)::int4 + AS curpages, + pg_catalog.pg_stat_get_last_analyze_time(c.oid) + AS last_analyze, + pg_catalog.pg_stat_get_last_autoanalyze_time(c.oid) + AS last_autoanalyze, + COALESCE(a.attname, ''), + n1.nspname AS schemaname_of_atttype, + t.typname, + a.atttypmod, + s.stainherit, + s.stanullfrac, + s.stawidth, + s.stadistinct, + s.stakind1, + s.stakind2, + s.stakind3, + s.stakind4, + s.stakind5, + s.staop1, + s.staop2, + s.staop3, + s.staop4, + s.staop5, + s.stacoll1, + s.stacoll2, + s.stacoll3, + s.stacoll4, + s.stacoll5, + s.stanumbers1, + s.stanumbers2, + s.stanumbers3, + s.stanumbers4, + s.stanumbers5, + s.stavalues1, + s.stavalues2, + s.stavalues3, + s.stavalues4, + s.stavalues5 + FROM pg_statistic s + JOIN pg_attribute a + ON (s.starelid = a.attrelid AND s.staattnum = a.attnum) + JOIN pg_type t + ON a.atttypid = t.oid + JOIN pg_namespace n1 + ON t.typnamespace = n1.oid + RIGHT JOIN pg_catalog.pg_class c + ON s.starelid = c.oid + JOIN pg_catalog.pg_namespace n2 + ON c.relnamespace = n2.oid + WHERE c.relkind IN ('r', 'i', 'f', 'm') + AND NOT n2.nspname IN ('pg_catalog', + 'pg_toast', + 'information_schema', + 'dbms_stats') + -- AND n2.nspname = 'public' + -- AND c.relname = 'test' + -- AND a.attname = 'id' + AND n2.nspname = 's1' AND c.relname IS NULL + ORDER BY starelid, staattnum) +TO STDOUT +(FORMAT 'binary'); +\o +COMMIT; +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; + 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 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ +(0 rows) + +TRUNCATE dbms_stats.work; +\! rm doc/export_plain_stats-12.sql.sample_test +/* + * No.16-2 export_effective_stats-12.sql.sample + */ +-- No.16-2-1 +VACUUM ANALYZE; +SELECT dbms_stats.lock_database_stats(); + lock_database_stats +--------------------- + pt0 + pt0_idx + st0 + st0_idx + st1 + s0.st0 + s0.st0_idx + s0.st1 + s0.st1_idx + s0.st2 + s0.st2_idx + st1_idx + st1_exp + s0.sft0 + s0.smv0 + s1.st0 + s0.st3 +(17 rows) + +UPDATE dbms_stats.relation_stats_locked + SET (relpages, reltuples, relallvisible, curpages) = (NULL, NULL, NULL, NULL); +UPDATE dbms_stats.column_stats_locked + SET (stanullfrac, stawidth, stadistinct, + stakind1, stakind2, stakind3, stakind4, stakind5, + staop1, staop2, staop3, staop4, staop5, + stanumbers1, stanumbers2, stanumbers3, stanumbers4, stanumbers5, + stavalues1, stavalues2, stavalues3, stavalues4, stavalues5) + = (NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL) + WHERE starelid = 's0.st0'::regclass; +\i doc/export_effective_stats-12.sql.sample +/* + * If you want the statistics of per-relation or per-column, please modify + * nspname, relname, and attname in 'WHERE' clause. + */ +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE; +/* + * If you want to chage the output file name, please modify the following name. + */ +\o export_stats.dmp +COPY (SELECT n2.nspname, + cl.relname, + r.relpages, + r.reltuples, + r.relallvisible, + r.curpages, + r.last_analyze, + r.last_autoanalyze, + COALESCE(a.attname, ''), + n1.nspname AS schemaname_of_atttype, + t.typname, + a.atttypmod, + co.stainherit, + co.stanullfrac, + co.stawidth, + co.stadistinct, + co.stakind1, + co.stakind2, + co.stakind3, + co.stakind4, + co.stakind5, + co.staop1, + co.staop2, + co.staop3, + co.staop4, + co.staop5, + co.stacoll1, + co.stacoll2, + co.stacoll3, + co.stacoll4, + co.stacoll5, + co.stanumbers1, + co.stanumbers2, + co.stanumbers3, + co.stanumbers4, + co.stanumbers5, + co.stavalues1, + co.stavalues2, + co.stavalues3, + co.stavalues4, + co.stavalues5 + FROM dbms_stats.column_stats_effective co + JOIN pg_attribute a + ON (co.starelid = a.attrelid AND co.staattnum = a.attnum) + JOIN pg_type t + ON a.atttypid = t.oid + JOIN pg_namespace n1 + ON t.typnamespace = n1.oid + RIGHT JOIN dbms_stats.relation_stats_effective r + ON co.starelid = r.relid + JOIN pg_catalog.pg_class cl + ON r.relid = cl.oid + JOIN pg_catalog.pg_namespace n2 + ON cl.relnamespace = n2.oid + -- WHERE n2.nspname = 'public' + -- AND cl.relname = 'test' + -- AND a.attname = 'id' + ORDER BY starelid, staattnum) +TO STDOUT +(FORMAT 'binary'); +\o +COMMIT; +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; + 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 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------------------+------------+------------ + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) +(27 rows) + +TRUNCATE dbms_stats.work; +-- No.16-2-2 +\! sed '/ORDER/i\\ WHERE n2.nspname = '"\'s0\'" doc/export_effective_stats-12.sql.sample > doc/export_effective_stats-12.sql.sample_test +\i doc/export_effective_stats-12.sql.sample_test +/* + * If you want the statistics of per-relation or per-column, please modify + * nspname, relname, and attname in 'WHERE' clause. + */ +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE; +/* + * If you want to chage the output file name, please modify the following name. + */ +\o export_stats.dmp +COPY (SELECT n2.nspname, + cl.relname, + r.relpages, + r.reltuples, + r.relallvisible, + r.curpages, + r.last_analyze, + r.last_autoanalyze, + COALESCE(a.attname, ''), + n1.nspname AS schemaname_of_atttype, + t.typname, + a.atttypmod, + co.stainherit, + co.stanullfrac, + co.stawidth, + co.stadistinct, + co.stakind1, + co.stakind2, + co.stakind3, + co.stakind4, + co.stakind5, + co.staop1, + co.staop2, + co.staop3, + co.staop4, + co.staop5, + co.stacoll1, + co.stacoll2, + co.stacoll3, + co.stacoll4, + co.stacoll5, + co.stanumbers1, + co.stanumbers2, + co.stanumbers3, + co.stanumbers4, + co.stanumbers5, + co.stavalues1, + co.stavalues2, + co.stavalues3, + co.stavalues4, + co.stavalues5 + FROM dbms_stats.column_stats_effective co + JOIN pg_attribute a + ON (co.starelid = a.attrelid AND co.staattnum = a.attnum) + JOIN pg_type t + ON a.atttypid = t.oid + JOIN pg_namespace n1 + ON t.typnamespace = n1.oid + RIGHT JOIN dbms_stats.relation_stats_effective r + ON co.starelid = r.relid + JOIN pg_catalog.pg_class cl + ON r.relid = cl.oid + JOIN pg_catalog.pg_namespace n2 + ON cl.relnamespace = n2.oid + -- WHERE n2.nspname = 'public' + -- AND cl.relname = 'test' + -- AND a.attname = 'id' + WHERE n2.nspname = 's0' + ORDER BY starelid, staattnum) +TO STDOUT +(FORMAT 'binary'); +\o +COMMIT; +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; + 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 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------------------+------------+------------ + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) +(16 rows) + +\! rm doc/export_effective_stats-12.sql.sample_test +TRUNCATE dbms_stats.work; +-- No.16-2-3 +\! sed '/ORDER/i\\ WHERE cl.relname = '"\'st0\'" doc/export_effective_stats-12.sql.sample > doc/export_effective_stats-12.sql.sample_test +\i doc/export_effective_stats-12.sql.sample_test +/* + * If you want the statistics of per-relation or per-column, please modify + * nspname, relname, and attname in 'WHERE' clause. + */ +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE; +/* + * If you want to chage the output file name, please modify the following name. + */ +\o export_stats.dmp +COPY (SELECT n2.nspname, + cl.relname, + r.relpages, + r.reltuples, + r.relallvisible, + r.curpages, + r.last_analyze, + r.last_autoanalyze, + COALESCE(a.attname, ''), + n1.nspname AS schemaname_of_atttype, + t.typname, + a.atttypmod, + co.stainherit, + co.stanullfrac, + co.stawidth, + co.stadistinct, + co.stakind1, + co.stakind2, + co.stakind3, + co.stakind4, + co.stakind5, + co.staop1, + co.staop2, + co.staop3, + co.staop4, + co.staop5, + co.stacoll1, + co.stacoll2, + co.stacoll3, + co.stacoll4, + co.stacoll5, + co.stanumbers1, + co.stanumbers2, + co.stanumbers3, + co.stanumbers4, + co.stanumbers5, + co.stavalues1, + co.stavalues2, + co.stavalues3, + co.stavalues4, + co.stavalues5 + FROM dbms_stats.column_stats_effective co + JOIN pg_attribute a + ON (co.starelid = a.attrelid AND co.staattnum = a.attnum) + JOIN pg_type t + ON a.atttypid = t.oid + JOIN pg_namespace n1 + ON t.typnamespace = n1.oid + RIGHT JOIN dbms_stats.relation_stats_effective r + ON co.starelid = r.relid + JOIN pg_catalog.pg_class cl + ON r.relid = cl.oid + JOIN pg_catalog.pg_namespace n2 + ON cl.relnamespace = n2.oid + -- WHERE n2.nspname = 'public' + -- AND cl.relname = 'test' + -- AND a.attname = 'id' + WHERE cl.relname = 'st0' + ORDER BY starelid, staattnum) +TO STDOUT +(FORMAT 'binary'); +\o +COMMIT; +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; + 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 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------+------------+------------ + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) +(8 rows) + +\! rm doc/export_effective_stats-12.sql.sample_test +TRUNCATE dbms_stats.work; +-- No.16-2-4 +\! sed '/ORDER/i\\ WHERE cl.relname = '"\'pg_toast_1262\'" doc/export_effective_stats-12.sql.sample > doc/export_effective_stats-12.sql.sample_test +\i doc/export_effective_stats-12.sql.sample_test +/* + * If you want the statistics of per-relation or per-column, please modify + * nspname, relname, and attname in 'WHERE' clause. + */ +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE; +/* + * If you want to chage the output file name, please modify the following name. + */ +\o export_stats.dmp +COPY (SELECT n2.nspname, + cl.relname, + r.relpages, + r.reltuples, + r.relallvisible, + r.curpages, + r.last_analyze, + r.last_autoanalyze, + COALESCE(a.attname, ''), + n1.nspname AS schemaname_of_atttype, + t.typname, + a.atttypmod, + co.stainherit, + co.stanullfrac, + co.stawidth, + co.stadistinct, + co.stakind1, + co.stakind2, + co.stakind3, + co.stakind4, + co.stakind5, + co.staop1, + co.staop2, + co.staop3, + co.staop4, + co.staop5, + co.stacoll1, + co.stacoll2, + co.stacoll3, + co.stacoll4, + co.stacoll5, + co.stanumbers1, + co.stanumbers2, + co.stanumbers3, + co.stanumbers4, + co.stanumbers5, + co.stavalues1, + co.stavalues2, + co.stavalues3, + co.stavalues4, + co.stavalues5 + FROM dbms_stats.column_stats_effective co + JOIN pg_attribute a + ON (co.starelid = a.attrelid AND co.staattnum = a.attnum) + JOIN pg_type t + ON a.atttypid = t.oid + JOIN pg_namespace n1 + ON t.typnamespace = n1.oid + RIGHT JOIN dbms_stats.relation_stats_effective r + ON co.starelid = r.relid + JOIN pg_catalog.pg_class cl + ON r.relid = cl.oid + JOIN pg_catalog.pg_namespace n2 + ON cl.relnamespace = n2.oid + -- WHERE n2.nspname = 'public' + -- AND cl.relname = 'test' + -- AND a.attname = 'id' + WHERE cl.relname = 'pg_toast_1262' + ORDER BY starelid, staattnum) +TO STDOUT +(FORMAT 'binary'); +\o +COMMIT; +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; + 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 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ +(0 rows) + +\! rm doc/export_effective_stats-12.sql.sample_test +TRUNCATE dbms_stats.work; +-- No.16-2-5 +\! sed '/ORDER/i\\ WHERE cl.relname = '"\'st0_idx\'" doc/export_effective_stats-12.sql.sample > doc/export_effective_stats-12.sql.sample_test +\i doc/export_effective_stats-12.sql.sample_test +/* + * If you want the statistics of per-relation or per-column, please modify + * nspname, relname, and attname in 'WHERE' clause. + */ +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE; +/* + * If you want to chage the output file name, please modify the following name. + */ +\o export_stats.dmp +COPY (SELECT n2.nspname, + cl.relname, + r.relpages, + r.reltuples, + r.relallvisible, + r.curpages, + r.last_analyze, + r.last_autoanalyze, + COALESCE(a.attname, ''), + n1.nspname AS schemaname_of_atttype, + t.typname, + a.atttypmod, + co.stainherit, + co.stanullfrac, + co.stawidth, + co.stadistinct, + co.stakind1, + co.stakind2, + co.stakind3, + co.stakind4, + co.stakind5, + co.staop1, + co.staop2, + co.staop3, + co.staop4, + co.staop5, + co.stacoll1, + co.stacoll2, + co.stacoll3, + co.stacoll4, + co.stacoll5, + co.stanumbers1, + co.stanumbers2, + co.stanumbers3, + co.stanumbers4, + co.stanumbers5, + co.stavalues1, + co.stavalues2, + co.stavalues3, + co.stavalues4, + co.stavalues5 + FROM dbms_stats.column_stats_effective co + JOIN pg_attribute a + ON (co.starelid = a.attrelid AND co.staattnum = a.attnum) + JOIN pg_type t + ON a.atttypid = t.oid + JOIN pg_namespace n1 + ON t.typnamespace = n1.oid + RIGHT JOIN dbms_stats.relation_stats_effective r + ON co.starelid = r.relid + JOIN pg_catalog.pg_class cl + ON r.relid = cl.oid + JOIN pg_catalog.pg_namespace n2 + ON cl.relnamespace = n2.oid + -- WHERE n2.nspname = 'public' + -- AND cl.relname = 'test' + -- AND a.attname = 'id' + WHERE cl.relname = 'st0_idx' + ORDER BY starelid, staattnum) +TO STDOUT +(FORMAT 'binary'); +\o +COMMIT; +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; + 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 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ + 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) + 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) +(2 rows) + +\! rm doc/export_effective_stats-12.sql.sample_test +TRUNCATE dbms_stats.work; +-- No.16-2-6 +\! sed '/ORDER/i\\ WHERE cl.relname = '"\'ss0\'" doc/export_effective_stats-12.sql.sample > doc/export_effective_stats-12.sql.sample_test +\i doc/export_effective_stats-12.sql.sample_test +/* + * If you want the statistics of per-relation or per-column, please modify + * nspname, relname, and attname in 'WHERE' clause. + */ +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE; +/* + * If you want to chage the output file name, please modify the following name. + */ +\o export_stats.dmp +COPY (SELECT n2.nspname, + cl.relname, + r.relpages, + r.reltuples, + r.relallvisible, + r.curpages, + r.last_analyze, + r.last_autoanalyze, + COALESCE(a.attname, ''), + n1.nspname AS schemaname_of_atttype, + t.typname, + a.atttypmod, + co.stainherit, + co.stanullfrac, + co.stawidth, + co.stadistinct, + co.stakind1, + co.stakind2, + co.stakind3, + co.stakind4, + co.stakind5, + co.staop1, + co.staop2, + co.staop3, + co.staop4, + co.staop5, + co.stacoll1, + co.stacoll2, + co.stacoll3, + co.stacoll4, + co.stacoll5, + co.stanumbers1, + co.stanumbers2, + co.stanumbers3, + co.stanumbers4, + co.stanumbers5, + co.stavalues1, + co.stavalues2, + co.stavalues3, + co.stavalues4, + co.stavalues5 + FROM dbms_stats.column_stats_effective co + JOIN pg_attribute a + ON (co.starelid = a.attrelid AND co.staattnum = a.attnum) + JOIN pg_type t + ON a.atttypid = t.oid + JOIN pg_namespace n1 + ON t.typnamespace = n1.oid + RIGHT JOIN dbms_stats.relation_stats_effective r + ON co.starelid = r.relid + JOIN pg_catalog.pg_class cl + ON r.relid = cl.oid + JOIN pg_catalog.pg_namespace n2 + ON cl.relnamespace = n2.oid + -- WHERE n2.nspname = 'public' + -- AND cl.relname = 'test' + -- AND a.attname = 'id' + WHERE cl.relname = 'ss0' + ORDER BY starelid, staattnum) +TO STDOUT +(FORMAT 'binary'); +\o +COMMIT; +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; + 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 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ +(0 rows) + +\! rm doc/export_effective_stats-12.sql.sample_test +TRUNCATE dbms_stats.work; +-- No.16-2-7 +\! sed '/ORDER/i\\ WHERE cl.relname = '"\'sc0\'" doc/export_effective_stats-12.sql.sample > doc/export_effective_stats-12.sql.sample_test +\i doc/export_effective_stats-12.sql.sample_test +/* + * If you want the statistics of per-relation or per-column, please modify + * nspname, relname, and attname in 'WHERE' clause. + */ +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE; +/* + * If you want to chage the output file name, please modify the following name. + */ +\o export_stats.dmp +COPY (SELECT n2.nspname, + cl.relname, + r.relpages, + r.reltuples, + r.relallvisible, + r.curpages, + r.last_analyze, + r.last_autoanalyze, + COALESCE(a.attname, ''), + n1.nspname AS schemaname_of_atttype, + t.typname, + a.atttypmod, + co.stainherit, + co.stanullfrac, + co.stawidth, + co.stadistinct, + co.stakind1, + co.stakind2, + co.stakind3, + co.stakind4, + co.stakind5, + co.staop1, + co.staop2, + co.staop3, + co.staop4, + co.staop5, + co.stacoll1, + co.stacoll2, + co.stacoll3, + co.stacoll4, + co.stacoll5, + co.stanumbers1, + co.stanumbers2, + co.stanumbers3, + co.stanumbers4, + co.stanumbers5, + co.stavalues1, + co.stavalues2, + co.stavalues3, + co.stavalues4, + co.stavalues5 + FROM dbms_stats.column_stats_effective co + JOIN pg_attribute a + ON (co.starelid = a.attrelid AND co.staattnum = a.attnum) + JOIN pg_type t + ON a.atttypid = t.oid + JOIN pg_namespace n1 + ON t.typnamespace = n1.oid + RIGHT JOIN dbms_stats.relation_stats_effective r + ON co.starelid = r.relid + JOIN pg_catalog.pg_class cl + ON r.relid = cl.oid + JOIN pg_catalog.pg_namespace n2 + ON cl.relnamespace = n2.oid + -- WHERE n2.nspname = 'public' + -- AND cl.relname = 'test' + -- AND a.attname = 'id' + WHERE cl.relname = 'sc0' + ORDER BY starelid, staattnum) +TO STDOUT +(FORMAT 'binary'); +\o +COMMIT; +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; + 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 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ +(0 rows) + +\! rm doc/export_effective_stats-12.sql.sample_test +TRUNCATE dbms_stats.work; +-- No.16-2-8 +\! sed '/ORDER/i\\ WHERE cl.relname = '"\'sft0\'" doc/export_effective_stats-12.sql.sample > doc/export_effective_stats-12.sql.sample_test +\i doc/export_effective_stats-12.sql.sample_test +/* + * If you want the statistics of per-relation or per-column, please modify + * nspname, relname, and attname in 'WHERE' clause. + */ +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE; +/* + * If you want to chage the output file name, please modify the following name. + */ +\o export_stats.dmp +COPY (SELECT n2.nspname, + cl.relname, + r.relpages, + r.reltuples, + r.relallvisible, + r.curpages, + r.last_analyze, + r.last_autoanalyze, + COALESCE(a.attname, ''), + n1.nspname AS schemaname_of_atttype, + t.typname, + a.atttypmod, + co.stainherit, + co.stanullfrac, + co.stawidth, + co.stadistinct, + co.stakind1, + co.stakind2, + co.stakind3, + co.stakind4, + co.stakind5, + co.staop1, + co.staop2, + co.staop3, + co.staop4, + co.staop5, + co.stacoll1, + co.stacoll2, + co.stacoll3, + co.stacoll4, + co.stacoll5, + co.stanumbers1, + co.stanumbers2, + co.stanumbers3, + co.stanumbers4, + co.stanumbers5, + co.stavalues1, + co.stavalues2, + co.stavalues3, + co.stavalues4, + co.stavalues5 + FROM dbms_stats.column_stats_effective co + JOIN pg_attribute a + ON (co.starelid = a.attrelid AND co.staattnum = a.attnum) + JOIN pg_type t + ON a.atttypid = t.oid + JOIN pg_namespace n1 + ON t.typnamespace = n1.oid + RIGHT JOIN dbms_stats.relation_stats_effective r + ON co.starelid = r.relid + JOIN pg_catalog.pg_class cl + ON r.relid = cl.oid + JOIN pg_catalog.pg_namespace n2 + ON cl.relnamespace = n2.oid + -- WHERE n2.nspname = 'public' + -- AND cl.relname = 'test' + -- AND a.attname = 'id' + WHERE cl.relname = 'sft0' + ORDER BY starelid, staattnum) +TO STDOUT +(FORMAT 'binary'); +\o +COMMIT; +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; + 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 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------------------+------------+------------ + 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) +(1 row) + +\! rm doc/export_effective_stats-12.sql.sample_test +TRUNCATE dbms_stats.work; +-- No.16-2-9 +\! sed '/ORDER/i\\ WHERE cl.relname = '"\'smv0\'" doc/export_effective_stats-12.sql.sample > doc/export_effective_stats-12.sql.sample_test +\i doc/export_effective_stats-12.sql.sample_test +/* + * If you want the statistics of per-relation or per-column, please modify + * nspname, relname, and attname in 'WHERE' clause. + */ +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE; +/* + * If you want to chage the output file name, please modify the following name. + */ +\o export_stats.dmp +COPY (SELECT n2.nspname, + cl.relname, + r.relpages, + r.reltuples, + r.relallvisible, + r.curpages, + r.last_analyze, + r.last_autoanalyze, + COALESCE(a.attname, ''), + n1.nspname AS schemaname_of_atttype, + t.typname, + a.atttypmod, + co.stainherit, + co.stanullfrac, + co.stawidth, + co.stadistinct, + co.stakind1, + co.stakind2, + co.stakind3, + co.stakind4, + co.stakind5, + co.staop1, + co.staop2, + co.staop3, + co.staop4, + co.staop5, + co.stacoll1, + co.stacoll2, + co.stacoll3, + co.stacoll4, + co.stacoll5, + co.stanumbers1, + co.stanumbers2, + co.stanumbers3, + co.stanumbers4, + co.stanumbers5, + co.stavalues1, + co.stavalues2, + co.stavalues3, + co.stavalues4, + co.stavalues5 + FROM dbms_stats.column_stats_effective co + JOIN pg_attribute a + ON (co.starelid = a.attrelid AND co.staattnum = a.attnum) + JOIN pg_type t + ON a.atttypid = t.oid + JOIN pg_namespace n1 + ON t.typnamespace = n1.oid + RIGHT JOIN dbms_stats.relation_stats_effective r + ON co.starelid = r.relid + JOIN pg_catalog.pg_class cl + ON r.relid = cl.oid + JOIN pg_catalog.pg_namespace n2 + ON cl.relnamespace = n2.oid + -- WHERE n2.nspname = 'public' + -- AND cl.relname = 'test' + -- AND a.attname = 'id' + WHERE cl.relname = 'smv0' + ORDER BY starelid, staattnum) +TO STDOUT +(FORMAT 'binary'); +\o +COMMIT; +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; + 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 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ + 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) + 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) + 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) +(3 rows) + +\! rm doc/export_effective_stats-12.sql.sample_test +TRUNCATE dbms_stats.work; +-- No.16-2-10 +\! 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 +\i doc/export_effective_stats-12.sql.sample_test +/* + * If you want the statistics of per-relation or per-column, please modify + * nspname, relname, and attname in 'WHERE' clause. + */ +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE; +/* + * If you want to chage the output file name, please modify the following name. + */ +\o export_stats.dmp +COPY (SELECT n2.nspname, + cl.relname, + r.relpages, + r.reltuples, + r.relallvisible, + r.curpages, + r.last_analyze, + r.last_autoanalyze, + COALESCE(a.attname, ''), + n1.nspname AS schemaname_of_atttype, + t.typname, + a.atttypmod, + co.stainherit, + co.stanullfrac, + co.stawidth, + co.stadistinct, + co.stakind1, + co.stakind2, + co.stakind3, + co.stakind4, + co.stakind5, + co.staop1, + co.staop2, + co.staop3, + co.staop4, + co.staop5, + co.stacoll1, + co.stacoll2, + co.stacoll3, + co.stacoll4, + co.stacoll5, + co.stanumbers1, + co.stanumbers2, + co.stanumbers3, + co.stanumbers4, + co.stanumbers5, + co.stavalues1, + co.stavalues2, + co.stavalues3, + co.stavalues4, + co.stavalues5 + FROM dbms_stats.column_stats_effective co + JOIN pg_attribute a + ON (co.starelid = a.attrelid AND co.staattnum = a.attnum) + JOIN pg_type t + ON a.atttypid = t.oid + JOIN pg_namespace n1 + ON t.typnamespace = n1.oid + RIGHT JOIN dbms_stats.relation_stats_effective r + ON co.starelid = r.relid + JOIN pg_catalog.pg_class cl + ON r.relid = cl.oid + JOIN pg_catalog.pg_namespace n2 + ON cl.relnamespace = n2.oid + -- WHERE n2.nspname = 'public' + -- AND cl.relname = 'test' + -- AND a.attname = 'id' + WHERE n2.nspname = 's0' AND a.attname = 'id' + ORDER BY starelid, staattnum) +TO STDOUT +(FORMAT 'binary'); +\o +COMMIT; +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; + 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 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+-------------+------------+------------------------+------------+------------ + 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) + 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) + 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) + 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) + 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) + 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) +(6 rows) + +\! rm doc/export_effective_stats-12.sql.sample_test +TRUNCATE dbms_stats.work; +-- No.16-2-11 +\! 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 +\i doc/export_effective_stats-12.sql.sample_test +/* + * If you want the statistics of per-relation or per-column, please modify + * nspname, relname, and attname in 'WHERE' clause. + */ +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE; +/* + * If you want to chage the output file name, please modify the following name. + */ +\o export_stats.dmp +COPY (SELECT n2.nspname, + cl.relname, + r.relpages, + r.reltuples, + r.relallvisible, + r.curpages, + r.last_analyze, + r.last_autoanalyze, + COALESCE(a.attname, ''), + n1.nspname AS schemaname_of_atttype, + t.typname, + a.atttypmod, + co.stainherit, + co.stanullfrac, + co.stawidth, + co.stadistinct, + co.stakind1, + co.stakind2, + co.stakind3, + co.stakind4, + co.stakind5, + co.staop1, + co.staop2, + co.staop3, + co.staop4, + co.staop5, + co.stacoll1, + co.stacoll2, + co.stacoll3, + co.stacoll4, + co.stacoll5, + co.stanumbers1, + co.stanumbers2, + co.stanumbers3, + co.stanumbers4, + co.stanumbers5, + co.stavalues1, + co.stavalues2, + co.stavalues3, + co.stavalues4, + co.stavalues5 + FROM dbms_stats.column_stats_effective co + JOIN pg_attribute a + ON (co.starelid = a.attrelid AND co.staattnum = a.attnum) + JOIN pg_type t + ON a.atttypid = t.oid + JOIN pg_namespace n1 + ON t.typnamespace = n1.oid + RIGHT JOIN dbms_stats.relation_stats_effective r + ON co.starelid = r.relid + JOIN pg_catalog.pg_class cl + ON r.relid = cl.oid + JOIN pg_catalog.pg_namespace n2 + ON cl.relnamespace = n2.oid + -- WHERE n2.nspname = 'public' + -- AND cl.relname = 'test' + -- AND a.attname = 'id' + WHERE n2.nspname = 's0' AND a.attname IS NULL + ORDER BY starelid, staattnum) +TO STDOUT +(FORMAT 'binary'); +\o +COMMIT; +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; + 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 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ + 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) + 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) + 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) + 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) +(4 rows) + +\! rm doc/export_effective_stats-12.sql.sample_test +TRUNCATE dbms_stats.work; +-- No.16-2-12 +\! 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 +\i doc/export_effective_stats-12.sql.sample_test +/* + * If you want the statistics of per-relation or per-column, please modify + * nspname, relname, and attname in 'WHERE' clause. + */ +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE; +/* + * If you want to chage the output file name, please modify the following name. + */ +\o export_stats.dmp +COPY (SELECT n2.nspname, + cl.relname, + r.relpages, + r.reltuples, + r.relallvisible, + r.curpages, + r.last_analyze, + r.last_autoanalyze, + COALESCE(a.attname, ''), + n1.nspname AS schemaname_of_atttype, + t.typname, + a.atttypmod, + co.stainherit, + co.stanullfrac, + co.stawidth, + co.stadistinct, + co.stakind1, + co.stakind2, + co.stakind3, + co.stakind4, + co.stakind5, + co.staop1, + co.staop2, + co.staop3, + co.staop4, + co.staop5, + co.stacoll1, + co.stacoll2, + co.stacoll3, + co.stacoll4, + co.stacoll5, + co.stanumbers1, + co.stanumbers2, + co.stanumbers3, + co.stanumbers4, + co.stanumbers5, + co.stavalues1, + co.stavalues2, + co.stavalues3, + co.stavalues4, + co.stavalues5 + FROM dbms_stats.column_stats_effective co + JOIN pg_attribute a + ON (co.starelid = a.attrelid AND co.staattnum = a.attnum) + JOIN pg_type t + ON a.atttypid = t.oid + JOIN pg_namespace n1 + ON t.typnamespace = n1.oid + RIGHT JOIN dbms_stats.relation_stats_effective r + ON co.starelid = r.relid + JOIN pg_catalog.pg_class cl + ON r.relid = cl.oid + JOIN pg_catalog.pg_namespace n2 + ON cl.relnamespace = n2.oid + -- WHERE n2.nspname = 'public' + -- AND cl.relname = 'test' + -- AND a.attname = 'id' + WHERE n2.nspname = 's0' AND cl.relname IS NULL + ORDER BY starelid, staattnum) +TO STDOUT +(FORMAT 'binary'); +\o +COMMIT; +COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); +SELECT * FROM work_v; + 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 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ +(0 rows) + +\! rm doc/export_effective_stats-12.sql.sample_test +TRUNCATE dbms_stats.work; +/* + * Stab function dbms_stats.import + */ +ALTER FUNCTION dbms_stats.import( + nspname text, + relid regclass, + attname text, + src text +) RENAME TO truth_import; +CREATE FUNCTION dbms_stats.import( + nspname text, + relid regclass, + attname text, + src text +) RETURNS void AS +$$ +BEGIN + RAISE NOTICE 'arguments are "%", "%", "%", "%"', $1, $2, $3, $4; + RETURN; +END +$$ +LANGUAGE plpgsql; +/* + * No.17-1 dbms_stats.import_database_stats(src) + */ +-- No.17-1-1 +SELECT dbms_stats.import_database_stats('@abs_srcdir@/export_stats.dmp'); +NOTICE: arguments are "", "", "", "@abs_srcdir@/export_stats.dmp" + import_database_stats +----------------------- + +(1 row) + +/* + * No.17-2 dbms_stats.import_schema_stats(schemaname, src) + */ +-- No.17-2-1 +SELECT dbms_stats.import_schema_stats('s0', '@abs_srcdir@/export_stats.dmp'); +NOTICE: arguments are "s0", "", "", "@abs_srcdir@/export_stats.dmp" + import_schema_stats +--------------------- + +(1 row) + +/* + * No.17-3 dbms_stats.import_table_stats(relid, src) + */ +-- No.17-3-1 +SELECT dbms_stats.import_table_stats('s0.st0', '@abs_srcdir@/export_stats.dmp'); +NOTICE: arguments are "", "s0.st0", "", "@abs_srcdir@/export_stats.dmp" + import_table_stats +-------------------- + +(1 row) + +/* + * No.17-4 dbms_stats.import_table_stats(schemaname, tablename, src) + */ +-- No.17-4-1 +SELECT dbms_stats.import_table_stats('s0', 'st0', '@abs_srcdir@/export_stats.dmp'); +NOTICE: arguments are "", "s0.st0", "", "@abs_srcdir@/export_stats.dmp" + import_table_stats +-------------------- + +(1 row) + +/* + * No.17-5 dbms_stats.import_column_stats (relid, attname, src) + */ +-- No.17-5-1 +SELECT dbms_stats.import_column_stats('s0.st0', 'id', '@abs_srcdir@/export_stats.dmp'); +NOTICE: arguments are "", "s0.st0", "id", "@abs_srcdir@/export_stats.dmp" + import_column_stats +--------------------- + +(1 row) + +/* + * No.17-6 dbms_stats.import_column_stats (schemaname, tablename, attname, src) + */ +-- No.17-6-1 +SELECT dbms_stats.import_column_stats('s0', 'st0', 'id','@abs_srcdir@/export_stats.dmp'); +NOTICE: arguments are "", "s0.st0", "id", "@abs_srcdir@/export_stats.dmp" + import_column_stats +--------------------- + +(1 row) + +/* + * Delete stab function dbms_stats.import + */ +DROP FUNCTION dbms_stats.import( + nspname text, + relid regclass, + attname text, + src text +); +ALTER FUNCTION dbms_stats.truth_import( + nspname text, + relid regclass, + attname text, + src text +) RENAME TO import; diff --git a/pg_dbms_stats.c b/pg_dbms_stats.c index 417fe77..cdecbfc 100644 --- a/pg_dbms_stats.c +++ b/pg_dbms_stats.c @@ -40,7 +40,9 @@ #if PG_VERSION_NUM >= 100000 #include #endif - +#if PG_VERSION_NUM >= 120000 +#include "access/relation.h" +#endif #include "pg_dbms_stats.h" PG_MODULE_MAGIC; @@ -727,7 +729,7 @@ dbms_stats_invalidate_cache_internal(Oid relid, bool sta_col) /* * invalidate prepared statements and force re-planning with pg_dbms_stats. */ - rel = try_relation_open(relid, NoLock); + rel = try_relation_open(relid, AccessShareLock); if (rel != NULL) { if (sta_col && @@ -754,7 +756,7 @@ dbms_stats_invalidate_cache_internal(Oid relid, bool sta_col) CacheInvalidateRelcacheByRelid(rel->rd_index->indrelid); CacheInvalidateRelcache(rel); - relation_close(rel, NoLock); + relation_close(rel, AccessShareLock); } } @@ -835,14 +837,14 @@ dbms_stats_is_system_catalog_internal(Oid relid) return false; /* no such relation */ - rel = try_relation_open(relid, NoLock); + rel = try_relation_open(relid, AccessShareLock); if (rel == NULL) return false; /* check by namespace name. */ schema_name = get_namespace_name(rel->rd_rel->relnamespace); result = dbms_stats_is_system_schema_internal(schema_name); - relation_close(rel, NoLock); + relation_close(rel, AccessShareLock); return result; } diff --git a/sql/init-12.sql b/sql/init-12.sql new file mode 100644 index 0000000..477d194 --- /dev/null +++ b/sql/init-12.sql @@ -0,0 +1,118 @@ +CREATE MATERIALIZED VIEW s0.smv0 AS +SELECT st0.id, + st0.num, + st2.txt + FROM s0.st0,s0.st2 + WHERE st0.id = st2.id + ORDER BY id; +CREATE VIEW plain_relations_statistic_v AS +SELECT oid::regclass, + relpages, + reltuples, + relallvisible, + pg_relation_size(oid) / 8192 curpages + FROM pg_class + ORDER BY oid::regclass::text; +CREATE VIEW relations_locked_v AS +SELECT relid::regclass, + relname, + relpages, + reltuples, + relallvisible, + curpages + FROM dbms_stats.relation_stats_locked + ORDER BY relid; +CREATE VIEW relations_backup_v AS +SELECT id, + relid::regclass, + relname, + relpages, + reltuples, + relallvisible, + curpages + FROM dbms_stats.relation_stats_backup + ORDER BY id, relid; +CREATE VIEW plain_columns_statistic_v AS +SELECT starelid::regclass, staattnum, stainherit, + stanullfrac, stawidth, stadistinct, + stakind1, stakind2, stakind3, stakind4, stakind5, + staop1, staop2, staop3, staop4, staop5, + stanumbers1, stanumbers2, stanumbers3, stanumbers4, stanumbers5, + stavalues1::text, stavalues2::text, stavalues3::text, stavalues4::text, stavalues5::text + FROM pg_statistic + ORDER BY starelid, staattnum, stainherit; +CREATE VIEW columns_locked_v AS +SELECT starelid::regclass, staattnum, attname, stainherit, + stanullfrac, stawidth, stadistinct, + stakind1, stakind2, stakind3, stakind4, stakind5, + staop1, staop2, staop3, staop4, staop5, + stanumbers1, stanumbers2, stanumbers3, stanumbers4, stanumbers5, + stavalues1, stavalues2, stavalues3, stavalues4, stavalues5 + FROM dbms_stats.column_stats_locked c + JOIN pg_attribute a + ON (c.starelid = a.attrelid AND c.staattnum = a.attnum) + ORDER BY starelid, staattnum, stainherit; +CREATE VIEW columns_backup_v AS +SELECT id, statypid, + starelid::regclass, staattnum, stainherit, + stanullfrac, stawidth, stadistinct, + stakind1, stakind2, stakind3, stakind4, stakind5, + staop1, staop2, staop3, staop4, staop5, + stanumbers1, stanumbers2, stanumbers3, stanumbers4, stanumbers5, + stavalues1, stavalues2, stavalues3, stavalues4, stavalues5 + FROM dbms_stats.column_stats_backup + ORDER BY id, starelid, staattnum, stainherit; +CREATE TABLE dbms_stats.work ( + nspname name NOT NULL, + relname name NOT NULL, + relpages int4 NOT NULL, + reltuples float4 NOT NULL, + relallvisible int4 NOT NULL, + curpages int4 NOT NULL, + last_analyze timestamp with time zone, + last_autoanalyze timestamp with time zone, + attname name, + nspname_of_typename name, + typname name, + atttypmod int4, + stainherit bool, + stanullfrac float4, + stawidth int4, + stadistinct float4, + stakind1 int2, + stakind2 int2, + stakind3 int2, + stakind4 int2, + stakind5 int2, + staop1 oid, + staop2 oid, + staop3 oid, + staop4 oid, + staop5 oid, + stacoll1 oid, + stacoll2 oid, + stacoll3 oid, + stacoll4 oid, + stacoll5 oid, + stanumbers1 float4[], + stanumbers2 float4[], + stanumbers3 float4[], + stanumbers4 float4[], + stanumbers5 float4[], + stavalues1 dbms_stats.anyarray, + stavalues2 dbms_stats.anyarray, + stavalues3 dbms_stats.anyarray, + stavalues4 dbms_stats.anyarray + ,stavalues5 dbms_stats.anyarray +) WITH (autovacuum_enabled = 'false'); +CREATE VIEW work_v AS +SELECT 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 + FROM dbms_stats.work + ORDER BY nspname, relname, attname, stainherit; +ANALYZE s0.sft0; diff --git a/sql/init-common.sql b/sql/init-common.sql index 657ead9..086d56a 100644 --- a/sql/init-common.sql +++ b/sql/init-common.sql @@ -12,7 +12,6 @@ CREATE EXTENSION pg_dbms_stats; SET client_min_messages = warning; DROP ROLE IF EXISTS regular_user; CREATE ROLE regular_user LOGIN; -SET client_min_messages = fatal; DROP ROLE IF EXISTS super_user; CREATE ROLE super_user SUPERUSER CREATEDB CREATEROLE INHERIT LOGIN; diff --git a/sql/ut-12.sql b/sql/ut-12.sql new file mode 100644 index 0000000..5f2730f --- /dev/null +++ b/sql/ut-12.sql @@ -0,0 +1,2829 @@ +\pset null '(null)' +/* + * No.2-1 table definitions. + */ +-- No.2-1-1 +\d dbms_stats.backup_history +-- No.2-1-2 +\d dbms_stats.column_stats_backup +-- No.2-1-3 +\d dbms_stats.column_stats_locked +-- No.2-1-4 +\d dbms_stats.relation_stats_backup +-- No.2-1-5 +\d dbms_stats.relation_stats_locked + +/* + * No.2-2 view definitions. + */ +-- No.2-2-1 +\dS+ dbms_stats.column_stats_effective +-- No.2-2-2 +\dS+ dbms_stats.relation_stats_effective +-- No.2-2-3 +\dS+ dbms_stats.stats +-- No.2-2-4 +\dS+ dbms_stats.column_stats_locked +-- No.2-2-5 +\dS+ dbms_stats.relation_stats_locked + +/* + * No.2-4 dbms_stats.anyarray + */ +-- No.2-4-1 +SELECT n.nspname, t.typname, t.typlen, t.typbyval, t.typtype, + t.typcategory, t.typispreferred, t.typisdefined, t.typdelim, + t.typrelid, t.typelem, t.typinput, t.typoutput, t.typreceive, + t.typsend, t.typmodin, t.typmodout, t.typanalyze, t.typalign, + t.typstorage, t.typnotnull, t.typbasetype, t.typtypmod, t.typndims, + t.typcollation, t.typdefaultbin, t.typdefault, t.typacl + FROM pg_type t, pg_namespace n + WHERE t.typnamespace = n.oid + AND n.nspname = 'dbms_stats' + AND t.typname = 'anyarray'; + +/* + * No.5-1 dbms_stats.merge + */ +UPDATE pg_statistic SET + stanullfrac = staattnum, + stawidth = staattnum, + stadistinct = staattnum, + stakind1 = 4, + stakind2 = 1, + stakind3 = 2, + stakind4 = 3, + stakind5 = 5, + staop1 = 14, + staop2 = 11, + staop3 = 12, + staop4 = 13, + staop5 = 15, + stanumbers1 = ARRAY[staattnum,4], + stanumbers2 = ARRAY[staattnum,1], + stanumbers3 = ARRAY[staattnum,2], + stanumbers4 = ARRAY[staattnum,3], + stanumbers5 = ARRAY[staattnum,5], + stavalues2 = array_cat(stavalues1,stavalues1), + stavalues3 = array_cat(array_cat(stavalues1,stavalues1),stavalues1), + stavalues4 = array_cat(array_cat(array_cat(stavalues1,stavalues1),stavalues1),stavalues1) + ,stavalues5 = array_cat(array_cat(array_cat(array_cat(stavalues1,stavalues1),stavalues1),stavalues1),stavalues1) + WHERE starelid = 'st0'::regclass; +SELECT dbms_stats.lock_table_stats('st0'); +UPDATE dbms_stats.column_stats_locked SET + stainherit = 't', + stanullfrac = -staattnum, + stawidth = -staattnum, + stadistinct = -staattnum, + stakind1 = 2, + stakind2 = 3, + stakind3 = 4, + stakind4 = 1, + stakind5 = 5, + staop1 = 22, + staop2 = 23, + staop3 = 24, + staop4 = 21, + staop5 = 25, + stanumbers1 = ARRAY[-staattnum,22], + stanumbers2 = ARRAY[-staattnum,23], + stanumbers3 = ARRAY[-staattnum,24], + stanumbers4 = ARRAY[-staattnum,21], + stanumbers5 = ARRAY[-staattnum,25], + stavalues1 = stavalues3, + stavalues2 = stavalues2, + stavalues3 = stavalues1, + stavalues4 = stavalues4 + ,stavalues5 = stavalues5 +; + +/* + * Driver function dbms_stats.merge1 + */ +CREATE FUNCTION dbms_stats.merge1( + lhs dbms_stats.column_stats_locked, + rhs pg_catalog.pg_statistic +) RETURNS integer AS +'$libdir/pg_dbms_stats', 'dbms_stats_merge' +LANGUAGE C STABLE; + +SELECT * FROM columns_locked_v + WHERE starelid = 'st0'::regclass; +SELECT * FROM plain_columns_statistic_v + WHERE starelid = 'st0'::regclass; + +SET client_min_messages TO LOG; + +-- No.5-1-1 +SELECT (m.merge).starelid::regclass, + (m.merge).staattnum, + (m.merge).stainherit, + (m.merge).stanullfrac, + (m.merge).stawidth, + (m.merge).stadistinct, + (m.merge).stakind1, + (m.merge).stakind2, + (m.merge).stakind3, + (m.merge).stakind4, + (m.merge).stakind5, + (m.merge).staop1, + (m.merge).staop2, + (m.merge).staop3, + (m.merge).staop4, + (m.merge).staop5, + (m.merge).stanumbers1, + (m.merge).stanumbers2, + (m.merge).stanumbers3, + (m.merge).stanumbers4, + (m.merge).stanumbers5, + (m.merge).stavalues1, + (m.merge).stavalues2, + (m.merge).stavalues3, + (m.merge).stavalues4 + ,(m.merge).stavalues5 + FROM (SELECT dbms_stats.merge(NULL, s) + FROM pg_statistic s + WHERE starelid = 'st0'::regclass + AND staattnum = '1'::int2) m; + +-- No.5-1-2 +SELECT (m.merge).starelid::regclass, + (m.merge).staattnum, + (m.merge).stainherit, + (m.merge).stanullfrac, + (m.merge).stawidth, + (m.merge).stadistinct, + (m.merge).stakind1, + (m.merge).stakind2, + (m.merge).stakind3, + (m.merge).stakind4, + (m.merge).stakind5, + (m.merge).staop1, + (m.merge).staop2, + (m.merge).staop3, + (m.merge).staop4, + (m.merge).staop5, + (m.merge).stanumbers1, + (m.merge).stanumbers2, + (m.merge).stanumbers3, + (m.merge).stanumbers4, + (m.merge).stanumbers5, + (m.merge).stavalues1, + (m.merge).stavalues2, + (m.merge).stavalues3, + (m.merge).stavalues4 + ,(m.merge).stavalues5 + FROM (SELECT dbms_stats.merge(v, NULL) + FROM dbms_stats.column_stats_locked v + WHERE starelid = 'st0'::regclass + AND staattnum = '2'::int2) m; + +-- No.5-1-3 +SELECT dbms_stats.merge(NULL, NULL); + +-- No.5-1-4 +SELECT (m.merge).starelid::regclass, + (m.merge).staattnum, + (m.merge).stainherit, + (m.merge).stanullfrac, + (m.merge).stawidth, + (m.merge).stadistinct, + (m.merge).stakind1, + (m.merge).stakind2, + (m.merge).stakind3, + (m.merge).stakind4, + (m.merge).stakind5, + (m.merge).staop1, + (m.merge).staop2, + (m.merge).staop3, + (m.merge).staop4, + (m.merge).staop5, + (m.merge).stanumbers1, + (m.merge).stanumbers2, + (m.merge).stanumbers3, + (m.merge).stanumbers4, + (m.merge).stanumbers5, + (m.merge).stavalues1, + (m.merge).stavalues2, + (m.merge).stavalues3, + (m.merge).stavalues4 + ,(m.merge).stavalues5 + FROM (SELECT dbms_stats.merge(v, s) + FROM dbms_stats.column_stats_locked v, + pg_statistic s + WHERE v.starelid = 'st0'::regclass + AND v.staattnum = '2'::int2 + AND s.starelid = 'st0'::regclass + AND s.staattnum = '1'::int2) m; + +-- No.5-1-5 +SELECT (m.merge).starelid::regclass, + (m.merge).staattnum, + (m.merge).stainherit, + (m.merge).stanullfrac, + (m.merge).stawidth, + (m.merge).stadistinct, + (m.merge).stakind1, + (m.merge).stakind2, + (m.merge).stakind3, + (m.merge).stakind4, + (m.merge).stakind5, + (m.merge).staop1, + (m.merge).staop2, + (m.merge).staop3, + (m.merge).staop4, + (m.merge).staop5, + (m.merge).stanumbers1, + (m.merge).stanumbers2, + (m.merge).stanumbers3, + (m.merge).stanumbers4, + (m.merge).stanumbers5, + (m.merge).stavalues1, + (m.merge).stavalues2, + (m.merge).stavalues3, + (m.merge).stavalues4 + ,(m.merge).stavalues5 + FROM (SELECT dbms_stats.merge(v, s) + FROM dbms_stats.column_stats_locked v, + pg_statistic s + WHERE v.starelid = 'st0'::regclass + AND v.staattnum = '2'::int2 + AND s.starelid = 'st0'::regclass + AND s.staattnum = '1'::int2) m; + +-- No.5-1-6 +SELECT dbms_stats.merge1(v, s) + FROM dbms_stats.column_stats_locked v, + pg_statistic s + WHERE v.starelid = 'st0'::regclass + AND v.staattnum = '2'::int2 + AND s.starelid = 'st0'::regclass + AND s.staattnum = '1'::int2; + +-- No.5-1-7 +SELECT dbms_stats.merge(NULL, ( + s.starelid::regclass, s.staattnum, s.stainherit, + s.stanullfrac, s.stawidth, s.stadistinct, + s.stakind1, s.stakind2, s.stakind3, s.stakind4, + s.stakind5, + s.staop1, s.staop2, s.staop3, + s.staop4, + NULL, s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, + s.stanumbers5, + s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 + ,s.stavalues5 + )) + FROM pg_statistic s + WHERE s.starelid = 'st0'::regclass + AND s.staattnum = '1'::int2; + +-- No.5-1-8 +SELECT (m.merge).starelid::regclass, + (m.merge).staattnum, + (m.merge).stainherit, + (m.merge).stanullfrac, + (m.merge).stawidth, + (m.merge).stadistinct, + (m.merge).stakind1, + (m.merge).stakind2, + (m.merge).stakind3, + (m.merge).stakind4, + (m.merge).stakind5, + (m.merge).staop1, + (m.merge).staop2, + (m.merge).staop3, + (m.merge).staop4, + (m.merge).staop5, + (m.merge).stanumbers1, + (m.merge).stanumbers2, + (m.merge).stanumbers3, + (m.merge).stanumbers4, + (m.merge).stanumbers5, + (m.merge).stavalues1, + (m.merge).stavalues2, + (m.merge).stavalues3, + (m.merge).stavalues4 + ,(m.merge).stavalues5 + FROM (SELECT dbms_stats.merge(NULL, ( + s.starelid::regclass, s.staattnum, s.stainherit, + s.stanullfrac, s.stawidth, s.stadistinct, + s.stakind1, s.stakind2, s.stakind3, s.stakind4, + s.stakind5, + s.staop1, s.staop2, s.staop3, s.staop4, + s.staop5, + NULL, s.stanumbers2, s.stanumbers3, s.stanumbers4, + s.stanumbers5, + s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 + ,s.stavalues5 + )) + FROM pg_statistic s + WHERE s.starelid = 'st0'::regclass + AND s.staattnum = '1'::int2) m; + +-- No.5-1-9 +SELECT dbms_stats.merge(( + v.starelid::regclass, v.staattnum, v.stainherit, + v.stanullfrac, v.stawidth, v.stadistinct, + v.stakind1, v.stakind2, v.stakind3, v.stakind4, + v.stakind5, + v.staop1, v.staop2, v.staop3, + v.staop4, + NULL, v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, + v.stanumbers5, + v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 + ,v.stavalues5 + ), NULL) + FROM dbms_stats.column_stats_locked v + WHERE v.starelid = 'st0'::regclass + AND v.staattnum = '2'::int2; + +-- No.5-1-10 +SELECT (m.merge).starelid::regclass, + (m.merge).staattnum, + (m.merge).stainherit, + (m.merge).stanullfrac, + (m.merge).stawidth, + (m.merge).stadistinct, + (m.merge).stakind1, + (m.merge).stakind2, + (m.merge).stakind3, + (m.merge).stakind4, + (m.merge).stakind5, + (m.merge).staop1, + (m.merge).staop2, + (m.merge).staop3, + (m.merge).staop4, + (m.merge).staop5, + (m.merge).stanumbers1, + (m.merge).stanumbers2, + (m.merge).stanumbers3, + (m.merge).stanumbers4, + (m.merge).stanumbers5, + (m.merge).stavalues1, + (m.merge).stavalues2, + (m.merge).stavalues3, + (m.merge).stavalues4 + ,(m.merge).stavalues5 + FROM (SELECT dbms_stats.merge(( + v.starelid::regclass, v.staattnum, v.stainherit, + v.stanullfrac, v.stawidth, v.stadistinct, + v.stakind1, v.stakind2, v.stakind3, v.stakind4, + v.stakind5, + v.staop1, v.staop2, v.staop3, v.staop4, + v.staop5, + NULL, v.stanumbers2, v.stanumbers3, v.stanumbers4, + v.stanumbers5, + v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 + ,v.stavalues5 + ), NULL) + FROM dbms_stats.column_stats_locked v + WHERE v.starelid = 'st0'::regclass + AND v.staattnum = '2'::int2) m; + +-- No.5-1-11 +SELECT dbms_stats.merge(( + v.starelid::regclass, v.staattnum, v.stainherit, + v.stanullfrac, v.stawidth, v.stadistinct, + v.stakind1, v.stakind2, v.stakind3, v.stakind4, + v.stakind5, + v.staop1, v.staop2, v.staop3, + v.staop4, + NULL, v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, + v.stanumbers5, + v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 + ,v.stavalues5 + ), ( + s.starelid::regclass, s.staattnum, s.stainherit, + s.stanullfrac, s.stawidth, s.stadistinct, + s.stakind1, s.stakind2, s.stakind3, s.stakind4, + s.stakind5, + s.staop1, s.staop2, s.staop3, + s.staop4, + NULL, s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, + s.stanumbers5, + s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 + ,s.stavalues5 + )) + FROM dbms_stats.column_stats_locked v, + pg_statistic s + WHERE v.starelid = 'st0'::regclass + AND v.staattnum = '2'::int2 + AND s.starelid = 'st0'::regclass + AND s.staattnum = '1'::int2; + +-- No.5-1-12 +SELECT (m.merge).starelid::regclass, + (m.merge).staattnum, + (m.merge).stainherit, + (m.merge).stanullfrac, + (m.merge).stawidth, + (m.merge).stadistinct, + (m.merge).stakind1, + (m.merge).stakind2, + (m.merge).stakind3, + (m.merge).stakind4, + (m.merge).stakind5, + (m.merge).staop1, + (m.merge).staop2, + (m.merge).staop3, + (m.merge).staop4, + (m.merge).staop5, + (m.merge).stanumbers1, + (m.merge).stanumbers2, + (m.merge).stanumbers3, + (m.merge).stanumbers4, + (m.merge).stanumbers5, + (m.merge).stavalues1, + (m.merge).stavalues2, + (m.merge).stavalues3, + (m.merge).stavalues4 + ,(m.merge).stavalues5 + FROM (SELECT dbms_stats.merge(( + v.starelid::regclass, v.staattnum, v.stainherit, + v.stanullfrac, v.stawidth, v.stadistinct, + v.stakind1, v.stakind2, v.stakind3, v.stakind4, + v.stakind5, + v.staop1, v.staop2, v.staop3, v.staop4, + v.staop5, + NULL, v.stanumbers2, v.stanumbers3, v.stanumbers4, + v.stanumbers5, + v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 + ,v.stavalues5 + ), ( + s.starelid::regclass, s.staattnum, s.stainherit, + s.stanullfrac, s.stawidth, s.stadistinct, + s.stakind1, s.stakind2, s.stakind3, s.stakind4, + s.stakind5, + s.staop1, s.staop2, s.staop3, s.staop4, + s.staop5, + NULL, s.stanumbers2, s.stanumbers3, s.stanumbers4, + s.stanumbers5, + s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 + ,s.stavalues5 + )) + FROM dbms_stats.column_stats_locked v, + pg_statistic s + WHERE v.starelid = 'st0'::regclass + AND v.staattnum = '2'::int2 + AND s.starelid = 'st0'::regclass + AND s.staattnum = '1'::int2) m; + +-- No.5-1-13 +SELECT (m.merge).starelid::regclass, + (m.merge).staattnum, + (m.merge).stainherit, + (m.merge).stanullfrac, + (m.merge).stawidth, + (m.merge).stadistinct, + (m.merge).stakind1, + (m.merge).stakind2, + (m.merge).stakind3, + (m.merge).stakind4, + (m.merge).stakind5, + (m.merge).staop1, + (m.merge).staop2, + (m.merge).staop3, + (m.merge).staop4, + (m.merge).staop5, + (m.merge).stanumbers1, + (m.merge).stanumbers2, + (m.merge).stanumbers3, + (m.merge).stanumbers4, + (m.merge).stanumbers5, + (m.merge).stavalues1, + (m.merge).stavalues2, + (m.merge).stavalues3, + (m.merge).stavalues4 + ,(m.merge).stavalues5 + FROM (SELECT dbms_stats.merge(( + 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 + ), s) + FROM pg_statistic s + WHERE s.starelid = 'st0'::regclass + AND s.staattnum = '1'::int2) m; + +-- No.5-1-14 +SELECT (m.merge).starelid::regclass, + (m.merge).staattnum, + (m.merge).stainherit, + (m.merge).stanullfrac, + (m.merge).stawidth, + (m.merge).stadistinct, + (m.merge).stakind1, + (m.merge).stakind2, + (m.merge).stakind3, + (m.merge).stakind4, + (m.merge).stakind5, + (m.merge).staop1, + (m.merge).staop2, + (m.merge).staop3, + (m.merge).staop4, + (m.merge).staop5, + (m.merge).stanumbers1, + (m.merge).stanumbers2, + (m.merge).stanumbers3, + (m.merge).stanumbers4, + (m.merge).stanumbers5, + (m.merge).stavalues1, + (m.merge).stavalues2, + (m.merge).stavalues3, + (m.merge).stavalues4 + ,(m.merge).stavalues5 + FROM (SELECT dbms_stats.merge(v, ( + 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)) + FROM dbms_stats.column_stats_locked v + WHERE v.starelid = 'st0'::regclass + AND v.staattnum = '2'::int2) m; + +-- No.5-1-15 +SELECT (m.merge).starelid::regclass, + (m.merge).staattnum, + (m.merge).stainherit, + (m.merge).stanullfrac, + (m.merge).stawidth, + (m.merge).stadistinct, + (m.merge).stakind1, + (m.merge).stakind2, + (m.merge).stakind3, + (m.merge).stakind4, + (m.merge).stakind5, + (m.merge).staop1, + (m.merge).staop2, + (m.merge).staop3, + (m.merge).staop4, + (m.merge).staop5, + (m.merge).stanumbers1, + (m.merge).stanumbers2, + (m.merge).stanumbers3, + (m.merge).stanumbers4, + (m.merge).stanumbers5, + (m.merge).stavalues1, + (m.merge).stavalues2, + (m.merge).stavalues3, + (m.merge).stavalues4 + ,(m.merge).stavalues5 + FROM (SELECT dbms_stats.merge(v, s) + FROM dbms_stats.column_stats_locked v, + pg_statistic s + WHERE v.starelid = 'st0'::regclass + AND v.staattnum = '2'::int2 + AND s.starelid = 'st0'::regclass + AND s.staattnum = '1'::int2) m; + +-- No.5-1-16 +SELECT dbms_stats.merge(( + v.starelid::regclass, v.staattnum, v.stainherit, + v.stanullfrac, v.stawidth, v.stadistinct, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL + ,NULL, NULL, NULL, NULL + ), ( + s.starelid::regclass, s.staattnum, s.stainherit, + s.stanullfrac, s.stawidth, s.stadistinct, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL)) + FROM dbms_stats.column_stats_locked v, + pg_statistic s + WHERE v.starelid = 'st0'::regclass + AND v.staattnum = '2'::int2 + AND s.starelid = 'st0'::regclass + AND s.staattnum = '1'::int2; + +-- No.5-1-17 +SELECT (m.merge).starelid::regclass, + (m.merge).staattnum, + (m.merge).stainherit, + (m.merge).stanullfrac, + (m.merge).stawidth, + (m.merge).stadistinct, + (m.merge).stakind1, + (m.merge).stakind2, + (m.merge).stakind3, + (m.merge).stakind4, + (m.merge).stakind5, + (m.merge).staop1, + (m.merge).staop2, + (m.merge).staop3, + (m.merge).staop4, + (m.merge).staop5, + (m.merge).stanumbers1, + (m.merge).stanumbers2, + (m.merge).stanumbers3, + (m.merge).stanumbers4, + (m.merge).stanumbers5, + (m.merge).stavalues1, + (m.merge).stavalues2, + (m.merge).stavalues3, + (m.merge).stavalues4 + ,(m.merge).stavalues5 + FROM (SELECT dbms_stats.merge(( + v.starelid::regclass, v.staattnum, v.stainherit, + v.stanullfrac, v.stawidth, v.stadistinct, + v.stakind1, v.stakind2, v.stakind3, v.stakind4, + v.stakind5, + v.staop1, v.staop2, v.staop3, + v.staop4, + NULL, v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, + v.stanumbers5, + v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 + ,v.stavalues5 + ), ( + s.starelid::regclass, s.staattnum, s.stainherit, + s.stanullfrac, s.stawidth, s.stadistinct, + s.stakind1, s.stakind2, s.stakind3, s.stakind4, + s.stakind5, + s.staop1, s.staop2, s.staop3, s.staop4, + s.staop5, + s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, + s.stanumbers5, + s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 + ,s.stavalues5 + )) + FROM dbms_stats.column_stats_locked v, + pg_statistic s + WHERE v.starelid = 'st0'::regclass + AND v.staattnum = '1'::int2 + AND s.starelid = 'st0'::regclass + AND s.staattnum = '1'::int2) m; + +-- No.5-1-18 +SELECT dbms_stats.merge(( + v.starelid::regclass, v.staattnum, v.stainherit, + v.stanullfrac, v.stawidth, v.stadistinct, + v.stakind1, v.stakind2, v.stakind3, v.stakind4, + v.stakind5, + v.staop1, v.staop2, v.staop3, + v.staop4, + NULL, v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, + v.stanumbers5, + v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 + ,v.stavalues5 + ), ( + s.starelid::regclass, s.staattnum, s.stainherit, + s.stanullfrac, s.stawidth, s.stadistinct, + s.stakind1, s.stakind2, s.stakind3, s.stakind4, + s.stakind5, + s.staop1, s.staop2, s.staop3, + s.staop4, + NULL, s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, + s.stanumbers5, + s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 + ,s.stavalues5 + )) + FROM dbms_stats.column_stats_locked v, + pg_statistic s + WHERE v.starelid = 'st0'::regclass + AND v.staattnum = '1'::int2 + AND s.starelid = 'st0'::regclass + AND s.staattnum = '1'::int2; + +-- No.5-1-19 +SELECT (m.merge).starelid::regclass, + (m.merge).staattnum, + (m.merge).stainherit, + (m.merge).stanullfrac, + (m.merge).stawidth, + (m.merge).stadistinct, + (m.merge).stakind1, + (m.merge).stakind2, + (m.merge).stakind3, + (m.merge).stakind4, + (m.merge).stakind5, + (m.merge).staop1, + (m.merge).staop2, + (m.merge).staop3, + (m.merge).staop4, + (m.merge).staop5, + (m.merge).stanumbers1, + (m.merge).stanumbers2, + (m.merge).stanumbers3, + (m.merge).stanumbers4, + (m.merge).stanumbers5, + (m.merge).stavalues1, + (m.merge).stavalues2, + (m.merge).stavalues3, + (m.merge).stavalues4 + ,(m.merge).stavalues5 + FROM (SELECT dbms_stats.merge(( + v.starelid::regclass, v.staattnum, v.stainherit, + v.stanullfrac, v.stawidth, v.stadistinct, + '1', '1', '1', '1', + '1', + v.staop1, v.staop2, v.staop3, v.staop4, + v.staop5, + v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, + v.stanumbers5, + v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 + ,v.stavalues5 + ), ( + s.starelid::regclass, s.staattnum, s.stainherit, + s.stanullfrac, s.stawidth, s.stadistinct, + '1', '1', '1', '1', + '1', + s.staop1, s.staop2, s.staop3, s.staop4, + s.staop5, + s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, + s.stanumbers5, + s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 + ,s.stavalues5 + )) + FROM dbms_stats.column_stats_locked v, + pg_statistic s + WHERE v.starelid = 'st0'::regclass + AND v.staattnum = '2'::int2 + AND s.starelid = 'st0'::regclass + AND s.staattnum = '1'::int2) m; + +-- No.5-1-20 +SELECT (m.merge).starelid::regclass, + (m.merge).staattnum, + (m.merge).stainherit, + (m.merge).stanullfrac, + (m.merge).stawidth, + (m.merge).stadistinct, + (m.merge).stakind1, + (m.merge).stakind2, + (m.merge).stakind3, + (m.merge).stakind4, + (m.merge).stakind5, + (m.merge).staop1, + (m.merge).staop2, + (m.merge).staop3, + (m.merge).staop4, + (m.merge).staop5, + (m.merge).stanumbers1, + (m.merge).stanumbers2, + (m.merge).stanumbers3, + (m.merge).stanumbers4, + (m.merge).stanumbers5, + (m.merge).stavalues1, + (m.merge).stavalues2, + (m.merge).stavalues3, + (m.merge).stavalues4 + ,(m.merge).stavalues5 + FROM (SELECT dbms_stats.merge((v.starelid::regclass, v.staattnum, v.stainherit, + v.stanullfrac, v.stawidth, v.stadistinct, + '2', '2', '2', '2', + '2', + v.staop1, v.staop2, v.staop3, v.staop4, + v.staop5, + v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, + v.stanumbers5, + v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 + ,v.stavalues5 + ), ( + s.starelid::regclass, s.staattnum, s.stainherit, + s.stanullfrac, s.stawidth, s.stadistinct, + '2', '2', '2', '2', + '2', + s.staop1, s.staop2, s.staop3, s.staop4, + s.staop5, + s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, + s.stanumbers5, + s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 + ,s.stavalues5 + )) + FROM dbms_stats.column_stats_locked v, + pg_statistic s + WHERE v.starelid = 'st0'::regclass + AND v.staattnum = '2'::int2 + AND s.starelid = 'st0'::regclass + AND s.staattnum = '1'::int2) m; + +-- No.5-1-21 +SELECT dbms_stats.merge((v.starelid::regclass, '2', v.stainherit, + v.stanullfrac, v.stawidth, v.stadistinct, + '1', '1', '1', '1', + '1', + v.staop1, v.staop2, v.staop3, v.staop4, + v.staop5, + v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, + v.stanumbers5, + v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 + ,v.stavalues5 + ), ( + s.starelid::regclass, s.staattnum, s.stainherit, + s.stanullfrac, s.stawidth, s.stadistinct, + '1', '1', '1', '1', + '1', + s.staop1, s.staop2, s.staop3, s.staop4, + s.staop5, + s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, + s.stanumbers5, + s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 + ,s.stavalues5 + )) + FROM dbms_stats.column_stats_locked v, + pg_statistic s + WHERE v.starelid = 'st0'::regclass + AND v.staattnum = '1'::int2 + AND s.starelid = 'st0'::regclass + AND s.staattnum = '1'::int2; + +-- No.5-1-22 +SELECT dbms_stats.merge((v.starelid::regclass, '2', v.stainherit, + v.stanullfrac, v.stawidth, v.stadistinct, + '2', '2', '2', '2', + '2', + v.staop1, v.staop2, v.staop3, v.staop4, + v.staop5, + v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, + v.stanumbers5, + v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 + ,v.stavalues5 + ), ( + s.starelid::regclass, s.staattnum, s.stainherit, + s.stanullfrac, s.stawidth, s.stadistinct, + '2', '2', '2', '2', + '2', + s.staop1, s.staop2, s.staop3, s.staop4, + s.staop5, + s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, + s.stanumbers5, + s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 + ,s.stavalues5 + )) + FROM dbms_stats.column_stats_locked v, + pg_statistic s + WHERE v.starelid = 'st0'::regclass + AND v.staattnum = '1'::int2 + AND s.starelid = 'st0'::regclass + AND s.staattnum = '1'::int2; +RESET client_min_messages; +SELECT dbms_stats.unlock_database_stats(); + +/* + * No.6-4 dbms_stats.is_target_relkind + */ +-- No.6-4- 10-11 +SELECT dbms_stats.is_target_relkind(k::"char") + FROM (VALUES ('r'), ('i'), ('f'), ('m'), + ('S'), ('t'), ('v'), ('c')) t(k); + +/* + * No.7-1 dbms_stats.backup + */ +DELETE FROM dbms_stats.backup_history; +INSERT INTO dbms_stats.backup_history(id, time, unit) values(1, '2012-01-01', 'd'); +-- No.7-1-9 +SELECT dbms_stats.backup(1, 's0.sft0'::regclass, NULL); +SELECT count(*) FROM dbms_stats.relation_stats_backup; +SELECT count(*) FROM dbms_stats.column_stats_backup; + +-- No.7-1-10 +DELETE FROM dbms_stats.relation_stats_backup; +SELECT dbms_stats.backup(1, 's0.smv0'::regclass, NULL); +SELECT count(*) FROM dbms_stats.relation_stats_backup; +SELECT count(*) FROM dbms_stats.column_stats_backup; + +-- No.7-1-12 +DELETE FROM dbms_stats.relation_stats_backup; +SELECT dbms_stats.backup(1, NULL, 1::int2); +SELECT relid::regclass FROM dbms_stats.relation_stats_backup + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, staattnum FROM dbms_stats.column_stats_backup + GROUP BY starelid, staattnum + ORDER BY starelid, staattnum; + +-- No.7-1-14 +DELETE FROM dbms_stats.relation_stats_backup; +SELECT dbms_stats.backup(1, NULL::regclass, NULL); +SELECT relid::regclass FROM dbms_stats.relation_stats_backup + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, staattnum FROM dbms_stats.column_stats_backup + GROUP BY starelid, staattnum + ORDER BY starelid, staattnum; + +-- No.7-1-18 +DELETE FROM dbms_stats.relation_stats_backup; +\! psql contrib_regression -c "SELECT dbms_stats.backup(NULL, 's0.st0'::regclass, NULL)" > results/ut_no2_1_17.out 2>&1 +SELECT count(*) FROM dbms_stats.relation_stats_backup; +SELECT count(*) FROM dbms_stats.column_stats_backup; + +/* + * No.8-1 dbms_stats.backup + */ +SELECT setval('dbms_stats.backup_history_id_seq',1, false); +/* + * Stab function dbms_stats.backup + */ +ALTER FUNCTION dbms_stats.backup( + backup_id int8, + relid regclass, + attnum int2) + RENAME TO truth_func_backup; + +CREATE OR REPLACE FUNCTION dbms_stats.backup( + backup_id int8, + regclass, + attnum int2) +RETURNS int8 AS +$$ +BEGIN + RAISE NOTICE 'arguments are %, %, %', $1, $2, $3; + RETURN 1; +END; +$$ +LANGUAGE plpgsql; + +-- No.8-1-1 +DELETE FROM dbms_stats.backup_history; +SELECT dbms_stats.backup('s0.st0'::regclass, 'id', 'dummy comment'); +SELECT id, unit, comment FROM dbms_stats.backup_history; + +-- No.8-1-2 +DELETE FROM dbms_stats.backup_history; +SELECT dbms_stats.backup('s0.st0'::regclass, NULL, 'dummy comment'); +SELECT id, unit, comment FROM dbms_stats.backup_history; + +-- No.8-1-3 +DELETE FROM dbms_stats.backup_history; +SELECT dbms_stats.backup(NULL::regclass, 'id', 'dummy comment'); +SELECT id, unit, comment FROM dbms_stats.backup_history; + +-- No.8-1-4 +DELETE FROM dbms_stats.backup_history; +SELECT dbms_stats.backup(NULL::regclass, NULL, 'dummy comment'); +SELECT id, unit, comment FROM dbms_stats.backup_history; + +-- No.8-1-5 +DELETE FROM dbms_stats.backup_history; +SELECT dbms_stats.backup(0, NULL, 'dummy comment'); +SELECT id, unit, comment FROM dbms_stats.backup_history; + +-- No.8-1-6 +DELETE FROM dbms_stats.backup_history; +SELECT dbms_stats.backup('s0.st0'::regclass, NULL, 'dummy comment'); +SELECT id, unit, comment FROM dbms_stats.backup_history; + +-- No.8-1-7 +DELETE FROM dbms_stats.backup_history; +SELECT dbms_stats.backup( + 'pg_toast.pg_toast_2618'::regclass, + NULL, + 'dummy comment'); +SELECT id, unit, comment FROM dbms_stats.backup_history; + +-- No.8-1-8 +DELETE FROM dbms_stats.backup_history; +SELECT dbms_stats.backup('s0.st0_idx'::regclass, NULL, 'dummy comment'); +SELECT id, unit, comment FROM dbms_stats.backup_history; + +-- No.8-1-9 +DELETE FROM dbms_stats.backup_history; +SELECT dbms_stats.backup('s0.ss0'::regclass, NULL, 'dummy comment'); +SELECT id, unit, comment FROM dbms_stats.backup_history; + +-- No.8-1-10 +DELETE FROM dbms_stats.backup_history; +SELECT dbms_stats.backup('s0.sc0'::regclass, NULL, 'dummy comment'); +SELECT id, unit, comment FROM dbms_stats.backup_history; + +-- No.8-1-11 +DELETE FROM dbms_stats.backup_history; +SELECT dbms_stats.backup('s0.sft0'::regclass, NULL, 'dummy comment'); +SELECT id, unit, comment FROM dbms_stats.backup_history; + +-- No.8-1-12 +DELETE FROM dbms_stats.backup_history; +SELECT dbms_stats.backup('s0.smv0'::regclass, NULL, 'dummy comment'); +SELECT id, unit, comment FROM dbms_stats.backup_history; + +-- No.8-1-13 +DELETE FROM dbms_stats.backup_history; +SELECT dbms_stats.backup('pg_catalog.pg_class'::regclass, NULL, 'dummy comment'); +SELECT id, unit, comment FROM dbms_stats.backup_history; + +-- No.8-1-14 +DELETE FROM dbms_stats.backup_history; +SELECT dbms_stats.backup('s0.st0'::regclass, 'dummy', 'dummy comment'); +SELECT id, unit, comment FROM dbms_stats.backup_history; + +-- No.8-1-15 +DELETE FROM dbms_stats.backup_history; +DELETE FROM pg_statistic + WHERE starelid = 's0.st0'::regclass + AND staattnum = 1::int2; +SELECT count(*) FROM dbms_stats.column_stats_effective + WHERE starelid = 's0.st0'::regclass + AND staattnum = 1::int2; +SELECT dbms_stats.backup('s0.st0'::regclass, 'id', 'dummy comment'); +SELECT id, unit, comment FROM dbms_stats.backup_history; + +/* + * Stab function dbms_stats.backup + */ +ALTER FUNCTION dbms_stats.backup( + relid regclass, + attname text, + comment text) + RENAME TO truth_func_backup; +CREATE OR REPLACE FUNCTION dbms_stats.backup( + relid regclass DEFAULT NULL, + attname text DEFAULT NULL, + comment text DEFAULT NULL) +RETURNS int8 AS +$$ +BEGIN + IF $3 = '' THEN + RAISE NOTICE 'third argument is not NULL but string ""'; + END IF; + RAISE NOTICE 'arguments are %, %, %', $1, $2, $3; + RETURN 1; +END; +$$ +LANGUAGE plpgsql; + +/* + * No.8-3 dbms_stats.backup_schema_stats + */ +SELECT setval('dbms_stats.backup_history_id_seq',9, false); +-- No.8-3-1 +SELECT dbms_stats.backup_schema_stats('s0', 'comment'); +SELECT id, unit, comment FROM dbms_stats.backup_history + ORDER BY id DESC + LIMIT 1; +-- No.8-3-2 +SELECT dbms_stats.backup_schema_stats('s00', 'comment'); +SELECT id, unit, comment FROM dbms_stats.backup_history + ORDER BY id DESC + LIMIT 1; +-- No.8-3-3 +SELECT dbms_stats.backup_schema_stats('pg_catalog', 'comment'); +SELECT id, unit, comment FROM dbms_stats.backup_history + ORDER BY id DESC + LIMIT 1; + +/* + * Delete stab function dbms_stats.backup + */ +DROP FUNCTION dbms_stats.backup( + backup_id int8, + regclass, + attnum int2); +ALTER FUNCTION dbms_stats.truth_func_backup( + backup_id int8, + regclass, + attnum int2) + RENAME TO backup; +DROP FUNCTION dbms_stats.backup( + regclass, + attname text, + comment text); +ALTER FUNCTION dbms_stats.truth_func_backup( + regclass, + attname text, + comment text) + RENAME TO backup; +VACUUM ANALYZE; + +/* + * create backup statistics state A + */ +DELETE FROM dbms_stats.backup_history; + +INSERT INTO dbms_stats.backup_history(id, time, unit) + VALUES (1, '2012-02-29 23:59:56.999999', 'd'); + +SELECT setval('dbms_stats.backup_history_id_seq',1); +SELECT dbms_stats.backup(); +UPDATE dbms_stats.backup_history + SET time = '2012-02-29 23:59:57' + WHERE id = 2; +SELECT dbms_stats.backup('s0.st0'); +UPDATE dbms_stats.backup_history + SET time = '2012-02-29 23:59:57.000001' + WHERE id = 3; +SELECT dbms_stats.backup(); +UPDATE dbms_stats.backup_history + SET time = '2012-02-29 23:59:58' + WHERE id = 4; +DELETE FROM dbms_stats.relation_stats_backup + WHERE id = 4; +SELECT dbms_stats.backup('s0.st0', 'id'); +UPDATE dbms_stats.backup_history + SET time = '2012-03-01 00:00:00' + WHERE id = 5; +SELECT dbms_stats.backup('s0.st0'); +UPDATE dbms_stats.backup_history + SET time = '2012-03-01 00:00:02' + WHERE id = 6; +SELECT dbms_stats.backup('public.st0'); +UPDATE dbms_stats.backup_history + SET time = '2012-03-01 00:00:04' + WHERE id = 7; +INSERT INTO dbms_stats.backup_history(time, unit) + VALUES ('2012-03-01 00:00:06', 's'); +SELECT dbms_stats.backup(8, c.oid, NULL) + FROM pg_catalog.pg_class c, + pg_catalog.pg_namespace n + WHERE n.nspname = 's0' + AND c.relnamespace = n.oid + AND c.relkind IN ('r', 'i'); + +SELECT * FROM dbms_stats.backup_history + ORDER BY id; +SELECT * FROM relations_backup_v; +SELECT * FROM columns_backup_v; + +VACUUM ANALYZE; + +/* + * No.9-1 dbms_stats.restore + */ +-- No.9-1-1 +DELETE FROM dbms_stats.relation_stats_locked; +VACUUM dbms_stats.relation_stats_locked; -- in order to avoid auto vacuum +BEGIN; +SELECT * FROM internal_locks; +SELECT dbms_stats.restore(2, 's0.st0', NULL); +SELECT * FROM internal_locks; +COMMIT; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid, attname, stainherit FROM columns_locked_v c; + +-- No.9-1-2 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.restore(2, 'st0', NULL); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid, attname, stainherit FROM columns_locked_v c; + +-- No.9-1-3 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.restore(2, 's00.s0', NULL); +SELECT count(*) FROM dbms_stats.column_stats_locked; +SELECT count(*) FROM dbms_stats.relation_stats_locked; + +-- No.9-1-4 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.restore(NULL, 's0.st0', NULL); +SELECT count(*) FROM dbms_stats.column_stats_locked; +SELECT count(*) FROM dbms_stats.relation_stats_locked; + +-- No.9-1-5 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.restore(2, 's0.st0', 'id'); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid, attname, stainherit FROM columns_locked_v c; + +-- No.9-1-6 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.restore(2, NULL, 'id'); +SELECT count(*) FROM dbms_stats.column_stats_locked; +SELECT count(*) FROM dbms_stats.relation_stats_locked; + +-- No.9-1-7 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.restore(2, 's0.st0', NULL); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid, attname, stainherit FROM columns_locked_v c; + +-- No.9-1-8 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.restore(2, NULL, NULL); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid, attname, stainherit FROM columns_locked_v c; + +-- No.9-1-9 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.restore(0, 's0.st0', NULL); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid, attname, stainherit FROM columns_locked_v c; + +-- No.9-1-10 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.restore(2, 0, 'id'); +SELECT count(*) FROM dbms_stats.column_stats_locked; +SELECT count(*) FROM dbms_stats.relation_stats_locked; + +-- No.9-1-11 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.restore(1, 's0.st0', NULL); +SELECT count(*) FROM dbms_stats.column_stats_locked; +SELECT count(*) FROM dbms_stats.relation_stats_locked; + +-- No.9-1-12 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.restore(2, 's0.st0', 'dummy'); +SELECT count(*) FROM dbms_stats.column_stats_locked; +SELECT count(*) FROM dbms_stats.relation_stats_locked; + +-- No.9-1-13 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.restore(1, 's0.st0', 'id'); +SELECT count(*) FROM dbms_stats.column_stats_locked; +SELECT count(*) FROM dbms_stats.relation_stats_locked; + +-- No.9-1-15 +DELETE FROM dbms_stats.relation_stats_locked; +ALTER TABLE s1.st0 DROP COLUMN id; +SELECT dbms_stats.restore(2, 's1.st0', 'id'); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid, attname, stainherit FROM columns_locked_v c; + +-- No.9-1-14 +DELETE FROM dbms_stats.relation_stats_locked; +\set s1_st0_oid `psql contrib_regression -tA -c "SELECT c.oid FROM pg_class c, pg_namespace n WHERE c.relnamespace = n.oid AND n.nspname = 's1' AND c.relname = 'st0';"` +DROP TABLE s1.st0; +-- SELECT dbms_stats.restore(2, :s1_st0_oid, NULL); +-- To avoid test unstability caused by relation id alloction, the test +-- above is omitted. + +SELECT count(*) FROM dbms_stats.relation_stats_locked; +SELECT count(*) FROM dbms_stats.column_stats_locked; +CREATE TABLE s1.st0(id integer, num integer) WITH (autovacuum_enabled = 'false'); +INSERT INTO s1.st0 VALUES (1, 15), (2, 25), (3, 35), (4, 45); +VACUUM ANALYZE; +-- No.9-1-16 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.restore(2, 's0.st0', NULL); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid, attname, stainherit FROM columns_locked_v c; + +-- No.9-1-17 +DELETE FROM dbms_stats.relation_stats_locked; +INSERT INTO dbms_stats.relation_stats_backup( + id, relid, relname, relpages, reltuples, + relallvisible, + curpages) + VALUES (2, + 'pg_toast.pg_toast_2618'::regclass, + 'pg_toast.pg_toast_2618', 1, 1, + 1, + 1); +SELECT * FROM relations_backup_v + WHERE id = 2 + AND relname = 'pg_toast.pg_toast_2618'; +SELECT dbms_stats.restore(2, 'pg_toast.pg_toast_2618', NULL); +SELECT count(*) FROM dbms_stats.column_stats_locked; +SELECT count(*) FROM dbms_stats.relation_stats_locked; +DELETE FROM dbms_stats.relation_stats_backup + WHERE id = 2 + AND relname = 'pg_toast.pg_toast_2618'; + +-- No.9-1-18 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.restore(2, 's0.st0_idx', NULL); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid, attname, stainherit FROM columns_locked_v c; + +-- No.9-1-19 +DELETE FROM dbms_stats.relation_stats_locked; +INSERT INTO dbms_stats.relation_stats_backup( + id, relid, relname, relpages, reltuples, + relallvisible, + curpages) + VALUES (2, 's0.ss0'::regclass, 's0.ss0', 1, 1, + 1, + 1); +SELECT * FROM relations_backup_v + WHERE id = 2 + AND relname = 's0.ss0'; +SELECT dbms_stats.restore(2, 's0.ss0', NULL); +SELECT count(*) FROM dbms_stats.column_stats_locked; +SELECT count(*) FROM dbms_stats.relation_stats_locked; +DELETE FROM dbms_stats.relation_stats_backup + WHERE id = 2 + AND relname = 's0.ss0'; + +-- No.9-1-20 +DELETE FROM dbms_stats.relation_stats_locked; +INSERT INTO dbms_stats.relation_stats_backup( + id, relid, relname, relpages, reltuples, + relallvisible, + curpages) + VALUES (2, 's0.sc0'::regclass, 's0.sc0', 1, 1, + 1, + 1); +SELECT * FROM relations_backup_v + WHERE id = 2 + AND relname = 's0.sc0'; +SELECT dbms_stats.restore(2, 's0.sc0', NULL); +SELECT count(*) FROM dbms_stats.column_stats_locked; +SELECT count(*) FROM dbms_stats.relation_stats_locked; +DELETE FROM dbms_stats.relation_stats_backup + WHERE id = 2 + AND relname = 's0.sc0'; + +-- No.9-1-21 +DELETE FROM dbms_stats.relation_stats_locked; +INSERT INTO dbms_stats.relation_stats_backup( + id, relid, relname, relpages, reltuples, + relallvisible, + curpages) + VALUES (3, 's0.sft0'::regclass, 's0.sft0', 1, 1, + 1, + 1); +SELECT * FROM relations_backup_v + WHERE id = 3 + AND relname = 's0.sft0'; +SELECT dbms_stats.restore(2, 's0.sft0', NULL); +SELECT count(*) FROM dbms_stats.column_stats_locked; +SELECT count(*) FROM dbms_stats.relation_stats_locked; +DELETE FROM dbms_stats.relation_stats_backup + WHERE id = 3 + AND relname = 's0.sft0'; + +-- No.9-1-22 +DELETE FROM dbms_stats.relation_stats_locked; +INSERT INTO dbms_stats.relation_stats_backup( + id, relid, relname, relpages, reltuples, + relallvisible, + curpages) + VALUES (3, 's0.smv0'::regclass, 's0.smv0', 1, 1, + 1, + 1); +SELECT * FROM relations_backup_v + WHERE id = 3 + AND relname = 's0.smv0'; +SELECT dbms_stats.restore(2, 's0.smv0', NULL); +SELECT count(*) FROM dbms_stats.column_stats_locked; +SELECT count(*) FROM dbms_stats.relation_stats_locked; +DELETE FROM dbms_stats.relation_stats_backup + WHERE id = 3 + AND relname = 's0.smv0'; + +-- No.9-1-23 +DELETE FROM dbms_stats.relation_stats_locked; +INSERT INTO dbms_stats.relation_stats_backup( + id, relid, relname, relpages, reltuples, + relallvisible, + curpages) + VALUES (2, 'pg_catalog.pg_class'::regclass, 'pg_catalog.pg_class', 1, 1, + 1, + 1); +SELECT * FROM relations_backup_v + WHERE id = 2 + AND relname = 'pg_catalog.pg_class'; +SELECT dbms_stats.restore(2, 'pg_catalog.pg_class', NULL); +SELECT count(*) FROM dbms_stats.column_stats_locked; +SELECT count(*) FROM dbms_stats.relation_stats_locked; +DELETE FROM dbms_stats.relation_stats_backup + WHERE id = 2 + AND relname = 'pg_catalog.pg_class'; + +-- No.9-1-24 +DELETE FROM dbms_stats.relation_stats_locked; +INSERT INTO dbms_stats.relation_stats_locked(relid, relname) + VALUES ('s0.st0'::regclass, 's0.st0'); +INSERT INTO dbms_stats.column_stats_locked(starelid, staattnum, stainherit) + SELECT starelid::regclass, staattnum, stainherit + FROM dbms_stats.column_stats_effective + WHERE starelid = 's0.st0'::regclass; +SELECT id, unit, comment FROM dbms_stats.backup_history + WHERE id = 2; +SELECT * FROM columns_locked_v; +SELECT * FROM relations_locked_v; +SELECT dbms_stats.restore(2, 's0.st0', NULL); +SELECT * FROM relations_locked_v; +SELECT * FROM columns_locked_v; + +-- No.9-1-25 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT id, unit, comment FROM dbms_stats.backup_history + WHERE id = 2; +SELECT dbms_stats.restore(2, 's0.st0', NULL); +SELECT * FROM relations_locked_v; +SELECT * FROM columns_locked_v; + +/* + * Stab function dbms_stats.restore + */ +CREATE OR REPLACE FUNCTION dbms_stats.restore( + backup_id int8, + relid regclass DEFAULT NULL, + attname text DEFAULT NULL) +RETURNS SETOF regclass AS +$$ +BEGIN + RAISE NOTICE 'arguments are "%, %, %"', $1, $2, $3; + RETURN QUERY + SELECT c.oid::regclass + FROM pg_class c, dbms_stats.relation_stats_backup b + WHERE (c.oid = $2 OR $2 IS NULL) + AND c.oid = b.relid + AND c.relkind IN ('r', 'i') + AND (b.id <= $1 OR $1 IS NOT NULL) + GROUP BY c.oid + ORDER BY c.oid::regclass::text; +END; +$$ +LANGUAGE plpgsql; + +/* + * No.10-1 dbms_stats.restore_database_stats + */ +-- No.10-1-1 +SELECT dbms_stats.restore_database_stats('2012-02-29 23:59:57'); +-- No.10-1-2 +SELECT dbms_stats.restore_database_stats('2012-02-29 23:59:57.000002'); +-- No.10-1-3 +SELECT dbms_stats.restore_database_stats('2012-01-01 00:00:00'); +--#No.10-1-4 is skipped after lock tests +--#No.10-1-5 is skipped after lock tests +-- No.10-1-6 +SELECT dbms_stats.restore_database_stats('2012-02-29 23:59:57'); + +/* + * No.10-2 dbms_stats.restore_schema_stats + */ +-- No.10-2-1 +SELECT dbms_stats.restore_schema_stats('s0', '2012-02-29 23:59:57'); +-- No.10-2-2 +SELECT dbms_stats.restore_schema_stats('s0', '2012-02-29 23:59:57.000002'); +-- No.10-2-3 +SELECT dbms_stats.restore_schema_stats('s0', '2012-01-01 00:00:00'); +--#No.10-2-4 is skipped after lock tests +--#No.10-2-5 is skipped after lock tests +-- No.10-2-6 +SELECT dbms_stats.restore_schema_stats('s0', '2012-02-29 23:59:57'); +-- No.10-2-7 +SELECT dbms_stats.restore_schema_stats('s0', '2012-02-29 23:59:57'); +--#No.10-2-8 is skipped after lock tests +-- No.10-2-9 +SELECT dbms_stats.restore_schema_stats('s00', '2012-02-29 23:59:57'); +-- No.10-2-10 +SELECT dbms_stats.restore_schema_stats('pg_catalog', '2012-02-29 23:59:57'); + +/* + * No.10-7 dbms_stats.restore_stats + */ +-- No.10-7-1 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.restore_stats(NULL); + +-- No.10-7-2 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.restore_stats(0); + +-- No.10-7-3 +DELETE FROM dbms_stats.relation_stats_locked; +VACUUM dbms_stats.relation_stats_locked; -- in order to avoid auto vacuum +BEGIN; +SELECT * FROM internal_locks; +SELECT dbms_stats.restore_stats(2); +SELECT * FROM internal_locks; +COMMIT; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid, attname, stainherit FROM columns_locked_v c; + +-- No.10-7-4 +DELETE FROM dbms_stats.relation_stats_locked; +INSERT INTO dbms_stats.relation_stats_locked(relid, relname) + SELECT relid::regclass, relname + FROM dbms_stats.relation_stats_effective; +INSERT INTO dbms_stats.column_stats_locked(starelid, staattnum, stainherit) + SELECT starelid::regclass, staattnum, stainherit + FROM dbms_stats.column_stats_effective; +SELECT id, unit, comment FROM dbms_stats.backup_history + WHERE id = 8; +SELECT * FROM columns_locked_v; +SELECT * FROM relations_locked_v; +SELECT dbms_stats.restore_stats(8); +SELECT * FROM relations_locked_v; +SELECT * FROM columns_locked_v; + +-- No.10-7-5 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT id, unit, comment FROM dbms_stats.backup_history + WHERE id = 8; +SELECT dbms_stats.restore_stats(8); +SELECT * FROM relations_locked_v; +SELECT * FROM columns_locked_v; + +/* + * No.11-1 dbms_stats.lock(relid, attname) + */ +-- No.11-1-1 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock(NULL, NULL); +-- No.11-1-2 +ALTER FUNCTION dbms_stats.lock(relid regclass) + RENAME TO truth_lock; +CREATE FUNCTION dbms_stats.lock(relid regclass) +RETURNS regclass AS +$$ +BEGIN + RAISE NOTICE 'arguments are %', $1; + RETURN $1; +END +$$ +LANGUAGE plpgsql; +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('s0.st0', NULL); +DROP FUNCTION dbms_stats.lock(relid regclass); +ALTER FUNCTION dbms_stats.truth_lock(relid regclass) + RENAME TO lock; +-- No.11-1-3 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock(NULL, 'id'); +-- No.11-1-4 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('s0.st0', 'id'); +SELECT * FROM relations_locked_v; +SELECT * FROM columns_locked_v c; +-- No.11-1-5 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock(0, 'id'); +-- No.11-1-6 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('s0.st0', 'id'); +SELECT * FROM relations_locked_v; +SELECT * FROM columns_locked_v c; +-- No.11-1-7 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('pg_toast.pg_toast_2618', 'id'); +-- No.11-1-8 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('s0.st0_idx', 'id'); +-- No.11-1-9 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('st1_exp', 'lower'); +SELECT * FROM relations_locked_v; +SELECT * FROM columns_locked_v c; +DELETE FROM dbms_stats.relation_stats_locked; + +-- No.11-1-10 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('s0.ss0', 'id'); +-- No.11-1-11 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('s0.sc0', 'id'); +-- No.11-1-12 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('s0.sft0', 'id'); +SELECT * FROM relations_locked_v; +SELECT * FROM columns_locked_v c; +-- No.11-1-13 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('s0.smv0', 'id'); +SELECT * FROM relations_locked_v; +SELECT * FROM columns_locked_v c; +-- No.11-1-14 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('pg_catalog.pg_class', 'id'); +-- No.11-1-15 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('s0.st0', 'dummy'); +-- No.11-1-16 +DELETE FROM dbms_stats.relation_stats_locked; +DELETE FROM pg_statistic + WHERE starelid = 's0.st0'::regclass; +SELECT dbms_stats.lock('s0.st0', 'id'); +VACUUM ANALYZE; +-- No.11-1-17 +DELETE FROM dbms_stats.relation_stats_locked; +INSERT INTO dbms_stats.relation_stats_locked( + relid, relname, relpages, reltuples, + relallvisible, + curpages) + VALUES('s0.st0'::regclass, 's0.st0', 1, 1640, + 1, + 1); +SELECT dbms_stats.lock_column_stats('s0.st0','id'); +UPDATE dbms_stats.column_stats_locked + SET (stanullfrac, stawidth, stadistinct, + stakind1, stakind2, stakind3, stakind4, + stakind5, + staop1, staop2, staop3, staop4, + staop5, + stanumbers1, stanumbers2, stanumbers3, stanumbers4, + stanumbers5, + stavalues1, stavalues2, stavalues3, stavalues4 + ,stavalues5 + ) = ( + NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL) + WHERE starelid = 's0.st0'::regclass; +SELECT dbms_stats.lock('s0.st0', 'id'); +SELECT * FROM relations_locked_v; +SELECT * FROM columns_locked_v c; +-- No.11-1-18 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('s0.st0', 'id'); +SELECT * FROM relations_locked_v + WHERE relid = 's0.st0'::regclass; +SELECT starelid, attname, stainherit FROM columns_locked_v c; + +/* + * No.11-2 dbms_stats.lock(relid) + */ +-- No.11-2-1 +DELETE FROM dbms_stats.relation_stats_locked; +VACUUM dbms_stats.relation_stats_locked; -- in order to avoid auto vacuum +BEGIN; +SELECT * FROM internal_locks; +SELECT dbms_stats.lock('s0.st0'); +SELECT * FROM relations_locked_v; +SELECT * FROM columns_locked_v c; +SELECT * FROM internal_locks; +COMMIT; + +-- No.11-2-2 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock(NULL); +-- No.11-2-3 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('0'); +-- No.11-2-4 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('s0.st0'); +SELECT * FROM relations_locked_v; +SELECT * FROM columns_locked_v c; +-- No.11-2-5 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('pg_toast.pg_toast_2618'); +-- No.11-2-6 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('s0.st0_idx'); +SELECT * FROM relations_locked_v; +SELECT * FROM columns_locked_v c; +-- No.11-2-7 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('s0.ss0'); +-- No.11-2-8 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('s0.sc0'); +-- No.11-2-9 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('s0.sft0'); +SELECT * FROM relations_locked_v; +SELECT * FROM columns_locked_v c; +-- No.11-2-10 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('s0.smv0'); +SELECT * FROM relations_locked_v; +SELECT * FROM columns_locked_v c; +-- No.11-2-11 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('pg_catalog.pg_class'); +-- No.11-2-12 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_table_stats('s0.st0'); +UPDATE dbms_stats.relation_stats_locked + SET (relpages, reltuples, + relallvisible, + curpages) + = (NULL, NULL, NULL + ,NULL + ) + WHERE relid = 's0.st0'::regclass; +SELECT dbms_stats.lock('s0.st0'); +SELECT * FROM relations_locked_v; +SELECT * FROM columns_locked_v c; +-- No.11-2-13 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock('s0.st0'); +SELECT * FROM relations_locked_v; +SELECT * FROM columns_locked_v c; + +/* + * Stab function dbms_stats.lock + */ +ALTER FUNCTION dbms_stats.lock(relid regclass) + RENAME TO truth_lock; +CREATE FUNCTION dbms_stats.lock(relid regclass) +RETURNS regclass AS +$$ +BEGIN + RAISE NOTICE 'arguments are %', $1; + RETURN $1; +END +$$ +LANGUAGE plpgsql; + +ALTER FUNCTION dbms_stats.lock(relid regclass, attname text) + RENAME TO truth_lock; +CREATE FUNCTION dbms_stats.lock( + relid regclass, + attname text) +RETURNS regclass AS +$$ +BEGIN + RAISE NOTICE 'arguments are %, %', $1, $2; + RETURN $1; +END +$$ +LANGUAGE plpgsql; + +/* + * No.12-1 dbms_stats.lock_database_stats + */ +-- No.12-1-1 +SELECT dbms_stats.lock_database_stats(); + +/* + * No.12-2 dbms_stats.lock_schema_stats + */ +-- No.12-2-1 +SELECT dbms_stats.lock_schema_stats('s0'); +-- No.12-2-2 +SELECT dbms_stats.lock_schema_stats('s00'); +-- No.12-2-3 +SELECT dbms_stats.lock_schema_stats('pg_catalog'); + +/* + * No.12-3 dbms_stats.lock_table_stats(regclass) + */ +-- No.12-3-1 +SELECT dbms_stats.lock_table_stats('s0.st0'); +-- No.12-3-2 +SELECT dbms_stats.lock_table_stats('st0'); +-- No.12-3-3 +SELECT dbms_stats.lock_table_stats('s00.s0'); + +/* + * No.12-4 dbms_stats.lock_table_stats(schemaname, tablename) + */ +-- No.12-4-1 +SELECT dbms_stats.lock_table_stats('s0', 'st0'); + +/* + * No.12-5 dbms_stats.lock_column_stats(regclass, attname) + */ +-- No.12-5-1 +SELECT dbms_stats.lock_column_stats('s0.st0', 'id'); +-- No.12-5-2 +SELECT dbms_stats.lock_column_stats('st0', 'id'); +-- No.12-5-3 +SELECT dbms_stats.lock_column_stats('s00.s0', 'id'); + +/* + * No.12-6 dbms_stats.lock_column_stats(schemaname, tablename, int2) + */ +-- No.12-6-1 +SELECT dbms_stats.lock_column_stats('s0', 'st0', 'id'); + +/* + * Delete Stab function lock + */ +DROP FUNCTION dbms_stats.lock(relid regclass); +ALTER FUNCTION dbms_stats.truth_lock(relid regclass) + RENAME TO lock; +DROP FUNCTION dbms_stats.lock(relid regclass, attname text); +ALTER FUNCTION dbms_stats.truth_lock(relid regclass, attname text) + RENAME TO lock; + +/* + * No.13-1 dbms_stats.unlock + */ +-- No.13-1-1 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT * FROM dbms_stats.backup_history + ORDER BY id; +SELECT count(*) FROM dbms_stats.relation_stats_backup; +SELECT count(*) FROM dbms_stats.column_stats_backup; +SELECT dbms_stats.unlock(); +SELECT count(*) FROM dbms_stats.relation_stats_locked; +SELECT count(*) FROM dbms_stats.column_stats_locked; +SELECT * FROM dbms_stats.backup_history + ORDER BY id; +SELECT count(*) FROM dbms_stats.relation_stats_backup; +SELECT count(*) FROM dbms_stats.column_stats_backup; + +-- No.13-1-2 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT dbms_stats.unlock(); +SELECT count(*) FROM dbms_stats.relation_stats_locked; +SELECT count(*) FROM dbms_stats.column_stats_locked; + +-- No.13-1-3 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +DELETE FROM dbms_stats.column_stats_locked; +SELECT dbms_stats.unlock(); +SELECT count(*) FROM dbms_stats.relation_stats_locked; +SELECT count(*) FROM dbms_stats.column_stats_locked; + +-- No.13-1-4 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.unlock(); +SELECT count(*) FROM dbms_stats.relation_stats_locked; +SELECT count(*) FROM dbms_stats.column_stats_locked; + +-- No.13-1-5 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; +SELECT dbms_stats.unlock('s0.st0'); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + +-- No.13-1-6 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; +SELECT dbms_stats.unlock('st0'); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + +-- No.13-1-7 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT count(*) FROM dbms_stats.relation_stats_locked; +SELECT count(*) FROM dbms_stats.column_stats_locked; +SELECT dbms_stats.unlock('s00.s0'); +SELECT count(*) FROM dbms_stats.relation_stats_locked; +SELECT count(*) FROM dbms_stats.column_stats_locked; + +-- No.13-1-8 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid, attname, stainherit FROM columns_locked_v c; +SELECT dbms_stats.unlock('s0.st0', 'id'); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid, attname, stainherit FROM columns_locked_v c; + +-- No.13-1-9 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid, attname, stainherit FROM columns_locked_v c; +SELECT dbms_stats.unlock('s0.st0', 'dummy'); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid, attname, stainherit FROM columns_locked_v c; + +-- No.13-1-10 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +DELETE FROM dbms_stats.column_stats_locked; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT dbms_stats.unlock('s0.st0', 'id'); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, staattnum FROM dbms_stats.column_stats_locked + GROUP BY starelid, staattnum + ORDER BY starelid, staattnum; + +-- No.13-1-11 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, staattnum FROM dbms_stats.column_stats_locked + GROUP BY starelid, staattnum + ORDER BY starelid, staattnum; +SELECT dbms_stats.unlock(NULL, 'id'); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, staattnum FROM dbms_stats.column_stats_locked + GROUP BY starelid, staattnum + ORDER BY starelid, staattnum; + +-- No.13-1-12 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, staattnum FROM dbms_stats.column_stats_locked + GROUP BY starelid, staattnum + ORDER BY starelid, staattnum; +SELECT dbms_stats.unlock('s0.st0', NULL); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, staattnum FROM dbms_stats.column_stats_locked + GROUP BY starelid, staattnum + ORDER BY starelid, staattnum; + +-- No.13-1-13 +DELETE FROM dbms_stats.relation_stats_locked; +VACUUM dbms_stats.relation_stats_locked; -- in order to avoid auto vacuum +SELECT dbms_stats.lock_database_stats(); +SELECT count(*) FROM dbms_stats.relation_stats_locked; +SELECT count(*) FROM dbms_stats.column_stats_locked; +BEGIN; +SELECT * FROM internal_locks; +SELECT dbms_stats.unlock(); +SELECT * FROM internal_locks; +COMMIT; +SELECT count(*) FROM dbms_stats.relation_stats_locked; +SELECT count(*) FROM dbms_stats.column_stats_locked; + +/* + * No.14-1 dbms_stats.unlock_database_stats + */ +-- No.14-1-1 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT * FROM dbms_stats.backup_history + ORDER BY id; +SELECT count(*) FROM dbms_stats.relation_stats_backup; +SELECT count(*) FROM dbms_stats.column_stats_backup; +SELECT count(*) FROM dbms_stats.relation_stats_locked; +SELECT count(*) FROM dbms_stats.column_stats_locked; +SELECT dbms_stats.unlock_database_stats(); +SELECT count(*) FROM dbms_stats.relation_stats_locked; +SELECT count(*) FROM dbms_stats.column_stats_locked; +SELECT * FROM dbms_stats.backup_history + ORDER BY id; +SELECT count(*) FROM dbms_stats.relation_stats_backup; +SELECT count(*) FROM dbms_stats.column_stats_backup; + +-- No.14-1-2 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +DELETE FROM dbms_stats.column_stats_locked; +SELECT count(*) FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.unlock_database_stats(); +SELECT count(*) FROM dbms_stats.relation_stats_locked; +SELECT count(*) FROM dbms_stats.column_stats_locked; + +-- No.14-1-3 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.unlock_database_stats(); +SELECT count(*) FROM dbms_stats.relation_stats_locked; +SELECT count(*) FROM dbms_stats.column_stats_locked; + +-- No.14-1-4 +DELETE FROM dbms_stats.relation_stats_locked; +VACUUM dbms_stats.relation_stats_locked; -- in order to avoid auto vacuum +SELECT dbms_stats.lock_database_stats(); +SELECT count(*) FROM dbms_stats.relation_stats_locked; +SELECT count(*) FROM dbms_stats.column_stats_locked; +BEGIN; +SELECT * FROM internal_locks; +SELECT dbms_stats.unlock_database_stats(); +SELECT * FROM internal_locks; +COMMIT; +SELECT count(*) FROM dbms_stats.relation_stats_locked; +SELECT count(*) FROM dbms_stats.column_stats_locked; + +/* + * No.14-2 dbms_stats.unlock_schema_stats + */ +-- No.14-2-1 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT * FROM dbms_stats.backup_history + ORDER BY id; +SELECT count(*) FROM dbms_stats.relation_stats_backup; +SELECT count(*) FROM dbms_stats.column_stats_backup; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; +SELECT dbms_stats.unlock_schema_stats('s0'); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; +SELECT * FROM dbms_stats.backup_history + ORDER BY id; +SELECT count(*) FROM dbms_stats.relation_stats_backup; +SELECT count(*) FROM dbms_stats.column_stats_backup; + +-- No.14-2-2 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +DELETE FROM dbms_stats.column_stats_locked; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; +SELECT dbms_stats.unlock_schema_stats('s0'); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + +-- No.14-2-3 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; +SELECT dbms_stats.unlock_schema_stats('s0'); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + +-- No.14-2-4 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; +SELECT dbms_stats.unlock_schema_stats('s0'); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + +-- No.14-2-5 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; +SELECT dbms_stats.unlock_schema_stats('s00'); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + +-- No.14-2-6 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; +SELECT dbms_stats.unlock_schema_stats('pg_catalog'); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + +-- No.14-2-7 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; +SELECT dbms_stats.unlock_schema_stats(NULL); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + +-- No.14-2-8 +DELETE FROM dbms_stats.relation_stats_locked; +VACUUM dbms_stats.relation_stats_locked; -- in order to avoid auto vacuum +SELECT dbms_stats.lock_database_stats(); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; +BEGIN; +SELECT * FROM internal_locks; +SELECT dbms_stats.unlock_schema_stats('s0'); +SELECT * FROM internal_locks; +COMMIT; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + +/* + * No.14-3 dbms_stats.unlock_table_stats(regclass) + */ +-- No.14-3-1 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT * FROM dbms_stats.backup_history + ORDER BY id; +SELECT count(*) FROM dbms_stats.relation_stats_backup; +SELECT count(*) FROM dbms_stats.column_stats_backup; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; +SELECT dbms_stats.unlock_table_stats('s0.st0'); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; +SELECT * FROM dbms_stats.backup_history + ORDER BY id; +SELECT count(*) FROM dbms_stats.relation_stats_backup; +SELECT count(*) FROM dbms_stats.column_stats_backup; + +-- No.14-3-2 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +DELETE FROM dbms_stats.column_stats_locked; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; +SELECT dbms_stats.unlock_table_stats('s0.st0'); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + +-- No.14-3-3 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; +SELECT dbms_stats.unlock_table_stats('s0.st0'); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + +-- No.14-3-4 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; +SELECT dbms_stats.unlock_table_stats('s0.st0'); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + +-- No.14-3-5 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; +SELECT dbms_stats.unlock_table_stats('st0'); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + +-- No.14-3-6 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; +SELECT dbms_stats.unlock_table_stats('s00.s0'); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + +-- No.14-3-7 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; +SELECT dbms_stats.unlock_table_stats(NULL); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + +-- No.14-3-8 +DELETE FROM dbms_stats.relation_stats_locked; +VACUUM dbms_stats.relation_stats_locked; -- in order to avoid auto vacuum +SELECT dbms_stats.lock_database_stats(); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; +BEGIN; +SELECT * FROM internal_locks; +SELECT dbms_stats.unlock_table_stats('s0.st0'); +SELECT * FROM internal_locks; +COMMIT; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + +/* + * No.14-4 dbms_stats.unlock_table_stats(schemaname, tablename) + */ +-- No.14-4-1 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT * FROM dbms_stats.backup_history + ORDER BY id; +SELECT count(*) FROM dbms_stats.relation_stats_backup; +SELECT count(*) FROM dbms_stats.column_stats_backup; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; +SELECT dbms_stats.unlock_table_stats('s0','st0'); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; +SELECT * FROM dbms_stats.backup_history + ORDER BY id; +SELECT count(*) FROM dbms_stats.relation_stats_backup; +SELECT count(*) FROM dbms_stats.column_stats_backup; + +-- No.14-4-2 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +DELETE FROM dbms_stats.column_stats_locked; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; +SELECT dbms_stats.unlock_table_stats('s0', 'st0'); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + +-- No.14-4-3 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; +SELECT dbms_stats.unlock_table_stats('s0', 'st0'); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + +-- No.14-4-4 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; +SELECT dbms_stats.unlock_table_stats('s0', 'st0'); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + +-- No.14-4-5 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; +SELECT dbms_stats.unlock_table_stats('s00', 's0'); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + +-- No.14-4-6 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; +SELECT dbms_stats.unlock_table_stats(NULL, 'st0'); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + +-- No.14-4-7 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; +SELECT dbms_stats.unlock_table_stats('s0', NULL); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + +-- No.14-4-8 +DELETE FROM dbms_stats.relation_stats_locked; +VACUUM dbms_stats.relation_stats_locked; -- in order to avoid auto vacuum +SELECT dbms_stats.lock_database_stats(); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; +BEGIN; +SELECT * FROM internal_locks; +SELECT dbms_stats.unlock_table_stats('s0', 'st0'); +SELECT * FROM internal_locks; +COMMIT; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid::regclass, count(*) FROM dbms_stats.column_stats_locked + GROUP BY starelid + ORDER BY starelid; + +/* + * No.14-5 dbms_stats.unlock_column_stats(regclass, attname) + */ +-- No.14-5-1 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT * FROM dbms_stats.backup_history + ORDER BY id; +SELECT count(*) FROM dbms_stats.relation_stats_backup; +SELECT count(*) FROM dbms_stats.column_stats_backup; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid, attname, stainherit FROM columns_locked_v c; +SELECT dbms_stats.unlock_column_stats('s0.st0', 'id'); +SELECT starelid, attname, stainherit FROM columns_locked_v c; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT * FROM dbms_stats.backup_history + ORDER BY id; +SELECT count(*) FROM dbms_stats.relation_stats_backup; +SELECT count(*) FROM dbms_stats.column_stats_backup; + +-- No.14-5-2 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +DELETE FROM dbms_stats.column_stats_locked; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT dbms_stats.unlock_column_stats('s0.st0', 'id'); +SELECT count(*) FROM dbms_stats.column_stats_locked; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + +-- No.14-5-3 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid, attname, stainherit FROM columns_locked_v c; +SELECT dbms_stats.unlock_column_stats('s0.st0', 'id'); +SELECT starelid, attname, stainherit FROM columns_locked_v c; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + +-- No.14-5-4 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid, attname, stainherit FROM columns_locked_v c; +SELECT dbms_stats.unlock_column_stats('st0', 'id'); +SELECT starelid, attname, stainherit FROM columns_locked_v c; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + +-- No.14-5-5 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid, attname, stainherit FROM columns_locked_v c; +SELECT dbms_stats.unlock_column_stats('s0.st0', 'dummy'); +SELECT starelid, attname, stainherit FROM columns_locked_v c; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + +-- No.14-5-6 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid, attname, stainherit FROM columns_locked_v c; +SELECT dbms_stats.unlock_column_stats('s00.s0', 'id'); +SELECT starelid, attname, stainherit FROM columns_locked_v c; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + +-- No.14-5-7 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid, attname, stainherit FROM columns_locked_v c; +SELECT dbms_stats.unlock_column_stats(NULL, 'id'); +SELECT starelid, attname, stainherit FROM columns_locked_v c; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + +-- No.14-5-8 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid, attname, stainherit FROM columns_locked_v c; +SELECT dbms_stats.unlock_column_stats('s0.st0', NULL); +SELECT starelid, attname, stainherit FROM columns_locked_v c; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + +-- No.14-5-9 +DELETE FROM dbms_stats.relation_stats_locked; +VACUUM dbms_stats.relation_stats_locked; -- in order to avoid auto vacuum +SELECT dbms_stats.lock_database_stats(); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid, attname, stainherit FROM columns_locked_v c; +BEGIN; +SELECT * FROM internal_locks; +SELECT dbms_stats.unlock_column_stats('s0.st0', 'id'); +SELECT * FROM internal_locks; +COMMIT; +SELECT starelid, attname, stainherit FROM columns_locked_v c; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + +/* + * No.14-6 dbms_stats.unlock_column_stats(schemaname, tablename, attname) + */ +-- No.14-6-1 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT * FROM dbms_stats.backup_history + ORDER BY id; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid, attname, stainherit FROM columns_locked_v c; +SELECT dbms_stats.unlock_column_stats('s0', 'st0', 'id'); +SELECT starelid, attname, stainherit FROM columns_locked_v c; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT * FROM dbms_stats.backup_history + ORDER BY id; +SELECT count(*) FROM dbms_stats.relation_stats_backup; +SELECT count(*) FROM dbms_stats.column_stats_backup; + +-- No.14-6-2 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +DELETE FROM dbms_stats.column_stats_locked; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT dbms_stats.unlock_column_stats('s0', 'st0', 'id'); +SELECT starelid, attname, stainherit FROM columns_locked_v c; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + +-- No.14-6-3 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid, attname, stainherit FROM columns_locked_v c; +SELECT dbms_stats.unlock_column_stats('s0', 'st0', 'id'); +SELECT starelid, attname, stainherit FROM columns_locked_v c; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + +-- No.14-6-4 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid, attname, stainherit FROM columns_locked_v c; +SELECT dbms_stats.unlock_column_stats('s0', 'st0', 'dummy'); +SELECT starelid, attname, stainherit FROM columns_locked_v c; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + +-- No.14-6-5 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid, attname, stainherit FROM columns_locked_v c; +SELECT dbms_stats.unlock_column_stats(NULL, 'st0', 'id'); +SELECT starelid, attname, stainherit FROM columns_locked_v c; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + +-- No.14-6-6 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid, attname, stainherit FROM columns_locked_v c; +SELECT dbms_stats.unlock_column_stats('s0', NULL, 'id'); +SELECT starelid, attname, stainherit FROM columns_locked_v c; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + +-- No.14-6-7 +DELETE FROM dbms_stats.relation_stats_locked; +SELECT dbms_stats.lock_database_stats(); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid, attname, stainherit FROM columns_locked_v c; +SELECT dbms_stats.unlock_column_stats('s0', 'st0', NULL); +SELECT starelid, attname, stainherit FROM columns_locked_v c; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + +-- No.14-6-8 +DELETE FROM dbms_stats.relation_stats_locked; +VACUUM dbms_stats.relation_stats_locked; -- in order to avoid auto vacuum +SELECT dbms_stats.lock_database_stats(); +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; +SELECT starelid, attname, stainherit FROM columns_locked_v c; +BEGIN; +SELECT * FROM internal_locks; +SELECT dbms_stats.unlock_column_stats('s0', 'st0', 'id'); +SELECT * FROM internal_locks; +COMMIT; +SELECT starelid, attname, stainherit FROM columns_locked_v c; +SELECT relid::regclass FROM dbms_stats.relation_stats_locked + GROUP BY relid + ORDER BY relid; + +-- No.15 Make sure that the stats given by pg_dbms_stats doesn't +-- ignored by ACL check +CREATE FUNCTION testfunc() RETURNS TEXT AS $$ +DECLARE + ret text; + v text; +BEGIN + ret = ''; + FOR v IN EXPLAIN SELECT * FROM s0.st4 WHERE a < '000' LOOP + -- mask unnecessary values + v = regexp_replace(v, '(cost|width)=[0-9.]+', E'\\1=xxx', 'g'); + ret = ret || v || E'\n'; + END LOOP; + RETURN ret; +END; +$$ LANGUAGE plpgsql; + +SET pg_dbms_stats.use_locked_stats TO on; +CREATE TABLE s0.st4 (a text) WITH (autovacuum_enabled = 'false'); +INSERT INTO s0.st4 SELECT '1' || md5(g::text) FROM generate_series(1, 10000) as g; +VACUUM ANALYZE s0.st4; +-- should estimate that rows = 1, not 5000 +SELECT testfunc(); +SET pg_dbms_stats.use_locked_stats TO off; +SELECT dbms_stats.lock_table_stats('s0.st4'); +SET pg_dbms_stats.use_locked_stats TO on; +-- should estimate that rows = 1, not 5000 +SELECT testfunc(); +DROP TABLE s0.st4; +SELECT dbms_stats.clean_up_stats(); + +/* + * No.15-2 Ditto for index stats + */ +CREATE TABLE s0.st4 (a double precision) WITH (autovacuum_enabled = 'false'); +CREATE INDEX on s0.st4 (floor(log(a))); +SELECT dbms_stats.lock_table_stats('s0.st4'); +INSERT INTO s0.st4 (SELECT a from GENERATE_SERIES(1, 99999) a); +ANALYZE t1; +SET pg_dbms_stats.use_locked_stats TO off; +SELECT testfunc(); +SET pg_dbms_stats.use_locked_stats TO on; +SELECT testfunc(); +DROP TABLE s0.st4; +DROP FUNCTION testfunc(); +SELECT dbms_stats.clean_up_stats(); + +-- No.16 error description. -- abnormal case. +RESET SESSION AUTHORIZATION; +CREATE TABLE s0.st4 (a int, b text) WITH (autovacuum_enabled = 'false'); +CREATE VIEW s0.vst4 AS select * FROM s0.st4; +GRANT SELECT ON s0.vst4 TO regular_user; + +ALTER TABLE dbms_stats.relation_stats_locked OWNER TO regular_user; +/* reconnection needed to flush cache */ +\c - regular_user + +EXPLAIN (COSTS OFF) SELECT * FROM s0.vst4 WHERE a = 1; + +\c - super_user +ALTER TABLE dbms_stats.relation_stats_locked OWNER TO super_user; +DROP TABLE s0.st4 CASCADE; + +/* + * No.20-1 confirm change at 1.3.5. Moved from ut-common.sql at 1.3.11 + */ +SELECT CURRENT_USER; +CREATE TABLE s0.st4 (a int, b text) WITH (autovacuum_enabled = 'false'); +CREATE INDEX i_st4_a on s0.st4 (a); +CREATE VIEW s0.vst4 AS select * FROM s0.st4; +GRANT SELECT ON s0.vst4 TO regular_user; +INSERT INTO s0.st4 (SELECT a, a::text FROM generate_series(0, 999) a); +ANALYZE s0.st4; +SELECT dbms_stats.lock('s0.st4'); +DELETE FROM s0.st4; +INSERT INTO s0.st4 (SELECT 1, a::text FROM generate_series(0, 999) a); +ANALYZE s0.st4; + +EXPLAIN (COSTS OFF) SELECT * FROM s0.vst4 WHERE a = 1; +EXPLAIN (COSTS OFF) SELECT * FROM s0.st4 WHERE a = 1; + +SET SESSION AUTHORIZATION regular_user; + +EXPLAIN (COSTS OFF) SELECT * FROM s0.st4 WHERE a = 1; +EXPLAIN (COSTS OFF) SELECT * FROM s0.vst4 WHERE a = 1; + +SET pg_dbms_stats.use_locked_stats TO off; +EXPLAIN (COSTS OFF) SELECT * FROM s0.vst4 WHERE a = 1; +\c - super_user +ALTER TABLE dbms_stats.relation_stats_locked OWNER TO super_user; + +SELECT dbms_stats.unlock('s0.st4'); +DROP TABLE s0.st4 CASCADE; From d38416a77a3882c93ca371e6a943f0c36a0f4397 Mon Sep 17 00:00:00 2001 From: kato_s Date: Tue, 10 Dec 2019 05:40:34 +0000 Subject: [PATCH 2/2] fix build for PG12 take 2. --- expected/init-12.out | 4 + expected/ut-12.out | 662 +++++++++++++++++++++--------------- input/ut_imp_exp-12.source | 7 + output/ut_imp_exp-12.source | 371 ++++++++++---------- pg_dbms_stats.c | 21 +- pg_dbms_stats.h | 2 +- sql/init-12.sql | 4 + sql/ut-12.sql | 137 +++++++- 8 files changed, 734 insertions(+), 474 deletions(-) diff --git a/expected/init-12.out b/expected/init-12.out index 477d194..c866cfd 100644 --- a/expected/init-12.out +++ b/expected/init-12.out @@ -37,6 +37,7 @@ SELECT starelid::regclass, staattnum, stainherit, stanullfrac, stawidth, stadistinct, stakind1, stakind2, stakind3, stakind4, stakind5, staop1, staop2, staop3, staop4, staop5, + stacoll1, stacoll2, stacoll3, stacoll4, stacoll5, stanumbers1, stanumbers2, stanumbers3, stanumbers4, stanumbers5, stavalues1::text, stavalues2::text, stavalues3::text, stavalues4::text, stavalues5::text FROM pg_statistic @@ -46,6 +47,7 @@ SELECT starelid::regclass, staattnum, attname, stainherit, stanullfrac, stawidth, stadistinct, stakind1, stakind2, stakind3, stakind4, stakind5, staop1, staop2, staop3, staop4, staop5, + stacoll1, stacoll2, stacoll3, stacoll4, stacoll5, stanumbers1, stanumbers2, stanumbers3, stanumbers4, stanumbers5, stavalues1, stavalues2, stavalues3, stavalues4, stavalues5 FROM dbms_stats.column_stats_locked c @@ -58,6 +60,7 @@ SELECT id, statypid, stanullfrac, stawidth, stadistinct, stakind1, stakind2, stakind3, stakind4, stakind5, staop1, staop2, staop3, staop4, staop5, + stacoll1, stacoll2, stacoll3, stacoll4, stacoll5, stanumbers1, stanumbers2, stanumbers3, stanumbers4, stanumbers5, stavalues1, stavalues2, stavalues3, stavalues4, stavalues5 FROM dbms_stats.column_stats_backup @@ -111,6 +114,7 @@ SELECT nspname, relname, relpages, reltuples, relallvisible, stainherit, stanullfrac, stawidth, stadistinct, stakind1, stakind2, stakind3, stakind4, stakind5, staop1, staop2, staop3, staop4, staop5, + stacoll1, stacoll2, stacoll3, stacoll4, stacoll5, stanumbers1, stanumbers2, stanumbers3, stanumbers4, stanumbers5, stavalues1, stavalues2, stavalues3, stavalues4, stavalues5 FROM dbms_stats.work diff --git a/expected/ut-12.out b/expected/ut-12.out index 7e75dde..8b14d79 100644 --- a/expected/ut-12.out +++ b/expected/ut-12.out @@ -470,6 +470,11 @@ UPDATE pg_statistic SET staop3 = 12, staop4 = 13, staop5 = 15, + stacoll1 = 24, + stacoll2 = 21, + stacoll3 = 22, + stacoll4 = 23, + stacoll5 = 25, stanumbers1 = ARRAY[staattnum,4], stanumbers2 = ARRAY[staattnum,1], stanumbers3 = ARRAY[staattnum,2], @@ -501,6 +506,11 @@ UPDATE dbms_stats.column_stats_locked SET staop3 = 24, staop4 = 21, staop5 = 25, + stacoll1 = 34, + stacoll2 = 31, + stacoll3 = 32, + stacoll4 = 33, + stacoll5 = 35, stanumbers1 = ARRAY[-staattnum,22], stanumbers2 = ARRAY[-staattnum,23], stanumbers3 = ARRAY[-staattnum,24], @@ -523,18 +533,18 @@ CREATE FUNCTION dbms_stats.merge1( LANGUAGE C STABLE; SELECT * FROM columns_locked_v WHERE starelid = 'st0'::regclass; - starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 -----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+---------------------------+-------------------+------------+-----------------------------------+------------------------------------------- - st0 | 1 | id | t | -1 | -1 | -1 | 2 | 3 | 4 | 1 | 5 | 22 | 23 | 24 | 21 | 25 | {-1,22} | {-1,23} | {-1,24} | {-1,21} | {-1,25} | {1,2,1,2,1,2} | {1,2,1,2} | {1,2} | {1,2,1,2,1,2,1,2} | {1,2,1,2,1,2,1,2,1,2} - st0 | 2 | name | t | -2 | -2 | -2 | 2 | 3 | 4 | 1 | 5 | 22 | 23 | 24 | 21 | 25 | {-2,22} | {-2,23} | {-2,24} | {-2,21} | {-2,25} | {"test ","test ","test "} | {"test ","test "} | {"test "} | {"test ","test ","test ","test "} | {"test ","test ","test ","test ","test "} + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+---------------------------+-------------------+------------+-----------------------------------+------------------------------------------- + st0 | 1 | id | t | -1 | -1 | -1 | 2 | 3 | 4 | 1 | 5 | 22 | 23 | 24 | 21 | 25 | 34 | 31 | 32 | 33 | 35 | {-1,22} | {-1,23} | {-1,24} | {-1,21} | {-1,25} | {1,2,1,2,1,2} | {1,2,1,2} | {1,2} | {1,2,1,2,1,2,1,2} | {1,2,1,2,1,2,1,2,1,2} + st0 | 2 | name | t | -2 | -2 | -2 | 2 | 3 | 4 | 1 | 5 | 22 | 23 | 24 | 21 | 25 | 34 | 31 | 32 | 33 | 35 | {-2,22} | {-2,23} | {-2,24} | {-2,21} | {-2,25} | {"test ","test ","test "} | {"test ","test "} | {"test "} | {"test ","test ","test ","test "} | {"test ","test ","test ","test ","test "} (2 rows) SELECT * FROM plain_columns_statistic_v WHERE starelid = 'st0'::regclass; - starelid | staattnum | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 -----------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+-------------------+---------------------------+-----------------------------------+------------------------------------------- - st0 | 1 | f | 1 | 1 | 1 | 4 | 1 | 2 | 3 | 5 | 14 | 11 | 12 | 13 | 15 | {1,4} | {1,1} | {1,2} | {1,3} | {1,5} | {1,2} | {1,2,1,2} | {1,2,1,2,1,2} | {1,2,1,2,1,2,1,2} | {1,2,1,2,1,2,1,2,1,2} - st0 | 2 | f | 2 | 2 | 2 | 4 | 1 | 2 | 3 | 5 | 14 | 11 | 12 | 13 | 15 | {2,4} | {2,1} | {2,2} | {2,3} | {2,5} | {"test "} | {"test ","test "} | {"test ","test ","test "} | {"test ","test ","test ","test "} | {"test ","test ","test ","test ","test "} + starelid | staattnum | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------+-------------------+---------------------------+-----------------------------------+------------------------------------------- + st0 | 1 | f | 1 | 1 | 1 | 4 | 1 | 2 | 3 | 5 | 14 | 11 | 12 | 13 | 15 | 24 | 21 | 22 | 23 | 25 | {1,4} | {1,1} | {1,2} | {1,3} | {1,5} | {1,2} | {1,2,1,2} | {1,2,1,2,1,2} | {1,2,1,2,1,2,1,2} | {1,2,1,2,1,2,1,2,1,2} + st0 | 2 | f | 2 | 2 | 2 | 4 | 1 | 2 | 3 | 5 | 14 | 11 | 12 | 13 | 15 | 24 | 21 | 22 | 23 | 25 | {2,4} | {2,1} | {2,2} | {2,3} | {2,5} | {"test "} | {"test ","test "} | {"test ","test ","test "} | {"test ","test ","test ","test "} | {"test ","test ","test ","test ","test "} (2 rows) SET client_min_messages TO LOG; @@ -555,6 +565,11 @@ SELECT (m.merge).starelid::regclass, (m.merge).staop3, (m.merge).staop4, (m.merge).staop5, + (m.merge).stacoll1, + (m.merge).stacoll2, + (m.merge).stacoll3, + (m.merge).stacoll4, + (m.merge).stacoll5, (m.merge).stanumbers1, (m.merge).stanumbers2, (m.merge).stanumbers3, @@ -569,9 +584,9 @@ SELECT (m.merge).starelid::regclass, FROM pg_statistic s WHERE starelid = 'st0'::regclass AND staattnum = '1'::int2) m; - starelid | staattnum | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 -----------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+---------------+-------------------+----------------------- - st0 | 1 | f | 1 | 1 | 1 | 4 | 1 | 2 | 3 | 5 | 14 | 11 | 12 | 13 | 15 | {1,4} | {1,1} | {1,2} | {1,3} | {1,5} | {1,2} | {1,2,1,2} | {1,2,1,2,1,2} | {1,2,1,2,1,2,1,2} | {1,2,1,2,1,2,1,2,1,2} + starelid | staattnum | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------+------------+---------------+-------------------+----------------------- + st0 | 1 | f | 1 | 1 | 1 | 4 | 1 | 2 | 3 | 5 | 14 | 11 | 12 | 13 | 15 | 24 | 21 | 22 | 23 | 25 | {1,4} | {1,1} | {1,2} | {1,3} | {1,5} | {1,2} | {1,2,1,2} | {1,2,1,2,1,2} | {1,2,1,2,1,2,1,2} | {1,2,1,2,1,2,1,2,1,2} (1 row) -- No.5-1-2 @@ -591,6 +606,11 @@ SELECT (m.merge).starelid::regclass, (m.merge).staop3, (m.merge).staop4, (m.merge).staop5, + (m.merge).stacoll1, + (m.merge).stacoll2, + (m.merge).stacoll3, + (m.merge).stacoll4, + (m.merge).stacoll5, (m.merge).stanumbers1, (m.merge).stanumbers2, (m.merge).stanumbers3, @@ -605,9 +625,9 @@ SELECT (m.merge).starelid::regclass, FROM dbms_stats.column_stats_locked v WHERE starelid = 'st0'::regclass AND staattnum = '2'::int2) m; - starelid | staattnum | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 -----------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+---------------------------+-------------------+------------+-----------------------------------+------------------------------------------- - st0 | 2 | t | -2 | -2 | -2 | 2 | 3 | 4 | 1 | 5 | 22 | 23 | 24 | 21 | 25 | {-2,22} | {-2,23} | {-2,24} | {-2,21} | {-2,25} | {"test ","test ","test "} | {"test ","test "} | {"test "} | {"test ","test ","test ","test "} | {"test ","test ","test ","test ","test "} + starelid | staattnum | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+---------------------------+-------------------+------------+-----------------------------------+------------------------------------------- + st0 | 2 | t | -2 | -2 | -2 | 2 | 3 | 4 | 1 | 5 | 22 | 23 | 24 | 21 | 25 | 34 | 31 | 32 | 33 | 35 | {-2,22} | {-2,23} | {-2,24} | {-2,21} | {-2,25} | {"test ","test ","test "} | {"test ","test "} | {"test "} | {"test ","test ","test ","test "} | {"test ","test ","test ","test ","test "} (1 row) -- No.5-1-3 @@ -634,6 +654,11 @@ SELECT (m.merge).starelid::regclass, (m.merge).staop3, (m.merge).staop4, (m.merge).staop5, + (m.merge).stacoll1, + (m.merge).stacoll2, + (m.merge).stacoll3, + (m.merge).stacoll4, + (m.merge).stacoll5, (m.merge).stanumbers1, (m.merge).stanumbers2, (m.merge).stanumbers3, @@ -651,9 +676,9 @@ SELECT (m.merge).starelid::regclass, AND v.staattnum = '2'::int2 AND s.starelid = 'st0'::regclass AND s.staattnum = '1'::int2) m; - starelid | staattnum | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 -----------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+---------------------------+-------------------+------------+-----------------------------------+------------------------------------------- - st0 | 2 | t | -2 | -2 | -2 | 2 | 3 | 4 | 1 | 5 | 22 | 23 | 24 | 21 | 25 | {-2,22} | {-2,23} | {-2,24} | {-2,21} | {-2,25} | {"test ","test ","test "} | {"test ","test "} | {"test "} | {"test ","test ","test ","test "} | {"test ","test ","test ","test ","test "} + starelid | staattnum | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+---------------------------+-------------------+------------+-----------------------------------+------------------------------------------- + st0 | 2 | t | -2 | -2 | -2 | 2 | 3 | 4 | 1 | 5 | 22 | 23 | 24 | 21 | 25 | 34 | 31 | 32 | 33 | 35 | {-2,22} | {-2,23} | {-2,24} | {-2,21} | {-2,25} | {"test ","test ","test "} | {"test ","test "} | {"test "} | {"test ","test ","test ","test "} | {"test ","test ","test ","test ","test "} (1 row) -- No.5-1-5 @@ -673,6 +698,11 @@ SELECT (m.merge).starelid::regclass, (m.merge).staop3, (m.merge).staop4, (m.merge).staop5, + (m.merge).stacoll1, + (m.merge).stacoll2, + (m.merge).stacoll3, + (m.merge).stacoll4, + (m.merge).stacoll5, (m.merge).stanumbers1, (m.merge).stanumbers2, (m.merge).stanumbers3, @@ -690,9 +720,9 @@ SELECT (m.merge).starelid::regclass, AND v.staattnum = '2'::int2 AND s.starelid = 'st0'::regclass AND s.staattnum = '1'::int2) m; - starelid | staattnum | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 -----------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+---------------------------+-------------------+------------+-----------------------------------+------------------------------------------- - st0 | 2 | t | -2 | -2 | -2 | 2 | 3 | 4 | 1 | 5 | 22 | 23 | 24 | 21 | 25 | {-2,22} | {-2,23} | {-2,24} | {-2,21} | {-2,25} | {"test ","test ","test "} | {"test ","test "} | {"test "} | {"test ","test ","test ","test "} | {"test ","test ","test ","test ","test "} + starelid | staattnum | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+---------------------------+-------------------+------------+-----------------------------------+------------------------------------------- + st0 | 2 | t | -2 | -2 | -2 | 2 | 3 | 4 | 1 | 5 | 22 | 23 | 24 | 21 | 25 | 34 | 31 | 32 | 33 | 35 | {-2,22} | {-2,23} | {-2,24} | {-2,21} | {-2,25} | {"test ","test ","test "} | {"test ","test "} | {"test "} | {"test ","test ","test ","test "} | {"test ","test ","test ","test ","test "} (1 row) -- No.5-1-6 @@ -712,7 +742,8 @@ SELECT dbms_stats.merge(NULL, ( s.stakind5, s.staop1, s.staop2, s.staop3, s.staop4, - NULL, s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, + NULL, stacoll1, stacoll2, stacoll3, stacoll4, stacoll5, + s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, s.stanumbers5, s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 ,s.stavalues5 @@ -720,10 +751,11 @@ SELECT dbms_stats.merge(NULL, ( FROM pg_statistic s WHERE s.starelid = 'st0'::regclass AND s.staattnum = '1'::int2; -ERROR: cannot cast type record to pg_statistic -LINE 8: NULL, s.stanumbers1, s.stanumbers2, s.stanumbers3, s.... - ^ -DETAIL: Cannot cast type real[] to oid in column 17. + merge +-------- + (null) +(1 row) + -- No.5-1-8 SELECT (m.merge).starelid::regclass, (m.merge).staattnum, @@ -741,6 +773,11 @@ SELECT (m.merge).starelid::regclass, (m.merge).staop3, (m.merge).staop4, (m.merge).staop5, + (m.merge).stacoll1, + (m.merge).stacoll2, + (m.merge).stacoll3, + (m.merge).stacoll4, + (m.merge).stacoll5, (m.merge).stanumbers1, (m.merge).stanumbers2, (m.merge).stanumbers3, @@ -758,6 +795,8 @@ SELECT (m.merge).starelid::regclass, s.stakind5, s.staop1, s.staop2, s.staop3, s.staop4, s.staop5, + s.stacoll1, s.stacoll2, s.stacoll3, s.stacoll4, + s.stacoll5, NULL, s.stanumbers2, s.stanumbers3, s.stanumbers4, s.stanumbers5, s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 @@ -766,10 +805,11 @@ SELECT (m.merge).starelid::regclass, FROM pg_statistic s WHERE s.starelid = 'st0'::regclass AND s.staattnum = '1'::int2) m; -ERROR: cannot cast type record to pg_statistic -LINE 34: NULL, s.stanumbers2, s.stanumbers3, s.stanumbe... - ^ -DETAIL: Cannot cast type real[] to oid in column 18. + starelid | staattnum | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------+------------+---------------+-------------------+----------------------- + st0 | 1 | f | 1 | 1 | 1 | 4 | 1 | 2 | 3 | 5 | 14 | 11 | 12 | 13 | 15 | 24 | 21 | 22 | 23 | 25 | (null) | {1,1} | {1,2} | {1,3} | {1,5} | {1,2} | {1,2,1,2} | {1,2,1,2,1,2} | {1,2,1,2,1,2,1,2} | {1,2,1,2,1,2,1,2,1,2} +(1 row) + -- No.5-1-9 SELECT dbms_stats.merge(( v.starelid::regclass, v.staattnum, v.stainherit, @@ -778,7 +818,9 @@ SELECT dbms_stats.merge(( v.stakind5, v.staop1, v.staop2, v.staop3, v.staop4, - NULL, v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, + NULL, v.stacoll1, v.stacoll2, v.stacoll3, v.stacoll4, + v.stacoll5, + v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, v.stanumbers5, v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 ,v.stavalues5 @@ -786,10 +828,11 @@ SELECT dbms_stats.merge(( FROM dbms_stats.column_stats_locked v WHERE v.starelid = 'st0'::regclass AND v.staattnum = '2'::int2; -ERROR: cannot cast type record to dbms_stats.column_stats_locked -LINE 8: NULL, v.stanumbers1, v.stanumbers2, v.stanumbers3, v.... - ^ -DETAIL: Cannot cast type real[] to oid in column 17. + merge +-------- + (null) +(1 row) + -- No.5-1-10 SELECT (m.merge).starelid::regclass, (m.merge).staattnum, @@ -807,6 +850,11 @@ SELECT (m.merge).starelid::regclass, (m.merge).staop3, (m.merge).staop4, (m.merge).staop5, + (m.merge).stacoll1, + (m.merge).stacoll2, + (m.merge).stacoll3, + (m.merge).stacoll4, + (m.merge).stacoll5, (m.merge).stanumbers1, (m.merge).stanumbers2, (m.merge).stanumbers3, @@ -824,6 +872,7 @@ SELECT (m.merge).starelid::regclass, v.stakind5, v.staop1, v.staop2, v.staop3, v.staop4, v.staop5, + v.stacoll1, v.stacoll2, v.stacoll3, v.stacoll4, v.stacoll5, NULL, v.stanumbers2, v.stanumbers3, v.stanumbers4, v.stanumbers5, v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 @@ -832,10 +881,11 @@ SELECT (m.merge).starelid::regclass, FROM dbms_stats.column_stats_locked v WHERE v.starelid = 'st0'::regclass AND v.staattnum = '2'::int2) m; -ERROR: cannot cast type record to dbms_stats.column_stats_locked -LINE 34: NULL, v.stanumbers2, v.stanumbers3, v.stanumbe... - ^ -DETAIL: Cannot cast type real[] to oid in column 18. + starelid | staattnum | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+---------------------------+-------------------+------------+-----------------------------------+------------------------------------------- + st0 | 2 | t | -2 | -2 | -2 | 2 | 3 | 4 | 1 | 5 | 22 | 23 | 24 | 21 | 25 | 34 | 31 | 32 | 33 | 35 | (null) | {-2,23} | {-2,24} | {-2,21} | {-2,25} | {"test ","test ","test "} | {"test ","test "} | {"test "} | {"test ","test ","test ","test "} | {"test ","test ","test ","test ","test "} +(1 row) + -- No.5-1-11 SELECT dbms_stats.merge(( v.starelid::regclass, v.staattnum, v.stainherit, @@ -844,10 +894,11 @@ SELECT dbms_stats.merge(( v.stakind5, v.staop1, v.staop2, v.staop3, v.staop4, - NULL, v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, + NULL, v.stacoll1, v.stacoll2, v.stacoll3, v.stacoll4, v.stacoll5, + v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, v.stanumbers5, - v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 - ,v.stavalues5 + v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4, + v.stavalues5 ), ( s.starelid::regclass, s.staattnum, s.stainherit, s.stanullfrac, s.stawidth, s.stadistinct, @@ -855,10 +906,11 @@ SELECT dbms_stats.merge(( s.stakind5, s.staop1, s.staop2, s.staop3, s.staop4, - NULL, s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, + NULL, s.stacoll1, s.stacoll2, s.stacoll3, s.stacoll4, s.stacoll5, + s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, s.stanumbers5, - s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 - ,s.stavalues5 + s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4, + s.stavalues5 )) FROM dbms_stats.column_stats_locked v, pg_statistic s @@ -866,10 +918,13 @@ SELECT dbms_stats.merge(( AND v.staattnum = '2'::int2 AND s.starelid = 'st0'::regclass AND s.staattnum = '1'::int2; -ERROR: cannot cast type record to dbms_stats.column_stats_locked -LINE 8: NULL, v.stanumbers1, v.stanumbers2, v.stanumbers3, v.... - ^ -DETAIL: Cannot cast type real[] to oid in column 17. +LOG: pg_dbms_stats: bad statistics +DETAIL: column "staop5" should not be null + merge +-------- + (null) +(1 row) + -- No.5-1-12 SELECT (m.merge).starelid::regclass, (m.merge).staattnum, @@ -887,6 +942,11 @@ SELECT (m.merge).starelid::regclass, (m.merge).staop3, (m.merge).staop4, (m.merge).staop5, + (m.merge).stacoll1, + (m.merge).stacoll2, + (m.merge).stacoll3, + (m.merge).stacoll4, + (m.merge).stacoll5, (m.merge).stanumbers1, (m.merge).stanumbers2, (m.merge).stanumbers3, @@ -904,10 +964,11 @@ SELECT (m.merge).starelid::regclass, v.stakind5, v.staop1, v.staop2, v.staop3, v.staop4, v.staop5, + v.stacoll1, v.stacoll2, v.stacoll3, v.stacoll4, + v.stacoll5, NULL, v.stanumbers2, v.stanumbers3, v.stanumbers4, v.stanumbers5, - v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 - ,v.stavalues5 + v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4,v.stavalues5 ), ( s.starelid::regclass, s.staattnum, s.stainherit, s.stanullfrac, s.stawidth, s.stadistinct, @@ -915,7 +976,9 @@ SELECT (m.merge).starelid::regclass, s.stakind5, s.staop1, s.staop2, s.staop3, s.staop4, s.staop5, - NULL, s.stanumbers2, s.stanumbers3, s.stanumbers4, + s.stacoll1, s.stacoll2, s.stacoll3, s.stacoll4, s.stacoll5, + NULL, + s.stanumbers2, s.stanumbers3, s.stanumbers4, s.stanumbers5, s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 ,s.stavalues5 @@ -926,10 +989,11 @@ SELECT (m.merge).starelid::regclass, AND v.staattnum = '2'::int2 AND s.starelid = 'st0'::regclass AND s.staattnum = '1'::int2) m; -ERROR: cannot cast type record to dbms_stats.column_stats_locked -LINE 34: NULL, v.stanumbers2, v.stanumbers3, v.stanumbe... - ^ -DETAIL: Cannot cast type real[] to oid in column 18. + starelid | staattnum | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+---------------------------+-------------------+------------+-----------------------------------+------------------------------------------- + st0 | 2 | t | -2 | -2 | -2 | 2 | 3 | 4 | 1 | 5 | 22 | 23 | 24 | 21 | 25 | 34 | 31 | 32 | 33 | 35 | (null) | {-2,23} | {-2,24} | {-2,21} | {-2,25} | {"test ","test ","test "} | {"test ","test "} | {"test "} | {"test ","test ","test ","test "} | {"test ","test ","test ","test ","test "} +(1 row) + -- No.5-1-13 SELECT (m.merge).starelid::regclass, (m.merge).staattnum, @@ -947,6 +1011,11 @@ SELECT (m.merge).starelid::regclass, (m.merge).staop3, (m.merge).staop4, (m.merge).staop5, + (m.merge).stacoll1, + (m.merge).stacoll2, + (m.merge).stacoll3, + (m.merge).stacoll4, + (m.merge).stacoll5, (m.merge).stanumbers1, (m.merge).stanumbers2, (m.merge).stanumbers3, @@ -961,6 +1030,7 @@ SELECT (m.merge).starelid::regclass, 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 @@ -969,10 +1039,11 @@ SELECT (m.merge).starelid::regclass, FROM pg_statistic s WHERE s.starelid = 'st0'::regclass AND s.staattnum = '1'::int2) m; -ERROR: cannot cast type record to dbms_stats.column_stats_locked -LINE 27: FROM (SELECT dbms_stats.merge(( - ^ -DETAIL: Input has too few columns. + starelid | staattnum | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------+------------+---------------+-------------------+----------------------- + st0 | 1 | f | 1 | 1 | 1 | 4 | 1 | 2 | 3 | 5 | 14 | 11 | 12 | 13 | 15 | 24 | 21 | 22 | 23 | 25 | {1,4} | {1,1} | {1,2} | {1,3} | {1,5} | {1,2} | {1,2,1,2} | {1,2,1,2,1,2} | {1,2,1,2,1,2,1,2} | {1,2,1,2,1,2,1,2,1,2} +(1 row) + -- No.5-1-14 SELECT (m.merge).starelid::regclass, (m.merge).staattnum, @@ -990,6 +1061,11 @@ SELECT (m.merge).starelid::regclass, (m.merge).staop3, (m.merge).staop4, (m.merge).staop5, + (m.merge).stacoll1, + (m.merge).stacoll2, + (m.merge).stacoll3, + (m.merge).stacoll4, + (m.merge).stacoll5, (m.merge).stanumbers1, (m.merge).stanumbers2, (m.merge).stanumbers3, @@ -1004,6 +1080,7 @@ SELECT (m.merge).starelid::regclass, 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, @@ -1011,10 +1088,11 @@ SELECT (m.merge).starelid::regclass, FROM dbms_stats.column_stats_locked v WHERE v.starelid = 'st0'::regclass AND v.staattnum = '2'::int2) m; -ERROR: cannot cast type record to pg_statistic -LINE 27: FROM (SELECT dbms_stats.merge(v, ( - ^ -DETAIL: Input has too few columns. + starelid | staattnum | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+---------------------------+-------------------+------------+-----------------------------------+------------------------------------------- + st0 | 2 | t | -2 | -2 | -2 | 2 | 3 | 4 | 1 | 5 | 22 | 23 | 24 | 21 | 25 | 34 | 31 | 32 | 33 | 35 | {-2,22} | {-2,23} | {-2,24} | {-2,21} | {-2,25} | {"test ","test ","test "} | {"test ","test "} | {"test "} | {"test ","test ","test ","test "} | {"test ","test ","test ","test ","test "} +(1 row) + -- No.5-1-15 SELECT (m.merge).starelid::regclass, (m.merge).staattnum, @@ -1032,6 +1110,11 @@ SELECT (m.merge).starelid::regclass, (m.merge).staop3, (m.merge).staop4, (m.merge).staop5, + (m.merge).stacoll1, + (m.merge).stacoll2, + (m.merge).stacoll3, + (m.merge).stacoll4, + (m.merge).stacoll5, (m.merge).stanumbers1, (m.merge).stanumbers2, (m.merge).stanumbers3, @@ -1049,9 +1132,9 @@ SELECT (m.merge).starelid::regclass, AND v.staattnum = '2'::int2 AND s.starelid = 'st0'::regclass AND s.staattnum = '1'::int2) m; - starelid | staattnum | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 -----------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+---------------------------+-------------------+------------+-----------------------------------+------------------------------------------- - st0 | 2 | t | -2 | -2 | -2 | 2 | 3 | 4 | 1 | 5 | 22 | 23 | 24 | 21 | 25 | {-2,22} | {-2,23} | {-2,24} | {-2,21} | {-2,25} | {"test ","test ","test "} | {"test ","test "} | {"test "} | {"test ","test ","test ","test "} | {"test ","test ","test ","test ","test "} + starelid | staattnum | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+---------------------------+-------------------+------------+-----------------------------------+------------------------------------------- + st0 | 2 | t | -2 | -2 | -2 | 2 | 3 | 4 | 1 | 5 | 22 | 23 | 24 | 21 | 25 | 34 | 31 | 32 | 33 | 35 | {-2,22} | {-2,23} | {-2,24} | {-2,21} | {-2,25} | {"test ","test ","test "} | {"test ","test "} | {"test "} | {"test ","test ","test ","test "} | {"test ","test ","test ","test ","test "} (1 row) -- No.5-1-16 @@ -1059,6 +1142,7 @@ SELECT dbms_stats.merge(( v.starelid::regclass, v.staattnum, v.stainherit, v.stanullfrac, v.stawidth, v.stadistinct, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL @@ -1067,6 +1151,7 @@ SELECT dbms_stats.merge(( s.starelid::regclass, s.staattnum, s.stainherit, s.stanullfrac, s.stawidth, s.stadistinct, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, @@ -1077,10 +1162,13 @@ SELECT dbms_stats.merge(( AND v.staattnum = '2'::int2 AND s.starelid = 'st0'::regclass AND s.staattnum = '1'::int2; -ERROR: cannot cast type record to dbms_stats.column_stats_locked -LINE 1: SELECT dbms_stats.merge(( - ^ -DETAIL: Input has too few columns. +LOG: pg_dbms_stats: bad statistics +DETAIL: column "stakind1" should not be null + merge +-------- + (null) +(1 row) + -- No.5-1-17 SELECT (m.merge).starelid::regclass, (m.merge).staattnum, @@ -1098,6 +1186,11 @@ SELECT (m.merge).starelid::regclass, (m.merge).staop3, (m.merge).staop4, (m.merge).staop5, + (m.merge).stacoll1, + (m.merge).stacoll2, + (m.merge).stacoll3, + (m.merge).stacoll4, + (m.merge).stacoll5, (m.merge).stanumbers1, (m.merge).stanumbers2, (m.merge).stanumbers3, @@ -1113,9 +1206,9 @@ SELECT (m.merge).starelid::regclass, v.stanullfrac, v.stawidth, v.stadistinct, v.stakind1, v.stakind2, v.stakind3, v.stakind4, v.stakind5, - v.staop1, v.staop2, v.staop3, - v.staop4, - NULL, v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, + v.staop1, v.staop2, v.staop3, v.staop4, NULL, + v.stacoll1, v.stacoll2, v.stacoll3, v.stacoll4, v.stacoll5, + v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, v.stanumbers5, v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 ,v.stavalues5 @@ -1126,6 +1219,7 @@ SELECT (m.merge).starelid::regclass, s.stakind5, s.staop1, s.staop2, s.staop3, s.staop4, s.staop5, + s.stacoll1, s.stacoll2, s.stacoll3, s.stacoll4, s.stacoll5, s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, s.stanumbers5, s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 @@ -1137,10 +1231,11 @@ SELECT (m.merge).starelid::regclass, AND v.staattnum = '1'::int2 AND s.starelid = 'st0'::regclass AND s.staattnum = '1'::int2) m; -ERROR: cannot cast type record to dbms_stats.column_stats_locked -LINE 34: NULL, v.stanumbers1, v.stanumbers2, v.stanumbe... - ^ -DETAIL: Cannot cast type real[] to oid in column 17. + starelid | staattnum | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------+------------+---------------+-------------------+----------------------- + st0 | 1 | t | -1 | -1 | -1 | 4 | 1 | 2 | 3 | 5 | 14 | 11 | 12 | 13 | 15 | 24 | 21 | 22 | 23 | 25 | {1,4} | {1,1} | {1,2} | {1,3} | {1,5} | {1,2} | {1,2,1,2} | {1,2,1,2,1,2} | {1,2,1,2,1,2,1,2} | {1,2,1,2,1,2,1,2,1,2} +(1 row) + -- No.5-1-18 SELECT dbms_stats.merge(( v.starelid::regclass, v.staattnum, v.stainherit, @@ -1148,8 +1243,9 @@ SELECT dbms_stats.merge(( v.stakind1, v.stakind2, v.stakind3, v.stakind4, v.stakind5, v.staop1, v.staop2, v.staop3, - v.staop4, - NULL, v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, + v.staop4, NULL, + v.stacoll1, v.stacoll2, v.stacoll3, v.stacoll4, v.stacoll5, + v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, v.stanumbers5, v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 ,v.stavalues5 @@ -1159,8 +1255,9 @@ SELECT dbms_stats.merge(( s.stakind1, s.stakind2, s.stakind3, s.stakind4, s.stakind5, s.staop1, s.staop2, s.staop3, - s.staop4, - NULL, s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, + s.staop4, NULL, + s.stacoll1, s.stacoll2, s.stacoll3, s.stacoll4, s.stacoll5, + s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, s.stanumbers5, s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 ,s.stavalues5 @@ -1171,10 +1268,13 @@ SELECT dbms_stats.merge(( AND v.staattnum = '1'::int2 AND s.starelid = 'st0'::regclass AND s.staattnum = '1'::int2; -ERROR: cannot cast type record to dbms_stats.column_stats_locked -LINE 8: NULL, v.stanumbers1, v.stanumbers2, v.stanumbers3, v.... - ^ -DETAIL: Cannot cast type real[] to oid in column 17. +LOG: pg_dbms_stats: bad statistics +DETAIL: column "staop5" should not be null + merge +-------- + (null) +(1 row) + -- No.5-1-19 SELECT (m.merge).starelid::regclass, (m.merge).staattnum, @@ -1192,6 +1292,11 @@ SELECT (m.merge).starelid::regclass, (m.merge).staop3, (m.merge).staop4, (m.merge).staop5, + (m.merge).stacoll1, + (m.merge).stacoll2, + (m.merge).stacoll3, + (m.merge).stacoll4, + (m.merge).stacoll5, (m.merge).stanumbers1, (m.merge).stanumbers2, (m.merge).stanumbers3, @@ -1209,6 +1314,7 @@ SELECT (m.merge).starelid::regclass, '1', v.staop1, v.staop2, v.staop3, v.staop4, v.staop5, + v.stacoll1, v.stacoll2, v.stacoll3, v.stacoll4, v.stacoll5, v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, v.stanumbers5, v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 @@ -1220,6 +1326,7 @@ SELECT (m.merge).starelid::regclass, '1', s.staop1, s.staop2, s.staop3, s.staop4, s.staop5, + s.stacoll1, s.stacoll2, s.stacoll3, s.stacoll4, s.stacoll5, s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, s.stanumbers5, s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 @@ -1231,10 +1338,11 @@ SELECT (m.merge).starelid::regclass, AND v.staattnum = '2'::int2 AND s.starelid = 'st0'::regclass AND s.staattnum = '1'::int2) m; -ERROR: cannot cast type record to dbms_stats.column_stats_locked -LINE 34: v.stanumbers1, v.stanumbers2, v.stanumbers3, v... - ^ -DETAIL: Cannot cast type real[] to oid in column 17. + starelid | staattnum | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+---------------------------+-------------------+------------+-----------------------------------+------------------------------------------- + st0 | 2 | t | -2 | -2 | -2 | 1 | 1 | 1 | 1 | 1 | 22 | 23 | 24 | 21 | 25 | 34 | 31 | 32 | 33 | 35 | {-2,22} | {-2,23} | {-2,24} | {-2,21} | {-2,25} | {"test ","test ","test "} | {"test ","test "} | {"test "} | {"test ","test ","test ","test "} | {"test ","test ","test ","test ","test "} +(1 row) + -- No.5-1-20 SELECT (m.merge).starelid::regclass, (m.merge).staattnum, @@ -1252,6 +1360,11 @@ SELECT (m.merge).starelid::regclass, (m.merge).staop3, (m.merge).staop4, (m.merge).staop5, + (m.merge).stacoll1, + (m.merge).stacoll2, + (m.merge).stacoll3, + (m.merge).stacoll4, + (m.merge).stacoll5, (m.merge).stanumbers1, (m.merge).stanumbers2, (m.merge).stanumbers3, @@ -1268,6 +1381,7 @@ SELECT (m.merge).starelid::regclass, '2', v.staop1, v.staop2, v.staop3, v.staop4, v.staop5, + v.stacoll1, v.stacoll2, v.stacoll3, v.stacoll4, v.stacoll5, v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, v.stanumbers5, v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 @@ -1279,6 +1393,7 @@ SELECT (m.merge).starelid::regclass, '2', s.staop1, s.staop2, s.staop3, s.staop4, s.staop5, + s.stacoll1, s.stacoll2, s.stacoll3, s.stacoll4, s.stacoll5, s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, s.stanumbers5, s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 @@ -1290,10 +1405,11 @@ SELECT (m.merge).starelid::regclass, AND v.staattnum = '2'::int2 AND s.starelid = 'st0'::regclass AND s.staattnum = '1'::int2) m; -ERROR: cannot cast type record to dbms_stats.column_stats_locked -LINE 33: v.stanumbers1, v.stanumbers2, v.stanumbers3, v... - ^ -DETAIL: Cannot cast type real[] to oid in column 17. + starelid | staattnum | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+---------------------------+-------------------+------------+-----------------------------------+------------------------------------------- + st0 | 2 | t | -2 | -2 | -2 | 2 | 2 | 2 | 2 | 2 | 22 | 23 | 24 | 21 | 25 | 34 | 31 | 32 | 33 | 35 | {-2,22} | {-2,23} | {-2,24} | {-2,21} | {-2,25} | {"test ","test ","test "} | {"test ","test "} | {"test "} | {"test ","test ","test ","test "} | {"test ","test ","test ","test ","test "} +(1 row) + -- No.5-1-21 SELECT dbms_stats.merge((v.starelid::regclass, '2', v.stainherit, v.stanullfrac, v.stawidth, v.stadistinct, @@ -1301,6 +1417,7 @@ SELECT dbms_stats.merge((v.starelid::regclass, '2', v.stainherit, '1', v.staop1, v.staop2, v.staop3, v.staop4, v.staop5, + v.stacoll1, v.stacoll2, v.stacoll3, v.stacoll4, v.stacoll5, v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, v.stanumbers5, v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 @@ -1312,6 +1429,7 @@ SELECT dbms_stats.merge((v.starelid::regclass, '2', v.stainherit, '1', s.staop1, s.staop2, s.staop3, s.staop4, s.staop5, + s.stacoll1, s.stacoll2, s.stacoll3, s.stacoll4, s.stacoll5, s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, s.stanumbers5, s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 @@ -1323,10 +1441,14 @@ SELECT dbms_stats.merge((v.starelid::regclass, '2', v.stainherit, AND v.staattnum = '1'::int2 AND s.starelid = 'st0'::regclass AND s.staattnum = '1'::int2; -ERROR: cannot cast type record to dbms_stats.column_stats_locked -LINE 7: v.stanumbers1, v.stanumbers2, v.stanumbers3, v... - ^ -DETAIL: Cannot cast type real[] to oid in column 17. +LOG: pg_dbms_stats: bad column type +DETAIL: type of column "name" has been changed +HINT: need to execute dbms_stats.unlock('st0', 'name') + merge +-------- + (null) +(1 row) + -- No.5-1-22 SELECT dbms_stats.merge((v.starelid::regclass, '2', v.stainherit, v.stanullfrac, v.stawidth, v.stadistinct, @@ -1334,6 +1456,7 @@ SELECT dbms_stats.merge((v.starelid::regclass, '2', v.stainherit, '2', v.staop1, v.staop2, v.staop3, v.staop4, v.staop5, + v.stacoll1, v.stacoll2, v.stacoll3, v.stacoll4, v.stacoll5, v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, v.stanumbers5, v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 @@ -1345,6 +1468,7 @@ SELECT dbms_stats.merge((v.starelid::regclass, '2', v.stainherit, '2', s.staop1, s.staop2, s.staop3, s.staop4, s.staop5, + s.stacoll1, s.stacoll2, s.stacoll3, s.stacoll4, s.stacoll5, s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, s.stanumbers5, s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 @@ -1356,10 +1480,14 @@ SELECT dbms_stats.merge((v.starelid::regclass, '2', v.stainherit, AND v.staattnum = '1'::int2 AND s.starelid = 'st0'::regclass AND s.staattnum = '1'::int2; -ERROR: cannot cast type record to dbms_stats.column_stats_locked -LINE 7: v.stanumbers1, v.stanumbers2, v.stanumbers3, v... - ^ -DETAIL: Cannot cast type real[] to oid in column 17. +LOG: pg_dbms_stats: bad column type +DETAIL: type of column "name" has been changed +HINT: need to execute dbms_stats.unlock('st0', 'name') + merge +-------- + (null) +(1 row) + RESET client_min_messages; SELECT dbms_stats.unlock_database_stats(); unlock_database_stats @@ -2011,47 +2139,47 @@ SELECT * FROM relations_backup_v; (26 rows) SELECT * FROM columns_backup_v; - id | statypid | starelid | staattnum | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 -----+----------+----------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+------------------------+-------------+-------------+-------------+-------------+------------------------+------------+------------+------------+------------ - 2 | 23 | st0 | 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) - 2 | 1042 | st0 | 2 | 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) - 2 | 23 | st1 | 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) - 2 | 25 | st1 | 2 | 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) - 2 | 23 | s0.st0 | 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) - 2 | 23 | s0.st0 | 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) - 2 | 23 | s0.st0 | 2 | 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) - 2 | 23 | s0.st0 | 2 | 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) - 2 | 23 | s0.st1 | 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) - 2 | 23 | s0.st1 | 2 | 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) - 2 | 23 | s0.st2 | 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) - 2 | 25 | s0.st2 | 2 | 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) - 2 | 23 | s1.st0 | 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) - 2 | 23 | s1.st0 | 2 | 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) - 2 | 25 | st1_exp | 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) - 2 | 23 | s0.sft0 | 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) - 2 | 23 | s0.smv0 | 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) - 2 | 23 | s0.smv0 | 2 | 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) - 2 | 25 | s0.smv0 | 3 | 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) - 3 | 23 | s0.st0 | 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) - 3 | 23 | s0.st0 | 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) - 3 | 23 | s0.st0 | 2 | 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) - 3 | 23 | s0.st0 | 2 | 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) - 5 | 23 | s0.st0 | 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) - 5 | 23 | s0.st0 | 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) - 6 | 23 | s0.st0 | 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) - 6 | 23 | s0.st0 | 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) - 6 | 23 | s0.st0 | 2 | 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) - 6 | 23 | s0.st0 | 2 | 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) - 7 | 23 | st0 | 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) - 7 | 1042 | st0 | 2 | 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) - 8 | 23 | s0.st0 | 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) - 8 | 23 | s0.st0 | 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) - 8 | 23 | s0.st0 | 2 | 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) - 8 | 23 | s0.st0 | 2 | 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) - 8 | 23 | s0.st1 | 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) - 8 | 23 | s0.st1 | 2 | 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) - 8 | 23 | s0.st2 | 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) - 8 | 25 | s0.st2 | 2 | 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) + id | statypid | starelid | staattnum | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----+----------+----------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+------------------------+-------------+-------------+-------------+-------------+------------------------+------------+------------+------------+------------ + 2 | 23 | st0 | 1 | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2} | (null) | (null) | (null) | (null) + 2 | 1042 | st0 | 2 | f | 0 | 6 | -0.5 | 1 | 3 | 0 | 0 | 0 | 1054 | 1058 | 0 | 0 | 0 | 100 | 100 | 0 | 0 | 0 | {1} | {1} | (null) | (null) | (null) | {"test "} | (null) | (null) | (null) | (null) + 2 | 23 | st1 | 1 | f | 0 | 4 | 3 | 1 | 3 | 0 | 0 | 0 | 96 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | {0.3334,0.3333,0.3333} | {0.3332} | (null) | (null) | (null) | {1,0,2} | (null) | (null) | (null) | (null) + 2 | 25 | st1 | 2 | f | 0 | 2 | 3 | 1 | 3 | 0 | 0 | 0 | 98 | 664 | 0 | 0 | 0 | 100 | 100 | 0 | 0 | 0 | {0.3334,0.3333,0.3333} | {0.3332} | (null) | (null) | (null) | {1,0,2} | (null) | (null) | (null) | (null) + 2 | 23 | s0.st0 | 1 | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2} | (null) | (null) | (null) | (null) + 2 | 23 | s0.st0 | 1 | t | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,4,5,6} | (null) | (null) | (null) | (null) + 2 | 23 | s0.st0 | 2 | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20} | (null) | (null) | (null) | (null) + 2 | 23 | s0.st0 | 2 | t | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20,40,50,60} | (null) | (null) | (null) | (null) + 2 | 23 | s0.st1 | 1 | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {4,5,6} | (null) | (null) | (null) | (null) + 2 | 23 | s0.st1 | 2 | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {40,50,60} | (null) | (null) | (null) | (null) + 2 | 23 | s0.st2 | 1 | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,3} | (null) | (null) | (null) | (null) + 2 | 25 | s0.st2 | 2 | f | 0 | 5 | -1 | 2 | 3 | 0 | 0 | 0 | 664 | 664 | 0 | 0 | 0 | 100 | 100 | 0 | 0 | 0 | (null) | {0.5} | (null) | (null) | (null) | {1,comment,test} | (null) | (null) | (null) | (null) + 2 | 23 | s1.st0 | 1 | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,3,4} | (null) | (null) | (null) | (null) + 2 | 23 | s1.st0 | 2 | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {15,25,35,45} | (null) | (null) | (null) | (null) + 2 | 25 | st1_exp | 1 | f | 0 | 5 | 3 | 1 | 3 | 0 | 0 | 0 | 98 | 664 | 0 | 0 | 0 | 100 | 100 | 0 | 0 | 0 | {0.3334,0.3333,0.3333} | {0.3332} | (null) | (null) | (null) | {1,0,2} | (null) | (null) | (null) | (null) + 2 | 23 | s0.sft0 | 1 | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,3,4,5,6,7,8,9,10} | (null) | (null) | (null) | (null) + 2 | 23 | s0.smv0 | 1 | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2} | (null) | (null) | (null) | (null) + 2 | 23 | s0.smv0 | 2 | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20} | (null) | (null) | (null) | (null) + 2 | 25 | s0.smv0 | 3 | f | 0 | 3 | -1 | 2 | 3 | 0 | 0 | 0 | 664 | 664 | 0 | 0 | 0 | 100 | 100 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,test} | (null) | (null) | (null) | (null) + 3 | 23 | s0.st0 | 1 | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2} | (null) | (null) | (null) | (null) + 3 | 23 | s0.st0 | 1 | t | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,4,5,6} | (null) | (null) | (null) | (null) + 3 | 23 | s0.st0 | 2 | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20} | (null) | (null) | (null) | (null) + 3 | 23 | s0.st0 | 2 | t | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20,40,50,60} | (null) | (null) | (null) | (null) + 5 | 23 | s0.st0 | 1 | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2} | (null) | (null) | (null) | (null) + 5 | 23 | s0.st0 | 1 | t | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,4,5,6} | (null) | (null) | (null) | (null) + 6 | 23 | s0.st0 | 1 | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2} | (null) | (null) | (null) | (null) + 6 | 23 | s0.st0 | 1 | t | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,4,5,6} | (null) | (null) | (null) | (null) + 6 | 23 | s0.st0 | 2 | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20} | (null) | (null) | (null) | (null) + 6 | 23 | s0.st0 | 2 | t | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20,40,50,60} | (null) | (null) | (null) | (null) + 7 | 23 | st0 | 1 | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2} | (null) | (null) | (null) | (null) + 7 | 1042 | st0 | 2 | f | 0 | 6 | -0.5 | 1 | 3 | 0 | 0 | 0 | 1054 | 1058 | 0 | 0 | 0 | 100 | 100 | 0 | 0 | 0 | {1} | {1} | (null) | (null) | (null) | {"test "} | (null) | (null) | (null) | (null) + 8 | 23 | s0.st0 | 1 | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2} | (null) | (null) | (null) | (null) + 8 | 23 | s0.st0 | 1 | t | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,4,5,6} | (null) | (null) | (null) | (null) + 8 | 23 | s0.st0 | 2 | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20} | (null) | (null) | (null) | (null) + 8 | 23 | s0.st0 | 2 | t | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20,40,50,60} | (null) | (null) | (null) | (null) + 8 | 23 | s0.st1 | 1 | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {4,5,6} | (null) | (null) | (null) | (null) + 8 | 23 | s0.st1 | 2 | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {40,50,60} | (null) | (null) | (null) | (null) + 8 | 23 | s0.st2 | 1 | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,3} | (null) | (null) | (null) | (null) + 8 | 25 | s0.st2 | 2 | f | 0 | 5 | -1 | 2 | 3 | 0 | 0 | 0 | 664 | 664 | 0 | 0 | 0 | 100 | 100 | 0 | 0 | 0 | (null) | {0.5} | (null) | (null) | (null) | {1,comment,test} | (null) | (null) | (null) | (null) (39 rows) VACUUM ANALYZE; @@ -2709,12 +2837,12 @@ SELECT id, unit, comment FROM dbms_stats.backup_history (1 row) SELECT * FROM columns_locked_v; - starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 -----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ - s0.st0 | 1 | id | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) - s0.st0 | 1 | id | t | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) - s0.st0 | 2 | num | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) - s0.st0 | 2 | num | t | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ + s0.st0 | 1 | id | f | (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) | (null) + s0.st0 | 1 | id | t | (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) | (null) + s0.st0 | 2 | num | f | (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) | (null) + s0.st0 | 2 | num | t | (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) | (null) (4 rows) SELECT * FROM relations_locked_v; @@ -2736,12 +2864,12 @@ SELECT * FROM relations_locked_v; (1 row) SELECT * FROM columns_locked_v; - starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 -----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------+------------+------------ - s0.st0 | 1 | id | 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) - s0.st0 | 1 | id | 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) - s0.st0 | 2 | num | 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) - s0.st0 | 2 | num | 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) + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------+------------+------------ + s0.st0 | 1 | id | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2} | (null) | (null) | (null) | (null) + s0.st0 | 1 | id | t | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,4,5,6} | (null) | (null) | (null) | (null) + s0.st0 | 2 | num | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20} | (null) | (null) | (null) | (null) + s0.st0 | 2 | num | t | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20,40,50,60} | (null) | (null) | (null) | (null) (4 rows) -- No.9-1-25 @@ -2766,12 +2894,12 @@ SELECT * FROM relations_locked_v; (1 row) SELECT * FROM columns_locked_v; - starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 -----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------+------------+------------ - s0.st0 | 1 | id | 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) - s0.st0 | 1 | id | 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) - s0.st0 | 2 | num | 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) - s0.st0 | 2 | num | 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) + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------+------------+------------ + s0.st0 | 1 | id | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2} | (null) | (null) | (null) | (null) + s0.st0 | 1 | id | t | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,4,5,6} | (null) | (null) | (null) | (null) + s0.st0 | 2 | num | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20} | (null) | (null) | (null) | (null) + s0.st0 | 2 | num | t | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20,40,50,60} | (null) | (null) | (null) | (null) (4 rows) /* @@ -3128,27 +3256,27 @@ SELECT id, unit, comment FROM dbms_stats.backup_history (1 row) SELECT * FROM columns_locked_v; - starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 -----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ - st0 | 1 | id | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) - st0 | 2 | name | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) - st1 | 1 | val | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) - st1 | 2 | str | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) - s0.st0 | 1 | id | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) - s0.st0 | 1 | id | t | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) - s0.st0 | 2 | num | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) - s0.st0 | 2 | num | t | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) - s0.st1 | 1 | id | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) - s0.st1 | 2 | num | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) - s0.st2 | 1 | id | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) - s0.st2 | 2 | txt | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) - st1_exp | 1 | lower | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) - s0.sft0 | 1 | id | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) - s0.smv0 | 1 | id | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) - s0.smv0 | 2 | num | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) - s0.smv0 | 3 | txt | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) - s1.st0 | 1 | id | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) - s1.st0 | 2 | num | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ + st0 | 1 | id | f | (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) | (null) + st0 | 2 | name | f | (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) | (null) + st1 | 1 | val | f | (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) | (null) + st1 | 2 | str | f | (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) | (null) + s0.st0 | 1 | id | f | (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) | (null) + s0.st0 | 1 | id | t | (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) | (null) + s0.st0 | 2 | num | f | (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) | (null) + s0.st0 | 2 | num | t | (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) | (null) + s0.st1 | 1 | id | f | (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) | (null) + s0.st1 | 2 | num | f | (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) | (null) + s0.st2 | 1 | id | f | (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) | (null) + s0.st2 | 2 | txt | f | (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) | (null) + st1_exp | 1 | lower | f | (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) | (null) + s0.sft0 | 1 | id | f | (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) | (null) + s0.smv0 | 1 | id | f | (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) | (null) + s0.smv0 | 2 | num | f | (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) | (null) + s0.smv0 | 3 | txt | f | (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) | (null) + s1.st0 | 1 | id | f | (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) | (null) + s1.st0 | 2 | num | f | (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) | (null) (19 rows) SELECT * FROM relations_locked_v; @@ -3205,27 +3333,27 @@ SELECT * FROM relations_locked_v; (16 rows) SELECT * FROM columns_locked_v; - starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 -----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------+------------+------------ - st0 | 1 | id | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) - st0 | 2 | name | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) - st1 | 1 | val | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) - st1 | 2 | str | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) - s0.st0 | 1 | id | 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) - s0.st0 | 1 | id | 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) - s0.st0 | 2 | num | 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) - s0.st0 | 2 | num | 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) - s0.st1 | 1 | id | 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) - s0.st1 | 2 | num | 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) - s0.st2 | 1 | id | 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) - s0.st2 | 2 | txt | 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) - st1_exp | 1 | lower | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) - s0.sft0 | 1 | id | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) - s0.smv0 | 1 | id | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) - s0.smv0 | 2 | num | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) - s0.smv0 | 3 | txt | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) - s1.st0 | 1 | id | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) - s1.st0 | 2 | num | f | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) | (null) + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------+------------+------------ + st0 | 1 | id | f | (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) | (null) + st0 | 2 | name | f | (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) | (null) + st1 | 1 | val | f | (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) | (null) + st1 | 2 | str | f | (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) | (null) + s0.st0 | 1 | id | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2} | (null) | (null) | (null) | (null) + s0.st0 | 1 | id | t | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,4,5,6} | (null) | (null) | (null) | (null) + s0.st0 | 2 | num | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20} | (null) | (null) | (null) | (null) + s0.st0 | 2 | num | t | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20,40,50,60} | (null) | (null) | (null) | (null) + s0.st1 | 1 | id | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {4,5,6} | (null) | (null) | (null) | (null) + s0.st1 | 2 | num | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {40,50,60} | (null) | (null) | (null) | (null) + s0.st2 | 1 | id | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,3} | (null) | (null) | (null) | (null) + s0.st2 | 2 | txt | f | 0 | 5 | -1 | 2 | 3 | 0 | 0 | 0 | 664 | 664 | 0 | 0 | 0 | 100 | 100 | 0 | 0 | 0 | (null) | {0.5} | (null) | (null) | (null) | {1,comment,test} | (null) | (null) | (null) | (null) + st1_exp | 1 | lower | f | (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) | (null) + s0.sft0 | 1 | id | f | (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) | (null) + s0.smv0 | 1 | id | f | (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) | (null) + s0.smv0 | 2 | num | f | (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) | (null) + s0.smv0 | 3 | txt | f | (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) | (null) + s1.st0 | 1 | id | f | (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) | (null) + s1.st0 | 2 | num | f | (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) | (null) (19 rows) -- No.10-7-5 @@ -3260,16 +3388,16 @@ SELECT * FROM relations_locked_v; (6 rows) SELECT * FROM columns_locked_v; - starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 -----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------+------------+------------ - s0.st0 | 1 | id | 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) - s0.st0 | 1 | id | 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) - s0.st0 | 2 | num | 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) - s0.st0 | 2 | num | 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) - s0.st1 | 1 | id | 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) - s0.st1 | 2 | num | 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) - s0.st2 | 1 | id | 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) - s0.st2 | 2 | txt | 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) + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------+------------+------------ + s0.st0 | 1 | id | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2} | (null) | (null) | (null) | (null) + s0.st0 | 1 | id | t | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,4,5,6} | (null) | (null) | (null) | (null) + s0.st0 | 2 | num | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20} | (null) | (null) | (null) | (null) + s0.st0 | 2 | num | t | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20,40,50,60} | (null) | (null) | (null) | (null) + s0.st1 | 1 | id | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {4,5,6} | (null) | (null) | (null) | (null) + s0.st1 | 2 | num | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {40,50,60} | (null) | (null) | (null) | (null) + s0.st2 | 1 | id | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,3} | (null) | (null) | (null) | (null) + s0.st2 | 2 | txt | f | 0 | 5 | -1 | 2 | 3 | 0 | 0 | 0 | 664 | 664 | 0 | 0 | 0 | 100 | 100 | 0 | 0 | 0 | (null) | {0.5} | (null) | (null) | (null) | {1,comment,test} | (null) | (null) | (null) | (null) (8 rows) /* @@ -3323,10 +3451,10 @@ SELECT * FROM relations_locked_v; (1 row) SELECT * FROM columns_locked_v c; - starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 -----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------ - s0.st0 | 1 | id | 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) - s0.st0 | 1 | id | 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) + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------ + s0.st0 | 1 | id | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2} | (null) | (null) | (null) | (null) + s0.st0 | 1 | id | t | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,4,5,6} | (null) | (null) | (null) | (null) (2 rows) -- No.11-1-5 @@ -3349,10 +3477,10 @@ SELECT * FROM relations_locked_v; (1 row) SELECT * FROM columns_locked_v c; - starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 -----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------ - s0.st0 | 1 | id | 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) - s0.st0 | 1 | id | 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) + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------ + s0.st0 | 1 | id | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2} | (null) | (null) | (null) | (null) + s0.st0 | 1 | id | t | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,4,5,6} | (null) | (null) | (null) | (null) (2 rows) -- No.11-1-7 @@ -3380,9 +3508,9 @@ SELECT * FROM relations_locked_v; (1 row) SELECT * FROM columns_locked_v c; - starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 -----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+------------------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ - st1_exp | 1 | lower | 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) + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+------------------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ + st1_exp | 1 | lower | f | 0 | 5 | 3 | 1 | 3 | 0 | 0 | 0 | 98 | 664 | 0 | 0 | 0 | 100 | 100 | 0 | 0 | 0 | {0.3334,0.3333,0.3333} | {0.3332} | (null) | (null) | (null) | {1,0,2} | (null) | (null) | (null) | (null) (1 row) DELETE FROM dbms_stats.relation_stats_locked; @@ -3411,9 +3539,9 @@ SELECT * FROM relations_locked_v; (1 row) SELECT * FROM columns_locked_v c; - starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 -----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------------+------------+------------+------------+------------ - s0.sft0 | 1 | id | 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) + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------------------+------------+------------+------------+------------ + s0.sft0 | 1 | id | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,3,4,5,6,7,8,9,10} | (null) | (null) | (null) | (null) (1 row) -- No.11-1-13 @@ -3431,9 +3559,9 @@ SELECT * FROM relations_locked_v; (1 row) SELECT * FROM columns_locked_v c; - starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 -----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ - s0.smv0 | 1 | id | 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) + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ + s0.smv0 | 1 | id | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2} | (null) | (null) | (null) | (null) (1 row) -- No.11-1-14 @@ -3500,10 +3628,10 @@ SELECT * FROM relations_locked_v; (1 row) SELECT * FROM columns_locked_v c; - starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 -----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------ - s0.st0 | 1 | id | 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) - s0.st0 | 1 | id | 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) + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------ + s0.st0 | 1 | id | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2} | (null) | (null) | (null) | (null) + s0.st0 | 1 | id | t | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,4,5,6} | (null) | (null) | (null) | (null) (2 rows) -- No.11-1-18 @@ -3553,12 +3681,12 @@ SELECT * FROM relations_locked_v; (1 row) SELECT * FROM columns_locked_v c; - starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 -----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------+------------+------------ - s0.st0 | 1 | id | 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) - s0.st0 | 1 | id | 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) - s0.st0 | 2 | num | 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) - s0.st0 | 2 | num | 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) + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------+------------+------------ + s0.st0 | 1 | id | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2} | (null) | (null) | (null) | (null) + s0.st0 | 1 | id | t | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,4,5,6} | (null) | (null) | (null) | (null) + s0.st0 | 2 | num | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20} | (null) | (null) | (null) | (null) + s0.st0 | 2 | num | t | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20,40,50,60} | (null) | (null) | (null) | (null) (4 rows) SELECT * FROM internal_locks; @@ -3597,12 +3725,12 @@ SELECT * FROM relations_locked_v; (1 row) SELECT * FROM columns_locked_v c; - starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 -----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------+------------+------------ - s0.st0 | 1 | id | 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) - s0.st0 | 1 | id | 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) - s0.st0 | 2 | num | 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) - s0.st0 | 2 | num | 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) + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------+------------+------------ + s0.st0 | 1 | id | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2} | (null) | (null) | (null) | (null) + s0.st0 | 1 | id | t | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,4,5,6} | (null) | (null) | (null) | (null) + s0.st0 | 2 | num | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20} | (null) | (null) | (null) | (null) + s0.st0 | 2 | num | t | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20,40,50,60} | (null) | (null) | (null) | (null) (4 rows) -- No.11-2-5 @@ -3626,8 +3754,8 @@ SELECT * FROM relations_locked_v; (1 row) SELECT * FROM columns_locked_v c; - starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 -----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ (0 rows) -- No.11-2-7 @@ -3657,9 +3785,9 @@ SELECT * FROM relations_locked_v; (1 row) SELECT * FROM columns_locked_v c; - starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 -----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------------+------------+------------+------------+------------ - s0.sft0 | 1 | id | 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) + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------------------+------------+------------+------------+------------ + s0.sft0 | 1 | id | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,3,4,5,6,7,8,9,10} | (null) | (null) | (null) | (null) (1 row) -- No.11-2-10 @@ -3677,11 +3805,11 @@ SELECT * FROM relations_locked_v; (1 row) SELECT * FROM columns_locked_v c; - starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 -----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ - s0.smv0 | 1 | id | 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) - s0.smv0 | 2 | num | 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) - s0.smv0 | 3 | txt | 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) + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ + s0.smv0 | 1 | id | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2} | (null) | (null) | (null) | (null) + s0.smv0 | 2 | num | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20} | (null) | (null) | (null) | (null) + s0.smv0 | 3 | txt | f | 0 | 3 | -1 | 2 | 3 | 0 | 0 | 0 | 664 | 664 | 0 | 0 | 0 | 100 | 100 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,test} | (null) | (null) | (null) | (null) (3 rows) -- No.11-2-11 @@ -3718,12 +3846,12 @@ SELECT * FROM relations_locked_v; (1 row) SELECT * FROM columns_locked_v c; - starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 -----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------+------------+------------ - s0.st0 | 1 | id | 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) - s0.st0 | 1 | id | 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) - s0.st0 | 2 | num | 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) - s0.st0 | 2 | num | 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) + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------+------------+------------ + s0.st0 | 1 | id | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2} | (null) | (null) | (null) | (null) + s0.st0 | 1 | id | t | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,4,5,6} | (null) | (null) | (null) | (null) + s0.st0 | 2 | num | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20} | (null) | (null) | (null) | (null) + s0.st0 | 2 | num | t | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20,40,50,60} | (null) | (null) | (null) | (null) (4 rows) -- No.11-2-13 @@ -3741,12 +3869,12 @@ SELECT * FROM relations_locked_v; (1 row) SELECT * FROM columns_locked_v c; - starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 -----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------+------------+------------ - s0.st0 | 1 | id | 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) - s0.st0 | 1 | id | 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) - s0.st0 | 2 | num | 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) - s0.st0 | 2 | num | 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) + starelid | staattnum | attname | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +----------+-----------+---------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------+------------+------------ + s0.st0 | 1 | id | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2} | (null) | (null) | (null) | (null) + s0.st0 | 1 | id | t | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,4,5,6} | (null) | (null) | (null) | (null) + s0.st0 | 2 | num | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20} | (null) | (null) | (null) | (null) + s0.st0 | 2 | num | t | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20,40,50,60} | (null) | (null) | (null) | (null) (4 rows) /* diff --git a/input/ut_imp_exp-12.source b/input/ut_imp_exp-12.source index f895947..3f89294 100644 --- a/input/ut_imp_exp-12.source +++ b/input/ut_imp_exp-12.source @@ -24,6 +24,11 @@ UPDATE dbms_stats.column_stats_locked SET staop3 = 24, staop4 = 21, staop5 = 25, + stacoll1 = 34, + stacoll2 = 31, + stacoll3 = 32, + stacoll4 = 33, + stacoll5 = 35, stanumbers1 = ARRAY[-staattnum,22], stanumbers2 = ARRAY[-staattnum,23], stanumbers3 = ARRAY[-staattnum,24], @@ -130,12 +135,14 @@ UPDATE dbms_stats.column_stats_locked SET (stanullfrac, stawidth, stadistinct, stakind1, stakind2, stakind3, stakind4, stakind5, staop1, staop2, staop3, staop4, staop5, + stacoll1, stacoll2, stacoll3, stacoll4, stacoll5, stanumbers1, stanumbers2, stanumbers3, stanumbers4, stanumbers5, stavalues1, stavalues2, stavalues3, stavalues4, stavalues5) = (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, NULL) WHERE starelid = 's0.st0'::regclass; \i doc/export_effective_stats-12.sql.sample diff --git a/output/ut_imp_exp-12.source b/output/ut_imp_exp-12.source index 0b0ea9a..83edaa7 100644 --- a/output/ut_imp_exp-12.source +++ b/output/ut_imp_exp-12.source @@ -45,6 +45,11 @@ UPDATE dbms_stats.column_stats_locked SET staop3 = 24, staop4 = 21, staop5 = 25, + stacoll1 = 34, + stacoll2 = 31, + stacoll3 = 32, + stacoll4 = 33, + stacoll5 = 35, stanumbers1 = ARRAY[-staattnum,22], stanumbers2 = ARRAY[-staattnum,23], stanumbers3 = ARRAY[-staattnum,24], @@ -135,35 +140,35 @@ TO STDOUT COMMIT; COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); SELECT * FROM work_v; - 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 ----------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+------------------------+-------------+-------------+-------------+-------------+------------------------+------------+------------+------------+------------ - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) + 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 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+------------------------+-------------+-------------+-------------+-------------+------------------------+------------+------------+------------+------------ + 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) | (null) | (null) | (null) | (null) | (null) + 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) | (null) | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2} | (null) | (null) | (null) | (null) + 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 | 100 | 100 | 0 | 0 | 0 | {1} | {1} | (null) | (null) | (null) | {"test "} | (null) | (null) | (null) | (null) + 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) | (null) | (null) | (null) | (null) | (null) + 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 | 100 | 100 | 0 | 0 | 0 | {0.3334,0.3333,0.3333} | {0.3332} | (null) | (null) | (null) | {1,0,2} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | {0.3334,0.3333,0.3333} | {0.3332} | (null) | (null) | (null) | {1,0,2} | (null) | (null) | (null) | (null) + 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 | 100 | 100 | 0 | 0 | 0 | {0.3334,0.3333,0.3333} | {0.3332} | (null) | (null) | (null) | {1,0,2} | (null) | (null) | (null) | (null) + 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) | (null) | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,3,4,5,6,7,8,9,10} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20} | (null) | (null) | (null) | (null) + 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 | 100 | 100 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,test} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,4,5,6} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20,40,50,60} | (null) | (null) | (null) | (null) + 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) | (null) | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {4,5,6} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {40,50,60} | (null) | (null) | (null) | (null) + 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) | (null) | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,3} | (null) | (null) | (null) | (null) + 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 | 100 | 100 | 0 | 0 | 0 | (null) | {0.5} | (null) | (null) | (null) | {1,comment,test} | (null) | (null) | (null) | (null) + 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) | (null) | (null) | (null) | (null) | (null) + 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) | (null) | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,3,4} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {15,25,35,45} | (null) | (null) | (null) | (null) (27 rows) TRUNCATE dbms_stats.work; @@ -250,24 +255,24 @@ TO STDOUT COMMIT; COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); SELECT * FROM work_v; - 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 ----------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------------+------------+------------+------------+------------ - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) + 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 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------------------+------------+------------+------------+------------ + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,3,4,5,6,7,8,9,10} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20} | (null) | (null) | (null) | (null) + 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 | 100 | 100 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,test} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,4,5,6} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20,40,50,60} | (null) | (null) | (null) | (null) + 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) | (null) | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {4,5,6} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {40,50,60} | (null) | (null) | (null) | (null) + 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) | (null) | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,3} | (null) | (null) | (null) | (null) + 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 | 100 | 100 | 0 | 0 | 0 | (null) | {0.5} | (null) | (null) | (null) | {1,comment,test} | (null) | (null) | (null) | (null) + 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) | (null) | (null) | (null) | (null) | (null) + 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) | (null) | (null) | (null) | (null) | (null) (16 rows) TRUNCATE dbms_stats.work; @@ -355,16 +360,16 @@ TO STDOUT COMMIT; COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); SELECT * FROM work_v; - 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 ----------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------+------------+------------ - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) + 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 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------+------------+------------ + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2} | (null) | (null) | (null) | (null) + 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 | 100 | 100 | 0 | 0 | 0 | {1} | {1} | (null) | (null) | (null) | {"test "} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,4,5,6} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20,40,50,60} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,3,4} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {15,25,35,45} | (null) | (null) | (null) | (null) (8 rows) TRUNCATE dbms_stats.work; @@ -459,8 +464,8 @@ TO STDOUT COMMIT; COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); SELECT * FROM work_v; - 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 ----------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ + 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 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ (0 rows) TRUNCATE dbms_stats.work; @@ -548,10 +553,10 @@ TO STDOUT COMMIT; COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); SELECT * FROM work_v; - 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 ----------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ - 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) - 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) + 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 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ + 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) | (null) | (null) | (null) | (null) | (null) + 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) | (null) | (null) | (null) | (null) | (null) (2 rows) TRUNCATE dbms_stats.work; @@ -639,8 +644,8 @@ TO STDOUT COMMIT; COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); SELECT * FROM work_v; - 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 ----------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ + 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 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ (0 rows) TRUNCATE dbms_stats.work; @@ -728,8 +733,8 @@ TO STDOUT COMMIT; COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); SELECT * FROM work_v; - 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 ----------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ + 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 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ (0 rows) TRUNCATE dbms_stats.work; @@ -817,9 +822,9 @@ TO STDOUT COMMIT; COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); SELECT * FROM work_v; - 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 ----------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------------+------------+------------+------------+------------ - 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) + 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 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------------------+------------+------------+------------+------------ + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,3,4,5,6,7,8,9,10} | (null) | (null) | (null) | (null) (1 row) TRUNCATE dbms_stats.work; @@ -907,11 +912,11 @@ TO STDOUT COMMIT; COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); SELECT * FROM work_v; - 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 ----------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ - 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) - 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) - 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) + 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 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20} | (null) | (null) | (null) | (null) + 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 | 100 | 100 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,test} | (null) | (null) | (null) | (null) (3 rows) TRUNCATE dbms_stats.work; @@ -999,14 +1004,14 @@ TO STDOUT COMMIT; COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); SELECT * FROM work_v; - 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 ----------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------------+------------+------------+------------+------------ - 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) - 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) - 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) - 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) - 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) - 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) + 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 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------------------+------------+------------+------------+------------ + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,3,4,5,6,7,8,9,10} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,4,5,6} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {4,5,6} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,3} | (null) | (null) | (null) | (null) (6 rows) TRUNCATE dbms_stats.work; @@ -1094,12 +1099,12 @@ TO STDOUT COMMIT; COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); SELECT * FROM work_v; - 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 ----------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ - 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) - 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) - 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) - 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) + 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 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ + 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) | (null) | (null) | (null) | (null) | (null) + 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) | (null) | (null) | (null) | (null) | (null) + 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) | (null) | (null) | (null) | (null) | (null) + 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) | (null) | (null) | (null) | (null) | (null) (4 rows) TRUNCATE dbms_stats.work; @@ -1187,8 +1192,8 @@ TO STDOUT COMMIT; COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); SELECT * FROM work_v; - 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 ----------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ + 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 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ (0 rows) TRUNCATE dbms_stats.work; @@ -1226,12 +1231,14 @@ UPDATE dbms_stats.column_stats_locked SET (stanullfrac, stawidth, stadistinct, stakind1, stakind2, stakind3, stakind4, stakind5, staop1, staop2, staop3, staop4, staop5, + stacoll1, stacoll2, stacoll3, stacoll4, stacoll5, stanumbers1, stanumbers2, stanumbers3, stanumbers4, stanumbers5, stavalues1, stavalues2, stavalues3, stavalues4, stavalues5) = (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, NULL) WHERE starelid = 's0.st0'::regclass; \i doc/export_effective_stats-12.sql.sample @@ -1308,35 +1315,35 @@ TO STDOUT COMMIT; COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); SELECT * FROM work_v; - 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 ----------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------------------+------------+------------ - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) + 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 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------------------+------------+------------ + 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) | (null) | (null) | (null) | (null) | (null) + 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) | (null) | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2} | (null) | (null) | (null) | (null) + 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 | 100 | 100 | 0 | 0 | 0 | {1} | {1} | (null) | (null) | (null) | {"test "} | (null) | (null) | (null) | (null) + 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) | (null) | (null) | (null) | (null) | (null) + 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 | 34 | 31 | 32 | 33 | 35 | {-2,22} | {-2,23} | {-2,24} | {-2,21} | {-2,25} | (null) | (null) | {1,0,2} | (null) | (null) + 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 | 34 | 31 | 32 | 33 | 35 | {-1,22} | {-1,23} | {-1,24} | {-1,21} | {-1,25} | (null) | (null) | {1,0,2} | (null) | (null) + 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 | 34 | 31 | 32 | 33 | 35 | {-1,22} | {-1,23} | {-1,24} | {-1,21} | {-1,25} | (null) | (null) | {1,0,2} | (null) | (null) + 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) | (null) | (null) | (null) | (null) | (null) + 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 | 34 | 31 | 32 | 33 | 35 | {-1,22} | {-1,23} | {-1,24} | {-1,21} | {-1,25} | (null) | (null) | {1,2,3,4,5,6,7,8,9,10} | (null) | (null) + 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 | 34 | 31 | 32 | 33 | 35 | {-1,22} | {-1,23} | {-1,24} | {-1,21} | {-1,25} | (null) | (null) | {1,2} | (null) | (null) + 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 | 34 | 31 | 32 | 33 | 35 | {-2,22} | {-2,23} | {-2,24} | {-2,21} | {-2,25} | (null) | (null) | {10,20} | (null) | (null) + 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 | 34 | 31 | 32 | 33 | 35 | {-3,22} | {-3,23} | {-3,24} | {-3,21} | {-3,25} | (null) | (null) | {1,test} | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,4,5,6} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20,40,50,60} | (null) | (null) | (null) | (null) + 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) | (null) | (null) | (null) | (null) | (null) + 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 | 34 | 31 | 32 | 33 | 35 | {-1,22} | {-1,23} | {-1,24} | {-1,21} | {-1,25} | (null) | (null) | {4,5,6} | (null) | (null) + 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 | 34 | 31 | 32 | 33 | 35 | {-2,22} | {-2,23} | {-2,24} | {-2,21} | {-2,25} | (null) | (null) | {40,50,60} | (null) | (null) + 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) | (null) | (null) | (null) | (null) | (null) + 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 | 34 | 31 | 32 | 33 | 35 | {-1,22} | {-1,23} | {-1,24} | {-1,21} | {-1,25} | (null) | (null) | {1,2,3} | (null) | (null) + 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 | 34 | 31 | 32 | 33 | 35 | {-2,22} | {-2,23} | {-2,24} | {-2,21} | {-2,25} | (null) | (null) | {1,comment,test} | (null) | (null) + 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) | (null) | (null) | (null) | (null) | (null) + 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) | (null) | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,3,4} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {15,25,35,45} | (null) | (null) | (null) | (null) (27 rows) TRUNCATE dbms_stats.work; @@ -1417,24 +1424,24 @@ TO STDOUT COMMIT; COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); SELECT * FROM work_v; - 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 ----------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------------------+------------+------------ - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) + 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 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------------------+------------+------------ + 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 | 34 | 31 | 32 | 33 | 35 | {-1,22} | {-1,23} | {-1,24} | {-1,21} | {-1,25} | (null) | (null) | {1,2,3,4,5,6,7,8,9,10} | (null) | (null) + 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 | 34 | 31 | 32 | 33 | 35 | {-1,22} | {-1,23} | {-1,24} | {-1,21} | {-1,25} | (null) | (null) | {1,2} | (null) | (null) + 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 | 34 | 31 | 32 | 33 | 35 | {-2,22} | {-2,23} | {-2,24} | {-2,21} | {-2,25} | (null) | (null) | {10,20} | (null) | (null) + 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 | 34 | 31 | 32 | 33 | 35 | {-3,22} | {-3,23} | {-3,24} | {-3,21} | {-3,25} | (null) | (null) | {1,test} | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,4,5,6} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20,40,50,60} | (null) | (null) | (null) | (null) + 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) | (null) | (null) | (null) | (null) | (null) + 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 | 34 | 31 | 32 | 33 | 35 | {-1,22} | {-1,23} | {-1,24} | {-1,21} | {-1,25} | (null) | (null) | {4,5,6} | (null) | (null) + 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 | 34 | 31 | 32 | 33 | 35 | {-2,22} | {-2,23} | {-2,24} | {-2,21} | {-2,25} | (null) | (null) | {40,50,60} | (null) | (null) + 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) | (null) | (null) | (null) | (null) | (null) + 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 | 34 | 31 | 32 | 33 | 35 | {-1,22} | {-1,23} | {-1,24} | {-1,21} | {-1,25} | (null) | (null) | {1,2,3} | (null) | (null) + 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 | 34 | 31 | 32 | 33 | 35 | {-2,22} | {-2,23} | {-2,24} | {-2,21} | {-2,25} | (null) | (null) | {1,comment,test} | (null) | (null) + 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) | (null) | (null) | (null) | (null) | (null) + 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) | (null) | (null) | (null) | (null) | (null) (16 rows) \! rm doc/export_effective_stats-12.sql.sample_test @@ -1516,16 +1523,16 @@ TO STDOUT COMMIT; COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); SELECT * FROM work_v; - 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 ----------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------+------------+------------ - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) + 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 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------+------------+------------ + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2} | (null) | (null) | (null) | (null) + 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 | 100 | 100 | 0 | 0 | 0 | {1} | {1} | (null) | (null) | (null) | {"test "} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,4,5,6} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {10,20,40,50,60} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,3,4} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {15,25,35,45} | (null) | (null) | (null) | (null) (8 rows) \! rm doc/export_effective_stats-12.sql.sample_test @@ -1607,8 +1614,8 @@ TO STDOUT COMMIT; COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); SELECT * FROM work_v; - 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 ----------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ + 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 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ (0 rows) \! rm doc/export_effective_stats-12.sql.sample_test @@ -1690,10 +1697,10 @@ TO STDOUT COMMIT; COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); SELECT * FROM work_v; - 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 ----------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ - 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) - 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) + 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 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ + 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) | (null) | (null) | (null) | (null) | (null) + 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) | (null) | (null) | (null) | (null) | (null) (2 rows) \! rm doc/export_effective_stats-12.sql.sample_test @@ -1775,8 +1782,8 @@ TO STDOUT COMMIT; COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); SELECT * FROM work_v; - 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 ----------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ + 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 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ (0 rows) \! rm doc/export_effective_stats-12.sql.sample_test @@ -1858,8 +1865,8 @@ TO STDOUT COMMIT; COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); SELECT * FROM work_v; - 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 ----------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ + 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 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ (0 rows) \! rm doc/export_effective_stats-12.sql.sample_test @@ -1941,9 +1948,9 @@ TO STDOUT COMMIT; COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); SELECT * FROM work_v; - 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 ----------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------------------+------------+------------ - 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) + 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 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------------------+------------+------------ + 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 | 34 | 31 | 32 | 33 | 35 | {-1,22} | {-1,23} | {-1,24} | {-1,21} | {-1,25} | (null) | (null) | {1,2,3,4,5,6,7,8,9,10} | (null) | (null) (1 row) \! rm doc/export_effective_stats-12.sql.sample_test @@ -2025,11 +2032,11 @@ TO STDOUT COMMIT; COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); SELECT * FROM work_v; - 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 ----------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ - 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) - 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) - 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) + 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 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ + 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 | 34 | 31 | 32 | 33 | 35 | {-1,22} | {-1,23} | {-1,24} | {-1,21} | {-1,25} | (null) | (null) | {1,2} | (null) | (null) + 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 | 34 | 31 | 32 | 33 | 35 | {-2,22} | {-2,23} | {-2,24} | {-2,21} | {-2,25} | (null) | (null) | {10,20} | (null) | (null) + 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 | 34 | 31 | 32 | 33 | 35 | {-3,22} | {-3,23} | {-3,24} | {-3,21} | {-3,25} | (null) | (null) | {1,test} | (null) | (null) (3 rows) \! rm doc/export_effective_stats-12.sql.sample_test @@ -2111,14 +2118,14 @@ TO STDOUT COMMIT; COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); SELECT * FROM work_v; - 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 ----------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+-------------+------------+------------------------+------------+------------ - 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) - 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) - 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) - 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) - 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) - 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) + 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 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+-------------+------------+------------------------+------------+------------ + 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 | 34 | 31 | 32 | 33 | 35 | {-1,22} | {-1,23} | {-1,24} | {-1,21} | {-1,25} | (null) | (null) | {1,2,3,4,5,6,7,8,9,10} | (null) | (null) + 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 | 34 | 31 | 32 | 33 | 35 | {-1,22} | {-1,23} | {-1,24} | {-1,21} | {-1,25} | (null) | (null) | {1,2} | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2} | (null) | (null) | (null) | (null) + 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 | 0 | 0 | 0 | 0 | 0 | (null) | {1} | (null) | (null) | (null) | {1,2,4,5,6} | (null) | (null) | (null) | (null) + 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 | 34 | 31 | 32 | 33 | 35 | {-1,22} | {-1,23} | {-1,24} | {-1,21} | {-1,25} | (null) | (null) | {4,5,6} | (null) | (null) + 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 | 34 | 31 | 32 | 33 | 35 | {-1,22} | {-1,23} | {-1,24} | {-1,21} | {-1,25} | (null) | (null) | {1,2,3} | (null) | (null) (6 rows) \! rm doc/export_effective_stats-12.sql.sample_test @@ -2200,12 +2207,12 @@ TO STDOUT COMMIT; COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); SELECT * FROM work_v; - 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 ----------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ - 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) - 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) - 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) - 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) + 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 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ + 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) | (null) | (null) | (null) | (null) | (null) + 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) | (null) | (null) | (null) | (null) | (null) + 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) | (null) | (null) | (null) | (null) | (null) + 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) | (null) | (null) | (null) | (null) | (null) (4 rows) \! rm doc/export_effective_stats-12.sql.sample_test @@ -2287,8 +2294,8 @@ TO STDOUT COMMIT; COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary'); SELECT * FROM work_v; - 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 ----------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ + 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 | stacoll1 | stacoll2 | stacoll3 | stacoll4 | stacoll5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 +---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+----------+----------+----------+----------+----------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------ (0 rows) \! rm doc/export_effective_stats-12.sql.sample_test diff --git a/pg_dbms_stats.c b/pg_dbms_stats.c index cdecbfc..1dfb020 100644 --- a/pg_dbms_stats.c +++ b/pg_dbms_stats.c @@ -42,6 +42,7 @@ #endif #if PG_VERSION_NUM >= 120000 #include "access/relation.h" +#include "optimizer/plancat.h" #endif #include "pg_dbms_stats.h" @@ -228,7 +229,9 @@ static void init_rel_stats_entry(StatsRelationEntry *entry, Oid relid); static void dbms_stats_estimate_rel_size(Relation rel, int32 *attr_widths, BlockNumber *pages, double *tuples, double *allvisfrac, BlockNumber curpages); +#if PG_VERSION_NUM < 120000 static int32 dbms_stats_get_rel_data_width(Relation rel, int32 *attr_widths); +#endif /* Unit test suit functions */ #ifdef UNIT_TEST @@ -816,7 +819,7 @@ dbms_stats_is_system_catalog(PG_FUNCTION_ARGS) PG_RETURN_BOOL(true); relid = PG_GETARG_OID(0); - result = dbms_stats_is_system_catalog_internal(relid); + result = dbms_stats_is_system_catalog_internal(relid, AccessShareLock); PG_RETURN_BOOL(result); } @@ -826,7 +829,7 @@ dbms_stats_is_system_catalog(PG_FUNCTION_ARGS) * Check whether the given relation is one of system catalogs. */ bool -dbms_stats_is_system_catalog_internal(Oid relid) +dbms_stats_is_system_catalog_internal(Oid relid, LOCKMODE lockmode) { Relation rel; char *schema_name; @@ -837,14 +840,14 @@ dbms_stats_is_system_catalog_internal(Oid relid) return false; /* no such relation */ - rel = try_relation_open(relid, AccessShareLock); + rel = try_relation_open(relid, lockmode); if (rel == NULL) return false; /* check by namespace name. */ schema_name = get_namespace_name(rel->rd_rel->relnamespace); result = dbms_stats_is_system_schema_internal(schema_name); - relation_close(rel, AccessShareLock); + relation_close(rel, lockmode); return result; } @@ -1134,7 +1137,7 @@ get_merged_relation_stats(Oid relid, BlockNumber *pages, double *tuples, /* * pg_dbms_stats doesn't handle system catalogs and its internal relation_stats_effective */ - if (dbms_stats_is_system_catalog_internal(relid)) + if (dbms_stats_is_system_catalog_internal(relid, NoLock)) return; /* @@ -1293,7 +1296,7 @@ get_merged_column_stats(Oid relid, AttrNumber attnum, bool inh) * Return NULL for system catalog, directing the caller to use system * statistics. */ - if (dbms_stats_is_system_catalog_internal(relid)) + if (dbms_stats_is_system_catalog_internal(relid, NoLock)) return NULL; /* Return cached statistics, if any. */ @@ -1786,7 +1789,11 @@ dbms_stats_estimate_rel_size(Relation rel, int32 *attr_widths, */ int32 tuple_width; +#if PG_VERSION_NUM >= 120000 + tuple_width = get_rel_data_width(rel, attr_widths); +#else tuple_width = dbms_stats_get_rel_data_width(rel, attr_widths); +#endif tuple_width += sizeof(HeapTupleHeaderData); tuple_width += sizeof(ItemPointerData); /* note: integer division is intentional here */ @@ -1828,6 +1835,7 @@ dbms_stats_estimate_rel_size(Relation rel, int32 *attr_widths, } } +#if PG_VERSION_NUM < 120000 /* * dbms_stats_get_rel_data_width * @@ -1879,6 +1887,7 @@ dbms_stats_get_rel_data_width(Relation rel, int32 *attr_widths) return tuple_width; } +#endif #ifdef UNIT_TEST void test_pg_dbms_stats(int *passed, int *total); diff --git a/pg_dbms_stats.h b/pg_dbms_stats.h index ffca841..e951a75 100644 --- a/pg_dbms_stats.h +++ b/pg_dbms_stats.h @@ -10,6 +10,6 @@ #define PG_DBMS_STATS_H bool dbms_stats_is_system_schema_internal(char *schema_name); -bool dbms_stats_is_system_catalog_internal(Oid regclass); +bool dbms_stats_is_system_catalog_internal(Oid regclass, LOCKMODE lockmode); #endif /* PG_DBMS_STATS_H */ diff --git a/sql/init-12.sql b/sql/init-12.sql index 477d194..c866cfd 100644 --- a/sql/init-12.sql +++ b/sql/init-12.sql @@ -37,6 +37,7 @@ SELECT starelid::regclass, staattnum, stainherit, stanullfrac, stawidth, stadistinct, stakind1, stakind2, stakind3, stakind4, stakind5, staop1, staop2, staop3, staop4, staop5, + stacoll1, stacoll2, stacoll3, stacoll4, stacoll5, stanumbers1, stanumbers2, stanumbers3, stanumbers4, stanumbers5, stavalues1::text, stavalues2::text, stavalues3::text, stavalues4::text, stavalues5::text FROM pg_statistic @@ -46,6 +47,7 @@ SELECT starelid::regclass, staattnum, attname, stainherit, stanullfrac, stawidth, stadistinct, stakind1, stakind2, stakind3, stakind4, stakind5, staop1, staop2, staop3, staop4, staop5, + stacoll1, stacoll2, stacoll3, stacoll4, stacoll5, stanumbers1, stanumbers2, stanumbers3, stanumbers4, stanumbers5, stavalues1, stavalues2, stavalues3, stavalues4, stavalues5 FROM dbms_stats.column_stats_locked c @@ -58,6 +60,7 @@ SELECT id, statypid, stanullfrac, stawidth, stadistinct, stakind1, stakind2, stakind3, stakind4, stakind5, staop1, staop2, staop3, staop4, staop5, + stacoll1, stacoll2, stacoll3, stacoll4, stacoll5, stanumbers1, stanumbers2, stanumbers3, stanumbers4, stanumbers5, stavalues1, stavalues2, stavalues3, stavalues4, stavalues5 FROM dbms_stats.column_stats_backup @@ -111,6 +114,7 @@ SELECT nspname, relname, relpages, reltuples, relallvisible, stainherit, stanullfrac, stawidth, stadistinct, stakind1, stakind2, stakind3, stakind4, stakind5, staop1, staop2, staop3, staop4, staop5, + stacoll1, stacoll2, stacoll3, stacoll4, stacoll5, stanumbers1, stanumbers2, stanumbers3, stanumbers4, stanumbers5, stavalues1, stavalues2, stavalues3, stavalues4, stavalues5 FROM dbms_stats.work diff --git a/sql/ut-12.sql b/sql/ut-12.sql index 5f2730f..ce84f18 100644 --- a/sql/ut-12.sql +++ b/sql/ut-12.sql @@ -59,6 +59,11 @@ UPDATE pg_statistic SET staop3 = 12, staop4 = 13, staop5 = 15, + stacoll1 = 24, + stacoll2 = 21, + stacoll3 = 22, + stacoll4 = 23, + stacoll5 = 25, stanumbers1 = ARRAY[staattnum,4], stanumbers2 = ARRAY[staattnum,1], stanumbers3 = ARRAY[staattnum,2], @@ -85,6 +90,11 @@ UPDATE dbms_stats.column_stats_locked SET staop3 = 24, staop4 = 21, staop5 = 25, + stacoll1 = 34, + stacoll2 = 31, + stacoll3 = 32, + stacoll4 = 33, + stacoll5 = 35, stanumbers1 = ARRAY[-staattnum,22], stanumbers2 = ARRAY[-staattnum,23], stanumbers3 = ARRAY[-staattnum,24], @@ -131,6 +141,11 @@ SELECT (m.merge).starelid::regclass, (m.merge).staop3, (m.merge).staop4, (m.merge).staop5, + (m.merge).stacoll1, + (m.merge).stacoll2, + (m.merge).stacoll3, + (m.merge).stacoll4, + (m.merge).stacoll5, (m.merge).stanumbers1, (m.merge).stanumbers2, (m.merge).stanumbers3, @@ -163,6 +178,11 @@ SELECT (m.merge).starelid::regclass, (m.merge).staop3, (m.merge).staop4, (m.merge).staop5, + (m.merge).stacoll1, + (m.merge).stacoll2, + (m.merge).stacoll3, + (m.merge).stacoll4, + (m.merge).stacoll5, (m.merge).stanumbers1, (m.merge).stanumbers2, (m.merge).stanumbers3, @@ -198,6 +218,11 @@ SELECT (m.merge).starelid::regclass, (m.merge).staop3, (m.merge).staop4, (m.merge).staop5, + (m.merge).stacoll1, + (m.merge).stacoll2, + (m.merge).stacoll3, + (m.merge).stacoll4, + (m.merge).stacoll5, (m.merge).stanumbers1, (m.merge).stanumbers2, (m.merge).stanumbers3, @@ -233,6 +258,11 @@ SELECT (m.merge).starelid::regclass, (m.merge).staop3, (m.merge).staop4, (m.merge).staop5, + (m.merge).stacoll1, + (m.merge).stacoll2, + (m.merge).stacoll3, + (m.merge).stacoll4, + (m.merge).stacoll5, (m.merge).stanumbers1, (m.merge).stanumbers2, (m.merge).stanumbers3, @@ -268,7 +298,8 @@ SELECT dbms_stats.merge(NULL, ( s.stakind5, s.staop1, s.staop2, s.staop3, s.staop4, - NULL, s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, + NULL, stacoll1, stacoll2, stacoll3, stacoll4, stacoll5, + s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, s.stanumbers5, s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 ,s.stavalues5 @@ -294,6 +325,11 @@ SELECT (m.merge).starelid::regclass, (m.merge).staop3, (m.merge).staop4, (m.merge).staop5, + (m.merge).stacoll1, + (m.merge).stacoll2, + (m.merge).stacoll3, + (m.merge).stacoll4, + (m.merge).stacoll5, (m.merge).stanumbers1, (m.merge).stanumbers2, (m.merge).stanumbers3, @@ -311,6 +347,8 @@ SELECT (m.merge).starelid::regclass, s.stakind5, s.staop1, s.staop2, s.staop3, s.staop4, s.staop5, + s.stacoll1, s.stacoll2, s.stacoll3, s.stacoll4, + s.stacoll5, NULL, s.stanumbers2, s.stanumbers3, s.stanumbers4, s.stanumbers5, s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 @@ -328,7 +366,9 @@ SELECT dbms_stats.merge(( v.stakind5, v.staop1, v.staop2, v.staop3, v.staop4, - NULL, v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, + NULL, v.stacoll1, v.stacoll2, v.stacoll3, v.stacoll4, + v.stacoll5, + v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, v.stanumbers5, v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 ,v.stavalues5 @@ -354,6 +394,11 @@ SELECT (m.merge).starelid::regclass, (m.merge).staop3, (m.merge).staop4, (m.merge).staop5, + (m.merge).stacoll1, + (m.merge).stacoll2, + (m.merge).stacoll3, + (m.merge).stacoll4, + (m.merge).stacoll5, (m.merge).stanumbers1, (m.merge).stanumbers2, (m.merge).stanumbers3, @@ -371,6 +416,7 @@ SELECT (m.merge).starelid::regclass, v.stakind5, v.staop1, v.staop2, v.staop3, v.staop4, v.staop5, + v.stacoll1, v.stacoll2, v.stacoll3, v.stacoll4, v.stacoll5, NULL, v.stanumbers2, v.stanumbers3, v.stanumbers4, v.stanumbers5, v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 @@ -388,10 +434,11 @@ SELECT dbms_stats.merge(( v.stakind5, v.staop1, v.staop2, v.staop3, v.staop4, - NULL, v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, + NULL, v.stacoll1, v.stacoll2, v.stacoll3, v.stacoll4, v.stacoll5, + v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, v.stanumbers5, - v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 - ,v.stavalues5 + v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4, + v.stavalues5 ), ( s.starelid::regclass, s.staattnum, s.stainherit, s.stanullfrac, s.stawidth, s.stadistinct, @@ -399,10 +446,11 @@ SELECT dbms_stats.merge(( s.stakind5, s.staop1, s.staop2, s.staop3, s.staop4, - NULL, s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, + NULL, s.stacoll1, s.stacoll2, s.stacoll3, s.stacoll4, s.stacoll5, + s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, s.stanumbers5, - s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 - ,s.stavalues5 + s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4, + s.stavalues5 )) FROM dbms_stats.column_stats_locked v, pg_statistic s @@ -428,6 +476,11 @@ SELECT (m.merge).starelid::regclass, (m.merge).staop3, (m.merge).staop4, (m.merge).staop5, + (m.merge).stacoll1, + (m.merge).stacoll2, + (m.merge).stacoll3, + (m.merge).stacoll4, + (m.merge).stacoll5, (m.merge).stanumbers1, (m.merge).stanumbers2, (m.merge).stanumbers3, @@ -445,10 +498,11 @@ SELECT (m.merge).starelid::regclass, v.stakind5, v.staop1, v.staop2, v.staop3, v.staop4, v.staop5, + v.stacoll1, v.stacoll2, v.stacoll3, v.stacoll4, + v.stacoll5, NULL, v.stanumbers2, v.stanumbers3, v.stanumbers4, v.stanumbers5, - v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 - ,v.stavalues5 + v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4,v.stavalues5 ), ( s.starelid::regclass, s.staattnum, s.stainherit, s.stanullfrac, s.stawidth, s.stadistinct, @@ -456,7 +510,9 @@ SELECT (m.merge).starelid::regclass, s.stakind5, s.staop1, s.staop2, s.staop3, s.staop4, s.staop5, - NULL, s.stanumbers2, s.stanumbers3, s.stanumbers4, + s.stacoll1, s.stacoll2, s.stacoll3, s.stacoll4, s.stacoll5, + NULL, + s.stanumbers2, s.stanumbers3, s.stanumbers4, s.stanumbers5, s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 ,s.stavalues5 @@ -485,6 +541,11 @@ SELECT (m.merge).starelid::regclass, (m.merge).staop3, (m.merge).staop4, (m.merge).staop5, + (m.merge).stacoll1, + (m.merge).stacoll2, + (m.merge).stacoll3, + (m.merge).stacoll4, + (m.merge).stacoll5, (m.merge).stanumbers1, (m.merge).stanumbers2, (m.merge).stanumbers3, @@ -499,6 +560,7 @@ SELECT (m.merge).starelid::regclass, 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 @@ -525,6 +587,11 @@ SELECT (m.merge).starelid::regclass, (m.merge).staop3, (m.merge).staop4, (m.merge).staop5, + (m.merge).stacoll1, + (m.merge).stacoll2, + (m.merge).stacoll3, + (m.merge).stacoll4, + (m.merge).stacoll5, (m.merge).stanumbers1, (m.merge).stanumbers2, (m.merge).stanumbers3, @@ -539,6 +606,7 @@ SELECT (m.merge).starelid::regclass, 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, @@ -564,6 +632,11 @@ SELECT (m.merge).starelid::regclass, (m.merge).staop3, (m.merge).staop4, (m.merge).staop5, + (m.merge).stacoll1, + (m.merge).stacoll2, + (m.merge).stacoll3, + (m.merge).stacoll4, + (m.merge).stacoll5, (m.merge).stanumbers1, (m.merge).stanumbers2, (m.merge).stanumbers3, @@ -587,6 +660,7 @@ SELECT dbms_stats.merge(( v.starelid::regclass, v.staattnum, v.stainherit, v.stanullfrac, v.stawidth, v.stadistinct, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL @@ -595,6 +669,7 @@ SELECT dbms_stats.merge(( s.starelid::regclass, s.staattnum, s.stainherit, s.stanullfrac, s.stawidth, s.stadistinct, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, @@ -623,6 +698,11 @@ SELECT (m.merge).starelid::regclass, (m.merge).staop3, (m.merge).staop4, (m.merge).staop5, + (m.merge).stacoll1, + (m.merge).stacoll2, + (m.merge).stacoll3, + (m.merge).stacoll4, + (m.merge).stacoll5, (m.merge).stanumbers1, (m.merge).stanumbers2, (m.merge).stanumbers3, @@ -638,9 +718,9 @@ SELECT (m.merge).starelid::regclass, v.stanullfrac, v.stawidth, v.stadistinct, v.stakind1, v.stakind2, v.stakind3, v.stakind4, v.stakind5, - v.staop1, v.staop2, v.staop3, - v.staop4, - NULL, v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, + v.staop1, v.staop2, v.staop3, v.staop4, NULL, + v.stacoll1, v.stacoll2, v.stacoll3, v.stacoll4, v.stacoll5, + v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, v.stanumbers5, v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 ,v.stavalues5 @@ -651,6 +731,7 @@ SELECT (m.merge).starelid::regclass, s.stakind5, s.staop1, s.staop2, s.staop3, s.staop4, s.staop5, + s.stacoll1, s.stacoll2, s.stacoll3, s.stacoll4, s.stacoll5, s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, s.stanumbers5, s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 @@ -670,8 +751,9 @@ SELECT dbms_stats.merge(( v.stakind1, v.stakind2, v.stakind3, v.stakind4, v.stakind5, v.staop1, v.staop2, v.staop3, - v.staop4, - NULL, v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, + v.staop4, NULL, + v.stacoll1, v.stacoll2, v.stacoll3, v.stacoll4, v.stacoll5, + v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, v.stanumbers5, v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 ,v.stavalues5 @@ -681,8 +763,9 @@ SELECT dbms_stats.merge(( s.stakind1, s.stakind2, s.stakind3, s.stakind4, s.stakind5, s.staop1, s.staop2, s.staop3, - s.staop4, - NULL, s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, + s.staop4, NULL, + s.stacoll1, s.stacoll2, s.stacoll3, s.stacoll4, s.stacoll5, + s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, s.stanumbers5, s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 ,s.stavalues5 @@ -711,6 +794,11 @@ SELECT (m.merge).starelid::regclass, (m.merge).staop3, (m.merge).staop4, (m.merge).staop5, + (m.merge).stacoll1, + (m.merge).stacoll2, + (m.merge).stacoll3, + (m.merge).stacoll4, + (m.merge).stacoll5, (m.merge).stanumbers1, (m.merge).stanumbers2, (m.merge).stanumbers3, @@ -728,6 +816,7 @@ SELECT (m.merge).starelid::regclass, '1', v.staop1, v.staop2, v.staop3, v.staop4, v.staop5, + v.stacoll1, v.stacoll2, v.stacoll3, v.stacoll4, v.stacoll5, v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, v.stanumbers5, v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 @@ -739,6 +828,7 @@ SELECT (m.merge).starelid::regclass, '1', s.staop1, s.staop2, s.staop3, s.staop4, s.staop5, + s.stacoll1, s.stacoll2, s.stacoll3, s.stacoll4, s.stacoll5, s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, s.stanumbers5, s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 @@ -768,6 +858,11 @@ SELECT (m.merge).starelid::regclass, (m.merge).staop3, (m.merge).staop4, (m.merge).staop5, + (m.merge).stacoll1, + (m.merge).stacoll2, + (m.merge).stacoll3, + (m.merge).stacoll4, + (m.merge).stacoll5, (m.merge).stanumbers1, (m.merge).stanumbers2, (m.merge).stanumbers3, @@ -784,6 +879,7 @@ SELECT (m.merge).starelid::regclass, '2', v.staop1, v.staop2, v.staop3, v.staop4, v.staop5, + v.stacoll1, v.stacoll2, v.stacoll3, v.stacoll4, v.stacoll5, v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, v.stanumbers5, v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 @@ -795,6 +891,7 @@ SELECT (m.merge).starelid::regclass, '2', s.staop1, s.staop2, s.staop3, s.staop4, s.staop5, + s.stacoll1, s.stacoll2, s.stacoll3, s.stacoll4, s.stacoll5, s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, s.stanumbers5, s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 @@ -814,6 +911,7 @@ SELECT dbms_stats.merge((v.starelid::regclass, '2', v.stainherit, '1', v.staop1, v.staop2, v.staop3, v.staop4, v.staop5, + v.stacoll1, v.stacoll2, v.stacoll3, v.stacoll4, v.stacoll5, v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, v.stanumbers5, v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 @@ -825,6 +923,7 @@ SELECT dbms_stats.merge((v.starelid::regclass, '2', v.stainherit, '1', s.staop1, s.staop2, s.staop3, s.staop4, s.staop5, + s.stacoll1, s.stacoll2, s.stacoll3, s.stacoll4, s.stacoll5, s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, s.stanumbers5, s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4 @@ -844,6 +943,7 @@ SELECT dbms_stats.merge((v.starelid::regclass, '2', v.stainherit, '2', v.staop1, v.staop2, v.staop3, v.staop4, v.staop5, + v.stacoll1, v.stacoll2, v.stacoll3, v.stacoll4, v.stacoll5, v.stanumbers1, v.stanumbers2, v.stanumbers3, v.stanumbers4, v.stanumbers5, v.stavalues1, v.stavalues2, v.stavalues3, v.stavalues4 @@ -855,6 +955,7 @@ SELECT dbms_stats.merge((v.starelid::regclass, '2', v.stainherit, '2', s.staop1, s.staop2, s.staop3, s.staop4, s.staop5, + s.stacoll1, s.stacoll2, s.stacoll3, s.stacoll4, s.stacoll5, s.stanumbers1, s.stanumbers2, s.stanumbers3, s.stanumbers4, s.stanumbers5, s.stavalues1, s.stavalues2, s.stavalues3, s.stavalues4