From b7cd45a615e670ea2a6419e2e02dd3d6d1850c90 Mon Sep 17 00:00:00 2001
From: Daniel <d.hornung@indiscale.com>
Date: Wed, 2 Oct 2024 10:22:19 +0200
Subject: [PATCH] FIX: "Offset" is a reserved keyword in MariaDB 10.6

---
 patches/applyPatches.sh              | 1 -
 patches/patch20231211-7.0.2/patch.sh | 6 ------
 procedures/entityVersioning.sql      | 6 +++---
 utils/update_sql_procedures.sh       | 2 +-
 4 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/patches/applyPatches.sh b/patches/applyPatches.sh
index 72754cc..85bdad8 100755
--- a/patches/applyPatches.sh
+++ b/patches/applyPatches.sh
@@ -47,6 +47,5 @@ do
 done
 
 cd ../
-echo "updating procedures"
 
 $UTILSPATH/update_sql_procedures.sh
diff --git a/patches/patch20231211-7.0.2/patch.sh b/patches/patch20231211-7.0.2/patch.sh
index c9a8c31..422fc00 100755
--- a/patches/patch20231211-7.0.2/patch.sh
+++ b/patches/patch20231211-7.0.2/patch.sh
@@ -34,14 +34,8 @@ fi
 
 check_version $OLD_VERSION
 
-echo "version checked"
-
 mysql_execute "UPDATE data_type SET datatype=17 WHERE datatype=3"
 
-echo "updated"
-
 update_version $NEW_VERSION
 
-echo "version updated"
-
 success
diff --git a/procedures/entityVersioning.sql b/procedures/entityVersioning.sql
index b474d01..5adaa4d 100644
--- a/procedures/entityVersioning.sql
+++ b/procedures/entityVersioning.sql
@@ -283,7 +283,7 @@ DROP FUNCTION IF EXISTS db_5_0.get_head_relative //
  * ----------
  * EntityID : VARCHAR(255)
  *   The entity id.
- * Offset : INT UNSIGNED
+ * HeadOffset : INT UNSIGNED
  *   Distance in the sequence of primary parents of the entity. E.g. `0` is the
  *   HEAD itself. `1` is the primary parent of the HEAD. `2` is the primary
  *   parent of the primary parent of the HEAD, and so on.
@@ -294,7 +294,7 @@ DROP FUNCTION IF EXISTS db_5_0.get_head_relative //
  */
 CREATE FUNCTION db_5_0.get_head_relative(
     EntityID VARCHAR(255),
-    Offset INT UNSIGNED)
+    HeadOffset INT UNSIGNED)
 RETURNS VARBINARY(255)
 READS SQL DATA
 BEGIN
@@ -311,7 +311,7 @@ BEGIN
             FROM entity_version AS e
             WHERE e.entity_id = InternalEntityID
             ORDER BY e._iversion DESC
-            LIMIT 1 OFFSET Offset
+            LIMIT 1 OFFSET HeadOffset
         );
 END;
 //
diff --git a/utils/update_sql_procedures.sh b/utils/update_sql_procedures.sh
index b9a9e7f..00069fa 100755
--- a/utils/update_sql_procedures.sh
+++ b/utils/update_sql_procedures.sh
@@ -37,7 +37,7 @@ fi
 source $UTILSPATH/load_settings.sh
 source $UTILSPATH/helpers.sh
 
-echo -n "updating procedures ... "
+echo "Updating procedures ... "
 temp_proc_sql=$(mktemp --suffix=.sql)
 sed -e "s/db_5_0/$DATABASE_NAME/g" procedures/*.sql procedures/query/*.sql \
     > "$temp_proc_sql"
-- 
GitLab