dbicdh/PostgreSQL/deploy/2/002-extract_crashing_functions.sql
changeset 78 0ebef32c34af
parent 77 e408da1419cd
child 79 4ae8bb6f8a96
equal deleted inserted replaced
77:e408da1419cd 78:0ebef32c34af
     1 
       
     2 CREATE OR REPLACE FUNCTION extract_crashing_functions (processed_json jsonb) RETURNS text AS
       
     3 $$
       
     4     -- extract threads[crashing_idx]->frames[*]->function
       
     5     SELECT string_agg(functions, E'\n')
       
     6     FROM (
       
     7         SELECT jsonb_array_elements(
       
     8             (($1 #> ARRAY['threads', $1->'crash_info'->>'crashing_thread'])->'frames')
       
     9         )->>'function' AS functions
       
    10     ) AS frames
       
    11 $$
       
    12 LANGUAGE sql IMMUTABLE;
       
    13 
       
    14 -- This extension is the contrib modules
       
    15 CREATE EXTENSION IF NOT EXISTS pg_trgm;
       
    16 
       
    17 -- Used for searching function in the crashing thread backtrace
       
    18 -- Search will be really slow if this index is not present
       
    19 CREATE INDEX crash_report_datas_idx_extract_crashing_functions ON crash_report_datas USING gist (
       
    20     extract_crashing_functions(processed) gist_trgm_ops
       
    21 );
       
    22