From 5d7848d8bf874873494ec17bc256490e18d7211c Mon Sep 17 00:00:00 2001
From: unknown <bell@sanja.is.com.ua>
Date: Sat, 11 Sep 2004 18:46:06 +0300
Subject: fixed privilege system upgrade script, to allow VIEW privileges for
 used who have CREATE privilege (BUG#5329)

scripts/mysql_fix_privilege_tables.sql:
  fixed privilege system upgrade script, to allow VIEW privileges for used who have CREATE privilege
---
 scripts/mysql_fix_privilege_tables.sql | 12 ++++++++++++
 1 file changed, 12 insertions(+)

(limited to 'scripts/mysql_fix_privilege_tables.sql')

diff --git a/scripts/mysql_fix_privilege_tables.sql b/scripts/mysql_fix_privilege_tables.sql
index 18dfe14bc45..5b335862584 100644
--- a/scripts/mysql_fix_privilege_tables.sql
+++ b/scripts/mysql_fix_privilege_tables.sql
@@ -144,6 +144,13 @@ alter table user comment='Users and global privileges';
 alter table func comment='User defined functions';
 alter table tables_priv comment='Table privileges';
 alter table columns_priv comment='Column privileges';
+
+#
+# Detect whether we had Create_view_priv
+# 
+SET @hadCreateViewPriv:=0;
+SELECT @hadCreateViewPriv:=1 FROM user WHERE Create_view_priv LIKE '%';
+
 #
 # Create VIEWs privileges (v5.0)
 #
@@ -158,6 +165,11 @@ ALTER TABLE db ADD Show_view_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Creat
 ALTER TABLE host ADD Show_view_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Create_view_priv;
 ALTER TABLE user ADD Show_view_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Create_view_priv;
 
+#
+# Assign create/show view privileges to people who have create provileges
+#
+UPDATE user SET Create_view_priv=Create_priv, Show_view_priv=Create_priv where user<>"" AND @hadCreateViewPriv = 0;
+
 #
 # Create some possible missing tables
 #
-- 
cgit v1.2.1

