Repository: incubator-ranger Updated Branches: refs/heads/master e71e76a51 -> 1be6d9354
RANGER-1063: Increase size of sort_order column of x_policy_item_user_perm and x_policy_item_group_perm table Signed-off-by: Gautam Borad <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/1be6d935 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/1be6d935 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/1be6d935 Branch: refs/heads/master Commit: 1be6d93544448e86d3aa682243499418f2210206 Parents: e71e76a Author: pradeep agrawal <[email protected]> Authored: Sat Jun 25 21:43:34 2016 +0530 Committer: Gautam Borad <[email protected]> Committed: Mon Jul 4 12:16:33 2016 +0530 ---------------------------------------------------------------------- .../mysql/patches/024-sortorder-column-size.sql | 33 +++++++++++++++ .../patches/024-sortorder-column-size.sql | 39 +++++++++++++++++ .../patches/024-sortorder-column-size.sql | 33 +++++++++++++++ .../patches/024-sortorder-column-size.sql | 25 +++++++++++ .../patches/024-sortorder-column-size.sql | 44 ++++++++++++++++++++ 5 files changed, 174 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/1be6d935/security-admin/db/mysql/patches/024-sortorder-column-size.sql ---------------------------------------------------------------------- diff --git a/security-admin/db/mysql/patches/024-sortorder-column-size.sql b/security-admin/db/mysql/patches/024-sortorder-column-size.sql new file mode 100644 index 0000000..a70c11f --- /dev/null +++ b/security-admin/db/mysql/patches/024-sortorder-column-size.sql @@ -0,0 +1,33 @@ +-- 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_sort_order_column_datatype_of_perm_tables; + +delimiter ;; +create procedure change_sort_order_column_datatype_of_perm_tables() begin +DECLARE loginID bigint(20); + /* check tables exist or not */ + if exists (select * from information_schema.columns where table_schema=database() and table_name = 'x_policy_item_user_perm' and column_name = 'sort_order' and data_type='tinyint') then + ALTER TABLE `x_policy_item_user_perm` MODIFY COLUMN sort_order INT DEFAULT 0; + end if; + if exists (select * from information_schema.columns where table_schema=database() and table_name = 'x_policy_item_group_perm' and column_name = 'sort_order' and data_type='tinyint') then + ALTER TABLE `x_policy_item_group_perm` MODIFY COLUMN sort_order INT DEFAULT 0; + end if; +end;; + +delimiter ; +call change_sort_order_column_datatype_of_perm_tables(); + +drop procedure if exists change_sort_order_column_datatype_of_perm_tables; http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/1be6d935/security-admin/db/oracle/patches/024-sortorder-column-size.sql ---------------------------------------------------------------------- diff --git a/security-admin/db/oracle/patches/024-sortorder-column-size.sql b/security-admin/db/oracle/patches/024-sortorder-column-size.sql new file mode 100644 index 0000000..adac534 --- /dev/null +++ b/security-admin/db/oracle/patches/024-sortorder-column-size.sql @@ -0,0 +1,39 @@ +-- 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. + + +DECLARE + v_column_exists1 number:=0; + v_column_exists2 number:=0; +BEGIN + Select count(*) into v_column_exists1 + from user_tab_cols + where (column_name = upper('sort_order')) + and table_name = upper('x_policy_item_user_perm') and DATA_TYPE='NUMBER' and DATA_PRECISION=3; + + Select count(*) into v_column_exists2 + from user_tab_cols + where (column_name = upper('sort_order')) + and table_name = upper('x_policy_item_group_perm') and DATA_TYPE='NUMBER' and DATA_PRECISION=3; + + if (v_column_exists1 = 1) then + execute immediate 'ALTER TABLE x_policy_item_user_perm MODIFY(sort_order NUMBER(10) DEFAULT 0)'; + commit; + end if; + if (v_column_exists2 = 1) then + execute immediate 'ALTER TABLE x_policy_item_group_perm MODIFY(sort_order NUMBER(10) DEFAULT 0)'; + commit; + end if; +end;/ \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/1be6d935/security-admin/db/postgres/patches/024-sortorder-column-size.sql ---------------------------------------------------------------------- diff --git a/security-admin/db/postgres/patches/024-sortorder-column-size.sql b/security-admin/db/postgres/patches/024-sortorder-column-size.sql new file mode 100644 index 0000000..15a3984 --- /dev/null +++ b/security-admin/db/postgres/patches/024-sortorder-column-size.sql @@ -0,0 +1,33 @@ +-- 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 change_sort_order_column_datatype_of_perm_tables() +RETURNS void AS $$ +DECLARE + v_column_exists1 integer := 0; + v_column_exists2 integer := 0; +BEGIN + select count(*) into v_column_exists1 from pg_attribute where attrelid in(select oid from pg_class where relname='x_policy_item_user_perm') and attname='sort_order' and attlen=2; + IF v_column_exists1 = 1 THEN + ALTER TABLE x_policy_item_user_perm ALTER COLUMN sort_order TYPE INT; + END IF; + select count(*) into v_column_exists2 from pg_attribute where attrelid in(select oid from pg_class where relname='x_policy_item_group_perm') and attname='sort_order' and attlen=2; + IF v_column_exists2 = 1 THEN + ALTER TABLE x_policy_item_group_perm ALTER COLUMN sort_order TYPE INT; + END IF; +END; +$$ LANGUAGE plpgsql; +select change_sort_order_column_datatype_of_perm_tables(); +select 'delimiter end'; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/1be6d935/security-admin/db/sqlanywhere/patches/024-sortorder-column-size.sql ---------------------------------------------------------------------- diff --git a/security-admin/db/sqlanywhere/patches/024-sortorder-column-size.sql b/security-admin/db/sqlanywhere/patches/024-sortorder-column-size.sql new file mode 100644 index 0000000..5b47aec --- /dev/null +++ b/security-admin/db/sqlanywhere/patches/024-sortorder-column-size.sql @@ -0,0 +1,25 @@ +-- 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. + +BEGIN + IF EXISTS(select * from SYS.SYSCOLUMNS where tname = 'x_policy_item_user_perm' and cname='sort_order' and coltype='tinyint') THEN + ALTER TABLE dbo.x_policy_item_user_perm ALTER sort_order INT DEFAULT 0 NULL; + END IF; + IF EXISTS(select * from SYS.SYSCOLUMNS where tname = 'x_policy_item_group_perm' and cname='sort_order' and coltype='tinyint') THEN + ALTER TABLE dbo.x_policy_item_group_perm ALTER sort_order INT DEFAULT 0 NULL; + END IF; +END +GO +exit http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/1be6d935/security-admin/db/sqlserver/patches/024-sortorder-column-size.sql ---------------------------------------------------------------------- diff --git a/security-admin/db/sqlserver/patches/024-sortorder-column-size.sql b/security-admin/db/sqlserver/patches/024-sortorder-column-size.sql new file mode 100644 index 0000000..06823a8 --- /dev/null +++ b/security-admin/db/sqlserver/patches/024-sortorder-column-size.sql @@ -0,0 +1,44 @@ +-- 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. + +IF EXISTS(select * from INFORMATION_SCHEMA.columns where table_name = 'x_policy_item_user_perm' and column_name = 'sort_order' and DATA_TYPE='tinyint') +BEGIN + DECLARE @ObjectName VARCHAR(100); + SELECT @ObjectName = OBJECT_NAME([default_object_id]) FROM SYS.COLUMNS WHERE [object_id] = OBJECT_ID('[dbo].[x_policy_item_user_perm]') AND [name] = 'sort_order'; + IF @ObjectName IS NOT NULL + BEGIN + EXEC('ALTER TABLE [dbo].[x_policy_item_user_perm] DROP CONSTRAINT ' + @ObjectName) + END + IF NOT EXISTS(select name from SYS.sysobjects where parent_obj in (select id from SYS.sysobjects where name='x_policy_item_user_perm') and name=@ObjectName) + BEGIN + ALTER TABLE [dbo].[x_policy_item_user_perm] ALTER COLUMN [sort_order] [int] + END +END +GO +IF EXISTS(select * from INFORMATION_SCHEMA.columns where table_name = 'x_policy_item_group_perm' and column_name = 'sort_order' and DATA_TYPE='tinyint') +BEGIN + DECLARE @ObjectName VARCHAR(100); + SELECT @ObjectName = OBJECT_NAME([default_object_id]) FROM SYS.COLUMNS WHERE [object_id] = OBJECT_ID('[dbo].[x_policy_item_group_perm]') AND [name] = 'sort_order'; + IF @ObjectName IS NOT NULL + BEGIN + EXEC('ALTER TABLE [dbo].[x_policy_item_group_perm] DROP CONSTRAINT ' + @ObjectName) + END + IF NOT EXISTS(select name from SYS.sysobjects where parent_obj in (select id from SYS.sysobjects where name='x_policy_item_group_perm') and name=@ObjectName) + BEGIN + ALTER TABLE [dbo].[x_policy_item_group_perm] ALTER COLUMN [sort_order] [int] + END +END +GO +exit
