--
BEGIN;

CREATE OR REPLACE FUNCTION entity_save(
    in_entity_id int, in_name text, in_entity_class INT
) RETURNS INT AS $$

    DECLARE
        e entity;
        e_id int;
        
    BEGIN
    
        select * into e from entity where id = in_entity_id;
        
            
        update 
            entity 
        SET
            name = in_name,
            entity_class = in_entity_class
        WHERE
            id = in_entity_id;
        IF NOT FOUND THEN
            -- do the insert magic.
            e_id = nextval('entity_id_seq');
            insert into entity (id, name, entity_class) values 
                (e_id,
                in_name,
                in_entity_class
                );
            return e_id;
        END IF;
        return in_entity_id;
            
    END;

$$ language 'plpgsql';

CREATE OR REPLACE FUNCTION entity__list_classes ()
RETURNS SETOF entity_class AS $$
DECLARE out_row entity_class;
BEGIN
	FOR out_row IN 
		SELECT * FROM entity_class
		WHERE active
		ORDER BY id
	LOOP
		RETURN NEXT out_row;
	END LOOP;
END;
$$ LANGUAGE PLPGSQL;

CREATE OR REPLACE FUNCTION entity__get_entity (
    in_entity_id int
) RETURNS setof entity AS $$

declare
    v_row entity;
BEGIN
    SELECT * INTO v_row FROM entity WHERE id = in_entity_id;
    IF NOT FOUND THEN
        raise exception 'Could not find entity with ID %', in_entity_id;
    ELSE
        return next v_row;
    END IF;
END;

$$ language plpgsql;



