Created
January 21, 2014 08:12
-
-
Save bububa/8536141 to your computer and use it in GitHub Desktop.
plproxy query setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE FUNCTION "plproxy"."get_cluster_config"(IN cluster_name text, OUT "key" text, OUT val text) RETURNS SETOF "record" | |
AS $BODY$ | |
begin | |
key := 'statement_timeout'; | |
val := 60; | |
return next; | |
return; | |
end; $BODY$ | |
LANGUAGE plpgsql | |
COST 100 | |
ROWS 1000 | |
CALLED ON NULL INPUT | |
SECURITY INVOKER | |
VOLATILE; | |
ALTER FUNCTION "plproxy"."get_cluster_config"(IN cluster_name text, OUT "key" text, OUT val text) OWNER TO "turbo"; | |
CREATE FUNCTION "plproxy"."get_cluster_partitions"(IN cluster_name text) RETURNS SETOF "text" | |
AS $BODY$ | |
BEGIN | |
IF cluster_name = 'sem' THEN | |
RETURN NEXT 'dbname=kwinsights host=code1 user=turbo'; | |
RETURN NEXT 'dbname=kwinsights host=code2 user=turbo'; | |
RETURN NEXT 'dbname=kwinsights host=code5 user=turbo'; | |
RETURN NEXT 'dbname=kwinsights host=code6 user=turbo'; | |
RETURN; | |
END IF; | |
RAISE EXCEPTION 'Unknown cluster'; | |
END; | |
$BODY$ | |
LANGUAGE plpgsql | |
COST 100 | |
ROWS 1000 | |
CALLED ON NULL INPUT | |
SECURITY INVOKER | |
VOLATILE; | |
ALTER FUNCTION "plproxy"."get_cluster_partitions"(IN cluster_name text) OWNER TO "turbo"; | |
CREATE FUNCTION "plproxy"."get_cluster_version"(IN cluster_name text) RETURNS "int4" | |
AS $BODY$ | |
BEGIN | |
IF cluster_name = 'sem' THEN | |
RETURN 1; | |
END IF; | |
RAISE EXCEPTION 'Unknown cluster'; | |
END; | |
$BODY$ | |
LANGUAGE plpgsql | |
COST 100 | |
CALLED ON NULL INPUT | |
SECURITY INVOKER | |
VOLATILE; | |
ALTER FUNCTION "plproxy"."get_cluster_version"(IN cluster_name text) OWNER TO "turbo"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment