From fa7bc8cf632a04f39aef22603168f8deff340fea Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Fri, 19 Dec 2008 19:56:59 +0000 Subject: [PATCH] ebl speedup a bit base64_decode_lstat ebl set base64_decode_lstat as IMMUTABLE STRICT to be able to create index with this function git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8194 91ce42f0-d328-0410-95d8-f526ca767f89 --- gui/bweb/script/bweb-postgresql.sql | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gui/bweb/script/bweb-postgresql.sql b/gui/bweb/script/bweb-postgresql.sql index 9c20d7b110..fbea337cae 100644 --- a/gui/bweb/script/bweb-postgresql.sql +++ b/gui/bweb/script/bweb-postgresql.sql @@ -235,9 +235,11 @@ RETURNS double precision AS $$ select extract(epoch from $1); $$ LANGUAGE SQL; -CREATE OR REPLACE FUNCTION base64_decode_lstat(int4, varchar) RETURNS int8 AS $$ +CREATE OR REPLACE FUNCTION base64_decode_lstat(int4, varchar) RETURNS int8 +IMMUTABLE STRICT AS $$ DECLARE val int8; +len int8; b64 varchar(64); size varchar(64); i int; @@ -245,8 +247,9 @@ BEGIN size := split_part($2, ' ', $1); b64 := 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; val := 0; -FOR i IN 1..length(size) LOOP -val := val + (strpos(b64, substr(size, i, 1))-1) * (64^(length(size)-i)); +len=length(size); +FOR i IN 1..len LOOP +val := val + (strpos(b64, substr(size, i, 1))-1) * (64^(len-i)); END LOOP; RETURN val; END; -- 2.39.5