]> git.sur5r.net Git - bacula/bacula/commitdiff
ebl add base64_decode_lstat function to Mysql (require mysql > 5)
authorEric Bollengier <eric@eb.homelinux.org>
Tue, 7 Oct 2008 18:41:41 +0000 (18:41 +0000)
committerEric Bollengier <eric@eb.homelinux.org>
Tue, 7 Oct 2008 18:41:41 +0000 (18:41 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7727 91ce42f0-d328-0410-95d8-f526ca767f89

gui/bweb/script/bweb-mysql.sql

index 0fb5bb457e57fff2f269dca7f11a121c765bae26..9494e104d999cd5faac75e68e7d32d7870a7bfdc 100644 (file)
@@ -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
 -- --------------------------------------------------