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;
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;