OSDN Git Service

1.3.1
[pgdbmsstats/pg_dbms_stats.git] / expected / init-common.out
1 /*
2  * No.1-1 CREATE EXTENSION
3  */
4 -- No.1-1-1
5 CREATE EXTENSION pg_dbms_stats;
6 -- No.1-1-2
7 DROP EXTENSION pg_dbms_stats;
8 CREATE EXTENSION pg_dbms_stats;
9 -- create no superuser and superuser
10 SET client_min_messages = warning;
11 DROP ROLE IF EXISTS regular_user;
12 CREATE ROLE regular_user LOGIN;
13 SET client_min_messages = fatal;
14 CREATE ROLE postgres SUPERUSER CREATEDB CREATEROLE INHERIT LOGIN;
15 -- create object
16 CREATE TABLE pt0(id integer, day date);
17 CREATE INDEX pt0_idx ON pt0(id);
18 CREATE TABLE st0(id integer, name char(5));
19 CREATE INDEX st0_idx ON st0(id);
20 CREATE TABLE st1(val integer, str text);
21 CREATE SCHEMA s0;
22 CREATE TABLE s0.st0(id integer, num integer);
23 CREATE INDEX st0_idx ON s0.st0(id);
24 CREATE TABLE s0.st1() INHERITS(s0.st0);
25 CREATE INDEX st1_idx ON s0.st1(id);
26 CREATE TABLE s0.st2(id integer, txt text);
27 CREATE INDEX st2_idx ON s0.st2(id);
28 CREATE VIEW sv0 AS
29     SELECT st0.id, st0.num, st2.txt
30       FROM s0.st0 st0, s0.st2 st2
31      WHERE st0.id = st2.id;
32 CREATE TYPE s0.sc0 AS (num integer, txt text);
33 CREATE SEQUENCE s0.ss0 START 1;
34 CREATE SCHEMA s1;
35 CREATE TABLE s1.st0(id integer, num integer);
36 CREATE SCHEMA s2;
37 GRANT USAGE ON SCHEMA s0 TO regular_user;
38 GRANT SELECT ON TABLE s0.st2 TO regular_user;
39 CREATE TYPE complex AS (
40      r double precision,
41      i double precision
42 );
43 CREATE FUNCTION inform(VARIADIC arr text[]) RETURNS int AS $$
44 DECLARE
45     str text := 'arguments are ';
46     count int;
47 BEGIN
48     FOR count IN SELECT i FROM generate_subscripts($1, 1) g(i) LOOP
49         IF count != 1 THEN
50             str := str || ', ';
51         END IF;
52         IF $1[count] IS NULL THEN
53             str := str || '<NULL>';
54         ELSE
55             str := str || $1[count];
56         END IF;
57     END LOOP;
58     RAISE NOTICE '%', str;
59     RETURN 1;
60 END;
61 $$LANGUAGE plpgsql;
62 CREATE VIEW lockd_io AS
63        SELECT relname, heap_blks_read hbr, heap_blks_hit hbh,
64               idx_blks_read ibr, idx_blks_hit ibh
65          FROM pg_statio_user_tables
66         WHERE schemaname = 'dbms_stats'
67           AND relname LIKE '%stats_locked'
68         ORDER BY relid;
69 -- load data
70 INSERT INTO st0 VALUES (1, 'test'), (2, 'test');
71 INSERT INTO st1 SELECT i % 3, i % 3 FROM generate_series(1, 10000) t(i);
72 INSERT INTO s0.st0 VALUES (1, 10), (2, 20);
73 INSERT INTO s0.st1 VALUES (4, 40), (5, 50), (6, 60);
74 INSERT INTO s0.st2 VALUES (1, '1'), (2, 'test'), (3, 'comment');
75 INSERT INTO s1.st0 VALUES (1, 15), (2, 25), (3, 35), (4, 45);
76 CREATE INDEX st1_idx ON st1 (val);
77 CREATE INDEX st1_exp ON st1 (lower(str));
78 VACUUM ANALYZE;