dbicdh/PostgreSQL/deploy/2/002-extract_crashing_functions.sql
changeset 61 3a0ca02556da
child 76 6a33901e2721
equal deleted inserted replaced
60:7ad91b3d5562 61:3a0ca02556da
       
     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_datas_idx_extract_crashing_functions ON crash_datas USING gin (
       
    20     extract_crashing_functions(processed) gin_trgm_ops
       
    21 );
       
    22