Database Reference
In-Depth Information
BEGIN
FOR i IN 1..array_length(i_username,1) LOOP
SELECT *
INTO status, message
FROM new_user(i_username[i],
i_pwdhash[i], i_email[i]);
RETURN NEXT;
END LOOP;
END;
$$ LANGUAGE plpgsql SECURITY DEFINER;
The following PL/Proxy function definition created on the proxy database can be
used to split the calls across the partitions:
CREATE or REPLACE FUNCTION create_new_users(
IN i_username text[], IN i_pwdhash text[],
IN i_email text[],
OUT status int, OUT message text ) RETURNS
SETOF RECORD
AS $$
CLUSTER 'messaging';
RUN ON hashtext(i_username);
SPLIT i_username, i_pwdhash, i_email;
$$ LANGUAGE plproxy SECURITY DEFINER;
It would be called by sending in three arrays to the function:
SELECT * FROM create_new_users(
ARRAY['bob', 'jane', 'tom'],
ARRAY[md5('bobs_pwd'), md5('janes_pwd'),
md5('toms_pwd')],
ARRAY['bob@mail.com', 'jane@mail.com',
'tom@mail.com']
);
Search WWH ::




Custom Search