From dbc3cbf0266ba325fe70eabad9e73e14cf0e58ef Mon Sep 17 00:00:00 2001
From: Jaime Perez Crespo <jaime.perez@uninett.no>
Date: Thu, 2 Jun 2016 11:53:07 +0200
Subject: [PATCH] Use LONGTEXT instead of the TEXT data type in MySQL to avoid
 size constraints in the latter. This resolves #399.

---
 lib/SimpleSAML/Store/SQL.php | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/SimpleSAML/Store/SQL.php b/lib/SimpleSAML/Store/SQL.php
index 9a3666a7c..534f2eaee 100644
--- a/lib/SimpleSAML/Store/SQL.php
+++ b/lib/SimpleSAML/Store/SQL.php
@@ -95,7 +95,12 @@ class SimpleSAML_Store_SQL extends SimpleSAML_Store {
 			return;
 		}
 
-		$query = 'CREATE TABLE ' . $this->prefix . '_kvstore (_type VARCHAR(30) NOT NULL, _key VARCHAR(50) NOT NULL, _value TEXT NOT NULL, _expire TIMESTAMP, PRIMARY KEY (_key, _type))';
+		$text_t = 'TEXT';
+		if ($this->driver === 'mysql') {
+			// TEXT data type has size constraints that can be hit at some point, so we use LONGTEXT instead
+			$text_t = 'LONGTEXT';
+		}
+		$query = 'CREATE TABLE ' . $this->prefix . '_kvstore (_type VARCHAR(30) NOT NULL, _key VARCHAR(50) NOT NULL, _value '.$text_t.' NOT NULL, _expire TIMESTAMP, PRIMARY KEY (_key, _type))';
 		$this->pdo->exec($query);
 
 		$query = 'CREATE INDEX ' . $this->prefix . '_kvstore_expire ON '  . $this->prefix . '_kvstore (_expire)';
-- 
GitLab