root/sql/sprocs/stratcon.map_uuid_to_sid.sql

Revision 47a77d02f1268e637a4807266064909be566e1f7, 1.0 kB (checked in by Theo Schlossnagle <jesus@omniti.com>, 5 years ago)

flag-day(stratcond,webconsole,database) get realtime graphs working on uuids

  • Property mode set to 100644
Line 
1 CREATE OR REPLACE FUNCTION stratcon.map_uuid_to_sid(in v_uuid uuid, in v_noit text, out o_sid int, out o_noit text, out o_storage_node_id int, out o_fqdn text, out o_dsn text)
2 RETURNS RECORD
3 AS $$
4 BEGIN
5     -- we don't currently do anything with the noit name,
6     -- but I think we had a reason to use it
7
8     SELECT sid, storage_node_id, noit, fqdn, dsn
9       FROM stratcon.map_uuid_to_sid LEFT JOIN stratcon.storage_node USING (storage_node_id)
10      WHERE id = v_uuid INTO o_sid, o_storage_node_id, o_noit, o_fqdn, o_dsn;
11     IF NOT FOUND THEN
12
13         SELECT nextval('stratcon.map_uuid_to_sid_sid_seq') INTO o_sid; 
14         SELECT * FROM stratcon.choose_storage_node_for_sid(v_uuid, v_noit) INTO o_storage_node_id, o_fqdn, o_dsn;
15
16         INSERT INTO stratcon.map_uuid_to_sid(id,sid,noit,storage_node_id) VALUES (v_uuid, o_sid, v_noit, o_storage_node_id);
17
18     END IF;
19
20 END
21 $$ LANGUAGE plpgsql
22 SECURITY DEFINER
23 ;
24
25 GRANT EXECUTE ON FUNCTION stratcon.map_uuid_to_sid(uuid,text) TO stratcon;
26
Note: See TracBrowser for help on using the browser.