You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

262 lines
12 KiB

  1. #
  2. # MDEV-23102: 10.4 create mariadb.sys user on each update even
  3. # is the user is not needed
  4. #
  5. # part 2: reassigning mysql.user and deleting gis procedures
  6. call mtr.add_suppression("Cannot load from mysql.proc. The table is probably corrupted");
  7. create database mysqltest1;
  8. use mysqltest1;
  9. create table save_global_priv as select * from mysql.global_priv;
  10. create table save_tables_priv as select * from mysql.tables_priv;
  11. create table save_proxies_priv as select * from mysql.proxies_priv;
  12. create table mysql.save_proc like mysql.proc;
  13. insert into mysql.save_proc select * from mysql.proc;
  14. set @save_sql_mode= @@sql_mode;
  15. use mysql;
  16. # make changed definition of gis procedures and user view
  17. create user superuser@localhost;
  18. grant all privileges on mysql.* to superuser@localhost;
  19. drop view user;
  20. CREATE DEFINER='superuser'@'localhost' SQL SECURITY DEFINER VIEW IF NOT EXISTS user AS SELECT
  21. Host,
  22. User,
  23. IF(JSON_VALUE(Priv, '$.plugin') IN ('mysql_native_password', 'mysql_old_password'), IFNULL(JSON_VALUE(Priv, '$.authentication_string'), ''), '') AS Password,
  24. IF(JSON_VALUE(Priv, '$.access') & 1, 'Y', 'N') AS Select_priv,
  25. IF(JSON_VALUE(Priv, '$.access') & 2, 'Y', 'N') AS Insert_priv,
  26. IF(JSON_VALUE(Priv, '$.access') & 4, 'Y', 'N') AS Update_priv,
  27. IF(JSON_VALUE(Priv, '$.access') & 8, 'Y', 'N') AS Delete_priv,
  28. IF(JSON_VALUE(Priv, '$.access') & 16, 'Y', 'N') AS Create_priv,
  29. IF(JSON_VALUE(Priv, '$.access') & 32, 'Y', 'N') AS Drop_priv,
  30. IF(JSON_VALUE(Priv, '$.access') & 64, 'Y', 'N') AS Reload_priv,
  31. IF(JSON_VALUE(Priv, '$.access') & 128, 'Y', 'N') AS Shutdown_priv,
  32. IF(JSON_VALUE(Priv, '$.access') & 256, 'Y', 'N') AS Process_priv,
  33. IF(JSON_VALUE(Priv, '$.access') & 512, 'Y', 'N') AS File_priv,
  34. IF(JSON_VALUE(Priv, '$.access') & 1024, 'Y', 'N') AS Grant_priv,
  35. IF(JSON_VALUE(Priv, '$.access') & 2048, 'Y', 'N') AS References_priv,
  36. IF(JSON_VALUE(Priv, '$.access') & 4096, 'Y', 'N') AS Index_priv,
  37. IF(JSON_VALUE(Priv, '$.access') & 8192, 'Y', 'N') AS Alter_priv,
  38. IF(JSON_VALUE(Priv, '$.access') & 16384, 'Y', 'N') AS Show_db_priv,
  39. IF(JSON_VALUE(Priv, '$.access') & 32768, 'Y', 'N') AS Super_priv,
  40. IF(JSON_VALUE(Priv, '$.access') & 65536, 'Y', 'N') AS Create_tmp_table_priv,
  41. IF(JSON_VALUE(Priv, '$.access') & 131072, 'Y', 'N') AS Lock_tables_priv,
  42. IF(JSON_VALUE(Priv, '$.access') & 262144, 'Y', 'N') AS Execute_priv,
  43. IF(JSON_VALUE(Priv, '$.access') & 524288, 'Y', 'N') AS Repl_slave_priv,
  44. IF(JSON_VALUE(Priv, '$.access') & 1048576, 'Y', 'N') AS Repl_client_priv,
  45. IF(JSON_VALUE(Priv, '$.access') & 2097152, 'Y', 'N') AS Create_view_priv,
  46. IF(JSON_VALUE(Priv, '$.access') & 4194304, 'Y', 'N') AS Show_view_priv,
  47. IF(JSON_VALUE(Priv, '$.access') & 8388608, 'Y', 'N') AS Create_routine_priv,
  48. IF(JSON_VALUE(Priv, '$.access') & 16777216, 'Y', 'N') AS Alter_routine_priv,
  49. IF(JSON_VALUE(Priv, '$.access') & 33554432, 'Y', 'N') AS Create_user_priv,
  50. IF(JSON_VALUE(Priv, '$.access') & 67108864, 'Y', 'N') AS Event_priv,
  51. IF(JSON_VALUE(Priv, '$.access') & 134217728, 'Y', 'N') AS Trigger_priv,
  52. IF(JSON_VALUE(Priv, '$.access') & 268435456, 'Y', 'N') AS Create_tablespace_priv,
  53. IF(JSON_VALUE(Priv, '$.access') & 536870912, 'Y', 'N') AS Delete_history_priv,
  54. ELT(IFNULL(JSON_VALUE(Priv, '$.ssl_type'), 0) + 1, '', 'ANY','X509', 'SPECIFIED') AS ssl_type,
  55. IFNULL(JSON_VALUE(Priv, '$.ssl_cipher'), '') AS ssl_cipher,
  56. IFNULL(JSON_VALUE(Priv, '$.x509_issuer'), '') AS x509_issuer,
  57. IFNULL(JSON_VALUE(Priv, '$.x509_subject'), '') AS x509_subject,
  58. CAST(IFNULL(JSON_VALUE(Priv, '$.max_questions'), 0) AS UNSIGNED) AS max_questions,
  59. CAST(IFNULL(JSON_VALUE(Priv, '$.max_updates'), 0) AS UNSIGNED) AS max_updates,
  60. CAST(IFNULL(JSON_VALUE(Priv, '$.max_connections'), 0) AS UNSIGNED) AS max_connections,
  61. CAST(IFNULL(JSON_VALUE(Priv, '$.max_user_connections'), 0) AS SIGNED) AS max_user_connections,
  62. IFNULL(JSON_VALUE(Priv, '$.plugin'), '') AS plugin,
  63. IFNULL(JSON_VALUE(Priv, '$.authentication_string'), '') AS authentication_string,
  64. 'N' AS password_expired,
  65. ELT(IFNULL(JSON_VALUE(Priv, '$.is_role'), 0) + 1, 'N', 'Y') AS is_role,
  66. IFNULL(JSON_VALUE(Priv, '$.default_role'), '') AS default_role,
  67. CAST(IFNULL(JSON_VALUE(Priv, '$.max_statement_time'), 0.0) AS DECIMAL(12,6)) AS max_statement_time
  68. FROM global_priv;
  69. DROP PROCEDURE IF EXISTS mysql.AddGeometryColumn;
  70. DROP PROCEDURE IF EXISTS mysql.DropGeometryColumn;
  71. drop user 'mariadb.sys'@'localhost';
  72. # check changed definitions mysql_upgrade
  73. SELECT count(*) FROM information_schema.VIEWS WHERE TABLE_CATALOG = 'def'
  74. and TABLE_SCHEMA = 'mysql' and TABLE_NAME='user' and DEFINER = 'superuser@localhost';
  75. count(*)
  76. 1
  77. SELECT count(*) FROM information_schema.VIEWS WHERE TABLE_CATALOG = 'def' and TABLE_SCHEMA = 'mysql' and TABLE_NAME='user' and DEFINER = 'mariadb.sys@localhost';
  78. count(*)
  79. 0
  80. SELECT count(*) FROM information_schema.ROUTINES WHERE ROUTINE_CATALOG = 'def' and ROUTINE_SCHEMA = 'mysql' and ROUTINE_NAME='AddGeometryColumn';
  81. count(*)
  82. 0
  83. SELECT count(*) FROM information_schema.ROUTINES WHERE ROUTINE_CATALOG = 'def' and ROUTINE_SCHEMA = 'mysql' and ROUTINE_NAME='DropGeometryColumn';
  84. count(*)
  85. 0
  86. SELECT * FROM information_schema.USER_PRIVILEGES WHERE GRANTEE="'mariadb.sys'@'localhost'";
  87. GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE
  88. SELECT * FROM information_schema.TABLE_PRIVILEGES WHERE GRANTEE="'mariadb.sys'@'localhost'";
  89. GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE
  90. # Run mysql_upgrade
  91. Phase 1/7: Checking and upgrading mysql database
  92. Processing databases
  93. mysql
  94. mysql.column_stats OK
  95. mysql.columns_priv OK
  96. mysql.db OK
  97. mysql.event OK
  98. mysql.func OK
  99. mysql.global_priv OK
  100. mysql.gtid_slave_pos OK
  101. mysql.help_category OK
  102. mysql.help_keyword OK
  103. mysql.help_relation OK
  104. mysql.help_topic OK
  105. mysql.index_stats OK
  106. mysql.innodb_index_stats
  107. Error : Unknown storage engine 'InnoDB'
  108. error : Corrupt
  109. mysql.innodb_table_stats
  110. Error : Unknown storage engine 'InnoDB'
  111. error : Corrupt
  112. mysql.plugin OK
  113. mysql.proc OK
  114. mysql.procs_priv OK
  115. mysql.proxies_priv OK
  116. mysql.roles_mapping OK
  117. mysql.save_proc OK
  118. mysql.servers OK
  119. mysql.table_stats OK
  120. mysql.tables_priv OK
  121. mysql.time_zone OK
  122. mysql.time_zone_leap_second OK
  123. mysql.time_zone_name OK
  124. mysql.time_zone_transition OK
  125. mysql.time_zone_transition_type OK
  126. mysql.transaction_registry
  127. Error : Unknown storage engine 'InnoDB'
  128. error : Corrupt
  129. Repairing tables
  130. mysql.innodb_index_stats
  131. Error : Unknown storage engine 'InnoDB'
  132. error : Corrupt
  133. mysql.innodb_table_stats
  134. Error : Unknown storage engine 'InnoDB'
  135. error : Corrupt
  136. mysql.transaction_registry
  137. Error : Unknown storage engine 'InnoDB'
  138. error : Corrupt
  139. Phase 2/7: Installing used storage engines... Skipped
  140. Phase 3/7: Fixing views
  141. mysql.user OK
  142. Phase 4/7: Running 'mysql_fix_privilege_tables'
  143. Phase 5/7: Fixing table and database names
  144. Phase 6/7: Checking and upgrading tables
  145. Processing databases
  146. information_schema
  147. mtr
  148. mtr.global_suppressions OK
  149. mtr.test_suppressions OK
  150. mysqltest1
  151. mysqltest1.save_global_priv OK
  152. mysqltest1.save_proxies_priv OK
  153. mysqltest1.save_tables_priv OK
  154. performance_schema
  155. test
  156. Phase 7/7: Running 'FLUSH PRIVILEGES'
  157. OK
  158. # check new definitions mysql_upgrade
  159. SELECT count(*) FROM information_schema.VIEWS WHERE TABLE_CATALOG = 'def'
  160. and TABLE_SCHEMA = 'mysql' and TABLE_NAME='user' and DEFINER = 'superuser@localhost';
  161. count(*)
  162. 1
  163. SELECT count(*) FROM information_schema.VIEWS WHERE TABLE_CATALOG = 'def' and TABLE_SCHEMA = 'mysql' and TABLE_NAME='user' and DEFINER = 'mariadb.sys@localhost';
  164. count(*)
  165. 0
  166. SELECT count(*) FROM information_schema.ROUTINES WHERE ROUTINE_CATALOG = 'def' and ROUTINE_SCHEMA = 'mysql' and ROUTINE_NAME='AddGeometryColumn';
  167. count(*)
  168. 0
  169. SELECT count(*) FROM information_schema.ROUTINES WHERE ROUTINE_CATALOG = 'def' and ROUTINE_SCHEMA = 'mysql' and ROUTINE_NAME='DropGeometryColumn';
  170. count(*)
  171. 0
  172. select count(*) from global_priv where user='mariadb.sys' and host='localhost';
  173. count(*)
  174. 0
  175. # above should be 0 (no mariadb.sys@localhost user)
  176. # restore environment
  177. DROP USER 'superuser'@'localhost';
  178. DROP VIEW mysql.user;
  179. Phase 1/7: Checking and upgrading mysql database
  180. Processing databases
  181. mysql
  182. mysql.column_stats OK
  183. mysql.columns_priv OK
  184. mysql.db OK
  185. mysql.event OK
  186. mysql.func OK
  187. mysql.global_priv OK
  188. mysql.gtid_slave_pos OK
  189. mysql.help_category OK
  190. mysql.help_keyword OK
  191. mysql.help_relation OK
  192. mysql.help_topic OK
  193. mysql.index_stats OK
  194. mysql.innodb_index_stats
  195. Error : Unknown storage engine 'InnoDB'
  196. error : Corrupt
  197. mysql.innodb_table_stats
  198. Error : Unknown storage engine 'InnoDB'
  199. error : Corrupt
  200. mysql.plugin OK
  201. mysql.proc OK
  202. mysql.procs_priv OK
  203. mysql.proxies_priv OK
  204. mysql.roles_mapping OK
  205. mysql.save_proc OK
  206. mysql.servers OK
  207. mysql.table_stats OK
  208. mysql.tables_priv OK
  209. mysql.time_zone OK
  210. mysql.time_zone_leap_second OK
  211. mysql.time_zone_name OK
  212. mysql.time_zone_transition OK
  213. mysql.time_zone_transition_type OK
  214. mysql.transaction_registry
  215. Error : Unknown storage engine 'InnoDB'
  216. error : Corrupt
  217. Repairing tables
  218. mysql.innodb_index_stats
  219. Error : Unknown storage engine 'InnoDB'
  220. error : Corrupt
  221. mysql.innodb_table_stats
  222. Error : Unknown storage engine 'InnoDB'
  223. error : Corrupt
  224. mysql.transaction_registry
  225. Error : Unknown storage engine 'InnoDB'
  226. error : Corrupt
  227. Phase 2/7: Installing used storage engines... Skipped
  228. Phase 3/7: Fixing views
  229. Phase 4/7: Running 'mysql_fix_privilege_tables'
  230. Phase 5/7: Fixing table and database names
  231. Phase 6/7: Checking and upgrading tables
  232. Processing databases
  233. information_schema
  234. mtr
  235. mtr.global_suppressions OK
  236. mtr.test_suppressions OK
  237. mysqltest1
  238. mysqltest1.save_global_priv OK
  239. mysqltest1.save_proxies_priv OK
  240. mysqltest1.save_tables_priv OK
  241. performance_schema
  242. test
  243. Phase 7/7: Running 'FLUSH PRIVILEGES'
  244. OK
  245. delete from global_priv;
  246. delete from tables_priv;
  247. delete from proxies_priv;
  248. delete from proc;
  249. insert into mysql.global_priv select * from mysqltest1.save_global_priv;
  250. insert into mysql.tables_priv select * from mysqltest1.save_tables_priv;
  251. insert into mysql.proxies_priv select * from mysqltest1.save_proxies_priv;
  252. rename table proc to bad_proc;
  253. rename table save_proc to proc;
  254. drop table bad_proc;
  255. flush privileges;
  256. disconnect default;
  257. connect default,localhost,root,,;
  258. connection default;
  259. drop database mysqltest1;
  260. # End of 10.4 tests (but better do not add other tests here)