RANGER-2114 : Internal Exception: com.mysql.jdbc.MysqlDataTruncation: Data 
truncation: Data too long for

column 'content' at row 1

Signed-off-by: Gautam Borad <gau...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/ranger/commit/0ab1077b
Tree: http://git-wip-us.apache.org/repos/asf/ranger/tree/0ab1077b
Diff: http://git-wip-us.apache.org/repos/asf/ranger/diff/0ab1077b

Branch: refs/heads/ranger-1
Commit: 0ab1077ba729625b78d7b3361bd3458e89e3ea0b
Parents: e936dd7
Author: fatimaawez <fatimakhan4...@gmail.com>
Authored: Fri Aug 10 15:37:40 2018 +0530
Committer: Mehul Parikh <me...@apache.org>
Committed: Wed Aug 29 14:29:53 2018 +0530

----------------------------------------------------------------------
 .../optimized/current/ranger_core_db_mysql.sql  |  3 +-
 .../patches/034-x_data_histContentSize.sql      | 31 ++++++++++++++++++++
 2 files changed, 33 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ranger/blob/0ab1077b/security-admin/db/mysql/optimized/current/ranger_core_db_mysql.sql
----------------------------------------------------------------------
diff --git a/security-admin/db/mysql/optimized/current/ranger_core_db_mysql.sql 
b/security-admin/db/mysql/optimized/current/ranger_core_db_mysql.sql
index 9d200ba..3f23b00 100644
--- a/security-admin/db/mysql/optimized/current/ranger_core_db_mysql.sql
+++ b/security-admin/db/mysql/optimized/current/ranger_core_db_mysql.sql
@@ -923,7 +923,7 @@ CREATE TABLE `x_data_hist` (
 `action` varchar(512) NOT NULL,
 `from_time` datetime NOT NULL,
 `to_time` datetime DEFAULT NULL,
-`content` text NOT NULL,
+`content` MEDIUMTEXT NOT NULL,
 primary key (`id`)
 )ROW_FORMAT=DYNAMIC;
 
@@ -1345,6 +1345,7 @@ INSERT INTO x_db_version_h 
(version,inst_at,inst_by,updated_at,updated_by,active
 INSERT INTO x_db_version_h 
(version,inst_at,inst_by,updated_at,updated_by,active) VALUES 
('031',UTC_TIMESTAMP(),'Ranger 1.0.0',UTC_TIMESTAMP(),'localhost','Y');
 INSERT INTO x_db_version_h 
(version,inst_at,inst_by,updated_at,updated_by,active) VALUES 
('032',UTC_TIMESTAMP(),'Ranger 1.0.0',UTC_TIMESTAMP(),'localhost','Y');
 INSERT INTO x_db_version_h 
(version,inst_at,inst_by,updated_at,updated_by,active) VALUES 
('033',UTC_TIMESTAMP(),'Ranger 1.0.0',UTC_TIMESTAMP(),'localhost','Y');
+INSERT INTO x_db_version_h 
(version,inst_at,inst_by,updated_at,updated_by,active) VALUES 
('034',UTC_TIMESTAMP(),'Ranger 2.0.0',UTC_TIMESTAMP(),'localhost','Y');
 INSERT INTO x_db_version_h 
(version,inst_at,inst_by,updated_at,updated_by,active) VALUES 
('DB_PATCHES',UTC_TIMESTAMP(),'Ranger 1.0.0',UTC_TIMESTAMP(),'localhost','Y');
 INSERT INTO x_user_module_perm 
(user_id,module_id,create_time,update_time,added_by_id,upd_by_id,is_allowed) 
VALUES (1,3,UTC_TIMESTAMP(),UTC_TIMESTAMP(),1,1,1);
 INSERT INTO x_user_module_perm 
(user_id,module_id,create_time,update_time,added_by_id,upd_by_id,is_allowed) 
VALUES (1,1,UTC_TIMESTAMP(),UTC_TIMESTAMP(),1,1,1);

http://git-wip-us.apache.org/repos/asf/ranger/blob/0ab1077b/security-admin/db/mysql/patches/034-x_data_histContentSize.sql
----------------------------------------------------------------------
diff --git a/security-admin/db/mysql/patches/034-x_data_histContentSize.sql 
b/security-admin/db/mysql/patches/034-x_data_histContentSize.sql
new file mode 100644
index 0000000..18aa20f
--- /dev/null
+++ b/security-admin/db/mysql/patches/034-x_data_histContentSize.sql
@@ -0,0 +1,31 @@
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+
+drop procedure if exists change_content_column_datatype_of_x_data_hist_table;
+
+delimiter ;;
+create procedure change_content_column_datatype_of_x_data_hist_table() begin
+
+ /* change content data type to longtext if not exist */
+ if exists (select * from information_schema.columns where 
table_schema=database() and table_name = 'x_data_hist' and column_name = 
'content' and data_type='text') then
+       ALTER TABLE  `x_data_hist` CHANGE `content` `content` MEDIUMTEXT NOT 
NULL;
+ end if;
+
+end;;
+
+delimiter ;
+call change_content_column_datatype_of_x_data_hist_table();
+
+drop procedure if exists change_content_column_datatype_of_x_data_hist_table;

Reply via email to