# schema
-- SWH DB schema upgrade
-- from_version: 88
-- to_version: 89
-- description: indexer: Add content_ctags
insert into dbversion(version, release, description)
values(89, now(), 'Work In Progress');
-- ctags metadata
create table content_ctags (
id sha1 primary key references content(sha1) not null,
ctags jsonb
);
comment on table content_ctags is 'Ctags information on a raw content';
comment on column content_ctags.lang is 'Ctags information';
-- add tmp_content_ctags entries to content_ctags, overwriting
-- duplicates if conflict_update is true, skipping duplicates otherwise.
--
-- If filtering duplicates is in order, the call to
-- swh_ctags_missing must take place before calling this function.
--
--
-- operates in bulk: 0. swh_mktemp(content_ctags), 1. COPY to tmp_content_ctags,
-- 2. call this function
create or replace function swh_content_ctags_add(conflict_update boolean)
returns void
language plpgsql
as $$
begin
if conflict_update then
insert into content_ctags (id, ctags)
select id, ctags
from tmp_content_ctags
on conflict(id)
do update set ctags = excluded.ctags;
else
insert into content_ctags (id, ctags)
select id, ctags
from tmp_content_ctags
on conflict do nothing;
end if;
return;
end
$$;
comment on function swh_content_ctags_add(boolean) IS 'Add new ctags symbols per content';
-- check which entries of tmp_bytea are missing from content_ctags
--
-- operates in bulk: 0. swh_mktemp_bytea(), 1. COPY to tmp_bytea,
-- 2. call this function
create or replace function swh_content_ctags_missing()
returns setof sha1
language plpgsql
as $$
begin
return query
(select id::sha1 from tmp_bytea as tmp
where not exists
(select 1 from content_ctags as c where c.id = tmp.id));
return;
end
$$;
comment on function swh_content_ctags_missing() IS 'Filter missing content ctags';
-- Retrieve list of content ctags from the temporary table.
--
-- operates in bulk: 0. mktemp(tmp_bytea), 1. COPY to tmp_bytea, 2. call this function
create or replace function swh_content_ctags_get()
returns setof content_ctags
language plpgsql
as $$
begin
return query
select id::sha1, ctags
from tmp_bytea t
inner join content_ctags using(id);
return;
end
$$;
comment on function swh_content_ctags_get() IS 'List content ctags';
# sample output
\xa23ca74da260282c58d5291de07379f988e070a2 | [{"file": true, "kind": "macro", "line": 2, "name": "__types_loaded__", "pattern": "/^#define __types_loaded__ /"}, {"file": true, "kind": "struct", "line": 12, "name": "IOSB", "pattern": "/^struct IOSB$/"}, {"file": true, "kind": "member", "line": 14, "name": "status", "scope": "IOSB", "pattern": "/^ short status, count;$/", "typeref": "short", "scopeKind": "struct"}, {"file": true, "kind": "member", "line": 14, "name": "count", "scope": "IOSB", "pattern": "/^ short status, count;$/", "typeref": "short", "scopeKind": "struct"}, {"file": true, "kind": "member", "line": 15, "name": "devinfo", "scope": "IOSB", "pattern": "/^ long devinfo;$/", "typeref": "long", "scopeKind": "struct"}, {"file": true, "kind": "struct", "line": 19, "name": "list3", "pattern": "/^struct itm$list3$/"}, {"file": true, "kind": "member", "line": 21, "name": "buflen", "scope": "list3", "pattern": "/^ short buflen;$/", "typeref": "short", "scopeKind": "struct"}, {"file": true, "kind": "member", "line": 22, "name": "itemcode", "scope": "list3", "pattern": "/^ short itemcode;$/", "typeref": "short", "scopeKind": "struct"}, {"file": true, "kind": "member", "line": 23, "name": "buffer", "scope": "list3", "pattern": "/^ void *buffer;$/", "typeref": "void *", "scopeKind": "struct"}, {"file": true, "kind": "member", "line": 24, "name": "retlen", "scope": "list3", "pattern": "/^ size_t *retlen;$/", "typeref": "size_t *", "scopeKind": "struct"}, {"file": true, "kind": "struct", "line": 28, "name": "LOCK", "pattern": "/^struct LOCK$/"}, {"file": true, "kind": "member", "line": 30, "name": "status", "scope": "LOCK", "pattern": "/^ short status, reserved;$/", "typeref": "short", "scopeKind": "struct"}, {"file": true, "kind": "member", "line": 30, "name": "reserved", "scope": "LOCK", "pattern": "/^ short status, reserved;$/", "typeref": "short", "scopeKind": "struct"}, {"file": true, "kind": "member", "line": 31, "name": "lockid", "scope": "LOCK", "pattern": "/^ long lockid;$/", "typeref": "long", "scopeKind": "struct"}, {"file": true, "kind": "member", "line": 32, "name": "value", "scope": "LOCK", "pattern": "/^ long value[4];$/", "typeref": "long[4]", "scopeKind": "struct"}, {"file": true, "kind": "struct", "line": 36, "name": "EXHCB", "pattern": "/^struct EXHCB$/"}, {"file": true, "kind": "member", "line": 39, "name": "exh", "scope": "EXHCB", "pattern": "/^ int (*exh$a_routine)();$/", "typeref": "int (* $a_routine)()", "scopeKind": "struct"}]
\x4167662cc8560391d730101cb51a963d62732eda | [{"kind": "function", "line": 30, "name": "vmssrcdir", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 39, "name": "VMSLIB", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 39, "name": "VMSLIB", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 39, "name": "VMSLIB", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 40, "name": "VMSLIB", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 41, "name": "VMSLIB", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 41, "name": "VMSLIB", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 42, "name": "VMSLIB", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 43, "name": "VMSLIB", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 44, "name": "VMSLIB", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 44, "name": "VMSLIB", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 44, "name": "VMSLIB", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 46, "name": "MODULES", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 55, "name": "SOURCE", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 62, "name": "define", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 63, "name": "include", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 66, "name": "define", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 67, "name": "include", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 72, "name": "sys", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 85, "name": "exe", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 95, "name": "obj", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 99, "name": "all_vmslib", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 102, "name": "olb", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 105, "name": "olb", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 108, "name": "olb", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 111, "name": "olb", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 114, "name": "olb", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 117, "name": "olb", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 126, "name": "mostlyclean", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 129, "name": "mostlyclean", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 129, "name": "delete", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 133, "name": "clean", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 139, "name": "realclean", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 143, "name": "prot", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 146, "name": "prot", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 158, "name": "obj", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 162, "name": "getsyi", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 163, "name": "select", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 164, "name": "obj", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 169, "name": "section", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 170, "name": "environment", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 173, "name": "command", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 177, "name": "obj", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 178, "name": "VMSLIB", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 179, "name": "object", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 180, "name": "obj", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 181, "name": "VMSLIB", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 182, "name": "object", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 183, "name": "obj", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 184, "name": "VMSLIB", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 185, "name": "object", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 186, "name": "obj", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 187, "name": "VMSLIB", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 188, "name": "object", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 189, "name": "obj", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 189, "name": "c", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 190, "name": "VMSLIB", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 191, "name": "object", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 192, "name": "obj", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 193, "name": "VMSLIB", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 194, "name": "object", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 195, "name": "obj", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 195, "name": "c", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 196, "name": "VMSLIB", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 197, "name": "object", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 198, "name": "obj", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 198, "name": "c", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 199, "name": "VMSLIB", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 200, "name": "object", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 201, "name": "obj", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 201, "name": "c", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 202, "name": "VMSLIB", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 203, "name": "object", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 204, "name": "obj", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 204, "name": "c", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 205, "name": "VMSLIB", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 206, "name": "object", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 207, "name": "obj", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 207, "name": "c", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 208, "name": "VMSLIB", "scope": "", "pattern": "", "scopeKind": "interface"}, {"kind": "function", "line": 209, "name": "object", "scope": "", "pattern": "", "scopeKind": "interface"}]