-- 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;
|
|
CREATE TABLE rxp_t (id numeric);
|
INSERT INTO rxp_t VALUES (1);
|
|
|
DROP FUNCTION IF EXISTS rxp_hit(text, text, text, text, text);
|
|
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 $$;
|
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 $$;
|
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 $$;
|
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 $$;
|
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 $$;
|
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 $$;
|
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 $$;
|
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 $$;
|
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 $$;
|
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;
|