| author | Vincent Tondellier <tonton@team1664.org> |
| Sat, 09 May 2015 23:28:45 +0200 | |
| changeset 69 | 5794f095a709 |
| parent 61 | 3a0ca02556da |
| child 76 | 6a33901e2721 |
| permissions | -rw-r--r-- |
|
61
3a0ca02556da
Add crash_data table to store the json
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
1 |
|
|
3a0ca02556da
Add crash_data table to store the json
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
2 |
CREATE OR REPLACE FUNCTION extract_crashing_functions (processed_json jsonb) RETURNS text AS |
|
3a0ca02556da
Add crash_data table to store the json
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
3 |
$$ |
|
3a0ca02556da
Add crash_data table to store the json
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
4 |
-- extract threads[crashing_idx]->frames[*]->function |
|
3a0ca02556da
Add crash_data table to store the json
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
5 |
SELECT string_agg(functions, E'\n') |
|
3a0ca02556da
Add crash_data table to store the json
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
6 |
FROM ( |
|
3a0ca02556da
Add crash_data table to store the json
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
7 |
SELECT jsonb_array_elements( |
|
3a0ca02556da
Add crash_data table to store the json
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
8 |
(($1 #> ARRAY['threads', $1->'crash_info'->>'crashing_thread'])->'frames') |
|
3a0ca02556da
Add crash_data table to store the json
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
9 |
)->>'function' AS functions |
|
3a0ca02556da
Add crash_data table to store the json
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
10 |
) AS frames |
|
3a0ca02556da
Add crash_data table to store the json
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
11 |
$$ |
|
3a0ca02556da
Add crash_data table to store the json
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
12 |
LANGUAGE sql IMMUTABLE; |
|
3a0ca02556da
Add crash_data table to store the json
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
13 |
|
|
3a0ca02556da
Add crash_data table to store the json
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
14 |
-- This extension is the contrib modules |
|
3a0ca02556da
Add crash_data table to store the json
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
15 |
CREATE EXTENSION IF NOT EXISTS pg_trgm; |
|
3a0ca02556da
Add crash_data table to store the json
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
16 |
|
|
3a0ca02556da
Add crash_data table to store the json
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
17 |
-- Used for searching function in the crashing thread backtrace |
|
3a0ca02556da
Add crash_data table to store the json
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
18 |
-- Search will be really slow if this index is not present |
|
3a0ca02556da
Add crash_data table to store the json
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
19 |
CREATE INDEX crash_datas_idx_extract_crashing_functions ON crash_datas USING gin ( |
|
3a0ca02556da
Add crash_data table to store the json
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
20 |
extract_crashing_functions(processed) gin_trgm_ops |
|
3a0ca02556da
Add crash_data table to store the json
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
21 |
); |
|
3a0ca02556da
Add crash_data table to store the json
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
22 |