|
| 1 | +# |
| 2 | +# The definer of Add/DropGeometryColumn procedures should be updated to mariadb.sys during upgrade |
| 3 | +# |
| 4 | +use mysql; |
| 5 | +create table save_proc like proc; |
| 6 | +insert into save_proc select * from proc; |
| 7 | +set @save_sql_mode= @@sql_mode; |
| 8 | +# |
| 9 | +# If the definer is root before the upgrade: |
| 10 | +# Drop the procedures if exists and recreate with root definer |
| 11 | +# |
| 12 | +DROP PROCEDURE IF EXISTS AddGeometryColumn; |
| 13 | +DROP PROCEDURE IF EXISTS DropGeometryColumn; |
| 14 | +CREATE DEFINER=`root`@`localhost` PROCEDURE AddGeometryColumn(catalog varchar(64), t_schema varchar(64), |
| 15 | +t_name varchar(64), geometry_column varchar(64), t_srid int) SQL SECURITY INVOKER |
| 16 | +begin |
| 17 | +set @qwe= concat('ALTER TABLE ', t_schema, '.', t_name, ' ADD ', geometry_column,' GEOMETRY REF_SYSTEM_ID=', t_srid); PREPARE ls from @qwe; execute ls; deallocate prepare ls; end | |
| 18 | +CREATE DEFINER=`root`@`localhost` PROCEDURE DropGeometryColumn(catalog varchar(64), t_schema varchar(64), |
| 19 | +t_name varchar(64), geometry_column varchar(64)) SQL SECURITY INVOKER |
| 20 | +begin |
| 21 | +set @qwe= concat('ALTER TABLE ', t_schema, '.', t_name, ' DROP ', geometry_column); PREPARE ls from @qwe; execute ls; deallocate prepare ls; end | |
| 22 | +SELECT count(*) FROM information_schema.ROUTINES WHERE ROUTINE_CATALOG = 'def' and ROUTINE_SCHEMA = 'mysql' and ROUTINE_NAME='AddGeometryColumn' and DEFINER = 'root@localhost'; |
| 23 | +count(*) |
| 24 | +1 |
| 25 | +SELECT count(*) FROM information_schema.ROUTINES WHERE ROUTINE_CATALOG = 'def' and ROUTINE_SCHEMA = 'mysql' and ROUTINE_NAME='DropGeometryColumn' and DEFINER = 'root@localhost'; |
| 26 | +count(*) |
| 27 | +1 |
| 28 | +SELECT count(*) FROM information_schema.ROUTINES WHERE ROUTINE_CATALOG = 'def' and ROUTINE_SCHEMA = 'mysql' and ROUTINE_NAME='AddGeometryColumn' and DEFINER = 'mariadb.sys@localhost'; |
| 29 | +count(*) |
| 30 | +0 |
| 31 | +SELECT count(*) FROM information_schema.ROUTINES WHERE ROUTINE_CATALOG = 'def' and ROUTINE_SCHEMA = 'mysql' and ROUTINE_NAME='DropGeometryColumn' and DEFINER = 'mariadb.sys@localhost'; |
| 32 | +count(*) |
| 33 | +0 |
| 34 | +# |
| 35 | +# Run mysql_upgrade |
| 36 | +# |
| 37 | +Phase 1/7: Checking and upgrading mysql database |
| 38 | +Processing databases |
| 39 | +mysql |
| 40 | +mysql.column_stats OK |
| 41 | +mysql.columns_priv OK |
| 42 | +mysql.db OK |
| 43 | +mysql.event OK |
| 44 | +mysql.func OK |
| 45 | +mysql.global_priv OK |
| 46 | +mysql.gtid_slave_pos OK |
| 47 | +mysql.help_category OK |
| 48 | +mysql.help_keyword OK |
| 49 | +mysql.help_relation OK |
| 50 | +mysql.help_topic OK |
| 51 | +mysql.index_stats OK |
| 52 | +mysql.innodb_index_stats |
| 53 | +Error : Unknown storage engine 'InnoDB' |
| 54 | +error : Corrupt |
| 55 | +mysql.innodb_table_stats |
| 56 | +Error : Unknown storage engine 'InnoDB' |
| 57 | +error : Corrupt |
| 58 | +mysql.plugin OK |
| 59 | +mysql.proc OK |
| 60 | +mysql.procs_priv OK |
| 61 | +mysql.proxies_priv OK |
| 62 | +mysql.roles_mapping OK |
| 63 | +mysql.save_proc OK |
| 64 | +mysql.servers OK |
| 65 | +mysql.table_stats OK |
| 66 | +mysql.tables_priv OK |
| 67 | +mysql.time_zone OK |
| 68 | +mysql.time_zone_leap_second OK |
| 69 | +mysql.time_zone_name OK |
| 70 | +mysql.time_zone_transition OK |
| 71 | +mysql.time_zone_transition_type OK |
| 72 | +mysql.transaction_registry |
| 73 | +Error : Unknown storage engine 'InnoDB' |
| 74 | +error : Corrupt |
| 75 | + |
| 76 | +Repairing tables |
| 77 | +mysql.innodb_index_stats |
| 78 | +Error : Unknown storage engine 'InnoDB' |
| 79 | +error : Corrupt |
| 80 | +mysql.innodb_table_stats |
| 81 | +Error : Unknown storage engine 'InnoDB' |
| 82 | +error : Corrupt |
| 83 | +mysql.transaction_registry |
| 84 | +Error : Unknown storage engine 'InnoDB' |
| 85 | +error : Corrupt |
| 86 | +Phase 2/7: Installing used storage engines... Skipped |
| 87 | +Phase 3/7: Fixing views |
| 88 | +mysql.user OK |
| 89 | +Phase 4/7: Running 'mysql_fix_privilege_tables' |
| 90 | +Phase 5/7: Fixing table and database names |
| 91 | +Phase 6/7: Checking and upgrading tables |
| 92 | +Processing databases |
| 93 | +information_schema |
| 94 | +mtr |
| 95 | +mtr.global_suppressions OK |
| 96 | +mtr.test_suppressions OK |
| 97 | +performance_schema |
| 98 | +test |
| 99 | +Phase 7/7: Running 'FLUSH PRIVILEGES' |
| 100 | +OK |
| 101 | +# |
| 102 | +# check new definers of Add/DropGeometryColumn |
| 103 | +# |
| 104 | +SELECT count(*) FROM information_schema.ROUTINES WHERE ROUTINE_CATALOG = 'def' and ROUTINE_SCHEMA = 'mysql' and ROUTINE_NAME='AddGeometryColumn' and DEFINER = 'root@localhost'; |
| 105 | +count(*) |
| 106 | +0 |
| 107 | +SELECT count(*) FROM information_schema.ROUTINES WHERE ROUTINE_CATALOG = 'def' and ROUTINE_SCHEMA = 'mysql' and ROUTINE_NAME='DropGeometryColumn' and DEFINER = 'root@localhost'; |
| 108 | +count(*) |
| 109 | +0 |
| 110 | +SELECT count(*) FROM information_schema.ROUTINES WHERE ROUTINE_CATALOG = 'def' and ROUTINE_SCHEMA = 'mysql' and ROUTINE_NAME='AddGeometryColumn' and DEFINER = 'mariadb.sys@localhost'; |
| 111 | +count(*) |
| 112 | +1 |
| 113 | +SELECT count(*) FROM information_schema.ROUTINES WHERE ROUTINE_CATALOG = 'def' and ROUTINE_SCHEMA = 'mysql' and ROUTINE_NAME='DropGeometryColumn' and DEFINER = 'mariadb.sys@localhost'; |
| 114 | +count(*) |
| 115 | +1 |
| 116 | +# |
| 117 | +# restore environment |
| 118 | +# |
| 119 | +delete from proc; |
| 120 | +rename table proc to bad_proc; |
| 121 | +rename table save_proc to proc; |
| 122 | +drop table bad_proc; |
| 123 | +flush privileges; |
0 commit comments