Bob Proulx wrote:
> Therefore the problem seems to stem from trying to do this fixup when
> the fixup has already been done. Unfortunately it produces the scary
> syntax error message that needs to be tracked down and understood.
Looking at this closer the fix_privs section I think it could be
simplified somewhat. Instead of doing the entire fixup
non-interactively all at once if each column addition were run
individually then this error could be detected and ignored.
I thought about querying first to see if those columns exist. But the
server may not have the client installed and so querying first seems
problematic. Just going ahead and trying it and ignoring if it is a
duplicate seems best.
Instead of the current fix_privs variable section the following could
be used to run each column addition individually and then ignore the
error if the column already exists. This still isn't perfect. But it
is an improvement over the current situation that is completely dead
reckoning and doesn't handle the situation well and produce syntax
errors in the log.
new_mysql_columns="
Create_view_priv
Show_view_priv
Create_routine_priv
Alter_routine_priv
Create_user_priv
Event_priv
Trigger_priv
Create_tablespace_priv
"
for col in $new_mysql_columns; do
printf "USE mysql;\n ALTER TABLE user ADD column $col enum('N','Y')
CHARACTER SET utf8 NOT NULL DEFAULT 'N';\n" | $MYSQL_BOOTSTRAP 2>&1 | sed
"/^ERROR:.*Duplicate column name '$col'/d;/Aborting/d" | $ERR_LOGGER
done
I will attach the idea as an attachment against this version of the
postinst script. I still wish there were a better way. Perhaps
someone else will think of something better. But I think this is
still an improvement over the current syntax error production.
Thank you for maintaining mysql.
Bob
--- /var/lib/dpkg/info/mysql-server-5.5.postinst 2013-05-10 18:10:55.000000000 -0600
+++ /tmp/mysql-server-5.5.postinst 2013-05-13 13:42:55.000000000 -0600
@@ -207,16 +207,16 @@
" Repl_slave_priv='Y', Repl_client_priv='Y', Create_view_priv='Y', "\
" Show_view_priv='Y', Create_routine_priv='Y', Alter_routine_priv='Y', "\
" Create_user_priv='Y', Event_priv='Y', Trigger_priv='Y', Create_tablespace_priv='Y' "`;
- fix_privs=`echo -e \
- "USE mysql;\n" \
- "ALTER TABLE user ADD column Create_view_priv enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N'; " \
- "ALTER TABLE user ADD column Show_view_priv enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N'; " \
- "ALTER TABLE user ADD column Create_routine_priv enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N'; " \
- "ALTER TABLE user ADD column Alter_routine_priv enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N'; " \
- "ALTER TABLE user ADD column Create_user_priv enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N'; " \
- "ALTER TABLE user ADD column Event_priv enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N'; " \
- "ALTER TABLE user ADD column Trigger_priv enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N'; " \
- "ALTER TABLE user ADD column Create_tablespace_priv enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N'; " `
+ new_mysql_columns="
+ Create_view_priv
+ Show_view_priv
+ Create_routine_priv
+ Alter_routine_priv
+ Create_user_priv
+ Event_priv
+ Trigger_priv
+ Create_tablespace_priv
+ "
# Engines supported by etch should be installed per default. The query sequence is supposed
# to be aborted if the CREATE TABLE fails due to an already existent table in which case the
# admin might already have chosen to remove one or more plugins. Newlines are necessary.
@@ -238,7 +238,9 @@
password_error="yes"
fi
- echo "$fix_privs" | $MYSQL_BOOTSTRAP 2>&1 | $ERR_LOGGER
+ for col in $new_mysql_columns; do
+ printf "USE mysql;\n ALTER TABLE user ADD column $col enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N';\n" | $MYSQL_BOOTSTRAP 2>&1 | sed "/^ERROR:.*Duplicate column name '$col'/d;/Aborting/d" | $ERR_LOGGER
+ done
echo "$replace_query" | $MYSQL_BOOTSTRAP 2>&1 | $ERR_LOGGER
set +e
echo "$install_plugins" | $MYSQL_BOOTSTRAP 2>&1 | $ERR_LOGGER