List:Commits« Previous MessageNext Message »
From:Marc Alff Date:April 27 2010 7:19am
Subject:bzr push into mysql-next-mr-wl5291 branch (marc.alff:3140 to 3141)
WL#5291
View as plain text  
 3141 Marc Alff	2010-04-27
      WL#5291 MySQL Install / Upgrade script format

    added:
      sql/sql_bootstrap.cc
      sql/sql_bootstrap.h
    modified:
      client/mysql_upgrade.c
      libmysqld/CMakeLists.txt
      libmysqld/Makefile.am
      mysql-test/mysql-test-run.pl
      scripts/Makefile.am
      scripts/comp_sql.c
      scripts/mysql_system_tables.sql
      scripts/mysql_system_tables_fix.sql
      sql/CMakeLists.txt
      sql/Makefile.am
      sql/sql_parse.cc
 3140 Marc Alff	2010-04-26
      New tree

    modified:
      .bzr-mysql/default.conf
=== modified file 'client/mysql_upgrade.c'
--- a/client/mysql_upgrade.c	2010-03-24 15:03:44 +0000
+++ b/client/mysql_upgrade.c	2010-04-27 07:18:34 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -757,17 +757,35 @@ static void print_line(char* line)
 static int run_sql_fix_privilege_tables(void)
 {
   int found_real_errors= 0;
+  const char **query_ptr;
+  DYNAMIC_STRING ds_script;
   DYNAMIC_STRING ds_result;
   DBUG_ENTER("run_sql_fix_privilege_tables");
 
+  if (init_dynamic_string(&ds_script, "", 65536, 1024))
+    die("Out of memory");
+
   if (init_dynamic_string(&ds_result, "", 512, 512))
     die("Out of memory");
 
   verbose("Running 'mysql_fix_privilege_tables'...");
-  run_query(mysql_fix_privilege_tables,
+
+  /*
+    Individual queries can not be executed independently by invoking
+    a forked mysql client, because the script uses session variables
+    and prepared statements.
+  */
+  for ( query_ptr= &mysql_fix_privilege_tables[0];
+        *query_ptr != NULL;
+        query_ptr++
+      )
+  {
+    dynstr_append(&ds_script, *query_ptr);
+  }
+
+  run_query(ds_script.str,
             &ds_result, /* Collect result */
             TRUE);
-
   {
     /*
       Scan each line of the result for real errors
@@ -792,6 +810,7 @@ static int run_sql_fix_privilege_tables(
   }
 
   dynstr_free(&ds_result);
+  dynstr_free(&ds_script);
   return found_real_errors;
 }
 

=== modified file 'libmysqld/CMakeLists.txt'
--- a/libmysqld/CMakeLists.txt	2010-03-31 14:05:33 +0000
+++ b/libmysqld/CMakeLists.txt	2010-04-27 07:18:34 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2006 MySQL AB
+# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
 # 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -84,7 +84,7 @@ SET(SQL_EMBEDDED_SOURCES emb_qcache.cc l
 	       ../sql/rpl_utility.cc
            ../sql/sys_vars.cc
            ${CMAKE_BINARY_DIR}/sql/sql_builtin.cc
-           ../sql/mdl.cc ../sql/transaction.cc
+           ../sql/mdl.cc ../sql/transaction.cc ../sql/sql_bootstrap.cc
            ${GEN_SOURCES}
            ${MYSYS_LIBWRAP_SOURCE}
 )

=== modified file 'libmysqld/Makefile.am'
--- a/libmysqld/Makefile.am	2010-03-31 14:05:33 +0000
+++ b/libmysqld/Makefile.am	2010-04-27 07:18:34 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2006 MySQL AB
+# Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
 # 
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Library General Public
@@ -78,7 +78,7 @@ sqlsources = derror.cc field.cc field_co
 	debug_sync.cc sql_tablespace.cc transaction.cc \
 	rpl_injector.cc my_user.c partition_info.cc \
 	sql_servers.cc event_parse_data.cc sql_signal.cc \
-	rpl_handler.cc mdl.cc keycaches.cc sql_audit.cc
+	rpl_handler.cc mdl.cc keycaches.cc sql_audit.cc sql_bootstrap.cc
 
 libmysqld_int_a_SOURCES= $(libmysqld_sources)
 nodist_libmysqld_int_a_SOURCES= $(libmysqlsources) $(sqlsources)

=== modified file 'mysql-test/mysql-test-run.pl'
--- a/mysql-test/mysql-test-run.pl	2010-03-22 10:36:23 +0000
+++ b/mysql-test/mysql-test-run.pl	2010-04-27 07:18:34 +0000
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 # -*- cperl -*-
 
-# Copyright (C) 2009 Sun Microsystems, Inc
+# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -2868,7 +2868,7 @@ sub mysql_install_db {
   {
     my $sql_dir= dirname($path_sql);
     # Use the mysql database for system tables
-    mtr_tofile($bootstrap_sql_file, "use mysql\n");
+    mtr_tofile($bootstrap_sql_file, "use mysql;\n");
 
     # Add the offical mysql system tables
     # for a production system

=== modified file 'scripts/Makefile.am'
--- a/scripts/Makefile.am	2010-03-25 07:26:12 +0000
+++ b/scripts/Makefile.am	2010-04-27 07:18:34 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2000-2006 MySQL AB
+# Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
 # 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -111,14 +111,15 @@ mysql_fix_privilege_tables.sql: mysql_sy
 	@echo "Building $@";
 	@cat mysql_system_tables.sql mysql_system_tables_fix.sql > $@
 
+comp_sql_SOURCES= comp_sql.c
+
 #
 # Build mysql_fix_privilege_tables_sql.c from
 # mysql_fix_privileges_tables.sql using comp_sql
 # The "sleep" ensures the generated file has a younger timestamp than its source
 # (which may have been generated in this very same "make" run).
 #
-mysql_fix_privilege_tables_sql.c: comp_sql.c mysql_fix_privilege_tables.sql
-	$(MAKE) $(AM_MAKEFLAGS) comp_sql$(EXEEXT)
+mysql_fix_privilege_tables_sql.c: comp_sql$(EXEEXT) mysql_fix_privilege_tables.sql
 	sleep 2
 	$(top_builddir)/scripts/comp_sql$(EXEEXT) \
 	  mysql_fix_privilege_tables \

=== modified file 'scripts/comp_sql.c'
--- a/scripts/comp_sql.c	2007-04-23 12:01:48 +0000
+++ b/scripts/comp_sql.c	2010-04-27 07:18:34 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 MySQL AB
+/* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -14,10 +14,6 @@
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
 /*
-  Written by Magnus Svensson
-*/
-
-/*
   Converts a SQL file into a C file that can be compiled and linked
   into other programs
 */
@@ -26,7 +22,20 @@
 #include <stdlib.h>
 #include <stdio.h>
 
-FILE *in, *out;
+#include "../sql/sql_bootstrap.h"
+
+/*
+  This is an internal tool used during the build process only,
+  - do not make a library just for this,
+    which would make the Makefiles and the server link
+    more complex than necessary,
+  - do not duplicate the code either.
+ so just add the sql_bootstrap.cc code as is.
+*/
+#include "../sql/sql_bootstrap.cc"
+
+FILE *in;
+FILE *out;
 
 static void die(const char *fmt, ...)
 {
@@ -54,13 +63,60 @@ static void die(const char *fmt, ...)
   exit(1);
 }
 
+char *fgets_fn(char *buffer, size_t size, fgets_input_t input)
+{
+  return fgets(buffer, size, (FILE*) input);
+}
+
+static void print_query(FILE *out, const char *query)
+{
+  const char *ptr= query;
+  int column= 0;
+
+  fprintf(out, "\"");
+  while (*ptr)
+  {
+    if (column >= 120)
+    {
+      /* Wrap to the next line, tabulated. */
+      fprintf(out, "\"\n  \"");
+      column= 2;
+    }
+    switch(*ptr)
+    {
+    case '\n':
+      /*
+        Preserve the \n character in the query text,
+        and wrap to the next line, tabulated.
+      */
+      fprintf(out, "\\n\"\n  \"");
+      column= 2;
+      break;
+    case '\r':
+      /* Skipped */
+      break;
+    case '\"':
+      fprintf(out, "\\\"");
+      column++;
+      break;
+    default:
+      putc(*ptr, out);
+      column++;
+      break;
+    }
+    ptr++;
+  }
+  fprintf(out, "\\n\",\n");
+}
 
 int main(int argc, char *argv[])
 {
-  char buff[512];
+  char query[MAX_BOOTSTRAP_QUERY_SIZE];
   char* struct_name= argv[1];
   char* infile_name= argv[2];
   char* outfile_name= argv[3];
+  int rc;
+  int query_length;
 
   if (argc != 4)
     die("Usage: comp_sql <struct_name> <sql_filename> <c_filename>");
@@ -71,55 +127,31 @@ int main(int argc, char *argv[])
   if (!(out= fopen(outfile_name, "w")))
     die("Failed to open output file '%s'", outfile_name);
 
-  fprintf(out, "const char* %s={\n\"", struct_name);
+  fprintf(out, "/*\n");
+  fprintf(out, "  Do not edit this file, it is automatically generated from:\n");
+  fprintf(out, "  <%s>\n", infile_name);
+  fprintf(out, "*/\n");
+  fprintf(out, "const char* %s[]={\n", struct_name);
 
-  while (fgets(buff, sizeof(buff), in))
+  for ( ; ; )
   {
-    char *curr= buff;
-    while (*curr)
-    {
-      if (*curr == '\n')
-      {
-        /*
-          Reached end of line, add escaped newline, escaped
-          backslash and a newline to outfile
-        */
-        fprintf(out, "\\n \"\n\"");
-        curr++;
-      }
-      else if (*curr == '\r')
-      {
-        curr++; /* Skip */
-      }
-      else
-      {
-        if (*curr == '"')
-        {
-          /* Needs escape */
-          fputc('\\', out);
-        }
-
-        fputc(*curr, out);
-        curr++;
-      }
-    }
-    if (*(curr-1) != '\n')
-    {
-      /*
-        Some compilers have a max string length,
-        insert a newline at every 512th char in long
-        strings
-      */
-      fprintf(out, "\"\n\"");
-    }
+    rc= read_bootstrap_query(query, &query_length,
+                             (fgets_input_t) in, fgets_fn);
+
+    if (rc == READ_BOOTSTRAP_ERROR)
+      die("Failed to read the bootstrap input file.\n");
+    
+    if (rc == READ_BOOTSTRAP_EOF)
+      break;
+
+    print_query(out, query);
   }
 
-  fprintf(out, "\\\n\"};\n");
+  fprintf(out, "NULL\n};\n");
 
   fclose(in);
   fclose(out);
 
   exit(0);
-
 }
 

=== modified file 'scripts/mysql_system_tables.sql'
--- a/scripts/mysql_system_tables.sql	2010-03-05 15:31:01 +0000
+++ b/scripts/mysql_system_tables.sql	2010-04-27 07:18:34 +0000
@@ -1,4 +1,4 @@
--- Copyright (C) 2008, 2010 Oracle and/or its affiliates. All rights reserved.
+-- Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
 --
 -- This program is free software; you can redistribute it and/or modify
 -- it under the terms of the GNU General Public License as published by
@@ -113,9 +113,9 @@ CREATE TABLE IF NOT EXISTS ndb_binlog_in
 
 set @have_old_pfs= (select count(*) from information_schema.schemata where schema_name='performance_schema');
 
-SET @l1="SET @broken_tables = (select count(*) from information_schema.tables";
-SET @l2=" where engine != \'PERFORMANCE_SCHEMA\' and table_schema=\'performance_schema\')";
-SET @cmd=concat(@l1,@l2);
+SET @cmd="SET @broken_tables = (select count(*) from information_schema.tables"
+  " where engine != \'PERFORMANCE_SCHEMA\' and table_schema=\'performance_schema\')";
+GO
 
 -- Work around for bug#49542
 SET @str = IF(@have_old_pfs = 1, @cmd, 'SET @broken_tables = 0');
@@ -123,9 +123,9 @@ PREPARE stmt FROM @str;
 EXECUTE stmt;
 DROP PREPARE stmt;
 
-SET @l1="SET @broken_views = (select count(*) from information_schema.views";
-SET @l2=" where table_schema='performance_schema')";
-SET @cmd=concat(@l1,@l2);
+SET @cmd="SET @broken_views = (select count(*) from information_schema.views"
+  " where table_schema='performance_schema')";
+GO
 
 -- Work around for bug#49542
 SET @str = IF(@have_old_pfs = 1, @cmd, 'SET @broken_views = 0');
@@ -191,12 +191,11 @@ set @have_pfs= (select count(engine) fro
 -- TABLE COND_INSTANCES
 --
 
-SET @l1="CREATE TABLE performance_schema.COND_INSTANCES(";
-SET @l2="NAME VARCHAR(128) not null,";
-SET @l3="OBJECT_INSTANCE_BEGIN BIGINT not null";
-SET @l4=")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @cmd=concat(@l1,@l2,@l3,@l4);
+SET @cmd="CREATE TABLE performance_schema.COND_INSTANCES("
+  "NAME VARCHAR(128) not null,"
+  "OBJECT_INSTANCE_BEGIN BIGINT not null"
+  ")ENGINE=PERFORMANCE_SCHEMA;";
+GO
 
 SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
 PREPARE stmt FROM @str;
@@ -207,26 +206,25 @@ DROP PREPARE stmt;
 -- TABLE EVENTS_WAITS_CURRENT
 --
 
-SET @l1="CREATE TABLE performance_schema.EVENTS_WAITS_CURRENT(";
-SET @l2="THREAD_ID INTEGER not null,";
-SET @l3="EVENT_ID BIGINT unsigned not null,";
-SET @l4="EVENT_NAME VARCHAR(128) not null,";
-SET @l5="SOURCE VARCHAR(64),";
-SET @l6="TIMER_START BIGINT unsigned,";
-SET @l7="TIMER_END BIGINT unsigned,";
-SET @l8="TIMER_WAIT BIGINT unsigned,";
-SET @l9="SPINS INTEGER unsigned,";
-SET @l10="OBJECT_SCHEMA VARCHAR(64),";
-SET @l11="OBJECT_NAME VARCHAR(512),";
-SET @l12="OBJECT_TYPE VARCHAR(64),";
-SET @l13="OBJECT_INSTANCE_BEGIN BIGINT not null,";
-SET @l14="NESTING_EVENT_ID BIGINT unsigned,";
-SET @l15="OPERATION VARCHAR(16) not null,";
-SET @l16="NUMBER_OF_BYTES BIGINT unsigned,";
-SET @l17="FLAGS INTEGER unsigned";
-SET @l18=")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @cmd=concat(@l1,@l2,@l3,@l4,@l5,@l6,@l7,@l8,@l9,@l10,@l11,@l12,@l13,@l14,@l15,@l16,@l17,@l18);
+SET @cmd="CREATE TABLE performance_schema.EVENTS_WAITS_CURRENT("
+  "THREAD_ID INTEGER not null,"
+  "EVENT_ID BIGINT unsigned not null,"
+  "EVENT_NAME VARCHAR(128) not null,"
+  "SOURCE VARCHAR(64),"
+  "TIMER_START BIGINT unsigned,"
+  "TIMER_END BIGINT unsigned,"
+  "TIMER_WAIT BIGINT unsigned,"
+  "SPINS INTEGER unsigned,"
+  "OBJECT_SCHEMA VARCHAR(64),"
+  "OBJECT_NAME VARCHAR(512),"
+  "OBJECT_TYPE VARCHAR(64),"
+  "OBJECT_INSTANCE_BEGIN BIGINT not null,"
+  "NESTING_EVENT_ID BIGINT unsigned,"
+  "OPERATION VARCHAR(16) not null,"
+  "NUMBER_OF_BYTES BIGINT unsigned,"
+  "FLAGS INTEGER unsigned"
+  ")ENGINE=PERFORMANCE_SCHEMA;";
+GO
 
 SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
 PREPARE stmt FROM @str;
@@ -237,10 +235,25 @@ DROP PREPARE stmt;
 -- TABLE EVENTS_WAITS_HISTORY
 --
 
-SET @l1="CREATE TABLE performance_schema.EVENTS_WAITS_HISTORY(";
--- lines 2 to 18 are unchanged from EVENTS_WAITS_CURRENT
-
-SET @cmd=concat(@l1,@l2,@l3,@l4,@l5,@l6,@l7,@l8,@l9,@l10,@l11,@l12,@l13,@l14,@l15,@l16,@l17,@l18);
+SET @cmd="CREATE TABLE performance_schema.EVENTS_WAITS_HISTORY("
+  "THREAD_ID INTEGER not null,"
+  "EVENT_ID BIGINT unsigned not null,"
+  "EVENT_NAME VARCHAR(128) not null,"
+  "SOURCE VARCHAR(64),"
+  "TIMER_START BIGINT unsigned,"
+  "TIMER_END BIGINT unsigned,"
+  "TIMER_WAIT BIGINT unsigned,"
+  "SPINS INTEGER unsigned,"
+  "OBJECT_SCHEMA VARCHAR(64),"
+  "OBJECT_NAME VARCHAR(512),"
+  "OBJECT_TYPE VARCHAR(64),"
+  "OBJECT_INSTANCE_BEGIN BIGINT not null,"
+  "NESTING_EVENT_ID BIGINT unsigned,"
+  "OPERATION VARCHAR(16) not null,"
+  "NUMBER_OF_BYTES BIGINT unsigned,"
+  "FLAGS INTEGER unsigned"
+  ")ENGINE=PERFORMANCE_SCHEMA;";
+GO
 
 SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
 PREPARE stmt FROM @str;
@@ -251,10 +264,25 @@ DROP PREPARE stmt;
 -- TABLE EVENTS_WAITS_HISTORY_LONG
 --
 
-SET @l1="CREATE TABLE performance_schema.EVENTS_WAITS_HISTORY_LONG(";
--- lines 2 to 18 are unchanged from EVENTS_WAITS_CURRENT
-
-SET @cmd=concat(@l1,@l2,@l3,@l4,@l5,@l6,@l7,@l8,@l9,@l10,@l11,@l12,@l13,@l14,@l15,@l16,@l17,@l18);
+SET @cmd="CREATE TABLE performance_schema.EVENTS_WAITS_HISTORY_LONG("
+  "THREAD_ID INTEGER not null,"
+  "EVENT_ID BIGINT unsigned not null,"
+  "EVENT_NAME VARCHAR(128) not null,"
+  "SOURCE VARCHAR(64),"
+  "TIMER_START BIGINT unsigned,"
+  "TIMER_END BIGINT unsigned,"
+  "TIMER_WAIT BIGINT unsigned,"
+  "SPINS INTEGER unsigned,"
+  "OBJECT_SCHEMA VARCHAR(64),"
+  "OBJECT_NAME VARCHAR(512),"
+  "OBJECT_TYPE VARCHAR(64),"
+  "OBJECT_INSTANCE_BEGIN BIGINT not null,"
+  "NESTING_EVENT_ID BIGINT unsigned,"
+  "OPERATION VARCHAR(16) not null,"
+  "NUMBER_OF_BYTES BIGINT unsigned,"
+  "FLAGS INTEGER unsigned"
+  ")ENGINE=PERFORMANCE_SCHEMA;";
+GO
 
 SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
 PREPARE stmt FROM @str;
@@ -265,16 +293,15 @@ DROP PREPARE stmt;
 -- TABLE EVENTS_WAITS_SUMMARY_BY_EVENT_NAME
 --
 
-SET @l1="CREATE TABLE performance_schema.EVENTS_WAITS_SUMMARY_BY_EVENT_NAME(";
-SET @l2="EVENT_NAME VARCHAR(128) not null,";
-SET @l3="COUNT_STAR BIGINT unsigned not null,";
-SET @l4="SUM_TIMER_WAIT BIGINT unsigned not null,";
-SET @l5="MIN_TIMER_WAIT BIGINT unsigned not null,";
-SET @l6="AVG_TIMER_WAIT BIGINT unsigned not null,";
-SET @l7="MAX_TIMER_WAIT BIGINT unsigned not null";
-SET @l8=")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @cmd=concat(@l1,@l2,@l3,@l4,@l5,@l6,@l7,@l8);
+SET @cmd="CREATE TABLE performance_schema.EVENTS_WAITS_SUMMARY_BY_EVENT_NAME("
+  "EVENT_NAME VARCHAR(128) not null,"
+  "COUNT_STAR BIGINT unsigned not null,"
+  "SUM_TIMER_WAIT BIGINT unsigned not null,"
+  "MIN_TIMER_WAIT BIGINT unsigned not null,"
+  "AVG_TIMER_WAIT BIGINT unsigned not null,"
+  "MAX_TIMER_WAIT BIGINT unsigned not null"
+  ")ENGINE=PERFORMANCE_SCHEMA;";
+GO
 
 SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
 PREPARE stmt FROM @str;
@@ -285,17 +312,16 @@ DROP PREPARE stmt;
 -- TABLE EVENTS_WAITS_SUMMARY_BY_INSTANCE
 --
 
-SET @l1="CREATE TABLE performance_schema.EVENTS_WAITS_SUMMARY_BY_INSTANCE(";
-SET @l2="EVENT_NAME VARCHAR(128) not null,";
-SET @l3="OBJECT_INSTANCE_BEGIN BIGINT not null,";
-SET @l4="COUNT_STAR BIGINT unsigned not null,";
-SET @l5="SUM_TIMER_WAIT BIGINT unsigned not null,";
-SET @l6="MIN_TIMER_WAIT BIGINT unsigned not null,";
-SET @l7="AVG_TIMER_WAIT BIGINT unsigned not null,";
-SET @l8="MAX_TIMER_WAIT BIGINT unsigned not null";
-SET @l9=")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @cmd=concat(@l1,@l2,@l3,@l4,@l5,@l6,@l7,@l8,@l9);
+SET @cmd="CREATE TABLE performance_schema.EVENTS_WAITS_SUMMARY_BY_INSTANCE("
+  "EVENT_NAME VARCHAR(128) not null,"
+  "OBJECT_INSTANCE_BEGIN BIGINT not null,"
+  "COUNT_STAR BIGINT unsigned not null,"
+  "SUM_TIMER_WAIT BIGINT unsigned not null,"
+  "MIN_TIMER_WAIT BIGINT unsigned not null,"
+  "AVG_TIMER_WAIT BIGINT unsigned not null,"
+  "MAX_TIMER_WAIT BIGINT unsigned not null"
+  ")ENGINE=PERFORMANCE_SCHEMA;";
+GO
 
 SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
 PREPARE stmt FROM @str;
@@ -306,17 +332,16 @@ DROP PREPARE stmt;
 -- TABLE EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME
 --
 
-SET @l1="CREATE TABLE performance_schema.EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME(";
-SET @l2="THREAD_ID INTEGER not null,";
-SET @l3="EVENT_NAME VARCHAR(128) not null,";
-SET @l4="COUNT_STAR BIGINT unsigned not null,";
-SET @l5="SUM_TIMER_WAIT BIGINT unsigned not null,";
-SET @l6="MIN_TIMER_WAIT BIGINT unsigned not null,";
-SET @l7="AVG_TIMER_WAIT BIGINT unsigned not null,";
-SET @l8="MAX_TIMER_WAIT BIGINT unsigned not null";
-SET @l9=")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @cmd=concat(@l1,@l2,@l3,@l4,@l5,@l6,@l7,@l8,@l9);
+SET @cmd="CREATE TABLE performance_schema.EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME("
+  "THREAD_ID INTEGER not null,"
+  "EVENT_NAME VARCHAR(128) not null,"
+  "COUNT_STAR BIGINT unsigned not null,"
+  "SUM_TIMER_WAIT BIGINT unsigned not null,"
+  "MIN_TIMER_WAIT BIGINT unsigned not null,"
+  "AVG_TIMER_WAIT BIGINT unsigned not null,"
+  "MAX_TIMER_WAIT BIGINT unsigned not null"
+  ")ENGINE=PERFORMANCE_SCHEMA;";
+GO
 
 SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
 PREPARE stmt FROM @str;
@@ -327,13 +352,12 @@ DROP PREPARE stmt;
 -- TABLE FILE_INSTANCES
 --
 
-SET @l1="CREATE TABLE performance_schema.FILE_INSTANCES(";
-SET @l2="FILE_NAME VARCHAR(512) not null,";
-SET @l3="EVENT_NAME VARCHAR(128) not null,";
-SET @l4="OPEN_COUNT INTEGER unsigned not null";
-SET @l5=")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @cmd=concat(@l1,@l2,@l3,@l4,@l5);
+SET @cmd="CREATE TABLE performance_schema.FILE_INSTANCES("
+  "FILE_NAME VARCHAR(512) not null,"
+  "EVENT_NAME VARCHAR(128) not null,"
+  "OPEN_COUNT INTEGER unsigned not null"
+  ")ENGINE=PERFORMANCE_SCHEMA;";
+GO
 
 SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
 PREPARE stmt FROM @str;
@@ -344,15 +368,14 @@ DROP PREPARE stmt;
 -- TABLE FILE_SUMMARY_BY_EVENT_NAME
 --
 
-SET @l1="CREATE TABLE performance_schema.FILE_SUMMARY_BY_EVENT_NAME(";
-SET @l2="EVENT_NAME VARCHAR(128) not null,";
-SET @l3="COUNT_READ BIGINT unsigned not null,";
-SET @l4="COUNT_WRITE BIGINT unsigned not null,";
-SET @l5="SUM_NUMBER_OF_BYTES_READ BIGINT unsigned not null,";
-SET @l6="SUM_NUMBER_OF_BYTES_WRITE BIGINT unsigned not null";
-SET @l7=")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @cmd=concat(@l1,@l2,@l3,@l4,@l5,@l6,@l7);
+SET @cmd="CREATE TABLE performance_schema.FILE_SUMMARY_BY_EVENT_NAME("
+  "EVENT_NAME VARCHAR(128) not null,"
+  "COUNT_READ BIGINT unsigned not null,"
+  "COUNT_WRITE BIGINT unsigned not null,"
+  "SUM_NUMBER_OF_BYTES_READ BIGINT unsigned not null,"
+  "SUM_NUMBER_OF_BYTES_WRITE BIGINT unsigned not null"
+  ")ENGINE=PERFORMANCE_SCHEMA;";
+GO
 
 SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
 PREPARE stmt FROM @str;
@@ -363,16 +386,15 @@ DROP PREPARE stmt;
 -- TABLE FILE_SUMMARY_BY_INSTANCE
 --
 
-SET @l1="CREATE TABLE performance_schema.FILE_SUMMARY_BY_INSTANCE(";
-SET @l2="FILE_NAME VARCHAR(512) not null,";
-SET @l3="EVENT_NAME VARCHAR(128) not null,";
-SET @l4="COUNT_READ BIGINT unsigned not null,";
-SET @l5="COUNT_WRITE BIGINT unsigned not null,";
-SET @l6="SUM_NUMBER_OF_BYTES_READ BIGINT unsigned not null,";
-SET @l7="SUM_NUMBER_OF_BYTES_WRITE BIGINT unsigned not null";
-SET @l8=")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @cmd=concat(@l1,@l2,@l3,@l4,@l5,@l6,@l7,@l8);
+SET @cmd="CREATE TABLE performance_schema.FILE_SUMMARY_BY_INSTANCE("
+  "FILE_NAME VARCHAR(512) not null,"
+  "EVENT_NAME VARCHAR(128) not null,"
+  "COUNT_READ BIGINT unsigned not null,"
+  "COUNT_WRITE BIGINT unsigned not null,"
+  "SUM_NUMBER_OF_BYTES_READ BIGINT unsigned not null,"
+  "SUM_NUMBER_OF_BYTES_WRITE BIGINT unsigned not null"
+  ")ENGINE=PERFORMANCE_SCHEMA;";
+GO
 
 SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
 PREPARE stmt FROM @str;
@@ -383,13 +405,12 @@ DROP PREPARE stmt;
 -- TABLE MUTEX_INSTANCES
 --
 
-SET @l1="CREATE TABLE performance_schema.MUTEX_INSTANCES(";
-SET @l2="NAME VARCHAR(128) not null,";
-SET @l3="OBJECT_INSTANCE_BEGIN BIGINT not null,";
-SET @l4="LOCKED_BY_THREAD_ID INTEGER";
-SET @l5=")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @cmd=concat(@l1,@l2,@l3,@l4,@l5);
+SET @cmd="CREATE TABLE performance_schema.MUTEX_INSTANCES("
+  "NAME VARCHAR(128) not null,"
+  "OBJECT_INSTANCE_BEGIN BIGINT not null,"
+  "LOCKED_BY_THREAD_ID INTEGER"
+  ")ENGINE=PERFORMANCE_SCHEMA;";
+GO
 
 SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
 PREPARE stmt FROM @str;
@@ -400,14 +421,13 @@ DROP PREPARE stmt;
 -- TABLE PERFORMANCE_TIMERS
 --
 
-SET @l1="CREATE TABLE performance_schema.PERFORMANCE_TIMERS(";
-SET @l2="TIMER_NAME ENUM ('CYCLE', 'NANOSECOND', 'MICROSECOND', 'MILLISECOND', 'TICK') not null,";
-SET @l3="TIMER_FREQUENCY BIGINT,";
-SET @l4="TIMER_RESOLUTION BIGINT,";
-SET @l5="TIMER_OVERHEAD BIGINT";
-SET @l6=") ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @cmd=concat(@l1,@l2,@l3,@l4,@l5,@l6);
+SET @cmd="CREATE TABLE performance_schema.PERFORMANCE_TIMERS("
+  "TIMER_NAME ENUM ('CYCLE', 'NANOSECOND', 'MICROSECOND', 'MILLISECOND', 'TICK') not null,"
+  "TIMER_FREQUENCY BIGINT,"
+  "TIMER_RESOLUTION BIGINT,"
+  "TIMER_OVERHEAD BIGINT"
+  ") ENGINE=PERFORMANCE_SCHEMA;";
+GO
 
 SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
 PREPARE stmt FROM @str;
@@ -418,13 +438,12 @@ DROP PREPARE stmt;
 -- TABLE PROCESSLIST
 --
 
-SET @l1="CREATE TABLE performance_schema.PROCESSLIST(";
-SET @l2="THREAD_ID INTEGER not null,";
-SET @l3="ID INTEGER not null,";
-SET @l4="NAME VARCHAR(64) not null";
-SET @l5=")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @cmd=concat(@l1,@l2,@l3,@l4,@l5);
+SET @cmd="CREATE TABLE performance_schema.PROCESSLIST("
+  "THREAD_ID INTEGER not null,"
+  "ID INTEGER not null,"
+  "NAME VARCHAR(64) not null"
+  ")ENGINE=PERFORMANCE_SCHEMA;";
+GO
 
 SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
 PREPARE stmt FROM @str;
@@ -435,14 +454,13 @@ DROP PREPARE stmt;
 -- TABLE RWLOCK_INSTANCES
 --
 
-SET @l1="CREATE TABLE performance_schema.RWLOCK_INSTANCES(";
-SET @l2="NAME VARCHAR(128) not null,";
-SET @l3="OBJECT_INSTANCE_BEGIN BIGINT not null,";
-SET @l4="WRITE_LOCKED_BY_THREAD_ID INTEGER,";
-SET @l5="READ_LOCKED_BY_COUNT INTEGER unsigned not null";
-SET @l6=")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @cmd=concat(@l1,@l2,@l3,@l4,@l5,@l6);
+SET @cmd="CREATE TABLE performance_schema.RWLOCK_INSTANCES("
+  "NAME VARCHAR(128) not null,"
+  "OBJECT_INSTANCE_BEGIN BIGINT not null,"
+  "WRITE_LOCKED_BY_THREAD_ID INTEGER,"
+  "READ_LOCKED_BY_COUNT INTEGER unsigned not null"
+  ")ENGINE=PERFORMANCE_SCHEMA;";
+GO
 
 SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
 PREPARE stmt FROM @str;
@@ -453,12 +471,11 @@ DROP PREPARE stmt;
 -- TABLE SETUP_CONSUMERS
 --
 
-SET @l1="CREATE TABLE performance_schema.SETUP_CONSUMERS(";
-SET @l2="NAME VARCHAR(64) not null,";
-SET @l3="ENABLED ENUM ('YES', 'NO') not null";
-SET @l4=")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @cmd=concat(@l1,@l2,@l3,@l4);
+SET @cmd="CREATE TABLE performance_schema.SETUP_CONSUMERS("
+  "NAME VARCHAR(64) not null,"
+  "ENABLED ENUM ('YES', 'NO') not null"
+  ")ENGINE=PERFORMANCE_SCHEMA;";
+GO
 
 SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
 PREPARE stmt FROM @str;
@@ -466,16 +483,18 @@ EXECUTE stmt;
 DROP PREPARE stmt;
 
 --
--- TABLE SETUP_INSTRUMENTS
+-- TABLE SETUP_OBJECTS
 --
 
-SET @l1="CREATE TABLE performance_schema.SETUP_INSTRUMENTS(";
-SET @l2="NAME VARCHAR(128) not null,";
-SET @l3="ENABLED ENUM ('YES', 'NO') not null,";
-SET @l4="TIMED ENUM ('YES', 'NO') not null";
-SET @l5=")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @cmd=concat(@l1,@l2,@l3,@l4,@l5);
+SET @cmd="CREATE TABLE performance_schema.SETUP_OBJECTS("
+  "OBJECT_TYPE VARCHAR(64),"
+  "OBJECT_SCHEMA VARCHAR(64),"
+  "OBJECT_NAME VARCHAR(64),"
+  "ENABLED ENUM ('YES', 'NO') not null,"
+  "TIMED ENUM ('YES', 'NO') not null,"
+  "AGGREGATED ENUM ('YES', 'NO') not null"
+  ")ENGINE=PERFORMANCE_SCHEMA;";
+GO
 
 SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
 PREPARE stmt FROM @str;
@@ -483,19 +502,15 @@ EXECUTE stmt;
 DROP PREPARE stmt;
 
 --
--- TABLE SETUP_OBJECTS
+-- TABLE SETUP_INSTRUMENTS
 --
 
-SET @l1="CREATE TABLE performance_schema.SETUP_OBJECTS(";
-SET @l2="OBJECT_TYPE VARCHAR(64),";
-SET @l3="OBJECT_SCHEMA VARCHAR(64),";
-SET @l4="OBJECT_NAME VARCHAR(64),";
-SET @l5="ENABLED ENUM ('YES', 'NO') not null,";
-SET @l6="TIMED ENUM ('YES', 'NO') not null,";
-SET @l7="AGGREGATED ENUM ('YES', 'NO') not null";
-SET @l8=")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @cmd=concat(@l1,@l2,@l3,@l4,@l5,@l6,@l7,@l8);
+SET @cmd="CREATE TABLE performance_schema.SETUP_INSTRUMENTS("
+  "NAME VARCHAR(128) not null,"
+  "ENABLED ENUM ('YES', 'NO') not null,"
+  "TIMED ENUM ('YES', 'NO') not null"
+  ")ENGINE=PERFORMANCE_SCHEMA;";
+GO
 
 SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
 PREPARE stmt FROM @str;
@@ -506,12 +521,11 @@ DROP PREPARE stmt;
 -- TABLE SETUP_TIMERS
 --
 
-SET @l1="CREATE TABLE performance_schema.SETUP_TIMERS(";
-SET @l2="NAME VARCHAR(64) not null,";
-SET @l3="TIMER_NAME ENUM ('CYCLE', 'NANOSECOND', 'MICROSECOND', 'MILLISECOND', 'TICK') not null";
-SET @l4=")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @cmd=concat(@l1,@l2,@l3,@l4);
+SET @cmd="CREATE TABLE performance_schema.SETUP_TIMERS("
+  "NAME VARCHAR(64) not null,"
+  "TIMER_NAME ENUM ('CYCLE', 'NANOSECOND', 'MICROSECOND', 'MILLISECOND', 'TICK') not null"
+  ")ENGINE=PERFORMANCE_SCHEMA;";
+GO
 
 SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
 PREPARE stmt FROM @str;

=== modified file 'scripts/mysql_system_tables_fix.sql'
--- a/scripts/mysql_system_tables_fix.sql	2010-03-25 07:26:12 +0000
+++ b/scripts/mysql_system_tables_fix.sql	2010-04-27 07:18:34 +0000
@@ -14,9 +14,21 @@ ALTER TABLE user add File_priv enum('N',
 SET @hadGrantPriv:=0;
 SELECT @hadGrantPriv:=1 FROM user WHERE Grant_priv LIKE '%';
 
-ALTER TABLE user add Grant_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add References_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add Index_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add Alter_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL;
-ALTER TABLE host add Grant_priv enum('N','Y') NOT NULL,add References_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add Index_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add Alter_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL;
-ALTER TABLE db add Grant_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add References_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add Index_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add Alter_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL;
+ALTER TABLE user add Grant_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,
+  add References_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,
+  add Index_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,
+  add Alter_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL;
+GO
+ALTER TABLE host add Grant_priv enum('N','Y') NOT NULL,
+  add References_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,
+  add Index_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,
+  add Alter_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL;
+GO
+ALTER TABLE db add Grant_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,
+  add References_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,
+  add Index_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,
+  add Alter_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL;
+GO
 
 # Fix privileges for old tables
 UPDATE user SET Grant_priv=File_priv,References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv WHERE @hadGrantPriv = 0;
@@ -32,6 +44,7 @@ ADD ssl_type enum('','ANY','X509', 'SPEC
 ADD ssl_cipher BLOB NOT NULL,
 ADD x509_issuer BLOB NOT NULL,
 ADD x509_subject BLOB NOT NULL;
+GO
 ALTER TABLE user MODIFY ssl_type enum('','ANY','X509', 'SPECIFIED') NOT NULL;
 
 #
@@ -39,6 +52,7 @@ ALTER TABLE user MODIFY ssl_type enum(''
 #
 ALTER TABLE tables_priv
   ADD KEY Grantor (Grantor);
+GO
 
 ALTER TABLE tables_priv
   MODIFY Host char(60) NOT NULL default '',
@@ -48,6 +62,7 @@ ALTER TABLE tables_priv
   MODIFY Grantor char(77) NOT NULL default '',
   ENGINE=MyISAM,
   CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
+GO
 
 ALTER TABLE tables_priv
   MODIFY Column_priv set('Select','Insert','Update','References')
@@ -57,6 +72,7 @@ ALTER TABLE tables_priv
                         'Create View','Show view')
     COLLATE utf8_general_ci DEFAULT '' NOT NULL,
   COMMENT='Table privileges';
+GO
 
 #
 # columns_priv
@@ -67,6 +83,7 @@ ALTER TABLE tables_priv
 ALTER TABLE columns_priv
   CHANGE Type Column_priv set('Select','Insert','Update','References')
     COLLATE utf8_general_ci DEFAULT '' NOT NULL;
+GO
 
 ALTER TABLE columns_priv
   MODIFY Host char(60) NOT NULL default '',
@@ -77,10 +94,12 @@ ALTER TABLE columns_priv
   ENGINE=MyISAM,
   CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin,
   COMMENT='Column privileges';
+GO
 
 ALTER TABLE columns_priv
   MODIFY Column_priv set('Select','Insert','Update','References')
     COLLATE utf8_general_ci DEFAULT '' NOT NULL;
+GO
 
 #
 #  Add the new 'type' column to the func table.
@@ -104,10 +123,14 @@ ADD Lock_tables_priv enum('N','Y') COLLA
 ADD Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Lock_tables_priv,
 ADD Repl_slave_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Execute_priv,
 ADD Repl_client_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Repl_slave_priv;
+GO
 
 # Convert privileges so that users have similar privileges as before
 
-UPDATE user SET Show_db_priv= Select_priv, Super_priv=Process_priv, Execute_priv=Process_priv, Create_tmp_table_priv='Y', Lock_tables_priv='Y', Repl_slave_priv=file_priv, Repl_client_priv=File_priv where user<>"" AND @hadShowDbPriv = 0;
+UPDATE user SET Show_db_priv= Select_priv, Super_priv=Process_priv, Execute_priv=Process_priv,
+  Create_tmp_table_priv='Y', Lock_tables_priv='Y', Repl_slave_priv=file_priv, Repl_client_priv=File_priv
+  where user<>"" AND @hadShowDbPriv = 0;
+GO
 
 
 #  Add fields that can be used to limit number of questions and connections
@@ -117,6 +140,7 @@ ALTER TABLE user
 ADD max_questions int(11) NOT NULL DEFAULT 0 AFTER x509_subject,
 ADD max_updates   int(11) unsigned NOT NULL DEFAULT 0 AFTER max_questions,
 ADD max_connections int(11) unsigned NOT NULL DEFAULT 0 AFTER max_updates;
+GO
 
 
 #
@@ -126,9 +150,11 @@ ADD max_connections int(11) unsigned NOT
 ALTER TABLE db
 ADD Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
 ADD Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
+GO
 ALTER TABLE host
 ADD Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,
 ADD Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL;
+GO
 
 alter table user change max_questions max_questions int(11) unsigned DEFAULT 0  NOT NULL;
 
@@ -144,6 +170,7 @@ ALTER TABLE user
   MODIFY Host char(60) NOT NULL default '',
   MODIFY User char(16) NOT NULL default '',
   ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
+GO
 ALTER TABLE user
   MODIFY Password char(41) character set latin1 collate latin1_bin NOT NULL default '',
   MODIFY Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
@@ -168,12 +195,14 @@ ALTER TABLE user
   MODIFY Repl_slave_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
   MODIFY Repl_client_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
   MODIFY ssl_type enum('','ANY','X509', 'SPECIFIED') COLLATE utf8_general_ci DEFAULT '' NOT NULL;
+GO
 
 ALTER TABLE db
   MODIFY Host char(60) NOT NULL default '',
   MODIFY Db char(64) NOT NULL default '',
   MODIFY User char(16) NOT NULL default '',
   ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
+GO
 ALTER TABLE db
   MODIFY  Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
   MODIFY  Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
@@ -187,11 +216,13 @@ ALTER TABLE db
   MODIFY  Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
   MODIFY  Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
   MODIFY  Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
+GO
 
 ALTER TABLE host
   MODIFY Host char(60) NOT NULL default '',
   MODIFY Db char(64) NOT NULL default '',
   ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
+GO
 ALTER TABLE host
   MODIFY Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
   MODIFY Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
@@ -205,11 +236,14 @@ ALTER TABLE host
   MODIFY Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
   MODIFY Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
   MODIFY Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
+GO
 
 ALTER TABLE func
   ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
+GO
 ALTER TABLE func
   MODIFY type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL;
+GO
 
 #
 # Modify log tables.
@@ -246,6 +280,7 @@ ALTER TABLE plugin
   MODIFY name varchar(64) COLLATE utf8_general_ci NOT NULL DEFAULT '',
   MODIFY dl varchar(128) COLLATE utf8_general_ci NOT NULL DEFAULT '',
   CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
+GO
 
 #
 # Detect whether we had Create_view_priv
@@ -342,6 +377,7 @@ ALTER TABLE user MODIFY Create_user_priv
 UPDATE user LEFT JOIN db USING (Host,User) SET Create_user_priv='Y'
   WHERE @hadCreateUserPriv = 0 AND
         (user.Grant_priv = 'Y' OR db.Grant_priv = 'Y');
+GO
 
 #
 # procs_priv
@@ -350,21 +386,26 @@ UPDATE user LEFT JOIN db USING (Host,Use
 ALTER TABLE procs_priv
   ENGINE=MyISAM,
   CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
+GO
 
 ALTER TABLE procs_priv
   MODIFY Proc_priv set('Execute','Alter Routine','Grant')
     COLLATE utf8_general_ci DEFAULT '' NOT NULL;
+GO
 
 ALTER IGNORE TABLE procs_priv
   MODIFY Routine_name char(64)
     COLLATE utf8_general_ci DEFAULT '' NOT NULL;
+GO
 
 ALTER TABLE procs_priv
   ADD Routine_type enum('FUNCTION','PROCEDURE')
     COLLATE utf8_general_ci NOT NULL AFTER Routine_name;
+GO
 
 ALTER TABLE procs_priv
   MODIFY Timestamp timestamp AFTER Proc_priv;
+GO
 
 #
 # proc
@@ -416,6 +457,7 @@ ALTER TABLE proc MODIFY name char(64) DE
                             'PAD_CHAR_TO_FULL_LENGTH'
                             ) DEFAULT '' NOT NULL,
                  DEFAULT CHARACTER SET utf8;
+GO
 
 # Correct the character set and collation
 ALTER TABLE proc CONVERT TO CHARACTER SET utf8;
@@ -426,62 +468,77 @@ ALTER TABLE proc  MODIFY db
                          char(77) collate utf8_bin DEFAULT '' NOT NULL,
                   MODIFY comment
                          char(64) collate utf8_bin DEFAULT '' NOT NULL;
+GO
 
 ALTER TABLE proc ADD character_set_client
                      char(32) collate utf8_bin DEFAULT NULL
                      AFTER comment;
+GO
 ALTER TABLE proc MODIFY character_set_client
                         char(32) collate utf8_bin DEFAULT NULL;
+GO
 
 SELECT CASE WHEN COUNT(*) > 0 THEN 
 CONCAT ("WARNING: NULL values of the 'character_set_client' column ('mysql.proc' table) have been updated with a default value (", @@character_set_client, "). Please verify if necessary.")
 ELSE NULL 
 END 
 AS value FROM proc WHERE character_set_client IS NULL;
+GO
 
 UPDATE proc SET character_set_client = @@character_set_client 
                      WHERE character_set_client IS NULL;
+GO
 
 ALTER TABLE proc ADD collation_connection
                      char(32) collate utf8_bin DEFAULT NULL
                      AFTER character_set_client;
+GO
 ALTER TABLE proc MODIFY collation_connection
                         char(32) collate utf8_bin DEFAULT NULL;
+GO
 
 SELECT CASE WHEN COUNT(*) > 0 THEN 
 CONCAT ("WARNING: NULL values of the 'collation_connection' column ('mysql.proc' table) have been updated with a default value (", @@collation_connection, "). Please verify if necessary.")
 ELSE NULL 
 END 
 AS value FROM proc WHERE collation_connection IS NULL;
+GO
 
 UPDATE proc SET collation_connection = @@collation_connection
                      WHERE collation_connection IS NULL;
+GO
 
 ALTER TABLE proc ADD db_collation
                      char(32) collate utf8_bin DEFAULT NULL
                      AFTER collation_connection;
+GO
 ALTER TABLE proc MODIFY db_collation
                         char(32) collate utf8_bin DEFAULT NULL;
+GO
 
 SELECT CASE WHEN COUNT(*) > 0 THEN 
 CONCAT ("WARNING: NULL values of the 'db_collation' column ('mysql.proc' table) have been updated with default values. Please verify if necessary.")
 ELSE NULL
 END
 AS value FROM proc WHERE db_collation IS NULL;
+GO
 
 UPDATE proc AS p SET db_collation  = 
                      ( SELECT DEFAULT_COLLATION_NAME 
                        FROM INFORMATION_SCHEMA.SCHEMATA 
                        WHERE SCHEMA_NAME = p.db)
                      WHERE db_collation IS NULL;
+GO
 
 ALTER TABLE proc ADD body_utf8 longblob DEFAULT NULL
                      AFTER db_collation;
+GO
 ALTER TABLE proc MODIFY body_utf8 longblob DEFAULT NULL;
 
 # Change comment from char(64) to text
 ALTER TABLE proc MODIFY comment
                         text collate utf8_bin NOT NULL;
+GO
 
 #
 # EVENT privilege
@@ -539,6 +596,7 @@ ALTER TABLE event MODIFY sql_mode
                             'NO_ENGINE_SUBSTITUTION',
                             'PAD_CHAR_TO_FULL_LENGTH'
                             ) DEFAULT '' NOT NULL AFTER on_completion;
+GO
 ALTER TABLE event MODIFY name char(64) CHARACTER SET utf8 NOT NULL default '';
 
 ALTER TABLE event MODIFY COLUMN originator INT UNSIGNED NOT NULL;
@@ -548,27 +606,35 @@ ALTER TABLE event MODIFY COLUMN status E
 
 ALTER TABLE event ADD COLUMN time_zone char(64) CHARACTER SET latin1
         NOT NULL DEFAULT 'SYSTEM' AFTER originator;
+GO
 
 ALTER TABLE event ADD character_set_client
                       char(32) collate utf8_bin DEFAULT NULL
                       AFTER time_zone;
+GO
 ALTER TABLE event MODIFY character_set_client
                          char(32) collate utf8_bin DEFAULT NULL;
+GO
 
 ALTER TABLE event ADD collation_connection
                       char(32) collate utf8_bin DEFAULT NULL
                       AFTER character_set_client;
+GO
 ALTER TABLE event MODIFY collation_connection
                          char(32) collate utf8_bin DEFAULT NULL;
+GO
 
 ALTER TABLE event ADD db_collation
                       char(32) collate utf8_bin DEFAULT NULL
                       AFTER collation_connection;
+GO
 ALTER TABLE event MODIFY db_collation
                          char(32) collate utf8_bin DEFAULT NULL;
+GO
 
 ALTER TABLE event ADD body_utf8 longblob DEFAULT NULL
                       AFTER db_collation;
+GO
 ALTER TABLE event MODIFY body_utf8 longblob DEFAULT NULL;
 
 
@@ -588,7 +654,10 @@ ALTER TABLE host MODIFY Trigger_priv enu
 ALTER TABLE db ADD Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
 ALTER TABLE db MODIFY Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
 
-ALTER TABLE tables_priv MODIFY Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') COLLATE utf8_general_ci DEFAULT '' NOT NULL;
+ALTER TABLE tables_priv MODIFY Table_priv set('Select','Insert','Update','Delete','Create','Drop',
+                                              'Grant','References','Index','Alter','Create View','Show view','Trigger')
+  COLLATE utf8_general_ci DEFAULT '' NOT NULL;
+GO
 
 UPDATE user SET Trigger_priv=Super_priv WHERE @hadTriggerPriv = 0;
 

=== modified file 'sql/CMakeLists.txt'
--- a/sql/CMakeLists.txt	2010-03-31 14:05:33 +0000
+++ b/sql/CMakeLists.txt	2010-04-27 07:18:34 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2006 MySQL AB
+# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
 # 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -75,7 +75,7 @@ SET (SQL_SOURCE
                sql_connect.cc scheduler.cc 
                sql_profile.cc event_parse_data.cc
                sql_signal.cc rpl_handler.cc mdl.cc
-               transaction.cc sys_vars.cc
+               transaction.cc sys_vars.cc sql_bootstrap.cc
                ${GEN_SOURCES}
                ${MYSYS_LIBWRAP_SOURCE})
 

=== modified file 'sql/Makefile.am'
--- a/sql/Makefile.am	2010-03-31 14:05:33 +0000
+++ b/sql/Makefile.am	2010-04-27 07:18:34 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2000-2006 MySQL AB
+# Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
 # 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -155,7 +155,7 @@ mysqld_SOURCES =	sql_lex.cc sql_handler.
 			rpl_utility.cc rpl_injector.cc rpl_rli.cc rpl_mi.cc \
 			rpl_reporting.cc \
                         sql_union.cc sql_derived.cc \
-			sql_client.cc \
+			sql_client.cc sql_bootstrap.cc \
 			repl_failsafe.h repl_failsafe.cc \
 			sql_olap.cc sql_view.cc \
 			gstream.cc spatial.cc sql_help.cc sql_cursor.cc \

=== added file 'sql/sql_bootstrap.cc'
--- a/sql/sql_bootstrap.cc	1970-01-01 00:00:00 +0000
+++ b/sql/sql_bootstrap.cc	2010-04-27 07:18:34 +0000
@@ -0,0 +1,115 @@
+/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+
+#include <ctype.h>
+#include <string.h>
+#include "sql_bootstrap.h"
+
+int read_bootstrap_query(char *query, int *query_length,
+                         fgets_input_t input, fgets_fn_t fgets_fn)
+{
+  char line_buffer[MAX_BOOTSTRAP_LINE_SIZE];
+  const char *line;
+  int len;
+  int query_len= 0;
+
+  for ( ; ; )
+  {
+    line= (*fgets_fn)(line_buffer, sizeof(line_buffer), input);
+
+    if (line == NULL)
+      return (query_len ? READ_BOOTSTRAP_ERROR : READ_BOOTSTRAP_EOF);
+
+    len= strlen(line);
+
+    /*
+      Remove trailing whitespace characters.
+      This assumes:
+      - no multibyte encoded character can be found at the very end of a line,
+      - whitespace characters from the "C" locale only.
+     which is sufficient for the kind of queries found
+     in the bootstrap scripts.
+    */
+    while (len && (isspace(line[len - 1])))
+      len--;
+    /*
+      Cleanly end the string, so we don't have to test len > x
+      all the time before reading line[x], in the code below.
+    */
+    line_buffer[len]= '\0';
+
+    /* Skip blank lines */
+    if (len == 0)
+      continue;
+
+    /* Skip # comments */
+    if (line[0] == '#')
+      continue;
+    
+    /* Skip -- comments */
+    if ((line[0] == '-') && (line[1] == '-'))
+      continue;
+
+    /* Skip delimiter, ignored. */
+    if (strncmp(line, "delimiter", 9) == 0)
+      continue;
+
+    if (query_len == 0)
+    {
+      if (line[len - 1] == ';')
+      {
+        /*
+          The first line is terminated by ';'.
+          This is a valid single line query.
+        */
+        memcpy(query, line, len);
+        *query_length= len;
+        query[len]= '\0';
+        return 0;
+      }
+    }
+    else
+    {
+      if ((len >= 2) && (line[0] == 'G') && (line[1] == 'O'))
+      {
+        /*
+          Found the multiline 'GO' delimiter.
+          This is a valid multi line query.
+        */
+        *query_length= query_len;
+        query[query_len]= '\0';
+        return 0;
+      }
+    }
+
+    /* Append the current line to a multi line query. */
+    if (query_len + len + 1 >= MAX_BOOTSTRAP_QUERY_SIZE)
+      return READ_BOOTSTRAP_ERROR;
+
+    if (query_len != 0)
+    {
+      /*
+        Append a \n to the current line, if any,
+        to preserve the intended presentation.
+       */
+      query[query_len]= '\n';
+      query_len++;
+    }
+    memcpy(query + query_len, line, len);
+    query_len+= len;
+  }
+}
+

=== added file 'sql/sql_bootstrap.h'
--- a/sql/sql_bootstrap.h	1970-01-01 00:00:00 +0000
+++ b/sql/sql_bootstrap.h	2010-04-27 07:18:34 +0000
@@ -0,0 +1,44 @@
+/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+
+#ifndef SQL_BOOTSTRAP_H
+#define SQL_BOOTSTRAP_H
+
+/**
+  The maximum size of a bootstrap query.
+  Increase this size if parsing a longer query during bootstrap is necessary.
+  The longest query in use currently is:
+    INSERT INTO time_zone_transition ..., 8059 characters
+*/
+#define MAX_BOOTSTRAP_QUERY_SIZE 10000
+/**
+  The maximum size of a bootstrap query, expressed in a single line.
+  Do not increase this size, use the multiline syntax with 'GO' instead.
+*/
+#define MAX_BOOTSTRAP_LINE_SIZE 10000
+
+#define READ_BOOTSTRAP_EOF 1
+#define READ_BOOTSTRAP_ERROR 2
+
+typedef void *fgets_input_t;
+typedef char * (*fgets_fn_t)(char *, size_t, fgets_input_t);
+
+int read_bootstrap_query(char *query, int *query_length,
+                         fgets_input_t input, fgets_fn_t fgets_fn);
+
+#endif
+
+

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2010-04-07 12:02:19 +0000
+++ b/sql/sql_parse.cc	2010-04-27 07:18:34 +0000
@@ -1,4 +1,4 @@
-/* Copyright 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -94,6 +94,7 @@
 #include "sql_prepare.h"
 #include "probes_mysql.h"
 #include "set_var.h"
+#include "sql_bootstrap.h"
 
 #define FLAGSTR(V,F) ((V)&(F)?#F" ":"")
 
@@ -455,11 +456,19 @@ void execute_init_command(THD *thd, LEX_
 #endif
 }
 
+static char *fgets_fn(char *buffer, size_t size, fgets_input_t input)
+{
+  MYSQL_FILE *in= static_cast<MYSQL_FILE*> (input);
+  return mysql_file_fgets(buffer, size, in);
+}
 
 static void handle_bootstrap_impl(THD *thd)
 {
   MYSQL_FILE *file= bootstrap_file;
-  char *buff;
+  char buffer[MAX_BOOTSTRAP_QUERY_SIZE];
+  char *query;
+  int length;
+  int rc;
   const char* found_semicolon= NULL;
 
   DBUG_ENTER("handle_bootstrap");
@@ -481,44 +490,26 @@ static void handle_bootstrap_impl(THD *t
   */
   thd->client_capabilities|= CLIENT_MULTI_RESULTS;
 
-  buff= (char*) thd->net.buff;
   thd->init_for_queries();
-  while (mysql_file_fgets(buff, thd->net.max_packet, file))
+
+  for ( ; ; )
   {
-    char *query;
-    /* strlen() can't be deleted because mysql_file_fgets() doesn't return length */
-    ulong length= (ulong) strlen(buff);
-    while (buff[length-1] != '\n' && !mysql_file_feof(file))
+    rc= read_bootstrap_query(buffer, &length, file, fgets_fn);
+
+    if (rc == READ_BOOTSTRAP_ERROR)
     {
-      /*
-        We got only a part of the current string. Will try to increase
-        net buffer then read the rest of the current string.
-      */
-      /* purecov: begin tested */
-      if (net_realloc(&(thd->net), 2 * thd->net.max_packet))
-      {
-        thd->protocol->end_statement();
-        bootstrap_error= 1;
-        break;
-      }
-      buff= (char*) thd->net.buff;
-      mysql_file_fgets(buff + length, thd->net.max_packet - length, file);
-      length+= (ulong) strlen(buff + length);
-      /* purecov: end */
+      thd->raise_error(ER_SYNTAX_ERROR);
+      thd->protocol->end_statement();
+      bootstrap_error= 1;
+      break;
     }
-    if (bootstrap_error)
-      break;                                    /* purecov: inspected */
 
-    while (length && (my_isspace(thd->charset(), buff[length-1]) ||
-                      buff[length-1] == ';'))
-      length--;
-    buff[length]=0;
+    if (rc == READ_BOOTSTRAP_EOF)
+      break;
 
-    /* Skip lines starting with delimiter */
-    if (strncmp(buff, STRING_WITH_LEN("delimiter")) == 0)
-      continue;
+    DBUG_ASSERT(rc == 0);
 
-    query= (char *) thd->memdup_w_gap(buff, length + 1,
+    query= (char *) thd->memdup_w_gap(buffer, length + 1,
                                       thd->db_length + 1 +
                                       QUERY_CACHE_FLAGS_SIZE);
     thd->set_query_and_id(query, length, next_query_id());


Attachment: [text/bzr-bundle] bzr/marc.alff@oracle.com-20100427071834-fz4hnqpht3upzcy5.bundle
Thread
bzr push into mysql-next-mr-wl5291 branch (marc.alff:3140 to 3141)WL#5291Marc Alff27 Apr