Skip to content

Instantly share code, notes, and snippets.

@eMerzh
Created January 20, 2012 11:02
Show Gist options
  • Save eMerzh/e93792540cb3a68054c9 to your computer and use it in GitHub Desktop.
Save eMerzh/e93792540cb3a68054c9 to your computer and use it in GitHub Desktop.
Potsgresql Immutable
CREATE OR REPLACE FUNCTION test_immutable( a int )
RETURNS varchar
LANGUAGE plpgsql
IMMUTABLE
AS $function$
BEGIN
raise notice 'plouf';
return 'toto';
END
$function$
;
CREATE TABLE test (a varchar);
INSERT INTO test values ('a') ;
INSERT INTO test values ('a') ;
INSERT INTO test values ('a') ;
INSERT INTO test values ('a') ;
PREPARE test (int) as select * from test
where a = test_immutable($1);
EXECUTE test(1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment