diff --git a/BUILD/check-cpu b/BUILD/check-cpu
index e207d12d9725fc9c3398a83ebae974e3ccb365a7..9dd10b8ec3e45f830355189eb4a80196c58abb22 100755
--- a/BUILD/check-cpu
+++ b/BUILD/check-cpu
@@ -167,8 +167,7 @@ check_cpu () {
   touch __test.c
 
   while [ "$cpu_arg" ] ; do
-    # FIXME: echo -n isn't portable - see contortions autoconf goes through
-    echo -n testing $cpu_arg "... " >&2
+    printf "testing $cpu_arg ... " >&2
           
     # compile check
     check_cpu_cflags=`eval echo $check_cpu_args`
diff --git a/client/mysqldump.c b/client/mysqldump.c
index 2d2fe439f766ee1f3dc5684d131cfc3358ded6b2..3bf9fff1b863292f7ce4210426f681ea2b57153f 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -2589,6 +2589,8 @@ static char *primary_key_fields(const char *table_name)
   char show_keys_buff[15 + 64 * 2 + 3];
   uint result_length = 0;
   char *result = 0;
+  char buff[NAME_LEN * 2 + 3];
+  char *quoted_field;
 
   my_snprintf(show_keys_buff, sizeof(show_keys_buff), 
 	      "SHOW KEYS FROM %s", table_name);
@@ -2612,8 +2614,10 @@ static char *primary_key_fields(const char *table_name)
   {
     /* Key is unique */
     do
-      result_length += strlen(row[4]) + 1;      /* + 1 for ',' or \0 */
-    while ((row = mysql_fetch_row(res)) && atoi(row[3]) > 1);
+    {
+      quoted_field= quote_name(row[4], buff, 0);
+      result_length+= strlen(quoted_field) + 1; /* + 1 for ',' or \0 */
+    } while ((row= mysql_fetch_row(res)) && atoi(row[3]) > 1);
   }
 
   /* Build the ORDER BY clause result */
@@ -2627,9 +2631,13 @@ static char *primary_key_fields(const char *table_name)
     }
     mysql_data_seek(res, 0);
     row = mysql_fetch_row(res);
-    end = strmov(result, row[4]);
-    while ((row = mysql_fetch_row(res)) && atoi(row[3]) > 1)
-      end = strxmov(end, ",", row[4], NullS);
+    quoted_field= quote_name(row[4], buff, 0);
+    end= strmov(result, quoted_field);
+    while ((row= mysql_fetch_row(res)) && atoi(row[3]) > 1)
+    {
+      quoted_field= quote_name(row[4], buff, 0);
+      end= strxmov(end, ",", quoted_field, NullS);
+    }
   }
 
 cleanup:
diff --git a/configure.in b/configure.in
index 4ac0637e42c4d7ba4acbf2e2c35c53b88d7c3945..8457a2dcad0cd82ee7ec0adf482c7c3820b83a76 100644
--- a/configure.in
+++ b/configure.in
@@ -2990,10 +2990,14 @@ AM_CONDITIONAL(HAVE_NETWARE, test "$netware_dir" = "netware")
 export CC CXX CFLAGS CXXFLAGS LD LDFLAGS AR
 ac_configure_args="$ac_configure_args CFLAGS='$CFLAGS' CXXFLAGS='$CXXFLAGS'"
 
-if test "$with_server" = "yes" -o "$THREAD_SAFE_CLIENT" != "no"
+if test "$with_server" != "no" -o "$THREAD_SAFE_CLIENT" != "no"
 then
   AC_DEFINE([THREAD], [1],
             [Define if you want to have threaded code. This may be undef on client code])
+fi
+
+if test "$with_server" != "no"
+then
   # Avoid _PROGRAMS names
   THREAD_LPROGRAMS="test_thr_alarm\$(EXEEXT) test_thr_lock\$(EXEEXT)"
   AC_SUBST(THREAD_LPROGRAMS)
diff --git a/heap/hp_block.c b/heap/hp_block.c
index f26b208b52170894255252832a477e527abfeb6a..4ae97581adbc543caa40f452986178d5c1fc38f1 100644
--- a/heap/hp_block.c
+++ b/heap/hp_block.c
@@ -76,7 +76,7 @@ int hp_get_new_block(HP_BLOCK *block, ulong *alloc_length)
     and my_default_record_cache_size we get about 1/128 unused memory.
    */
   *alloc_length=sizeof(HP_PTRS)*i+block->records_in_block* block->recbuffer;
-  if (!(root=(HP_PTRS*) my_malloc(*alloc_length,MYF(0))))
+  if (!(root=(HP_PTRS*) my_malloc(*alloc_length,MYF(MY_WME))))
     return 1;
 
   if (i == 0)
diff --git a/heap/hp_write.c b/heap/hp_write.c
index 808fe6608b142061f6713048cd7ec38dad4c74bc..841dda6264e74fbcf5046cbe08fb58ed0ec0d7c9 100644
--- a/heap/hp_write.c
+++ b/heap/hp_write.c
@@ -68,11 +68,17 @@ int heap_write(HP_INFO *info, const byte *record)
   DBUG_RETURN(0);
 
 err:
-  DBUG_PRINT("info",("Duplicate key: %d", keydef - share->keydef));
+  if (my_errno == HA_ERR_FOUND_DUPP_KEY)
+    DBUG_PRINT("info",("Duplicate key: %d", keydef - share->keydef));
   info->errkey= keydef - share->keydef;
-  if (keydef->algorithm == HA_KEY_ALG_BTREE)
+  /*
+    We don't need to delete non-inserted key from rb-tree.  Also, if
+    we got ENOMEM, the key wasn't inserted, so don't try to delete it
+    either.  Otherwise for HASH index on HA_ERR_FOUND_DUPP_KEY the key
+    was inserted and we have to delete it.
+  */
+  if (keydef->algorithm == HA_KEY_ALG_BTREE || my_errno == ENOMEM)
   {
-    /* we don't need to delete non-inserted key from rb-tree */
     keydef--;
   }
   while (keydef >= share->keydef)
diff --git a/include/my_global.h b/include/my_global.h
index 41b660227b5704f9329b1eab60244a197be4f6a7..2de54e521b5cac8a03153675d1d89d8c9534adc6 100644
--- a/include/my_global.h
+++ b/include/my_global.h
@@ -84,6 +84,42 @@
 #define NETWARE_SET_SCREEN_MODE(A)
 #endif
 
+/*
+  The macros below are used to allow build of Universal/fat binaries of
+  MySQL and MySQL applications under darwin. 
+*/
+#ifdef TARGET_FAT_BINARY
+# undef SIZEOF_CHARP 
+# undef SIZEOF_INT 
+# undef SIZEOF_LONG 
+# undef SIZEOF_LONG_LONG 
+# undef SIZEOF_OFF_T 
+# undef SIZEOF_SHORT 
+
+#if defined(__i386__)
+# undef WORDS_BIGENDIAN
+# define SIZEOF_CHARP 4
+# define SIZEOF_INT 4
+# define SIZEOF_LONG 4
+# define SIZEOF_LONG_LONG 8
+# define SIZEOF_OFF_T 8
+# define SIZEOF_SHORT 2
+
+#elif defined(__ppc__)
+# define WORDS_BIGENDIAN
+# define SIZEOF_CHARP 4
+# define SIZEOF_INT 4
+# define SIZEOF_LONG 4
+# define SIZEOF_LONG_LONG 8
+# define SIZEOF_OFF_T 8
+# define SIZEOF_SHORT 2
+
+#else
+# error Building FAT binary for an unknown architecture.
+#endif
+#endif /* TARGET_FAT_BINARY */
+
+
 /*
   The macros below are borrowed from include/linux/compiler.h in the
   Linux kernel. Use them to indicate the likelyhood of the truthfulness
diff --git a/innobase/include/hash0hash.h b/innobase/include/hash0hash.h
index 51315e408752dd210c004f909e8bd84112b82da1..13f46760698a2ba3b07500c93486fe6fafc79657 100644
--- a/innobase/include/hash0hash.h
+++ b/innobase/include/hash0hash.h
@@ -18,6 +18,9 @@ typedef struct hash_cell_struct hash_cell_t;
 
 typedef void*	hash_node_t;
 
+/* Fix Bug #13859: symbol collision between imap/mysql */
+#define hash_create hash0_create
+
 /*****************************************************************
 Creates a hash table with >= n array cells. The actual number
 of cells is chosen to be a prime number slightly bigger than n. */
diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result
index fdf21a50a028b1e26d776d91f375fa60d509813c..24f29b23e87d13f18c943a7442ea8e79e346de41 100644
--- a/mysql-test/r/ctype_utf8.result
+++ b/mysql-test/r/ctype_utf8.result
@@ -124,12 +124,34 @@ create table t1 select date_format("2004-01-19 10:10:10", "%Y-%m-%d");
 show create table t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (
-  `date_format("2004-01-19 10:10:10", "%Y-%m-%d")` binary(10) default NULL
+  `date_format("2004-01-19 10:10:10", "%Y-%m-%d")` char(10) character set utf8 default NULL
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
 select * from t1;
 date_format("2004-01-19 10:10:10", "%Y-%m-%d")
 2004-01-19
 drop table t1;
+set names utf8;
+set LC_TIME_NAMES='fr_FR';
+create table t1 (s1 char(20) character set latin1);
+insert into t1 values (date_format('2004-02-02','%M'));
+select hex(s1) from t1;
+hex(s1)
+66E97672696572
+drop table t1;
+create table t1 (s1 char(20) character set koi8r);
+set LC_TIME_NAMES='ru_RU';
+insert into t1 values (date_format('2004-02-02','%M'));
+insert into t1 values (date_format('2004-02-02','%b'));
+insert into t1 values (date_format('2004-02-02','%W'));
+insert into t1 values (date_format('2004-02-02','%a'));
+select hex(s1), s1 from t1;
+hex(s1)	s1
+E6C5D7D2C1CCD1	Февраля
+E6C5D7	Фев
+F0CFCEC5C4C5CCD8CEC9CB	Понедельник
+F0CEC4	Пнд
+drop table t1;
+set LC_TIME_NAMES='en_US';
 set names koi8r;
 create table t1 (s1 char(1) character set utf8);
 insert into t1 values (_koi8r'ÁÂ');
diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result
index 721982e11e3462c512b428eb22744ef3efe4f606..498fee2d03783be25c5fdd37bc3c3fd589abcd16 100644
--- a/mysql-test/r/mysqldump.result
+++ b/mysql-test/r/mysqldump.result
@@ -1584,4 +1584,66 @@ CREATE TABLE `t1` (
 /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
 
 drop table t1;
+CREATE TABLE `t1` (
+`a b` INT,
+`c"d` INT,
+`e``f` INT,
+PRIMARY KEY (`a b`, `c"d`, `e``f`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+insert into t1 values (0815, 4711, 2006);
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,ANSI' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+DROP TABLE IF EXISTS "t1";
+CREATE TABLE "t1" (
+  "a b" int(11) NOT NULL default '0',
+  "c""d" int(11) NOT NULL default '0',
+  "e`f" int(11) NOT NULL default '0',
+  PRIMARY KEY  ("a b","c""d","e`f")
+);
+
+LOCK TABLES "t1" WRITE;
+/*!40000 ALTER TABLE "t1" DISABLE KEYS */;
+INSERT INTO "t1" VALUES (815,4711,2006);
+/*!40000 ALTER TABLE "t1" ENABLE KEYS */;
+UNLOCK TABLES;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8 */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+DROP TABLE IF EXISTS `t1`;
+CREATE TABLE `t1` (
+  `a b` int(11) NOT NULL default '0',
+  `c"d` int(11) NOT NULL default '0',
+  `e``f` int(11) NOT NULL default '0',
+  PRIMARY KEY  (`a b`,`c"d`,`e``f`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+LOCK TABLES `t1` WRITE;
+/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
+INSERT INTO `t1` VALUES (815,4711,2006);
+/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
+UNLOCK TABLES;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+DROP TABLE `t1`;
 End of 4.1 tests
diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result
index 94c51fdc18bce810cbfabdf603d17b499bf5a2ee..0d6b01f3481f3d45a1bbd08c137f44522d5fd9bd 100644
--- a/mysql-test/r/ps.result
+++ b/mysql-test/r/ps.result
@@ -1035,4 +1035,71 @@ EXECUTE stmt USING @a;
 0	0
 DEALLOCATE PREPARE stmt;
 DROP TABLE t1;
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (i INT);
+PREPARE st_19182
+FROM "CREATE TABLE t2 (i INT, j INT, KEY (i), KEY(j)) SELECT i FROM t1";
+EXECUTE st_19182;
+DESC t2;
+Field	Type	Null	Key	Default	Extra
+j	int(11)	YES	MUL	NULL	
+i	int(11)	YES	MUL	NULL	
+DROP TABLE t2;
+EXECUTE st_19182;
+DESC t2;
+Field	Type	Null	Key	Default	Extra
+j	int(11)	YES	MUL	NULL	
+i	int(11)	YES	MUL	NULL	
+DEALLOCATE PREPARE st_19182;
+DROP TABLE t2, t1;
+drop database if exists mysqltest;
+drop table if exists t1, t2;
+create database mysqltest character set utf8;
+prepare stmt1 from "create table mysqltest.t1 (c char(10))";
+prepare stmt2 from "create table mysqltest.t2 select 'test'";
+execute stmt1;
+execute stmt2;
+show create table mysqltest.t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c` char(10) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=utf8
+show create table mysqltest.t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `test` char(4) character set latin1 NOT NULL default ''
+) ENGINE=MyISAM DEFAULT CHARSET=utf8
+drop table mysqltest.t1;
+drop table mysqltest.t2;
+alter database mysqltest character set latin1;
+execute stmt1;
+execute stmt2;
+show create table mysqltest.t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c` char(10) character set utf8 default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+show create table mysqltest.t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `test` char(4) NOT NULL default ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop database mysqltest;
+deallocate prepare stmt1;
+deallocate prepare stmt2;
+execute stmt;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c` char(10) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQLTEST_VARDIR/tmp/'
+drop table t1;
+execute stmt;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c` char(10) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQLTEST_VARDIR/tmp/'
+drop table t1;
+deallocate prepare stmt;
 End of 4.1 tests.
diff --git a/mysql-test/r/rpl_locale.result b/mysql-test/r/rpl_locale.result
new file mode 100644
index 0000000000000000000000000000000000000000..5de5bab9a0b93c21ec97a90307be1c10b96f9a13
--- /dev/null
+++ b/mysql-test/r/rpl_locale.result
@@ -0,0 +1,16 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+create table t1 (s1 char(10));
+set lc_time_names= 'de_DE';
+insert into t1 values (date_format('2001-01-01','%W'));
+select * from t1;
+s1
+Montag
+select * from t1;
+s1
+Montag
+drop table t1;
diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result
index 0aa7ea7f83cd4d628f35cdfeea4d4d55069ac166..14f1eb7d306e7f02d86eda4c235a7a27c92f1a9f 100644
--- a/mysql-test/r/variables.result
+++ b/mysql-test/r/variables.result
@@ -499,6 +499,63 @@ set names latin1;
 select @@have_innodb;
 @@have_innodb
 #
+*** Various tests with LC_TIME_NAMES
+*** LC_TIME_NAMES: testing case insensitivity
+set @@lc_time_names='ru_ru';
+select @@lc_time_names;
+@@lc_time_names
+ru_RU
+*** LC_TIME_NAMES: testing with a user variable
+set @lc='JA_JP';
+set @@lc_time_names=@lc;
+select @@lc_time_names;
+@@lc_time_names
+ja_JP
+*** LC_TIME_NAMES: testing with string expressions
+set lc_time_names=concat('de','_','DE');
+select @@lc_time_names;
+@@lc_time_names
+de_DE
+set lc_time_names=concat('de','+','DE');
+ERROR HY000: Unknown locale: 'de+DE'
+select @@lc_time_names;
+@@lc_time_names
+de_DE
+LC_TIME_NAMES: testing with numeric expressions
+set @@lc_time_names=1+2;
+select @@lc_time_names;
+@@lc_time_names
+sv_SE
+set @@lc_time_names=1/0;
+ERROR 42000: Incorrect argument type to variable 'lc_time_names'
+select @@lc_time_names;
+@@lc_time_names
+sv_SE
+set lc_time_names=en_US;
+LC_TIME_NAMES: testing NULL and a negative number:
+set lc_time_names=NULL;
+ERROR 42000: Variable 'lc_time_names' can't be set to the value of 'NULL'
+set lc_time_names=-1;
+ERROR HY000: Unknown locale: '-1'
+select @@lc_time_names;
+@@lc_time_names
+en_US
+LC_TIME_NAMES: testing locale with the last ID:
+set lc_time_names=108;
+select @@lc_time_names;
+@@lc_time_names
+zh_HK
+LC_TIME_NAMES: testing a number beyond the valid ID range:
+set lc_time_names=109;
+ERROR HY000: Unknown locale: '109'
+select @@lc_time_names;
+@@lc_time_names
+zh_HK
+LC_TIME_NAMES: testing that 0 is en_US:
+set lc_time_names=0;
+select @@lc_time_names;
+@@lc_time_names
+en_US
 set @test = @@query_prealloc_size;
 set @@query_prealloc_size = @test;
 select @@query_prealloc_size = @test;
diff --git a/mysql-test/t/backup.test b/mysql-test/t/backup.test
index b6b3ef1c0603f921dd05a595cbdaa1e34545c5b6..0f1881368a91374e29aa9b5bef80f417256e5c9d 100644
--- a/mysql-test/t/backup.test
+++ b/mysql-test/t/backup.test
@@ -51,5 +51,6 @@ unlock tables;
 connection con1;
 reap;
 drop table t5;
+--system rm $MYSQLTEST_VARDIR/tmp/t?.*
 
 # End of 4.1 tests
diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test
index af40121852f37b4b7a05532b2f38fbe3db6bfcde..0b3f9ed2400d4fdd25239de87d619cb83b8615fa 100644
--- a/mysql-test/t/ctype_utf8.test
+++ b/mysql-test/t/ctype_utf8.test
@@ -93,6 +93,26 @@ show create table t1;
 select * from t1;
 drop table t1;
 
+#
+# Bug#22646 LC_TIME_NAMES: Assignment to non-UTF8 target fails
+#
+set names utf8;
+set LC_TIME_NAMES='fr_FR';
+create table t1 (s1 char(20) character set latin1);
+insert into t1 values (date_format('2004-02-02','%M'));
+select hex(s1) from t1;
+drop table t1;
+create table t1 (s1 char(20) character set koi8r);
+set LC_TIME_NAMES='ru_RU';
+insert into t1 values (date_format('2004-02-02','%M'));
+insert into t1 values (date_format('2004-02-02','%b'));
+insert into t1 values (date_format('2004-02-02','%W'));
+insert into t1 values (date_format('2004-02-02','%a'));
+select hex(s1), s1 from t1;
+drop table t1;
+set LC_TIME_NAMES='en_US';
+
+
 #
 # Bug #2366  	Wrong utf8 behaviour when data is truncated
 #
diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test
index b0df2bb9db2bb800b0bbd4fb5fcb23c4e95096fb..4a077f1ffa36c9a3564054d40a0b19a88e69a4b2 100644
--- a/mysql-test/t/mysqldump.test
+++ b/mysql-test/t/mysqldump.test
@@ -702,4 +702,19 @@ create table t1 (a int);
 --exec $MYSQL_DUMP --skip-comments --force test t1 --where='xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' 2>&1
 drop table t1;
 
+#
+# BUG#13926: --order-by-primary fails if PKEY contains quote character
+#
+CREATE TABLE `t1` (
+  `a b` INT,
+  `c"d` INT,
+  `e``f` INT,
+  PRIMARY KEY (`a b`, `c"d`, `e``f`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+insert into t1 values (0815, 4711, 2006);
+
+--exec $MYSQL_DUMP --skip-comments --compatible=ansi --order-by-primary test t1
+--exec $MYSQL_DUMP --skip-comments --order-by-primary test t1
+DROP TABLE `t1`;
+
 --echo End of 4.1 tests
diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test
index fbeaaa494e09999520b57476d2342dfcfa4e3300..c963e59110f5f5811ff993c2898db493311f6da8 100644
--- a/mysql-test/t/ps.test
+++ b/mysql-test/t/ps.test
@@ -1068,5 +1068,82 @@ EXECUTE stmt USING @a;
 DEALLOCATE PREPARE stmt;
 DROP TABLE t1;
 
+#
+# Bug#19182: CREATE TABLE bar (m INT) SELECT n FROM foo; doesn't work
+# from stored procedure.
+#
+# The cause of a bug was that cached LEX::create_list was modified,
+# and then together with LEX::key_list was reset.
+#
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+CREATE TABLE t1 (i INT);
+
+PREPARE st_19182
+FROM "CREATE TABLE t2 (i INT, j INT, KEY (i), KEY(j)) SELECT i FROM t1";
 
+EXECUTE st_19182;
+DESC t2;
+
+DROP TABLE t2;
+
+# Check that on second execution we don't loose 'j' column and the keys
+# on 'i' and 'j' columns.
+EXECUTE st_19182;
+DESC t2;
+
+DEALLOCATE PREPARE st_19182;
+DROP TABLE t2, t1;
+
+#
+# Bug #22060 "ALTER TABLE x AUTO_INCREMENT=y in SP crashes server"
+#
+# Code which implemented CREATE/ALTER TABLE and CREATE DATABASE
+# statement modified HA_CREATE_INFO structure in LEX, making these
+# statements PS/SP-unsafe (their re-execution might have resulted
+# in incorrect results).
+#
+--disable_warnings
+drop database if exists mysqltest;
+drop table if exists t1, t2;
+--enable_warnings
+# CREATE TABLE and CREATE TABLE ... SELECT
+create database mysqltest character set utf8;
+prepare stmt1 from "create table mysqltest.t1 (c char(10))";
+prepare stmt2 from "create table mysqltest.t2 select 'test'";
+execute stmt1;
+execute stmt2;
+show create table mysqltest.t1;
+show create table mysqltest.t2;
+drop table mysqltest.t1;
+drop table mysqltest.t2;
+alter database mysqltest character set latin1;
+execute stmt1;
+execute stmt2;
+show create table mysqltest.t1;
+show create table mysqltest.t2;
+drop database mysqltest;
+deallocate prepare stmt1;
+deallocate prepare stmt2;
+#
+# CREATE TABLE with DATA DIRECTORY option
+#
+# Protect ourselves from data left in tmp/ by a previos possibly failed
+# test
+--system rm -f $MYSQLTEST_VARDIR/tmp/t1.*
+--disable_query_log
+eval prepare stmt from "create table t1 (c char(10)) data directory='$MYSQLTEST_VARDIR/tmp'";
+--enable_query_log
+execute stmt;
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+show create table t1;
+drop table t1;
+execute stmt;
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+show create table t1;
+drop table t1;
+deallocate prepare stmt;
+#
 --echo End of 4.1 tests.
diff --git a/mysql-test/t/rpl_locale.test b/mysql-test/t/rpl_locale.test
new file mode 100644
index 0000000000000000000000000000000000000000..530a3d77636d30055a3b7afae86c83c88aba13ad
--- /dev/null
+++ b/mysql-test/t/rpl_locale.test
@@ -0,0 +1,22 @@
+# Replication of locale variables
+
+source include/master-slave.inc;
+
+#
+# Bug#22645 LC_TIME_NAMES: Statement not replicated
+#
+connection master;
+create table t1 (s1 char(10));
+set lc_time_names= 'de_DE';
+insert into t1 values (date_format('2001-01-01','%W'));
+select * from t1;
+sync_slave_with_master;
+connection slave;
+select * from t1;
+connection master;
+drop table t1;
+sync_slave_with_master;
+
+# End of 4.1 tests
+
+
diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test
index 8322c0f84bd9c9ae1f7c20c9960c8ee119e62aaf..808dc0973d464f56a97f8edb7f24e076f1c12856 100644
--- a/mysql-test/t/variables.test
+++ b/mysql-test/t/variables.test
@@ -396,6 +396,50 @@ set names latin1;
 --replace_column 1 #
 select @@have_innodb;
 
+#
+# Tests for lc_time_names
+# Note, when adding new locales, please fix ID accordingly:
+# - to test the last ID (currently 108)
+# - and the next after the last (currently 109)
+#
+--echo *** Various tests with LC_TIME_NAMES
+--echo *** LC_TIME_NAMES: testing case insensitivity
+set @@lc_time_names='ru_ru';
+select @@lc_time_names;
+--echo *** LC_TIME_NAMES: testing with a user variable
+set @lc='JA_JP';
+set @@lc_time_names=@lc;
+select @@lc_time_names;
+--echo *** LC_TIME_NAMES: testing with string expressions
+set lc_time_names=concat('de','_','DE');
+select @@lc_time_names;
+--error 1105
+set lc_time_names=concat('de','+','DE');
+select @@lc_time_names;
+--echo LC_TIME_NAMES: testing with numeric expressions
+set @@lc_time_names=1+2;
+select @@lc_time_names;
+--error 1232
+set @@lc_time_names=1/0;
+select @@lc_time_names;
+set lc_time_names=en_US;
+--echo LC_TIME_NAMES: testing NULL and a negative number:
+--error 1231
+set lc_time_names=NULL;
+--error 1105
+set lc_time_names=-1;
+select @@lc_time_names;
+--echo LC_TIME_NAMES: testing locale with the last ID:
+set lc_time_names=108;
+select @@lc_time_names;
+--echo LC_TIME_NAMES: testing a number beyond the valid ID range:
+--error 1105
+set lc_time_names=109;
+select @@lc_time_names;
+--echo LC_TIME_NAMES: testing that 0 is en_US:
+set lc_time_names=0;
+select @@lc_time_names;
+
 #
 # Bug #13334: query_prealloc_size default less than minimum
 #
diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh
index 6359eb009ce2bfc9d26af5fe2bb2db5eff9349f4..917ac0a19c1c2c2a981b179b20ec4d3c8c617356 100644
--- a/scripts/make_binary_distribution.sh
+++ b/scripts/make_binary_distribution.sh
@@ -322,7 +322,7 @@ BASE=$BASE2
 #
 
 if [ x"@GXX@" = x"yes" ] ; then
-  gcclib=`@CC@ --print-libgcc-file`
+  gcclib=`@CC@ @CFLAGS@ --print-libgcc-file`
   if [ $? -ne 0 ] ; then
     echo "Warning: Couldn't find libgcc.a!"
   else
diff --git a/scripts/mysql_secure_installation.sh b/scripts/mysql_secure_installation.sh
index 1c7ca34ad59f2122b282737342ac6880c9736ddf..e42e83233c3d5388608a226f4b3d2049ede72006 100644
--- a/scripts/mysql_secure_installation.sh
+++ b/scripts/mysql_secure_installation.sh
@@ -22,6 +22,16 @@ command=".mysql.$$"
 trap "interrupt" 2
 
 rootpass=""
+echo_n=
+echo_c=
+
+set_echo_compat() {
+    case `echo "testing\c"`,`echo -n testing` in
+	*c*,-n*) echo_n=   echo_c=     ;;
+	*c*,*)   echo_n=-n echo_c=     ;;
+	*)       echo_n=   echo_c='\c' ;;
+    esac
+}
 
 prepare() {
     touch $config $command
@@ -45,7 +55,7 @@ get_root_password() {
     status=1
     while [ $status -eq 1 ]; do
 	stty -echo
-	echo -n "Enter current password for root (enter for none): "
+	echo $echo_n "Enter current password for root (enter for none): $echo_c"
 	read password
 	echo
 	stty echo
@@ -65,10 +75,10 @@ get_root_password() {
 
 set_root_password() {
     stty -echo
-    echo -n "New password: "
+    echo $echo_n "New password: $echo_c"
     read password1
     echo
-    echo -n "Re-enter new password: "
+    echo $echo_n "Re-enter new password: $echo_c"
     read password2
     echo
     stty echo
@@ -173,6 +183,7 @@ cleanup() {
 # The actual script starts here
 
 prepare
+set_echo_compat
 
 echo
 echo
@@ -201,11 +212,11 @@ echo "root user without the proper authorisation."
 echo
 
 if [ $hadpass -eq 0 ]; then
-    echo -n "Set root password? [Y/n] "
+    echo $echo_n "Set root password? [Y/n] $echo_c"
 else
     echo "You already have a root password set, so you can safely answer 'n'."
     echo
-    echo -n "Change the root password? [Y/n] "
+    echo $echo_n "Change the root password? [Y/n] $echo_c"
 fi
 
 read reply
@@ -232,7 +243,7 @@ echo "go a bit smoother.  You should remove them before moving into a"
 echo "production environment."
 echo
 
-echo -n "Remove anonymous users? [Y/n] "
+echo $echo_n "Remove anonymous users? [Y/n] $echo_c"
 
 read reply
 if [ "$reply" = "n" ]; then
@@ -251,7 +262,7 @@ echo "Normally, root should only be allowed to connect from 'localhost'.  This"
 echo "ensures that someone cannot guess at the root password from the network."
 echo
 
-echo -n "Disallow root login remotely? [Y/n] "
+echo $echo_n "Disallow root login remotely? [Y/n] $echo_c"
 read reply
 if [ "$reply" = "n" ]; then
     echo " ... skipping."
@@ -270,7 +281,7 @@ echo "access.  This is also intended only for testing, and should be removed"
 echo "before moving into a production environment."
 echo
 
-echo -n "Remove test database and access to it? [Y/n] "
+echo $echo_n "Remove test database and access to it? [Y/n] $echo_c"
 read reply
 if [ "$reply" = "n" ]; then
     echo " ... skipping."
@@ -288,7 +299,7 @@ echo "Reloading the privilege tables will ensure that all changes made so far"
 echo "will take effect immediately."
 echo
 
-echo -n "Reload privilege tables now? [Y/n] "
+echo $echo_n "Reload privilege tables now? [Y/n] $echo_c"
 read reply
 if [ "$reply" = "n" ]; then
     echo " ... skipping."
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 461998477b5b42ff7fbacc9adb0439b110aad3af..13ff89eceb0fa2afb63d1964c94a333c92c01e25 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -2473,8 +2473,9 @@ bool Item_func_set_user_var::update_hash(void *ptr, uint length,
 	char *pos= (char*) entry+ ALIGN_SIZE(sizeof(user_var_entry));
 	if (entry->value == pos)
 	  entry->value=0;
-	if (!(entry->value=(char*) my_realloc(entry->value, length,
-					      MYF(MY_ALLOW_ZERO_PTR))))
+        entry->value= (char*) my_realloc(entry->value, length,
+                                         MYF(MY_ALLOW_ZERO_PTR | MY_WME));
+        if (!entry->value)
 	  goto err;
       }
     }
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index d6465406c682acbe2082aff05200b58021f10fc2..6c002918479a7b52a7ca96db18a17e1cb4dea228 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -595,16 +595,10 @@ bool make_date_time(DATE_TIME_FORMAT *format, TIME *l_time,
   uint weekday;
   ulong length;
   const char *ptr, *end;
-  MY_LOCALE *locale;
   THD *thd= current_thd;
-  char buf[128];
-  String tmp(buf, sizeof(buf), thd->variables.character_set_results);
-  uint errors= 0;
+  MY_LOCALE *locale= thd->variables.lc_time_names;
 
-  tmp.length(0);
   str->length(0);
-  str->set_charset(&my_charset_bin);
-  locale = thd->variables.lc_time_names;
 
   if (l_time->neg)
     str->append("-", 1);
@@ -618,41 +612,37 @@ bool make_date_time(DATE_TIME_FORMAT *format, TIME *l_time,
     {
       switch (*++ptr) {
       case 'M':
-	if (!l_time->month)
-	  return 1;
-	tmp.copy(locale->month_names->type_names[l_time->month-1],
-		   strlen(locale->month_names->type_names[l_time->month-1]),
-		   system_charset_info, tmp.charset(), &errors);
-	str->append(tmp.ptr(), tmp.length());
-	break;
+        if (!l_time->month)
+          return 1;
+        str->append(locale->month_names->type_names[l_time->month-1],
+                    strlen(locale->month_names->type_names[l_time->month-1]),
+                    system_charset_info);
+        break;
       case 'b':
-	if (!l_time->month)
-	  return 1;
-	tmp.copy(locale->ab_month_names->type_names[l_time->month-1],
-		 strlen(locale->ab_month_names->type_names[l_time->month-1]),
-		 system_charset_info, tmp.charset(), &errors);
-	str->append(tmp.ptr(), tmp.length());
-	break;
+        if (!l_time->month)
+          return 1;
+        str->append(locale->ab_month_names->type_names[l_time->month-1],
+                    strlen(locale->ab_month_names->type_names[l_time->month-1]),
+                    system_charset_info);
+        break;
       case 'W':
-	if (type == MYSQL_TIMESTAMP_TIME)
-	  return 1;
-	weekday= calc_weekday(calc_daynr(l_time->year,l_time->month,
-					 l_time->day),0);
-	tmp.copy(locale->day_names->type_names[weekday],
-		 strlen(locale->day_names->type_names[weekday]),
-		 system_charset_info, tmp.charset(), &errors);
-	str->append(tmp.ptr(), tmp.length());
-	break;
+        if (type == MYSQL_TIMESTAMP_TIME)
+          return 1;
+        weekday= calc_weekday(calc_daynr(l_time->year,l_time->month,
+                              l_time->day),0);
+        str->append(locale->day_names->type_names[weekday],
+                    strlen(locale->day_names->type_names[weekday]),
+                    system_charset_info);
+        break;
       case 'a':
-	if (type == MYSQL_TIMESTAMP_TIME)
-	  return 1;
-	weekday=calc_weekday(calc_daynr(l_time->year,l_time->month,
-					l_time->day),0);
-	tmp.copy(locale->ab_day_names->type_names[weekday],
-		 strlen(locale->ab_day_names->type_names[weekday]),
-		 system_charset_info, tmp.charset(), &errors);
-	str->append(tmp.ptr(), tmp.length());
-	break;
+        if (type == MYSQL_TIMESTAMP_TIME)
+          return 1;
+        weekday=calc_weekday(calc_daynr(l_time->year,l_time->month,
+                             l_time->day),0);
+        str->append(locale->ab_day_names->type_names[weekday],
+                    strlen(locale->ab_day_names->type_names[weekday]),
+                    system_charset_info);
+        break;
       case 'D':
 	if (type == MYSQL_TIMESTAMP_TIME)
 	  return 1;
@@ -1638,8 +1628,9 @@ longlong Item_func_sec_to_time::val_int()
 
 void Item_func_date_format::fix_length_and_dec()
 {
+  THD* thd= current_thd;
   decimals=0;
-  collation.set(&my_charset_bin);
+  collation.set(thd->variables.collation_connection);
   if (args[1]->type() == STRING_ITEM)
   {						// Optimize the normal case
     fixed_length=1;
@@ -1653,17 +1644,14 @@ void Item_func_date_format::fix_length_and_dec()
     args[1]->collation.set(
         get_charset_by_csname(args[1]->collation.collation->csname,
                               MY_CS_BINSORT,MYF(0)), DERIVATION_COERCIBLE);
-    /*
-      The result is a binary string (no reason to use collation->mbmaxlen
-      This is becasue make_date_time() only returns binary strings
-    */
-    max_length= format_length(((Item_string*) args[1])->const_string());
+    max_length= format_length(((Item_string*) args[1])->const_string()) *
+                collation.collation->mbmaxlen;
   }
   else
   {
     fixed_length=0;
-    /* The result is a binary string (no reason to use collation->mbmaxlen */
-    max_length=min(args[1]->max_length,MAX_BLOB_WIDTH) * 10;
+    max_length= min(args[1]->max_length,MAX_BLOB_WIDTH) * 10 * 
+                collation.collation->mbmaxlen;
     set_if_smaller(max_length,MAX_BLOB_WIDTH);
   }
   maybe_null=1;					// If wrong date
@@ -1783,6 +1771,7 @@ String *Item_func_date_format::val_str(String *str)
   date_time_format.format.length= format->length(); 
 
   /* Create the result string */
+  str->set_charset(collation.collation);
   if (!make_date_time(&date_time_format, &l_time,
                       is_time_format ? MYSQL_TIMESTAMP_TIME :
                                        MYSQL_TIMESTAMP_DATE,
diff --git a/sql/log.cc b/sql/log.cc
index 7e97bfd071299c887bbf76f8f6f796773d30a896..b91ec2b3dee4952db39b46f51f7fdc1a5c919ac2 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -1350,6 +1350,21 @@ COLLATION_CONNECTION=%u,COLLATION_DATABASE=%u,COLLATION_SERVER=%u",
         if (e.write(file))
           goto err;
       }
+      /*
+        Use the same ONE_SHOT trick for making replication of lc_time_names.
+      */
+      if (thd->variables.lc_time_names->number) // Not en_US
+      {
+        char buf[32];
+        uint length= my_snprintf(buf, sizeof(buf),
+                                 "SET ONE_SHOT LC_TIME_NAMES=%u", 
+                                 (uint) thd->variables.lc_time_names->number);
+        Query_log_event e(thd, buf, length, 0, FALSE);
+        e.set_log_pos(this);
+	e.error_code= 0;	// This statement cannot fail (see [1]).
+        if (e.write(file))
+          goto err;
+      }
 #endif
 
       if (thd->last_insert_id_used)
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index a12944437d7954bf43f21f3724bcec163f446bd3..3a240612cfaf8475ab0936448c0f778de17a6d69 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -71,6 +71,7 @@ extern CHARSET_INFO *national_charset_info, *table_alias_charset;
 
 typedef struct my_locale_st
 {
+  uint  number;
   const char *name;
   const char *description;
   const bool is_ascii;
@@ -84,6 +85,7 @@ extern MY_LOCALE my_locale_en_US;
 extern MY_LOCALE *my_locales[];
 
 MY_LOCALE *my_locale_by_name(const char *name);
+MY_LOCALE *my_locale_by_number(uint number);
 
 /***************************************************************************
   Configuration parameters
@@ -563,25 +565,22 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
 		       uint &key_count, int select_field_count);
 int mysql_create_table(THD *thd,const char *db, const char *table_name,
 		       HA_CREATE_INFO *create_info,
-		       List<create_field> &fields, List<Key> &keys,
+                       Alter_info *alter_info,
 		       bool tmp_table, uint select_field_count);
 
 TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
 			       const char *db, const char *name,
-			       List<create_field> *extra_fields,
-			       List<Key> *keys,
+                               Alter_info *alter_info,
 			       List<Item> *items,
 			       MYSQL_LOCK **lock);
 int mysql_alter_table(THD *thd, char *new_db, char *new_name,
 		      HA_CREATE_INFO *create_info,
 		      TABLE_LIST *table_list,
-		      List<create_field> &fields,
-		      List<Key> &keys,
+                      Alter_info *alter_info,
 		      uint order_num, ORDER *order,
 		      enum enum_duplicates handle_duplicates,
-                      bool ignore,
-		      ALTER_INFO *alter_info, bool do_send_ok=1);
-int mysql_recreate_table(THD *thd, TABLE_LIST *table_list, bool do_send_ok);
+                      bool ignore);
+int mysql_recreate_table(THD *thd, TABLE_LIST *table_list);
 int mysql_create_like_table(THD *thd, TABLE_LIST *table,
                             HA_CREATE_INFO *create_info,
                             Table_ident *src_table);
@@ -590,9 +589,6 @@ bool mysql_rename_table(enum db_type base,
 			const char * old_name,
 			const char *new_db,
 			const char * new_name);
-int mysql_create_index(THD *thd, TABLE_LIST *table_list, List<Key> &keys);
-int mysql_drop_index(THD *thd, TABLE_LIST *table_list,
-		     ALTER_INFO *alter_info);
 int mysql_prepare_update(THD *thd, TABLE_LIST *table_list,
 			 TABLE_LIST *update_table_list,
 			 Item **conds, uint order_num, ORDER *order);
@@ -679,7 +675,8 @@ int get_quote_char_for_identifier(THD *thd, const char *name, uint length);
 void mysqld_list_fields(THD *thd,TABLE_LIST *table, const char *wild);
 int mysqld_dump_create_info(THD *thd, TABLE *table, int fd = -1);
 int mysqld_show_create(THD *thd, TABLE_LIST *table_list);
-int mysqld_show_create_db(THD *thd, char *dbname, HA_CREATE_INFO *create);
+int mysqld_show_create_db(THD *thd, char *dbname,
+                          const HA_CREATE_INFO *create);
 
 void mysqld_list_processes(THD *thd,const char *user,bool verbose);
 int mysqld_show_status(THD *thd);
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 71ca382f9d95085cffb525e98dbf863cf080b21c..30724c78a62ce15160ae74ee639e42a3c6d34ba3 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -2570,19 +2570,38 @@ void sys_var_thd_time_zone::set_default(THD *thd, enum_var_type type)
 
 bool sys_var_thd_lc_time_names::check(THD *thd, set_var *var)
 {
-  char *locale_str =var->value->str_value.c_ptr();
-  MY_LOCALE *locale_match=  my_locale_by_name(locale_str);
+  MY_LOCALE *locale_match;
 
-  if(locale_match == NULL) 
+  if (var->value->result_type() == INT_RESULT)
   {
-    my_printf_error(ER_UNKNOWN_ERROR, "Unknown locale: '%s'", MYF(0), locale_str);
-    return 1;
+    if (!(locale_match= my_locale_by_number((uint) var->value->val_int())))
+    {
+      char buf[20];
+      int10_to_str((int) var->value->val_int(), buf, -10);
+      my_printf_error(ER_UNKNOWN_ERROR, "Unknown locale: '%s'", MYF(0), buf);
+      return 1;
+    }
   }
-  else 
+  else // STRING_RESULT
   {
-    var->save_result.locale_value= locale_match;
-    return 0;
+    char buff[6]; 
+    String str(buff, sizeof(buff), &my_charset_latin1), *res;
+    if (!(res=var->value->val_str(&str)))
+    {
+      my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, "NULL");
+      return 1;
+    }
+    const char *locale_str= res->c_ptr();
+    if (!(locale_match= my_locale_by_name(locale_str)))
+    {
+      my_printf_error(ER_UNKNOWN_ERROR,
+                      "Unknown locale: '%s'", MYF(0), locale_str);
+      return 1;
+    }
   }
+
+  var->save_result.locale_value= locale_match;
+  return 0;
 }
 
 
diff --git a/sql/set_var.h b/sql/set_var.h
index 1ae3a18111f5546e11ae6d08e91acd6b5eca2168..78b34963e9d61916f45e1ecdfb3b846a51a86bed 100644
--- a/sql/set_var.h
+++ b/sql/set_var.h
@@ -764,12 +764,16 @@ class sys_var_thd_lc_time_names :public sys_var_thd
 public:
   sys_var_thd_lc_time_names(const char *name_arg):
     sys_var_thd(name_arg) 
-  {}
+  {
+#if MYSQL_VERSION_ID < 50000
+    no_support_one_shot= 0;
+#endif
+  }
   bool check(THD *thd, set_var *var);
   SHOW_TYPE type() { return SHOW_CHAR; }
   bool check_update_type(Item_result type)
   {
-    return type != STRING_RESULT;		/* Only accept strings */
+    return ((type != STRING_RESULT) && (type != INT_RESULT));
   }
   bool check_default(enum_var_type type) { return 0; }
   bool update(THD *thd, set_var *var);
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 05105bfc86a57f014b5414d7e81220755149d1a7..db6f65cab55dfc7d155cefbf829a29943f975220 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -1293,20 +1293,21 @@ class select_create: public select_insert {
   ORDER *group;
   const char *db;
   const char *name;
-  List<create_field> *extra_fields;
-  List<Key> *keys;
   HA_CREATE_INFO *create_info;
+  Alter_info *alter_info;
   MYSQL_LOCK *lock;
   Field **field;
 public:
   select_create(const char *db_name, const char *table_name,
-		HA_CREATE_INFO *create_info_par,
-		List<create_field> &fields_par,
-		List<Key> &keys_par,
-		List<Item> &select_fields,enum_duplicates duplic, bool ignore)
-    :select_insert (NULL, &select_fields, duplic, ignore), db(db_name),
-    name(table_name), extra_fields(&fields_par),keys(&keys_par),
-    create_info(create_info_par), lock(0)
+                HA_CREATE_INFO *create_info_arg,
+                Alter_info *alter_info_arg,
+                List<Item> &select_fields,
+                enum_duplicates duplic, bool ignore)
+    :select_insert(NULL, &select_fields, duplic, ignore),
+    db(db_name), name(table_name),
+    create_info(create_info_arg),
+    alter_info(alter_info_arg),
+    lock(0)
     {}
   int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
   void store_values(List<Item> &values);
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index d6c746d5d5db5f4a654cdcee0876ed955d1056d6..f5bbba742a5b68c96f4fd6157716698749aaf006 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -1805,7 +1805,7 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
 
   unit= u;
   table= create_table_from_items(thd, create_info, db, name,
-				 extra_fields, keys, &values, &lock);
+                                 alter_info, &values, &lock);
   if (!table)
     DBUG_RETURN(-1);				// abort() deletes table
 
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index dfe406c351e9b06362de2c6a89a90510e52d325b..270fdb3f20a3f556e9866fad3edd4a45c9ee5e07 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -1015,6 +1015,18 @@ int yylex(void *arg, void *yythd)
   }
 }
 
+
+Alter_info::Alter_info(const Alter_info &rhs, MEM_ROOT *mem_root)
+  :drop_list(rhs.drop_list, mem_root),
+  alter_list(rhs.alter_list, mem_root),
+  key_list(rhs.key_list, mem_root),
+  create_list(rhs.create_list, mem_root),
+  flags(rhs.flags),
+  keys_onoff(rhs.keys_onoff),
+  tablespace_op(rhs.tablespace_op),
+  is_simple(rhs.is_simple)
+{}
+
 /*
   st_select_lex structures initialisations
 */
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 12f89202e2d5d236c87e0ab2ff7f0d7cb844d56b..7faeb8046c7d4ac51bcabbcdc9079138b06cea1e 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -571,19 +571,61 @@ typedef class st_select_lex SELECT_LEX;
 #define ALTER_ORDER		64
 #define ALTER_OPTIONS		128
 
-typedef struct st_alter_info
+/**
+  @brief Parsing data for CREATE or ALTER TABLE.
+
+  This structure contains a list of columns or indexes to be created,
+  altered or dropped.
+*/
+
+class Alter_info
 {
+public:
   List<Alter_drop>            drop_list;
   List<Alter_column>          alter_list;
+  List<Key>	              key_list;
+  List<create_field>          create_list;
   uint                        flags;
   enum enum_enable_or_disable keys_onoff;
   enum tablespace_op_type     tablespace_op;
   bool                        is_simple;
 
-  st_alter_info(){clear();}
-  void clear(){keys_onoff= LEAVE_AS_IS;tablespace_op= NO_TABLESPACE_OP;}
-  void reset(){drop_list.empty();alter_list.empty();clear();}
-} ALTER_INFO;
+  Alter_info() :
+    flags(0),
+    keys_onoff(LEAVE_AS_IS),
+    tablespace_op(NO_TABLESPACE_OP),
+    is_simple(1)
+  {}
+  void reset()
+  {
+    drop_list.empty();
+    alter_list.empty();
+    key_list.empty();
+    create_list.empty();
+    flags= 0;
+    keys_onoff= LEAVE_AS_IS;
+    tablespace_op= NO_TABLESPACE_OP;
+    is_simple= 1;
+  }
+  /**
+    Construct a copy of this object to be used for mysql_alter_table
+    and mysql_create_table. Historically, these two functions modify
+    their Alter_info arguments. This behaviour breaks re-execution of
+    prepared statements and stored procedures and is compensated by
+    always supplying a copy of Alter_info to these functions.
+    The constructed copy still shares key Key, Alter_drop, create_field
+    and Alter_column elements of the lists - these structures are not
+    modified and thus are not copied.
+
+    @note You need to use check thd->is_fatal_error for out
+    of memory condition after calling this function.
+  */
+  Alter_info(const Alter_info &rhs, MEM_ROOT *mem_root);
+private:
+  Alter_info &operator=(const Alter_info &rhs); // not implemented
+  Alter_info(const Alter_info &rhs);            // not implemented
+};
+
 
 /* The state of the lex parsing. This is saved in the THD struct */
 
@@ -620,8 +662,6 @@ typedef struct st_lex
   List<String>	      interval_list;
   List<LEX_USER>      users_list;
   List<LEX_COLUMN>    columns;
-  List<Key>	      key_list;
-  List<create_field>  create_list;
   List<Item>	      *insert_list,field_list,value_list,update_list;
   List<List_item>     many_values;
   List<set_var_base>  var_list;
@@ -654,7 +694,7 @@ typedef struct st_lex
   bool derived_tables;
   bool safe_to_cache_query;
   bool subqueries, ignore;
-  ALTER_INFO alter_info;
+  Alter_info alter_info;
   /* Prepared statements SQL syntax:*/
   LEX_STRING prepared_stmt_name; /* Statement name (in all queries) */
   /* 
diff --git a/sql/sql_list.h b/sql/sql_list.h
index e799ecf3d6eeb5024f505c4a5ee9047aefb22154..47379ab1ddfc32eee91dfe5613adf4d0ed8df025 100644
--- a/sql/sql_list.h
+++ b/sql/sql_list.h
@@ -66,21 +66,24 @@ class Sql_alloc
   pointer.
 */
 
-class list_node :public Sql_alloc
+
+/**
+  list_node - a node of a single-linked list.
+  @note We never call a destructor for instances of this class.
+*/
+
+struct list_node :public Sql_alloc
 {
-public:
   list_node *next;
   void *info;
   list_node(void *info_par,list_node *next_par)
     :next(next_par),info(info_par)
-    {}
+  {}
   list_node()					/* For end_of_list */
-    {
-      info=0;
-      next= this;
-    }
-  friend class base_list;
-  friend class base_list_iterator;
+  {
+    info= 0;
+    next= this;
+  }
 };
 
 
@@ -96,11 +99,56 @@ class base_list :public Sql_alloc
 
   inline void empty() { elements=0; first= &end_of_list; last=&first;}
   inline base_list() { empty(); }
+  /**
+    This is a shallow copy constructor that implicitly passes the ownership
+    from the source list to the new instance. The old instance is not
+    updated, so both objects end up sharing the same nodes. If one of
+    the instances then adds or removes a node, the other becomes out of
+    sync ('last' pointer), while still operational. Some old code uses and
+    relies on this behaviour. This logic is quite tricky: please do not use
+    it in any new code.
+  */
   inline base_list(const base_list &tmp) :Sql_alloc()
   {
-    elements=tmp.elements;
-    first=tmp.first;
-    last=tmp.last;
+    elements= tmp.elements;
+    first= tmp.first;
+    last= elements ? tmp.last : &first;
+  }
+  /**
+    Construct a deep copy of the argument in memory root mem_root.
+    The elements themselves are copied by pointer.
+  */
+  inline base_list(const base_list &rhs, MEM_ROOT *mem_root)
+  {
+    if (rhs.elements)
+    {
+      /*
+        It's okay to allocate an array of nodes at once: we never
+        call a destructor for list_node objects anyway.
+      */
+      first= (list_node*) alloc_root(mem_root,
+                                     sizeof(list_node) * rhs.elements);
+      if (first)
+      {
+        elements= rhs.elements;
+        list_node *dst= first;
+        list_node *src= rhs.first;
+        for (; dst < first + elements - 1; dst++, src= src->next)
+        {
+          dst->info= src->info;
+          dst->next= dst + 1;
+        }
+        /* Copy the last node */
+        dst->info= src->info;
+        dst->next= &end_of_list;
+        /* Setup 'last' member */
+        last= &dst->next;
+        return;
+      }
+    }
+    elements= 0;
+    first= &end_of_list;
+    last= &first;
   }
   inline base_list(bool error) { }
   inline bool push_back(void *info)
@@ -327,6 +375,8 @@ template <class T> class List :public base_list
 public:
   inline List() :base_list() {}
   inline List(const List<T> &tmp) :base_list(tmp) {}
+  inline List(const List<T> &tmp, MEM_ROOT *mem_root) :
+    base_list(tmp, mem_root) {}
   inline bool push_back(T *a) { return base_list::push_back(a); }
   inline bool push_front(T *a) { return base_list::push_front(a); }
   inline T* head() {return (T*) base_list::head(); }
diff --git a/sql/sql_locale.cc b/sql/sql_locale.cc
index 9dae55e450865cfc65e009fe61e407f0ba014ad1..1f60c61ed46f9f9e9f091dc066c599e4dd1b7bd1 100644
--- a/sql/sql_locale.cc
+++ b/sql/sql_locale.cc
@@ -24,17 +24,6 @@
 #include "mysql_priv.h"
 
 
-MY_LOCALE *my_locale_by_name(const char *name)
-{
-  MY_LOCALE **locale;
-  for( locale= my_locales; *locale != NULL; locale++) 
-  {
-    if(!strcmp((*locale)->name, name))
-      return *locale;
-  }
-  return NULL;
-}
-
 /***** LOCALE BEGIN ar_AE: Arabic - United Arab Emirates *****/
 static const char *my_locale_month_names_ar_AE[13] = 
  {"يناير","فبراير","مارس","أبريل","مايو","يونيو","يوليو","أغسطس","سبتمبر","أكتوبر","نوفمبر","ديسمبر", NullS };
@@ -53,7 +42,16 @@ static TYPELIB my_locale_typelib_day_names_ar_AE =
 static TYPELIB my_locale_typelib_ab_day_names_ar_AE = 
  { array_elements(my_locale_ab_day_names_ar_AE)-1, "", my_locale_ab_day_names_ar_AE, NULL };
 MY_LOCALE my_locale_ar_AE=
- { "ar_AE", "Arabic - United Arab Emirates", FALSE, &my_locale_typelib_month_names_ar_AE, &my_locale_typelib_ab_month_names_ar_AE, &my_locale_typelib_day_names_ar_AE, &my_locale_typelib_ab_day_names_ar_AE };
+{
+  6,
+  "ar_AE",
+  "Arabic - United Arab Emirates",
+  FALSE,
+  &my_locale_typelib_month_names_ar_AE,
+  &my_locale_typelib_ab_month_names_ar_AE,
+  &my_locale_typelib_day_names_ar_AE,
+  &my_locale_typelib_ab_day_names_ar_AE
+};
 /***** LOCALE END ar_AE *****/
 
 /***** LOCALE BEGIN ar_BH: Arabic - Bahrain *****/
@@ -74,7 +72,16 @@ static TYPELIB my_locale_typelib_day_names_ar_BH =
 static TYPELIB my_locale_typelib_ab_day_names_ar_BH = 
  { array_elements(my_locale_ab_day_names_ar_BH)-1, "", my_locale_ab_day_names_ar_BH, NULL };
 MY_LOCALE my_locale_ar_BH=
- { "ar_BH", "Arabic - Bahrain", FALSE, &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, &my_locale_typelib_ab_day_names_ar_BH };
+{
+  7,
+  "ar_BH",
+  "Arabic - Bahrain",
+  FALSE,
+  &my_locale_typelib_month_names_ar_BH,
+  &my_locale_typelib_ab_month_names_ar_BH,
+  &my_locale_typelib_day_names_ar_BH,
+  &my_locale_typelib_ab_day_names_ar_BH
+};
 /***** LOCALE END ar_BH *****/
 
 /***** LOCALE BEGIN ar_JO: Arabic - Jordan *****/
@@ -95,7 +102,16 @@ static TYPELIB my_locale_typelib_day_names_ar_JO =
 static TYPELIB my_locale_typelib_ab_day_names_ar_JO = 
  { array_elements(my_locale_ab_day_names_ar_JO)-1, "", my_locale_ab_day_names_ar_JO, NULL };
 MY_LOCALE my_locale_ar_JO=
- { "ar_JO", "Arabic - Jordan", FALSE, &my_locale_typelib_month_names_ar_JO, &my_locale_typelib_ab_month_names_ar_JO, &my_locale_typelib_day_names_ar_JO, &my_locale_typelib_ab_day_names_ar_JO };
+{
+  8,
+  "ar_JO",
+  "Arabic - Jordan",
+  FALSE,
+  &my_locale_typelib_month_names_ar_JO,
+  &my_locale_typelib_ab_month_names_ar_JO,
+  &my_locale_typelib_day_names_ar_JO,
+  &my_locale_typelib_ab_day_names_ar_JO
+};
 /***** LOCALE END ar_JO *****/
 
 /***** LOCALE BEGIN ar_SA: Arabic - Saudi Arabia *****/
@@ -116,7 +132,16 @@ static TYPELIB my_locale_typelib_day_names_ar_SA =
 static TYPELIB my_locale_typelib_ab_day_names_ar_SA = 
  { array_elements(my_locale_ab_day_names_ar_SA)-1, "", my_locale_ab_day_names_ar_SA, NULL };
 MY_LOCALE my_locale_ar_SA=
- { "ar_SA", "Arabic - Saudi Arabia", FALSE, &my_locale_typelib_month_names_ar_SA, &my_locale_typelib_ab_month_names_ar_SA, &my_locale_typelib_day_names_ar_SA, &my_locale_typelib_ab_day_names_ar_SA };
+{
+  9,
+  "ar_SA",
+  "Arabic - Saudi Arabia",
+  FALSE,
+  &my_locale_typelib_month_names_ar_SA,
+  &my_locale_typelib_ab_month_names_ar_SA,
+  &my_locale_typelib_day_names_ar_SA,
+  &my_locale_typelib_ab_day_names_ar_SA
+};
 /***** LOCALE END ar_SA *****/
 
 /***** LOCALE BEGIN ar_SY: Arabic - Syria *****/
@@ -137,7 +162,16 @@ static TYPELIB my_locale_typelib_day_names_ar_SY =
 static TYPELIB my_locale_typelib_ab_day_names_ar_SY = 
  { array_elements(my_locale_ab_day_names_ar_SY)-1, "", my_locale_ab_day_names_ar_SY, NULL };
 MY_LOCALE my_locale_ar_SY=
- { "ar_SY", "Arabic - Syria", FALSE, &my_locale_typelib_month_names_ar_SY, &my_locale_typelib_ab_month_names_ar_SY, &my_locale_typelib_day_names_ar_SY, &my_locale_typelib_ab_day_names_ar_SY };
+{
+  10,
+  "ar_SY",
+  "Arabic - Syria",
+  FALSE,
+  &my_locale_typelib_month_names_ar_SY,
+  &my_locale_typelib_ab_month_names_ar_SY,
+  &my_locale_typelib_day_names_ar_SY,
+  &my_locale_typelib_ab_day_names_ar_SY
+};
 /***** LOCALE END ar_SY *****/
 
 /***** LOCALE BEGIN be_BY: Belarusian - Belarus *****/
@@ -158,7 +192,16 @@ static TYPELIB my_locale_typelib_day_names_be_BY =
 static TYPELIB my_locale_typelib_ab_day_names_be_BY = 
  { array_elements(my_locale_ab_day_names_be_BY)-1, "", my_locale_ab_day_names_be_BY, NULL };
 MY_LOCALE my_locale_be_BY=
- { "be_BY", "Belarusian - Belarus", FALSE, &my_locale_typelib_month_names_be_BY, &my_locale_typelib_ab_month_names_be_BY, &my_locale_typelib_day_names_be_BY, &my_locale_typelib_ab_day_names_be_BY };
+{
+  11,
+  "be_BY",
+  "Belarusian - Belarus",
+  FALSE,
+  &my_locale_typelib_month_names_be_BY,
+  &my_locale_typelib_ab_month_names_be_BY,
+  &my_locale_typelib_day_names_be_BY,
+  &my_locale_typelib_ab_day_names_be_BY
+};
 /***** LOCALE END be_BY *****/
 
 /***** LOCALE BEGIN bg_BG: Bulgarian - Bulgaria *****/
@@ -179,7 +222,16 @@ static TYPELIB my_locale_typelib_day_names_bg_BG =
 static TYPELIB my_locale_typelib_ab_day_names_bg_BG = 
  { array_elements(my_locale_ab_day_names_bg_BG)-1, "", my_locale_ab_day_names_bg_BG, NULL };
 MY_LOCALE my_locale_bg_BG=
- { "bg_BG", "Bulgarian - Bulgaria", FALSE, &my_locale_typelib_month_names_bg_BG, &my_locale_typelib_ab_month_names_bg_BG, &my_locale_typelib_day_names_bg_BG, &my_locale_typelib_ab_day_names_bg_BG };
+{
+  12,
+  "bg_BG",
+  "Bulgarian - Bulgaria",
+  FALSE,
+  &my_locale_typelib_month_names_bg_BG,
+  &my_locale_typelib_ab_month_names_bg_BG,
+  &my_locale_typelib_day_names_bg_BG,
+  &my_locale_typelib_ab_day_names_bg_BG
+};
 /***** LOCALE END bg_BG *****/
 
 /***** LOCALE BEGIN ca_ES: Catalan - Catalan *****/
@@ -200,7 +252,16 @@ static TYPELIB my_locale_typelib_day_names_ca_ES =
 static TYPELIB my_locale_typelib_ab_day_names_ca_ES = 
  { array_elements(my_locale_ab_day_names_ca_ES)-1, "", my_locale_ab_day_names_ca_ES, NULL };
 MY_LOCALE my_locale_ca_ES=
- { "ca_ES", "Catalan - Catalan", FALSE, &my_locale_typelib_month_names_ca_ES, &my_locale_typelib_ab_month_names_ca_ES, &my_locale_typelib_day_names_ca_ES, &my_locale_typelib_ab_day_names_ca_ES };
+{
+  13,
+  "ca_ES",
+  "Catalan - Catalan",
+  FALSE,
+  &my_locale_typelib_month_names_ca_ES,
+  &my_locale_typelib_ab_month_names_ca_ES,
+  &my_locale_typelib_day_names_ca_ES,
+  &my_locale_typelib_ab_day_names_ca_ES
+};
 /***** LOCALE END ca_ES *****/
 
 /***** LOCALE BEGIN cs_CZ: Czech - Czech Republic *****/
@@ -221,7 +282,16 @@ static TYPELIB my_locale_typelib_day_names_cs_CZ =
 static TYPELIB my_locale_typelib_ab_day_names_cs_CZ = 
  { array_elements(my_locale_ab_day_names_cs_CZ)-1, "", my_locale_ab_day_names_cs_CZ, NULL };
 MY_LOCALE my_locale_cs_CZ=
- { "cs_CZ", "Czech - Czech Republic", FALSE, &my_locale_typelib_month_names_cs_CZ, &my_locale_typelib_ab_month_names_cs_CZ, &my_locale_typelib_day_names_cs_CZ, &my_locale_typelib_ab_day_names_cs_CZ };
+{
+  14,
+  "cs_CZ",
+  "Czech - Czech Republic",
+  FALSE,
+  &my_locale_typelib_month_names_cs_CZ,
+  &my_locale_typelib_ab_month_names_cs_CZ,
+  &my_locale_typelib_day_names_cs_CZ,
+  &my_locale_typelib_ab_day_names_cs_CZ
+};
 /***** LOCALE END cs_CZ *****/
 
 /***** LOCALE BEGIN da_DK: Danish - Denmark *****/
@@ -242,7 +312,16 @@ static TYPELIB my_locale_typelib_day_names_da_DK =
 static TYPELIB my_locale_typelib_ab_day_names_da_DK = 
  { array_elements(my_locale_ab_day_names_da_DK)-1, "", my_locale_ab_day_names_da_DK, NULL };
 MY_LOCALE my_locale_da_DK=
- { "da_DK", "Danish - Denmark", FALSE, &my_locale_typelib_month_names_da_DK, &my_locale_typelib_ab_month_names_da_DK, &my_locale_typelib_day_names_da_DK, &my_locale_typelib_ab_day_names_da_DK };
+{
+  15,
+  "da_DK",
+  "Danish - Denmark",
+  FALSE,
+  &my_locale_typelib_month_names_da_DK,
+  &my_locale_typelib_ab_month_names_da_DK,
+  &my_locale_typelib_day_names_da_DK,
+  &my_locale_typelib_ab_day_names_da_DK
+};
 /***** LOCALE END da_DK *****/
 
 /***** LOCALE BEGIN de_AT: German - Austria *****/
@@ -263,7 +342,16 @@ static TYPELIB my_locale_typelib_day_names_de_AT =
 static TYPELIB my_locale_typelib_ab_day_names_de_AT = 
  { array_elements(my_locale_ab_day_names_de_AT)-1, "", my_locale_ab_day_names_de_AT, NULL };
 MY_LOCALE my_locale_de_AT=
- { "de_AT", "German - Austria", FALSE, &my_locale_typelib_month_names_de_AT, &my_locale_typelib_ab_month_names_de_AT, &my_locale_typelib_day_names_de_AT, &my_locale_typelib_ab_day_names_de_AT };
+{
+  16,
+  "de_AT",
+  "German - Austria",
+  FALSE,
+  &my_locale_typelib_month_names_de_AT,
+  &my_locale_typelib_ab_month_names_de_AT,
+  &my_locale_typelib_day_names_de_AT,
+  &my_locale_typelib_ab_day_names_de_AT
+};
 /***** LOCALE END de_AT *****/
 
 /***** LOCALE BEGIN de_DE: German - Germany *****/
@@ -284,7 +372,16 @@ static TYPELIB my_locale_typelib_day_names_de_DE =
 static TYPELIB my_locale_typelib_ab_day_names_de_DE = 
  { array_elements(my_locale_ab_day_names_de_DE)-1, "", my_locale_ab_day_names_de_DE, NULL };
 MY_LOCALE my_locale_de_DE=
- { "de_DE", "German - Germany", FALSE, &my_locale_typelib_month_names_de_DE, &my_locale_typelib_ab_month_names_de_DE, &my_locale_typelib_day_names_de_DE, &my_locale_typelib_ab_day_names_de_DE };
+{
+  4,
+  "de_DE",
+  "German - Germany",
+  FALSE,
+  &my_locale_typelib_month_names_de_DE,
+  &my_locale_typelib_ab_month_names_de_DE,
+  &my_locale_typelib_day_names_de_DE,
+  &my_locale_typelib_ab_day_names_de_DE
+};
 /***** LOCALE END de_DE *****/
 
 /***** LOCALE BEGIN en_US: English - United States *****/
@@ -305,7 +402,16 @@ static TYPELIB my_locale_typelib_day_names_en_US =
 static TYPELIB my_locale_typelib_ab_day_names_en_US = 
  { array_elements(my_locale_ab_day_names_en_US)-1, "", my_locale_ab_day_names_en_US, NULL };
 MY_LOCALE my_locale_en_US=
- { "en_US", "English - United States", TRUE, &my_locale_typelib_month_names_en_US, &my_locale_typelib_ab_month_names_en_US, &my_locale_typelib_day_names_en_US, &my_locale_typelib_ab_day_names_en_US };
+{
+  0,
+  "en_US",
+  "English - United States",
+  TRUE,
+  &my_locale_typelib_month_names_en_US,
+  &my_locale_typelib_ab_month_names_en_US,
+  &my_locale_typelib_day_names_en_US,
+  &my_locale_typelib_ab_day_names_en_US
+};
 /***** LOCALE END en_US *****/
 
 /***** LOCALE BEGIN es_ES: Spanish - Spain *****/
@@ -326,7 +432,16 @@ static TYPELIB my_locale_typelib_day_names_es_ES =
 static TYPELIB my_locale_typelib_ab_day_names_es_ES = 
  { array_elements(my_locale_ab_day_names_es_ES)-1, "", my_locale_ab_day_names_es_ES, NULL };
 MY_LOCALE my_locale_es_ES=
- { "es_ES", "Spanish - Spain", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES };
+{
+  17,
+  "es_ES",
+  "Spanish - Spain",
+  FALSE,
+  &my_locale_typelib_month_names_es_ES,
+  &my_locale_typelib_ab_month_names_es_ES,
+  &my_locale_typelib_day_names_es_ES,
+  &my_locale_typelib_ab_day_names_es_ES
+};
 /***** LOCALE END es_ES *****/
 
 /***** LOCALE BEGIN et_EE: Estonian - Estonia *****/
@@ -347,7 +462,16 @@ static TYPELIB my_locale_typelib_day_names_et_EE =
 static TYPELIB my_locale_typelib_ab_day_names_et_EE = 
  { array_elements(my_locale_ab_day_names_et_EE)-1, "", my_locale_ab_day_names_et_EE, NULL };
 MY_LOCALE my_locale_et_EE=
- { "et_EE", "Estonian - Estonia", FALSE, &my_locale_typelib_month_names_et_EE, &my_locale_typelib_ab_month_names_et_EE, &my_locale_typelib_day_names_et_EE, &my_locale_typelib_ab_day_names_et_EE };
+{
+  18,
+  "et_EE",
+  "Estonian - Estonia",
+  FALSE,
+  &my_locale_typelib_month_names_et_EE,
+  &my_locale_typelib_ab_month_names_et_EE,
+  &my_locale_typelib_day_names_et_EE,
+  &my_locale_typelib_ab_day_names_et_EE
+};
 /***** LOCALE END et_EE *****/
 
 /***** LOCALE BEGIN eu_ES: Basque - Basque *****/
@@ -368,7 +492,16 @@ static TYPELIB my_locale_typelib_day_names_eu_ES =
 static TYPELIB my_locale_typelib_ab_day_names_eu_ES = 
  { array_elements(my_locale_ab_day_names_eu_ES)-1, "", my_locale_ab_day_names_eu_ES, NULL };
 MY_LOCALE my_locale_eu_ES=
- { "eu_ES", "Basque - Basque", TRUE, &my_locale_typelib_month_names_eu_ES, &my_locale_typelib_ab_month_names_eu_ES, &my_locale_typelib_day_names_eu_ES, &my_locale_typelib_ab_day_names_eu_ES };
+{
+  19,
+  "eu_ES",
+  "Basque - Basque",
+  TRUE,
+  &my_locale_typelib_month_names_eu_ES,
+  &my_locale_typelib_ab_month_names_eu_ES,
+  &my_locale_typelib_day_names_eu_ES,
+  &my_locale_typelib_ab_day_names_eu_ES
+};
 /***** LOCALE END eu_ES *****/
 
 /***** LOCALE BEGIN fi_FI: Finnish - Finland *****/
@@ -389,7 +522,16 @@ static TYPELIB my_locale_typelib_day_names_fi_FI =
 static TYPELIB my_locale_typelib_ab_day_names_fi_FI = 
  { array_elements(my_locale_ab_day_names_fi_FI)-1, "", my_locale_ab_day_names_fi_FI, NULL };
 MY_LOCALE my_locale_fi_FI=
- { "fi_FI", "Finnish - Finland", FALSE, &my_locale_typelib_month_names_fi_FI, &my_locale_typelib_ab_month_names_fi_FI, &my_locale_typelib_day_names_fi_FI, &my_locale_typelib_ab_day_names_fi_FI };
+{
+  20,
+  "fi_FI",
+  "Finnish - Finland",
+  FALSE,
+  &my_locale_typelib_month_names_fi_FI,
+  &my_locale_typelib_ab_month_names_fi_FI,
+  &my_locale_typelib_day_names_fi_FI,
+  &my_locale_typelib_ab_day_names_fi_FI
+};
 /***** LOCALE END fi_FI *****/
 
 /***** LOCALE BEGIN fo_FO: Faroese - Faroe Islands *****/
@@ -410,7 +552,16 @@ static TYPELIB my_locale_typelib_day_names_fo_FO =
 static TYPELIB my_locale_typelib_ab_day_names_fo_FO = 
  { array_elements(my_locale_ab_day_names_fo_FO)-1, "", my_locale_ab_day_names_fo_FO, NULL };
 MY_LOCALE my_locale_fo_FO=
- { "fo_FO", "Faroese - Faroe Islands", FALSE, &my_locale_typelib_month_names_fo_FO, &my_locale_typelib_ab_month_names_fo_FO, &my_locale_typelib_day_names_fo_FO, &my_locale_typelib_ab_day_names_fo_FO };
+{
+  21,
+  "fo_FO",
+  "Faroese - Faroe Islands",
+  FALSE,
+  &my_locale_typelib_month_names_fo_FO,
+  &my_locale_typelib_ab_month_names_fo_FO,
+  &my_locale_typelib_day_names_fo_FO,
+  &my_locale_typelib_ab_day_names_fo_FO
+};
 /***** LOCALE END fo_FO *****/
 
 /***** LOCALE BEGIN fr_FR: French - France *****/
@@ -431,7 +582,16 @@ static TYPELIB my_locale_typelib_day_names_fr_FR =
 static TYPELIB my_locale_typelib_ab_day_names_fr_FR = 
  { array_elements(my_locale_ab_day_names_fr_FR)-1, "", my_locale_ab_day_names_fr_FR, NULL };
 MY_LOCALE my_locale_fr_FR=
- { "fr_FR", "French - France", FALSE, &my_locale_typelib_month_names_fr_FR, &my_locale_typelib_ab_month_names_fr_FR, &my_locale_typelib_day_names_fr_FR, &my_locale_typelib_ab_day_names_fr_FR };
+{
+  5,
+  "fr_FR",
+  "French - France",
+  FALSE,
+  &my_locale_typelib_month_names_fr_FR,
+  &my_locale_typelib_ab_month_names_fr_FR,
+  &my_locale_typelib_day_names_fr_FR,
+  &my_locale_typelib_ab_day_names_fr_FR
+};
 /***** LOCALE END fr_FR *****/
 
 /***** LOCALE BEGIN gl_ES: Galician - Galician *****/
@@ -452,7 +612,16 @@ static TYPELIB my_locale_typelib_day_names_gl_ES =
 static TYPELIB my_locale_typelib_ab_day_names_gl_ES = 
  { array_elements(my_locale_ab_day_names_gl_ES)-1, "", my_locale_ab_day_names_gl_ES, NULL };
 MY_LOCALE my_locale_gl_ES=
- { "gl_ES", "Galician - Galician", FALSE, &my_locale_typelib_month_names_gl_ES, &my_locale_typelib_ab_month_names_gl_ES, &my_locale_typelib_day_names_gl_ES, &my_locale_typelib_ab_day_names_gl_ES };
+{
+  22,
+  "gl_ES",
+  "Galician - Galician",
+  FALSE,
+  &my_locale_typelib_month_names_gl_ES,
+  &my_locale_typelib_ab_month_names_gl_ES,
+  &my_locale_typelib_day_names_gl_ES,
+  &my_locale_typelib_ab_day_names_gl_ES
+};
 /***** LOCALE END gl_ES *****/
 
 /***** LOCALE BEGIN gu_IN: Gujarati - India *****/
@@ -473,7 +642,16 @@ static TYPELIB my_locale_typelib_day_names_gu_IN =
 static TYPELIB my_locale_typelib_ab_day_names_gu_IN = 
  { array_elements(my_locale_ab_day_names_gu_IN)-1, "", my_locale_ab_day_names_gu_IN, NULL };
 MY_LOCALE my_locale_gu_IN=
- { "gu_IN", "Gujarati - India", FALSE, &my_locale_typelib_month_names_gu_IN, &my_locale_typelib_ab_month_names_gu_IN, &my_locale_typelib_day_names_gu_IN, &my_locale_typelib_ab_day_names_gu_IN };
+{
+  23,
+  "gu_IN",
+  "Gujarati - India",
+  FALSE,
+  &my_locale_typelib_month_names_gu_IN,
+  &my_locale_typelib_ab_month_names_gu_IN,
+  &my_locale_typelib_day_names_gu_IN,
+  &my_locale_typelib_ab_day_names_gu_IN
+};
 /***** LOCALE END gu_IN *****/
 
 /***** LOCALE BEGIN he_IL: Hebrew - Israel *****/
@@ -494,7 +672,16 @@ static TYPELIB my_locale_typelib_day_names_he_IL =
 static TYPELIB my_locale_typelib_ab_day_names_he_IL = 
  { array_elements(my_locale_ab_day_names_he_IL)-1, "", my_locale_ab_day_names_he_IL, NULL };
 MY_LOCALE my_locale_he_IL=
- { "he_IL", "Hebrew - Israel", FALSE, &my_locale_typelib_month_names_he_IL, &my_locale_typelib_ab_month_names_he_IL, &my_locale_typelib_day_names_he_IL, &my_locale_typelib_ab_day_names_he_IL };
+{
+  24,
+  "he_IL",
+  "Hebrew - Israel",
+  FALSE,
+  &my_locale_typelib_month_names_he_IL,
+  &my_locale_typelib_ab_month_names_he_IL,
+  &my_locale_typelib_day_names_he_IL,
+  &my_locale_typelib_ab_day_names_he_IL
+};
 /***** LOCALE END he_IL *****/
 
 /***** LOCALE BEGIN hi_IN: Hindi - India *****/
@@ -515,7 +702,16 @@ static TYPELIB my_locale_typelib_day_names_hi_IN =
 static TYPELIB my_locale_typelib_ab_day_names_hi_IN = 
  { array_elements(my_locale_ab_day_names_hi_IN)-1, "", my_locale_ab_day_names_hi_IN, NULL };
 MY_LOCALE my_locale_hi_IN=
- { "hi_IN", "Hindi - India", FALSE, &my_locale_typelib_month_names_hi_IN, &my_locale_typelib_ab_month_names_hi_IN, &my_locale_typelib_day_names_hi_IN, &my_locale_typelib_ab_day_names_hi_IN };
+{
+  25,
+  "hi_IN",
+  "Hindi - India",
+  FALSE,
+  &my_locale_typelib_month_names_hi_IN,
+  &my_locale_typelib_ab_month_names_hi_IN,
+  &my_locale_typelib_day_names_hi_IN,
+  &my_locale_typelib_ab_day_names_hi_IN
+};
 /***** LOCALE END hi_IN *****/
 
 /***** LOCALE BEGIN hr_HR: Croatian - Croatia *****/
@@ -536,7 +732,16 @@ static TYPELIB my_locale_typelib_day_names_hr_HR =
 static TYPELIB my_locale_typelib_ab_day_names_hr_HR = 
  { array_elements(my_locale_ab_day_names_hr_HR)-1, "", my_locale_ab_day_names_hr_HR, NULL };
 MY_LOCALE my_locale_hr_HR=
- { "hr_HR", "Croatian - Croatia", FALSE, &my_locale_typelib_month_names_hr_HR, &my_locale_typelib_ab_month_names_hr_HR, &my_locale_typelib_day_names_hr_HR, &my_locale_typelib_ab_day_names_hr_HR };
+{
+  26,
+  "hr_HR",
+  "Croatian - Croatia",
+  FALSE,
+  &my_locale_typelib_month_names_hr_HR,
+  &my_locale_typelib_ab_month_names_hr_HR,
+  &my_locale_typelib_day_names_hr_HR,
+  &my_locale_typelib_ab_day_names_hr_HR
+};
 /***** LOCALE END hr_HR *****/
 
 /***** LOCALE BEGIN hu_HU: Hungarian - Hungary *****/
@@ -557,7 +762,16 @@ static TYPELIB my_locale_typelib_day_names_hu_HU =
 static TYPELIB my_locale_typelib_ab_day_names_hu_HU = 
  { array_elements(my_locale_ab_day_names_hu_HU)-1, "", my_locale_ab_day_names_hu_HU, NULL };
 MY_LOCALE my_locale_hu_HU=
- { "hu_HU", "Hungarian - Hungary", FALSE, &my_locale_typelib_month_names_hu_HU, &my_locale_typelib_ab_month_names_hu_HU, &my_locale_typelib_day_names_hu_HU, &my_locale_typelib_ab_day_names_hu_HU };
+{
+  27,
+  "hu_HU",
+  "Hungarian - Hungary",
+  FALSE,
+  &my_locale_typelib_month_names_hu_HU,
+  &my_locale_typelib_ab_month_names_hu_HU,
+  &my_locale_typelib_day_names_hu_HU,
+  &my_locale_typelib_ab_day_names_hu_HU
+};
 /***** LOCALE END hu_HU *****/
 
 /***** LOCALE BEGIN id_ID: Indonesian - Indonesia *****/
@@ -578,7 +792,16 @@ static TYPELIB my_locale_typelib_day_names_id_ID =
 static TYPELIB my_locale_typelib_ab_day_names_id_ID = 
  { array_elements(my_locale_ab_day_names_id_ID)-1, "", my_locale_ab_day_names_id_ID, NULL };
 MY_LOCALE my_locale_id_ID=
- { "id_ID", "Indonesian - Indonesia", TRUE, &my_locale_typelib_month_names_id_ID, &my_locale_typelib_ab_month_names_id_ID, &my_locale_typelib_day_names_id_ID, &my_locale_typelib_ab_day_names_id_ID };
+{
+  28,
+  "id_ID",
+  "Indonesian - Indonesia",
+  TRUE,
+  &my_locale_typelib_month_names_id_ID,
+  &my_locale_typelib_ab_month_names_id_ID,
+  &my_locale_typelib_day_names_id_ID,
+  &my_locale_typelib_ab_day_names_id_ID
+};
 /***** LOCALE END id_ID *****/
 
 /***** LOCALE BEGIN is_IS: Icelandic - Iceland *****/
@@ -599,7 +822,16 @@ static TYPELIB my_locale_typelib_day_names_is_IS =
 static TYPELIB my_locale_typelib_ab_day_names_is_IS = 
  { array_elements(my_locale_ab_day_names_is_IS)-1, "", my_locale_ab_day_names_is_IS, NULL };
 MY_LOCALE my_locale_is_IS=
- { "is_IS", "Icelandic - Iceland", FALSE, &my_locale_typelib_month_names_is_IS, &my_locale_typelib_ab_month_names_is_IS, &my_locale_typelib_day_names_is_IS, &my_locale_typelib_ab_day_names_is_IS };
+{
+  29,
+  "is_IS",
+  "Icelandic - Iceland",
+  FALSE,
+  &my_locale_typelib_month_names_is_IS,
+  &my_locale_typelib_ab_month_names_is_IS,
+  &my_locale_typelib_day_names_is_IS,
+  &my_locale_typelib_ab_day_names_is_IS
+};
 /***** LOCALE END is_IS *****/
 
 /***** LOCALE BEGIN it_CH: Italian - Switzerland *****/
@@ -620,7 +852,16 @@ static TYPELIB my_locale_typelib_day_names_it_CH =
 static TYPELIB my_locale_typelib_ab_day_names_it_CH = 
  { array_elements(my_locale_ab_day_names_it_CH)-1, "", my_locale_ab_day_names_it_CH, NULL };
 MY_LOCALE my_locale_it_CH=
- { "it_CH", "Italian - Switzerland", FALSE, &my_locale_typelib_month_names_it_CH, &my_locale_typelib_ab_month_names_it_CH, &my_locale_typelib_day_names_it_CH, &my_locale_typelib_ab_day_names_it_CH };
+{
+  30,
+  "it_CH",
+  "Italian - Switzerland",
+  FALSE,
+  &my_locale_typelib_month_names_it_CH,
+  &my_locale_typelib_ab_month_names_it_CH,
+  &my_locale_typelib_day_names_it_CH,
+  &my_locale_typelib_ab_day_names_it_CH
+};
 /***** LOCALE END it_CH *****/
 
 /***** LOCALE BEGIN ja_JP: Japanese - Japan *****/
@@ -641,7 +882,16 @@ static TYPELIB my_locale_typelib_day_names_ja_JP =
 static TYPELIB my_locale_typelib_ab_day_names_ja_JP = 
  { array_elements(my_locale_ab_day_names_ja_JP)-1, "", my_locale_ab_day_names_ja_JP, NULL };
 MY_LOCALE my_locale_ja_JP=
- { "ja_JP", "Japanese - Japan", FALSE, &my_locale_typelib_month_names_ja_JP, &my_locale_typelib_ab_month_names_ja_JP, &my_locale_typelib_day_names_ja_JP, &my_locale_typelib_ab_day_names_ja_JP };
+{
+  2,
+  "ja_JP",
+  "Japanese - Japan",
+  FALSE,
+  &my_locale_typelib_month_names_ja_JP,
+  &my_locale_typelib_ab_month_names_ja_JP,
+  &my_locale_typelib_day_names_ja_JP,
+  &my_locale_typelib_ab_day_names_ja_JP
+};
 /***** LOCALE END ja_JP *****/
 
 /***** LOCALE BEGIN ko_KR: Korean - Korea *****/
@@ -662,7 +912,16 @@ static TYPELIB my_locale_typelib_day_names_ko_KR =
 static TYPELIB my_locale_typelib_ab_day_names_ko_KR = 
  { array_elements(my_locale_ab_day_names_ko_KR)-1, "", my_locale_ab_day_names_ko_KR, NULL };
 MY_LOCALE my_locale_ko_KR=
- { "ko_KR", "Korean - Korea", FALSE, &my_locale_typelib_month_names_ko_KR, &my_locale_typelib_ab_month_names_ko_KR, &my_locale_typelib_day_names_ko_KR, &my_locale_typelib_ab_day_names_ko_KR };
+{
+  31,
+  "ko_KR",
+  "Korean - Korea",
+  FALSE,
+  &my_locale_typelib_month_names_ko_KR,
+  &my_locale_typelib_ab_month_names_ko_KR,
+  &my_locale_typelib_day_names_ko_KR,
+  &my_locale_typelib_ab_day_names_ko_KR
+};
 /***** LOCALE END ko_KR *****/
 
 /***** LOCALE BEGIN lt_LT: Lithuanian - Lithuania *****/
@@ -683,7 +942,16 @@ static TYPELIB my_locale_typelib_day_names_lt_LT =
 static TYPELIB my_locale_typelib_ab_day_names_lt_LT = 
  { array_elements(my_locale_ab_day_names_lt_LT)-1, "", my_locale_ab_day_names_lt_LT, NULL };
 MY_LOCALE my_locale_lt_LT=
- { "lt_LT", "Lithuanian - Lithuania", FALSE, &my_locale_typelib_month_names_lt_LT, &my_locale_typelib_ab_month_names_lt_LT, &my_locale_typelib_day_names_lt_LT, &my_locale_typelib_ab_day_names_lt_LT };
+{
+  32,
+  "lt_LT",
+  "Lithuanian - Lithuania",
+  FALSE,
+  &my_locale_typelib_month_names_lt_LT,
+  &my_locale_typelib_ab_month_names_lt_LT,
+  &my_locale_typelib_day_names_lt_LT,
+  &my_locale_typelib_ab_day_names_lt_LT
+};
 /***** LOCALE END lt_LT *****/
 
 /***** LOCALE BEGIN lv_LV: Latvian - Latvia *****/
@@ -704,7 +972,16 @@ static TYPELIB my_locale_typelib_day_names_lv_LV =
 static TYPELIB my_locale_typelib_ab_day_names_lv_LV = 
  { array_elements(my_locale_ab_day_names_lv_LV)-1, "", my_locale_ab_day_names_lv_LV, NULL };
 MY_LOCALE my_locale_lv_LV=
- { "lv_LV", "Latvian - Latvia", FALSE, &my_locale_typelib_month_names_lv_LV, &my_locale_typelib_ab_month_names_lv_LV, &my_locale_typelib_day_names_lv_LV, &my_locale_typelib_ab_day_names_lv_LV };
+{
+  33,
+  "lv_LV",
+  "Latvian - Latvia",
+  FALSE,
+  &my_locale_typelib_month_names_lv_LV,
+  &my_locale_typelib_ab_month_names_lv_LV,
+  &my_locale_typelib_day_names_lv_LV,
+  &my_locale_typelib_ab_day_names_lv_LV
+};
 /***** LOCALE END lv_LV *****/
 
 /***** LOCALE BEGIN mk_MK: Macedonian - FYROM *****/
@@ -725,7 +1002,16 @@ static TYPELIB my_locale_typelib_day_names_mk_MK =
 static TYPELIB my_locale_typelib_ab_day_names_mk_MK = 
  { array_elements(my_locale_ab_day_names_mk_MK)-1, "", my_locale_ab_day_names_mk_MK, NULL };
 MY_LOCALE my_locale_mk_MK=
- { "mk_MK", "Macedonian - FYROM", FALSE, &my_locale_typelib_month_names_mk_MK, &my_locale_typelib_ab_month_names_mk_MK, &my_locale_typelib_day_names_mk_MK, &my_locale_typelib_ab_day_names_mk_MK };
+{
+  34,
+  "mk_MK",
+  "Macedonian - FYROM",
+  FALSE,
+  &my_locale_typelib_month_names_mk_MK,
+  &my_locale_typelib_ab_month_names_mk_MK,
+  &my_locale_typelib_day_names_mk_MK,
+  &my_locale_typelib_ab_day_names_mk_MK
+};
 /***** LOCALE END mk_MK *****/
 
 /***** LOCALE BEGIN mn_MN: Mongolia - Mongolian *****/
@@ -746,7 +1032,16 @@ static TYPELIB my_locale_typelib_day_names_mn_MN =
 static TYPELIB my_locale_typelib_ab_day_names_mn_MN = 
  { array_elements(my_locale_ab_day_names_mn_MN)-1, "", my_locale_ab_day_names_mn_MN, NULL };
 MY_LOCALE my_locale_mn_MN=
- { "mn_MN", "Mongolia - Mongolian", FALSE, &my_locale_typelib_month_names_mn_MN, &my_locale_typelib_ab_month_names_mn_MN, &my_locale_typelib_day_names_mn_MN, &my_locale_typelib_ab_day_names_mn_MN };
+{
+  35,
+  "mn_MN",
+  "Mongolia - Mongolian",
+  FALSE,
+  &my_locale_typelib_month_names_mn_MN,
+  &my_locale_typelib_ab_month_names_mn_MN,
+  &my_locale_typelib_day_names_mn_MN,
+  &my_locale_typelib_ab_day_names_mn_MN
+};
 /***** LOCALE END mn_MN *****/
 
 /***** LOCALE BEGIN ms_MY: Malay - Malaysia *****/
@@ -767,7 +1062,16 @@ static TYPELIB my_locale_typelib_day_names_ms_MY =
 static TYPELIB my_locale_typelib_ab_day_names_ms_MY = 
  { array_elements(my_locale_ab_day_names_ms_MY)-1, "", my_locale_ab_day_names_ms_MY, NULL };
 MY_LOCALE my_locale_ms_MY=
- { "ms_MY", "Malay - Malaysia", TRUE, &my_locale_typelib_month_names_ms_MY, &my_locale_typelib_ab_month_names_ms_MY, &my_locale_typelib_day_names_ms_MY, &my_locale_typelib_ab_day_names_ms_MY };
+{
+  36,
+  "ms_MY",
+  "Malay - Malaysia",
+  TRUE,
+  &my_locale_typelib_month_names_ms_MY,
+  &my_locale_typelib_ab_month_names_ms_MY,
+  &my_locale_typelib_day_names_ms_MY,
+  &my_locale_typelib_ab_day_names_ms_MY
+};
 /***** LOCALE END ms_MY *****/
 
 /***** LOCALE BEGIN nb_NO: Norwegian(Bokml) - Norway *****/
@@ -788,7 +1092,16 @@ static TYPELIB my_locale_typelib_day_names_nb_NO =
 static TYPELIB my_locale_typelib_ab_day_names_nb_NO = 
  { array_elements(my_locale_ab_day_names_nb_NO)-1, "", my_locale_ab_day_names_nb_NO, NULL };
 MY_LOCALE my_locale_nb_NO=
- { "nb_NO", "Norwegian(Bokml) - Norway", FALSE, &my_locale_typelib_month_names_nb_NO, &my_locale_typelib_ab_month_names_nb_NO, &my_locale_typelib_day_names_nb_NO, &my_locale_typelib_ab_day_names_nb_NO };
+{
+  37,
+  "nb_NO",
+  "Norwegian(Bokml) - Norway",
+  FALSE,
+  &my_locale_typelib_month_names_nb_NO,
+  &my_locale_typelib_ab_month_names_nb_NO,
+  &my_locale_typelib_day_names_nb_NO,
+  &my_locale_typelib_ab_day_names_nb_NO
+};
 /***** LOCALE END nb_NO *****/
 
 /***** LOCALE BEGIN nl_NL: Dutch - The Netherlands *****/
@@ -809,7 +1122,16 @@ static TYPELIB my_locale_typelib_day_names_nl_NL =
 static TYPELIB my_locale_typelib_ab_day_names_nl_NL = 
  { array_elements(my_locale_ab_day_names_nl_NL)-1, "", my_locale_ab_day_names_nl_NL, NULL };
 MY_LOCALE my_locale_nl_NL=
- { "nl_NL", "Dutch - The Netherlands", TRUE, &my_locale_typelib_month_names_nl_NL, &my_locale_typelib_ab_month_names_nl_NL, &my_locale_typelib_day_names_nl_NL, &my_locale_typelib_ab_day_names_nl_NL };
+{
+  38,
+  "nl_NL",
+  "Dutch - The Netherlands",
+  TRUE,
+  &my_locale_typelib_month_names_nl_NL,
+  &my_locale_typelib_ab_month_names_nl_NL,
+  &my_locale_typelib_day_names_nl_NL,
+  &my_locale_typelib_ab_day_names_nl_NL
+};
 /***** LOCALE END nl_NL *****/
 
 /***** LOCALE BEGIN pl_PL: Polish - Poland *****/
@@ -830,7 +1152,16 @@ static TYPELIB my_locale_typelib_day_names_pl_PL =
 static TYPELIB my_locale_typelib_ab_day_names_pl_PL = 
  { array_elements(my_locale_ab_day_names_pl_PL)-1, "", my_locale_ab_day_names_pl_PL, NULL };
 MY_LOCALE my_locale_pl_PL=
- { "pl_PL", "Polish - Poland", FALSE, &my_locale_typelib_month_names_pl_PL, &my_locale_typelib_ab_month_names_pl_PL, &my_locale_typelib_day_names_pl_PL, &my_locale_typelib_ab_day_names_pl_PL };
+{
+  39,
+  "pl_PL",
+  "Polish - Poland",
+  FALSE,
+  &my_locale_typelib_month_names_pl_PL,
+  &my_locale_typelib_ab_month_names_pl_PL,
+  &my_locale_typelib_day_names_pl_PL,
+  &my_locale_typelib_ab_day_names_pl_PL
+};
 /***** LOCALE END pl_PL *****/
 
 /***** LOCALE BEGIN pt_BR: Portugese - Brazil *****/
@@ -851,7 +1182,16 @@ static TYPELIB my_locale_typelib_day_names_pt_BR =
 static TYPELIB my_locale_typelib_ab_day_names_pt_BR = 
  { array_elements(my_locale_ab_day_names_pt_BR)-1, "", my_locale_ab_day_names_pt_BR, NULL };
 MY_LOCALE my_locale_pt_BR=
- { "pt_BR", "Portugese - Brazil", FALSE, &my_locale_typelib_month_names_pt_BR, &my_locale_typelib_ab_month_names_pt_BR, &my_locale_typelib_day_names_pt_BR, &my_locale_typelib_ab_day_names_pt_BR };
+{
+  40,
+  "pt_BR",
+  "Portugese - Brazil",
+  FALSE,
+  &my_locale_typelib_month_names_pt_BR,
+  &my_locale_typelib_ab_month_names_pt_BR,
+  &my_locale_typelib_day_names_pt_BR,
+  &my_locale_typelib_ab_day_names_pt_BR
+};
 /***** LOCALE END pt_BR *****/
 
 /***** LOCALE BEGIN pt_PT: Portugese - Portugal *****/
@@ -872,7 +1212,16 @@ static TYPELIB my_locale_typelib_day_names_pt_PT =
 static TYPELIB my_locale_typelib_ab_day_names_pt_PT = 
  { array_elements(my_locale_ab_day_names_pt_PT)-1, "", my_locale_ab_day_names_pt_PT, NULL };
 MY_LOCALE my_locale_pt_PT=
- { "pt_PT", "Portugese - Portugal", FALSE, &my_locale_typelib_month_names_pt_PT, &my_locale_typelib_ab_month_names_pt_PT, &my_locale_typelib_day_names_pt_PT, &my_locale_typelib_ab_day_names_pt_PT };
+{
+  41,
+  "pt_PT",
+  "Portugese - Portugal",
+  FALSE,
+  &my_locale_typelib_month_names_pt_PT,
+  &my_locale_typelib_ab_month_names_pt_PT,
+  &my_locale_typelib_day_names_pt_PT,
+  &my_locale_typelib_ab_day_names_pt_PT
+};
 /***** LOCALE END pt_PT *****/
 
 /***** LOCALE BEGIN ro_RO: Romanian - Romania *****/
@@ -893,7 +1242,16 @@ static TYPELIB my_locale_typelib_day_names_ro_RO =
 static TYPELIB my_locale_typelib_ab_day_names_ro_RO = 
  { array_elements(my_locale_ab_day_names_ro_RO)-1, "", my_locale_ab_day_names_ro_RO, NULL };
 MY_LOCALE my_locale_ro_RO=
- { "ro_RO", "Romanian - Romania", FALSE, &my_locale_typelib_month_names_ro_RO, &my_locale_typelib_ab_month_names_ro_RO, &my_locale_typelib_day_names_ro_RO, &my_locale_typelib_ab_day_names_ro_RO };
+{
+  42,
+  "ro_RO",
+  "Romanian - Romania",
+  FALSE,
+  &my_locale_typelib_month_names_ro_RO,
+  &my_locale_typelib_ab_month_names_ro_RO,
+  &my_locale_typelib_day_names_ro_RO,
+  &my_locale_typelib_ab_day_names_ro_RO
+};
 /***** LOCALE END ro_RO *****/
 
 /***** LOCALE BEGIN ru_RU: Russian - Russia *****/
@@ -914,7 +1272,16 @@ static TYPELIB my_locale_typelib_day_names_ru_RU =
 static TYPELIB my_locale_typelib_ab_day_names_ru_RU = 
  { array_elements(my_locale_ab_day_names_ru_RU)-1, "", my_locale_ab_day_names_ru_RU, NULL };
 MY_LOCALE my_locale_ru_RU=
- { "ru_RU", "Russian - Russia", FALSE, &my_locale_typelib_month_names_ru_RU, &my_locale_typelib_ab_month_names_ru_RU, &my_locale_typelib_day_names_ru_RU, &my_locale_typelib_ab_day_names_ru_RU };
+{
+  43,
+  "ru_RU",
+  "Russian - Russia",
+  FALSE,
+  &my_locale_typelib_month_names_ru_RU,
+  &my_locale_typelib_ab_month_names_ru_RU,
+  &my_locale_typelib_day_names_ru_RU,
+  &my_locale_typelib_ab_day_names_ru_RU
+};
 /***** LOCALE END ru_RU *****/
 
 /***** LOCALE BEGIN ru_UA: Russian - Ukraine *****/
@@ -935,7 +1302,16 @@ static TYPELIB my_locale_typelib_day_names_ru_UA =
 static TYPELIB my_locale_typelib_ab_day_names_ru_UA = 
  { array_elements(my_locale_ab_day_names_ru_UA)-1, "", my_locale_ab_day_names_ru_UA, NULL };
 MY_LOCALE my_locale_ru_UA=
- { "ru_UA", "Russian - Ukraine", FALSE, &my_locale_typelib_month_names_ru_UA, &my_locale_typelib_ab_month_names_ru_UA, &my_locale_typelib_day_names_ru_UA, &my_locale_typelib_ab_day_names_ru_UA };
+{
+  44,
+  "ru_UA",
+  "Russian - Ukraine",
+  FALSE,
+  &my_locale_typelib_month_names_ru_UA,
+  &my_locale_typelib_ab_month_names_ru_UA,
+  &my_locale_typelib_day_names_ru_UA,
+  &my_locale_typelib_ab_day_names_ru_UA
+};
 /***** LOCALE END ru_UA *****/
 
 /***** LOCALE BEGIN sk_SK: Slovak - Slovakia *****/
@@ -956,7 +1332,16 @@ static TYPELIB my_locale_typelib_day_names_sk_SK =
 static TYPELIB my_locale_typelib_ab_day_names_sk_SK = 
  { array_elements(my_locale_ab_day_names_sk_SK)-1, "", my_locale_ab_day_names_sk_SK, NULL };
 MY_LOCALE my_locale_sk_SK=
- { "sk_SK", "Slovak - Slovakia", FALSE, &my_locale_typelib_month_names_sk_SK, &my_locale_typelib_ab_month_names_sk_SK, &my_locale_typelib_day_names_sk_SK, &my_locale_typelib_ab_day_names_sk_SK };
+{
+  45,
+  "sk_SK",
+  "Slovak - Slovakia",
+  FALSE,
+  &my_locale_typelib_month_names_sk_SK,
+  &my_locale_typelib_ab_month_names_sk_SK,
+  &my_locale_typelib_day_names_sk_SK,
+  &my_locale_typelib_ab_day_names_sk_SK
+};
 /***** LOCALE END sk_SK *****/
 
 /***** LOCALE BEGIN sl_SI: Slovenian - Slovenia *****/
@@ -977,7 +1362,16 @@ static TYPELIB my_locale_typelib_day_names_sl_SI =
 static TYPELIB my_locale_typelib_ab_day_names_sl_SI = 
  { array_elements(my_locale_ab_day_names_sl_SI)-1, "", my_locale_ab_day_names_sl_SI, NULL };
 MY_LOCALE my_locale_sl_SI=
- { "sl_SI", "Slovenian - Slovenia", FALSE, &my_locale_typelib_month_names_sl_SI, &my_locale_typelib_ab_month_names_sl_SI, &my_locale_typelib_day_names_sl_SI, &my_locale_typelib_ab_day_names_sl_SI };
+{
+  46,
+  "sl_SI",
+  "Slovenian - Slovenia",
+  FALSE,
+  &my_locale_typelib_month_names_sl_SI,
+  &my_locale_typelib_ab_month_names_sl_SI,
+  &my_locale_typelib_day_names_sl_SI,
+  &my_locale_typelib_ab_day_names_sl_SI
+};
 /***** LOCALE END sl_SI *****/
 
 /***** LOCALE BEGIN sq_AL: Albanian - Albania *****/
@@ -998,7 +1392,16 @@ static TYPELIB my_locale_typelib_day_names_sq_AL =
 static TYPELIB my_locale_typelib_ab_day_names_sq_AL = 
  { array_elements(my_locale_ab_day_names_sq_AL)-1, "", my_locale_ab_day_names_sq_AL, NULL };
 MY_LOCALE my_locale_sq_AL=
- { "sq_AL", "Albanian - Albania", FALSE, &my_locale_typelib_month_names_sq_AL, &my_locale_typelib_ab_month_names_sq_AL, &my_locale_typelib_day_names_sq_AL, &my_locale_typelib_ab_day_names_sq_AL };
+{
+  47,
+  "sq_AL",
+  "Albanian - Albania",
+  FALSE,
+  &my_locale_typelib_month_names_sq_AL,
+  &my_locale_typelib_ab_month_names_sq_AL,
+  &my_locale_typelib_day_names_sq_AL,
+  &my_locale_typelib_ab_day_names_sq_AL
+};
 /***** LOCALE END sq_AL *****/
 
 /***** LOCALE BEGIN sr_YU: Servian - Yugoslavia *****/
@@ -1019,7 +1422,16 @@ static TYPELIB my_locale_typelib_day_names_sr_YU =
 static TYPELIB my_locale_typelib_ab_day_names_sr_YU = 
  { array_elements(my_locale_ab_day_names_sr_YU)-1, "", my_locale_ab_day_names_sr_YU, NULL };
 MY_LOCALE my_locale_sr_YU=
- { "sr_YU", "Servian - Yugoslavia", FALSE, &my_locale_typelib_month_names_sr_YU, &my_locale_typelib_ab_month_names_sr_YU, &my_locale_typelib_day_names_sr_YU, &my_locale_typelib_ab_day_names_sr_YU };
+{
+  48,
+  "sr_YU",
+  "Servian - Yugoslavia",
+  FALSE,
+  &my_locale_typelib_month_names_sr_YU,
+  &my_locale_typelib_ab_month_names_sr_YU,
+  &my_locale_typelib_day_names_sr_YU,
+  &my_locale_typelib_ab_day_names_sr_YU
+};
 /***** LOCALE END sr_YU *****/
 
 /***** LOCALE BEGIN sv_SE: Swedish - Sweden *****/
@@ -1040,7 +1452,16 @@ static TYPELIB my_locale_typelib_day_names_sv_SE =
 static TYPELIB my_locale_typelib_ab_day_names_sv_SE = 
  { array_elements(my_locale_ab_day_names_sv_SE)-1, "", my_locale_ab_day_names_sv_SE, NULL };
 MY_LOCALE my_locale_sv_SE=
- { "sv_SE", "Swedish - Sweden", FALSE, &my_locale_typelib_month_names_sv_SE, &my_locale_typelib_ab_month_names_sv_SE, &my_locale_typelib_day_names_sv_SE, &my_locale_typelib_ab_day_names_sv_SE };
+{
+  3,
+  "sv_SE",
+  "Swedish - Sweden",
+  FALSE,
+  &my_locale_typelib_month_names_sv_SE,
+  &my_locale_typelib_ab_month_names_sv_SE,
+  &my_locale_typelib_day_names_sv_SE,
+  &my_locale_typelib_ab_day_names_sv_SE
+};
 /***** LOCALE END sv_SE *****/
 
 /***** LOCALE BEGIN ta_IN: Tamil - India *****/
@@ -1061,7 +1482,16 @@ static TYPELIB my_locale_typelib_day_names_ta_IN =
 static TYPELIB my_locale_typelib_ab_day_names_ta_IN = 
  { array_elements(my_locale_ab_day_names_ta_IN)-1, "", my_locale_ab_day_names_ta_IN, NULL };
 MY_LOCALE my_locale_ta_IN=
- { "ta_IN", "Tamil - India", FALSE, &my_locale_typelib_month_names_ta_IN, &my_locale_typelib_ab_month_names_ta_IN, &my_locale_typelib_day_names_ta_IN, &my_locale_typelib_ab_day_names_ta_IN };
+{
+  49,
+  "ta_IN",
+  "Tamil - India",
+  FALSE,
+  &my_locale_typelib_month_names_ta_IN,
+  &my_locale_typelib_ab_month_names_ta_IN,
+  &my_locale_typelib_day_names_ta_IN,
+  &my_locale_typelib_ab_day_names_ta_IN
+};
 /***** LOCALE END ta_IN *****/
 
 /***** LOCALE BEGIN te_IN: Telugu - India *****/
@@ -1082,7 +1512,16 @@ static TYPELIB my_locale_typelib_day_names_te_IN =
 static TYPELIB my_locale_typelib_ab_day_names_te_IN = 
  { array_elements(my_locale_ab_day_names_te_IN)-1, "", my_locale_ab_day_names_te_IN, NULL };
 MY_LOCALE my_locale_te_IN=
- { "te_IN", "Telugu - India", FALSE, &my_locale_typelib_month_names_te_IN, &my_locale_typelib_ab_month_names_te_IN, &my_locale_typelib_day_names_te_IN, &my_locale_typelib_ab_day_names_te_IN };
+{
+  50,
+  "te_IN",
+  "Telugu - India",
+  FALSE,
+  &my_locale_typelib_month_names_te_IN,
+  &my_locale_typelib_ab_month_names_te_IN,
+  &my_locale_typelib_day_names_te_IN,
+  &my_locale_typelib_ab_day_names_te_IN
+};
 /***** LOCALE END te_IN *****/
 
 /***** LOCALE BEGIN th_TH: Thai - Thailand *****/
@@ -1103,7 +1542,16 @@ static TYPELIB my_locale_typelib_day_names_th_TH =
 static TYPELIB my_locale_typelib_ab_day_names_th_TH = 
  { array_elements(my_locale_ab_day_names_th_TH)-1, "", my_locale_ab_day_names_th_TH, NULL };
 MY_LOCALE my_locale_th_TH=
- { "th_TH", "Thai - Thailand", FALSE, &my_locale_typelib_month_names_th_TH, &my_locale_typelib_ab_month_names_th_TH, &my_locale_typelib_day_names_th_TH, &my_locale_typelib_ab_day_names_th_TH };
+{
+  51,
+  "th_TH",
+  "Thai - Thailand",
+  FALSE,
+  &my_locale_typelib_month_names_th_TH,
+  &my_locale_typelib_ab_month_names_th_TH,
+  &my_locale_typelib_day_names_th_TH,
+  &my_locale_typelib_ab_day_names_th_TH
+};
 /***** LOCALE END th_TH *****/
 
 /***** LOCALE BEGIN tr_TR: Turkish - Turkey *****/
@@ -1124,7 +1572,16 @@ static TYPELIB my_locale_typelib_day_names_tr_TR =
 static TYPELIB my_locale_typelib_ab_day_names_tr_TR = 
  { array_elements(my_locale_ab_day_names_tr_TR)-1, "", my_locale_ab_day_names_tr_TR, NULL };
 MY_LOCALE my_locale_tr_TR=
- { "tr_TR", "Turkish - Turkey", FALSE, &my_locale_typelib_month_names_tr_TR, &my_locale_typelib_ab_month_names_tr_TR, &my_locale_typelib_day_names_tr_TR, &my_locale_typelib_ab_day_names_tr_TR };
+{
+  52,
+  "tr_TR",
+  "Turkish - Turkey",
+  FALSE,
+  &my_locale_typelib_month_names_tr_TR,
+  &my_locale_typelib_ab_month_names_tr_TR,
+  &my_locale_typelib_day_names_tr_TR,
+  &my_locale_typelib_ab_day_names_tr_TR
+};
 /***** LOCALE END tr_TR *****/
 
 /***** LOCALE BEGIN uk_UA: Ukrainian - Ukraine *****/
@@ -1145,7 +1602,16 @@ static TYPELIB my_locale_typelib_day_names_uk_UA =
 static TYPELIB my_locale_typelib_ab_day_names_uk_UA = 
  { array_elements(my_locale_ab_day_names_uk_UA)-1, "", my_locale_ab_day_names_uk_UA, NULL };
 MY_LOCALE my_locale_uk_UA=
- { "uk_UA", "Ukrainian - Ukraine", FALSE, &my_locale_typelib_month_names_uk_UA, &my_locale_typelib_ab_month_names_uk_UA, &my_locale_typelib_day_names_uk_UA, &my_locale_typelib_ab_day_names_uk_UA };
+{
+  53,
+  "uk_UA",
+  "Ukrainian - Ukraine",
+  FALSE,
+  &my_locale_typelib_month_names_uk_UA,
+  &my_locale_typelib_ab_month_names_uk_UA,
+  &my_locale_typelib_day_names_uk_UA,
+  &my_locale_typelib_ab_day_names_uk_UA
+};
 /***** LOCALE END uk_UA *****/
 
 /***** LOCALE BEGIN ur_PK: Urdu - Pakistan *****/
@@ -1166,7 +1632,16 @@ static TYPELIB my_locale_typelib_day_names_ur_PK =
 static TYPELIB my_locale_typelib_ab_day_names_ur_PK = 
  { array_elements(my_locale_ab_day_names_ur_PK)-1, "", my_locale_ab_day_names_ur_PK, NULL };
 MY_LOCALE my_locale_ur_PK=
- { "ur_PK", "Urdu - Pakistan", FALSE, &my_locale_typelib_month_names_ur_PK, &my_locale_typelib_ab_month_names_ur_PK, &my_locale_typelib_day_names_ur_PK, &my_locale_typelib_ab_day_names_ur_PK };
+{
+  54,
+  "ur_PK",
+  "Urdu - Pakistan",
+  FALSE,
+  &my_locale_typelib_month_names_ur_PK,
+  &my_locale_typelib_ab_month_names_ur_PK,
+  &my_locale_typelib_day_names_ur_PK,
+  &my_locale_typelib_ab_day_names_ur_PK
+};
 /***** LOCALE END ur_PK *****/
 
 /***** LOCALE BEGIN vi_VN: Vietnamese - Vietnam *****/
@@ -1187,7 +1662,16 @@ static TYPELIB my_locale_typelib_day_names_vi_VN =
 static TYPELIB my_locale_typelib_ab_day_names_vi_VN = 
  { array_elements(my_locale_ab_day_names_vi_VN)-1, "", my_locale_ab_day_names_vi_VN, NULL };
 MY_LOCALE my_locale_vi_VN=
- { "vi_VN", "Vietnamese - Vietnam", FALSE, &my_locale_typelib_month_names_vi_VN, &my_locale_typelib_ab_month_names_vi_VN, &my_locale_typelib_day_names_vi_VN, &my_locale_typelib_ab_day_names_vi_VN };
+{
+  55,
+  "vi_VN",
+  "Vietnamese - Vietnam",
+  FALSE,
+  &my_locale_typelib_month_names_vi_VN,
+  &my_locale_typelib_ab_month_names_vi_VN,
+  &my_locale_typelib_day_names_vi_VN,
+  &my_locale_typelib_ab_day_names_vi_VN
+};
 /***** LOCALE END vi_VN *****/
 
 /***** LOCALE BEGIN zh_CN: Chinese - Peoples Republic of China *****/
@@ -1208,7 +1692,16 @@ static TYPELIB my_locale_typelib_day_names_zh_CN =
 static TYPELIB my_locale_typelib_ab_day_names_zh_CN = 
  { array_elements(my_locale_ab_day_names_zh_CN)-1, "", my_locale_ab_day_names_zh_CN, NULL };
 MY_LOCALE my_locale_zh_CN=
- { "zh_CN", "Chinese - Peoples Republic of China", FALSE, &my_locale_typelib_month_names_zh_CN, &my_locale_typelib_ab_month_names_zh_CN, &my_locale_typelib_day_names_zh_CN, &my_locale_typelib_ab_day_names_zh_CN };
+{
+  56,
+  "zh_CN",
+  "Chinese - Peoples Republic of China",
+  FALSE,
+  &my_locale_typelib_month_names_zh_CN,
+  &my_locale_typelib_ab_month_names_zh_CN,
+  &my_locale_typelib_day_names_zh_CN,
+  &my_locale_typelib_ab_day_names_zh_CN
+};
 /***** LOCALE END zh_CN *****/
 
 /***** LOCALE BEGIN zh_TW: Chinese - Taiwan *****/
@@ -1229,269 +1722,753 @@ static TYPELIB my_locale_typelib_day_names_zh_TW =
 static TYPELIB my_locale_typelib_ab_day_names_zh_TW = 
  { array_elements(my_locale_ab_day_names_zh_TW)-1, "", my_locale_ab_day_names_zh_TW, NULL };
 MY_LOCALE my_locale_zh_TW=
- { "zh_TW", "Chinese - Taiwan", FALSE, &my_locale_typelib_month_names_zh_TW, &my_locale_typelib_ab_month_names_zh_TW, &my_locale_typelib_day_names_zh_TW, &my_locale_typelib_ab_day_names_zh_TW };
+{
+  57,
+  "zh_TW",
+  "Chinese - Taiwan",
+  FALSE,
+  &my_locale_typelib_month_names_zh_TW,
+  &my_locale_typelib_ab_month_names_zh_TW,
+  &my_locale_typelib_day_names_zh_TW,
+  &my_locale_typelib_ab_day_names_zh_TW
+};
 /***** LOCALE END zh_TW *****/
 
 /***** LOCALE BEGIN ar_DZ: Arabic - Algeria *****/
 MY_LOCALE my_locale_ar_DZ=
- { "ar_DZ", "Arabic - Algeria", FALSE, &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, &my_locale_typelib_ab_day_names_ar_BH };
+{
+  58,
+  "ar_DZ",
+  "Arabic - Algeria",
+  FALSE,
+  &my_locale_typelib_month_names_ar_BH,
+  &my_locale_typelib_ab_month_names_ar_BH,
+  &my_locale_typelib_day_names_ar_BH,
+  &my_locale_typelib_ab_day_names_ar_BH
+};
 /***** LOCALE END ar_DZ *****/
 
 /***** LOCALE BEGIN ar_EG: Arabic - Egypt *****/
 MY_LOCALE my_locale_ar_EG=
- { "ar_EG", "Arabic - Egypt", FALSE, &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, &my_locale_typelib_ab_day_names_ar_BH };
+{
+  59,
+  "ar_EG",
+  "Arabic - Egypt",
+  FALSE,
+  &my_locale_typelib_month_names_ar_BH,
+  &my_locale_typelib_ab_month_names_ar_BH,
+  &my_locale_typelib_day_names_ar_BH,
+  &my_locale_typelib_ab_day_names_ar_BH
+};
 /***** LOCALE END ar_EG *****/
 
 /***** LOCALE BEGIN ar_IN: Arabic - Iran *****/
 MY_LOCALE my_locale_ar_IN=
- { "ar_IN", "Arabic - Iran", FALSE, &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, &my_locale_typelib_ab_day_names_ar_BH };
+{
+  60,
+  "ar_IN",
+  "Arabic - Iran",
+  FALSE,
+  &my_locale_typelib_month_names_ar_BH,
+  &my_locale_typelib_ab_month_names_ar_BH,
+  &my_locale_typelib_day_names_ar_BH,
+  &my_locale_typelib_ab_day_names_ar_BH
+};
 /***** LOCALE END ar_IN *****/
 
 /***** LOCALE BEGIN ar_IQ: Arabic - Iraq *****/
 MY_LOCALE my_locale_ar_IQ=
- { "ar_IQ", "Arabic - Iraq", FALSE, &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, &my_locale_typelib_ab_day_names_ar_BH };
+{
+  61,
+  "ar_IQ",
+  "Arabic - Iraq",
+  FALSE,
+  &my_locale_typelib_month_names_ar_BH,
+  &my_locale_typelib_ab_month_names_ar_BH,
+  &my_locale_typelib_day_names_ar_BH,
+  &my_locale_typelib_ab_day_names_ar_BH
+};
 /***** LOCALE END ar_IQ *****/
 
 /***** LOCALE BEGIN ar_KW: Arabic - Kuwait *****/
 MY_LOCALE my_locale_ar_KW=
- { "ar_KW", "Arabic - Kuwait", FALSE, &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, &my_locale_typelib_ab_day_names_ar_BH };
+{
+  62,
+  "ar_KW",
+  "Arabic - Kuwait",
+  FALSE,
+  &my_locale_typelib_month_names_ar_BH,
+  &my_locale_typelib_ab_month_names_ar_BH,
+  &my_locale_typelib_day_names_ar_BH,
+  &my_locale_typelib_ab_day_names_ar_BH
+};
 /***** LOCALE END ar_KW *****/
 
 /***** LOCALE BEGIN ar_LB: Arabic - Lebanon *****/
 MY_LOCALE my_locale_ar_LB=
- { "ar_LB", "Arabic - Lebanon", FALSE, &my_locale_typelib_month_names_ar_JO, &my_locale_typelib_ab_month_names_ar_JO, &my_locale_typelib_day_names_ar_JO, &my_locale_typelib_ab_day_names_ar_JO };
+{
+  63,
+  "ar_LB",
+  "Arabic - Lebanon",
+  FALSE,
+  &my_locale_typelib_month_names_ar_JO,
+  &my_locale_typelib_ab_month_names_ar_JO,
+  &my_locale_typelib_day_names_ar_JO,
+  &my_locale_typelib_ab_day_names_ar_JO
+};
 /***** LOCALE END ar_LB *****/
 
 /***** LOCALE BEGIN ar_LY: Arabic - Libya *****/
 MY_LOCALE my_locale_ar_LY=
- { "ar_LY", "Arabic - Libya", FALSE, &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, &my_locale_typelib_ab_day_names_ar_BH };
+{
+  64,
+  "ar_LY",
+  "Arabic - Libya",
+  FALSE,
+  &my_locale_typelib_month_names_ar_BH,
+  &my_locale_typelib_ab_month_names_ar_BH,
+  &my_locale_typelib_day_names_ar_BH,
+  &my_locale_typelib_ab_day_names_ar_BH
+};
 /***** LOCALE END ar_LY *****/
 
 /***** LOCALE BEGIN ar_MA: Arabic - Morocco *****/
 MY_LOCALE my_locale_ar_MA=
- { "ar_MA", "Arabic - Morocco", FALSE, &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, &my_locale_typelib_ab_day_names_ar_BH };
+{
+  65,
+  "ar_MA",
+  "Arabic - Morocco",
+  FALSE,
+  &my_locale_typelib_month_names_ar_BH,
+  &my_locale_typelib_ab_month_names_ar_BH,
+  &my_locale_typelib_day_names_ar_BH,
+  &my_locale_typelib_ab_day_names_ar_BH
+};
 /***** LOCALE END ar_MA *****/
 
 /***** LOCALE BEGIN ar_OM: Arabic - Oman *****/
 MY_LOCALE my_locale_ar_OM=
- { "ar_OM", "Arabic - Oman", FALSE, &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, &my_locale_typelib_ab_day_names_ar_BH };
+{
+  66,
+  "ar_OM",
+  "Arabic - Oman",
+  FALSE,
+  &my_locale_typelib_month_names_ar_BH,
+  &my_locale_typelib_ab_month_names_ar_BH,
+  &my_locale_typelib_day_names_ar_BH,
+  &my_locale_typelib_ab_day_names_ar_BH
+};
 /***** LOCALE END ar_OM *****/
 
 /***** LOCALE BEGIN ar_QA: Arabic - Qatar *****/
 MY_LOCALE my_locale_ar_QA=
- { "ar_QA", "Arabic - Qatar", FALSE, &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, &my_locale_typelib_ab_day_names_ar_BH };
+{
+  67,
+  "ar_QA",
+  "Arabic - Qatar",
+  FALSE,
+  &my_locale_typelib_month_names_ar_BH,
+  &my_locale_typelib_ab_month_names_ar_BH,
+  &my_locale_typelib_day_names_ar_BH,
+  &my_locale_typelib_ab_day_names_ar_BH
+};
 /***** LOCALE END ar_QA *****/
 
 /***** LOCALE BEGIN ar_SD: Arabic - Sudan *****/
 MY_LOCALE my_locale_ar_SD=
- { "ar_SD", "Arabic - Sudan", FALSE, &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, &my_locale_typelib_ab_day_names_ar_BH };
+{
+  68,
+  "ar_SD",
+  "Arabic - Sudan",
+  FALSE,
+  &my_locale_typelib_month_names_ar_BH,
+  &my_locale_typelib_ab_month_names_ar_BH,
+  &my_locale_typelib_day_names_ar_BH,
+  &my_locale_typelib_ab_day_names_ar_BH
+};
 /***** LOCALE END ar_SD *****/
 
 /***** LOCALE BEGIN ar_TN: Arabic - Tunisia *****/
 MY_LOCALE my_locale_ar_TN=
- { "ar_TN", "Arabic - Tunisia", FALSE, &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, &my_locale_typelib_ab_day_names_ar_BH };
+{
+  69,
+  "ar_TN",
+  "Arabic - Tunisia",
+  FALSE,
+  &my_locale_typelib_month_names_ar_BH,
+  &my_locale_typelib_ab_month_names_ar_BH,
+  &my_locale_typelib_day_names_ar_BH,
+  &my_locale_typelib_ab_day_names_ar_BH
+};
 /***** LOCALE END ar_TN *****/
 
 /***** LOCALE BEGIN ar_YE: Arabic - Yemen *****/
 MY_LOCALE my_locale_ar_YE=
- { "ar_YE", "Arabic - Yemen", FALSE, &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, &my_locale_typelib_ab_day_names_ar_BH };
+{
+  70,
+  "ar_YE",
+  "Arabic - Yemen",
+  FALSE,
+  &my_locale_typelib_month_names_ar_BH,
+  &my_locale_typelib_ab_month_names_ar_BH,
+  &my_locale_typelib_day_names_ar_BH,
+  &my_locale_typelib_ab_day_names_ar_BH
+};
 /***** LOCALE END ar_YE *****/
 
 /***** LOCALE BEGIN de_BE: German - Belgium *****/
 MY_LOCALE my_locale_de_BE=
- { "de_BE", "German - Belgium", FALSE, &my_locale_typelib_month_names_de_DE, &my_locale_typelib_ab_month_names_de_DE, &my_locale_typelib_day_names_de_DE, &my_locale_typelib_ab_day_names_de_DE };
+{
+  71,
+  "de_BE",
+  "German - Belgium",
+  FALSE,
+  &my_locale_typelib_month_names_de_DE,
+  &my_locale_typelib_ab_month_names_de_DE,
+  &my_locale_typelib_day_names_de_DE,
+  &my_locale_typelib_ab_day_names_de_DE
+};
 /***** LOCALE END de_BE *****/
 
 /***** LOCALE BEGIN de_CH: German - Switzerland *****/
 MY_LOCALE my_locale_de_CH=
- { "de_CH", "German - Switzerland", FALSE, &my_locale_typelib_month_names_de_DE, &my_locale_typelib_ab_month_names_de_DE, &my_locale_typelib_day_names_de_DE, &my_locale_typelib_ab_day_names_de_DE };
+{
+  72,
+  "de_CH",
+  "German - Switzerland",
+  FALSE,
+  &my_locale_typelib_month_names_de_DE,
+  &my_locale_typelib_ab_month_names_de_DE,
+  &my_locale_typelib_day_names_de_DE,
+  &my_locale_typelib_ab_day_names_de_DE
+};
 /***** LOCALE END de_CH *****/
 
 /***** LOCALE BEGIN de_LU: German - Luxembourg *****/
 MY_LOCALE my_locale_de_LU=
- { "de_LU", "German - Luxembourg", FALSE, &my_locale_typelib_month_names_de_DE, &my_locale_typelib_ab_month_names_de_DE, &my_locale_typelib_day_names_de_DE, &my_locale_typelib_ab_day_names_de_DE };
+{
+  73,
+  "de_LU",
+  "German - Luxembourg",
+  FALSE,
+  &my_locale_typelib_month_names_de_DE,
+  &my_locale_typelib_ab_month_names_de_DE,
+  &my_locale_typelib_day_names_de_DE,
+  &my_locale_typelib_ab_day_names_de_DE
+};
 /***** LOCALE END de_LU *****/
 
 /***** LOCALE BEGIN en_AU: English - Australia *****/
 MY_LOCALE my_locale_en_AU=
- { "en_AU", "English - Australia", TRUE, &my_locale_typelib_month_names_en_US, &my_locale_typelib_ab_month_names_en_US, &my_locale_typelib_day_names_en_US, &my_locale_typelib_ab_day_names_en_US };
+{
+  74,
+  "en_AU",
+  "English - Australia",
+  TRUE,
+  &my_locale_typelib_month_names_en_US,
+  &my_locale_typelib_ab_month_names_en_US,
+  &my_locale_typelib_day_names_en_US,
+  &my_locale_typelib_ab_day_names_en_US
+};
 /***** LOCALE END en_AU *****/
 
 /***** LOCALE BEGIN en_CA: English - Canada *****/
 MY_LOCALE my_locale_en_CA=
- { "en_CA", "English - Canada", TRUE, &my_locale_typelib_month_names_en_US, &my_locale_typelib_ab_month_names_en_US, &my_locale_typelib_day_names_en_US, &my_locale_typelib_ab_day_names_en_US };
+{
+  75,
+  "en_CA",
+  "English - Canada",
+  TRUE,
+  &my_locale_typelib_month_names_en_US,
+  &my_locale_typelib_ab_month_names_en_US,
+  &my_locale_typelib_day_names_en_US,
+  &my_locale_typelib_ab_day_names_en_US
+};
 /***** LOCALE END en_CA *****/
 
 /***** LOCALE BEGIN en_GB: English - United Kingdom *****/
 MY_LOCALE my_locale_en_GB=
- { "en_GB", "English - United Kingdom", TRUE, &my_locale_typelib_month_names_en_US, &my_locale_typelib_ab_month_names_en_US, &my_locale_typelib_day_names_en_US, &my_locale_typelib_ab_day_names_en_US };
+{
+  1,
+  "en_GB",
+  "English - United Kingdom",
+  TRUE,
+  &my_locale_typelib_month_names_en_US,
+  &my_locale_typelib_ab_month_names_en_US,
+  &my_locale_typelib_day_names_en_US,
+  &my_locale_typelib_ab_day_names_en_US
+};
 /***** LOCALE END en_GB *****/
 
 /***** LOCALE BEGIN en_IN: English - India *****/
 MY_LOCALE my_locale_en_IN=
- { "en_IN", "English - India", TRUE, &my_locale_typelib_month_names_en_US, &my_locale_typelib_ab_month_names_en_US, &my_locale_typelib_day_names_en_US, &my_locale_typelib_ab_day_names_en_US };
+{
+  76,
+  "en_IN",
+  "English - India",
+  TRUE,
+  &my_locale_typelib_month_names_en_US,
+  &my_locale_typelib_ab_month_names_en_US,
+  &my_locale_typelib_day_names_en_US,
+  &my_locale_typelib_ab_day_names_en_US
+};
 /***** LOCALE END en_IN *****/
 
 /***** LOCALE BEGIN en_NZ: English - New Zealand *****/
 MY_LOCALE my_locale_en_NZ=
- { "en_NZ", "English - New Zealand", TRUE, &my_locale_typelib_month_names_en_US, &my_locale_typelib_ab_month_names_en_US, &my_locale_typelib_day_names_en_US, &my_locale_typelib_ab_day_names_en_US };
+{
+  77,
+  "en_NZ",
+  "English - New Zealand",
+  TRUE,
+  &my_locale_typelib_month_names_en_US,
+  &my_locale_typelib_ab_month_names_en_US,
+  &my_locale_typelib_day_names_en_US,
+  &my_locale_typelib_ab_day_names_en_US
+};
 /***** LOCALE END en_NZ *****/
 
 /***** LOCALE BEGIN en_PH: English - Philippines *****/
 MY_LOCALE my_locale_en_PH=
- { "en_PH", "English - Philippines", TRUE, &my_locale_typelib_month_names_en_US, &my_locale_typelib_ab_month_names_en_US, &my_locale_typelib_day_names_en_US, &my_locale_typelib_ab_day_names_en_US };
+{
+  78,
+  "en_PH",
+  "English - Philippines",
+  TRUE,
+  &my_locale_typelib_month_names_en_US,
+  &my_locale_typelib_ab_month_names_en_US,
+  &my_locale_typelib_day_names_en_US,
+  &my_locale_typelib_ab_day_names_en_US
+};
 /***** LOCALE END en_PH *****/
 
 /***** LOCALE BEGIN en_ZA: English - South Africa *****/
 MY_LOCALE my_locale_en_ZA=
- { "en_ZA", "English - South Africa", TRUE, &my_locale_typelib_month_names_en_US, &my_locale_typelib_ab_month_names_en_US, &my_locale_typelib_day_names_en_US, &my_locale_typelib_ab_day_names_en_US };
+{
+  79,
+  "en_ZA",
+  "English - South Africa",
+  TRUE,
+  &my_locale_typelib_month_names_en_US,
+  &my_locale_typelib_ab_month_names_en_US,
+  &my_locale_typelib_day_names_en_US,
+  &my_locale_typelib_ab_day_names_en_US
+};
 /***** LOCALE END en_ZA *****/
 
 /***** LOCALE BEGIN en_ZW: English - Zimbabwe *****/
 MY_LOCALE my_locale_en_ZW=
- { "en_ZW", "English - Zimbabwe", TRUE, &my_locale_typelib_month_names_en_US, &my_locale_typelib_ab_month_names_en_US, &my_locale_typelib_day_names_en_US, &my_locale_typelib_ab_day_names_en_US };
+{
+  80,
+  "en_ZW",
+  "English - Zimbabwe",
+  TRUE,
+  &my_locale_typelib_month_names_en_US,
+  &my_locale_typelib_ab_month_names_en_US,
+  &my_locale_typelib_day_names_en_US,
+  &my_locale_typelib_ab_day_names_en_US
+};
 /***** LOCALE END en_ZW *****/
 
 /***** LOCALE BEGIN es_AR: Spanish - Argentina *****/
 MY_LOCALE my_locale_es_AR=
- { "es_AR", "Spanish - Argentina", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES };
+{
+  81,
+  "es_AR",
+  "Spanish - Argentina",
+  FALSE,
+  &my_locale_typelib_month_names_es_ES,
+  &my_locale_typelib_ab_month_names_es_ES,
+  &my_locale_typelib_day_names_es_ES,
+  &my_locale_typelib_ab_day_names_es_ES
+};
 /***** LOCALE END es_AR *****/
 
 /***** LOCALE BEGIN es_BO: Spanish - Bolivia *****/
 MY_LOCALE my_locale_es_BO=
- { "es_BO", "Spanish - Bolivia", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES };
+{
+  82,
+  "es_BO",
+  "Spanish - Bolivia",
+  FALSE,
+  &my_locale_typelib_month_names_es_ES,
+  &my_locale_typelib_ab_month_names_es_ES,
+  &my_locale_typelib_day_names_es_ES,
+  &my_locale_typelib_ab_day_names_es_ES
+};
 /***** LOCALE END es_BO *****/
 
 /***** LOCALE BEGIN es_CL: Spanish - Chile *****/
 MY_LOCALE my_locale_es_CL=
- { "es_CL", "Spanish - Chile", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES };
+{
+  83,
+  "es_CL",
+  "Spanish - Chile",
+  FALSE,
+  &my_locale_typelib_month_names_es_ES,
+  &my_locale_typelib_ab_month_names_es_ES,
+  &my_locale_typelib_day_names_es_ES,
+  &my_locale_typelib_ab_day_names_es_ES
+};
 /***** LOCALE END es_CL *****/
 
 /***** LOCALE BEGIN es_CO: Spanish - Columbia *****/
 MY_LOCALE my_locale_es_CO=
- { "es_CO", "Spanish - Columbia", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES };
+{
+  84,
+  "es_CO",
+  "Spanish - Columbia",
+  FALSE,
+  &my_locale_typelib_month_names_es_ES,
+  &my_locale_typelib_ab_month_names_es_ES,
+  &my_locale_typelib_day_names_es_ES,
+  &my_locale_typelib_ab_day_names_es_ES
+};
 /***** LOCALE END es_CO *****/
 
 /***** LOCALE BEGIN es_CR: Spanish - Costa Rica *****/
 MY_LOCALE my_locale_es_CR=
- { "es_CR", "Spanish - Costa Rica", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES };
+{
+  85,
+  "es_CR",
+  "Spanish - Costa Rica",
+  FALSE,
+  &my_locale_typelib_month_names_es_ES,
+  &my_locale_typelib_ab_month_names_es_ES,
+  &my_locale_typelib_day_names_es_ES,
+  &my_locale_typelib_ab_day_names_es_ES
+};
 /***** LOCALE END es_CR *****/
 
 /***** LOCALE BEGIN es_DO: Spanish - Dominican Republic *****/
 MY_LOCALE my_locale_es_DO=
- { "es_DO", "Spanish - Dominican Republic", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES };
+{
+  86,
+  "es_DO",
+  "Spanish - Dominican Republic",
+  FALSE,
+  &my_locale_typelib_month_names_es_ES,
+  &my_locale_typelib_ab_month_names_es_ES,
+  &my_locale_typelib_day_names_es_ES,
+  &my_locale_typelib_ab_day_names_es_ES
+};
 /***** LOCALE END es_DO *****/
 
 /***** LOCALE BEGIN es_EC: Spanish - Ecuador *****/
 MY_LOCALE my_locale_es_EC=
- { "es_EC", "Spanish - Ecuador", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES };
+{
+  87,
+  "es_EC",
+  "Spanish - Ecuador",
+  FALSE,
+  &my_locale_typelib_month_names_es_ES,
+  &my_locale_typelib_ab_month_names_es_ES,
+  &my_locale_typelib_day_names_es_ES,
+  &my_locale_typelib_ab_day_names_es_ES
+};
 /***** LOCALE END es_EC *****/
 
 /***** LOCALE BEGIN es_GT: Spanish - Guatemala *****/
 MY_LOCALE my_locale_es_GT=
- { "es_GT", "Spanish - Guatemala", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES };
+{
+  88,
+  "es_GT",
+  "Spanish - Guatemala",
+  FALSE,
+  &my_locale_typelib_month_names_es_ES,
+  &my_locale_typelib_ab_month_names_es_ES,
+  &my_locale_typelib_day_names_es_ES,
+  &my_locale_typelib_ab_day_names_es_ES
+};
 /***** LOCALE END es_GT *****/
 
 /***** LOCALE BEGIN es_HN: Spanish - Honduras *****/
 MY_LOCALE my_locale_es_HN=
- { "es_HN", "Spanish - Honduras", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES };
+{
+  89,
+  "es_HN",
+  "Spanish - Honduras",
+  FALSE,
+  &my_locale_typelib_month_names_es_ES,
+  &my_locale_typelib_ab_month_names_es_ES,
+  &my_locale_typelib_day_names_es_ES,
+  &my_locale_typelib_ab_day_names_es_ES
+};
 /***** LOCALE END es_HN *****/
 
 /***** LOCALE BEGIN es_MX: Spanish - Mexico *****/
 MY_LOCALE my_locale_es_MX=
- { "es_MX", "Spanish - Mexico", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES };
+{
+  90,
+  "es_MX",
+  "Spanish - Mexico",
+  FALSE,
+  &my_locale_typelib_month_names_es_ES,
+  &my_locale_typelib_ab_month_names_es_ES,
+  &my_locale_typelib_day_names_es_ES,
+  &my_locale_typelib_ab_day_names_es_ES
+};
 /***** LOCALE END es_MX *****/
 
 /***** LOCALE BEGIN es_NI: Spanish - Nicaragua *****/
 MY_LOCALE my_locale_es_NI=
- { "es_NI", "Spanish - Nicaragua", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES };
+{
+  91,
+  "es_NI",
+  "Spanish - Nicaragua",
+  FALSE,
+  &my_locale_typelib_month_names_es_ES,
+  &my_locale_typelib_ab_month_names_es_ES,
+  &my_locale_typelib_day_names_es_ES,
+  &my_locale_typelib_ab_day_names_es_ES
+};
 /***** LOCALE END es_NI *****/
 
 /***** LOCALE BEGIN es_PA: Spanish - Panama *****/
 MY_LOCALE my_locale_es_PA=
- { "es_PA", "Spanish - Panama", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES };
+{
+  92,
+  "es_PA",
+  "Spanish - Panama",
+  FALSE,
+  &my_locale_typelib_month_names_es_ES,
+  &my_locale_typelib_ab_month_names_es_ES,
+  &my_locale_typelib_day_names_es_ES,
+  &my_locale_typelib_ab_day_names_es_ES
+};
 /***** LOCALE END es_PA *****/
 
 /***** LOCALE BEGIN es_PE: Spanish - Peru *****/
 MY_LOCALE my_locale_es_PE=
- { "es_PE", "Spanish - Peru", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES };
+{
+  93,
+  "es_PE",
+  "Spanish - Peru",
+  FALSE,
+  &my_locale_typelib_month_names_es_ES,
+  &my_locale_typelib_ab_month_names_es_ES,
+  &my_locale_typelib_day_names_es_ES,
+  &my_locale_typelib_ab_day_names_es_ES
+};
 /***** LOCALE END es_PE *****/
 
 /***** LOCALE BEGIN es_PR: Spanish - Puerto Rico *****/
 MY_LOCALE my_locale_es_PR=
- { "es_PR", "Spanish - Puerto Rico", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES };
+{
+  94,
+  "es_PR",
+  "Spanish - Puerto Rico",
+  FALSE,
+  &my_locale_typelib_month_names_es_ES,
+  &my_locale_typelib_ab_month_names_es_ES,
+  &my_locale_typelib_day_names_es_ES,
+  &my_locale_typelib_ab_day_names_es_ES
+};
 /***** LOCALE END es_PR *****/
 
 /***** LOCALE BEGIN es_PY: Spanish - Paraguay *****/
 MY_LOCALE my_locale_es_PY=
- { "es_PY", "Spanish - Paraguay", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES };
+{
+  95,
+  "es_PY",
+  "Spanish - Paraguay",
+  FALSE,
+  &my_locale_typelib_month_names_es_ES,
+  &my_locale_typelib_ab_month_names_es_ES,
+  &my_locale_typelib_day_names_es_ES,
+  &my_locale_typelib_ab_day_names_es_ES
+};
 /***** LOCALE END es_PY *****/
 
 /***** LOCALE BEGIN es_SV: Spanish - El Salvador *****/
 MY_LOCALE my_locale_es_SV=
- { "es_SV", "Spanish - El Salvador", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES };
+{
+  96,
+  "es_SV",
+  "Spanish - El Salvador",
+  FALSE,
+  &my_locale_typelib_month_names_es_ES,
+  &my_locale_typelib_ab_month_names_es_ES,
+  &my_locale_typelib_day_names_es_ES,
+  &my_locale_typelib_ab_day_names_es_ES
+};
 /***** LOCALE END es_SV *****/
 
 /***** LOCALE BEGIN es_US: Spanish - United States *****/
 MY_LOCALE my_locale_es_US=
- { "es_US", "Spanish - United States", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES };
+{
+  97,
+  "es_US",
+  "Spanish - United States",
+  FALSE,
+  &my_locale_typelib_month_names_es_ES,
+  &my_locale_typelib_ab_month_names_es_ES,
+  &my_locale_typelib_day_names_es_ES,
+  &my_locale_typelib_ab_day_names_es_ES
+};
 /***** LOCALE END es_US *****/
 
 /***** LOCALE BEGIN es_UY: Spanish - Uruguay *****/
 MY_LOCALE my_locale_es_UY=
- { "es_UY", "Spanish - Uruguay", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES };
+{
+  98,
+  "es_UY",
+  "Spanish - Uruguay",
+  FALSE,
+  &my_locale_typelib_month_names_es_ES,
+  &my_locale_typelib_ab_month_names_es_ES,
+  &my_locale_typelib_day_names_es_ES,
+  &my_locale_typelib_ab_day_names_es_ES
+};
 /***** LOCALE END es_UY *****/
 
 /***** LOCALE BEGIN es_VE: Spanish - Venezuela *****/
 MY_LOCALE my_locale_es_VE=
- { "es_VE", "Spanish - Venezuela", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES };
+{
+  99,
+  "es_VE",
+  "Spanish - Venezuela",
+  FALSE,
+  &my_locale_typelib_month_names_es_ES,
+  &my_locale_typelib_ab_month_names_es_ES,
+  &my_locale_typelib_day_names_es_ES,
+  &my_locale_typelib_ab_day_names_es_ES
+};
 /***** LOCALE END es_VE *****/
 
 /***** LOCALE BEGIN fr_BE: French - Belgium *****/
 MY_LOCALE my_locale_fr_BE=
- { "fr_BE", "French - Belgium", FALSE, &my_locale_typelib_month_names_fr_FR, &my_locale_typelib_ab_month_names_fr_FR, &my_locale_typelib_day_names_fr_FR, &my_locale_typelib_ab_day_names_fr_FR };
+{
+  100,
+  "fr_BE",
+  "French - Belgium",
+  FALSE,
+  &my_locale_typelib_month_names_fr_FR,
+  &my_locale_typelib_ab_month_names_fr_FR,
+  &my_locale_typelib_day_names_fr_FR,
+  &my_locale_typelib_ab_day_names_fr_FR
+};
 /***** LOCALE END fr_BE *****/
 
 /***** LOCALE BEGIN fr_CA: French - Canada *****/
 MY_LOCALE my_locale_fr_CA=
- { "fr_CA", "French - Canada", FALSE, &my_locale_typelib_month_names_fr_FR, &my_locale_typelib_ab_month_names_fr_FR, &my_locale_typelib_day_names_fr_FR, &my_locale_typelib_ab_day_names_fr_FR };
+{
+  101,
+  "fr_CA",
+  "French - Canada",
+  FALSE,
+  &my_locale_typelib_month_names_fr_FR,
+  &my_locale_typelib_ab_month_names_fr_FR,
+  &my_locale_typelib_day_names_fr_FR,
+  &my_locale_typelib_ab_day_names_fr_FR
+};
 /***** LOCALE END fr_CA *****/
 
 /***** LOCALE BEGIN fr_CH: French - Switzerland *****/
 MY_LOCALE my_locale_fr_CH=
- { "fr_CH", "French - Switzerland", FALSE, &my_locale_typelib_month_names_fr_FR, &my_locale_typelib_ab_month_names_fr_FR, &my_locale_typelib_day_names_fr_FR, &my_locale_typelib_ab_day_names_fr_FR };
+{
+  102,
+  "fr_CH",
+  "French - Switzerland",
+  FALSE,
+  &my_locale_typelib_month_names_fr_FR,
+  &my_locale_typelib_ab_month_names_fr_FR,
+  &my_locale_typelib_day_names_fr_FR,
+  &my_locale_typelib_ab_day_names_fr_FR
+};
 /***** LOCALE END fr_CH *****/
 
 /***** LOCALE BEGIN fr_LU: French - Luxembourg *****/
 MY_LOCALE my_locale_fr_LU=
- { "fr_LU", "French - Luxembourg", FALSE, &my_locale_typelib_month_names_fr_FR, &my_locale_typelib_ab_month_names_fr_FR, &my_locale_typelib_day_names_fr_FR, &my_locale_typelib_ab_day_names_fr_FR };
+{
+  103,
+  "fr_LU",
+  "French - Luxembourg",
+  FALSE,
+  &my_locale_typelib_month_names_fr_FR,
+  &my_locale_typelib_ab_month_names_fr_FR,
+  &my_locale_typelib_day_names_fr_FR,
+  &my_locale_typelib_ab_day_names_fr_FR
+};
 /***** LOCALE END fr_LU *****/
 
 /***** LOCALE BEGIN it_IT: Italian - Italy *****/
 MY_LOCALE my_locale_it_IT=
- { "it_IT", "Italian - Italy", FALSE, &my_locale_typelib_month_names_it_CH, &my_locale_typelib_ab_month_names_it_CH, &my_locale_typelib_day_names_it_CH, &my_locale_typelib_ab_day_names_it_CH };
+{
+  104,
+  "it_IT",
+  "Italian - Italy",
+  FALSE,
+  &my_locale_typelib_month_names_it_CH,
+  &my_locale_typelib_ab_month_names_it_CH,
+  &my_locale_typelib_day_names_it_CH,
+  &my_locale_typelib_ab_day_names_it_CH
+};
 /***** LOCALE END it_IT *****/
 
 /***** LOCALE BEGIN nl_BE: Dutch - Belgium *****/
 MY_LOCALE my_locale_nl_BE=
- { "nl_BE", "Dutch - Belgium", TRUE, &my_locale_typelib_month_names_nl_NL, &my_locale_typelib_ab_month_names_nl_NL, &my_locale_typelib_day_names_nl_NL, &my_locale_typelib_ab_day_names_nl_NL };
+{
+  105,
+  "nl_BE",
+  "Dutch - Belgium",
+  TRUE,
+  &my_locale_typelib_month_names_nl_NL,
+  &my_locale_typelib_ab_month_names_nl_NL,
+  &my_locale_typelib_day_names_nl_NL,
+  &my_locale_typelib_ab_day_names_nl_NL
+};
 /***** LOCALE END nl_BE *****/
 
 /***** LOCALE BEGIN no_NO: Norwegian - Norway *****/
 MY_LOCALE my_locale_no_NO=
- { "no_NO", "Norwegian - Norway", FALSE, &my_locale_typelib_month_names_nb_NO, &my_locale_typelib_ab_month_names_nb_NO, &my_locale_typelib_day_names_nb_NO, &my_locale_typelib_ab_day_names_nb_NO };
+{
+  106,
+  "no_NO",
+  "Norwegian - Norway",
+  FALSE,
+  &my_locale_typelib_month_names_nb_NO,
+  &my_locale_typelib_ab_month_names_nb_NO,
+  &my_locale_typelib_day_names_nb_NO,
+  &my_locale_typelib_ab_day_names_nb_NO
+};
 /***** LOCALE END no_NO *****/
 
 /***** LOCALE BEGIN sv_FI: Swedish - Finland *****/
 MY_LOCALE my_locale_sv_FI=
- { "sv_FI", "Swedish - Finland", FALSE, &my_locale_typelib_month_names_sv_SE, &my_locale_typelib_ab_month_names_sv_SE, &my_locale_typelib_day_names_sv_SE, &my_locale_typelib_ab_day_names_sv_SE };
+{
+  107,
+  "sv_FI",
+  "Swedish - Finland",
+  FALSE,
+  &my_locale_typelib_month_names_sv_SE,
+  &my_locale_typelib_ab_month_names_sv_SE,
+  &my_locale_typelib_day_names_sv_SE,
+  &my_locale_typelib_ab_day_names_sv_SE
+};
 /***** LOCALE END sv_FI *****/
 
 /***** LOCALE BEGIN zh_HK: Chinese - Hong Kong SAR *****/
 MY_LOCALE my_locale_zh_HK=
- { "zh_HK", "Chinese - Hong Kong SAR", FALSE, &my_locale_typelib_month_names_zh_CN, &my_locale_typelib_ab_month_names_zh_CN, &my_locale_typelib_day_names_zh_CN, &my_locale_typelib_ab_day_names_zh_CN };
+{
+  108,
+  "zh_HK",
+  "Chinese - Hong Kong SAR",
+  FALSE,
+  &my_locale_typelib_month_names_zh_CN,
+  &my_locale_typelib_ab_month_names_zh_CN,
+  &my_locale_typelib_day_names_zh_CN,
+  &my_locale_typelib_ab_day_names_zh_CN
+};
 /***** LOCALE END zh_HK *****/
 
+
+/*
+  The list of all locales.
+  Note, locales must be ordered according to their
+  numbers to make my_locale_by_number() work fast.
+  Some debug asserts below check this.
+*/
 MY_LOCALE *my_locales[]=
   {
     &my_locale_en_US,
@@ -1605,3 +2582,31 @@ MY_LOCALE *my_locales[]=
     &my_locale_zh_HK,
     NULL 
   };
+
+
+MY_LOCALE *my_locale_by_number(uint number)
+{
+  MY_LOCALE *locale;
+  if (number >= array_elements(my_locales) - 1)
+    return NULL;
+  locale= my_locales[number];
+  // Check that locale is on its correct position in the array
+  DBUG_ASSERT(locale == my_locales[locale->number]);
+  return locale;
+}
+
+
+MY_LOCALE *my_locale_by_name(const char *name)
+{
+  MY_LOCALE **locale;
+  for (locale= my_locales; *locale != NULL; locale++) 
+  {
+    if (!my_strcasecmp(&my_charset_latin1, (*locale)->name, name))
+    {
+      // Check that locale is on its correct position in the array
+      DBUG_ASSERT((*locale) == my_locales[(*locale)->number]);
+      return *locale;
+    }
+  }
+  return NULL;
+}
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 19add72c23ef314c754d7fd765b8d82b85c7161a..f3f1041774c5e9caa0db08f9666495432352c8cc 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -1958,6 +1958,7 @@ static void reset_one_shot_variables(THD *thd)
   thd->update_charset();
   thd->variables.time_zone=
     global_system_variables.time_zone;
+  thd->variables.lc_time_names= &my_locale_en_US;
   thd->one_shot_set= 0;
 }
 
@@ -2478,19 +2479,36 @@ mysql_execute_command(THD *thd)
     }
     /* Skip first table, which is the table we are creating */
     TABLE_LIST *create_table, *create_table_local;
+    /*
+      Code below (especially in mysql_create_table() and select_create
+      methods) may modify HA_CREATE_INFO structure in LEX, so we have to
+      use a copy of this structure to make execution prepared statement-
+      safe. A shallow copy is enough as this code won't modify any memory
+      referenced from this structure.
+    */
+    HA_CREATE_INFO create_info(lex->create_info);
+    Alter_info alter_info(lex->alter_info, thd->mem_root);
+
+    if (thd->is_fatal_error)
+    {
+      /* out of memory when creating a copy of alter_info */
+      res= 1;
+      goto unsent_create_error;
+    }
     tables= lex->unlink_first_table(tables, &create_table,
 				    &create_table_local);
 
     if ((res= create_table_precheck(thd, tables, create_table)))
       goto unsent_create_error;
 
+    create_info.alias= create_table->alias;
 #ifndef HAVE_READLINK
-    lex->create_info.data_file_name=lex->create_info.index_file_name=0;
+    create_info.data_file_name= create_info.index_file_name= NULL;
 #else
     /* Fix names if symlinked tables */
-    if (append_file_to_dir(thd, &lex->create_info.data_file_name,
+    if (append_file_to_dir(thd, &create_info.data_file_name,
 			   create_table->real_name) ||
-	append_file_to_dir(thd,&lex->create_info.index_file_name,
+	append_file_to_dir(thd, &create_info.index_file_name,
 			   create_table->real_name))
     {
       res=-1;
@@ -2501,14 +2519,14 @@ mysql_execute_command(THD *thd)
       If we are using SET CHARSET without DEFAULT, add an implicite
       DEFAULT to not confuse old users. (This may change).
     */
-    if ((lex->create_info.used_fields & 
+    if ((create_info.used_fields &
 	 (HA_CREATE_USED_DEFAULT_CHARSET | HA_CREATE_USED_CHARSET)) ==
 	HA_CREATE_USED_CHARSET)
     {
-      lex->create_info.used_fields&= ~HA_CREATE_USED_CHARSET;
-      lex->create_info.used_fields|= HA_CREATE_USED_DEFAULT_CHARSET;
-      lex->create_info.default_table_charset= lex->create_info.table_charset;
-      lex->create_info.table_charset= 0;
+      create_info.used_fields&= ~HA_CREATE_USED_CHARSET;
+      create_info.used_fields|= HA_CREATE_USED_DEFAULT_CHARSET;
+      create_info.default_table_charset= create_info.table_charset;
+      create_info.table_charset= 0;
     }
     /*
       The create-select command will open and read-lock the select table
@@ -2542,11 +2560,14 @@ mysql_execute_command(THD *thd)
       if (!(res=open_and_lock_tables(thd,tables)))
       {
 	res= -1;				// If error
+        /*
+          select_create is currently not re-execution friendly and
+          needs to be created for every execution of a PS/SP.
+        */
         if ((result=new select_create(create_table->db,
                                       create_table->real_name,
-				      &lex->create_info,
-                                      lex->create_list,
-                                      lex->key_list,
+                                      &create_info,
+                                      &alter_info,
                                       select_lex->item_list, lex->duplicates,
                                       lex->ignore)))
         {
@@ -2558,22 +2579,18 @@ mysql_execute_command(THD *thd)
           res=handle_select(thd, lex, result);
           select_lex->resolve_mode= SELECT_LEX::NOMATTER_MODE;
         }
-	//reset for PS
-	lex->create_list.empty();
-	lex->key_list.empty();
       }
     }
     else // regular create
     {
       if (lex->name)
-        res= mysql_create_like_table(thd, create_table, &lex->create_info, 
+        res= mysql_create_like_table(thd, create_table, &create_info,
                                      (Table_ident *)lex->name); 
       else
       {
-        res= mysql_create_table(thd,create_table->db,
-			         create_table->real_name, &lex->create_info,
-			         lex->create_list,
-			         lex->key_list,0,0);
+        res= mysql_create_table(thd, create_table->db,
+                                create_table->real_name, &create_info,
+                                &alter_info, 0, 0);
       }
       if (!res)
 	send_ok(thd);
@@ -2591,15 +2608,49 @@ mysql_execute_command(THD *thd)
     break;
   }
   case SQLCOM_CREATE_INDEX:
+    /* Fall through */
+  case SQLCOM_DROP_INDEX:
+  /*
+    CREATE INDEX and DROP INDEX are implemented by calling ALTER
+    TABLE with proper arguments. This isn't very fast but it
+    should work for most cases.
+
+    In the future ALTER TABLE will notice that only added
+    indexes and create these one by one for the existing table
+    without having to do a full rebuild.
+
+    One should normally create all indexes with CREATE TABLE or
+    ALTER TABLE.
+  */
+  {
+    Alter_info alter_info(lex->alter_info, thd->mem_root);
+    HA_CREATE_INFO create_info;
+
+    if (thd->is_fatal_error) /* out of memory creating a copy of alter_info*/
+      goto error;
+
     if (check_one_table_access(thd, INDEX_ACL, tables))
       goto error; /* purecov: inspected */
     thd->enable_slow_log= opt_log_slow_admin_statements;
     if (end_active_trans(thd))
-      res= -1;
-    else
-      res = mysql_create_index(thd, tables, lex->key_list);
-    break;
+      goto error;
+    /*
+      Currently CREATE INDEX or DROP INDEX cause a full table rebuild
+      and thus classify as slow administrative statements just like
+      ALTER TABLE.
+    */
+    thd->enable_slow_log= opt_log_slow_admin_statements;
+
+    bzero((char*) &create_info, sizeof(create_info));
+    create_info.db_type= DB_TYPE_DEFAULT;
+    create_info.row_type= ROW_TYPE_NOT_USED;
+    create_info.default_table_charset= thd->variables.collation_database;
 
+    res= mysql_alter_table(thd, tables->db, tables->real_name,
+                           &create_info, tables, &alter_info,
+                           0, (ORDER*)0, DUP_ERROR, 0);
+    break;
+  }
 #ifdef HAVE_REPLICATION
   case SQLCOM_SLAVE_START:
   {
@@ -2642,6 +2693,17 @@ mysql_execute_command(THD *thd)
 #else
     {
       ulong priv=0;
+      /*
+        Code in mysql_alter_table() may modify its HA_CREATE_INFO argument,
+        so we have to use a copy of this structure to make execution
+        prepared statement- safe. A shallow copy is enough as no memory
+        referenced from this structure will be modified.
+      */
+      HA_CREATE_INFO create_info(lex->create_info);
+      Alter_info alter_info(lex->alter_info, thd->mem_root);
+
+      if (thd->is_fatal_error) /* out of memory creating a copy of alter_info */
+        goto error;
       if (lex->name && (!lex->name[0] || strlen(lex->name) > NAME_LEN))
       {
 	net_printf(thd, ER_WRONG_TABLE_NAME, lex->name);
@@ -2655,7 +2717,7 @@ mysql_execute_command(THD *thd)
           default database if the new name is not explicitly qualified
           by a database. (Bug #11493)
         */
-        if (lex->alter_info.flags & ALTER_RENAME)
+        if (alter_info.flags & ALTER_RENAME)
         {
           if (! thd->db)
           {
@@ -2671,7 +2733,7 @@ mysql_execute_command(THD *thd)
 	  check_access(thd,INSERT_ACL | CREATE_ACL,select_lex->db,&priv,0,0)||
 	  check_merge_table_access(thd, tables->db,
 				   (TABLE_LIST *)
-				   lex->create_info.merge_list.first))
+				   create_info.merge_list.first))
 	goto error;				/* purecov: inspected */
       if (grant_option)
       {
@@ -2690,26 +2752,26 @@ mysql_execute_command(THD *thd)
 	}
       }
       /* Don't yet allow changing of symlinks with ALTER TABLE */
-      if (lex->create_info.data_file_name)
+      if (create_info.data_file_name)
         push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0,
                      "DATA DIRECTORY option ignored");
-      if (lex->create_info.index_file_name)
+      if (create_info.index_file_name)
         push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0,
                      "INDEX DIRECTORY option ignored");
-      lex->create_info.data_file_name=lex->create_info.index_file_name=0;
+      create_info.data_file_name= create_info.index_file_name= NULL;
       /* ALTER TABLE ends previous transaction */
       if (end_active_trans(thd))
 	res= -1;
       else
       {
         thd->enable_slow_log= opt_log_slow_admin_statements;
-	res= mysql_alter_table(thd, select_lex->db, lex->name,
-			       &lex->create_info,
-			       tables, lex->create_list,
-			       lex->key_list,
-			       select_lex->order_list.elements,
+        res= mysql_alter_table(thd, select_lex->db, lex->name,
+                               &create_info,
+                               tables,
+                               &alter_info,
+                               select_lex->order_list.elements,
                                (ORDER *) select_lex->order_list.first,
-			       lex->duplicates, lex->ignore, &lex->alter_info);
+                               lex->duplicates, lex->ignore);
       }
       break;
     }
@@ -2846,7 +2908,7 @@ mysql_execute_command(THD *thd)
       goto error; /* purecov: inspected */
     thd->enable_slow_log= opt_log_slow_admin_statements;
     res= (specialflag & (SPECIAL_SAFE_MODE | SPECIAL_NO_NEW_FUNC)) ?
-      mysql_recreate_table(thd, tables, 1) :
+      mysql_recreate_table(thd, tables) :
       mysql_optimize_table(thd, tables, &lex->check_opt);
     /* ! we write after unlocking the table */
     if (!res && !lex->no_write_to_binlog)
@@ -3123,14 +3185,6 @@ mysql_execute_command(THD *thd)
     res= mysql_rm_table(thd,tables,lex->drop_if_exists, lex->drop_temporary);
   }
   break;
-  case SQLCOM_DROP_INDEX:
-    if (check_one_table_access(thd, INDEX_ACL, tables))
-      goto error;				/* purecov: inspected */
-    if (end_active_trans(thd))
-      res= -1;
-    else
-      res = mysql_drop_index(thd, tables, &lex->alter_info);
-    break;
   case SQLCOM_SHOW_DATABASES:
 #if defined(DONT_ALLOW_SHOW_COMMANDS)
     send_error(thd,ER_NOT_ALLOWED_COMMAND);   /* purecov: inspected */
@@ -3363,6 +3417,12 @@ purposes internal to the MySQL server", MYF(0));
     break;
   case SQLCOM_CREATE_DB:
   {
+    /*
+      As mysql_create_db() may modify HA_CREATE_INFO structure passed to
+      it, we need to use a copy of LEX::create_info to make execution
+      prepared statement- safe.
+    */
+    HA_CREATE_INFO create_info(lex->create_info);
     if (end_active_trans(thd))
     {
       res= -1;
@@ -3393,7 +3453,7 @@ purposes internal to the MySQL server", MYF(0));
     if (check_access(thd,CREATE_ACL,lex->name,0,1,0))
       break;
     res= mysql_create_db(thd,(lower_case_table_names == 2 ? alias : lex->name),
-			 &lex->create_info, 0);
+			 &create_info, 0);
     break;
   }
   case SQLCOM_DROP_DB:
@@ -4443,15 +4503,17 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type,
   if (type_modifier & PRI_KEY_FLAG)
   {
     lex->col_list.push_back(new key_part_spec(field_name,0));
-    lex->key_list.push_back(new Key(Key::PRIMARY, NullS, HA_KEY_ALG_UNDEF,
-				    0, lex->col_list));
+    lex->alter_info.key_list.push_back(new Key(Key::PRIMARY, NullS,
+                                               HA_KEY_ALG_UNDEF, 0,
+                                               lex->col_list));
     lex->col_list.empty();
   }
   if (type_modifier & (UNIQUE_FLAG | UNIQUE_KEY_FLAG))
   {
     lex->col_list.push_back(new key_part_spec(field_name,0));
-    lex->key_list.push_back(new Key(Key::UNIQUE, NullS, HA_KEY_ALG_UNDEF, 0,
-				    lex->col_list));
+    lex->alter_info.key_list.push_back(new Key(Key::UNIQUE, NullS,
+                                               HA_KEY_ALG_UNDEF, 0,
+                                               lex->col_list));
     lex->col_list.empty();
   }
 
@@ -4778,7 +4840,7 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type,
 					    new_field->sql_type,
 					    new_field->length);
   new_field->char_length= new_field->length;
-  lex->create_list.push_back(new_field);
+  lex->alter_info.create_list.push_back(new_field);
   lex->last_field=new_field;
   DBUG_RETURN(0);
 }
@@ -5458,57 +5520,6 @@ Item * all_any_subquery_creator(Item *left_expr,
 }
 
 
-/*
-  CREATE INDEX and DROP INDEX are implemented by calling ALTER TABLE with
-  the proper arguments.  This isn't very fast but it should work for most
-  cases.
-
-  In the future ALTER TABLE will notice that only added indexes
-  and create these one by one for the existing table without having to do
-  a full rebuild.
-
-  One should normally create all indexes with CREATE TABLE or ALTER TABLE.
-*/
-
-int mysql_create_index(THD *thd, TABLE_LIST *table_list, List<Key> &keys)
-{
-  List<create_field> fields;
-  ALTER_INFO alter_info;
-  alter_info.flags= ALTER_ADD_INDEX;
-  alter_info.is_simple= 0;
-  HA_CREATE_INFO create_info;
-  DBUG_ENTER("mysql_create_index");
-  bzero((char*) &create_info,sizeof(create_info));
-  create_info.db_type=DB_TYPE_DEFAULT;
-  create_info.default_table_charset= thd->variables.collation_database;
-  create_info.row_type= ROW_TYPE_NOT_USED;
-  DBUG_RETURN(mysql_alter_table(thd,table_list->db,table_list->real_name,
-				&create_info, table_list,
-				fields, keys, 0, (ORDER*)0,
-				DUP_ERROR, 0, &alter_info));
-}
-
-
-int mysql_drop_index(THD *thd, TABLE_LIST *table_list, ALTER_INFO *alter_info)
-{
-  List<create_field> fields;
-  List<Key> keys;
-  HA_CREATE_INFO create_info;
-  DBUG_ENTER("mysql_drop_index");
-  bzero((char*) &create_info,sizeof(create_info));
-  create_info.db_type=DB_TYPE_DEFAULT;
-  create_info.default_table_charset= thd->variables.collation_database;
-  create_info.row_type= ROW_TYPE_NOT_USED;
-  alter_info->clear();
-  alter_info->flags= ALTER_DROP_INDEX;
-  alter_info->is_simple= 0;
-  DBUG_RETURN(mysql_alter_table(thd,table_list->db,table_list->real_name,
-				&create_info, table_list,
-				fields, keys, 0, (ORDER*)0,
-				DUP_ERROR, 0, alter_info));
-}
-
-
 /*
   Multi update query pre-check
 
@@ -5791,7 +5802,6 @@ int create_table_precheck(THD *thd, TABLE_LIST *tables,
 
   want_priv= ((lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) ?
               CREATE_TMP_ACL : CREATE_ACL);
-  lex->create_info.alias= create_table->alias;
   if (check_access(thd, want_priv, create_table->db,
 		   &create_table->grant.privilege, 0, 0) ||
       check_merge_table_access(thd, create_table->db,
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 41e145790e9793e4ef94bc28cb428673ab24d3ac..494c10f6e6b39827edda7d81a942f796d0adf79f 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -845,7 +845,7 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
 }
 
 int mysqld_show_create_db(THD *thd, char *dbname,
-			  HA_CREATE_INFO *create_info)
+			  const HA_CREATE_INFO *create_info)
 {
   int length;
   char	path[FN_REFLEN];
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index f82dd627101bf2c58c1318df697012384606e43b..0316d6a3c10d48f08094649718df73bcb045fc88 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -456,8 +456,7 @@ void calculate_interval_lengths(CHARSET_INFO *cs, TYPELIB *interval,
     mysql_prepare_table()
     thd			Thread object
     create_info		Create information (like MAX_ROWS)
-    fields		List of fields to create
-    keys		List of keys to create
+    alter_info          List of columns and indexes to create
 
   DESCRIPTION
     Prepares the table and key structures for table creation.
@@ -468,8 +467,8 @@ void calculate_interval_lengths(CHARSET_INFO *cs, TYPELIB *interval,
 */
 
 int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
-			List<create_field> &fields,
-			List<Key> &keys, bool tmp_table, uint &db_options,
+                        Alter_info *alter_info,
+			bool tmp_table, uint &db_options,
 			handler *file, KEY *&key_info_buffer,
 			uint *key_count, int select_field_count)
 {
@@ -482,10 +481,11 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
   int		timestamps= 0, timestamps_with_niladic= 0;
   int		field_no,dup_no;
   int		select_field_pos,auto_increment=0;
+  List_iterator<create_field> it(alter_info->create_list);
+  List_iterator<create_field> it2(alter_info->create_list);
   DBUG_ENTER("mysql_prepare_table");
 
-  List_iterator<create_field> it(fields),it2(fields);
-  select_field_pos=fields.elements - select_field_count;
+  select_field_pos= alter_info->create_list.elements - select_field_count;
   null_fields=blob_columns=0;
 
   for (field_no=0; (sql_field=it++) ; field_no++)
@@ -883,7 +883,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
 
   /* Create keys */
 
-  List_iterator<Key> key_iterator(keys), key_iterator2(keys);
+  List_iterator<Key> key_iterator(alter_info->key_list);
+  List_iterator<Key> key_iterator2(alter_info->key_list);
   uint key_parts=0, fk_key_count=0;
   bool primary_key=0,unique_key=0;
   Key *key, *key2;
@@ -1333,23 +1334,27 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
 
   SYNOPSIS
     mysql_create_table()
-    thd			Thread object
-    db			Database
-    table_name		Table name
-    create_info		Create information (like MAX_ROWS)
-    fields		List of fields to create
-    keys		List of keys to create
-    tmp_table		Set to 1 if this is an internal temporary table
-			(From ALTER TABLE)
+    thd                  Thread object
+    db                   Database
+    table_name           Table name
+    create_info [in/out] Create information (like MAX_ROWS)
+    alter_info  [in/out] List of columns and indexes to create
+    tmp_table            Set to 1 if this is an internal temporary table
+                         (From ALTER TABLE)
 
   DESCRIPTION
-    If one creates a temporary table, this is automaticly opened
+    If one creates a temporary table, this is automatically opened
 
     no_log is needed for the case of CREATE ... SELECT,
     as the logging will be done later in sql_insert.cc
     select_field_count is also used for CREATE ... SELECT,
     and must be zero for standard create of table.
 
+    Note that structures passed as 'create_info' and 'alter_info' parameters
+    may be modified by this function. It is responsibility of the caller to
+    make a copy of create_info in order to provide correct execution in
+    prepared statements/stored routines.
+
   RETURN VALUES
     0	ok
     -1	error
@@ -1357,8 +1362,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
 
 int mysql_create_table(THD *thd,const char *db, const char *table_name,
 		       HA_CREATE_INFO *create_info,
-		       List<create_field> &fields,
-		       List<Key> &keys,bool tmp_table,
+                       Alter_info *alter_info,
+                       bool tmp_table,
 		       uint select_field_count)
 {
   char		path[FN_REFLEN];
@@ -1371,7 +1376,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
   DBUG_ENTER("mysql_create_table");
 
   /* Check for duplicate fields and check type of table to create */
-  if (!fields.elements)
+  if (!alter_info->create_list.elements)
   {
     my_error(ER_TABLE_MUST_HAVE_COLUMNS,MYF(0));
     DBUG_RETURN(-1);
@@ -1423,10 +1428,10 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
     create_info->default_table_charset= db_info.default_table_charset;
   }
 
-  if (mysql_prepare_table(thd, create_info, fields,
-			  keys, tmp_table, db_options, file,
-			  key_info_buffer, &key_count,
-			  select_field_count))
+  if (mysql_prepare_table(thd, create_info, alter_info, tmp_table,
+                          db_options, file,
+                          key_info_buffer, &key_count,
+                          select_field_count))
     DBUG_RETURN(-1);
 
       /* Check if table exists */
@@ -1503,8 +1508,8 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
   create_info->table_options=db_options;
 
   if (rea_create_table(thd, path, db, table_name,
-                       create_info, fields, key_count,
-		       key_info_buffer))
+                       create_info, alter_info->create_list,
+                       key_count, key_info_buffer))
     goto end;
   if (create_info->options & HA_LEX_CREATE_TMP_TABLE)
   {
@@ -1592,8 +1597,7 @@ make_unique_key_name(const char *field_name,KEY *start,KEY *end)
 
 TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
 			       const char *db, const char *name,
-			       List<create_field> *extra_fields,
-			       List<Key> *keys,
+                               Alter_info *alter_info,
 			       List<Item> *items,
 			       MYSQL_LOCK **lock)
 {
@@ -1627,7 +1631,7 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
 					   ((Item_field *)item)->field :
 					   (Field*) 0))))
       DBUG_RETURN(0);
-    extra_fields->push_back(cr_field);
+    alter_info->create_list.push_back(cr_field);
   }
   /* create and lock table */
   /* QQ: create and open should be done atomic ! */
@@ -1641,8 +1645,8 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
     open_table().
   */
   tmp_disable_binlog(thd);
-  if (!mysql_create_table(thd,db,name,create_info,*extra_fields,
-			 *keys,0,select_field_count))
+  if (!mysql_create_table(thd, db, name, create_info, alter_info,
+                          0, select_field_count))
   {
     if (!(table=open_table(thd,db,name,name,(bool*) 0)))
       quick_rm_table(create_info->db_type,db,table_case_name(create_info,name));
@@ -2146,6 +2150,7 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
 
     case HA_ADMIN_TRY_ALTER:
     {
+      my_bool save_no_send_ok= thd->net.no_send_ok;
       /*
         This is currently used only by InnoDB. ha_innobase::optimize() answers
         "try with alter", so here we close the table, do an ALTER TABLE,
@@ -2155,7 +2160,9 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
       TABLE_LIST *save_next= table->next;
       table->next= 0;
       tmp_disable_binlog(thd); // binlogging is done by caller if wanted
-      result_code= mysql_recreate_table(thd, table, 0);
+      thd->net.no_send_ok= TRUE;
+      result_code= mysql_recreate_table(thd, table);
+      thd->net.no_send_ok= save_no_send_ok;
       reenable_binlog(thd);
       close_thread_tables(thd);
       if (!result_code) // recreation went ok
@@ -2635,206 +2642,6 @@ mysql_discard_or_import_tablespace(THD *thd,
 }
 
 
-#ifdef NOT_USED
-/*
-  CREATE INDEX and DROP INDEX are implemented by calling ALTER TABLE with
-  the proper arguments.  This isn't very fast but it should work for most
-  cases.
-  One should normally create all indexes with CREATE TABLE or ALTER TABLE.
-*/
-
-int mysql_create_indexes(THD *thd, TABLE_LIST *table_list, List<Key> &keys)
-{
-  List<create_field> fields;
-  List<Alter_drop>   drop;
-  List<Alter_column> alter;
-  HA_CREATE_INFO     create_info;
-  int		     rc;
-  uint		     idx;
-  uint		     db_options;
-  uint		     key_count;
-  TABLE		     *table;
-  Field		     **f_ptr;
-  KEY		     *key_info_buffer;
-  char		     path[FN_REFLEN+1];
-  DBUG_ENTER("mysql_create_index");
-
-  /*
-    Try to use online generation of index.
-    This requires that all indexes can be created online.
-    Otherwise, the old alter table procedure is executed.
-
-    Open the table to have access to the correct table handler.
-  */
-  if (!(table=open_ltable(thd,table_list,TL_WRITE_ALLOW_READ)))
-    DBUG_RETURN(-1);
-
-  /*
-    The add_index method takes an array of KEY structs for the new indexes.
-    Preparing a new table structure generates this array.
-    It needs a list with all fields of the table, which does not need to
-    be correct in every respect. The field names are important.
-  */
-  for (f_ptr= table->field; *f_ptr; f_ptr++)
-  {
-    create_field *c_fld= new create_field(*f_ptr, *f_ptr);
-    c_fld->unireg_check= Field::NONE; /*avoid multiple auto_increments*/
-    fields.push_back(c_fld);
-  }
-  bzero((char*) &create_info,sizeof(create_info));
-  create_info.db_type=DB_TYPE_DEFAULT;
-  create_info.default_table_charset= thd->variables.collation_database;
-  db_options= 0;
-  if (mysql_prepare_table(thd, &create_info, fields,
-			  keys, /*tmp_table*/ 0, db_options, table->file,
-			  key_info_buffer, key_count,
-			  /*select_field_count*/ 0))
-    DBUG_RETURN(-1);
-
-  /*
-    Check if all keys can be generated with the add_index method.
-    If anyone cannot, then take the old way.
-  */
-  for (idx=0; idx< key_count; idx++)
-  {
-    DBUG_PRINT("info", ("creating index %s", key_info_buffer[idx].name));
-    if (!(table->file->index_ddl_flags(key_info_buffer+idx)&
-	  (HA_DDL_ONLINE| HA_DDL_WITH_LOCK)))
-      break ;
-  }
-  if ((idx < key_count)|| !key_count)
-  {
-    /* Re-initialize the create_info, which was changed by prepare table. */
-    bzero((char*) &create_info,sizeof(create_info));
-    create_info.db_type=DB_TYPE_DEFAULT;
-    create_info.default_table_charset= thd->variables.collation_database;
-    /* Cleanup the fields list. We do not want to create existing fields. */
-    fields.delete_elements();
-    if (real_alter_table(thd, table_list->db, table_list->real_name,
-			 &create_info, table_list, table,
-			 fields, keys, drop, alter, 0, (ORDER*)0,
-			 ALTER_ADD_INDEX, DUP_ERROR))
-      /* Don't need to free((gptr) key_info_buffer);*/
-      DBUG_RETURN(-1);
-  }
-  else
-  {
-    if (table->file->add_index(table, key_info_buffer, key_count)||
-        build_table_path(path, sizeof(path), table_list->db,
-                         (lower_case_table_names == 2) ?
-                         table_list->alias : table_list->real_name,
-                         reg_ext) == 0 ||
-	mysql_create_frm(thd, path, &create_info,
-			 fields, key_count, key_info_buffer, table->file))
-      /* don't need to free((gptr) key_info_buffer);*/
-      DBUG_RETURN(-1);
-  }
-  /* don't need to free((gptr) key_info_buffer);*/
-  DBUG_RETURN(0);
-}
-
-
-int mysql_drop_indexes(THD *thd, TABLE_LIST *table_list,
-		       List<Alter_drop> &drop)
-{
-  List<create_field> fields;
-  List<Key>	     keys;
-  List<Alter_column> alter;
-  HA_CREATE_INFO     create_info;
-  uint		     idx;
-  uint		     db_options;
-  uint		     key_count;
-  uint		     *key_numbers;
-  TABLE		     *table;
-  Field		     **f_ptr;
-  KEY		     *key_info;
-  KEY		     *key_info_buffer;
-  char		     path[FN_REFLEN];
-  DBUG_ENTER("mysql_drop_index");
-
-  /*
-    Try to use online generation of index.
-    This requires that all indexes can be created online.
-    Otherwise, the old alter table procedure is executed.
-
-    Open the table to have access to the correct table handler.
-  */
-  if (!(table=open_ltable(thd,table_list,TL_WRITE_ALLOW_READ)))
-    DBUG_RETURN(-1);
-
-  /*
-    The drop_index method takes an array of key numbers.
-    It cannot get more entries than keys in the table.
-  */
-  key_numbers= (uint*) thd->alloc(sizeof(uint*)*table->keys);
-  key_count= 0;
-
-  /*
-    Get the number of each key and check if it can be created online.
-  */
-  List_iterator<Alter_drop> drop_it(drop);
-  Alter_drop *drop_key;
-  while ((drop_key= drop_it++))
-  {
-    /* Find the key in the table. */
-    key_info=table->key_info;
-    for (idx=0; idx< table->keys; idx++, key_info++)
-    {
-      if (!my_strcasecmp(system_charset_info, key_info->name, drop_key->name))
-	break;
-    }
-    if (idx>= table->keys)
-    {
-      my_error(ER_CANT_DROP_FIELD_OR_KEY, MYF(0), drop_key->name);
-      /*don't need to free((gptr) key_numbers);*/
-      DBUG_RETURN(-1);
-    }
-    /*
-      Check if the key can be generated with the add_index method.
-      If anyone cannot, then take the old way.
-    */
-    DBUG_PRINT("info", ("dropping index %s", table->key_info[idx].name));
-    if (!(table->file->index_ddl_flags(table->key_info+idx)&
-	  (HA_DDL_ONLINE| HA_DDL_WITH_LOCK)))
-      break ;
-    key_numbers[key_count++]= idx;
-  }
-
-  bzero((char*) &create_info,sizeof(create_info));
-  create_info.db_type=DB_TYPE_DEFAULT;
-  create_info.default_table_charset= thd->variables.collation_database;
-
-  if ((drop_key)|| (drop.elements<= 0))
-  {
-    if (real_alter_table(thd, table_list->db, table_list->real_name,
-			 &create_info, table_list, table,
-			 fields, keys, drop, alter, 0, (ORDER*)0,
-			 ALTER_DROP_INDEX, DUP_ERROR))
-      /*don't need to free((gptr) key_numbers);*/
-      DBUG_RETURN(-1);
-  }
-  else
-  {
-    db_options= 0;
-    if (table->file->drop_index(table, key_numbers, key_count)||
-	mysql_prepare_table(thd, &create_info, fields,
-			    keys, /*tmp_table*/ 0, db_options, table->file,
-			    key_info_buffer, key_count,
-			    /*select_field_count*/ 0)||
-        build_table_path(path, sizeof(path), table_list->db,
-                         (lower_case_table_names == 2) ?
-                         table_list->alias : table_list->real_name,
-                         reg_ext) == 0 ||
-	mysql_create_frm(thd, path, &create_info,
-			 fields, key_count, key_info_buffer, table->file))
-      /*don't need to free((gptr) key_numbers);*/
-      DBUG_RETURN(-1);
-  }
-
-  /*don't need to free((gptr) key_numbers);*/
-  DBUG_RETURN(0);
-}
-#endif /* NOT_USED */
 
 
 /*
@@ -2887,15 +2694,21 @@ bool alter_table_manage_keys(TABLE *table, int indexes_were_disabled,
 
 /*
   Alter table
+
+
+  NOTE
+    The structures passed as 'create_info' and 'alter_info' parameters may
+    be modified by this function. It is responsibility of the caller to make
+    a copy of create_info in order to provide correct execution in prepared
+    statements/stored routines.
 */
 
 int mysql_alter_table(THD *thd,char *new_db, char *new_name,
 		      HA_CREATE_INFO *create_info,
 		      TABLE_LIST *table_list,
-		      List<create_field> &fields, List<Key> &keys,
+                      Alter_info *alter_info,
 		      uint order_num, ORDER *order,
-		      enum enum_duplicates handle_duplicates, bool ignore,
-		      ALTER_INFO *alter_info, bool do_send_ok)
+		      enum enum_duplicates handle_duplicates, bool ignore)
 {
   TABLE *table,*new_table;
   int error;
@@ -3064,8 +2877,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
 	Query_log_event qinfo(thd, thd->query, thd->query_length, 0, FALSE);
 	mysql_bin_log.write(&qinfo);
       }
-      if (do_send_ok)
-        send_ok(thd);
+      send_ok(thd);
     }
     else if (error > 0)
     {
@@ -3091,10 +2903,9 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
 
   restore_record(table,default_values);		// Empty record for DEFAULT
   List_iterator<Alter_drop> drop_it(alter_info->drop_list);
-  List_iterator<create_field> def_it(fields);
+  List_iterator<create_field> def_it(alter_info->create_list);
   List_iterator<Alter_column> alter_it(alter_info->alter_list);
-  List<create_field> create_list;		// Add new fields here
-  List<Key> key_list;				// Add new keys here
+  Alter_info new_info;                   // Add new columns and indexes here
   create_field *def;
 
   /*
@@ -3140,13 +2951,13 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
       def->field=field;
       if (!def->after)
       {
-	create_list.push_back(def);
+	new_info.create_list.push_back(def);
 	def_it.remove();
       }
     }
     else
     {						// Use old field value
-      create_list.push_back(def=new create_field(field,field));
+      new_info.create_list.push_back(def= new create_field(field, field));
       alter_it.rewind();			// Change default if ALTER
       Alter_column *alter;
       while ((alter=alter_it++))
@@ -3167,7 +2978,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
     }
   }
   def_it.rewind();
-  List_iterator<create_field> find_it(create_list);
+  List_iterator<create_field> find_it(new_info.create_list);
   while ((def=def_it++))			// Add new columns
   {
     if (def->change && ! def->field)
@@ -3176,9 +2987,9 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
       DBUG_RETURN(-1);
     }
     if (!def->after)
-      create_list.push_back(def);
+      new_info.create_list.push_back(def);
     else if (def->after == first_keyword)
-      create_list.push_front(def);
+      new_info.create_list.push_front(def);
     else
     {
       create_field *find;
@@ -3202,7 +3013,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
 	     table_name);
     DBUG_RETURN(-1);
   }
-  if (!create_list.elements)
+  if (!new_info.create_list.elements)
   {
     my_error(ER_CANT_REMOVE_ALL_FIELDS,MYF(0));
     DBUG_RETURN(-1);
@@ -3213,8 +3024,8 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
     for which some fields exists.
   */
 
-  List_iterator<Key> key_it(keys);
-  List_iterator<create_field> field_it(create_list);
+  List_iterator<Key> key_it(alter_info->key_list);
+  List_iterator<create_field> field_it(new_info.create_list);
   List<key_part_spec> key_parts;
 
   KEY *key_info=table->key_info;
@@ -3272,24 +3083,37 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
 					    key_part_length));
     }
     if (key_parts.elements)
-      key_list.push_back(new Key(key_info->flags & HA_SPATIAL ? Key::SPATIAL :
-				 (key_info->flags & HA_NOSAME ?
-				 (!my_strcasecmp(system_charset_info,
-						 key_name, primary_key_name) ?
-				  Key::PRIMARY	: Key::UNIQUE) :
-				  (key_info->flags & HA_FULLTEXT ?
-				   Key::FULLTEXT : Key::MULTIPLE)),
-				 key_name,
-				 key_info->algorithm,
-                                 test(key_info->flags & HA_GENERATED_KEY),
-				 key_parts));
+    {
+      Key *key;
+      enum Key::Keytype key_type;
+
+      if (key_info->flags & HA_SPATIAL)
+        key_type= Key::SPATIAL;
+      else if (key_info->flags & HA_NOSAME)
+      {
+        if (! my_strcasecmp(system_charset_info, key_name, primary_key_name))
+          key_type= Key::PRIMARY;
+        else
+          key_type= Key::UNIQUE;
+      }
+      else if (key_info->flags & HA_FULLTEXT)
+        key_type= Key::FULLTEXT;
+      else
+        key_type= Key::MULTIPLE;
+
+      key= new Key(key_type, key_name,
+                   key_info->algorithm,
+                   test(key_info->flags & HA_GENERATED_KEY),
+                   key_parts);
+      new_info.key_list.push_back(key);
+    }
   }
   {
     Key *key;
     while ((key=key_it++))			// Add new keys
     {
       if (key->type != Key::FOREIGN_KEY)
-	key_list.push_back(key);
+        new_info.key_list.push_back(key);
       if (key->name &&
 	  !my_strcasecmp(system_charset_info,key->name,primary_key_name))
       {
@@ -3393,7 +3217,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
     /* We don't log the statement, it will be logged later. */
     tmp_disable_binlog(thd);
     error= mysql_create_table(thd, new_db, tmp_name,
-                              create_info,create_list,key_list,1,0);
+                              create_info, &new_info, 1, 0);
     reenable_binlog(thd);
     if (error)
       DBUG_RETURN(error);
@@ -3422,10 +3246,10 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
   next_insert_id=thd->next_insert_id;		// Remember for loggin
   copied=deleted=0;
   if (!new_table->is_view)
-    error=copy_data_between_tables(table,new_table,create_list,
-				   handle_duplicates, ignore,
-				   order_num, order, &copied, &deleted,
-                                   alter_info->keys_onoff);
+    error= copy_data_between_tables(table, new_table, new_info.create_list,
+                                    handle_duplicates, ignore,
+                                    order_num, order, &copied, &deleted,
+                                    alter_info->keys_onoff);
   /*
     No need to have call to alter_table_manage_keys() in the else because
     in 4.1 we always copy data, except for views. In 5.0 it could happen
@@ -3637,8 +3461,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
   my_snprintf(tmp_name, sizeof(tmp_name), ER(ER_INSERT_INFO),
 	      (ulong) (copied + deleted), (ulong) deleted,
 	      (ulong) thd->cuted_fields);
-  if (do_send_ok)
-    send_ok(thd,copied+deleted,0L,tmp_name);
+  send_ok(thd, copied + deleted, 0L, tmp_name);
   thd->some_tables_deleted=0;
   DBUG_RETURN(0);
 
@@ -3828,30 +3651,26 @@ copy_data_between_tables(TABLE *from,TABLE *to,
     mysql_recreate_table()
     thd			Thread handler
     tables		Tables to recreate
-    do_send_ok          If we should send_ok() or leave it to caller
 
  RETURN
     Like mysql_alter_table().
 */
-int mysql_recreate_table(THD *thd, TABLE_LIST *table_list,
-                         bool do_send_ok)
+int mysql_recreate_table(THD *thd, TABLE_LIST *table_list)
 {
-  DBUG_ENTER("mysql_recreate_table");
   LEX *lex= thd->lex;
   HA_CREATE_INFO create_info;
-  lex->create_list.empty();
-  lex->key_list.empty();
-  lex->col_list.empty();
-  lex->alter_info.reset();
-  lex->alter_info.is_simple= 0;                 // Force full recreate
+  Alter_info alter_info;
+
+  DBUG_ENTER("mysql_recreate_table");
+
   bzero((char*) &create_info,sizeof(create_info));
   create_info.db_type=DB_TYPE_DEFAULT;
   create_info.row_type=ROW_TYPE_DEFAULT;
   create_info.default_table_charset=default_charset_info;
+  alter_info.is_simple= 0;                 // Force full recreate
   DBUG_RETURN(mysql_alter_table(thd, NullS, NullS, &create_info,
-                                table_list, lex->create_list,
-                                lex->key_list, 0, (ORDER *) 0,
-                                DUP_ERROR, 0, &lex->alter_info, do_send_ok));
+                                table_list, &alter_info,
+                                0, (ORDER *) 0, DUP_ERROR, 0));
 }
 
 
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index c6f4307f1eabee4529e66722c9be4a7726b86703..30283a47b2107e5cde426ab970985aaaac3b2d11 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -1021,8 +1021,7 @@ create:
 						  TL_READ_NO_INSERT:
 						  TL_READ)))
 	    YYABORT;
-	  lex->create_list.empty();
-	  lex->key_list.empty();
+          lex->alter_info.reset();
 	  lex->col_list.empty();
 	  lex->change=NullS;
 	  bzero((char*) &lex->create_info,sizeof(lex->create_info));
@@ -1040,16 +1039,18 @@ create:
 	    if (!lex->current_select->add_table_to_list(lex->thd, $7, NULL,
 							TL_OPTION_UPDATING))
 	      YYABORT;
-	    lex->create_list.empty();
-	    lex->key_list.empty();
+            lex->alter_info.reset();
+            lex->alter_info.is_simple= 0;
+            lex->alter_info.flags= ALTER_ADD_INDEX;
 	    lex->col_list.empty();
 	    lex->change=NullS;
 	  }
 	   '(' key_list ')'
 	  {
 	    LEX *lex=Lex;
+            Key *key= new Key($2, $4.str, $5, 0, lex->col_list);
 
-	    lex->key_list.push_back(new Key($2,$4.str, $5, 0, lex->col_list));
+            lex->alter_info.key_list.push_back(key);
 	    lex->col_list.empty();
 	  }
 	| CREATE DATABASE opt_if_not_exists ident
@@ -1305,29 +1306,34 @@ key_def:
 	key_type opt_ident key_alg '(' key_list ')'
 	  {
 	    LEX *lex=Lex;
-	    lex->key_list.push_back(new Key($1,$2, $3, 0, lex->col_list));
+            Key *key= new Key($1, $2, $3, 0, lex->col_list);
+            lex->alter_info.key_list.push_back(key);
+
 	    lex->col_list.empty();		/* Alloced by sql_alloc */
 	  }
 	| opt_constraint constraint_key_type opt_ident key_alg '(' key_list ')'
 	  {
 	    LEX *lex=Lex;
 	    const char *key_name= $3 ? $3:$1;
-	    lex->key_list.push_back(new Key($2, key_name, $4, 0,
-				    lex->col_list));
+            Key *key= new Key($2, key_name, $4, 0, lex->col_list);
+            lex->alter_info.key_list.push_back(key);
 	    lex->col_list.empty();		/* Alloced by sql_alloc */
 	  }
 	| opt_constraint FOREIGN KEY_SYM opt_ident '(' key_list ')' references
 	  {
 	    LEX *lex=Lex;
-	    lex->key_list.push_back(new foreign_key($4 ? $4:$1, lex->col_list,
-				    $8,
-				    lex->ref_list,
-				    lex->fk_delete_opt,
-				    lex->fk_update_opt,
-				    lex->fk_match_option));
-	    lex->key_list.push_back(new Key(Key::MULTIPLE, $4 ? $4 : $1,
-					    HA_KEY_ALG_UNDEF, 1,
-					    lex->col_list));
+            const char *key_name= $4 ? $4 : $1;
+            Key *key= new foreign_key(key_name, lex->col_list,
+                                      $8,
+                                      lex->ref_list,
+                                      lex->fk_delete_opt,
+                                      lex->fk_update_opt,
+                                      lex->fk_match_option);
+            lex->alter_info.key_list.push_back(key);
+            key= new Key(Key::MULTIPLE, key_name,
+                         HA_KEY_ALG_UNDEF, 1,
+                         lex->col_list);
+            lex->alter_info.key_list.push_back(key);
 	    lex->col_list.empty();		/* Alloced by sql_alloc */
 	  }
 	| constraint opt_check_constraint
