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);
-ERROR: relation "16712" does not exist
+-- 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
-------
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);
-ERROR: relation "16712" does not exist
+-- 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
-------
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);
-ERROR: relation "16712" does not exist
+-- 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
-------
1
(1 row)
-SELECT dbms_stats.backup(1, 's0.st0'::regclass, NULL);
-ERROR: duplicate key value violates unique constraint "relation_stats_backup_pkey"
-DETAIL: Key (id, relid)=(1, 16687) already exists.
-CONTEXT: SQL function "backup" statement 1
+-- SELECT dbms_stats.backup(1, 's0.st0'::regclass, NULL);
+-- To avoid test unstability caused by relation id allocation, unique
+-- constraint which used to be checked above is now checked more
+-- directly in the following step.
+SELECT ic.relname idxname, i.indisprimary
+ FROM pg_index i
+ JOIN pg_class c ON (c.oid = i.indrelid)
+ JOIN pg_namespace n ON (n.oid = c.relnamespace)
+ JOIN pg_class ic ON (ic.oid = i.indexrelid)
+ WHERE n.nspname = 'dbms_stats' AND c.relname = 'relation_stats_backup';
+ idxname | indisprimary
+----------------------------+--------------
+ relation_stats_backup_pkey | t
+(1 row)
+
SELECT count(*) FROM dbms_stats.relation_stats_backup;
count
-------
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);
+-- 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);
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);
+-- 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);
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);
+-- 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);
GROUP BY starelid, staattnum
ORDER BY starelid, staattnum;
SELECT count(*) FROM dbms_stats.relation_stats_backup;
-SELECT dbms_stats.backup(1, 's0.st0'::regclass, NULL);
+-- SELECT dbms_stats.backup(1, 's0.st0'::regclass, NULL);
+-- To avoid test unstability caused by relation id allocation, unique
+-- constraint which used to be checked above is now checked more
+-- directly in the following step.
+SELECT ic.relname idxname, i.indisprimary
+ FROM pg_index i
+ JOIN pg_class c ON (c.oid = i.indrelid)
+ JOIN pg_namespace n ON (n.oid = c.relnamespace)
+ JOIN pg_class ic ON (ic.oid = i.indexrelid)
+ WHERE n.nspname = 'dbms_stats' AND c.relname = 'relation_stats_backup';
SELECT count(*) FROM dbms_stats.relation_stats_backup;
SELECT count(*) FROM dbms_stats.column_stats_backup;