From 363ba107842127c8b23869b314a285e914f4a74f Mon Sep 17 00:00:00 2001
From: Robert Bindar <robert@mariadb.org>
Date: Tue, 2 Feb 2021 14:57:16 +0200
Subject: MDEV-24363 mysql.user password_expired column is incorrect

The mysql.user view password_expired column should display the right
result, in sync with whether an account has its password expired or not

For mariadb 10.4+ upgrades before this commit, the mysql.user view needs
to be dropped and recreated to actually make the view display the
correct value for the password_expired column.
---
 scripts/mysql_system_tables.sql | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'scripts/mysql_system_tables.sql')

diff --git a/scripts/mysql_system_tables.sql b/scripts/mysql_system_tables.sql
index d4d16c74c11..020385992ea 100644
--- a/scripts/mysql_system_tables.sql
+++ b/scripts/mysql_system_tables.sql
@@ -93,7 +93,7 @@ CREATE DEFINER='mariadb.sys'@'localhost' SQL SECURITY DEFINER VIEW IF NOT EXISTS
   CAST(IFNULL(JSON_VALUE(Priv, '$.max_user_connections'), 0) AS SIGNED) AS max_user_connections,
   IFNULL(JSON_VALUE(Priv, '$.plugin'), '') AS plugin,
   IFNULL(JSON_VALUE(Priv, '$.authentication_string'), '') AS authentication_string,
-  'N' AS password_expired,
+  IF(IFNULL(JSON_VALUE(Priv, '$.password_last_changed'), 1) = 0, 'Y', 'N') AS password_expired,
   ELT(IFNULL(JSON_VALUE(Priv, '$.is_role'), 0) + 1, 'N', 'Y') AS is_role,
   IFNULL(JSON_VALUE(Priv, '$.default_role'), '') AS default_role,
   CAST(IFNULL(JSON_VALUE(Priv, '$.max_statement_time'), 0.0) AS DECIMAL(12,6)) AS max_statement_time
-- 
cgit v1.2.1