@@ -1850,8 +1856,6 @@ alter:
 	  if (!lex->select_lex.add_table_to_list(thd, $4, NULL,
 						 TL_OPTION_UPDATING))
 	    YYABORT;
-	  lex->create_list.empty();
-	  lex->key_list.empty();
 	  lex->col_list.empty();
           lex->select_lex.init_order();
 	  lex->select_lex.db=lex->name=0;
@@ -1859,9 +1863,7 @@ alter:
 	  lex->create_info.db_type= DB_TYPE_DEFAULT;
 	  lex->create_info.default_table_charset= NULL;
 	  lex->create_info.row_type= ROW_TYPE_NOT_USED;
-	  lex->alter_info.reset();          
-	  lex->alter_info.is_simple= 1;
-	  lex->alter_info.flags= 0;
+          lex->alter_info.reset();
 	}
 	alter_list
 	{}
@@ -4030,7 +4032,9 @@ drop:
 	  {
 	     LEX *lex=Lex;
 	     lex->sql_command= SQLCOM_DROP_INDEX;
-	     lex->alter_info.drop_list.empty();
+             lex->alter_info.reset();
+             lex->alter_info.is_simple= 0;
+             lex->alter_info.flags= ALTER_DROP_INDEX;
 	     lex->alter_info.drop_list.push_back(new Alter_drop(Alter_drop::KEY,
                                                                 $3.str));
 	     if (!lex->current_select->add_table_to_list(lex->thd, $5, NULL,
diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh
index 083b89d9275e7904237b3ae30a0f97eedcc3a748..02176ea0b41a13429355254f91a869123e5847c9 100644
--- a/support-files/mysql.spec.sh
+++ b/support-files/mysql.spec.sh
@@ -340,7 +340,7 @@ install -m 644 libmysqld/libmysqld.a $RBR%{_libdir}/mysql/
 # Include libgcc.a in the devel subpackage (BUG 4921)
 if expr "$CC" : ".*gcc.*" > /dev/null ;
 then
-  libgcc=`$CC --print-libgcc-file`
+  libgcc=`$CC $CFLAGS --print-libgcc-file`
   if [ -f $libgcc ]
   then
     %define have_libgcc 1
@@ -726,6 +726,11 @@ fi
 # itself - note that they must be ordered by date (important when
 # merging BK trees)
 %changelog 
+* Fri Jan 05 2007 Kent Boortz <kent@mysql.com>
+
+- Add CFLAGS to gcc call with --print-libgcc-file, to make sure the
+  correct "libgcc.a" path is returned for the 32/64 bit architecture.
+
 * Thu Dec 14 2006 Joerg Bruehe <joerg@mysql.com>
 
 - Include the new man pages for "my_print_defaults" and "mysql_tzinfo_to_sql"