commit;
spilot.dk/old?h=master'>log</a><a href='/notmuch/tree/tags/29/0c/22B8B1E3-1DFA-4443-B08F-9FA6B960B8A5@kaospilot.dk/old?h=master'>tree</a><a href='/notmuch/commit/tags/29/0c/22B8B1E3-1DFA-4443-B08F-9FA6B960B8A5@kaospilot.dk/old?h=master'>commit</a><a class='active' href='/notmuch/diff/tags/29/0c/22B8B1E3-1DFA-4443-B08F-9FA6B960B8A5@kaospilot.dk/old?h=master'>diff</a></td><td class='form'><form class='right' method='get' action='/notmuch/log/tags/29/0c/22B8B1E3-1DFA-4443-B08F-9FA6B960B8A5@kaospilot.dk/old'>
<input type='hidden' name='h' value='master'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/notmuch/diff/?h=master'>root</a>/<a href='/notmuch/diff/tags?h=master'>tags</a>/<a href='/notmuch/diff/tags/29?h=master'>29</a>/<a href='/notmuch/diff/tags/29/0c?h=master'>0c</a>/<a href='/notmuch/diff/tags/29/0c/22B8B1E3-1DFA-4443-B08F-9FA6B960B8A5@kaospilot.dk?h=master'>22B8B1E3-1DFA-4443-B08F-9FA6B960B8A5@kaospilot.dk</a>/<a href='/notmuch/diff/tags/29/0c/22B8B1E3-1DFA-4443-B08F-9FA6B960B8A5@kaospilot.dk/old?h=master'>old</a></div><div class='content'><div class='cgit-panel'><b>diff options</b><form method='get'><input type='hidden' name='h' value='master'/><table><tr><td colspan='2'/></tr><tr><td class='label'>context:</td><td class='ctrl'><select name='context' onchange='this.form.submit();'><option value='1'>1</option><option value='2'>2</option><option value='3' selected='selected'>3</option><option value='4'>4</option><option value='5'>5</option><option value='6'>6</option><option value='7'>7</option><option value='8'>8</option><option value='9'>9</option><option value='10'>10</option><option value='15'>15</option><option value='20'>20</option><option value='25'>25</option><option value='30'>30</option><option value='35'>35</option><option value='40'>40</option></select></td></tr><tr><td class='label'>space:</td><td class='ctrl'><select name='ignorews' onchange='this.form.submit();'><option value='0' selected='selected'>include</option><option value='1'>ignore</option></select></td></tr><tr><td class='label'>mode:</td><td class='ctrl'><select name='dt' onchange='this.form.submit();'><option value='0' selected='selected'>unified</option><option value='1'>ssdiff</option><option value='2'>stat only</option></select></td></tr><tr><td/><td class='ctrl'><noscript><input type='submit' value='reload'/></noscript></td></tr></table></form></div><div class='diffstat-header'><a href='/notmuch/diff/?h=master'>Diffstat</a> (limited to 'tags/29/0c/22B8B1E3-1DFA-4443-B08F-9FA6B960B8A5@kaospilot.dk/old')</div><table summary='diffstat' class='diffstat'><tr><td class='mode'>-rw-r--r--</td><td class='add'><a href='/notmuch/diff/tags/29/0c/22B8B1E3-1DFA-4443-B08F-9FA6B960B8A5@kaospilot.dk/old?h=master'>tags/29/0c/22B8B1E3-1DFA-4443-B08F-9FA6B960B8A5@kaospilot.dk/old</a></td><td class='right'>0</td><td class='graph'><table summary='file diffstat' width='0%'><tr><td class='add' style='width: -nan%;'/><td class='rem' style='width: -nan%;'/><td class='none' style='width: -nan%;'/></tr></table></td></tr>
</table><div class='diffstat-summary'>1 files changed, 0 insertions, 0 deletions</div><table summary='diff' class='diff'><tr><td> class='add' style='width: -nan%;'/><td class='rem' style='width: -nan%;'/><td class='none' style='width: -nan%;'/></tr></table></td></tr>
<tr><td class='mode'>-rw-r--r--</td><td class='add'><a href='/notmuch/diff/tags/a4/d0/20140526103955.GB15479@master.debian.org/debian?h=master'>tags/a4/d0/20140526103955.GB15479@master.debian.org/debian</a></td><td class='right'>0</td><td class='graph'><table summary='file diffstat' width='0%'><tr><td class='add' style='width: -nan%;'/><td class='rem' style='width: -nan%;'/><td class='none' style='width: -nan%;'/></tr></table></td></tr>
<tr><td class='mode'>-rw-r--r--</td><td class='add'><a href='/notmuch/diff/tags/a4/d0/20140526103955.GB15479@master.debian.org/unread?h=master'>tags/a4/d0/20140526103955.GB15479@master.debian.org/unread</a></td><td class='right'>0</td><td class='graph'><table summary='file diffstat' width='0%'><tr><td class='add' style='width: -nan%;'/><td class='rem' style='width: -nan%;'/><td class='none' style='width: -nan%;'/></tr></table></td></tr>
<tr><td class='mode'>-rw-r--r--</td><td class='add'><a href='/notmuch/diff/tags/a4/d0/20161117040002.275A090@lxp5.free-owl.de/sys?h=master'>tags/a4/d0/20161117040002.275A090@lxp5.free-owl.de/sys</a></td><td class='right'>0</td><td class='graph'><table summary='file diffstat' width='0%'><tr><td class='add' style='width: -nan%;'/><td class='rem' style='width: -nan%;'/><td class='none' style='width: -nan%;'/></tr></table></td></tr>
<tr><td class='mode'>-rw-r--r--</td><td class='add'><a href='/notmuch/diff/tags/a4/d0/20161117040002.275A090@lxp5.free-owl.de/unread?h=master'>tags/a4/d0/20161117040002.275A090@lxp5.free-owl.de/unread</a></td><td class='right'>0</td><td class='graph'><table summary='file diffstat' width='0%'><tr><td class='add' style='width: -nan%;'/><td class='rem' style='width: -nan%;'/><td class='none' style='width: -nan%;'/></tr></table></td></tr>
<tr><td class='mode'>-rw-r--r--</td><td class='add'><a href='/notmuch/diff/tags/a4/d0/20170713190002.0D0C27355@lxp5.free-owl.de/sys?h=master'>tags/a4/d0/20170713190002.0D0C27355@lxp5.free-owl.de/sys</a></td><td class='right'>0</td><td class='graph'><table summary='file diffstat' width='0%'><tr><td class='add' style='width: -nan%;'/><td class='rem' style='width: -nan%;'/><td class='none' style='width: -nan%;'/></tr></table></td></tr>
<tr><td class='mode'>-rw-r--r--</td><td class='add'><a href='/notmuch/diff/tags/a4/d0/20170713190002.0D0C27355@lxp5.free-owl.de/unread?h=master'>tags/a4/d0/20170713190002.0D0C27355@lxp5.free-owl.de/unread</a></td><td class='right'>0</td><td class='graph'><table summary='file diffstat' width='0%'><tr><td class='add' style='width: -nan%;'/><td class='rem' style='width: -nan%;'/><td class='none' style='width: -nan%;'/></tr></table></td></tr>
<tr><td class='mode'>-rw-r--r--</td><td class='add'><a href='/notmuch/diff/tags/a4/d0/20170816020002.A842A74B3@lxp5.free-owl.de/sys?h=master'>tags/a4/d0/20170816020002.A842A74B3@lxp5.free-owl.de/sys</a></td><td class='right'>0</td><td class='graph'><table summary='file diffstat' width='0%'><tr><td class='add' style='width: -nan%;'/><td class='rem' style='width: -nan%;'/><td class='none' style='width: -nan%;'/></tr></table></td></tr>
<tr><td class='mode'>-rw-r--r--</td><td class='add'><a href='/notmuch/diff/tags/a4/d0/20170816020002.A842A74B3@lxp5.free-owl.de/unread?h=master'>tags/a4/d0/20170816020002.A842A74B3@lxp5.free-owl.de/unread</a></td><td class='right'>0</td><td class='graph'><table summary='file diffstat' width='0%'><tr><td class='add' style='width: -nan%;'/><td class='rem' style='width: -nan%;'/><td class='none' style='width: -nan%;'/></tr></table></td></tr>
<tr><td class='mode'>-rw-r--r--</td><td class='add'><a href='/notmuch/diff/tags/a4/d0/4CCB3115.6080507@periapt.co.uk/debian?h=master'>tags/a4/d0/4CCB3115.6080507@periapt.co.uk/debian</a></td><td class='right'>0</td><td class='graph'><table summary='file diffstat' width='0%'><tr><td class='add' style='width: -nan%;'/><td class='rem' style='width: -nan%;'/><td class='none' style='width: -nan%;'/></tr></table></td></tr>
<tr><td class='mode'>-rw-r--r--</td><td class='add'><a href='/notmuch/diff/tags/a4/d0/729e4e0afd1f6b6484a4b288415ff76bdf9e93b8.camel@puri.sm/signed?h=master'>tags/a4/d0/729e4e0afd1f6b6484a4b288415ff76bdf9e93b8.camel@puri.sm/signed</a></td><td class='right'>0</td><td class='graph'><table summary='file diffstat' width='0%'><tr><td class='add' style='width: -nan%;'/><td class='rem' style='width: -nan%;'/><td class='none' style='width: -nan%;'/></tr></table></td></tr>
<tr><td class='mode'>-rw-r--r--</td><td class='add'><a href='/notmuch/diff/tags/a4/d0/729e4e0afd1f6b6484a4b288415ff76bdf9e93b8.camel@puri.sm/unread?h=master'>tags/a4/d0/729e4e0afd1f6b6484a4b288415ff76bdf9e93b8.camel@puri.sm/unread</a></td><td class='right'>0</td><td class='graph'><table summary='file diffstat' width='0%'><tr><td class='add' style='width: -nan%;'/><td class='rem' style='width: -nan%;'/><td class='none' style='width: -nan%;'/></tr></table></td></tr>
<tr><td class='mode'>-rw-r--r--</td><td class='add'><a href='/notmuch/diff/tags/a4/d0/CABMQnV+C9GAxK1SvOmPMztDT4XriWM6P5o%3dFzUqZcjq0f8BV7Q@mail.gmail.com/debian?h=master'>tags/a4/d0/CABMQnV+C9GAxK1SvOmPMztDT4XriWM6P5o=FzUqZcjq0f8BV7Q@mail.gmail.com/debian</a></td><td class='right'>0</td><td class='graph'><table summary='file diffstat' width='0%'><tr><td class='add' style='width: -nan%;'/><td class='rem' style='width: -nan%;'/><td class='none' style='width: -nan%;'/></tr></table></td></tr>
<tr><td class='mode'>-rw-r--r--</td><td class='add'><a href='/notmuch/diff/tags/a4/d0/SNT108-W932B6B907DFDCDD92A2968B250@phx.gbl/inbox?h=master'>tags/a4/d0/SNT108-W932B6B907DFDCDD92A2968B250@phx.gbl/inbox</a></td><td class='right'>0</td><td class='graph'><table summary='file diffstat' width='0%'><tr><td class='add' style='width: -nan%;'/><td class='rem' style='width: -nan%;'/><td class='none' style='width: -nan%;'/></tr></table></td></tr>
<tr><td class='mode'>-rw-r--r--</td><td class='add'><a href='/notmuch/diff/tags/a4/d0/SNT108-W932B6B907DFDCDD92A2968B250@phx.gbl/old?h=master'>tags/a4/d0/SNT108-W932B6B907DFDCDD92A2968B250@phx.gbl/old</a></td><td class='right'>0</td><td class='graph'><table summary='file diffstat' width='0%'><tr><td class='add' style='width: -nan%;'/><td class='rem' style='width: -nan%;'/><td class='none' style='width: -nan%;'/></tr></table></td></tr>
<tr><td class='mode'>-rw-r--r--</td><td class='add'><a href='/notmuch/diff/tags/a4/d0/SNT108-W932B6B907DFDCDD92A2968B250@phx.gbl/replied?h=master'>tags/a4/d0/SNT108-W932B6B907DFDCDD92A2968B250@phx.gbl/replied</a></td><td class='right'>0</td><td class='graph'><table summary='file diffstat' width='0%'><tr><td class='add' style='width: -nan%;'/><td class='rem' style='width: -nan%;'/><td class='none' style='width: -nan%;'/></tr></table></td></tr>
<tr><td class='mode'>-rw-r--r--</td><td class='add'><a href='/notmuch/diff/tags/a4/d0/e95f3047d285001d0d6335785bd0df2b@3e723b591bdb95ce8f5c9b7032dc572ca97351d0da5efc73459c1fbaf438e43b/unread?h=master'>tags/a4/d0/e95f3047d285001d0d6335785bd0df2b@3e723b591bdb95ce8f5c9b7032dc572ca97351d0da5efc73459c1fbaf438e43b/unread</a></td><td class='right'>0</td><td class='graph'><table summary='file diffstat' width='0%'><tr><td class='add' style='width: -nan%;'/><td class='rem' style='width: -nan%;'/><td class='none' style='width: -nan%;'/></tr></table></td></tr>
<tr><td class='mode'>-rw-r--r--</td><td class='add'><a href='/notmuch/diff/tags/a4/d0/mailman.1193.1635304119.29772.pkg-javascript-devel@alioth-lists.debian.net/inbox?h=master'>tags/a4/d0/mailman.1193.1635304119.29772.pkg-javascript-devel@alioth-lists.debian.net/inbox</a></td><td class='right'>0</td><td class='graph'><table summary='file diffstat' width='0%'><tr><td class='add' style='width: -nan%;'/><td class='rem' style='width: -nan%;'/><td class='none' style='width: -nan%;'/></tr></table></td></tr>
<tr><td class='mode'>-rw-r--r--</td><td class='add'><a href='/notmuch/diff/tags/a4/d0/mailman.1193.1635304119.29772.pkg-javascript-devel@alioth-lists.debian.net/killed?h=master'>tags/a4/d0/mailman.1193.1635304119.29772.pkg-javascript-devel@alioth-lists.debian.net/killed</a></td><td class='right'>0</td><td class='graph'><table summary='file diffstat' width='0%'><tr><td class='add' style='width: -nan%;'/><td class='rem' style='width: -nan%;'/><td class='none' style='width: -nan%;'/></tr></table></td></tr>
<tr><td class='mode'>-rw-r--r--</td><td class='add'><a href='/notmuch/diff/tags/a4/d0/mailman.1193.1635304119.29772.pkg-javascript-devel@alioth-lists.debian.net/unread?h=master'>tags/a4/d0/mailman.1193.1635304119.29772.pkg-javascript-devel@alioth-lists.debian.net/unread</a></td><td class='right'>0</td><td class='graph'><table summary='file diffstat' width='0%'><tr><td class='add' style='width: -nan%;'/><td class='rem' style='width: -nan%;'/><td class='none' style='width: -nan%;'/></tr></table></td></tr>
<tr><td class='mode'>-rw-r--r--</td><td class='add'><a href='/notmuch/diff/tags/a4/d0/qii7lb%2524110s%25242@blaine.gmane.org/debian?h=master'>tags/a4/d0/qii7lb%24110s%242@blaine.gmane.org/debian</a></td><td class='right'>0</td><td class='graph'><table summary='file diffstat' width='0%'><tr><td class='add' style='width: -nan%;'/><td class='rem' style='width: -nan%;'/><td class='none' style='width: -nan%;'/></tr></table></td></tr>
<tr><td class='mode'>-rw-r--r--</td><td class='add'><a href='/notmuch/diff/tags/a4/d0/qii7lb%2524110s%25242@blaine.gmane.org/unread?h=master'>tags/a4/d0/qii7lb%24110s%242@blaine.gmane.org/unread</a></td><td class='right'>0</td><td class='graph'><table summary='file diffstat' width='0%'><tr><td class='add' style='width: -nan%;'/><td class='rem' style='width: -nan%;'/><td class='none' style='width: -nan%;'/></tr></table></td></tr>
</table><div class='diffstat-summary'>24 files changed, 0 insertions, 0 deletions</div><table summary='diff' class='diff'><tr><td>