Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
3 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
-- DBMS_XPLAN.DISPLAY: форматы без смены statistics_level.
-- Пара к sql/oracle/dbms_xplan_display_format.sql. Expected совпадает со стендом Oracle 23.5.
-- Текст плана не печатается.
SET client_min_messages = notice;
DROP TABLE IF EXISTS rxp_t;
NOTICE:  table "rxp_t" does not exist, skipping
CREATE TABLE rxp_t (id numeric);
INSERT INTO rxp_t VALUES (1);
DROP FUNCTION IF EXISTS rxp_hit(text, text, text, text, text);
NOTICE:  function rxp_hit(text,text,text,text,text) does not exist, skipping
CREATE FUNCTION rxp_hit(
    p_table text,
    p_sid text,
    p_fmt text,
    p_filter text,
    p_needle text
) RETURNS text
LANGUAGE plpgsql AS $$
DECLARE
    v_hit text := 'NO';
    r record;
BEGIN
    FOR r IN
        SELECT plan_table_output AS line
          FROM dbms_xplan_display(p_table, p_sid, p_fmt, p_filter)
    LOOP
        IF r.line IS NOT NULL AND position(upper(p_needle) IN upper(r.line)) > 0 THEN
            v_hit := 'YES';
        END IF;
    END LOOP;
    RETURN v_hit;
END $$;
DO $$
 
BEGIN
    EXECUTE 'EXPLAIN PLAN SET STATEMENT_ID = ''rxp_fmt'' FOR SELECT * FROM rxp_t';
END $$;
DO $$
 
DECLARE
    v_hit text;
BEGIN
    RAISE NOTICE 'Expected: section=NO';
    v_hit := rxp_hit('PLAN_TABLE', 'rxp_fmt', 'SERIAL', NULL, 'PARALLEL');
    RAISE NOTICE 'Actual:   section=%', v_hit;
END $$;
NOTICE:  Expected: section=NO
NOTICE:  Actual:   section=NO
DO $$
 
DECLARE
    v_hit text;
BEGIN
    RAISE NOTICE 'Expected: section=NO';
    v_hit := rxp_hit('PLAN_TABLE', 'rxp_fmt', 'ADAPTIVE', NULL, 'ADAPTIVE');
    RAISE NOTICE 'Actual:   section=%', v_hit;
END $$;
NOTICE:  Expected: section=NO
NOTICE:  Actual:   section=NO
DO $$
 
DECLARE
    v_hit text;
BEGIN
    RAISE NOTICE 'Expected: section=NO';
    v_hit := rxp_hit('PLAN_TABLE', 'rxp_fmt', 'PARTITION', NULL, 'PARTITION');
    RAISE NOTICE 'Actual:   section=%', v_hit;
END $$;
NOTICE:  Expected: section=NO
NOTICE:  Actual:   section=NO
DO $$
 
DECLARE
    v_hit text;
BEGIN
    RAISE NOTICE 'Expected: section=NO';
    v_hit := rxp_hit('PLAN_TABLE', 'rxp_fmt', 'PARALLEL', NULL, 'PARALLEL');
    RAISE NOTICE 'Actual:   section=%', v_hit;
END $$;
NOTICE:  Expected: section=NO
NOTICE:  Actual:   section=NO
DO $$
 
DECLARE
    v_hit text;
BEGIN
    RAISE NOTICE 'Expected: section=NO';
    v_hit := rxp_hit('PLAN_TABLE', 'rxp_fmt', 'REMOTE', NULL, 'REMOTE');
    RAISE NOTICE 'Actual:   section=%', v_hit;
END $$;
NOTICE:  Expected: section=NO
NOTICE:  Actual:   section=NO
DO $$
 
DECLARE
    v_hit text;
BEGIN
    RAISE NOTICE 'Expected: warn=YES';
    v_hit := rxp_hit('PLAN_TABLE', 'rxp_fmt', 'IOSTATS', NULL, 'BASIC PLAN STATISTICS NOT AVAILABLE');
    RAISE NOTICE 'Actual:   warn=%', v_hit;
END $$;
NOTICE:  Expected: warn=YES
NOTICE:  Actual:   warn=YES
DO $$
 
DECLARE
    v_hit text;
BEGIN
    RAISE NOTICE 'Expected: warn=YES';
    v_hit := rxp_hit('PLAN_TABLE', 'rxp_fmt', 'MEMSTATS', NULL, 'BASIC PLAN STATISTICS NOT AVAILABLE');
    RAISE NOTICE 'Actual:   warn=%', v_hit;
END $$;
NOTICE:  Expected: warn=YES
NOTICE:  Actual:   warn=YES
DO $$
 
DECLARE
    v_hit text;
BEGIN
    RAISE NOTICE 'Expected: warn=YES';
    v_hit := rxp_hit('PLAN_TABLE', 'rxp_fmt', 'ALLSTATS', NULL, 'BASIC PLAN STATISTICS NOT AVAILABLE');
    RAISE NOTICE 'Actual:   warn=%', v_hit;
END $$;
NOTICE:  Expected: warn=YES
NOTICE:  Actual:   warn=YES
DO $$
 
DECLARE
    v_hit text;
BEGIN
    RAISE NOTICE 'Expected: section=NO';
    v_hit := rxp_hit('PLAN_TABLE', 'rxp_fmt', 'LAST', NULL, 'A-ROWS');
    RAISE NOTICE 'Actual:   section=%', v_hit;
END $$;
NOTICE:  Expected: section=NO
NOTICE:  Actual:   section=NO
DO $$
 
BEGIN
    DELETE FROM plan_table WHERE statement_id IN ('rxp_fmt');
EXCEPTION
    WHEN SQLSTATE '42P01' THEN
        NULL;
END $$;
DROP FUNCTION IF EXISTS rxp_hit(text, text, text, text, text);
DROP TABLE IF EXISTS rxp_t;