root/sql/sprocs/stratcon.map_uuid_to_sid.sql

Revision 003566b519017539659f61ab68d038cb3218e43b, 0.8 kB (checked in by Robert Treat <robert@omniti.com>, 5 years ago)

give me a uuid and it's noit, i'll give you a sid and which node to put it on

  • 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_dsn text)
2 RETURNS RECORD
3 AS $$
4 DECLARE
5     v_new_storage_node_id int;
6 BEGIN
7     -- we don't currently do anything with the noit name,
8     -- but I think we had a reason to use it
9
10     SELECT sid, dsn FROM stratcon.map_uuid_to_sid LEFT JOIN stratcon.storage_node USING (storage_node_id) WHERE id = v_uuid INTO o_sid, 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() INTO v_new_storage_node_id, o_dsn;
15
16         INSERT INTO stratcon.map_uuid_to_sid(id,sid,storage_node_id) VALUES (v_uuid, o_sid, v_new_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.