You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by me...@apache.org on 2020/08/12 09:53:14 UTC

[ranger] branch ranger-2.1 updated: RANGER-2923 : Changing data type of sync_source_info column to accommodate more characters

This is an automated email from the ASF dual-hosted git repository.

mehul pushed a commit to branch ranger-2.1
in repository https://gitbox.apache.org/repos/asf/ranger.git


The following commit(s) were added to refs/heads/ranger-2.1 by this push:
     new 087aef3  RANGER-2923 : Changing data type of sync_source_info column to accommodate more characters
087aef3 is described below

commit 087aef3b31ef6a16d42806b0b06ebaca1c4dc7a2
Author: Mahesh Bandal <ma...@gmail.com>
AuthorDate: Wed Aug 5 19:56:07 2020 +0530

    RANGER-2923 : Changing data type of sync_source_info column to accommodate more characters
    
    Signed-off-by: Mehul Parikh <me...@apache.org>
---
 .../optimized/current/ranger_core_db_mysql.sql     |  3 +-
 ...ter-sync-source-info-in-x-ugsync-audit-info.sql | 27 ++++++++++++++
 .../optimized/current/ranger_core_db_oracle.sql    |  3 +-
 ...ter-sync-source-info-in-x-ugsync-audit-info.sql | 41 ++++++++++++++++++++++
 .../optimized/current/ranger_core_db_postgres.sql  |  3 +-
 ...ter-sync-source-info-in-x-ugsync-audit-info.sql | 31 ++++++++++++++++
 .../current/ranger_core_db_sqlanywhere.sql         |  4 ++-
 ...ter-sync-source-info-in-x-ugsync-audit-info.sql | 30 ++++++++++++++++
 .../optimized/current/ranger_core_db_sqlserver.sql |  3 +-
 ...ter-sync-source-info-in-x-ugsync-audit-info.sql | 21 +++++++++++
 10 files changed, 161 insertions(+), 5 deletions(-)

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 832d650..dfaf3c9 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
@@ -1313,7 +1313,7 @@ CREATE TABLE IF NOT EXISTS `x_ugsync_audit_info`(
 `no_of_new_groups` bigint(20) NOT NULL,
 `no_of_modified_users` bigint(20) NOT NULL,
 `no_of_modified_groups` bigint(20) NOT NULL,
-`sync_source_info` varchar(4000) NOT NULL,
+`sync_source_info` MEDIUMTEXT NOT NULL,
 `session_id` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `x_ugsync_audit_info_etime`(`event_time`),
@@ -1676,6 +1676,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 ('045',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 ('046',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 ('047',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 ('048',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 ('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)
diff --git a/security-admin/db/mysql/patches/048-alter-sync-source-info-in-x-ugsync-audit-info.sql b/security-admin/db/mysql/patches/048-alter-sync-source-info-in-x-ugsync-audit-info.sql
new file mode 100644
index 0000000..064565d
--- /dev/null
+++ b/security-admin/db/mysql/patches/048-alter-sync-source-info-in-x-ugsync-audit-info.sql
@@ -0,0 +1,27 @@
+-- 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 alter_table_x_ugsync_audit_info;
+
+delimiter ;;
+create procedure alter_table_x_ugsync_audit_info() begin
+
+if exists (select * from information_schema.columns where table_schema=database() and table_name = 'x_ugsync_audit_info' and column_name = 'sync_source_info' and data_type='varchar') then
+	ALTER TABLE `x_ugsync_audit_info` MODIFY `sync_source_info` MEDIUMTEXT NOT NULL;
+ end if;
+end;;
+
+delimiter ;
+call alter_table_x_ugsync_audit_info();
\ No newline at end of file
diff --git a/security-admin/db/oracle/optimized/current/ranger_core_db_oracle.sql b/security-admin/db/oracle/optimized/current/ranger_core_db_oracle.sql
index 4576e96..21626f6 100644
--- a/security-admin/db/oracle/optimized/current/ranger_core_db_oracle.sql
+++ b/security-admin/db/oracle/optimized/current/ranger_core_db_oracle.sql
@@ -1379,7 +1379,7 @@ no_of_new_users NUMBER(20) NOT NULL,
 no_of_new_groups NUMBER(20) NOT NULL,
 no_of_modified_users NUMBER(20) NOT NULL,
 no_of_modified_groups NUMBER(20) NOT NULL,
-sync_source_info VARCHAR(4000) NOT NULL,
+sync_source_info CLOB NOT NULL,
 session_id VARCHAR(255) DEFAULT NULL,
  PRIMARY KEY (id)
 );
@@ -1872,6 +1872,7 @@ INSERT INTO x_db_version_h (id,version,inst_at,inst_by,updated_at,updated_by,act
 INSERT INTO x_db_version_h (id,version,inst_at,inst_by,updated_at,updated_by,active) VALUES (X_DB_VERSION_H_SEQ.nextval, '045',sys_extract_utc(systimestamp),'Ranger 1.0.0',sys_extract_utc(systimestamp),'localhost','Y');
 INSERT INTO x_db_version_h (id,version,inst_at,inst_by,updated_at,updated_by,active) VALUES (X_DB_VERSION_H_SEQ.nextval, '046',sys_extract_utc(systimestamp),'Ranger 1.0.0',sys_extract_utc(systimestamp),'localhost','Y');
 INSERT INTO x_db_version_h (id,version,inst_at,inst_by,updated_at,updated_by,active) VALUES (X_DB_VERSION_H_SEQ.nextval, '047',sys_extract_utc(systimestamp),'Ranger 1.0.0',sys_extract_utc(systimestamp),'localhost','Y');
+INSERT INTO x_db_version_h (id,version,inst_at,inst_by,updated_at,updated_by,active) VALUES (X_DB_VERSION_H_SEQ.nextval, '048',sys_extract_utc(systimestamp),'Ranger 1.0.0',sys_extract_utc(systimestamp),'localhost','Y');
 INSERT INTO x_db_version_h (id,version,inst_at,inst_by,updated_at,updated_by,active) VALUES (X_DB_VERSION_H_SEQ.nextval, 'DB_PATCHES',sys_extract_utc(systimestamp),'Ranger 1.0.0',sys_extract_utc(systimestamp),'localhost','Y');
 
 INSERT INTO x_user_module_perm (id,user_id,module_id,create_time,update_time,added_by_id,upd_by_id,is_allowed) VALUES (X_USER_MODULE_PERM_SEQ.nextval,getXportalUIdByLoginId('admin'),getModulesIdByName('Reports'),sys_extract_utc(systimestamp),sys_extract_utc(systimestamp),getXportalUIdByLoginId('admin'),getXportalUIdByLoginId('admin'),1);
diff --git a/security-admin/db/oracle/patches/048-alter-sync-source-info-in-x-ugsync-audit-info.sql b/security-admin/db/oracle/patches/048-alter-sync-source-info-in-x-ugsync-audit-info.sql
new file mode 100644
index 0000000..b540643
--- /dev/null
+++ b/security-admin/db/oracle/patches/048-alter-sync-source-info-in-x-ugsync-audit-info.sql
@@ -0,0 +1,41 @@
+-- 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.
+-- sync_source_info CLOB NOT NULL,
+
+DECLARE
+        v_column_exists number:=0;
+        v_count number:=0;
+BEGIN
+        select count(*) into v_column_exists from user_tab_cols
+        where column_name = upper('sync_source_info') and table_name = upper('x_ugsync_audit_info');
+        IF (v_column_exists = 1) THEN
+                select count(*) into v_count from user_tab_cols
+                where table_name = upper('x_ugsync_audit_info')
+                        and column_name = upper('sync_source_info_copy')
+                        and DATA_TYPE = upper('VARCHAR2');
+                IF (v_count = 0) THEN
+                        execute immediate 'ALTER TABLE x_ugsync_audit_info ADD sync_source_info_copy CLOB';
+                        commit;
+                        execute immediate 'UPDATE x_ugsync_audit_info SET sync_source_info_copy = sync_source_info';
+                        commit;
+                        execute immediate 'ALTER TABLE x_ugsync_audit_info MODIFY sync_source_info_copy NOT NULL';
+                        commit;
+                        execute immediate 'ALTER TABLE x_ugsync_audit_info DROP COLUMN sync_source_info';
+                        commit;
+                        execute immediate 'ALTER TABLE x_ugsync_audit_info RENAME COLUMN sync_source_info_copy TO sync_source_info';
+                        commit;
+            END IF;
+        END IF;
+END;/
diff --git a/security-admin/db/postgres/optimized/current/ranger_core_db_postgres.sql b/security-admin/db/postgres/optimized/current/ranger_core_db_postgres.sql
index 6a0941f..5cd2cc7 100644
--- a/security-admin/db/postgres/optimized/current/ranger_core_db_postgres.sql
+++ b/security-admin/db/postgres/optimized/current/ranger_core_db_postgres.sql
@@ -1237,7 +1237,7 @@ no_of_new_users bigint NOT NULL,
 no_of_new_groups bigint NOT NULL,
 no_of_modified_users bigint NOT NULL,
 no_of_modified_groups bigint NOT NULL,
-sync_source_info varchar(4000) NOT NULL,
+sync_source_info TEXT NOT NULL,
 session_id varchar(255) DEFAULT NULL,
 primary key (id)
 );
@@ -1799,6 +1799,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 ('045',current_timestamp,'Ranger 1.0.0',current_timestamp,'localhost','Y');
 INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('046',current_timestamp,'Ranger 1.0.0',current_timestamp,'localhost','Y');
 INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('047',current_timestamp,'Ranger 1.0.0',current_timestamp,'localhost','Y');
+INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('048',current_timestamp,'Ranger 1.0.0',current_timestamp,'localhost','Y');
 INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('DB_PATCHES',current_timestamp,'Ranger 1.0.0',current_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
diff --git a/security-admin/db/postgres/patches/048-alter-sync-source-info-in-x-ugsync-audit-info.sql b/security-admin/db/postgres/patches/048-alter-sync-source-info-in-x-ugsync-audit-info.sql
new file mode 100644
index 0000000..f5ac0e1
--- /dev/null
+++ b/security-admin/db/postgres/patches/048-alter-sync-source-info-in-x-ugsync-audit-info.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.
+
+select 'delimiter start';
+CREATE OR REPLACE FUNCTION alter_table_x_ugsync_audit_info()
+RETURNS void AS $$
+DECLARE
+	v_column_exists integer := 0;
+BEGIN
+	select count(*) into v_column_exists from pg_attribute where attrelid in(select oid from pg_class where relname='x_ugsync_audit_info') and attname='sync_source_info' and atttypid = (select oid from pg_type where typname='varchar');
+	IF v_column_exists = 1 THEN
+		ALTER TABLE x_ugsync_audit_info alter column sync_source_info type TEXT;
+	END IF;
+END;
+$$ LANGUAGE plpgsql;
+select 'delimiter end';
+
+select alter_table_x_ugsync_audit_info();
+select 'delimiter end';
\ No newline at end of file
diff --git a/security-admin/db/sqlanywhere/optimized/current/ranger_core_db_sqlanywhere.sql b/security-admin/db/sqlanywhere/optimized/current/ranger_core_db_sqlanywhere.sql
index b663f3b..081b153 100644
--- a/security-admin/db/sqlanywhere/optimized/current/ranger_core_db_sqlanywhere.sql
+++ b/security-admin/db/sqlanywhere/optimized/current/ranger_core_db_sqlanywhere.sql
@@ -1065,7 +1065,7 @@ CREATE TABLE dbo.x_ugsync_audit_info(
 		no_of_new_groups bigint NOT NULL,
 		no_of_modified_users bigint NOT NULL,
 		no_of_modified_groups bigint NOT NULL,
-		sync_source_info varchar(4000) NOT NULL,
+		sync_source_info text NOT NULL,
 		session_id varchar(255) DEFAULT NULL NULL,
 		CONSTRAINT x_ugsync_audit_info_PK_id PRIMARY KEY CLUSTERED(id)
 )
@@ -2163,6 +2163,8 @@ INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active
 GO
 INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('047',CURRENT_TIMESTAMP,'Ranger 1.0.0',CURRENT_TIMESTAMP,'localhost','Y');
 GO
+INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('048',CURRENT_TIMESTAMP,'Ranger 1.0.0',CURRENT_TIMESTAMP,'localhost','Y');
+GO
 INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('DB_PATCHES',CURRENT_TIMESTAMP,'Ranger 1.0.0',CURRENT_TIMESTAMP,'localhost','Y');
 GO
 INSERT INTO x_user_module_perm (user_id,module_id,create_time,update_time,added_by_id,upd_by_id,is_allowed) VALUES (dbo.getXportalUIdByLoginId('admin'),dbo.getModulesIdByName('Reports'),CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,dbo.getXportalUIdByLoginId('admin'),dbo.getXportalUIdByLoginId('admin'),1);
diff --git a/security-admin/db/sqlanywhere/patches/048-alter-sync-source-info-in-x-ugsync-audit-info.sql b/security-admin/db/sqlanywhere/patches/048-alter-sync-source-info-in-x-ugsync-audit-info.sql
new file mode 100644
index 0000000..5a2d439
--- /dev/null
+++ b/security-admin/db/sqlanywhere/patches/048-alter-sync-source-info-in-x-ugsync-audit-info.sql
@@ -0,0 +1,30 @@
+-- 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.
+
+CREATE OR REPLACE PROCEDURE dbo.alterColumnSyncSourceInfoDataType (IN table_name varchar(100))
+AS
+BEGIN
+  DECLARE @stmt VARCHAR(300)
+  IF EXISTS(select * from SYS.SYSCOLUMNS where tname = table_name and cname='sync_source_info' and coltype='varchar')
+  BEGIN
+    SET @stmt = 'ALTER TABLE dbo.' + table_name + ' ALTER sync_source_info text NOT NULL'
+    execute(@stmt)
+  END
+END
+GO
+
+call dbo.alterColumnSyncSourceInfoDataType('x_ugsync_audit_info')
+GO
+EXIT
\ No newline at end of file
diff --git a/security-admin/db/sqlserver/optimized/current/ranger_core_db_sqlserver.sql b/security-admin/db/sqlserver/optimized/current/ranger_core_db_sqlserver.sql
index ab370ff..642d6c1 100644
--- a/security-admin/db/sqlserver/optimized/current/ranger_core_db_sqlserver.sql
+++ b/security-admin/db/sqlserver/optimized/current/ranger_core_db_sqlserver.sql
@@ -2134,7 +2134,7 @@ CREATE TABLE [dbo].[x_ugsync_audit_info](
         [no_of_new_groups] [bigint] NOT NULL,
         [no_of_modified_users] [bigint] NOT NULL,
         [no_of_modified_groups] [bigint] NOT NULL,
-        [sync_source_info] [varchar](4000) NOT NULL,
+        [sync_source_info] [nvarchar](max) NOT NULL,
         [session_id] [varchar](255) DEFAULT NULL NULL,
         PRIMARY KEY CLUSTERED
 (
@@ -3904,6 +3904,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 ('045',CURRENT_TIMESTAMP,'Ranger 1.0.0',CURRENT_TIMESTAMP,'localhost','Y');
 INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('046',CURRENT_TIMESTAMP,'Ranger 1.0.0',CURRENT_TIMESTAMP,'localhost','Y');
 INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('047',CURRENT_TIMESTAMP,'Ranger 1.0.0',CURRENT_TIMESTAMP,'localhost','Y');
+INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('048',CURRENT_TIMESTAMP,'Ranger 1.0.0',CURRENT_TIMESTAMP,'localhost','Y');
 INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('DB_PATCHES',CURRENT_TIMESTAMP,'Ranger 1.0.0',CURRENT_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 (dbo.getXportalUIdByLoginId('admin'),dbo.getModulesIdByName('Reports'),CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,dbo.getXportalUIdByLoginId('admin'),dbo.getXportalUIdByLoginId('admin'),1);
 INSERT INTO x_user_module_perm (user_id,module_id,create_time,update_time,added_by_id,upd_by_id,is_allowed) VALUES (dbo.getXportalUIdByLoginId('admin'),dbo.getModulesIdByName('Resource Based Policies'),CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,dbo.getXportalUIdByLoginId('admin'),dbo.getXportalUIdByLoginId('admin'),1);
diff --git a/security-admin/db/sqlserver/patches/048-alter-sync-source-info-in-x-ugsync-audit-info.sql b/security-admin/db/sqlserver/patches/048-alter-sync-source-info-in-x-ugsync-audit-info.sql
new file mode 100644
index 0000000..68ec2cc
--- /dev/null
+++ b/security-admin/db/sqlserver/patches/048-alter-sync-source-info-in-x-ugsync-audit-info.sql
@@ -0,0 +1,21 @@
+-- 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.
+GO
+IF EXISTS(select * from INFORMATION_SCHEMA.columns where table_name = 'x_ugsync_audit_info' and column_name = 'sync_source_info'  and DATA_TYPE='varchar')
+BEGIN
+	ALTER TABLE [dbo].[x_ugsync_audit_info] ALTER COLUMN [sync_source_info] [nvarchar](max) NOT NULL;
+END
+GO
+EXIT
\ No newline at end of file