From 8dbf1b81438fa4686b4b5224b08ecf93a38332d5 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Tue, 7 Oct 2008 18:41:41 +0000 Subject: [PATCH] ebl add base64_decode_lstat function to Mysql (require mysql > 5) git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7727 91ce42f0-d328-0410-95d8-f526ca767f89 --- gui/bweb/script/bweb-mysql.sql | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/gui/bweb/script/bweb-mysql.sql b/gui/bweb/script/bweb-mysql.sql index 0fb5bb457e..9494e104d9 100644 --- a/gui/bweb/script/bweb-mysql.sql +++ b/gui/bweb/script/bweb-mysql.sql @@ -1,3 +1,37 @@ +-- -------------------------------------------------- +-- Upgrade from 2.4 +-- -------------------------------------------------- + +delimiter | + +DROP FUNCTION IF EXISTS base64_decode_lstat | +CREATE FUNCTION base64_decode_lstat (field INTEGER, input BLOB) + RETURNS BIGINT + CONTAINS SQL + DETERMINISTIC + SQL SECURITY INVOKER +BEGIN + DECLARE first_char BINARY(1); + DECLARE accum_value BIGINT UNSIGNED DEFAULT 0; + + -- The number of fields can vary, so we need 2 calls to SUBSTRING_INDEX + SET input = SUBSTRING_INDEX(SUBSTRING_INDEX(input, ' ', field), + ' ', -1); + + WHILE LENGTH(input) > 0 DO + SET first_char = SUBSTRING(input, 1, 1); + SET input = SUBSTRING(input, 2); + + SET accum_value = (accum_value << 6) + + INSTR('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/', + first_char)-1; + END WHILE; + + RETURN accum_value; +END | + +delimiter ; + -- -------------------------------------------------- -- Upgrade from 2.2 -- -------------------------------------------------- -- 2.39.5