List:Commits« Previous MessageNext Message »
From:Marc Alff Date:March 7 2010 5:41pm
Subject:bzr commit into mysql-next-mr-bugfixing branch (marc.alff:3123)
View as plain text  
#At file:///home/malff/BZR_TREE/mysql-next-mr-bugfixing-51741/ based on revid:marc.alff@strippedrw70696h27e1okdp

 3123 Marc Alff	2010-03-07 [merge]
      local merge

    added:
      mysql-test/include/ctype_utf8mb4.inc
      mysql-test/r/ctype_utf8mb4_heap.result
      mysql-test/r/ctype_utf8mb4_innodb.result
      mysql-test/r/ctype_utf8mb4_myisam.result
      mysql-test/r/ctype_utf8mb4_ndb.result
      mysql-test/suite/perfschema/r/pfs_upgrade.result
      mysql-test/suite/perfschema/t/pfs_upgrade.test
      mysql-test/suite/sys_vars/r/log_error_func.result
      mysql-test/suite/sys_vars/r/log_error_func2.result
      mysql-test/suite/sys_vars/r/log_error_func3.result
      mysql-test/suite/sys_vars/t/log_error_func.cnf
      mysql-test/suite/sys_vars/t/log_error_func.test
      mysql-test/suite/sys_vars/t/log_error_func2.cnf
      mysql-test/suite/sys_vars/t/log_error_func2.test
      mysql-test/suite/sys_vars/t/log_error_func3.test
      mysql-test/t/ctype_utf8mb4_heap.test
      mysql-test/t/ctype_utf8mb4_innodb.test
      mysql-test/t/ctype_utf8mb4_myisam.test
      mysql-test/t/ctype_utf8mb4_ndb.test
    modified:
      COPYING
      README
      configure.in
      include/m_ctype.h
      mysql-test/collections/default.experimental
      mysql-test/lib/v1/mysql-test-run.pl
      mysql-test/r/ctype_utf8mb4.result
      mysql-test/t/ctype_utf8mb4.test
      scripts/mysql_system_tables.sql
      sql-common/client.c
      sql/mysql_priv.h
      sql/mysqld.cc
      sql/sys_vars.cc
      storage/perfschema/pfs_instr.cc
      strings/ctype-uca.c
      strings/ctype-ucs2.c
      strings/ctype-utf8.c
=== modified file 'COPYING'
--- a/COPYING	2005-04-13 09:51:38 +0000
+++ b/COPYING	2010-03-04 13:26:27 +0000
@@ -1,352 +1,339 @@
-                      GNU GENERAL PUBLIC LICENSE
-                         Version 2, June 1991
+		    GNU GENERAL PUBLIC LICENSE
+		       Version 2, June 1991
 
-     Copyright (C) 1989, 1991 Free Software Foundation, Inc.
-     59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
-
-     Everyone is permitted to copy and distribute verbatim copies
-     of this license document, but changing it is not allowed.
-
-Preamble
-========
-
-The licenses for most software are designed to take away your freedom
-to share and change it.  By contrast, the GNU General Public License is
-intended to guarantee your freedom to share and change free
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
 software--to make sure the software is free for all its users.  This
 General Public License applies to most of the Free Software
 Foundation's software and to any other program whose authors commit to
 using it.  (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.)  You can apply it to
+the GNU Lesser General Public License instead.)  You can apply it to
 your programs, too.
 
-When we speak of free software, we are referring to freedom, not price.
-Our General Public Licenses are designed to make sure that you have
-the freedom to distribute copies of free software (and charge for this
-service if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs; and that you know you can do these things.
-
-To protect your rights, we need to make restrictions that forbid anyone
-to deny you these rights or to ask you to surrender the rights.  These
-restrictions translate to certain responsibilities for you if you
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
 distribute copies of the software, or if you modify it.
 
-For example, if you distribute copies of such a program, whether gratis
-or for a fee, you must give the recipients all the rights that you
-have.  You must make sure that they, too, receive or can get the source
-code.  And you must show them these terms so they know their rights.
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
 
-We protect your rights with two steps: (1) copyright the software, and
+  We protect your rights with two steps: (1) copyright the software, and
 (2) offer you this license which gives you legal permission to copy,
 distribute and/or modify the software.
 
-Also, for each author's protection and ours, we want to make certain
+  Also, for each author's protection and ours, we want to make certain
 that everyone understands that there is no warranty for this free
 software.  If the software is modified by someone else and passed on, we
 want its recipients to know that what they have is not the original, so
 that any problems introduced by others will not reflect on the original
 authors' reputations.
 
-Finally, any free program is threatened constantly by software patents.
-We wish to avoid the danger that redistributors of a free program will
-individually obtain patent licenses, in effect making the program
-proprietary.  To prevent this, we have made it clear that any patent
-must be licensed for everyone's free use or not licensed at all.
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
 
-The precise terms and conditions for copying, distribution and
+  The precise terms and conditions for copying, distribution and
 modification follow.
 
-                      GNU GENERAL PUBLIC LICENSE
-    TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-  0. This License applies to any program or other work which contains a
-     notice placed by the copyright holder saying it may be distributed
-     under the terms of this General Public License.  The "Program",
-     below, refers to any such program or work, and a "work based on
-     the Program" means either the Program or any derivative work under
-     copyright law: that is to say, a work containing the Program or a
-     portion of it, either verbatim or with modifications and/or
-     translated into another language.  (Hereinafter, translation is
-     included without limitation in the term "modification".)  Each
-     licensee is addressed as "you".
-
-     Activities other than copying, distribution and modification are
-     not covered by this License; they are outside its scope.  The act
-     of running the Program is not restricted, and the output from the
-     Program is covered only if its contents constitute a work based on
-     the Program (independent of having been made by running the
-     Program).  Whether that is true depends on what the Program does.
+		    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
 
   1. You may copy and distribute verbatim copies of the Program's
-     source code as you receive it, in any medium, provided that you
-     conspicuously and appropriately publish on each copy an appropriate
-     copyright notice and disclaimer of warranty; keep intact all the
-     notices that refer to this License and to the absence of any
-     warranty; and give any other recipients of the Program a copy of
-     this License along with the Program.
-
-     You may charge a fee for the physical act of transferring a copy,
-     and you may at your option offer warranty protection in exchange
-     for a fee.
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
 
   2. You may modify your copy or copies of the Program or any portion
-     of it, thus forming a work based on the Program, and copy and
-     distribute such modifications or work under the terms of Section 1
-     above, provided that you also meet all of these conditions:
-
-       a. You must cause the modified files to carry prominent notices
-          stating that you changed the files and the date of any change.
-
-       b. You must cause any work that you distribute or publish, that
-          in whole or in part contains or is derived from the Program
-          or any part thereof, to be licensed as a whole at no charge
-          to all third parties under the terms of this License.
-
-       c. If the modified program normally reads commands interactively
-          when run, you must cause it, when started running for such
-          interactive use in the most ordinary way, to print or display
-          an announcement including an appropriate copyright notice and
-          a notice that there is no warranty (or else, saying that you
-          provide a warranty) and that users may redistribute the
-          program under these conditions, and telling the user how to
-          view a copy of this License.  (Exception: if the Program
-          itself is interactive but does not normally print such an
-          announcement, your work based on the Program is not required
-          to print an announcement.)
-
-     These requirements apply to the modified work as a whole.  If
-     identifiable sections of that work are not derived from the
-     Program, and can be reasonably considered independent and separate
-     works in themselves, then this License, and its terms, do not
-     apply to those sections when you distribute them as separate
-     works.  But when you distribute the same sections as part of a
-     whole which is a work based on the Program, the distribution of
-     the whole must be on the terms of this License, whose permissions
-     for other licensees extend to the entire whole, and thus to each
-     and every part regardless of who wrote it.
-
-     Thus, it is not the intent of this section to claim rights or
-     contest your rights to work written entirely by you; rather, the
-     intent is to exercise the right to control the distribution of
-     derivative or collective works based on the Program.
-
-     In addition, mere aggregation of another work not based on the
-     Program with the Program (or with a work based on the Program) on
-     a volume of a storage or distribution medium does not bring the
-     other work under the scope of this License.
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
 
   3. You may copy and distribute the Program (or a work based on it,
-     under Section 2) in object code or executable form under the terms
-     of Sections 1 and 2 above provided that you also do one of the
-     following:
-
-       a. Accompany it with the complete corresponding machine-readable
-          source code, which must be distributed under the terms of
-          Sections 1 and 2 above on a medium customarily used for
-          software interchange; or,
-
-       b. Accompany it with a written offer, valid for at least three
-          years, to give any third-party, for a charge no more than your
-          cost of physically performing source distribution, a complete
-          machine-readable copy of the corresponding source code, to be
-          distributed under the terms of Sections 1 and 2 above on a
-          medium customarily used for software interchange; or,
-
-       c. Accompany it with the information you received as to the offer
-          to distribute corresponding source code.  (This alternative is
-          allowed only for noncommercial distribution and only if you
-          received the program in object code or executable form with
-          such an offer, in accord with Subsection b above.)
-
-     The source code for a work means the preferred form of the work for
-     making modifications to it.  For an executable work, complete
-     source code means all the source code for all modules it contains,
-     plus any associated interface definition files, plus the scripts
-     used to control compilation and installation of the executable.
-     However, as a special exception, the source code distributed need
-     not include anything that is normally distributed (in either
-     source or binary form) with the major components (compiler,
-     kernel, and so on) of the operating system on which the executable
-     runs, unless that component itself accompanies the executable.
-
-     If distribution of executable or object code is made by offering
-     access to copy from a designated place, then offering equivalent
-     access to copy the source code from the same place counts as
-     distribution of the source code, even though third parties are not
-     compelled to copy the source along with the object code.
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
 
   4. You may not copy, modify, sublicense, or distribute the Program
-     except as expressly provided under this License.  Any attempt
-     otherwise to copy, modify, sublicense or distribute the Program is
-     void, and will automatically terminate your rights under this
-     License.  However, parties who have received copies, or rights,
-     from you under this License will not have their licenses
-     terminated so long as such parties remain in full compliance.
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
 
   5. You are not required to accept this License, since you have not
-     signed it.  However, nothing else grants you permission to modify
-     or distribute the Program or its derivative works.  These actions
-     are prohibited by law if you do not accept this License.
-     Therefore, by modifying or distributing the Program (or any work
-     based on the Program), you indicate your acceptance of this
-     License to do so, and all its terms and conditions for copying,
-     distributing or modifying the Program or works based on it.
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
 
   6. Each time you redistribute the Program (or any work based on the
-     Program), the recipient automatically receives a license from the
-     original licensor to copy, distribute or modify the Program
-     subject to these terms and conditions.  You may not impose any
-     further restrictions on the recipients' exercise of the rights
-     granted herein.  You are not responsible for enforcing compliance
-     by third parties to this License.
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
 
   7. If, as a consequence of a court judgment or allegation of patent
-     infringement or for any other reason (not limited to patent
-     issues), conditions are imposed on you (whether by court order,
-     agreement or otherwise) that contradict the conditions of this
-     License, they do not excuse you from the conditions of this
-     License.  If you cannot distribute so as to satisfy simultaneously
-     your obligations under this License and any other pertinent
-     obligations, then as a consequence you may not distribute the
-     Program at all.  For example, if a patent license would not permit
-     royalty-free redistribution of the Program by all those who
-     receive copies directly or indirectly through you, then the only
-     way you could satisfy both it and this License would be to refrain
-     entirely from distribution of the Program.
-
-     If any portion of this section is held invalid or unenforceable
-     under any particular circumstance, the balance of the section is
-     intended to apply and the section as a whole is intended to apply
-     in other circumstances.
-
-     It is not the purpose of this section to induce you to infringe any
-     patents or other property right claims or to contest validity of
-     any such claims; this section has the sole purpose of protecting
-     the integrity of the free software distribution system, which is
-     implemented by public license practices.  Many people have made
-     generous contributions to the wide range of software distributed
-     through that system in reliance on consistent application of that
-     system; it is up to the author/donor to decide if he or she is
-     willing to distribute software through any other system and a
-     licensee cannot impose that choice.
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
 
-     This section is intended to make thoroughly clear what is believed
-     to be a consequence of the rest of this License.
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
 
   8. If the distribution and/or use of the Program is restricted in
-     certain countries either by patents or by copyrighted interfaces,
-     the original copyright holder who places the Program under this
-     License may add an explicit geographical distribution limitation
-     excluding those countries, so that distribution is permitted only
-     in or among countries not thus excluded.  In such case, this
-     License incorporates the limitation as if written in the body of
-     this License.
-
-  9. The Free Software Foundation may publish revised and/or new
-     versions of the General Public License from time to time.  Such
-     new versions will be similar in spirit to the present version, but
-     may differ in detail to address new problems or concerns.
-
-     Each version is given a distinguishing version number.  If the
-     Program specifies a version number of this License which applies
-     to it and "any later version", you have the option of following
-     the terms and conditions either of that version or of any later
-     version published by the Free Software Foundation.  If the Program
-     does not specify a version number of this License, you may choose
-     any version ever published by the Free Software Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-     programs whose distribution conditions are different, write to the
-     author to ask for permission.  For software which is copyrighted
-     by the Free Software Foundation, write to the Free Software
-     Foundation; we sometimes make exceptions for this.  Our decision
-     will be guided by the two goals of preserving the free status of
-     all derivatives of our free software and of promoting the sharing
-     and reuse of software generally.
-
-                                NO WARRANTY
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO
-     WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE
-     LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-     HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
-     WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT
-     NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-     FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE
-     QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
-     PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
-     SERVICING, REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-     WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY
-     MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE
-     LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL,
-     INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
-     INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-     DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU
-     OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY
-     OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN
-     ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
-
-                      END OF TERMS AND CONDITIONS
-How to Apply These Terms to Your New Programs
-=============================================
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+			    NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
 
-If you develop a new program, and you want it to be of the greatest
+	    How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
 possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these
-terms.
+free software which everyone can redistribute and change under these terms.
 
-To do so, attach the following notices to the program.  It is safest to
-attach them to the start of each source file to most effectively convey
-the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
-     ONE LINE TO GIVE THE PROGRAM'S NAME AND A BRIEF IDEA OF WHAT IT DOES.
-     Copyright (C) YYYY  NAME OF AUTHOR
-
-     This program is free software; you can redistribute it and/or modify
-     it under the terms of the GNU General Public License as published by
-     the Free Software Foundation; either version 2 of the License, or
-     (at your option) any later version.
-
-     This program is distributed in the hope that it will be useful,
-     but WITHOUT ANY WARRANTY; without even the implied warranty of
-     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-     GNU General Public License for more details.
-
-     You should have received a copy of the GNU General Public License
-     along with this program; if not, write to the Free Software
-     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License along
+    with this program; if not, write to the Free Software Foundation, Inc.,
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 Also add information on how to contact you by electronic and paper mail.
 
 If the program is interactive, make it output a short notice like this
 when it starts in an interactive mode:
 
-     Gnomovision version 69, Copyright (C) 19YY NAME OF AUTHOR
-     Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
-     This is free software, and you are welcome to redistribute it
-     under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the
-appropriate parts of the General Public License.  Of course, the
-commands you use may be called something other than `show w' and `show
-c'; they could even be mouse-clicks or menu items--whatever suits your
-program.
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
 
 You should also get your employer (if you work as a programmer) or your
 school, if any, to sign a "copyright disclaimer" for the program, if
 necessary.  Here is a sample; alter the names:
 
-     Yoyodyne, Inc., hereby disclaims all copyright interest in the program
-     `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
-     SIGNATURE OF TY COON, 1 April 1989
-     Ty Coon, President of Vice
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
 
-This General Public License does not permit incorporating your program
-into proprietary programs.  If your program is a subroutine library,
-you may consider it more useful to permit linking proprietary
-applications with the library.  If this is what you want to do, use the
-GNU Library General Public License instead of this License.
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
 
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.

=== modified file 'README'
--- a/README	2010-03-01 09:19:39 +0000
+++ b/README	2010-03-04 13:45:11 +0000
@@ -1,6 +1,58 @@
-DO NOT TRANSLATE OR LOCALIZE
+This is a release of MySQL, a dual-license SQL database server.
+MySQL is brought to you by the MySQL team at Oracle Corporation.
 
-***************************************************************************
+************************************************************
+LICENSE
+************************************************************
+License information and use restrictions of this software can
+be found in these files:
+- For GPL (free) distributions, see the COPYING file and
+  the EXCEPTIONS-CLIENT file.
+- For commercial distributions, see the LICENSE.mysql file.
+
+GPLv2 Disclaimer
+For the avoidance of doubt, except that if any license choice
+other than GPL or LGPL is available it will apply instead, Oracle
+elects to use only the General Public License version 2 (GPLv2)
+at this time for any software where a choice of GPL license versions
+is made available with the language indicating that GPLv2 or any
+later version may be used, or where a choice of which version of
+the GPL is applied is otherwise unspecified.
+
+************************************************************
+FURTHER INFORMATION
+************************************************************
+For further information about MySQL or additional documentation, see:
+- The latest information about MySQL: http://dev.mysql.com/
+- The current MySQL documentation: http://dev.mysql.com/doc/
+
+Some manual sections of special interest:
+- If you are migrating from an older version of MySQL, please read 
+the "Upgrading from..." section first!
+- To see what MySQL can do, take a look at the features section.
+- For installation instructions, see the Installing and Upgrading
+chapter.
+- For the new features/bugfix history, see the Change History appendix.
+- For the currently known bugs/misfeatures (known errors) see the
+Problems and Common Errors appendix.
+- For a list of developers and other contributors, see the Credits
+appendix.
+
+A local copy of the MySQL Reference Manual can be found in the Docs
+directory in GNU Info format. You can also browse the manual online or
+download it in any of several formats at the URL given earlier in this
+file.
+
+************************************************************
+IMPORTANT:
+
+Bug or error reports should be sent to http://bugs.mysql.com.
+************************************************************
+
+
+************************************************************
+THIRD-PARTY SOFTWARE
+************************************************************
 
 %%The following software may be included in this product:
 FindGTest.cmake (part of CMake 2.8.0)

=== modified file 'configure.in'
--- a/configure.in	2010-03-02 14:34:50 +0000
+++ b/configure.in	2010-03-06 10:39:56 +0000
@@ -27,7 +27,7 @@ AC_PREREQ(2.59)
 # Remember to also update version.c in ndb.
 # When changing major version number please also check switch statement
 # in client/mysqlbinlog.cc:check_master_version().
-AC_INIT([MySQL Server], [5.5.99-m3], [], [mysql])
+AC_INIT([MySQL Server], [5.6.99-m4], [], [mysql])
 AC_CONFIG_SRCDIR([sql/mysqld.cc])
 AC_CANONICAL_SYSTEM
 # USTAR format gives us the possibility to store longer path names in

=== modified file 'include/m_ctype.h'
--- a/include/m_ctype.h	2010-02-24 09:15:34 +0000
+++ b/include/m_ctype.h	2010-03-04 11:00:32 +0000
@@ -38,6 +38,7 @@ extern "C" {
 
 #define my_wc_t ulong
 
+#define MY_CS_REPLACEMENT_CHARACTER 0xFFFD
 
 /*
   On i386 we store Unicode->CS conversion tables for

=== modified file 'mysql-test/collections/default.experimental'
--- a/mysql-test/collections/default.experimental	2010-03-02 07:24:32 +0000
+++ b/mysql-test/collections/default.experimental	2010-03-05 09:28:45 +0000
@@ -4,6 +4,7 @@
 binlog.binlog_multi_engine               # joro : NDB tests marked as experimental as agreed with bochklin
 
 funcs_1.charset_collation_1              # depends on compile-time decisions
+funcs_1.myisam_views @solaris            # Bug#50595 2010-03-05 alik funcs_1.myisam_views takes longer time on 6.0 branch than 5.1 branch
 
 main.information_schema                  # Bug#47449 2009-09-19 alik main.information_schema and innodb.innodb_information_schema fail sporadically
 main.lock_multi_bug38499                 # Bug#47448 2009-09-19 alik main.lock_multi_bug38499 times out sporadically

=== added file 'mysql-test/include/ctype_utf8mb4.inc'
--- a/mysql-test/include/ctype_utf8mb4.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/ctype_utf8mb4.inc	2010-03-05 08:17:19 +0000
@@ -0,0 +1,1858 @@
+#
+# Tests with the utf8mb4 character set
+#
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
+
+--echo #
+--echo # Start of 5.5 tests
+--echo #
+
+set names utf8mb4;
+
+select left(_utf8mb4 0xD0B0D0B1D0B2,1);
+select right(_utf8mb4 0xD0B0D0B2D0B2,1);
+
+select locate('he','hello');
+select locate('he','hello',2);
+select locate('lo','hello',2);
+select locate('HE','hello');
+select locate('HE','hello',2);
+select locate('LO','hello',2);
+select locate('HE','hello' collate utf8mb4_bin);
+select locate('HE','hello' collate utf8mb4_bin,2);
+select locate('LO','hello' collate utf8mb4_bin,2);
+
+select locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D0B1D0B2);
+select locate(_utf8mb4 0xD091, _utf8mb4 0xD0B0D0B1D0B2);
+select locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D091D0B2);
+select locate(_utf8mb4 0xD091, _utf8mb4 0xD0B0D0B1D0B2 collate utf8mb4_bin);
+select locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D091D0B2 collate utf8mb4_bin);
+
+select length(_utf8mb4 0xD0B1), bit_length(_utf8mb4 0xD0B1), char_length(_utf8mb4 0xD0B1);
+
+select 'a' like 'a';
+select 'A' like 'a';
+select 'A' like 'a' collate utf8mb4_bin;
+select _utf8mb4 0xD0B0D0B1D0B2 like concat(_utf8mb4'%',_utf8mb4 0xD0B1,_utf8mb4 '%');
+
+# Bug #6040: can't retrieve records with umlaut
+# characters in case insensitive manner.
+# Case insensitive search LIKE comparison
+# was broken for multibyte characters:
+select convert(_latin1'G�Andr�using utf8mb4) like CONVERT(_latin1'G�TER%' USING utf8mb4);
+select CONVERT(_koi8r'��' USING utf8mb4) LIKE CONVERT(_koi8r'�' USING utf8mb4);
+select CONVERT(_koi8r'�' USING utf8mb4) LIKE CONVERT(_koi8r'��' USING utf8mb4);
+
+#
+# Check the following:
+# "a"  == "a "
+# "a\0" < "a"
+# "a\0" < "a "
+
+SELECT 'a' = 'a ';
+SELECT 'a\0' < 'a';
+SELECT 'a\0' < 'a ';
+SELECT 'a\t' < 'a';
+SELECT 'a\t' < 'a ';
+
+#
+# The same for binary collation
+#
+SELECT 'a' = 'a ' collate utf8mb4_bin;
+SELECT 'a\0' < 'a' collate utf8mb4_bin;
+SELECT 'a\0' < 'a ' collate utf8mb4_bin;
+SELECT 'a\t' < 'a' collate utf8mb4_bin;
+SELECT 'a\t' < 'a ' collate utf8mb4_bin;
+
+eval CREATE TABLE t1 (a char(10) character set utf8mb4 not null) ENGINE $engine;
+INSERT INTO t1 VALUES ('a'),('a\0'),('a\t'),('a ');
+--sorted_result
+SELECT hex(a),STRCMP(a,'a'), STRCMP(a,'a ') FROM t1;
+DROP TABLE t1;
+
+#
+# Fix this, it should return 1:
+#
+#select _utf8mb4 0xD0B0D0B1D0B2 like concat(_utf8mb4'%',_utf8mb4 0xD091,_utf8mb4 '%');
+#
+
+#
+# Bug 2367: INSERT() behaviour is different for different charsets.
+#
+select insert('txs',2,1,'hi'),insert('is ',4,0,'a'),insert('txxxxt',2,4,'es');
+select insert("aa",100,1,"b"),insert("aa",1,3,"b");
+
+#
+# LELF() didn't work well with utf8mb4 in some cases too.
+#
+select char_length(left(@a:='тест',5)), length(@a), @a;
+
+
+#
+# CREATE ... SELECT
+#
+eval create table t1 ENGINE $engine select date_format("2004-01-19 10:10:10", "%Y-%m-%d");
+show create table t1;
+select * from t1;
+drop table t1;
+
+#
+# Bug#22646 LC_TIME_NAMES: Assignment to non-UTF8 target fails
+#
+set names utf8mb4;
+set LC_TIME_NAMES='fr_FR';
+eval create table t1 (s1 char(20) character set latin1) engine $engine;
+insert into t1 values (date_format('2004-02-02','%M'));
+select hex(s1) from t1;
+drop table t1;
+eval create table t1 (s1 char(20) character set koi8r) engine $engine;
+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'));
+--sorted_result
+select hex(s1), s1 from t1;
+drop table t1;
+set LC_TIME_NAMES='en_US';
+
+
+#
+# Bug #2366  	Wrong utf8mb4 behaviour when data is truncated
+#
+set names koi8r;
+eval create table t1 (s1 char(1) character set utf8mb4) engine $engine;
+insert into t1 values (_koi8r'�');
+select s1,hex(s1),char_length(s1),octet_length(s1) from t1;
+drop table t1;
+
+if (!$is_heap)
+{
+eval create table t1 (s1 tinytext character set utf8mb4) engine $engine;
+}
+if ($is_heap)
+{
+eval create table t1 (s1 varchar(255) character set utf8mb4) engine $engine;
+}
+insert into t1 select repeat('a',300);
+insert into t1 select repeat('�,300);
+insert into t1 select repeat('a�,300);
+insert into t1 select repeat('�',300);
+insert into t1 select repeat('�',300);
+--sorted_result
+select hex(s1) from t1;
+--sorted_result
+select length(s1),char_length(s1) from t1;
+drop table t1;
+
+if (!$is_heap)
+{
+eval create table t1 (s1 text character set utf8mb4) engine $engine;
+}
+if ($is_heap)
+{
+eval create table t1 (s1 varchar(255) character set utf8mb4) engine $engine;
+}
+insert into t1 select repeat('a',66000);
+insert into t1 select repeat('�,66000);
+insert into t1 select repeat('a�,66000);
+insert into t1 select repeat('�',66000);
+insert into t1 select repeat('�',66000);
+--sorted_result
+select length(s1),char_length(s1) from t1;
+drop table t1;
+
+#
+# Bug #2368 Multibyte charsets do not check that incoming data is well-formed
+#
+eval create table t1 (s1 char(10) character set utf8mb4) engine $engine;
+insert into t1 values (0x41FF);
+select hex(s1) from t1;
+drop table t1;
+
+eval create table t1 (s1 varchar(10) character set utf8mb4) engine $engine;
+insert into t1 values (0x41FF);
+select hex(s1) from t1;
+drop table t1;
+
+if (!$is_heap)
+{
+eval create table t1 (s1 text character set utf8mb4) engine $engine;
+insert into t1 values (0x41FF);
+select hex(s1) from t1;
+drop table t1;
+}
+
+#
+# Bug 2699
+# UTF8 breaks primary keys for cols > 333 characters
+#
+if(!$is_heap)
+{
+if(!$is_ndb)
+{
+--error ER_TOO_LONG_KEY
+eval create table t1 (a text character set utf8mb4, primary key(a(371))) engine $engine;
+}
+if($is_ndb)
+{
+--error ER_BLOB_USED_AS_KEY
+eval create table t1 (a text character set utf8mb4, primary key(a(371))) engine $engine;
+}
+}
+
+#
+# Bug 2959
+# UTF8 charset breaks joins with mixed column/string constant
+#
+eval CREATE TABLE t1 ( a varchar(10) ) CHARACTER SET utf8mb4 ENGINE $engine;
+INSERT INTO t1 VALUES ( 'test' );
+SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = b.a;
+SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = 'test' and b.a = 'test';
+SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = b.a and a.a = 'test';
+DROP TABLE t1;
+
+eval create table t1 (a char(255) character set utf8mb4) engine $engine;
+insert into t1 values('b'),('b');
+select * from t1 where a = 'b';
+select * from t1 where a = 'b' and a = 'b';
+select * from t1 where a = 'b' and a != 'b';
+drop table t1;
+
+#
+# Testing regexp
+#
+set collation_connection=utf8mb4_general_ci;
+--source include/ctype_regex.inc
+set names utf8mb4;
+
+#
+# Bug #3928 regexp [[:>:]] and UTF-8
+#
+set names utf8mb4;
+
+# This should return TRUE
+select  'вася'  rlike '[[:<:]]вася[[:>:]]';
+select  'вася ' rlike '[[:<:]]вася[[:>:]]';
+select ' вася'  rlike '[[:<:]]вася[[:>:]]';
+select ' вася ' rlike '[[:<:]]вася[[:>:]]';
+
+# This should return FALSE
+select  'васяz' rlike '[[:<:]]вася[[:>:]]';
+select 'zвася'  rlike '[[:<:]]вася[[:>:]]';
+select 'zвасяz' rlike '[[:<:]]вася[[:>:]]';
+
+#
+# Bug #4555
+# ALTER TABLE crashes mysqld with enum column collated utf8mb4_unicode_ci
+#
+eval CREATE TABLE t1 (a enum ('Y', 'N') DEFAULT 'N' COLLATE utf8mb4_unicode_ci) ENGINE $engine;
+ALTER TABLE t1 ADD COLUMN b CHAR(20);
+DROP TABLE t1;
+
+# Customer Support Center issue # 3299 
+# ENUM and SET multibyte fields computed their length wronly 
+# when converted into a char field
+set names utf8mb4;
+eval create table t1 (a enum('aaaa','проба') character set utf8mb4) engine $engine;
+show create table t1;
+insert into t1 values ('проба');
+select * from t1;
+eval create table t2 engine $engine select ifnull(a,a) from t1;
+show create table t2;
+select * from t2;
+drop table t1;
+drop table t2;
+
+#
+# Bug 4521: unique key prefix interacts poorly with utf8mb4
+# MYISAM: keys with prefix compression, case insensitive collation.
+#
+if (!$is_ndb)
+{
+eval create table t1 (c varchar(30) character set utf8mb4, unique(c(10))) engine $engine;
+insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z');
+insert into t1 values ('aaaaaaaaaa');
+--error ER_DUP_ENTRY
+insert into t1 values ('aaaaaaaaaaa');
+--error ER_DUP_ENTRY
+insert into t1 values ('aaaaaaaaaaaa');
+insert into t1 values (repeat('b',20));
+select c c1 from t1 where c='1';
+select c c2 from t1 where c='2';
+select c c3 from t1 where c='3';
+select c cx from t1 where c='x';
+select c cy from t1 where c='y';
+select c cz from t1 where c='z';
+select c ca10 from t1 where c='aaaaaaaaaa';
+select c cb20 from t1 where c=repeat('b',20);
+drop table t1;
+
+#
+# Bug 4521: unique key prefix interacts poorly with utf8mb4
+# InnoDB: keys with prefix compression, case insensitive collation.
+#
+--disable_warnings
+eval create table t1 (c varchar(30) character set utf8mb4, unique(c(10))) engine=$engine;
+--enable_warnings
+insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z');
+insert into t1 values ('aaaaaaaaaa');
+--error ER_DUP_ENTRY
+insert into t1 values ('aaaaaaaaaaa');
+--error ER_DUP_ENTRY
+insert into t1 values ('aaaaaaaaaaaa');
+insert into t1 values (repeat('b',20));
+select c c1 from t1 where c='1';
+select c c2 from t1 where c='2';
+select c c3 from t1 where c='3';
+select c cx from t1 where c='x';
+select c cy from t1 where c='y';
+select c cz from t1 where c='z';
+select c ca10 from t1 where c='aaaaaaaaaa';
+select c cb20 from t1 where c=repeat('b',20);
+drop table t1;
+
+#
+# Bug 4521: unique key prefix interacts poorly with utf8mb4
+# MYISAM: fixed length keys, case insensitive collation
+#
+eval create table t1 (c char(3) character set utf8mb4, unique (c(2))) engine $engine;
+insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z');
+insert into t1 values ('a');
+insert into t1 values ('aa');
+--error ER_DUP_ENTRY
+insert into t1 values ('aaa');
+insert into t1 values ('b');
+insert into t1 values ('bb');
+--error ER_DUP_ENTRY
+insert into t1 values ('bbb');
+insert into t1 values ('а');
+insert into t1 values ('аа');
+--error ER_DUP_ENTRY
+insert into t1 values ('ааа');
+insert into t1 values ('б');
+insert into t1 values ('бб');
+--error ER_DUP_ENTRY
+insert into t1 values ('ббб');
+insert into t1 values ('ꪪ');
+insert into t1 values ('ꪪꪪ');
+--error ER_DUP_ENTRY
+insert into t1 values ('ꪪꪪꪪ');
+drop table t1;
+#
+# Bug 4521: unique key prefix interacts poorly with utf8mb4
+# InnoDB: fixed length keys, case insensitive collation
+#
+--disable_warnings
+eval create table t1 (c char(3) character set utf8mb4, unique (c(2))) engine=$engine;
+--enable_warnings
+insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z');
+insert into t1 values ('a');
+insert into t1 values ('aa');
+--error ER_DUP_ENTRY
+insert into t1 values ('aaa');
+insert into t1 values ('b');
+insert into t1 values ('bb');
+--error ER_DUP_ENTRY
+insert into t1 values ('bbb');
+insert into t1 values ('а');
+insert into t1 values ('аа');
+--error ER_DUP_ENTRY
+insert into t1 values ('ааа');
+insert into t1 values ('б');
+insert into t1 values ('бб');
+--error ER_DUP_ENTRY
+insert into t1 values ('ббб');
+insert into t1 values ('ꪪ');
+insert into t1 values ('ꪪꪪ');
+--error ER_DUP_ENTRY
+insert into t1 values ('ꪪꪪꪪ');
+drop table t1;
+#
+# Bug 4531: unique key prefix interacts poorly with utf8mb4
+# Check HEAP+HASH, case insensitive collation
+#
+eval create table t1 (
+c char(10) character set utf8mb4,
+unique key a using hash (c(1))
+) engine=$engine;
+show create table t1;
+insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
+--error ER_DUP_ENTRY
+insert into t1 values ('aa');
+--error ER_DUP_ENTRY
+insert into t1 values ('aaa');
+insert into t1 values ('б');
+--error ER_DUP_ENTRY
+insert into t1 values ('s c_a from t1 where c='a';
+select c as c_a from t1 where c='б';
+drop table t1;
+
+#
+# Bug 4531: unique key prefix interacts poorly with utf8mb4
+# Check HEAP+BTREE, case insensitive collation
+#
+eval create table t1 (
+c char(10) character set utf8mb4,
+unique key a using btree (c(1))
+) engine=$engine;
+show create table t1;
+insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
+--error ER_DUP_ENTRY
+insert into t1 values ('aa');
+--error ER_DUP_ENTRY
+insert into t1 values ('aaa');
+insert into t1 values ('б');
+--error ER_DUP_ENTRY
+insert into t1 values ('бб');
+--error ER_DUP_ENTRY
+insert into t1 values ('ббб');
+select c as c_all from t1 order by c;
+select c as c_a from t1 where c='a';
+select c as c_a from t1 where c='б';
+drop table t1;
+
+#
+# Bug 4531: unique key prefix interacts poorly with utf8mb4
+# Check BDB, case insensitive collation
+#
+--disable_warnings
+eval create table t1 (
+c char(10) character set utf8mb4,
+unique key a (c(1))
+) engine=$engine;
+--enable_warnings
+insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
+--error ER_DUP_ENTRY
+insert into t1 values ('aa');
+--error ER_DUP_ENTRY
+insert into t1 values ('aaa');
+insert into t1 values ('б');
+--error ER_DUP_ENTRY
+insert into t1 values ('бб');
+--error ER_DUP_ENTRY
+insert into t1 values ('ббб');
+select c as c_all from t1 order by c;
+select c as c_a from t1 where c='a';
+select c as c_a from t1 where c='б';
+drop table t1;
+
+#
+# Bug 4521: unique key prefix interacts poorly with utf8mb4
+# MYISAM: keys with prefix compression, binary collation.
+#
+eval create table t1 (c varchar(30) character set utf8mb4 collate utf8mb4_bin, unique(c(10))) engine $engine;
+insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z');
+insert into t1 values ('aaaaaaaaaa');
+--error ER_DUP_ENTRY
+insert into t1 values ('aaaaaaaaaaa');
+--error ER_DUP_ENTRY
+insert into t1 values ('aaaaaaaaaaaa');
+insert into t1 values (repeat('b',20));
+select c c1 from t1 where c='1';
+select c c2 from t1 where c='2';
+select c c3 from t1 where c='3';
+select c cx from t1 where c='x';
+select c cy from t1 where c='y';
+select c cz from t1 where c='z';
+select c ca10 from t1 where c='aaaaaaaaaa';
+select c cb20 from t1 where c=repeat('b',20);
+drop table t1;
+
+#
+# Bug 4521: unique key prefix interacts poorly with utf8mb4
+# MYISAM: fixed length keys, binary collation
+#
+eval create table t1 (c char(3) character set utf8mb4 collate utf8mb4_bin, unique (c(2))) engine $engine;
+insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z');
+insert into t1 values ('a');
+insert into t1 values ('aa');
+--error ER_DUP_ENTRY
+insert into t1 values ('aaa');
+insert into t1 values ('b');
+insert into t1 values ('bb');
+--error ER_DUP_ENTRY
+insert into t1 values ('bbb');
+insert into t1 values ('а');
+insert into t1 values ('аа');
+--error ER_DUP_ENTRY
+insert into t1 values ('ааа');
+insert into t1 values ('б');
+insert into t1 values ('бб');
+--error ER_DUP_ENTRY
+insert into t1 values ('ббб');
+insert into t1 values ('ꪪ');
+insert into t1 values ('ꪪꪪ');
+--error ER_DUP_ENTRY
+insert into t1 values ('ꪪꪪꪪ');
+drop table t1;
+
+#
+# Bug 4531: unique key prefix interacts poorly with utf8mb4
+# Check HEAP+HASH, binary collation
+#
+eval create table t1 (
+c char(10) character set utf8mb4 collate utf8mb4_bin,
+unique key a using hash (c(1))
+) engine=$engine;
+show create table t1;
+insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
+--error ER_DUP_ENTRY
+insert into t1 values ('aa');
+--error ER_DUP_ENTRY
+insert into t1 values ('aaa');
+insert into t1 values ('б');
+--error ER_DUP_ENTRY
+insert into t1 values ('бб');
+--error ER_DUP_ENTRY
+insert into t1 values ('ббб');
+select c as c_all from t1 order by c;
+select c as c_a from t1 where c='a';
+select c as c_a from t1 where c='б';
+drop table t1;
+
+#
+# Bug 4531: unique key prefix interacts poorly with utf8mb4
+# Check HEAP+BTREE, binary collation
+#
+eval create table t1 (
+c char(10) character set utf8mb4 collate utf8mb4_bin,
+unique key a using btree (c(1))
+) engine=$engine;
+show create table t1;
+insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
+--error ER_DUP_ENTRY
+insert into t1 values ('aa');
+--error ER_DUP_ENTRY
+insert into t1 values ('aaa');
+insert into t1 values ('б');
+--error ER_DUP_ENTRY
+insert into t1 values ('бб');
+--error ER_DUP_ENTRY
+insert into t1 values ('ббб');
+select c as c_all from t1 order by c;
+select c as c_a from t1 where c='a';
+select c as c_a from t1 where c='б';
+drop table t1;
+
+#
+# Bug 4531: unique key prefix interacts poorly with utf8mb4
+# Check BDB, binary collation
+#
+--disable_warnings
+eval create table t1 (
+c char(10) character set utf8mb4 collate utf8mb4_bin,
+unique key a (c(1))
+) engine=$engine;
+--enable_warnings
+insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
+--error ER_DUP_ENTRY
+insert into t1 values ('aa');
+--error ER_DUP_ENTRY
+insert into t1 values ('aaa');
+insert into t1 values ('б');
+--error ER_DUP_ENTRY
+insert into t1 values ('бб');
+--error ER_DUP_ENTRY
+insert into t1 values ('ббб');
+select c as c_all from t1 order by c;
+select c as c_a from t1 where c='a';
+select c as c_a from t1 where c='б';
+drop table t1;
+}
+
+
+# Bug#4594: column index make = failed for gbk, but like works
+# Check MYISAM
+#
+eval create table t1 (
+  str varchar(255) character set utf8mb4 not null,
+  key str  (str(2))
+) engine=$engine;
+INSERT INTO t1 VALUES ('str');
+INSERT INTO t1 VALUES ('str2');
+select * from t1 where str='str';
+drop table t1;
+
+# Bug#4594: column index make = failed for gbk, but like works
+# Check InnoDB
+#
+--disable_warnings
+eval create table t1 (
+  str varchar(255) character set utf8mb4 not null,
+  key str  (str(2))
+) engine=$engine;
+--enable_warnings
+INSERT INTO t1 VALUES ('str');
+INSERT INTO t1 VALUES ('str2');
+select * from t1 where str='str';
+drop table t1;
+
+# the same for HEAP+BTREE
+#
+
+eval create table t1 (
+  str varchar(255) character set utf8mb4 not null,
+  key str using btree (str(2))
+) engine=$engine;
+INSERT INTO t1 VALUES ('str');
+INSERT INTO t1 VALUES ('str2');
+select * from t1 where str='str';
+drop table t1;
+
+# the same for HEAP+HASH
+#
+
+if (!$is_ndb)
+{
+eval create table t1 (
+  str varchar(255) character set utf8mb4 not null,
+  key str using hash (str(2))
+) engine=$engine;
+INSERT INTO t1 VALUES ('str');
+INSERT INTO t1 VALUES ('str2');
+select * from t1 where str='str';
+drop table t1;
+
+# the same for BDB
+#
+
+#hh
+--disable_warnings
+eval create table t1 (
+  str varchar(255) character set utf8mb4 not null,
+  key str (str(2))
+) engine= $engine;
+--enable_warnings
+INSERT INTO t1 VALUES ('str');
+INSERT INTO t1 VALUES ('str2');
+select * from t1 where str='str';
+drop table t1;
+}
+
+#
+# Bug #5397: Crash with varchar binary and LIKE
+#
+eval CREATE TABLE t1 (a varchar(32) BINARY) CHARACTER SET utf8mb4 ENGINE $engine;
+INSERT INTO t1 VALUES ('test');
+SELECT a FROM t1 WHERE a LIKE '%te';
+DROP TABLE t1;
+
+#
+# Bug #5723: length(<varchar utf8mb4 field>) returns varying results
+#
+--disable_warnings
+SET NAMES utf8mb4;
+--disable_warnings
+eval CREATE TABLE t1 (
+  subject varchar(255) character set utf8mb4 collate utf8mb4_unicode_ci,
+  p varchar(15) character set utf8mb4
+) ENGINE= $engine DEFAULT CHARSET=latin1;
+--enable_warnings
+INSERT INTO t1 VALUES ('谷川俊二と申しますが、書き込みました。どうすればよいですか? その他、住所等は間違えありません。連'040312-000057');
+INSERT INTO t1 VALUES ('aaa','bbb');
+--sorted_result
+SELECT length(subject) FROM t1;
+SELECT length(subject) FROM t1 ORDER BY 1;
+DROP TABLE t1;
+
+#
+# Bug #5832 SELECT doesn't return records in some cases
+#
+if (!$is_heap)
+{
+if (!$is_ndb)
+{
+eval CREATE TABLE t1 (
+    id       int unsigned NOT NULL auto_increment,
+    list_id  smallint unsigned NOT NULL,
+    term     TEXT NOT NULL,
+    PRIMARY KEY(id),
+    INDEX(list_id, term(4))
+) ENGINE=$engine CHARSET=utf8mb4;
+INSERT INTO t1 SET list_id = 1, term = "letterc";
+INSERT INTO t1 SET list_id = 1, term = "letterb";
+INSERT INTO t1 SET list_id = 1, term = "lettera";
+INSERT INTO t1 SET list_id = 1, term = "letterd";
+SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterc");
+SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterb");
+SELECT id FROM t1 WHERE (list_id = 1) AND (term = "lettera");
+SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterd");
+DROP TABLE t1;
+
+#
+# Bug #6043 erratic searching for diacriticals in indexed MyISAM UTF-8 table
+#
+SET NAMES latin1;
+eval CREATE TABLE t1 (
+    id int unsigned NOT NULL auto_increment,
+    list_id smallint unsigned NOT NULL,
+    term text NOT NULL,
+    PRIMARY KEY(id),
+    INDEX(list_id, term(19))
+) ENGINE=$engine CHARSET=utf8mb4;
+INSERT INTO t1 set list_id = 1, term = "test�st";
+INSERT INTO t1 set list_id = 1, term = "testetest";
+INSERT INTO t1 set list_id = 1, term = "test�st";
+SELECT id, term FROM t1 where (list_id = 1) AND (term = "test�st");
+SELECT id, term FROM t1 where (list_id = 1) AND (term = "testetest");
+SELECT id, term FROM t1 where (list_id = 1) AND (term = "test�st");
+DROP TABLE t1;
+}
+}
+
+#
+# Bug #6019 SELECT tries to use too short prefix index on utf8mb4 data
+#
+set names utf8mb4;
+--disable_warnings
+eval create table t1 (
+  a int primary key,
+  b varchar(6),
+  index b3(b(3))
+) engine=$engine character set=utf8mb4;
+--enable_warnings
+insert into t1 values(1,'foo'),(2,'foobar');
+--sorted_result
+select * from t1 where b like 'foob%';
+--disable_warnings
+alter table t1 engine=innodb;
+--enable_warnings
+--sorted_result
+select * from t1 where b like 'foob%';
+drop table t1;
+
+#
+# Test for calculate_interval_lengths() function
+#
+eval create table t1 (
+  a enum('петя','вася','анюта') character set utf8mb4 not null default 'анюта',
+  b set('ot null default 'анюта'
+) engine $engine;
+eval create table t2 engine $engine select concat(a,_utf8mb4'') as a, concat(b,_utf8mb4'')as b from t1;
+show create table t2;
+drop table t2;
+drop table t1;
+
+#
+# Bug #6787 LIKE not working properly with _ and utf8mb4 data
+#
+select 'c' like '\_' as want0; 
+
+#
+# SUBSTR with negative offset didn't work with multi-byte strings
+#
+SELECT SUBSTR('вася',-2);
+
+
+#
+# Bug #7730 Server crash using soundex on an utf8mb4 table
+#
+eval create table t1 (id integer, a varchar(100) character set utf8mb4 collate utf8mb4_unicode_ci) engine $engine;
+insert into t1 values (1, 'Test');
+select * from t1 where soundex(a) = soundex('Test');
+select * from t1 where soundex(a) = soundex('TEST');
+select * from t1 where soundex(a) = soundex('test');
+drop table t1;
+
+#
+# Bug#22638 SOUNDEX broken for international characters
+#
+select soundex(_utf8mb4 0xE99885E8A788E99A8FE697B6E69BB4E696B0E79A84E696B0E997BB);
+select hex(soundex(_utf8mb4 0xE99885E8A788E99A8FE697B6E69BB4E696B0E79A84E696B0E997BB));
+select soundex(_utf8mb4 0xD091D092D093);
+select hex(soundex(_utf8mb4 0xD091D092D093));
+
+
+SET collation_connection='utf8mb4_general_ci';
+-- source include/ctype_filesort.inc
+-- source include/ctype_like_escape.inc
+-- source include/ctype_german.inc
+SET collation_connection='utf8mb4_bin';
+-- source include/ctype_filesort.inc
+-- source include/ctype_like_escape.inc
+
+#
+# Bug #7874 CONCAT() gives wrong results mixing
+# latin1 field and utf8mb4 string literals
+#
+eval CREATE TABLE t1 (
+	user varchar(255) NOT NULL default ''
+) ENGINE=$engine DEFAULT CHARSET=latin1;
+INSERT INTO t1 VALUES ('one'),('two');
+SELECT CHARSET('a');
+--sorted_result
+SELECT user, CONCAT('<', user, '>') AS c FROM t1;
+DROP TABLE t1;
+
+#
+# Bug#8785
+# the same problem with the above, but with nested CONCATs
+#
+eval create table t1 (f1 varchar(1) not null) default charset utf8mb4 engine $engine;
+insert into t1 values (''), ('');
+select concat(concat(_latin1'->',f1),_latin1'<-') from t1;
+drop table t1;
+
+#
+# Bug#8385: utf8mb4_general_ci treats Cyrillic letters I and SHORT I as the same
+#
+select convert(_koi8r'� using utf8mb4) < convert(_koi8r'� using utf8mb4);
+
+#
+# Bugs#5980: NULL requires a characterset in a union
+#
+set names latin1;
+eval create table t1 (a varchar(10)) character set utf8mb4 engine $engine;
+insert into t1 values ('test');
+select ifnull(a,'') from t1;
+drop table t1;
+select repeat(_utf8mb4'+',3) as h union select NULL;
+select ifnull(NULL, _utf8mb4'string');
+
+#
+# Bug#9509 Optimizer: wrong result after AND with comparisons
+#
+set names utf8mb4;
+eval create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_lithuanian_ci) engine $engine;
+insert into t1 values ('I'),('K'),('Y');
+--sorted_result
+select * from t1 where s1 < 'K' and s1 = 'Y';
+--sorted_result
+select * from t1 where 'K' > s1 and s1 = 'Y';
+drop table t1;
+
+eval create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_czech_ci) engine $engine;
+insert into t1 values ('c'),('d'),('h'),('ch'),('CH'),('cH'),('Ch'),('i');
+--sorted_result
+select * from t1 where s1 > 'd' and s1 = 'CH';
+--sorted_result
+select * from t1 where 'd' < s1 and s1 = 'CH';
+--sorted_result
+select * from t1 where s1 = 'cH' and s1 <> 'ch';
+--sorted_result
+select * from t1 where 'cH' = s1 and s1 <> 'ch';
+drop table t1;
+
+#
+# Bug#10714: Inserting double value into utf8mb4 column crashes server
+#
+eval create table t1 (a varchar(255)) default character set utf8mb4 engine $engine;
+insert into t1 values (1.0);
+drop table t1;
+
+#
+# Bug#10253 compound index length and utf8mb4 char set
+# produces invalid query results
+#
+eval create table t1 (
+ id int not null,
+ city varchar(20) not null,
+ key (city(7),id)
+) character set=utf8mb4 engine $engine;
+insert into t1 values (1,'Durban North');
+insert into t1 values (2,'Durban');
+select * from t1 where city = 'Durban';
+select * from t1 where city = 'Durban ';
+drop table t1;
+
+#
+# Bug #11819 CREATE TABLE with a SET DEFAULT 0 and UTF8 crashes server.
+#
+--error 1067
+eval create table t1 (x set('A', 'B') default 0) character set utf8mb4 engine $engine;
+--error 1067
+eval create table t1 (x enum('A', 'B') default 0) character set utf8mb4 engine $engine;
+
+
+#
+# Test for bug #11167: join for utf8mb4 varchar value longer than 255 bytes 
+#
+
+SET NAMES UTF8;
+
+eval CREATE TABLE t1 (
+  `id` int(20) NOT NULL auto_increment,
+  `country` varchar(100) NOT NULL default '',
+  `shortcode` varchar(100) NOT NULL default '',
+  `operator` varchar(100) NOT NULL default '',
+  `momid` varchar(30) NOT NULL default '',
+  `keyword` varchar(160) NOT NULL default '',
+  `content` varchar(160) NOT NULL default '',
+  `second_token` varchar(160) default NULL,
+  `gateway_id` int(11) NOT NULL default '0',
+  `created` datetime NOT NULL default '0000-00-00 00:00:00',
+  `msisdn` varchar(15) NOT NULL default '',
+  PRIMARY KEY  (`id`),
+  UNIQUE KEY `MSCCSPK_20030521130957121` (`momid`),
+  KEY `IX_mobile_originated_message_keyword` (`keyword`),
+  KEY `IX_mobile_originated_message_created` (`created`),
+  KEY `IX_mobile_originated_message_support` (`msisdn`,`momid`,`keyword`,`gateway_id`,`created`)
+) ENGINE=$engine DEFAULT CHARSET=utf8mb4;
+
+INSERT INTO t1 VALUES 
+(1,'blah','464','aaa','fkc1c9ilc20x0hgae7lx6j09','ERR','ERR Имри.Афимим.Аеимимримдмримрмрирор имримримримр рмдиримримримр м.Дадимфшьмрим6-01 17:30:43','1234567890'),
+(2,'blah','464','aaa','haxpl2ilc20x00bj4tt2m5ti','11','11 g','G',3,'2005-06-02 22:43:10','1234567890');
+
+--disable_warnings
+eval CREATE TABLE t2 (
+  `msisdn` varchar(15) NOT NULL default '',
+  `operator_id` int(11) NOT NULL default '0',
+  `created` datetime NOT NULL default '0000-00-00 00:00:00',
+  UNIQUE KEY `PK_user` (`msisdn`)
+) ENGINE=$engine DEFAULT CHARSET=utf8mb4;
+--enable_warnings
+
+INSERT INTO t2 VALUES ('1234567890',2,'2005-05-24 13:53:25');
+
+SELECT content, t2.msisdn FROM t1, t2 WHERE t1.msisdn = '1234567890';
+
+DROP TABLE t1,t2;
+
+#
+# Bug#11591: CHAR column with utf8mb4 does not work properly
+# (more chars than expected)
+#
+eval create table t1 (a char(20) character set utf8mb4) engine $engine;
+insert into t1 values ('123456'),('андрей');
+alter table t1 modify a char(2) character set utf8mb4;
+select char_length(a), length(a), a from t1 order by a;
+drop table t1;
+
+#
+# Bugs#12611
+# ESCAPE + LIKE do not work when the escape char is a multibyte one
+#
+set names utf8mb4;
+select 'andre%' like 'andreñ%' escape 'ñ';
+
+#
+# Bugs#11754: SET NAMES utf8mb4 followed by SELECT "A\\" LIKE "A\\" returns 0
+#
+set names utf8mb4;
+select 'a\\' like 'a\\';
+select 'aa\\' like 'a%\\';
+
+eval create table t1 (a char(10), key(a)) character set utf8mb4 engine $engine;
+insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test");
+--sorted_result
+select * from t1 where a like "abc%";
+--sorted_result
+select * from t1 where a like concat("abc","%");
+--sorted_result
+select * from t1 where a like "ABC%";
+select * from t1 where a like "test%";
+select * from t1 where a like "te_t";
+--sorted_result
+select * from t1 where a like "%a%";
+--sorted_result
+select * from t1 where a like "%abcd%";
+select * from t1 where a like "%abc\d%";
+drop table t1;
+
+
+#
+# Bug#9557 MyISAM utf8mb4 table crash
+#
+eval CREATE TABLE t1 (
+  a varchar(255) NOT NULL default '',
+  KEY a (a)
+) ENGINE=$engine DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;
+insert into t1 values (_utf8mb4 0xe880bd);
+insert into t1 values (_utf8mb4 0x5b);
+--sorted_result
+select hex(a) from t1;
+drop table t1;
+
+#
+# Bug#13751 find_in_set: Illegal mix of collations
+#
+set names 'latin1';
+eval create table t1 (a varchar(255)) default charset=utf8mb4 engine $engine;
+select * from t1 where find_in_set('-1', a);
+drop table t1;
+
+#
+# Bug#13233: select distinct char(column) fails with utf8mb4
+#
+eval create table t1 (a int) engine $engine;
+insert into t1 values (48),(49),(50);
+set names utf8mb4;
+--sorted_result
+select distinct char(a) from t1;
+drop table t1;
+
+if (!$is_heap)
+{
+#
+# Bug#15581: COALESCE function truncates mutli-byte TINYTEXT values
+#
+eval CREATE TABLE t1 (t TINYTEXT CHARACTER SET utf8mb4) ENGINE $engine;
+INSERT INTO t1 VALUES(REPEAT('a', 100));
+if (!$is_ndb)
+{
+eval CREATE TEMPORARY TABLE t2 ENGINE $engine SELECT COALESCE(t) AS bug FROM t1;
+}
+if ($is_ndb)
+{
+eval CREATE TABLE t2 ENGINE $engine SELECT COALESCE(t) AS bug FROM t1;
+}
+SELECT LENGTH(bug) FROM t2;
+DROP TABLE t2;
+DROP TABLE t1;
+}
+
+#
+# Bug#17313: N'xxx' and _utf8mb4'xxx' are not equivalent
+#
+eval CREATE TABLE t1 (item varchar(255)) default character set utf8mb4 ENGINE $engine;
+INSERT INTO t1 VALUES (N'\\');
+INSERT INTO t1 VALUES (_utf8mb4'\\');
+INSERT INTO t1 VALUES (N'Cote d\'Ivoire');
+INSERT INTO t1 VALUES (_utf8mb4'Cote d\'Ivoire');
+SELECT item FROM t1 ORDER BY item;
+DROP TABLE t1;
+
+#
+# Bug#17705: Corruption of compressed index when index length changes between
+# 254 and 256
+#
+
+SET NAMES utf8mb4;
+DROP TABLE IF EXISTS t1;
+eval CREATE TABLE t1(a VARCHAR(255), KEY(a)) ENGINE=$engine DEFAULT CHARSET=utf8mb4;
+INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb');
+INSERT INTO t1 VALUES('uu');
+check table t1;
+INSERT INTO t1 VALUES('uU');
+check table t1;
+INSERT INTO t1 VALUES('uu');
+check table t1;
+INSERT INTO t1 VALUES('uuABC');
+check table t1;
+INSERT INTO t1 VALUES('UuABC');
+check table t1;
+INSERT INTO t1 VALUES('uuABC');
+check table t1;
+alter table t1 add b int;
+INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',1);
+INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',2);
+delete from t1 where b=1;
+INSERT INTO t1 VALUES('UUABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',1);
+check table t1;
+INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',3);
+INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',4);
+delete from t1 where b=3;
+INSERT INTO t1 VALUES('uUABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',3);
+check table t1;
+drop table t1;
+
+#
+# Bug#20471 LIKE search fails with indexed utf8mb4 char column
+#
+set names utf8mb4;
+eval create table t1 (s1 char(5) character set utf8mb4) engine $engine;
+insert into t1 values
+('a'),('b'),(null),('ペテルグル'),('ü'),('Y');
+create index it1 on t1 (s1);
+select s1 as before_delete_general_ci from t1 where s1 like 'ペテ%';
+delete from t1 where s1 = 'Y';
+select s1 as after_delete_general_ci from t1 where s1 like 'ペテ%';
+drop table t1;
+
+set names utf8mb4;
+eval create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_unicode_ci) engine $engine;
+insert into t1 values
+('a'),('b'),(null),('ペテルグル'),('ü'),('Y');
+create index it1 on t1 (s1);
+select s1 as before_delete_unicode_ci from t1 where s1 like 'er_delete_unicode_ci from t1 where s1 like 'ペテ%';
+drop table t1;
+
+set names utf8mb4;
+eval create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_bin) engine $engine;
+insert into t1 values
+('a'),('b'),(null),('ペテルグル'),('ü'),('Y');
+create index it1 on t1 (s1);
+select s1 as before_delete_bin from t1 where s1 like 'ペテ%';
+delete from t1 where s1 = 'Y';
+select s1 as after_delete_bin from t1 where s1 like 'ペテ%';
+drop table t1;
+
+# additional tests from duplicate bug#20744 MySQL return no result
+
+set names utf8mb4;
+--disable_warnings
+eval create table t1 (a varchar(30) not null primary key)
+engine=$engine default character set utf8mb4 collate utf8mb4_general_ci;
+--enable_warnings
+insert into t1 values ('あいうえおかきくけこさしす a like 'さしすせそかきくけこあいうえお%';
+select a as gci2 from t1 where a like 'あいうえおmes utf8mb4;
+--disable_warnings
+eval create table t1 (a varchar(30) not null primary key)
+engine=$engine default character set utf8mb4 collate utf8mb4_unicode_ci;
+--enable_warnings
+insert into t1 values ('あいうえおかきくけこさしすせそ');
+insert into t1 values (' as uci1 from t1 where a like 'さしすせそかきくlike 'あいうえおかきくけこさしすせそ';
+drop table t1;
+
+set names utf8mb4;
+--disable_warnings
+eval create table t1 (a varchar(30) not null primary key)
+engine=$engine default character set utf8mb4 collate utf8mb4_bin;
+--enable_warnings
+insert into t1 values ('あいうえおかきくけこさしすせそ');
+insert into t1 values ('さしすせそかきくけこあいうえrom t1 where a like 'あいうえおかきくけこさしすせそ';
+drop table t1;
+
+
+
+#
+# Bug#14896: Comparison with a key in a partial index over mb chararacter field
+#
+
+SET NAMES utf8mb4;
+eval CREATE TABLE t1 (id int PRIMARY KEY,
+                 a varchar(16) collate utf8mb4_unicode_ci NOT NULL default '',
+                 b int,
+                 f varchar(128) default 'XXX',
+                 INDEX (a(4))
+) ENGINE=$engine DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+INSERT INTO t1(id, a, b) VALUES
+  (1, 'cccc', 50), (2, 'cccc', 70), (3, 'cccc', 30),
+  (4, 'cccc', 30), (5, 'cccc', 20), (6, 'bbbbbb', 40),
+  (7, 'dddd', 30), (8, 'aaaa', 10), (9, 'aaaa', 50),
+  (10, 'eeeee', 40), (11, 'bbbbbb', 60);
+
+--sorted_result
+SELECT id, a, b FROM t1;
+
+--sorted_result
+SELECT id, a, b FROM t1 WHERE a BETWEEN 'aaaa' AND 'bbbbbb';
+
+--sorted_result
+SELECT id, a FROM t1 WHERE a='bbbbbb';
+SELECT id, a FROM t1 WHERE a='bbbbbb' ORDER BY b;
+
+DROP TABLE t1;
+
+#
+# Bug#16674: LIKE predicate for a utf8mb4 character set column
+#
+
+SET NAMES utf8mb4;
+
+eval CREATE TABLE t1 (
+  a CHAR(13) DEFAULT '',
+  INDEX(a)
+) ENGINE=$engine DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+INSERT INTO t1 VALUES 
+ ('Käli KKäli Käli 2+4'),
+ ('Käli Käli 2-6'), ('Käli Käli 2-6');
+INSERT INTO t1 SELECT * FROM t1;
+
+eval CREATE TABLE t2 (
+  a CHAR(13) DEFAULT '',
+  INDEX(a)
+) ENGINE=$engine DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
+
+INSERT INTO t2 VALUES
+ ('Kali Kali 2-4'), ('Kali Kali 2-4'),
+ ('Kali Kali 2+4'), ('Kali Kali 2+4'),
+ ('Kali Kali 2-6'), ('Kali Kali 2-6');
+INSERT INTO t2 SELECT * FROM t2;
+
+SELECT a FROM t1 WHERE a LIKE 'Käli Käli 2+4';
+SELECT a FROM t2 WHERE a LIKE 'Kali Kali 2+4';
+
+EXPLAIN SELECT a FROM t1 WHERE a LIKE 'Käli Käli 2+4';
+EXPLAIN SELECT a FROM t1 WHERE a = 'Käli Käli 2+4';
+EXPLAIN SELECT a FROM t2 WHERE a LIKE 'Kali Kali 2+4';
+EXPLAIN SELECT a FROM t2 WHERE a = 'Kali Kali 2+4';
+
+DROP TABLE t1,t2;
+
+eval CREATE TABLE t1 (
+  a char(255) DEFAULT '', 
+  KEY(a(10))
+) ENGINE=$engine DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+INSERT INTO t1 VALUES ('Käli Käli 2-4');
+SELECT * FROM t1 WHERE a LIKE 'K;
+SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%';
+DROP TABLE t1;
+
+eval CREATE TABLE t1 (
+  a char(255) DEFAULT ''
+) ENGINE=$engine DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+INSERT INTO t1 VALUES ('Käli Käli 2-4');
+INSERT INTO t1 VALUES ('Käli Käli 2-4');
+SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%';
+ALTER TABLE t1 ADD KEY (a(10));
+SELECT * FROM t1 WHERE a LIKE 'Käli Ke for a 'utf8mb4' text column with a partial index
+#            (see bug #16674 as well)
+#
+
+SET NAMES latin2;
+
+if (!$is_heap)
+{
+if (!$is_ndb)
+{
+eval CREATE TABLE t1 (
+  id int(11) NOT NULL default '0',
+  tid int(11) NOT NULL default '0',
+  val text NOT NULL,
+  INDEX idx(tid, val(10))
+) ENGINE=$engine DEFAULT CHARSET=utf8mb4;
+
+INSERT INTO t1 VALUES
+  (40988,72,'VOLN�ADSL'),(41009,72,'VOLN�ADSL'),
+  (41032,72,'VOLN�ADSL'),(41038,72,'VOLN�ADSL'),
+  (41063,72,'VOLN�ADSL'),(41537,72,'VOLN�ADSL Office'),
+  (42141,72,'VOLN�ADSL'),(42565,72,'VOLN�ADSL Combi'),
+  (42749,72,'VOLN�ADSL'),(44205,72,'VOLN�ADSL');
+
+SELECT * FROM t1 WHERE tid=72 and val LIKE 'VOLNY ADSL'; 
+SELECT * FROM t1 WHERE tid=72 and val LIKE 'VOLN�ADSL'; 
+SELECT * FROM t1 WHERE tid=72 and val LIKE '%VOLN�ADSL'; 
+
+ALTER TABLE t1 DROP KEY idx;
+ALTER TABLE t1 ADD KEY idx (tid,val(11));
+
+SELECT * FROM t1 WHERE tid=72 and val LIKE 'VOLN�ADSL'; 
+
+DROP TABLE t1;
+}
+}
+
+#
+# Bug 20709: problem with utf8mb4 fields in temporary tables
+#
+
+eval create table t1(a char(200) collate utf8mb4_unicode_ci NOT NULL default '')
+  default charset=utf8mb4 collate=utf8mb4_unicode_ci engine $engine;
+insert into t1 values (unhex('65')), (unhex('C3A9')), (unhex('65'));
+explain select distinct a from t1;
+SELECT COUNT(*) FROM (SELECT DISTINCT a FROM t1) AS t2;
+explain select a from t1 group by a;
+SELECT COUNT(*) FROM (SELECT a FROM t1 GROUP BY a) AS t2;
+drop table t1;
+
+#
+# Bug #20204: "order by" changes the results returned
+#
+
+eval create table t1(a char(10)) default charset utf8mb4 engine $engine;
+insert into t1 values ('123'), ('456');
+explain
+  select substr(Z.a,-1), Z.a from t1 as Y join t1 as Z on Y.a=Z.a order by 1;
+select substr(Z.a,-1), Z.a from t1 as Y join t1 as Z on Y.a=Z.a order by 1;
+drop table t1;
+
+#
+# Bug #34349: Passing invalid parameter to CHAR() in an ORDER BY causes
+# MySQL to hang
+#
+
+SET CHARACTER SET utf8mb4;
+SHOW VARIABLES LIKE 'character\_set\_%';
+CREATE DATABASE crashtest DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
+USE crashtest;
+eval CREATE TABLE crashtest (crash char(10)) DEFAULT CHARSET=utf8mb4 ENGINE $engine;
+INSERT INTO crashtest VALUES ('35'), ('36'), ('37');
+SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8mb4);
+INSERT INTO crashtest VALUES ('-1000');
+EXPLAIN SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8mb4);
+SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8mb4);
+DROP TABLE crashtest;
+DROP DATABASE crashtest;
+USE test;
+SET CHARACTER SET default;
+
+# End of 4.1 tests
+
+#
+# Test for bug #11484: wrong results for a DISTINCT varchar column in uft8. 
+#
+
+eval CREATE TABLE t1(id varchar(20) NOT NULL) DEFAULT CHARSET=utf8mb4 ENGINE $engine;
+INSERT INTO t1 VALUES ('xxx'), ('aa'), ('yyy'), ('aa');
+
+--sorted_result
+SELECT id FROM t1;
+--sorted_result
+SELECT DISTINCT id FROM t1;
+SELECT DISTINCT id FROM t1 ORDER BY id;
+
+DROP TABLE t1;
+
+#
+# Bug#20095 Changing length of VARCHAR field with UTF8
+# collation does not truncate values
+#
+eval create table t1 (
+  a varchar(26) not null
+) default character set utf8mb4 ENGINE $engine;
+insert into t1 (a) values ('abcdefghijklmnopqrstuvwxyz');
+select * from t1;
+# varchar to varchar
+alter table t1 change a a varchar(20) character set utf8mb4 not null;
+select * from t1;
+# varchar to char
+alter table t1 change a a char(15) character set utf8mb4 not null;
+select * from t1;
+# char to char
+alter table t1 change a a char(10) character set utf8mb4 not null;
+select * from t1;
+# char to varchar
+alter table t1 change a a varchar(5) character set utf8mb4 not null;
+select * from t1;
+drop table t1;
+
+#
+# Check that do_varstring2_mb produces a warning
+#
+if (!$is_ndb)
+{
+eval create table t1 (
+  a varchar(4000) not null
+) default character set utf8mb4 engine $engine;
+insert into t1 values (repeat('a',4000));
+alter table t1 change a a varchar(3000) character set utf8mb4 not null;
+select length(a) from t1;
+drop table t1;
+}
+
+#
+#  Bug#10504: Character set does not support traditional mode
+#  Bug#14146: CHAR(...USING ...) and CONVERT(CHAR(...) USING...)
+#             produce different results
+#
+set names utf8mb4;
+# correct value
+select hex(char(1 using utf8mb4));
+select char(0xd1,0x8f using utf8mb4);
+select char(0xd18f using utf8mb4);
+select char(53647 using utf8mb4);
+# incorrect value: return with warning
+select char(0xff,0x8f using utf8mb4);
+select convert(char(0xff,0x8f) using utf8mb4);
+# incorrect value in strict mode: return NULL with "Error" level warning
+set sql_mode=traditional;
+select char(0xff,0x8f using utf8mb4);
+select char(195 using utf8mb4);
+select char(196 using utf8mb4);
+select char(2557 using utf8mb4);
+select convert(char(0xff,0x8f) using utf8mb4);
+
+#
+# Check convert + char + using
+#
+select hex(convert(char(2557 using latin1) using utf8mb4));
+
+#
+# char() without USING returns "binary" by default, any argument is ok
+#
+select hex(char(195));
+select hex(char(196));
+select hex(char(2557));
+
+
+
+#
+# Bug#12891: UNION doesn't return DISTINCT result for multi-byte characters
+#
+set names utf8mb4;
+eval create table t1 (a char(1)) default character set utf8mb4 engine $engine;
+eval create table t2 (a char(1)) default character set utf8mb4 engine $engine;
+insert into t1 values('a'),('a'),(0xE38182),(0xE38182);
+insert into t1 values('i'),('i'),(0xE38184),(0xE38184);
+--sorted_result
+select * from t1 union distinct select * from t2;
+drop table t1,t2;
+
+
+#
+# Bug#12371: executing prepared statement fails (illegal mix of collations)
+#
+set names utf8mb4;
+eval create table t1 (a char(10), b varchar(10)) engine $engine;
+insert into t1 values ('bar','kostja');
+insert into t1 values ('kostja','bar');
+prepare my_stmt from "select * from t1 where a=?";
+set @a:='bar';
+execute my_stmt using @a;
+set @a:='kostja';
+execute my_stmt using @a;
+set @a:=null;
+execute my_stmt using @a;
+drop table if exists t1;
+
+
+#
+# Bug#21505 Create view - illegal mix of collation for operation 'UNION'
+#
+--disable_warnings
+drop table if exists t1;
+drop view if exists v1, v2;
+--enable_warnings
+set names utf8mb4;
+eval create table t1(col1 varchar(12) character set utf8mb4 collate utf8mb4_unicode_ci) engine $engine;
+insert into t1 values('t1_val');
+create view v1 as select 'v1_val' as col1;
+select coercibility(col1), collation(col1) from v1;
+create view v2 as select col1 from v1 union select col1 from t1;
+select coercibility(col1), collation(col1)from v2;
+drop view v1, v2;
+create view v1 as select 'v1_val' collate utf8mb4_swedish_ci as col1;
+select coercibility(col1), collation(col1) from v1;
+create view v2 as select col1 from v1 union select col1 from t1;
+select coercibility(col1), collation(col1) from v2;
+drop view v1, v2;
+drop table t1;
+
+#
+# Check conversion of NCHAR strings to subset (e.g. latin1).
+# Conversion is possible if string repertoire is ASCII.
+# Conversion is not possible if the string have extended characters
+#
+set names utf8mb4;
+eval create table t1 (a varchar(10) character set latin1, b int) engine $engine;
+insert into t1 values ('a',1);
+select concat(a, if(b>10, N'x', N'y')) from t1;
+--error 1267
+select concat(a, if(b>10, N'æ', N'ß')) from t1;
+drop table t1;
+
+# Conversion tests for character set introducers
+set names utf8mb4;
+eval create table t1 (a varchar(10) character set latin1, b int) engine $engine;
+insert into t1 values ('a',1);
+select concat(a, if(b>10, _utf8mb4'x', _utf8mb4'y')) from t1;
+--error 1267
+select concat(a, if(b>10, _utf8mb4'æ', _utf8mb4'ß')) from t1;
+drop table t1;
+
+# Conversion tests for introducer + HEX string
+set names utf8mb4;
+eval create table t1 (a varchar(10) character set latin1, b int) engine $engine;
+insert into t1 values ('a',1);
+select concat(a, if(b>10, _utf8mb4 0x78, _utf8mb4 0x79)) from t1;
+--error 1267
+select concat(a, if(b>10, _utf8mb4 0xC3A6, _utf8mb4 0xC3AF)) from t1;
+drop table t1;
+
+# Conversion tests for "text_literal TEXT_STRING_literal" syntax structure
+set names utf8mb4;
+eval create table t1 (a varchar(10) character set latin1, b int) engine $engine;
+insert into t1 values ('a',1);
+select concat(a, if(b>10, 'x' 'x', 'y' 'y')) from t1;
+--error 1267
+select concat(a, if(b>10, 'x' '60: Inconsistent results when joining
+# InnoDB tables using partial UTF8 indexes
+#
+--disable_warnings
+eval CREATE TABLE t1 (
+  colA int(11) NOT NULL,
+  colB varchar(255) character set utf8mb4 NOT NULL,
+   PRIMARY KEY  (colA)
+) ENGINE=$engine DEFAULT CHARSET=latin1;
+--enable_warnings
+INSERT INTO t1 (colA, colB) VALUES (1, 'foo'), (2, 'foo bar');
+--disable_warnings
+eval CREATE TABLE t2 (
+  colA int(11) NOT NULL,
+  colB varchar(255) character set utf8mb4 NOT NULL,
+   KEY bad  (colA,colB(3))
+) ENGINE=$engine DEFAULT CHARSET=latin1;
+--enable_warnings
+INSERT INTO t2 (colA, colB) VALUES (1, 'foo'),(2, 'foo bar');
+SELECT * FROM t1 JOIN t2 ON t1.colA=t2.colA AND t1.colB=t2.colB
+WHERE t1.colA < 3;
+DROP TABLE t1, t2;
+
+#
+# Bug#29205: truncation of UTF8 values when the UNION statement
+# forces collation to the binary charset
+#
+
+SELECT 'н1234567890' UNION SELECT _binary '1';
+SELECT 'н1234567890' UNION SELECT 1;
+
+SELECT '1' UNION SELECT 'н1234567890';
+SELECT 1 UNION SELECT 'н1234567890';
+
+eval CREATE TABLE t1 (c VARCHAR(11)) CHARACTER SET utf8mb4 ENGINE $engine;
+eval CREATE TABLE t2 (b CHAR(1) CHARACTER SET binary, i INT) ENGINE $engine;
+
+INSERT INTO t1 (c) VALUES ('н1234567890');
+INSERT INTO t2 (b, i) VALUES ('1', 1);
+
+SELECT c FROM t1 UNION SELECT b FROM t2;
+SELECT c FROM t1 UNION SELECT i FROM t2;
+
+SELECT b FROM t2 UNION SELECT c FROM t1;
+SELECT i FROM t2 UNION SELECT c FROM t1;
+
+DROP TABLE t1, t2;
+
+#
+# Bug#30982: CHAR(..USING..) can return a not-well-formed string
+# Bug #30986: Character set introducer followed by a HEX string can return bad result
+#
+set sql_mode=traditional;
+select hex(char(0xFF using utf8mb4));
+select hex(convert(0xFF using utf8mb4));
+--error ER_INVALID_CHARACTER_STRING
+select hex(_utf8mb4 0x616263FF);
+--error ER_INVALID_CHARACTER_STRING
+select hex(_utf8mb4 X'616263FF');
+--error ER_INVALID_CHARACTER_STRING
+select hex(_utf8mb4 B'001111111111');
+--error ER_INVALID_CHARACTER_STRING
+select (_utf8mb4 X'616263FF');
+set sql_mode=default;
+select hex(char(0xFF using utf8mb4));
+select hex(convert(0xFF using utf8mb4));
+--error ER_INVALID_CHARACTER_STRING
+select hex(_utf8mb4 0x616263FF);
+--error ER_INVALID_CHARACTER_STRING
+select hex(_utf8mb4 X'616263FF');
+--error ER_INVALID_CHARACTER_STRING
+select hex(_utf8mb4 B'001111111111');
+--error ER_INVALID_CHARACTER_STRING
+select (_utf8mb4 X'616263FF');
+
+#
+# Bug #36772: When using UTF8, CONVERT with GROUP BY returns truncated results
+#
+eval CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL) ENGINE $engine;
+INSERT INTO t1 VALUES (70000, 1092), (70001, 1085), (70002, 1065);
+--sorted_result
+SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b;
+--sorted_result
+SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1;
+ALTER TABLE t1 ADD UNIQUE (b);
+--sorted_result
+SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b;
+DROP INDEX b ON t1;
+--sorted_result
+SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b;
+ALTER TABLE t1 ADD INDEX (b);
+--sorted_result
+SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) from t1 GROUP BY b;
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#26474: Add Sinhala script (Sri Lanka) collation to MySQL
+--echo #
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+eval CREATE TABLE t1 (
+        predicted_order int NOT NULL,
+        utf8mb4_encoding VARCHAR(10) NOT NULL
+) CHARACTER SET utf8mb4 ENGINE $engine;
+INSERT INTO t1 VALUES (19, x'E0B696'), (30, x'E0B69AE0B798'), (61, x'E0B6AF'), (93, x'E0B799'), (52, x'E0B6A6'), (73, x'E0B6BBE0B78AE2808D'), (3, x'E0B686'), (56, x'E0B6AA'), (55, x'E0B6A9'), (70, x'E0B6B9'), (94, x'E0B79A'), (80, x'E0B785'), (25, x'E0B69AE0B791'), (48, x'E0B6A2'), (13, x'E0B690'), (86, x'E0B793'), (91, x'E0B79F'), (81, x'E0B786'), (79, x'E0B784'), (14, x'E0B691'), (99, x'E0B78A'), (8, x'E0B68B'), (68, x'E0B6B7'), (22, x'E0B69A'), (16, x'E0B693'), (33, x'E0B69AE0B7B3'), (38, x'E0B69AE0B79D'), (21, x'E0B683'), (11, x'E0B68E'), (77, x'E0B782'), (40, x'E0B69AE0B78A'), (101, x'E0B78AE2808DE0B6BB'), (35, x'E0B69AE0B79A'), (1, x'E0B7B4'), (9, x'E0B68C'), (96, x'E0B79C'), (6, x'E0B689'), (95, x'E0B79B'), (88, x'E0B796'), (64, x'E0B6B3'), (26, x'E0B69AE0B792'), (82, x'E0B78F'), (28, x'E0B69AE0B794'), (39, x'E0B69AE0B79E'), (97, x'E0B79D'), (2, x'E0B685'), (75, x'E0B780'), (34, x'E0B69AE0B799'), (69, x'E0B6B8'), (83, x'E0B790'), (18, x'E0B695'), (90, x'E0B7B2'), (17, x'E0B694'), (72, x'E0B6BB'), (66, x'E0B6B5'), (59, x'E0B6AD'), (44, x'E0B69E'), (15, x'E0B692'), (23, x'E0B69AE0B78F'), (65, x'E0B6B4'), (42, x'E0B69C'), (63, x'E0B6B1'), (85, x'E0B792'), (47, x'E0B6A1'), (49, x'E0B6A3'), (92, x'E0B7B3'), (78, x'E0B783'), (36, x'E0B69AE0B79B'), (4, x'E0B687'), (24, x'E0B69AE0B790'), (87, x'E0B794'), (37, x'E0B69AE0B79C'), (32, x'E0B69AE0B79F'), (29, x'E0B69AE0B796'), (43, x'E0B69D'), (62, x'E0B6B0'), (100, x'E0B78AE2808DE0B6BA'), (60, x'E0B6AE'), (45, x'E0B69F'), (12, x'E0B68F'), (46, x'E0B6A0'), (50, x'E0B6A5'), (51, x'E0B6A4'), (5, x'E0B688'), (76, x'E0B781'), (89, x'E0B798'), (74, x'E0B6BD'), (10, x'E0B68D'), (57, x'E0B6AB'), (71, x'E0B6BA'), (58, x'E0B6AC'), (27, x'E0B69AE0B793'), (54, x'E0B6A8'), (84, x'E0B791'), (31, x'E0B69AE0B7B2'), (98, x'E0B79E'), (53, x'E0B6A7'), (41, x'E0B69B'), (67, x'E0B6B6'), (7, x'E0B68A'), (20, x'E0B682');
+SELECT predicted_order, hex(utf8mb4_encoding) FROM t1 ORDER BY utf8mb4_encoding COLLATE utf8mb4_sinhala_ci;
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#32914 Character sets: illegal characters in utf8mb4 and utf32 columns
+--echo #
+eval create table t1 (utf8mb4 char(1) character set utf8mb4) engine $engine;
+--echo Testing [F0][90..BF][80..BF][80..BF]
+insert into t1 values (0xF0908080);
+insert into t1 values (0xF0BFBFBF);
+insert into t1 values (0xF08F8080);
+--sorted_result
+select hex(utf8mb4) from t1;
+delete from t1;
+
+--echo Testing [F2..F3][80..BF][80..BF][80..BF]
+insert into t1 values (0xF2808080);
+insert into t1 values (0xF2BFBFBF);
+--sorted_result
+select hex(utf8mb4) from t1;
+delete from t1;
+
+--echo Testing [F4][80..8F][80..BF][80..BF]
+insert into t1 values (0xF4808080);
+insert into t1 values (0xF48F8080);
+insert into t1 values (0xF4908080);
+--sorted_result
+select hex(utf8mb4) from t1;
+drop table t1;
+
+
+--echo #
+--echo # Check strnxfrm() with odd length
+--echo #
+set max_sort_length=5;
+select @@max_sort_length;
+eval create table t1 (a varchar(128) character set utf8mb4 collate utf8mb4_general_ci) engine $engine;
+insert into t1 values ('a'),('b'),('c');
+select * from t1 order by a;
+alter table t1 modify a varchar(128) character set utf8mb4 collate utf8mb4_bin;
+select * from t1 order by a;
+drop table t1;
+set max_sort_length=default;
+
+--echo #
+--echo # Bug#26180: Can't add columns to tables created with utf8mb4 text indexes
+--echo #
+if (!$is_heap)
+{
+if (!$is_ndb)
+{
+eval CREATE TABLE t1 (
+  clipid INT NOT NULL,
+  Tape TINYTEXT,
+  PRIMARY KEY (clipid),
+  KEY tape(Tape(255))
+) CHARACTER SET=utf8mb4 ENGINE $engine;
+ALTER TABLE t1 ADD mos TINYINT DEFAULT 0 AFTER clipid;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+}
+}
+
+#--echo #
+#--echo # Check that supplementary characters are not allowed in identifiers
+#--echo #
+# TODO: activate this when system_charset_info is changed to utf8mb4
+#--error 1300
+#CREATE DATABASE `𐀀`;
+#--error 1300
+#CREATE TABLE `𐀀` (a int);
+#--error 1166
+#CREATE TABLE test.t1 SELECT '𐀀';
+#--error 1300
+#CREATE USER `𐀀`;
+
+--echo #
+--echo # Testing 4-byte values.
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+eval CREATE TABLE t1 (
+        u_decimal int NOT NULL,
+        utf8mb4_encoding VARCHAR(10) NOT NULL
+) CHARACTER SET utf8mb4 ENGINE $engine;
+# Source of the following values: http://www.fileformat.info/info/unicode/block/index.htm
+# SINGLE BARLINE
+INSERT INTO t1 VALUES (119040, x'f09d8480'),
+# G CLEF
+                      (119070, x'f09d849e'),
+# HALF NOTE
+                      (119134, x'f09d859e'),
+# MUSICAL SYMBOL CROIX
+                      (119247, x'f09d878f'),
+# MATHEMATICAL BOLD ITALIC CAPITAL DELTA
+                      (120607, x'f09d9c9f'),
+# SANS-SERIF BOLD ITALIC CAPITAL PI
+                      (120735, x'f09d9e9f'),
+# <Plane 16 Private Use, Last> (last 4 byte character)
+                      (1114111, x'f48fbfbf'),
+# VARIATION SELECTOR-256
+                      (917999, x'f3a087af');
+# All from musical chars
+INSERT INTO t1 VALUES (119070, x'f09d849ef09d859ef09d859ef09d8480f09d859ff09d859ff09d859ff09d85a0f09d85a0f09d8480');
+#  Mix of 3-byte and 4-byte chars 
+INSERT INTO t1 VALUES (65131, x'efb9abf09d849ef09d859ef09d859ef09d8480f09d859fefb9abefb9abf09d85a0efb9ab');
+# All from musical chars, but 11 instead of 10 chars. truncated
+INSERT INTO t1 VALUES (119070, x'f09d849ef09d859ef09d859ef09d8480f09d859ff09d859ff09d859ff09d85a0f09d85a0f09d8480f09d85a0');
+
+--sorted_result
+SELECT u_decimal, hex(utf8mb4_encoding) FROM t1 ORDER BY utf8mb4_encoding COLLATE utf8mb4_general_ci, BINARY utf8mb4_encoding;
+
+# First invalid 4 byte value
+INSERT INTO t1 VALUES (1114111, x'f5808080');
+
+--sorted_result
+SELECT character_maximum_length, character_octet_length FROM information_schema.columns WHERE
+       table_name= 't1' AND column_name= 'utf8mb4_encoding';
+
+--disable_warnings
+DROP TABLE IF EXISTS t2;
+--enable_warnings
+eval CREATE TABLE t2 (
+        u_decimal int NOT NULL,
+        utf8mb3_encoding VARCHAR(10) NOT NULL
+) CHARACTER SET utf8mb3 ENGINE $engine;
+# LATIN CAPITAL LETTER VEND
+INSERT INTO t2 VALUES (42856, x'ea9da8');
+# SMALL COMMERCIAL AT
+INSERT INTO t2 VALUES (65131, x'efb9ab');
+# <Plane 16 Private Use, Last> (last 4 byte character)
+INSERT INTO t2 VALUES (1114111, x'f48fbfbf');
+
+--sorted_result
+SELECT character_maximum_length, character_octet_length FROM information_schema.columns WHERE
+       table_name= 't2' AND column_name= 'utf8mb3_encoding';
+
+#  Update a 3-byte char col with a 4-byte char, error
+UPDATE t2 SET utf8mb3_encoding= x'f48fbfbd' where u_decimal= 42856;
+
+#  Update to a 3-byte char casted to 4-byte, error?
+UPDATE t2 SET utf8mb3_encoding= _utf8mb4 x'ea9da8' where u_decimal= 42856;
+
+# Returns utfmb4
+--sorted_result
+SELECT HEX(CONCAT(utf8mb4_encoding, _utf8 x'ea9da8')) FROM t1;
+--sorted_result
+SELECT HEX(CONCAT(utf8mb4_encoding, utf8mb3_encoding)) FROM t1,t2;
+
+#--error ER_INVALID_CHARACTER_STRING
+#SELECT CONCAT(_utf8 utf8mb4_encoding, _utf8 '|') FROM t1;
+#--error ER_INVALID_CHARACTER_STRING
+#SELECT CONCAT(_utf8mb3 utf8mb4_encoding, _utf8 '|') FROM t1;
+
+SELECT count(*) FROM t1, t2
+   WHERE t1.utf8mb4_encoding > t2.utf8mb3_encoding;
+
+# Alter from 4-byte charset to 3-byte charset, error
+--disable_warnings
+ALTER TABLE t1 CONVERT TO CHARACTER SET utf8;
+--enable_warnings
+SHOW CREATE TABLE t1;
+--sorted_result
+SELECT u_decimal,hex(utf8mb4_encoding),utf8mb4_encoding FROM t1;
+
+# Alter table from utf8 to utf8mb4
+ALTER TABLE t2 CONVERT TO CHARACTER SET utf8mb4;
+SHOW CREATE TABLE t2;
+--sorted_result
+SELECT u_decimal,hex(utf8mb3_encoding) FROM t2;
+
+# Alter table back from utf8mb4 to utf8
+ALTER TABLE t2 CONVERT TO CHARACTER SET utf8mb3;
+SHOW CREATE TABLE t2;
+--sorted_result
+SELECT u_decimal,hex(utf8mb3_encoding) FROM t2;
+
+# ALter of utf8mb4 column to utf8
+--disable_warnings
+ALTER TABLE t1 MODIFY utf8mb4_encoding VARCHAR(10) CHARACTER SET utf8mb3;
+--enable_warnings
+SHOW CREATE TABLE t1;
+--sorted_result
+SELECT u_decimal,hex(utf8mb4_encoding) FROM t1;
+
+# ALter of utf8 column to utf8mb4
+ALTER TABLE t1 MODIFY utf8mb4_encoding VARCHAR(10) CHARACTER SET utf8mb4;
+SHOW CREATE TABLE t1;
+--sorted_result
+SELECT u_decimal,hex(utf8mb4_encoding) FROM t1;
+
+# ALter of utf8 column to utf8mb4
+ALTER TABLE t2 MODIFY utf8mb3_encoding VARCHAR(10) CHARACTER SET utf8mb4;
+SHOW CREATE TABLE t2;
+--sorted_result
+SELECT u_decimal,hex(utf8mb3_encoding) FROM t2;
+
+--disable_warnings
+DROP TABLE IF EXISTS t3;
+--enable_warnings
+eval CREATE TABLE t3 (
+        u_decimal int NOT NULL,
+        utf8mb3_encoding VARCHAR(10) NOT NULL
+) CHARACTER SET utf8 ENGINE $engine;
+
+# Insert select utf8mb4 (4-byte) into utf8 (3-byte), error
+#--error ER_INVALID_CHARACTER_STRING
+INSERT INTO t3 SELECT * FROM t1;
+
+--disable_warnings
+DROP TABLE IF EXISTS t4;
+--enable_warnings
+eval CREATE TABLE t4 (
+        u_decimal int NOT NULL,
+        utf8mb4_encoding VARCHAR(10) NOT NULL
+) CHARACTER SET utf8mb4 ENGINE $engine;
+
+# Insert select utf8 (3-byte) into utf8mb4 (4-byte)
+INSERT INTO t3 SELECT * FROM t2;
+
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+DROP TABLE t4;
+
+--echo #
+--echo # Testing that mixing utf8 and utf8mb4 collations returns utf8mb4
+--echo #
+SELECT CHARSET(CONCAT(_utf8mb4'a',_utf8'b'));
+
+eval CREATE TABLE t1 (utf8mb4 VARCHAR(10) CHARACTER SET utf8mb4 NOT NULL) ENGINE $engine;
+INSERT INTO t1 VALUES (x'ea9da8'),(x'f48fbfbf');
+SELECT CONCAT(utf8mb4, _utf8 x'ea9da8') FROM t1 LIMIT 0;
+
+eval CREATE TABLE t2 (utf8mb3 VARCHAR(10) CHARACTER SET utf8mb3 NOT NULL) ENGINE $engine;
+INSERT INTO t2 VALUES (x'ea9da8');
+
+SELECT HEX(CONCAT(utf8mb4, utf8mb3)) FROM t1,t2 ORDER BY 1;
+SELECT CHARSET(CONCAT(utf8mb4, utf8mb3)) FROM t1, t2 LIMIT 1;
+
+if (!$is_ndb)
+{
+eval CREATE TEMPORARY TABLE t3 ENGINE $engine AS SELECT *, concat(utf8mb4,utf8mb3) FROM t1, t2;
+SHOW CREATE TABLE t3;
+DROP TEMPORARY TABLE t3;
+}
+
+SELECT * FROM t1, t2 WHERE t1.utf8mb4 > t2.utf8mb3;
+SELECT * FROM t1, t2 WHERE t1.utf8mb4 = t2.utf8mb3;
+SELECT * FROM t1, t2 WHERE t1.utf8mb4 < t2.utf8mb3;
+
+DROP TABLE t1;
+DROP TABLE t2;
+
+--echo #
+--echo # Check that mixing utf8mb4 with an invalid utf8 constant returns error
+--echo #
+# This should perhaps be changed to return ER_INVALID_CHARACTER_STRING
+eval CREATE TABLE t1 (utf8mb4 VARCHAR(10) CHARACTER SET utf8mb4) ENGINE $engine;
+INSERT INTO t1 VALUES (x'f48fbfbf');
+--error ER_CANT_AGGREGATE_2COLLATIONS
+SELECT CONCAT(utf8mb4, _utf8 '�') FROM t1;
+--error ER_CANT_AGGREGATE_2COLLATIONS
+SELECT CONCAT('a', _utf8 '�') FROM t1;
+DROP TABLE t1;
+
+--echo #
+--echo # End of 5.5 tests
+--echo #
+
+--echo #
+--echo # End of tests
+--echo #

=== modified file 'mysql-test/lib/v1/mysql-test-run.pl'
--- a/mysql-test/lib/v1/mysql-test-run.pl	2010-03-03 19:22:02 +0000
+++ b/mysql-test/lib/v1/mysql-test-run.pl	2010-03-06 19:22:04 +0000
@@ -109,6 +109,7 @@ our $glob_use_embedded_server=    0;
 our @glob_test_mode;
 
 our $glob_basedir;
+our $glob_bindir;
 
 our $path_charsetsdir;
 our $path_client_bindir;
@@ -157,7 +158,6 @@ our $exe_mysqltest;
 our $exe_ndbd;
 our $exe_ndb_mgmd;
 our $exe_slave_mysqld;
-our $exe_im;
 our $exe_my_print_defaults;
 our $exe_perror;
 our $lib_udf_example;
@@ -720,13 +720,21 @@ sub command_line_setup () {
     $glob_mysql_test_dir= `cygpath -m "$glob_mysql_test_dir"`;
     chomp($glob_mysql_test_dir);
   }
-  $default_vardir= "$glob_mysql_test_dir/var";
+  if (defined $ENV{MTR_BINDIR}) 
+  {
+    $default_vardir= "$ENV{MTR_BINDIR}/mysql-test/var";
+  }
+  else
+  {
+    $default_vardir= "$glob_mysql_test_dir/var";
+  }
 
   # In most cases, the base directory we find everything relative to,
   # is the parent directory of the "mysql-test" directory. For source
   # distributions, TAR binary distributions and some other packages.
   $glob_basedir= dirname($glob_mysql_test_dir);
 
+  $glob_bindir= $ENV{'MTR_BINDIR'} || $glob_basedir;
   # In the RPM case, binaries and libraries are installed in the
   # default system locations, instead of having our own private base
   # directory. And we install "/usr/share/mysql-test". Moving up one
@@ -792,36 +800,37 @@ sub command_line_setup () {
   }
   else
   {
-    $path_client_bindir= mtr_path_exists("$glob_basedir/client_release",
-					 "$glob_basedir/client_debug",
+    $path_client_bindir= mtr_path_exists("$glob_bindir/client_release",
+					 "$glob_bindir/client_debug",
 					 vs_config_dirs('client', ''),
-					 "$glob_basedir/client",
-					 "$glob_basedir/bin");
+					 "$glob_bindir/client",
+					 "$glob_bindir/bin");
   }
   
   # Look for language files and charsetsdir, use same share
-  $path_share=      mtr_path_exists("$glob_basedir/share/mysql",
-                                    "$glob_basedir/sql/share",
-                                    "$glob_basedir/share");
+  $path_share=      mtr_path_exists("$glob_bindir/share/mysql",
+                                    "$glob_bindir/sql/share",
+                                    "$glob_bindir/share");
 
   $path_language=      mtr_path_exists("$path_share");
-  $path_charsetsdir=   mtr_path_exists("$path_share/charsets");
-
+  $path_charsetsdir =   mtr_path_exists("$glob_basedir/share/mysql/charsets",
+                                    "$glob_basedir/sql/share/charsets",
+                                    "$glob_basedir/share/charsets");
 
   if (!$opt_extern)
   {
     $exe_mysqld=       mtr_exe_exists (vs_config_dirs('sql', 'mysqld'),
                                        vs_config_dirs('sql', 'mysqld-debug'),
-				       "$glob_basedir/sql/mysqld",
+				       "$glob_bindir/sql/mysqld",
 				       "$path_client_bindir/mysqld-max-nt",
 				       "$path_client_bindir/mysqld-max",
 				       "$path_client_bindir/mysqld-nt",
 				       "$path_client_bindir/mysqld",
 				       "$path_client_bindir/mysqld-debug",
 				       "$path_client_bindir/mysqld-max",
-				       "$glob_basedir/libexec/mysqld",
-				       "$glob_basedir/bin/mysqld",
-				       "$glob_basedir/sbin/mysqld");
+				       "$glob_bindir/libexec/mysqld",
+				       "$glob_bindir/bin/mysqld",
+				       "$glob_bindir/sbin/mysqld");
 
     # Use the mysqld found above to find out what features are available
     collect_mysqld_features();
@@ -1563,37 +1572,24 @@ sub collect_mysqld_features_from_running
   }
 }
 
-sub executable_setup_im () {
-
-  # Look for instance manager binary - mysqlmanager
-  $exe_im=
-    mtr_exe_maybe_exists(
-      "$glob_basedir/server-tools/instance-manager/mysqlmanager",
-      "$glob_basedir/libexec/mysqlmanager",
-      "$glob_basedir/bin/mysqlmanager",
-      "$glob_basedir/sbin/mysqlmanager");
-
-  return ($exe_im eq "");
-}
-
 sub executable_setup_ndb () {
 
   # Look for ndb tols and binaries
-  my $ndb_path= mtr_file_exists("$glob_basedir/ndb",
-				"$glob_basedir/storage/ndb",
-				"$glob_basedir/bin");
+  my $ndb_path= mtr_file_exists("$glob_bindir/ndb",
+				"$glob_bindir/storage/ndb",
+				"$glob_bindir/bin");
 
   $exe_ndbd=
     mtr_exe_maybe_exists("$ndb_path/src/kernel/ndbd",
 			 "$ndb_path/ndbd",
-			 "$glob_basedir/libexec/ndbd");
+			 "$glob_bindir/libexec/ndbd");
   $exe_ndb_mgm=
     mtr_exe_maybe_exists("$ndb_path/src/mgmclient/ndb_mgm",
 			 "$ndb_path/ndb_mgm");
   $exe_ndb_mgmd=
     mtr_exe_maybe_exists("$ndb_path/src/mgmsrv/ndb_mgmd",
 			 "$ndb_path/ndb_mgmd",
-			 "$glob_basedir/libexec/ndb_mgmd");
+			 "$glob_bindir/libexec/ndb_mgmd");
   $exe_ndb_waiter=
     mtr_exe_maybe_exists("$ndb_path/tools/ndb_waiter",
 			 "$ndb_path/ndb_waiter");
@@ -1636,11 +1632,11 @@ sub executable_setup () {
   $exe_my_print_defaults=
     mtr_exe_exists(vs_config_dirs('extra', 'my_print_defaults'),
 		           "$path_client_bindir/my_print_defaults",
-		           "$glob_basedir/extra/my_print_defaults");
+		           "$glob_bindir/extra/my_print_defaults");
 
   # Look for perror
   $exe_perror= mtr_exe_exists(vs_config_dirs('extra', 'perror'),
-			                  "$glob_basedir/extra/perror",
+			                  "$glob_bindir/extra/perror",
 			                  "$path_client_bindir/perror");
 
   # Look for the client binaries
@@ -1697,23 +1693,15 @@ sub executable_setup () {
       }
     }
 
-    if ( ! $opt_skip_im and executable_setup_im())
-    {
-      mtr_warning("Could not find all required instance manager binaries, " .
-  		"all im tests will fail, use --skip-im to " .
-  		"continue without instance manager");
-      $instance_manager->{"executable_setup_failed"}= 1;
-    }
-
     # Look for the udf_example library
     $lib_udf_example=
       mtr_file_exists(vs_config_dirs('sql', 'udf_example.dll'),
-                      "$glob_basedir/sql/.libs/udf_example.so",);
+                      "$glob_bindir/sql/.libs/udf_example.so",);
 
     # Look for the ha_example library
     $lib_example_plugin=
       mtr_file_exists(vs_config_dirs('storage/example', 'ha_example.dll'),
-                      "$glob_basedir/storage/example/.libs/ha_example.so",);
+                      "$glob_bindir/storage/example/.libs/ha_example.so",);
 
   }
 
@@ -1722,7 +1710,7 @@ sub executable_setup () {
   {
     $exe_mysqltest=
       mtr_exe_exists(vs_config_dirs('libmysqld/examples','mysqltest_embedded'),
-                     "$glob_basedir/libmysqld/examples/mysqltest_embedded",
+                     "$glob_bindir/libmysqld/examples/mysqltest_embedded",
                      "$path_client_bindir/mysqltest_embedded");
   }
   else
@@ -1737,21 +1725,21 @@ sub executable_setup () {
     $exe_mysql_client_test=
       mtr_exe_maybe_exists(
         vs_config_dirs('libmysqld/examples', 'mysql_client_test_embedded'),
-        "$glob_basedir/libmysqld/examples/mysql_client_test_embedded");
+        "$glob_bindir/libmysqld/examples/mysql_client_test_embedded");
   }
   else
   {
     $exe_mysql_client_test=
       mtr_exe_maybe_exists(vs_config_dirs('tests', 'mysql_client_test'),
-                           "$glob_basedir/tests/mysql_client_test",
-                           "$glob_basedir/bin/mysql_client_test");
+                           "$glob_bindir/tests/mysql_client_test",
+                           "$glob_bindir/bin/mysql_client_test");
   }
 
   # Look for bug25714 executable which may _not_ exist in
   # some versions, test using it should be skipped
   $exe_bug25714=
       mtr_exe_maybe_exists(vs_config_dirs('tests', 'bug25714'),
-                           "$glob_basedir/tests/bug25714");
+                           "$glob_bindir/tests/bug25714");
 }
 
 
@@ -1860,13 +1848,13 @@ sub environment_setup () {
     # are used in favor of the system installed ones
     if ( $source_dist )
     {
-      push(@ld_library_paths, "$glob_basedir/libmysql/.libs/",
-	   "$glob_basedir/libmysql_r/.libs/",
-	   "$glob_basedir/zlib.libs/");
+      push(@ld_library_paths, "$glob_bindir/libmysql/.libs/",
+	   "$glob_bindir/libmysql_r/.libs/",
+	   "$glob_bindir/zlib.libs/");
     }
     else
     {
-      push(@ld_library_paths, "$glob_basedir/lib");
+      push(@ld_library_paths, "$glob_bindir/lib");
     }
   }
 
@@ -1875,7 +1863,7 @@ sub environment_setup () {
   # --------------------------------------------------------------------------
   if ( $glob_ndbcluster_supported )
   {
-    push(@ld_library_paths,  "$glob_basedir/storage/ndb/src/.libs");
+    push(@ld_library_paths,  "$glob_bindir/storage/ndb/src/.libs");
   }
 
   # --------------------------------------------------------------------------
@@ -1993,7 +1981,6 @@ sub environment_setup () {
   # ----------------------------------------------------
   if ( ! $opt_skip_im )
   {
-    $ENV{'IM_EXE'}=             $exe_im;
     $ENV{'IM_PATH_PID'}=        $instance_manager->{path_pid};
     $ENV{'IM_PATH_ANGEL_PID'}=  $instance_manager->{path_angel_pid};
     $ENV{'IM_PORT'}=            $instance_manager->{port};
@@ -2190,14 +2177,14 @@ sub environment_setup () {
                        vs_config_dirs('storage/myisam', 'myisamchk'),
                        vs_config_dirs('myisam', 'myisamchk'),
                        "$path_client_bindir/myisamchk",
-                       "$glob_basedir/storage/myisam/myisamchk",
-                       "$glob_basedir/myisam/myisamchk"));
+                       "$glob_bindir/storage/myisam/myisamchk",
+                       "$glob_bindir/myisam/myisamchk"));
   $ENV{'MYISAMPACK'}= mtr_native_path(mtr_exe_exists(
                         vs_config_dirs('storage/myisam', 'myisampack'),
                         vs_config_dirs('myisam', 'myisampack'),
                         "$path_client_bindir/myisampack",
-                        "$glob_basedir/storage/myisam/myisampack",
-                        "$glob_basedir/myisam/myisampack"));
+                        "$glob_bindir/storage/myisam/myisampack",
+                        "$glob_bindir/myisam/myisampack"));
 
   # ----------------------------------------------------
   # We are nice and report a bit about our settings
@@ -2548,12 +2535,12 @@ sub vs_config_dirs ($$) {
 
   if ($opt_vs_config)
   {
-    return ("$glob_basedir/$path_part/$opt_vs_config/$exe");
+    return ("$glob_bindir/$path_part/$opt_vs_config/$exe");
   }
 
-  return ("$glob_basedir/$path_part/release/$exe",
-          "$glob_basedir/$path_part/relwithdebinfo/$exe",
-          "$glob_basedir/$path_part/debug/$exe");
+  return ("$glob_bindir/$path_part/release/$exe",
+          "$glob_bindir/$path_part/relwithdebinfo/$exe",
+          "$glob_bindir/$path_part/debug/$exe");
 }
 
 ##############################################################################

=== modified file 'mysql-test/r/ctype_utf8mb4.result'
--- a/mysql-test/r/ctype_utf8mb4.result	2010-02-24 15:42:40 +0000
+++ b/mysql-test/r/ctype_utf8mb4.result	2010-03-04 12:02:30 +0000
@@ -2158,6 +2158,10 @@ u_decimal	hex(utf8mb4_encoding)
 INSERT INTO t1 VALUES (1114111, x'f5808080');
 Warnings:
 Warning	1366	Incorrect string value: '\xF5\x80\x80\x80' for column 'utf8mb4_encoding' at row 1
+SELECT character_maximum_length, character_octet_length FROM information_schema.columns WHERE
+table_name= 't1' AND column_name= 'utf8mb4_encoding';
+character_maximum_length	character_octet_length
+10	40
 DROP TABLE IF EXISTS t2;
 CREATE TABLE t2 (
 u_decimal int NOT NULL,
@@ -2168,20 +2172,197 @@ INSERT INTO t2 VALUES (65131, x'efb9ab')
 INSERT INTO t2 VALUES (1114111, x'f48fbfbf');
 Warnings:
 Warning	1366	Incorrect string value: '\xF4\x8F\xBF\xBF' for column 'utf8mb3_encoding' at row 1
+SELECT character_maximum_length, character_octet_length FROM information_schema.columns WHERE
+table_name= 't2' AND column_name= 'utf8mb3_encoding';
+character_maximum_length	character_octet_length
+10	30
+UPDATE t2 SET utf8mb3_encoding= x'f48fbfbd' where u_decimal= 42856;
+Warnings:
+Warning	1366	Incorrect string value: '\xF4\x8F\xBF\xBD' for column 'utf8mb3_encoding' at row 1
+UPDATE t2 SET utf8mb3_encoding= _utf8mb4 x'ea9da8' where u_decimal= 42856;
+SELECT HEX(CONCAT(utf8mb4_encoding, _utf8 x'ea9da8')) FROM t1;
+HEX(CONCAT(utf8mb4_encoding, _utf8 x'ea9da8'))
+F09D8480EA9DA8
+F09D849EEA9DA8
+F09D859EEA9DA8
+F09D878FEA9DA8
+F09D9C9FEA9DA8
+F09D9E9FEA9DA8
+F48FBFBFEA9DA8
+F3A087AFEA9DA8
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480EA9DA8
+EFB9ABF09D849EF09D859EF09D859EF09D8480F09D859FEFB9ABEFB9ABF09D85A0EFB9ABEA9DA8
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480EA9DA8
+EA9DA8
+SELECT HEX(CONCAT(utf8mb4_encoding, utf8mb3_encoding)) FROM t1,t2;
+HEX(CONCAT(utf8mb4_encoding, utf8mb3_encoding))
+F09D8480EA9DA8
+F09D8480EFB9AB
+F09D8480
+F09D849EEA9DA8
+F09D849EEFB9AB
+F09D849E
+F09D859EEA9DA8
+F09D859EEFB9AB
+F09D859E
+F09D878FEA9DA8
+F09D878FEFB9AB
+F09D878F
+F09D9C9FEA9DA8
+F09D9C9FEFB9AB
+F09D9C9F
+F09D9E9FEA9DA8
+F09D9E9FEFB9AB
+F09D9E9F
+F48FBFBFEA9DA8
+F48FBFBFEFB9AB
+F48FBFBF
+F3A087AFEA9DA8
+F3A087AFEFB9AB
+F3A087AF
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480EA9DA8
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480EFB9AB
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480
+EFB9ABF09D849EF09D859EF09D859EF09D8480F09D859FEFB9ABEFB9ABF09D85A0EFB9ABEA9DA8
+EFB9ABF09D849EF09D859EF09D859EF09D8480F09D859FEFB9ABEFB9ABF09D85A0EFB9ABEFB9AB
+EFB9ABF09D849EF09D859EF09D859EF09D8480F09D859FEFB9ABEFB9ABF09D85A0EFB9AB
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480EA9DA8
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480EFB9AB
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480
+EA9DA8
+EFB9AB
+
+SELECT count(*) FROM t1, t2
+WHERE t1.utf8mb4_encoding > t2.utf8mb3_encoding;
+count(*)
+33
+ALTER TABLE t1 CONVERT TO CHARACTER SET utf8;
+Warnings:
+Warning	1366	Incorrect string value: '\xF0\x9D\x84\x80' for column 'utf8mb4_encoding' at row 1
+Warning	1366	Incorrect string value: '\xF0\x9D\x84\x9E' for column 'utf8mb4_encoding' at row 2
+Warning	1366	Incorrect string value: '\xF0\x9D\x85\x9E' for column 'utf8mb4_encoding' at row 3
+Warning	1366	Incorrect string value: '\xF0\x9D\x87\x8F' for column 'utf8mb4_encoding' at row 4
+Warning	1366	Incorrect string value: '\xF0\x9D\x9C\x9F' for column 'utf8mb4_encoding' at row 5
+Warning	1366	Incorrect string value: '\xF0\x9D\x9E\x9F' for column 'utf8mb4_encoding' at row 6
+Warning	1366	Incorrect string value: '\xF4\x8F\xBF\xBF' for column 'utf8mb4_encoding' at row 7
+Warning	1366	Incorrect string value: '\xF3\xA0\x87\xAF' for column 'utf8mb4_encoding' at row 8
+Warning	1366	Incorrect string value: '\xF0\x9D\x84\x9E\xF0\x9D...' for column 'utf8mb4_encoding' at row 9
+Warning	1366	Incorrect string value: '\xF0\x9D\x84\x9E\xF0\x9D...' for column 'utf8mb4_encoding' at row 10
+Warning	1366	Incorrect string value: '\xF0\x9D\x84\x9E\xF0\x9D...' for column 'utf8mb4_encoding' at row 11
 SHOW CREATE TABLE t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (
   `u_decimal` int(11) NOT NULL,
   `utf8mb4_encoding` varchar(10) NOT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=utf8
+SELECT u_decimal,hex(utf8mb4_encoding),utf8mb4_encoding FROM t1;
+u_decimal	hex(utf8mb4_encoding)	utf8mb4_encoding
+119040	3F	?
+119070	3F	?
+119134	3F	?
+119247	3F	?
+120607	3F	?
+120735	3F	?
+1114111	3F	?
+917999	3F	?
+119070	3F3F3F3F3F3F3F3F3F3F	??????????
+65131	EFB9AB3F3F3F3F3FEFB9ABEFB9AB3FEFB9AB	﹫?????﹫﹫?﹫
+119070	3F3F3F3F3F3F3F3F3F3F	??????????
+1114111		
+ALTER TABLE t2 CONVERT TO CHARACTER SET utf8mb4;
+SHOW CREATE TABLE t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `u_decimal` int(11) NOT NULL,
+  `utf8mb3_encoding` varchar(10) NOT NULL
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4
+SELECT u_decimal,hex(utf8mb3_encoding) FROM t2;
+u_decimal	hex(utf8mb3_encoding)
+42856	EA9DA8
+65131	EFB9AB
+1114111	
+ALTER TABLE t2 CONVERT TO CHARACTER SET utf8mb3;
 SHOW CREATE TABLE t2;
 Table	Create Table
 t2	CREATE TABLE `t2` (
   `u_decimal` int(11) NOT NULL,
   `utf8mb3_encoding` varchar(10) NOT NULL
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8
+SELECT u_decimal,hex(utf8mb3_encoding) FROM t2;
+u_decimal	hex(utf8mb3_encoding)
+42856	EA9DA8
+65131	EFB9AB
+1114111	
+ALTER TABLE t1 MODIFY utf8mb4_encoding VARCHAR(10) CHARACTER SET utf8mb3;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `u_decimal` int(11) NOT NULL,
+  `utf8mb4_encoding` varchar(10) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=utf8
+SELECT u_decimal,hex(utf8mb4_encoding) FROM t1;
+u_decimal	hex(utf8mb4_encoding)
+119040	3F
+119070	3F
+119134	3F
+119247	3F
+120607	3F
+120735	3F
+1114111	3F
+917999	3F
+119070	3F3F3F3F3F3F3F3F3F3F
+65131	EFB9AB3F3F3F3F3FEFB9ABEFB9AB3FEFB9AB
+119070	3F3F3F3F3F3F3F3F3F3F
+1114111	
+ALTER TABLE t1 MODIFY utf8mb4_encoding VARCHAR(10) CHARACTER SET utf8mb4;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `u_decimal` int(11) NOT NULL,
+  `utf8mb4_encoding` varchar(10) CHARACTER SET utf8mb4 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=utf8
+SELECT u_decimal,hex(utf8mb4_encoding) FROM t1;
+u_decimal	hex(utf8mb4_encoding)
+119040	3F
+119070	3F
+119134	3F
+119247	3F
+120607	3F
+120735	3F
+1114111	3F
+917999	3F
+119070	3F3F3F3F3F3F3F3F3F3F
+65131	EFB9AB3F3F3F3F3FEFB9ABEFB9AB3FEFB9AB
+119070	3F3F3F3F3F3F3F3F3F3F
+1114111	
+ALTER TABLE t2 MODIFY utf8mb3_encoding VARCHAR(10) CHARACTER SET utf8mb4;
+SHOW CREATE TABLE t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `u_decimal` int(11) NOT NULL,
+  `utf8mb3_encoding` varchar(10) CHARACTER SET utf8mb4 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=utf8
+SELECT u_decimal,hex(utf8mb3_encoding) FROM t2;
+u_decimal	hex(utf8mb3_encoding)
+42856	EA9DA8
+65131	EFB9AB
+1114111	
+DROP TABLE IF EXISTS t3;
+CREATE TABLE t3 (
+u_decimal int NOT NULL,
+utf8mb3_encoding VARCHAR(10) NOT NULL
+) CHARACTER SET utf8;
+INSERT INTO t3 SELECT * FROM t1;
+DROP TABLE IF EXISTS t4;
+CREATE TABLE t4 (
+u_decimal int NOT NULL,
+utf8mb4_encoding VARCHAR(10) NOT NULL
+) CHARACTER SET utf8mb4;
+INSERT INTO t3 SELECT * FROM t2;
 DROP TABLE t1;
 DROP TABLE t2;
+DROP TABLE t3;
+DROP TABLE t4;
 #
 # Testing that mixing utf8 and utf8mb4 collations returns utf8mb4
 #
@@ -2231,6 +2412,62 @@ SELECT CONCAT('a', _utf8 '�') FROM t1;
 ERROR HY000: Illegal mix of collations (utf8mb4_general_ci,COERCIBLE) and (utf8_general_ci,COERCIBLE) for operation 'concat'
 DROP TABLE t1;
 #
+# Bug#51675 Server crashes on inserting 4 byte char.
+# after ALTER TABLE to 'utf8mb4' 
+#
+SET NAMES utf8;
+CREATE TABLE t1 ( 
+subject varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci, 
+p VARCHAR(15) CHARACTER SET utf8 
+) DEFAULT CHARSET=latin1;
+ALTER TABLE t1 ADD INDEX (subject);
+ALTER TABLE t1
+DEFAULT CHARACTER SET utf8,
+MODIFY subject varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
+MODIFY p varchar(255) CHARACTER SET utf8;
+Warnings:
+Warning	1071	Specified key was too long; max key length is 1000 bytes
+Warning	1071	Specified key was too long; max key length is 1000 bytes
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `subject` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
+  `p` varchar(255) DEFAULT NULL,
+  KEY `subject` (`subject`(250))
+) ENGINE=MyISAM DEFAULT CHARSET=utf8
+INSERT INTO t1(subject) VALUES ('abcd');
+INSERT INTO t1(subject) VALUES(x'f0909080');
+DROP TABLE t1;
+#
+# Bug #51676 Server crashes on SELECT, ORDER BY on 'utf8mb4' column
+#
+SET NAMES utf8mb4;
+CREATE TABLE t1 ( 
+subject varchar(255) character set utf8mb4 collate utf8mb4_unicode_ci, 
+p varchar(15) character set utf8mb4 
+) DEFAULT CHARSET=latin1;
+INSERT INTO t1(subject) VALUES(0xF0909080);
+INSERT INTO t1(subject) VALUES(0x616263F0909080646566);
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `subject` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
+  `p` varchar(15) CHARACTER SET utf8mb4 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SELECT *  FROM t1 ORDER BY 1;
+subject	p
+abc𐐀def	NULL
+𐐀	NULL
+SELECT hex(subject), length(subject), char_length(subject), octet_length(subject) FROM t1 ORDER BY 1;
+hex(subject)	length(subject)	char_length(subject)	octet_length(subject)
+616263F0909080646566	10	7	10
+F0909080	4	1	4
+SELECT subject FROM t1 ORDER BY 1;
+subject
+abc𐐀def
+𐐀
+DROP TABLE t1;
+#
 # End of 5.5 tests
 #
 #

=== added file 'mysql-test/r/ctype_utf8mb4_heap.result'
--- a/mysql-test/r/ctype_utf8mb4_heap.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/ctype_utf8mb4_heap.result	2010-03-05 08:17:19 +0000
@@ -0,0 +1,2260 @@
+drop table if exists t1,t2;
+#
+# Start of 5.5 tests
+#
+set names utf8mb4;
+select left(_utf8mb4 0xD0B0D0B1D0B2,1);
+left(_utf8mb4 0xD0B0D0B1D0B2,1)
+а
+select right(_utf8mb4 0xD0B0D0B2D0B2,1);
+right(_utf8mb4 0xD0B0D0B2D0B2,1)
+в
+select locate('he','hello');
+locate('he','hello')
+1
+select locate('he','hello',2);
+locate('he','hello',2)
+0
+select locate('lo','hello',2);
+locate('lo','hello',2)
+4
+select locate('HE','hello');
+locate('HE','hello')
+1
+select locate('HE','hello',2);
+locate('HE','hello',2)
+0
+select locate('LO','hello',2);
+locate('LO','hello',2)
+4
+select locate('HE','hello' collate utf8mb4_bin);
+locate('HE','hello' collate utf8mb4_bin)
+0
+select locate('HE','hello' collate utf8mb4_bin,2);
+locate('HE','hello' collate utf8mb4_bin,2)
+0
+select locate('LO','hello' collate utf8mb4_bin,2);
+locate('LO','hello' collate utf8mb4_bin,2)
+0
+select locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D0B1D0B2);
+locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D0B1D0B2)
+2
+select locate(_utf8mb4 0xD091, _utf8mb4 0xD0B0D0B1D0B2);
+locate(_utf8mb4 0xD091, _utf8mb4 0xD0B0D0B1D0B2)
+2
+select locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D091D0B2);
+locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D091D0B2)
+2
+select locate(_utf8mb4 0xD091, _utf8mb4 0xD0B0D0B1D0B2 collate utf8mb4_bin);
+locate(_utf8mb4 0xD091, _utf8mb4 0xD0B0D0B1D0B2 collate utf8mb4_bin)
+0
+select locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D091D0B2 collate utf8mb4_bin);
+locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D091D0B2 collate utf8mb4_bin)
+0
+select length(_utf8mb4 0xD0B1), bit_length(_utf8mb4 0xD0B1), char_length(_utf8mb4 0xD0B1);
+length(_utf8mb4 0xD0B1)	bit_length(_utf8mb4 0xD0B1)	char_length(_utf8mb4 0xD0B1)
+2	16	1
+select 'a' like 'a';
+'a' like 'a'
+1
+select 'A' like 'a';
+'A' like 'a'
+1
+select 'A' like 'a' collate utf8mb4_bin;
+'A' like 'a' collate utf8mb4_bin
+0
+select _utf8mb4 0xD0B0D0B1D0B2 like concat(_utf8mb4'%',_utf8mb4 0xD0B1,_utf8mb4 '%');
+_utf8mb4 0xD0B0D0B1D0B2 like concat(_utf8mb4'%',_utf8mb4 0xD0B1,_utf8mb4 '%')
+1
+select convert(_latin1'G�Andr�using utf8mb4) like CONVERT(_latin1'G�TER%' USING utf8mb4);
+convert(_latin1'G?nter Andr?' using utf8mb4) like CONVERT(_latin1'G?NTER%' USING utf8mb4)
+1
+select CONVERT(_koi8r'��' USING utf8mb4) LIKE CONVERT(_koi8r'�' USING utf8mb4);
+CONVERT(_koi8r'????' USING utf8mb4) LIKE CONVERT(_koi8r'????' USING utf8mb4)
+1
+select CONVERT(_koi8r'�' USING utf8mb4) LIKE CONVERT(_koi8r'��' USING utf8mb4);
+CONVERT(_koi8r'????' USING utf8mb4) LIKE CONVERT(_koi8r'????' USING utf8mb4)
+1
+SELECT 'a' = 'a ';
+'a' = 'a '
+1
+SELECT 'a\0' < 'a';
+'a\0' < 'a'
+1
+SELECT 'a\0' < 'a ';
+'a\0' < 'a '
+1
+SELECT 'a\t' < 'a';
+'a\t' < 'a'
+1
+SELECT 'a\t' < 'a ';
+'a\t' < 'a '
+1
+SELECT 'a' = 'a ' collate utf8mb4_bin;
+'a' = 'a ' collate utf8mb4_bin
+1
+SELECT 'a\0' < 'a' collate utf8mb4_bin;
+'a\0' < 'a' collate utf8mb4_bin
+1
+SELECT 'a\0' < 'a ' collate utf8mb4_bin;
+'a\0' < 'a ' collate utf8mb4_bin
+1
+SELECT 'a\t' < 'a' collate utf8mb4_bin;
+'a\t' < 'a' collate utf8mb4_bin
+1
+SELECT 'a\t' < 'a ' collate utf8mb4_bin;
+'a\t' < 'a ' collate utf8mb4_bin
+1
+CREATE TABLE t1 (a char(10) character set utf8mb4 not null) ENGINE heap;
+INSERT INTO t1 VALUES ('a'),('a\0'),('a\t'),('a ');
+SELECT hex(a),STRCMP(a,'a'), STRCMP(a,'a ') FROM t1;
+hex(a)	STRCMP(a,'a')	STRCMP(a,'a ')
+61	0	0
+61	0	0
+6100	-1	-1
+6109	-1	-1
+DROP TABLE t1;
+select insert('txs',2,1,'hi'),insert('is ',4,0,'a'),insert('txxxxt',2,4,'es');
+insert('txs',2,1,'hi')	insert('is ',4,0,'a')	insert('txxxxt',2,4,'es')
+this	is a	test
+select insert("aa",100,1,"b"),insert("aa",1,3,"b");
+insert("aa",100,1,"b")	insert("aa",1,3,"b")
+aa	b
+select char_length(left(@a:='тест',5)), length(@a), @a;
+char_length(left(@a:='тест',5))	length(@a)	@a
+4	8	тест
+create table t1 ENGINE heap 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")` varchar(10) CHARACTER SET utf8mb4 DEFAULT NULL
+) ENGINE=MEMORY 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 utf8mb4;
+set LC_TIME_NAMES='fr_FR';
+create table t1 (s1 char(20) character set latin1) engine heap;
+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) engine heap;
+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
+E6C5D7	Фев
+E6C5D7D2C1CCD1	недельник
+drop table t1;
+set LC_TIME_NAMES='en_US';
+set names koi8r;
+create table t1 (s1 char(1) character set utf8mb4) engine heap;
+insert into t1 values (_koi8r'�');
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+select s1,hex(s1),char_length(s1),octet_length(s1) from t1;
+s1	hex(s1)	char_length(s1)	octet_length(s1)
+�D0B0	1	2
+drop table t1;
+create table t1 (s1 varchar(255) character set utf8mb4) engine heap;
+insert into t1 select repeat('a',300);
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+insert into t1 select repeat('�,300);
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+insert into t1 select repeat('a�,300);
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+insert into t1 select repeat('�',300);
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+insert into t1 select repeat('mn 's1' at row 1
+select hex(s1) from t1;
+hex(s1)
+616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161
+61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61
+D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F
+D18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18F
+D18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18F
+select length(s1),char_length(s1) from t1;
+length(s1)	char_length(s1)
+255	255
+382	255
+383	255
+510	255
+510	255
+drop table t1;
+create table t1 (s1 varchar(255) character set utf8mb4) engine heap;
+insert into t1 select repeat('a',66000);
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+insert into t1 select repeat('�,66000);
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+insert into t1 select repeat('a�,66000);
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+insert into t1 select repeat('�',66000);
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+insert into t1 select repeat('�',66000);
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+select length(s1),char_length(s1) from t1;
+length(s1)	char_length(s1)
+255	255
+382	255
+383	255
+510	255
+510	255
+drop table t1;
+create table t1 (s1 char(10) character set utf8mb4) engine heap;
+insert into t1 values (0x41FF);
+Warnings:
+Warning	1366	Incorrect string value: '\xFF' for column 's1' at row 1
+select hex(s1) from t1;
+hex(s1)
+41
+drop table t1;
+create table t1 (s1 varchar(10) character set utf8mb4) engine heap;
+insert into t1 values (0x41FF);
+Warnings:
+Warning	1366	Incorrect string value: '\xFF' for column 's1' at row 1
+select hex(s1) from t1;
+hex(s1)
+41
+drop table t1;
+CREATE TABLE t1 ( a varchar(10) ) CHARACTER SET utf8mb4 ENGINE heap;
+INSERT INTO t1 VALUES ( 'test' );
+SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = b.a;
+a	a
+test	test
+SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = 'test' and b.a = 'test';
+a	a
+test	test
+SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = b.a and a.a = 'test';
+a	a
+test	test
+DROP TABLE t1;
+create table t1 (a char(255) character set utf8mb4) engine heap;
+insert into t1 values('b'),('b');
+select * from t1 where a = 'b';
+a
+b
+b
+select * from t1 where a = 'b' and a = 'b';
+a
+b
+b
+select * from t1 where a = 'b' and a != 'b';
+a
+drop table t1;
+set collation_connection=utf8mb4_general_ci;
+drop table if exists t1;
+create table t1 as
+select repeat(' ', 64) as s1, repeat(' ',64) as s2
+union
+select null, null;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `s1` varchar(64) CHARACTER SET utf8mb4 DEFAULT NULL,
+  `s2` varchar(64) CHARACTER SET utf8mb4 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+delete from t1;
+insert into t1 values('aaa','aaa');
+insert into t1 values('aaa|qqq','qqq');
+insert into t1 values('gheis','^[^a-dXYZ]+$');
+insert into t1 values('aab','^aa?b');
+insert into t1 values('Baaan','^Ba*n');
+insert into t1 values('aaa','qqq|aaa');
+insert into t1 values('qqq','qqq|aaa');
+insert into t1 values('bbb','qqq|aaa');
+insert into t1 values('bbb','qqq');
+insert into t1 values('aaa','aba');
+insert into t1 values(null,'abc');
+insert into t1 values('def',null);
+insert into t1 values(null,null);
+insert into t1 values('ghi','ghi[');
+select HIGH_PRIORITY s1 regexp s2 from t1;
+s1 regexp s2
+1
+1
+1
+1
+1
+1
+1
+0
+0
+0
+NULL
+NULL
+NULL
+NULL
+drop table t1;
+set names utf8mb4;
+set names utf8mb4;
+select  'вася'  rlike '[[:<:]]вася[[:>:]]';
+'вася'  rlike '[[:<:]]вася[[:>:]]'
+1
+select  'вася ' rlike '[[:<:]]вася[[:>:]]';
+'вася ' rlike '[[:<:]]вася[[:>:]]'
+1
+select ' вася'  rlike '[[:<:]]вася[[:>:]]';
+' вася'  rlike '[[:<:]]вася[[:>:]]'
+1
+select ' вася ' rlike '[[:<:]]вася[[:>:]]';
+' вася ' rlike '[[:<:]]вася[[:>:]]'
+1
+select  'васяz' rlike '[[:<:]]вася[[:>:]]';
+'васяz' rlike '[[:<:]]вася[[:>:]]'
+0
+select 'zвася'  rlike '[[:<:]]вася[[:>:]]';
+'zвася'  rlike '[[:<:]]вася[[:>:]]'
+0
+select 'zвасяz' rlike '[[:<:]]вася[[:>:]]';
+'zвасяz' rlike '[[:<:]]вася[[:>:]]'
+0
+CREATE TABLE t1 (a enum ('Y', 'N') DEFAULT 'N' COLLATE utf8mb4_unicode_ci) ENGINE heap;
+ALTER TABLE t1 ADD COLUMN b CHAR(20);
+DROP TABLE t1;
+set names utf8mb4;
+create table t1 (a enum('aaaa','проба') character set utf8mb4) engine heap;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` enum('aaaa','проба') CHARACTER SET utf8mb4 DEFAULT NULL
+) ENGINE=MEMORY DEFAULT CHARSET=latin1
+insert into t1 values ('проба');
+select * from t1;
+a
+проба
+create table t2 engine heap select ifnull(a,a) from t1;
+show create table t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `ifnull(a,a)` varchar(5) CHARACTER SET utf8mb4 DEFAULT NULL
+) ENGINE=MEMORY DEFAULT CHARSET=latin1
+select * from t2;
+ifnull(a,a)
+проба
+drop table t1;
+drop table t2;
+create table t1 (c varchar(30) character set utf8mb4, unique(c(10))) engine heap;
+insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z');
+insert into t1 values ('aaaaaaaaaa');
+insert into t1 values ('aaaaaaaaaaa');
+ERROR 23000: Duplicate entry 'aaaaaaaaaa' for key 'c'
+insert into t1 values ('aaaaaaaaaaaa');
+ERROR 23000: Duplicate entry 'aaaaaaaaaa' for key 'c'
+insert into t1 values (repeat('b',20));
+select c c1 from t1 where c='1';
+c1
+1
+select c c2 from t1 where c='2';
+c2
+2
+select c c3 from t1 where c='3';
+c3
+3
+select c cx from t1 where c='x';
+cx
+x
+select c cy from t1 where c='y';
+cy
+y
+select c cz from t1 where c='z';
+cz
+z
+select c ca10 from t1 where c='aaaaaaaaaa';
+ca10
+aaaaaaaaaa
+select c cb20 from t1 where c=repeat('b',20);
+cb20
+bbbbbbbbbbbbbbbbbbbb
+drop table t1;
+create table t1 (c varchar(30) character set utf8mb4, unique(c(10))) engine=heap;
+insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z');
+insert into t1 values ('aaaaaaaaaa');
+insert into t1 values ('aaaaaaaaaaa');
+ERROR 23000: Duplicate entry 'aaaaaaaaaa' for key 'c'
+insert into t1 values ('aaaaaaaaaaaa');
+ERROR 23000: Duplicate entry 'aaaaaaaaaa' for key 'c'
+insert into t1 values (repeat('b',20));
+select c c1 from t1 where c='1';
+c1
+1
+select c c2 from t1 where c='2';
+c2
+2
+select c c3 from t1 where c='3';
+c3
+3
+select c cx from t1 where c='x';
+cx
+x
+select c cy from t1 where c='y';
+cy
+y
+select c cz from t1 where c='z';
+cz
+z
+select c ca10 from t1 where c='aaaaaaaaaa';
+ca10
+aaaaaaaaaa
+select c cb20 from t1 where c=repeat('b',20);
+cb20
+bbbbbbbbbbbbbbbbbbbb
+drop table t1;
+create table t1 (c char(3) character set utf8mb4, unique (c(2))) engine heap;
+insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z');
+insert into t1 values ('a');
+insert into t1 values ('aa');
+insert into t1 values ('aaa');
+ERROR 23000: Duplicate entry 'aa' for key 'c'
+insert into t1 values ('b');
+insert into t1 values ('bb');
+insert into t1 values ('bbb');
+ERROR 23000: Duplicate entry 'bb' for key 'c'
+insert into t1 values ('а');
+insert into t1 values ('аа');
+insert into t1 values ('ааа');
+ERROR 23000: Duplicate entry 'аа' for key 'c'
+insert into t1 values ('б');
+insert into t1 values ('бб');
+insert into t1 values ('ббб');
+ERROR 23000: Duplicate entry 'бб' for key 'c'
+insert into t1 values ('ꪪ');
+insert into t1 values ('ꪪꪪ');
+insert into t1 values ('ꪪꪪꪪ');
+ERROR 23000: Duplicate entry 'ꪪꪪ' for key 'c'
+drop table t1;
+create table t1 (c char(3) character set utf8mb4, unique (c(2))) engine=heap;
+insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z');
+insert into t1 values ('a');
+insert into t1 values ('aa');
+insert into t1 values ('aaa');
+ERROR 23000: Duplicate entry 'aa' for key 'c'
+insert into t1 values ('b');
+insert into t1 values ('bb');
+insert into t1 values ('bbb');
+ERROR 23000: Duplicate entry 'bb' for key 'c'
+insert into t1 values ('а');
+insert into t1 values ('аа');
+insert into t1 values ('ааа');
+ERROR 23000: Duplicate entry 'аа' for key 'c'
+insert into t1 values ('б');
+insert into t1 values ('бб');
+insert into t1 values ('ббб');
+ERROR 23000: Duplicate entry 'бб' for key 'c'
+insert into t1 values ('ꪪ');
+insert into t1 values ('ꪪꪪ');
+insert into t1 values ('ꪪꪪꪪ');
+ERROR 23000: Duplicate entry 'ꪪꪪ' for key 'c'
+drop table t1;
+create table t1 (
+c char(10) character set utf8mb4,
+unique key a using hash (c(1))
+) engine=heap;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c` char(10) CHARACTER SET utf8mb4 DEFAULT NULL,
+  UNIQUE KEY `a` (`c`(1)) USING HASH
+) ENGINE=MEMORY DEFAULT CHARSET=latin1
+insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
+insert into t1 values ('aa');
+ERROR 23000: Duplicate entry 'a' for key 'a'
+insert into t1 values ('aaa');
+ERROR 23000: Duplicate entry 'a' for key 'a'
+insert into t1 values ('б');
+insert into t1 values ('бб');
+ERROR 23000: Duplicate entry 'б' for key 'a'
+insert into t1 values ('ббб');
+ERROR 23000: Duplicate entry 'б' for key 'a'
+select c as c_all from t1 order by c;
+c_all
+a
+b
+c
+d
+e
+f
+б
+select c as c_a from t1 where c='a';
+c_a
+a
+select c as c_a from t1 where c='б';
+c_a
+б
+drop table t1;
+create table t1 (
+c char(10) character set utf8mb4,
+unique key a using btree (c(1))
+) engine=heap;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c` char(10) CHARACTER SET utf8mb4 DEFAULT NULL,
+  UNIQUE KEY `a` (`c`(1)) USING BTREE
+) ENGINE=MEMORY DEFAULT CHARSET=latin1
+insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
+insert into t1 values ('aa');
+ERROR 23000: Duplicate entry 'a' for key 'a'
+insert into t1 values ('aaa');
+ERROR 23000: Duplicate entry 'a' for key 'a'
+insert into t1 values ('б');
+insert into t1 values ('бб');
+ERROR 23000: Duplicate entry 'б' for key 'a'
+insert into t1 values ('ббб');
+ERROR 23000: Duplicate entry 'б' for key 'a'
+select c as c_all from t1 order by c;
+c_all
+a
+b
+c
+d
+e
+f
+б
+select c as c_a from t1 where c='a';
+c_a
+a
+select c as c_a from t1 where c='б';
+c_a
+б
+drop table t1;
+create table t1 (
+c char(10) character set utf8mb4,
+unique key a (c(1))
+) engine=heap;
+insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
+insert into t1 values ('aa');
+ERROR 23000: Duplicate entry 'a' for key 'a'
+insert into t1 values ('aaa');
+ERROR 23000: Duplicate entry 'a' for key 'a'
+insert into t1 values ('б');
+insert into t1 values ('бб');
+ERROR 23000: Duplicate entry 'б' for key 'a'
+insert into t1 values ('ббct c as c_all from t1 order by c;
+c_all
+a
+b
+c
+d
+e
+f
+б
+select c as c_a from t1 where c='a';
+c_a
+a
+select c as c_a from t1 where c='б';
+c_a
+б
+drop table t1;
+create table t1 (c varchar(30) character set utf8mb4 collate utf8mb4_bin, unique(c(10))) engine heap;
+insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z');
+insert into t1 values ('aaaaaaaaaa');
+insert into t1 values ('aaaaaaaaaaa');
+ERROR 23000: Duplicate entry 'aaaaaaaaaa' for key 'c'
+insert into t1 values ('aaaaaaaaaaaa');
+ERROR 23000: Duplicate entry 'aaaaaaaaaa' for key 'c'
+insert into t1 values (repeat('b',20));
+select c c1 from t1 where c='1';
+c1
+1
+select c c2 from t1 where c='2';
+c2
+2
+select c c3 from t1 where c='3';
+c3
+3
+select c cx from t1 where c='x';
+cx
+x
+select c cy from t1 where c='y';
+cy
+y
+select c cz from t1 where c='z';
+cz
+z
+select c ca10 from t1 where c='aaaaaaaaaa';
+ca10
+aaaaaaaaaa
+select c cb20 from t1 where c=repeat('b',20);
+cb20
+bbbbbbbbbbbbbbbbbbbb
+drop table t1;
+create table t1 (c char(3) character set utf8mb4 collate utf8mb4_bin, unique (c(2))) engine heap;
+insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z');
+insert into t1 values ('a');
+insert into t1 values ('aa');
+insert into t1 values ('aaa');
+ERROR 23000: Duplicate entry 'aa' for key 'c'
+insert into t1 values ('b');
+insert into t1 values ('bb');
+insert into t1 values ('bbb');
+ERROR 23000: Duplicate entry 'bb' for key 'c'
+insert into t1 values ('а');
+insert into t1 values ('аа');
+insert into t1 values ('ааа');
+ERROR 23000: Duplicate entry 'аа' for key 'c'
+insert into t1 values ('б');
+insert into t1 values ('бб');
+insert into t1 values ('ббб');
+ERROR 23000: Duplicate entry 'бб' for key 'c'
+insert into t1 values ('ꪪ');
+insert into t1 values ('ꪪꪪ');
+insert into t1 values ('ꪪꪪꪪ');
+ERROR 23000: Duplicate entry 'ꪪꪪ' for key 'c'
+drop table t1;
+create table t1 (
+c char(10) character set utf8mb4 collate utf8mb4_bin,
+unique key a using hash (c(1))
+) engine=heap;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
+  UNIQUE KEY `a` (`c`(1)) USING HASH
+) ENGINE=MEMORY DEFAULT CHARSET=latin1
+insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
+insert into t1 values ('aa');
+ERROR 23000: Duplicate entry 'a' for key 'a'
+insert into t1 values ('aaa');
+ERROR 23000: Duplicate entry 'a' for key 'a'
+insert into t1 values ('б');
+insert into t1 values ('бб');
+ERROR 23000: Duplicate entry 'б' for key 'a'
+insert into t1 values ('ббб');
+ERROR 23000: Duplicate entry 'б' for key 'a'
+select c as c_all from t1 order by c;
+c_all
+a
+b
+c
+d
+e
+f
+б
+select c as c_a from t1 where c='a';
+c_a
+a
+select c as c_a from t1 where c='б';
+c_a
+б
+drop table t1;
+create table t1 (
+c char(10) character set utf8mb4 collate utf8mb4_bin,
+unique key a using btree (c(1))
+) engine=heap;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
+  UNIQUE KEY `a` (`c`(1)) USING BTREE
+) ENGINE=MEMORY DEFAULT CHARSET=latin1
+insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
+insert into t1 values ('aa');
+ERROR 23000: Duplicate entry 'a' for key 'a'
+insert into t1 values ('aaa');
+ERROR 23000: Duplicate entry 'a' for key 'a'
+insert into t1 values ('б');
+insert into t1 values ('бб');
+ERROR 23000: Duplicate entry 'б' for key 'a'
+insert into t1 values ('ббб');
+ERROR 23000: Duplicate entry 'б' for key 'a'
+select c as c_all from t1 order by c;
+c_all
+a
+b
+c
+d
+e
+f
+б
+select c as c_a from t1 where c='a';
+c_a
+a
+select c as c_a from t1 where c='б';
+c_a
+б
+drop table t1;
+create table t1 (
+c char(10) character set utf8mb4 collate utf8mb4_bin,
+unique key a (c(1))
+) engine=heap;
+insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
+insert into t1 values ('aa');
+ERROR 23000: Duplicate entry 'a' for key 'a'
+insert into t1 values ('aaa');
+ERROR 23000: Duplicate entry 'a' for key 'a'
+insert into t1 values ('б');
+insert into t1 values ('бб');
+ERROR 23000: Duplicate entry 'б' for key 'a'
+insert into t1 values ('ббб');
+ERROR 23000: Duplicate entry 'б' for key 'a'
+select c as c_all from t1 order by c;
+c_all
+a
+b
+c
+d
+e
+f
+б
+select c as c_a from t1 where c='a';
+c_a
+a
+select c as c_a from t1 where c='б';
+c_a
+б
+drop table t1;
+create table t1 (
+str varchar(255) character set utf8mb4 not null,
+key str  (str(2))
+) engine=heap;
+INSERT INTO t1 VALUES ('str');
+INSERT INTO t1 VALUES ('str2');
+select * from t1 where str='str';
+str
+str
+drop table t1;
+create table t1 (
+str varchar(255) character set utf8mb4 not null,
+key str  (str(2))
+) engine=heap;
+INSERT INTO t1 VALUES ('str');
+INSERT INTO t1 VALUES ('str2');
+select * from t1 where str='str';
+str
+str
+drop table t1;
+create table t1 (
+str varchar(255) character set utf8mb4 not null,
+key str using btree (str(2))
+) engine=heap;
+INSERT INTO t1 VALUES ('str');
+INSERT INTO t1 VALUES ('str2');
+select * from t1 where str='str';
+str
+str
+drop table t1;
+create table t1 (
+str varchar(255) character set utf8mb4 not null,
+key str using hash (str(2))
+) engine=heap;
+INSERT INTO t1 VALUES ('str');
+INSERT INTO t1 VALUES ('str2');
+select * from t1 where str='str';
+str
+str
+drop table t1;
+create table t1 (
+str varchar(255) character set utf8mb4 not null,
+key str (str(2))
+) engine= heap;
+INSERT INTO t1 VALUES ('str');
+INSERT INTO t1 VALUES ('str2');
+select * from t1 where str='str';
+str
+str
+drop table t1;
+CREATE TABLE t1 (a varchar(32) BINARY) CHARACTER SET utf8mb4 ENGINE heap;
+INSERT INTO t1 VALUES ('test');
+SELECT a FROM t1 WHERE a LIKE '%te';
+a
+DROP TABLE t1;
+SET NAMES utf8mb4;
+CREATE TABLE t1 (
+subject varchar(255) character set utf8mb4 collate utf8mb4_unicode_ci,
+p varchar(15) character set utf8mb4
+) ENGINE= heap DEFAULT CHARSET=latin1;
+INSERT INTO t1 VALUES ('谷川俊二と申しますが、インターネット予約の会員登録をしましたところ、メールアドレスを間違えてしまい会員IDが受け取ることが出来ませんでした。間違えアドレスはtani-shun@strippedne.ne.jpを書き込みました。どうすればよいん。連絡ください。よろしくお願いします。m(__)m','040312-000057');
+INSERT INTO t1 VALUES ('aaa','bbb');
+SELECT length(subject) FROM t1;
+length(subject)
+3
+432
+SELECT length(subject) FROM t1 ORDER BY 1;
+length(subject)
+3
+432
+DROP TABLE t1;
+set names utf8mb4;
+create table t1 (
+a int primary key,
+b varchar(6),
+index b3(b(3))
+) engine=heap character set=utf8mb4;
+insert into t1 values(1,'foo'),(2,'foobar');
+select * from t1 where b like 'foob%';
+a	b
+2	foobar
+alter table t1 engine=innodb;
+select * from t1 where b like 'foob%';
+a	b
+2	foobar
+drop table t1;
+create table t1 (
+a enum('ot null default 'анюта',
+b set('петя','вася','анюта') character set utf8mb4 not null default 'elect concat(a,_utf8mb4'') as a, concat(b,_utf8mb4'')as b from t1;
+show create table t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `a` varchar(5) CHARACTER SET utf8mb4 NOT NULL DEFAULT '',
+  `b` varchar(15) CHARACTER SET utf8mb4 NOT NULL DEFAULT ''
+) ENGINE=MEMORY DEFAULT CHARSET=latin1
+drop table t2;
+drop table t1;
+select 'c' like '\_' as want0;
+want0
+0
+SELECT SUBSTR('вася',-2);
+SUBSTR('вася',-2)
+ся
+create table t1 (id integer, a varchar(100) character set utf8mb4 collate utf8mb4_unicode_ci) engine heap;
+insert into t1 values (1, 'Test');
+select * from t1 where soundex(a) = soundex('Test');
+id	a
+1	Test
+select * from t1 where soundex(a) = soundex('TEST');
+id	a
+1	Test
+select * from t1 where soundex(a) = soundex('test');
+id	a
+1	Test
+drop table t1;
+select soundex(_utf8mb4 0xE99885E8A788E99A8FE697B6E69BB4E696B0E79A84E696B0E997BB);
+soundex(_utf8mb4 0xE99885E8A788E99A8FE697B6E69BB4E696B0E79A84E696B0E997BB)
+阅000
+select hex(soundex(_utf8mb4 0xE99885E8A788E99A8FE697B6E69BB4E696B0E79A84E696B0E997BB));
+hex(soundex(_utf8mb4 0xE99885E8A788E99A8FE697B6E69BB4E696B0E79A84E696B0E997BB))
+E99885303030
+select soundex(_utf8mb4 0xD091D092D093);
+soundex(_utf8mb4 0xD091D092D093)
+Б000
+select hex(soundex(_utf8mb4 0xD091D092D093));
+hex(soundex(_utf8mb4 0xD091D092D093))
+D091303030
+SET collation_connection='utf8mb4_general_ci';
+create table t1 select repeat('a',4000) a;
+delete from t1;
+insert into t1 values ('a'), ('a '), ('a\t');
+select collation(a),hex(a) from t1 order by a;
+collation(a)	hex(a)
+utf8mb4_general_ci	6109
+utf8mb4_general_ci	61
+utf8mb4_general_ci	6120
+drop table t1;
+select @@collation_connection;
+@@collation_connection
+utf8mb4_general_ci
+create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ;
+insert into t1 values('abcdef');
+insert into t1 values('_bcdef');
+insert into t1 values('a_cdef');
+insert into t1 values('ab_def');
+insert into t1 values('abc_ef');
+insert into t1 values('abcd_f');
+insert into t1 values('abcde_');
+select c1 as c1u from t1 where c1 like 'ab\_def';
+c1u
+ab_def
+select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
+c2h
+ab_def
+drop table t1;
+drop table if exists t1;
+create table t1 as select repeat(' ', 64) as s1;
+select collation(s1) from t1;
+collation(s1)
+utf8mb4_general_ci
+delete from t1;
+insert into t1 values ('a'),('ae'),(_latin1 0xE4);
+insert into t1 values ('o'),('oe'),(_latin1 0xF6);
+insert into t1 values ('s'),('ss'),(_latin1 0xDF);
+insert into t1 values ('u'),('ue'),(_latin1 0xFC);
+select s1, hex(s1) from t1 order by s1, binary s1;
+s1	hex(s1)
+a	61
+ä	C3A4
+ae	6165
+o	6F
+ö	C3B6
+oe	6F65
+s	73
+ß	C39F
+ss	7373
+u	75
+ü	C3BC
+ue	7565
+select group_concat(s1 order by binary s1) from t1 group by s1;
+group_concat(s1 order by binary s1)
+a,ä
+ae
+o,ö
+oe
+s,ß
+ss
+u,ü
+ue
+drop table t1;
+SET collation_connection='utf8mb4_bin';
+create table t1 select repeat('a',4000) a;
+delete from t1;
+insert into t1 values ('a'), ('a '), ('a\t');
+select collation(a),hex(a) from t1 order by a;
+collation(a)	hex(a)
+utf8mb4_bin	6109
+utf8mb4_bin	61
+utf8mb4_bin	6120
+drop table t1;
+select @@collation_connection;
+@@collation_connection
+utf8mb4_bin
+create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ;
+insert into t1 values('abcdef');
+insert into t1 values('_bcdef');
+insert into t1 values('a_cdef');
+insert into t1 values('ab_def');
+insert into t1 values('abc_ef');
+insert into t1 values('abcd_f');
+insert into t1 values('abcde_');
+select c1 as c1u from t1 where c1 like 'ab\_def';
+c1u
+ab_def
+select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
+c2h
+ab_def
+drop table t1;
+CREATE TABLE t1 (
+user varchar(255) NOT NULL default ''
+) ENGINE=heap DEFAULT CHARSET=latin1;
+INSERT INTO t1 VALUES ('one'),('two');
+SELECT CHARSET('a');
+CHARSET('a')
+utf8mb4
+SELECT user, CONCAT('<', user, '>') AS c FROM t1;
+user	c
+one	<one>
+two	<two>
+DROP TABLE t1;
+create table t1 (f1 varchar(1) not null) default charset utf8mb4 engine heap;
+insert into t1 values (''), ('');
+select concat(concat(_latin1'->',f1),_latin1'<-') from t1;
+concat(concat(_latin1'->',f1),_latin1'<-')
+-><-
+-><-
+drop table t1;
+select convert(_koi8r'� using utf8mb4) < convert(_koi8r'� using utf8mb4);
+convert(_koi8r'?' using utf8mb4) < convert(_koi8r'?' using utf8mb4)
+1
+set names latin1;
+create table t1 (a varchar(10)) character set utf8mb4 engine heap;
+insert into t1 values ('test');
+select ifnull(a,'') from t1;
+ifnull(a,'')
+test
+drop table t1;
+select repeat(_utf8mb4'+',3) as h union select NULL;
+h
++++
+NULL
+select ifnull(NULL, _utf8mb4'string');
+ifnull(NULL, _utf8mb4'string')
+string
+set names utf8mb4;
+create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_lithuanian_ci) engine heap;
+insert into t1 values ('I'),('K'),('Y');
+select * from t1 where s1 < 'K' and s1 = 'Y';
+s1
+I
+Y
+select * from t1 where 'K' > s1 and s1 = 'Y';
+s1
+I
+Y
+drop table t1;
+create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_czech_ci) engine heap;
+insert into t1 values ('c'),('d'),('h'),('ch'),('CH'),('cH'),('Ch'),('i');
+select * from t1 where s1 > 'd' and s1 = 'CH';
+s1
+CH
+Ch
+ch
+select * from t1 where 'd' < s1 and s1 = 'CH';
+s1
+CH
+Ch
+ch
+select * from t1 where s1 = 'cH' and s1 <> 'ch';
+s1
+cH
+select * from t1 where 'cH' = s1 and s1 <> 'ch';
+s1
+cH
+drop table t1;
+create table t1 (a varchar(255)) default character set utf8mb4 engine heap;
+insert into t1 values (1.0);
+drop table t1;
+create table t1 (
+id int not null,
+city varchar(20) not null,
+key (city(7),id)
+) character set=utf8mb4 engine heap;
+insert into t1 values (1,'Durban North');
+insert into t1 values (2,'Durban');
+select * from t1 where city = 'Durban';
+id	city
+2	Durban
+select * from t1 where city = 'Durban ';
+id	city
+2	Durban
+drop table t1;
+create table t1 (x set('A', 'B') default 0) character set utf8mb4 engine heap;
+ERROR 42000: Invalid default value for 'x'
+create table t1 (x enum('A', 'B') default 0) character set utf8mb4 engine heap;
+ERROR 42000: Invalid default value for 'x'
+SET NAMES UTF8;
+CREATE TABLE t1 (
+`id` int(20) NOT NULL auto_increment,
+`country` varchar(100) NOT NULL default '',
+`shortcode` varchar(100) NOT NULL default '',
+`operator` varchar(100) NOT NULL default '',
+`momid` varchar(30) NOT NULL default '',
+`keyword` varchar(160) NOT NULL default '',
+`content` varchar(160) NOT NULL default '',
+`second_token` varchar(160) default NULL,
+`gateway_id` int(11) NOT NULL default '0',
+`created` datetime NOT NULL default '0000-00-00 00:00:00',
+`msisdn` varchar(15) NOT NULL default '',
+PRIMARY KEY  (`id`),
+UNIQUE KEY `MSCCSPK_20030521130957121` (`momid`),
+KEY `IX_mobile_originated_message_keyword` (`keyword`),
+KEY `IX_mobile_originated_message_created` (`created`),
+KEY `IX_mobile_originated_message_support` (`msisdn`,`momid`,`keyword`,`gateway_id`,`created`)
+) ENGINE=heap DEFAULT CHARSET=utf8mb4;
+INSERT INTO t1 VALUES 
+(1,'blah','464','aaa','fkc1c9ilc20x0hgae7lx6j09','ERR','ERR Имри.Афимим.Аеимимримдмримрмрирор имрииримрфмфмим.Ад.Д имдимримрад.Амфшьмримд им.Адимимрн имадми','РОР',3,'2005-06-01 17:30:43','1234567890'),
+(2,'blah','464','aaa','haxpl2ilc20x00bj4tt2m5ti','11','11 g','G',3,'2005-06-02 22:43:10','1234567890');
+CREATE TABLE t2 (
+`msisdn` varchar(15) NOT NULL default '',
+`operator_id` int(11) NOT NULL default '0',
+`created` datetime NOT NULL default '0000-00-00 00:00:00',
+UNIQUE KEY `PK_user` (`msisdn`)
+) ENGINE=heap DEFAULT CHARSET=utf8mb4;
+INSERT INTO t2 VALUES ('1234567890',2,'2005-05-24 13:53:25');
+SELECT content, t2.msisdn FROM t1, t2 WHERE t1.msisdn = '1234567890';
+content	msisdn
+ERR Имри.Афимим.мрфмфмим.Ад.Д имдимримрад.Адимьмримд им.Адимимрн имадми	1234567890
+11 g	1234567890
+DROP TABLE t1,t2;
+create table t1 (a char(20) character set utf8mb4) engine heap;
+insert into t1 values ('123456'),('андрей');
+alter table t1 modify a char(2) character set utf8mb4;
+Warnings:
+Warning	1265	Data truncated for column 'a' at row 1
+Warning	1265	Data truncated for column 'a' at row 2
+select char_length(a), length(a), a from t1 order by a;
+char_length(a)	length(a)	a
+2	2	12
+2	4	ан
+drop table t1;
+set names utf8mb4;
+select 'andre%' like 'andreñ%' escape 'ñ';
+'andre%' like 'andreñ%' escape 'ñ'
+1
+set names utf8mb4;
+select 'a\\' like 'a\\';
+'a\\' like 'a\\'
+1
+select 'aa\\' like 'a%\\';
+'aa\\' like 'a%\\'
+1
+create table t1 (a char(10), key(a)) character set utf8mb4 engine heap;
+insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test");
+select * from t1 where a like "abc%";
+a
+abc
+abcd
+select * from t1 where a like concat("abc","%");
+a
+abc
+abcd
+select * from t1 where a like "ABC%";
+a
+abc
+abcd
+select * from t1 where a like "test%";
+a
+test
+select * from t1 where a like "te_t";
+a
+test
+select * from t1 where a like "%a%";
+a
+a
+abc
+abcd
+select * from t1 where a like "%abcd%";
+a
+abcd
+select * from t1 where a like "%abc\d%";
+a
+abcd
+drop table t1;
+CREATE TABLE t1 (
+a varchar(255) NOT NULL default '',
+KEY a (a)
+) ENGINE=heap DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;
+insert into t1 values (_utf8mb4 0xe880bd);
+insert into t1 values (_utf8mb4 0x5b);
+select hex(a) from t1;
+hex(a)
+5B
+E880BD
+drop table t1;
+set names 'latin1';
+create table t1 (a varchar(255)) default charset=utf8mb4 engine heap;
+select * from t1 where find_in_set('-1', a);
+a
+drop table t1;
+create table t1 (a int) engine heap;
+insert into t1 values (48),(49),(50);
+set names utf8mb4;
+select distinct char(a) from t1;
+char(a)
+0
+1
+2
+drop table t1;
+CREATE TABLE t1 (item varchar(255)) default character set utf8mb4 ENGINE heap;
+INSERT INTO t1 VALUES (N'\\');
+INSERT INTO t1 VALUES (_utf8mb4'\\');
+INSERT INTO t1 VALUES (N'Cote d\'Ivoire');
+INSERT INTO t1 VALUES (_utf8mb4'Cote d\'Ivoire');
+SELECT item FROM t1 ORDER BY item;
+item
+Cote d'Ivoire
+Cote d'Ivoire
+\
+\
+DROP TABLE t1;
+SET NAMES utf8mb4;
+DROP TABLE IF EXISTS t1;
+Warnings:
+Note	1051	Unknown table 't1'
+CREATE TABLE t1(a VARCHAR(255), KEY(a)) ENGINE=heap DEFAULT CHARSET=utf8mb4;
+INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb');
+INSERT INTO t1 VALUES('uu');
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	note	The storage engine for the table doesn't support check
+INSERT INTO t1 VALUES('uU');
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	note	The storage engine for the table doesn't support check
+INSERT INTO t1 VALUES('uu');
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	note	The storage engine for the table doesn't support check
+INSERT INTO t1 VALUES('uuABC');
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	note	The storage engine for the table doesn't support check
+INSERT INTO t1 VALUES('UuABC');
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	note	The storage engine for the table doesn't support check
+INSERT INTO t1 VALUES('uuABC');
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	note	The storage engine for the table doesn't support check
+alter table t1 add b int;
+INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',1);
+INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',2);
+delete from t1 where b=1;
+INSERT INTO t1 VALUES('UUABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',1);
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	note	The storage engine for the table doesn't support check
+INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',3);
+INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',4);
+delete from t1 where b=3;
+INSERT INTO t1 VALUES('uUABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',3);
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	note	The storage engine for the table doesn't support check
+drop table t1;
+set names utf8mb4;
+create table t1 (s1 char(5) character set utf8mb4) engine heap;
+insert into t1 values
+('a'),('b'),(null),('ペテルグル'),('ü'),('Y');
+create index it1 on t1 (s1);
+select s1 as before_delete_general_ci from t1 where s1 like 'ペテ%';
+before_delete_general_ci
+ペテルグル
+delete from t1 where s1 = 'Y';
+select s1 as after_delete_general_ci from t1 where s1 like 'ペテ%';
+after_delete_general_ci
+ペble t1 (s1 char(5) character set utf8mb4 collate utf8mb4_unicode_ci) engine heap;
+insert into t1 values
+('a'),('b'),(null),('ペテルグル'),('ü'),('Y');
+create index it1 on t1 (s1);
+select s1 as before_delete_unicode_ci from t1 where s1 like 'ペテ%';
+before_delete_unicode_ci
+ペテルグル
+delete from t1 where s1 = 'Y';
+select s1 as after_delete_unicode_ci from t1 where s1 like 'able t1;
+set names utf8mb4;
+create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_bin) engine heap;
+insert into t1 values
+('a'),('b'),(null),('ペテルグル'),('ü'),('Y');
+create index it1 on t1 (s1);
+select s1 as before_delete_bin from t1 where s1 like 'ペテ%';
+before_delete_bin
+ペテルグル
+delete from t1 where s1 = 'Y';
+select s1 as after_delete_bin from t1 where s1 like 'ペテ%';
+after_delete_bin
+ペテルグル
+drop table t1;
+set names utf8mb4;
+create table t1 (a varchar(30) not null primary key)
+engine=heap default character set utf8mb4 collate utf8mb4_general_ci;
+insert into t1 values ('あいうえおかきくけこさしすせそ');
+insert into t1 values ('さしすせそかきくけke 'さしすせそかきくけこあいうえお%';
+gci1
+さしすせそかきくけこあいうえお
+select a as gci2 from t1 where a like 'あいうえおかきくこさしすせそ
+drop table t1;
+set names utf8mb4;
+create table t1 (a varchar(30) not null primary key)
+engine=heap default character set utf8mb4 collate utf8mb4_unicode_ci;
+insert into t1 values ('あいうえおかきすせそかきくけこあいうえお');
+select a as uci1 from t1 where a like 'さしすせそかきくけこいうえおかきくけこさしすせそ';
+uci2
+あ+set names utf8mb4;
+create table t1 (a varchar(30) not null primary key)
+engine=heap default character set utf8mb4 collate utf8mb4_bin;
+insert into t1 values ('あいvalues ('さしすせそかきくけこあいうえお');
+select a as bin1 from t1 where a like 'さしすせそere a like 'あいうえおかきくけこさしすせそ';
+bin2
+あいうえおかきくけこさしすせそ
+drop table t1;
+SET NAMES utf8mb4;
+CREATE TABLE t1 (id int PRIMARY KEY,
+a varchar(16) collate utf8mb4_unicode_ci NOT NULL default '',
+b int,
+f varchar(128) default 'XXX',
+INDEX (a(4))
+) ENGINE=heap DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+INSERT INTO t1(id, a, b) VALUES
+(1, 'cccc', 50), (2, 'cccc', 70), (3, 'cccc', 30),
+(4, 'cccc', 30), (5, 'cccc', 20), (6, 'bbbbbb', 40),
+(7, 'dddd', 30), (8, 'aaaa', 10), (9, 'aaaa', 50),
+(10, 'eeeee', 40), (11, 'bbbbbb', 60);
+SELECT id, a, b FROM t1;
+id	a	b
+1	cccc	50
+10	eeeee	40
+11	bbbbbb	60
+2	cccc	70
+3	cccc	30
+4	cccc	30
+5	cccc	20
+6	bbbbbb	40
+7	dddd	30
+8	aaaa	10
+9	aaaa	50
+SELECT id, a, b FROM t1 WHERE a BETWEEN 'aaaa' AND 'bbbbbb';
+id	a	b
+11	bbbbbb	60
+6	bbbbbb	40
+8	aaaa	10
+9	aaaa	50
+SELECT id, a FROM t1 WHERE a='bbbbbb';
+id	a
+11	bbbbbb
+6	bbbbbb
+SELECT id, a FROM t1 WHERE a='bbbbbb' ORDER BY b;
+id	a
+6	bbbbbb
+11	bbbbbb
+DROP TABLE t1;
+SET NAMES utf8mb4;
+CREATE TABLE t1 (
+a CHAR(13) DEFAULT '',
+INDEX(a)
+) ENGINE=heap DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+INSERT INTO t1 VALUES 
+('Käli Käli 2-4'), ('Käli Käli 2-4'),
+('Käli Käli 2+4'), ('Käli Käli 2+4'),
+('Käli Käli 2-6'), ('Käli Käli 2-6');
+INSERT INTO t1 SELECT * FROM t1;
+CREATE TABLE t2 (
+a CHAR(13) DEFAULT '',
+INDEX(a)
+) ENGINE=heap DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
+INSERT INTO t2 VALUES
+('Kali Kali 2-4'), ('Kali Kali 2-4'),
+('Kali Kali 2+4'), ('Kali Kali 2+4'),
+('Kali Kali 2-6'), ('Kali Kali 2-6');
+INSERT INTO t2 SELECT * FROM t2;
+SELECT a FROM t1 WHERE a LIKE 'Käli Käli 2+4';
+a
+Käli Käli 2+4
+Käli Käli 2+4
+Käli Käli 2+4
+Käli Käli 2+4
+SELECT a FROM t2 WHERE a LIKE 'Kali Kali 2+4';
+a
+Kali Kali 2+4
+Kali Kali 2+4
+Kali Kali 2+4
+Kali Kali 2+4
+EXPLAIN SELECT a FROM t1 WHERE a LIKE 'Käli Käli 2+4';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	a	NULL	NULL	NULL	12	Using where
+EXPLAIN SELECT a FROM t1 WHERE a = 'Käli Käli 2+4';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ref	a	a	53	const	4	Using where
+EXPLAIN SELECT a FROM t2 WHERE a LIKE 'Kali Kali 2+4';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t2	ALL	a	NULL	NULL	NULL	12	Using where
+EXPLAIN SELECT a FROM t2 WHERE a = 'Kali Kali 2+4';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t2	ref	a	a	14	const	4	Using where
+DROP TABLE t1,t2;
+CREATE TABLE t1 (
+a char(255) DEFAULT '', 
+KEY(a(10))
+) ENGINE=heap DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+INSERT INTO t1 VALUES ('Käli Käli 2-4');
+SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%';
+a
+Käli Käli 2-4
+INSERT INTO t1 VALUES ('Käli Käli 2-4');
+SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%';
+a
+Käli Käli 2-4
+Käli Käli 2-4
+DROP TABLE t1;
+CREATE TABLE t1 (
+a char(255) DEFAULT ''
+) ENGINE=heap DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+INSERT INTO t1 VALUES ('Käli Käli 2-4');
+INSERT INTO t1 VALUES ('Käli Käli 2-4');
+SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%';
+a
+Käli Käli 2-4
+Käli Käli 2-4
+ALTER TABLE t1 ADD KEY (a(10));
+SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%';
+a
+Käli Käli 2-4
+Käli Käli 2-4
+DROP TABLE t1;
+SET NAMES latin2;
+create table t1(a char(200) collate utf8mb4_unicode_ci NOT NULL default '')
+default charset=utf8mb4 collate=utf8mb4_unicode_ci engine heap;
+insert into t1 values (unhex('65')), (unhex('C3A9')), (unhex('65'));
+explain select distinct a from t1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	Using temporary
+SELECT COUNT(*) FROM (SELECT DISTINCT a FROM t1) AS t2;
+COUNT(*)
+1
+explain select a from t1 group by a;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	Using temporary; Using filesort
+SELECT COUNT(*) FROM (SELECT a FROM t1 GROUP BY a) AS t2;
+COUNT(*)
+1
+drop table t1;
+create table t1(a char(10)) default charset utf8mb4 engine heap;
+insert into t1 values ('123'), ('456');
+explain
+select substr(Z.a,-1), Z.a from t1 as Y join t1 as Z on Y.a=Z.a order by 1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	Y	ALL	NULL	NULL	NULL	NULL	2	Using temporary; Using filesort
+1	SIMPLE	Z	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer
+select substr(Z.a,-1), Z.a from t1 as Y join t1 as Z on Y.a=Z.a order by 1;
+substr(Z.a,-1)	a
+3	123
+6	456
+drop table t1;
+SET CHARACTER SET utf8mb4;
+SHOW VARIABLES LIKE 'character\_set\_%';
+Variable_name	Value
+character_set_client	utf8mb4
+character_set_connection	latin1
+character_set_database	latin1
+character_set_filesystem	binary
+character_set_results	utf8mb4
+character_set_server	latin1
+character_set_system	utf8
+CREATE DATABASE crashtest DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
+USE crashtest;
+CREATE TABLE crashtest (crash char(10)) DEFAULT CHARSET=utf8mb4 ENGINE heap;
+INSERT INTO crashtest VALUES ('35'), ('36'), ('37');
+SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8mb4);
+crash
+35
+36
+37
+INSERT INTO crashtest VALUES ('-1000');
+EXPLAIN SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8mb4);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	crashtest	ALL	NULL	NULL	NULL	NULL	4	Using filesort
+SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8mb4);
+crash
+-1000
+35
+36
+37
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FFFFFC'
+DROP TABLE crashtest;
+DROP DATABASE crashtest;
+USE test;
+SET CHARACTER SET default;
+CREATE TABLE t1(id varchar(20) NOT NULL) DEFAULT CHARSET=utf8mb4 ENGINE heap;
+INSERT INTO t1 VALUES ('xxx'), ('aa'), ('yyy'), ('aa');
+SELECT id FROM t1;
+id
+aa
+aa
+xxx
+yyy
+SELECT DISTINCT id FROM t1;
+id
+aa
+xxx
+yyy
+SELECT DISTINCT id FROM t1 ORDER BY id;
+id
+aa
+xxx
+yyy
+DROP TABLE t1;
+create table t1 (
+a varchar(26) not null
+) default character set utf8mb4 ENGINE heap;
+insert into t1 (a) values ('abcdefghijklmnopqrstuvwxyz');
+select * from t1;
+a
+abcdefghijklmnopqrstuvwxyz
+alter table t1 change a a varchar(20) character set utf8mb4 not null;
+Warnings:
+Warning	1265	Data truncated for column 'a' at row 1
+select * from t1;
+a
+abcdefghijklmnopqrst
+alter table t1 change a a char(15) character set utf8mb4 not null;
+Warnings:
+Warning	1265	Data truncated for column 'a' at row 1
+select * from t1;
+a
+abcdefghijklmno
+alter table t1 change a a char(10) character set utf8mb4 not null;
+Warnings:
+Warning	1265	Data truncated for column 'a' at row 1
+select * from t1;
+a
+abcdefghij
+alter table t1 change a a varchar(5) character set utf8mb4 not null;
+Warnings:
+Warning	1265	Data truncated for column 'a' at row 1
+select * from t1;
+a
+abcde
+drop table t1;
+create table t1 (
+a varchar(4000) not null
+) default character set utf8mb4 engine heap;
+insert into t1 values (repeat('a',4000));
+alter table t1 change a a varchar(3000) character set utf8mb4 not null;
+Warnings:
+Warning	1265	Data truncated for column 'a' at row 1
+select length(a) from t1;
+length(a)
+3000
+drop table t1;
+set names utf8mb4;
+select hex(char(1 using utf8mb4));
+hex(char(1 using utf8mb4))
+01
+select char(0xd1,0x8f using utf8mb4);
+char(0xd1,0x8f using utf8mb4)
+я
+select char(0xd18f using utf8mb4);
+char(0xd18f using utf8mb4)
+я
+select char(53647 using utf8mb4);
+char(53647 using utf8mb4)
+я
+select char(0xff,0x8f using utf8mb4);
+char(0xff,0x8f using utf8mb4)
+
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FF8F'
+select convert(char(0xff,0x8f) using utf8mb4);
+convert(char(0xff,0x8f) using utf8mb4)
+
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FF8F'
+set sql_mode=traditional;
+select char(0xff,0x8f using utf8mb4);
+char(0xff,0x8f using utf8mb4)
+NULL
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FF8F'
+select char(195 using utf8mb4);
+char(195 using utf8mb4)
+NULL
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'C3'
+select char(196 using utf8mb4);
+char(196 using utf8mb4)
+NULL
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'C4'
+select char(2557 using utf8mb4);
+char(2557 using utf8mb4)
+NULL
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FD'
+select convert(char(0xff,0x8f) using utf8mb4);
+convert(char(0xff,0x8f) using utf8mb4)
+NULL
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FF8F'
+select hex(convert(char(2557 using latin1) using utf8mb4));
+hex(convert(char(2557 using latin1) using utf8mb4))
+09C3BD
+select hex(char(195));
+hex(char(195))
+C3
+select hex(char(196));
+hex(char(196))
+C4
+select hex(char(2557));
+hex(char(2557))
+09FD
+set names utf8mb4;
+create table t1 (a char(1)) default character set utf8mb4 engine heap;
+create table t2 (a char(1)) default character set utf8mb4 engine heap;
+insert into t1 values('a'),('a'),(0xE38182),(0xE38182);
+insert into t1 values('i'),('i'),(0xE38184),(0xE38184);
+select * from t1 union distinct select * from t2;
+a
+a
+i
+あ
+い
+drop table t1,t2;
+set names utf8mb4;
+create table t1 (a char(10), b varchar(10)) engine heap;
+insert into t1 values ('bar','kostja');
+insert into t1 values ('kostja','bar');
+prepare my_stmt from "select * from t1 where a=?";
+set @a:='bar';
+execute my_stmt using @a;
+a	b
+bar	kostja
+set @a:='kostja';
+execute my_stmt using @a;
+a	b
+kostja	bar
+set @a:=null;
+execute my_stmt using @a;
+a	b
+drop table if exists t1;
+drop table if exists t1;
+drop view if exists v1, v2;
+set names utf8mb4;
+create table t1(col1 varchar(12) character set utf8mb4 collate utf8mb4_unicode_ci) engine heap;
+insert into t1 values('t1_val');
+create view v1 as select 'v1_val' as col1;
+select coercibility(col1), collation(col1) from v1;
+coercibility(col1)	collation(col1)
+4	utf8mb4_general_ci
+create view v2 as select col1 from v1 union select col1 from t1;
+select coercibility(col1), collation(col1)from v2;
+coercibility(col1)	collation(col1)
+2	utf8mb4_unicode_ci
+2	utf8mb4_unicode_ci
+drop view v1, v2;
+create view v1 as select 'v1_val' collate utf8mb4_swedish_ci as col1;
+select coercibility(col1), collation(col1) from v1;
+coercibility(col1)	collation(col1)
+0	utf8mb4_swedish_ci
+create view v2 as select col1 from v1 union select col1 from t1;
+select coercibility(col1), collation(col1) from v2;
+coercibility(col1)	collation(col1)
+0	utf8mb4_swedish_ci
+0	utf8mb4_swedish_ci
+drop view v1, v2;
+drop table t1;
+set names utf8mb4;
+create table t1 (a varchar(10) character set latin1, b int) engine heap;
+insert into t1 values ('a',1);
+select concat(a, if(b>10, N'x', N'y')) from t1;
+concat(a, if(b>10, N'x', N'y'))
+ay
+select concat(a, if(b>10, N'æ', N'ß')) from t1;
+ERROR HY000: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation 'concat'
+drop table t1;
+set names utf8mb4;
+create table t1 (a varchar(10) character set latin1, b int) engine heap;
+insert into t1 values ('a',1);
+select concat(a, if(b>10, _utf8mb4'x', _utf8mb4'y')) from t1;
+concat(a, if(b>10, _utf8mb4'x', _utf8mb4'y'))
+ay
+select concat(a, if(b>10, _utf8mb4'æ', _utf8mb4'ß')) from t1;
+ERROR HY000: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation 'concat'
+drop table t1;
+set names utf8mb4;
+create table t1 (a varchar(10) character set latin1, b int) engine heap;
+insert into t1 values ('a',1);
+select concat(a, if(b>10, _utf8mb4 0x78, _utf8mb4 0x79)) from t1;
+concat(a, if(b>10, _utf8mb4 0x78, _utf8mb4 0x79))
+ay
+select concat(a, if(b>10, _utf8mb4 0xC3A6, _utf8mb4 0xC3AF)) from t1;
+ERROR HY000: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation 'concat'
+drop table t1;
+set names utf8mb4;
+create table t1 (a varchar(10) character set latin1, b int) engine heap;
+insert into t1 values ('a',1);
+select concat(a, if(b>10, 'x' 'x', 'y' 'y')) from t1;
+concat(a, if(b>10, 'x' 'x', 'y' 'y'))
+ayy
+select concat(a, if(b>10, 'x' 'æ', 'y' 'ß')) from t1;
+ERROR HY000: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation 'concat'
+drop table t1;
+CREATE TABLE t1 (
+colA int(11) NOT NULL,
+colB varchar(255) character set utf8mb4 NOT NULL,
+PRIMARY KEY  (colA)
+) ENGINE=heap DEFAULT CHARSET=latin1;
+INSERT INTO t1 (colA, colB) VALUES (1, 'foo'), (2, 'foo bar');
+CREATE TABLE t2 (
+colA int(11) NOT NULL,
+colB varchar(255) character set utf8mb4 NOT NULL,
+KEY bad  (colA,colB(3))
+) ENGINE=heap DEFAULT CHARSET=latin1;
+INSERT INTO t2 (colA, colB) VALUES (1, 'foo'),(2, 'foo bar');
+SELECT * FROM t1 JOIN t2 ON t1.colA=t2.colA AND t1.colB=t2.colB
+WHERE t1.colA < 3;
+colA	colB	colA	colB
+1	foo	1	foo
+2	foo bar	2	foo bar
+DROP TABLE t1, t2;
+SELECT 'н1234567890' UNION SELECT _binary '1';
+н1234567890
+1234567890
+н1234567890
+1
+SELECT '1' UNION SELECT 'н1234567890';
+1
+1
+н1234567890
+SELECT 1 UNION SELECT 'CHAR(11)) CHARACTER SET utf8mb4 ENGINE heap;
+CREATE TABLE t2 (b CHAR(1) CHARACTER SET binary, i INT) ENGINE heap;
+INSERT INTO t1 (c) VALUES ('н1234567890');
+INSERT INTO t2 (b, i) VALUES ('1', 1);
+SELECT c FROM t1 UNION SELECT b FROM t2;
+c
+н1234567890
+1
+SELECT c FROM t1 UNION SELECT i FROM t2;
+c
+н1234567890
+1
+SELECT b FROM t2 UNION SELECT c FROM t1;
+b
+1
+н1234567890
+SELECT i FROM t2 UNION SELECT c FROM t1;
+i
+1
+н1234567890
+DROP TABLE t1, t2;
+set sql_mode=traditional;
+select hex(char(0xFF using utf8mb4));
+hex(char(0xFF using utf8mb4))
+NULL
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FF'
+select hex(convert(0xFF using utf8mb4));
+hex(convert(0xFF using utf8mb4))
+NULL
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FF'
+select hex(_utf8mb4 0x616263FF);
+ERROR HY000: Invalid utf8mb4 character string: 'FF'
+select hex(_utf8mb4 X'616263FF');
+ERROR HY000: Invalid utf8mb4 character string: 'FF'
+select hex(_utf8mb4 B'001111111111');
+ERROR HY000: Invalid utf8mb4 character string: 'FF'
+select (_utf8mb4 X'616263FF');
+ERROR HY000: Invalid utf8mb4 character string: 'FF'
+set sql_mode=default;
+select hex(char(0xFF using utf8mb4));
+hex(char(0xFF using utf8mb4))
+
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FF'
+select hex(convert(0xFF using utf8mb4));
+hex(convert(0xFF using utf8mb4))
+
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FF'
+select hex(_utf8mb4 0x616263FF);
+ERROR HY000: Invalid utf8mb4 character string: 'FF'
+select hex(_utf8mb4 X'616263FF');
+ERROR HY000: Invalid utf8mb4 character string: 'FF'
+select hex(_utf8mb4 B'001111111111');
+ERROR HY000: Invalid utf8mb4 character string: 'FF'
+select (_utf8mb4 X'616263FF');
+ERROR HY000: Invalid utf8mb4 character string: 'FF'
+CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL) ENGINE heap;
+INSERT INTO t1 VALUES (70000, 1092), (70001, 1085), (70002, 1065);
+SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b;
+CONVERT(a, CHAR)	CONVERT(b, CHAR)
+70000	1092
+70001	1085
+70002	1065
+SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1;
+CONVERT(a, CHAR)	CONVERT(b, CHAR)
+70000	1092
+70001	1085
+70002	1065
+ALTER TABLE t1 ADD UNIQUE (b);
+SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b;
+CONVERT(a, CHAR)	CONVERT(b, CHAR)
+70000	1092
+70001	1085
+70002	1065
+DROP INDEX b ON t1;
+SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b;
+CONVERT(a, CHAR)	CONVERT(b, CHAR)
+70000	1092
+70001	1085
+70002	1065
+ALTER TABLE t1 ADD INDEX (b);
+SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) from t1 GROUP BY b;
+CONVERT(a, CHAR)	CONVERT(b, CHAR)
+70000	1092
+70001	1085
+70002	1065
+DROP TABLE t1;
+#
+# Bug#26474: Add Sinhala script (Sri Lanka) collation to MySQL
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+predicted_order int NOT NULL,
+utf8mb4_encoding VARCHAR(10) NOT NULL
+) CHARACTER SET utf8mb4 ENGINE heap;
+INSERT INTO t1 VALUES (19, x'E0B696'), (30, x'E0B69AE0B798'), (61, x'E0B6AF'), (93, x'E0B799'), (52, x'E0B6A6'), (73, x'E0B6BBE0B78AE2808D'), (3, x'E0B686'), (56, x'E0B6AA'), (55, x'E0B6A9'), (70, x'E0B6B9'), (94, x'E0B79A'), (80, x'E0B785'), (25, x'E0B69AE0B791'), (48, x'E0B6A2'), (13, x'E0B690'), (86, x'E0B793'), (91, x'E0B79F'), (81, x'E0B786'), (79, x'E0B784'), (14, x'E0B691'), (99, x'E0B78A'), (8, x'E0B68B'), (68, x'E0B6B7'), (22, x'E0B69A'), (16, x'E0B693'), (33, x'E0B69AE0B7B3'), (38, x'E0B69AE0B79D'), (21, x'E0B683'), (11, x'E0B68E'), (77, x'E0B782'), (40, x'E0B69AE0B78A'), (101, x'E0B78AE2808DE0B6BB'), (35, x'E0B69AE0B79A'), (1, x'E0B7B4'), (9, x'E0B68C'), (96, x'E0B79C'), (6, x'E0B689'), (95, x'E0B79B'), (88, x'E0B796'), (64, x'E0B6B3'), (26, x'E0B69AE0B792'), (82, x'E0B78F'), (28, x'E0B69AE0B794'), (39, x'E0B69AE0B79E'), (97, x'E0B79D'), (2, x'E0B685'), (75, x'E0B780'), (34, x'E0B69AE0B799'), (69, x'E0B6B8'), (83, x'E0B790'), (18, x'E0B695'), (90, x'E0B7B2'), (17, x'E0B694'), (72, x'E0B6BB'), (66, x'E0B6B5'), (59, x'E0B6AD'), (44, x'E0B69E'), (15, x'E0B692'), (23, x'E0B69AE0B78F'), (65, x'E0B6B4'), (42, x'E0B69C'), (63, x'E0B6B1'), (85, x'E0B792'), (47, x'E0B6A1'), (49, x'E0B6A3'), (92, x'E0B7B3'), (78, x'E0B783'), (36, x'E0B69AE0B79B'), (4, x'E0B687'), (24, x'E0B69AE0B790'), (87, x'E0B794'), (37, x'E0B69AE0B79C'), (32, x'E0B69AE0B79F'), (29, x'E0B69AE0B796'), (43, x'E0B69D'), (62, x'E0B6B0'), (100, x'E0B78AE2808DE0B6BA'), (60, x'E0B6AE'), (45, x'E0B69F'), (12, x'E0B68F'), (46, x'E0B6A0'), (50, x'E0B6A5'), (51, x'E0B6A4'), (5, x'E0B688'), (76, x'E0B781'), (89, x'E0B798'), (74, x'E0B6BD'), (10, x'E0B68D'), (57, x'E0B6AB'), (71, x'E0B6BA'), (58, x'E0B6AC'), (27, x'E0B69AE0B793'), (54, x'E0B6A8'), (84, x'E0B791'), (31, x'E0B69AE0B7B2'), (98, x'E0B79E'), (53, x'E0B6A7'), (41, x'E0B69B'), (67, x'E0B6B6'), (7, x'E0B68A'), (20, x'E0B682');
+SELECT predicted_order, hex(utf8mb4_encoding) FROM t1 ORDER BY utf8mb4_encoding COLLATE utf8mb4_sinhala_ci;
+predicted_order	hex(utf8mb4_encoding)
+1	E0B7B4
+2	E0B685
+3	E0B686
+4	E0B687
+5	E0B688
+6	E0B689
+7	E0B68A
+8	E0B68B
+9	E0B68C
+10	E0B68D
+11	E0B68E
+12	E0B68F
+13	E0B690
+14	E0B691
+15	E0B692
+16	E0B693
+17	E0B694
+18	E0B695
+19	E0B696
+20	E0B682
+21	E0B683
+22	E0B69A
+23	E0B69AE0B78F
+24	E0B69AE0B790
+25	E0B69AE0B791
+26	E0B69AE0B792
+27	E0B69AE0B793
+28	E0B69AE0B794
+29	E0B69AE0B796
+30	E0B69AE0B798
+31	E0B69AE0B7B2
+32	E0B69AE0B79F
+33	E0B69AE0B7B3
+34	E0B69AE0B799
+35	E0B69AE0B79A
+36	E0B69AE0B79B
+37	E0B69AE0B79C
+38	E0B69AE0B79D
+39	E0B69AE0B79E
+40	E0B69AE0B78A
+41	E0B69B
+42	E0B69C
+43	E0B69D
+44	E0B69E
+45	E0B69F
+46	E0B6A0
+47	E0B6A1
+48	E0B6A2
+49	E0B6A3
+50	E0B6A5
+51	E0B6A4
+52	E0B6A6
+53	E0B6A7
+54	E0B6A8
+55	E0B6A9
+56	E0B6AA
+57	E0B6AB
+58	E0B6AC
+59	E0B6AD
+60	E0B6AE
+61	E0B6AF
+62	E0B6B0
+63	E0B6B1
+64	E0B6B3
+65	E0B6B4
+66	E0B6B5
+67	E0B6B6
+68	E0B6B7
+69	E0B6B8
+70	E0B6B9
+71	E0B6BA
+72	E0B6BB
+73	E0B6BBE0B78AE2808D
+74	E0B6BD
+75	E0B780
+76	E0B781
+77	E0B782
+78	E0B783
+79	E0B784
+80	E0B785
+81	E0B786
+82	E0B78F
+83	E0B790
+84	E0B791
+85	E0B792
+86	E0B793
+87	E0B794
+88	E0B796
+89	E0B798
+90	E0B7B2
+91	E0B79F
+92	E0B7B3
+93	E0B799
+94	E0B79A
+95	E0B79B
+96	E0B79C
+97	E0B79D
+98	E0B79E
+99	E0B78A
+100	E0B78AE2808DE0B6BA
+101	E0B78AE2808DE0B6BB
+DROP TABLE t1;
+#
+# Bug#32914 Character sets: illegal characters in utf8mb4 and utf32 columns
+#
+create table t1 (utf8mb4 char(1) character set utf8mb4) engine heap;
+Testing [F0][90..BF][80..BF][80..BF]
+insert into t1 values (0xF0908080);
+insert into t1 values (0xF0BFBFBF);
+insert into t1 values (0xF08F8080);
+Warnings:
+Warning	1366	Incorrect string value: '\xF0\x8F\x80\x80' for column 'utf8mb4' at row 1
+select hex(utf8mb4) from t1;
+hex(utf8mb4)
+
+F0908080
+F0BFBFBF
+delete from t1;
+Testing [F2..F3][80..BF][80..BF][80..BF]
+insert into t1 values (0xF2808080);
+insert into t1 values (0xF2BFBFBF);
+select hex(utf8mb4) from t1;
+hex(utf8mb4)
+F2808080
+F2BFBFBF
+delete from t1;
+Testing [F4][80..8F][80..BF][80..BF]
+insert into t1 values (0xF4808080);
+insert into t1 values (0xF48F8080);
+insert into t1 values (0xF4908080);
+Warnings:
+Warning	1366	Incorrect string value: '\xF4\x90\x80\x80' for column 'utf8mb4' at row 1
+select hex(utf8mb4) from t1;
+hex(utf8mb4)
+
+F4808080
+F48F8080
+drop table t1;
+#
+# Check strnxfrm() with odd length
+#
+set max_sort_length=5;
+select @@max_sort_length;
+@@max_sort_length
+5
+create table t1 (a varchar(128) character set utf8mb4 collate utf8mb4_general_ci) engine heap;
+insert into t1 values ('a'),('b'),('c');
+select * from t1 order by a;
+a
+a
+b
+c
+alter table t1 modify a varchar(128) character set utf8mb4 collate utf8mb4_bin;
+select * from t1 order by a;
+a
+a
+b
+c
+drop table t1;
+set max_sort_length=default;
+#
+# Bug#26180: Can't add columns to tables created with utf8mb4 text indexes
+#
+#
+# Testing 4-byte values.
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+u_decimal int NOT NULL,
+utf8mb4_encoding VARCHAR(10) NOT NULL
+) CHARACTER SET utf8mb4 ENGINE heap;
+INSERT INTO t1 VALUES (119040, x'f09d8480'),
+# G CLEF
+(119070, x'f09d849e'),
+# HALF NOTE
+(119134, x'f09d859e'),
+# MUSICAL SYMBOL CROIX
+(119247, x'f09d878f'),
+# MATHEMATICAL BOLD ITALIC CAPITAL DELTA
+(120607, x'f09d9c9f'),
+# SANS-SERIF BOLD ITALIC CAPITAL PI
+(120735, x'f09d9e9f'),
+# <Plane 16 Private Use, Last> (last 4 byte character)
+(1114111, x'f48fbfbf'),
+# VARIATION SELECTOR-256
+(917999, x'f3a087af');
+INSERT INTO t1 VALUES (119070, x'f09d849ef09d859ef09d859ef09d8480f09d859ff09d859ff09d859ff09d85a0f09d85a0f09d8480');
+INSERT INTO t1 VALUES (65131, x'efb9abf09d849ef09d859ef09d859ef09d8480f09d859fefb9abefb9abf09d85a0efb9ab');
+INSERT INTO t1 VALUES (119070, x'f09d849ef09d859ef09d859ef09d8480f09d859ff09d859ff09d859ff09d85a0f09d85a0f09d8480f09d85a0');
+Warnings:
+Warning	1265	Data truncated for column 'utf8mb4_encoding' at row 1
+SELECT u_decimal, hex(utf8mb4_encoding) FROM t1 ORDER BY utf8mb4_encoding COLLATE utf8mb4_general_ci, BINARY utf8mb4_encoding;
+u_decimal	hex(utf8mb4_encoding)
+1114111	F48FBFBF
+119040	F09D8480
+119070	F09D849E
+119070	F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480
+119070	F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480
+119134	F09D859E
+119247	F09D878F
+120607	F09D9C9F
+120735	F09D9E9F
+65131	EFB9ABF09D849EF09D859EF09D859EF09D8480F09D859FEFB9ABEFB9ABF09D85A0EFB9AB
+917999	F3A087AF
+INSERT INTO t1 VALUES (1114111, x'f5808080');
+Warnings:
+Warning	1366	Incorrect string value: '\xF5\x80\x80\x80' for column 'utf8mb4_encoding' at row 1
+SELECT character_maximum_length, character_octet_length FROM information_schema.columns WHERE
+table_name= 't1' AND column_name= 'utf8mb4_encoding';
+character_maximum_length	character_octet_length
+10	40
+DROP TABLE IF EXISTS t2;
+CREATE TABLE t2 (
+u_decimal int NOT NULL,
+utf8mb3_encoding VARCHAR(10) NOT NULL
+) CHARACTER SET utf8mb3 ENGINE heap;
+INSERT INTO t2 VALUES (42856, x'ea9da8');
+INSERT INTO t2 VALUES (65131, x'efb9ab');
+INSERT INTO t2 VALUES (1114111, x'f48fbfbf');
+Warnings:
+Warning	1366	Incorrect string value: '\xF4\x8F\xBF\xBF' for column 'utf8mb3_encoding' at row 1
+SELECT character_maximum_length, character_octet_length FROM information_schema.columns WHERE
+table_name= 't2' AND column_name= 'utf8mb3_encoding';
+character_maximum_length	character_octet_length
+10	30
+UPDATE t2 SET utf8mb3_encoding= x'f48fbfbd' where u_decimal= 42856;
+Warnings:
+Warning	1366	Incorrect string value: '\xF4\x8F\xBF\xBD' for column 'utf8mb3_encoding' at row 1
+UPDATE t2 SET utf8mb3_encoding= _utf8mb4 x'ea9da8' where u_decimal= 42856;
+SELECT HEX(CONCAT(utf8mb4_encoding, _utf8 x'ea9da8')) FROM t1;
+HEX(CONCAT(utf8mb4_encoding, _utf8 x'ea9da8'))
+EA9DA8
+EFB9ABF09D849EF09D859EF09D859EF09D8480F09D859FEFB9ABEFB9ABF09D85A0EFB9ABEA9DA8
+F09D8480EA9DA8
+F09D849EEA9DA8
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480EA9DA8
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480EA9DA8
+F09D859EEA9DA8
+F09D878FEA9DA8
+F09D9C9FEA9DA8
+F09D9E9FEA9DA8
+F3A087AFEA9DA8
+F48FBFBFEA9DA8
+SELECT HEX(CONCAT(utf8mb4_encoding, utf8mb3_encoding)) FROM t1,t2;
+HEX(CONCAT(utf8mb4_encoding, utf8mb3_encoding))
+
+EA9DA8
+EFB9AB
+EFB9ABF09D849EF09D859EF09D859EF09D8480F09D859FEFB9ABEFB9ABF09D85A0EFB9AB
+EFB9ABF09D849EF09D859EF09D859EF09D8480F09D859FEFB9ABEFB9ABF09D85A0EFB9ABEA9DA8
+EFB9ABF09D849EF09D859EF09D859EF09D8480F09D859FEFB9ABEFB9ABF09D85A0EFB9ABEFB9AB
+F09D8480
+F09D8480EA9DA8
+F09D8480EFB9AB
+F09D849E
+F09D849EEA9DA8
+F09D849EEFB9AB
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480EA9DA8
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480EA9DA8
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480EFB9AB
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480EFB9AB
+F09D859E
+F09D859EEA9DA8
+F09D859EEFB9AB
+F09D878F
+F09D878FEA9DA8
+F09D878FEFB9AB
+F09D9C9F
+F09D9C9FEA9DA8
+F09D9C9FEFB9AB
+F09D9E9F
+F09D9E9FEA9DA8
+F09D9E9FEFB9AB
+F3A087AF
+F3A087AFEA9DA8
+F3A087AFEFB9AB
+F48FBFBF
+F48FBFBFEA9DA8
+F48FBFBFEFB9AB
+SELECT count(*) FROM t1, t2
+WHERE t1.utf8mb4_encoding > t2.utf8mb3_encoding;
+count(*)
+33
+ALTER TABLE t1 CONVERT TO CHARACTER SET utf8;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `u_decimal` int(11) NOT NULL,
+  `utf8mb4_encoding` varchar(10) NOT NULL
+) ENGINE=MEMORY DEFAULT CHARSET=utf8
+SELECT u_decimal,hex(utf8mb4_encoding),utf8mb4_encoding FROM t1;
+u_decimal	hex(utf8mb4_encoding)	utf8mb4_encoding
+1114111		
+1114111	3F	?
+119040	3F	?
+119070	3F	?
+119070	3F3F3F3F3F3F3F3F3F3F	??????????
+119070	3F3F3F3F3F3F3F3F3F3F	??????????
+119134	3F	?
+119247	3F	?
+120607	3F	?
+120735	3F	?
+65131	EFB9AB3F3F3F3F3FEFB9ABEFB9AB3FEFB9AB	﹫?????﹫SET utf8mb4;
+SHOW CREATE TABLE t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `u_decimal` int(11) NOT NULL,
+  `utf8mb3_encoding` varchar(10) NOT NULL
+) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4
+SELECT u_decimal,hex(utf8mb3_encoding) FROM t2;
+u_decimal	hex(utf8mb3_encoding)
+1114111	
+42856	EA9DA8
+65131	EFB9AB
+ALTER TABLE t2 CONVERT TO CHARACTER SET utf8mb3;
+SHOW CREATE TABLE t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `u_decimal` int(11) NOT NULL,
+  `utf8mb3_encoding` varchar(10) NOT NULL
+) ENGINE=MEMORY DEFAULT CHARSET=utf8
+SELECT u_decimal,hex(utf8mb3_encoding) FROM t2;
+u_decimal	hex(utf8mb3_encoding)
+1114111	
+42856	EA9DA8
+65131	EFB9AB
+ALTER TABLE t1 MODIFY utf8mb4_encoding VARCHAR(10) CHARACTER SET utf8mb3;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `u_decimal` int(11) NOT NULL,
+  `utf8mb4_encoding` varchar(10) DEFAULT NULL
+) ENGINE=MEMORY DEFAULT CHARSET=utf8
+SELECT u_decimal,hex(utf8mb4_encoding) FROM t1;
+u_decimal	hex(utf8mb4_encoding)
+1114111	
+1114111	3F
+119040	3F
+119070	3F
+119070	3F3F3F3F3F3F3F3F3F3F
+119070	3F3F3F3F3F3F3F3F3F3F
+119134	3F
+119247	3F
+120607	3F
+120735	3F
+65131	EFB9AB3F3F3F3F3FEFB9ABEFB9AB3FEFB9AB
+917999	3F
+ALTER TABLE t1 MODIFY utf8mb4_encoding VARCHAR(10) CHARACTER SET utf8mb4;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `u_decimal` int(11) NOT NULL,
+  `utf8mb4_encoding` varchar(10) CHARACTER SET utf8mb4 DEFAULT NULL
+) ENGINE=MEMORY DEFAULT CHARSET=utf8
+SELECT u_decimal,hex(utf8mb4_encoding) FROM t1;
+u_decimal	hex(utf8mb4_encoding)
+1114111	
+1114111	3F
+119040	3F
+119070	3F
+119070	3F3F3F3F3F3F3F3F3F3F
+119070	3F3F3F3F3F3F3F3F3F3F
+119134	3F
+119247	3F
+120607	3F
+120735	3F
+65131	EFB9AB3F3F3F3F3FEFB9ABEFB9AB3FEFB9AB
+917999	3F
+ALTER TABLE t2 MODIFY utf8mb3_encoding VARCHAR(10) CHARACTER SET utf8mb4;
+SHOW CREATE TABLE t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `u_decimal` int(11) NOT NULL,
+  `utf8mb3_encoding` varchar(10) CHARACTER SET utf8mb4 DEFAULT NULL
+) ENGINE=MEMORY DEFAULT CHARSET=utf8
+SELECT u_decimal,hex(utf8mb3_encoding) FROM t2;
+u_decimal	hex(utf8mb3_encoding)
+1114111	
+42856	EA9DA8
+65131	EFB9AB
+DROP TABLE IF EXISTS t3;
+CREATE TABLE t3 (
+u_decimal int NOT NULL,
+utf8mb3_encoding VARCHAR(10) NOT NULL
+) CHARACTER SET utf8 ENGINE heap;
+INSERT INTO t3 SELECT * FROM t1;
+DROP TABLE IF EXISTS t4;
+CREATE TABLE t4 (
+u_decimal int NOT NULL,
+utf8mb4_encoding VARCHAR(10) NOT NULL
+) CHARACTER SET utf8mb4 ENGINE heap;
+INSERT INTO t3 SELECT * FROM t2;
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+DROP TABLE t4;
+#
+# Testing that mixing utf8 and utf8mb4 collations returns utf8mb4
+#
+SELECT CHARSET(CONCAT(_utf8mb4'a',_utf8'b'));
+CHARSET(CONCAT(_utf8mb4'a',_utf8'b'))
+utf8mb4
+CREATE TABLE t1 (utf8mb4 VARCHAR(10) CHARACTER SET utf8mb4 NOT NULL) ENGINE heap;
+INSERT INTO t1 VALUES (x'ea9da8'),(x'f48fbfbf');
+SELECT CONCAT(utf8mb4, _utf8 x'ea9da8') FROM t1 LIMIT 0;
+CONCAT(utf8mb4, _utf8 x'ea9da8')
+CREATE TABLE t2 (utf8mb3 VARCHAR(10) CHARACTER SET utf8mb3 NOT NULL) ENGINE heap;
+INSERT INTO t2 VALUES (x'ea9da8');
+SELECT HEX(CONCAT(utf8mb4, utf8mb3)) FROM t1,t2 ORDER BY 1;
+HEX(CONCAT(utf8mb4, utf8mb3))
+EA9DA8EA9DA8
+F48FBFBFEA9DA8
+SELECT CHARSET(CONCAT(utf8mb4, utf8mb3)) FROM t1, t2 LIMIT 1;
+CHARSET(CONCAT(utf8mb4, utf8mb3))
+utf8mb4
+CREATE TEMPORARY TABLE t3 ENGINE heap AS SELECT *, concat(utf8mb4,utf8mb3) FROM t1, t2;
+SHOW CREATE TABLE t3;
+Table	Create Table
+t3	CREATE TEMPORARY TABLE `t3` (
+  `utf8mb4` varchar(10) CHARACTER SET utf8mb4 NOT NULL,
+  `utf8mb3` varchar(10) CHARACTER SET utf8 NOT NULL,
+  `concat(utf8mb4,utf8mb3)` varchar(20) CHARACTER SET utf8mb4 NOT NULL DEFAULT ''
+) ENGINE=MEMORY DEFAULT CHARSET=latin1
+DROP TEMPORARY TABLE t3;
+SELECT * FROM t1, t2 WHERE t1.utf8mb4 > t2.utf8mb3;
+utf8mb4	utf8mb3
+􏿿	Ꝩ
+SELECT * FROM t1, t2 WHERE t1.utf8mb4 = t2.utf8mb3;
+utf8mb4	utf8mb3
+Ꝩ	Ꝩ
+SELECT * FROM t1, t2 WHERE t1.utf8mb4 < t2.utf8mb3;
+utf8mb4	utf8mb3
+DROP TABLE t1;
+DROP TABLE t2;
+#
+# Check that mixing utf8mb4 with an invalid utf8 constant returns error
+#
+CREATE TABLE t1 (utf8mb4 VARCHAR(10) CHARACTER SET utf8mb4) ENGINE heap;
+INSERT INTO t1 VALUES (x'f48fbfbf');
+SELECT CONCAT(utf8mb4, _utf8 '�') FROM t1;
+ERROR HY000: Illegal mix of collations (utf8mb4_general_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation 'concat'
+SELECT CONCAT('a', _utf8 '�') FROM t1;
+ERROR HY000: Illegal mix of collations (utf8mb4_general_ci,COERCIBLE) and (utf8_general_ci,COERCIBLE) for operation 'concat'
+DROP TABLE t1;
+#
+# End of 5.5 tests
+#
+#
+# End of tests
+#

=== added file 'mysql-test/r/ctype_utf8mb4_innodb.result'
--- a/mysql-test/r/ctype_utf8mb4_innodb.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/ctype_utf8mb4_innodb.result	2010-03-05 08:17:19 +0000
@@ -0,0 +1,2407 @@
+drop table if exists t1,t2;
+#
+# Start of 5.5 tests
+#
+set names utf8mb4;
+select left(_utf8mb4 0xD0B0D0B1D0B2,1);
+left(_utf8mb4 0xD0B0D0B1D0B2,1)
+а
+select right(_utf8mb4 0xD0B0D0B2D0B2,1);
+right(_utf8mb4 0xD0B0D0B2D0B2,1)
+в
+select locate('he','hello');
+locate('he','hello')
+1
+select locate('he','hello',2);
+locate('he','hello',2)
+0
+select locate('lo','hello',2);
+locate('lo','hello',2)
+4
+select locate('HE','hello');
+locate('HE','hello')
+1
+select locate('HE','hello',2);
+locate('HE','hello',2)
+0
+select locate('LO','hello',2);
+locate('LO','hello',2)
+4
+select locate('HE','hello' collate utf8mb4_bin);
+locate('HE','hello' collate utf8mb4_bin)
+0
+select locate('HE','hello' collate utf8mb4_bin,2);
+locate('HE','hello' collate utf8mb4_bin,2)
+0
+select locate('LO','hello' collate utf8mb4_bin,2);
+locate('LO','hello' collate utf8mb4_bin,2)
+0
+select locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D0B1D0B2);
+locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D0B1D0B2)
+2
+select locate(_utf8mb4 0xD091, _utf8mb4 0xD0B0D0B1D0B2);
+locate(_utf8mb4 0xD091, _utf8mb4 0xD0B0D0B1D0B2)
+2
+select locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D091D0B2);
+locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D091D0B2)
+2
+select locate(_utf8mb4 0xD091, _utf8mb4 0xD0B0D0B1D0B2 collate utf8mb4_bin);
+locate(_utf8mb4 0xD091, _utf8mb4 0xD0B0D0B1D0B2 collate utf8mb4_bin)
+0
+select locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D091D0B2 collate utf8mb4_bin);
+locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D091D0B2 collate utf8mb4_bin)
+0
+select length(_utf8mb4 0xD0B1), bit_length(_utf8mb4 0xD0B1), char_length(_utf8mb4 0xD0B1);
+length(_utf8mb4 0xD0B1)	bit_length(_utf8mb4 0xD0B1)	char_length(_utf8mb4 0xD0B1)
+2	16	1
+select 'a' like 'a';
+'a' like 'a'
+1
+select 'A' like 'a';
+'A' like 'a'
+1
+select 'A' like 'a' collate utf8mb4_bin;
+'A' like 'a' collate utf8mb4_bin
+0
+select _utf8mb4 0xD0B0D0B1D0B2 like concat(_utf8mb4'%',_utf8mb4 0xD0B1,_utf8mb4 '%');
+_utf8mb4 0xD0B0D0B1D0B2 like concat(_utf8mb4'%',_utf8mb4 0xD0B1,_utf8mb4 '%')
+1
+select convert(_latin1'G�Andr8mb4);
+convert(_latin1'G?nter Andr?' using utf8mb4) like CONVERT(_latin1'G?NTER%' USING utf8mb4)
+1
+select CONVERT(_koi8r'��' USING utf8mb4) LIKE CONVERT(_koi8r'�' USING utf8mb4);
+CONVERT(_koi8r'????' USING utf8mb4) LIKE CONVERT(_koi8r'????' USING utf8mb4)
+1
+select CONVERT(_koi8r'�' USING utf8mb4) LIKE CONVERT(_koi8r'��' USING utf8mb4);
+CONVERT(_koi8r'????' USING utf8mb4) LIKE CONVERT(_koi8r'????' USING utf8mb4)
+1
+SELECT 'a' = 'a ';
+'a' = 'a '
+1
+SELECT 'a\0' < 'a';
+'a\0' < 'a'
+1
+SELECT 'a\0' < 'a ';
+'a\0' < 'a '
+1
+SELECT 'a\t' < 'a';
+'a\t' < 'a'
+1
+SELECT 'a\t' < 'a ';
+'a\t' < 'a '
+1
+SELECT 'a' = 'a ' collate utf8mb4_bin;
+'a' = 'a ' collate utf8mb4_bin
+1
+SELECT 'a\0' < 'a' collate utf8mb4_bin;
+'a\0' < 'a' collate utf8mb4_bin
+1
+SELECT 'a\0' < 'a ' collate utf8mb4_bin;
+'a\0' < 'a ' collate utf8mb4_bin
+1
+SELECT 'a\t' < 'a' collate utf8mb4_bin;
+'a\t' < 'a' collate utf8mb4_bin
+1
+SELECT 'a\t' < 'a ' collate utf8mb4_bin;
+'a\t' < 'a ' collate utf8mb4_bin
+1
+CREATE TABLE t1 (a char(10) character set utf8mb4 not null) ENGINE InnoDB;
+INSERT INTO t1 VALUES ('a'),('a\0'),('a\t'),('a ');
+SELECT hex(a),STRCMP(a,'a'), STRCMP(a,'a ') FROM t1;
+hex(a)	STRCMP(a,'a')	STRCMP(a,'a ')
+61	0	0
+61	0	0
+6100	-1	-1
+6109	-1	-1
+DROP TABLE t1;
+select insert('txs',2,1,'hi'),insert('is ',4,0,'a'),insert('txxxxt',2,4,'es');
+insert('txs',2,1,'hi')	insert('is ',4,0,'a')	insert('txxxxt',2,4,'es')
+this	is a	test
+select insert("aa",100,1,"b"),insert("aa",1,3,"b");
+insert("aa",100,1,"b")	insert("aa",1,3,"b")
+aa	b
+select char_length(left(@a:='тес5))	length(@a)	@a
+4	8	тест
+create table t1 ENGINE InnoDB 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")` varchar(10) CHARACTER SET utf8mb4 DEFAULT NULL
+) ENGINE=InnoDB 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 utf8mb4;
+set LC_TIME_NAMES='fr_FR';
+create table t1 (s1 char(20) character set latin1) engine InnoDB;
+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) engine InnoDB;
+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
+E6C5D7	Фев
+E6C5D7D2C1CCD1	Февраля
+F0CEC4	Пнд
+F0CFCEC5C4C5CCD8CEC9CB	Понедельник
+drop table t1;
+set LC_TIME_NAMES='en_US';
+set names koi8r;
+create table t1 (s1 char(1) character set utf8mb4) engine InnoDB;
+insert into t1 values (_koi8r'�');
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+select s1,hex(s1),char_length(s1),octet_length(s1) from t1;
+s1	hex(s1)	char_length(s1)	octet_length(s1)
+�D0B0	1	2
+drop table t1;
+create table t1 (s1 tinytext character set utf8mb4) engine InnoDB;
+insert into t1 select repeat('a',300);
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+insert into t1 select repeat('�,300);
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+insert into t1 select repeat('a�,300);
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+insert into t1 select repeat('�',300);
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+insert into t1 select repeat('�',300);
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+select hex(s1) from t1;
+hex(s1)
+616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161
+61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F
+D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61
+D18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18F
+D18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18F
+select length(s1),char_length(s1) from t1;
+length(s1)	char_length(s1)
+254	127
+254	127
+255	170
+255	170
+255	255
+drop table t1;
+create table t1 (s1 text character set utf8mb4) engine InnoDB;
+insert into t1 select repeat('a',66000);
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+insert into t1 select repeat('�,66000);
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+insert into t1 select repeat('alumn 's1' at row 1
+insert into t1 select repeat('�',66000);
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+insert into t1 select repeat('�',66000);
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+select length(s1),char_length(s1) from t1;
+length(s1)	char_length(s1)
+65534	32767
+65534	32767
+65535	43690
+65535	43690
+65535	65535
+drop table t1;
+create table t1 (s1 char(10) character set utf8mb4) engine InnoDB;
+insert into t1 values (0x41FF);
+Warnings:
+Warning	1366	Incorrect string value: '\xFF' for column 's1' at row 1
+select hex(s1) from t1;
+hex(s1)
+41
+drop table t1;
+create table t1 (s1 varchar(10) character set utf8mb4) engine InnoDB;
+insert into t1 values (0x41FF);
+Warnings:
+Warning	1366	Incorrect string value: '\xFF' for column 's1' at row 1
+select hex(s1) from t1;
+hex(s1)
+41
+drop table t1;
+create table t1 (s1 text character set utf8mb4) engine InnoDB;
+insert into t1 values (0x41FF);
+Warnings:
+Warning	1366	Incorrect string value: '\xFF' for column 's1' at row 1
+select hex(s1) from t1;
+hex(s1)
+41
+drop table t1;
+create table t1 (a text character set utf8mb4, primary key(a(371))) engine InnoDB;
+ERROR 42000: Specified key was too long; max key length is 767 bytes
+CREATE TABLE t1 ( a varchar(10) ) CHARACTER SET utf8mb4 ENGINE InnoDB;
+INSERT INTO t1 VALUES ( 'test' );
+SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = b.a;
+a	a
+test	test
+SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = 'test' and b.a = 'test';
+a	a
+test	test
+SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = b.a and a.a = 'test';
+a	a
+test	test
+DROP TABLE t1;
+create table t1 (a char(255) character set utf8mb4) engine InnoDB;
+insert into t1 values('b'),('b');
+select * from t1 where a = 'b';
+a
+b
+b
+select * from t1 where a = 'b' and a = 'b';
+a
+b
+b
+select * from t1 where a = 'b' and a != 'b';
+a
+drop table t1;
+set collation_connection=utf8mb4_general_ci;
+drop table if exists t1;
+create table t1 as
+select repeat(' ', 64) as s1, repeat(' ',64) as s2
+union
+select null, null;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `s1` varchar(64) CHARACTER SET utf8mb4 DEFAULT NULL,
+  `s2` varchar(64) CHARACTER SET utf8mb4 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+delete from t1;
+insert into t1 values('aaa','aaa');
+insert into t1 values('aaa|qqq','qqq');
+insert into t1 values('gheis','^[^a-dXYZ]+$');
+insert into t1 values('aab','^aa?b');
+insert into t1 values('Baaan','^Ba*n');
+insert into t1 values('aaa','qqq|aaa');
+insert into t1 values('qqq','qqq|aaa');
+insert into t1 values('bbb','qqq|aaa');
+insert into t1 values('bbb','qqq');
+insert into t1 values('aaa','aba');
+insert into t1 values(null,'abc');
+insert into t1 values('def',null);
+insert into t1 values(null,null);
+insert into t1 values('ghi','ghi[');
+select HIGH_PRIORITY s1 regexp s2 from t1;
+s1 regexp s2
+1
+1
+1
+1
+1
+1
+1
+0
+0
+0
+NULL
+NULL
+NULL
+NULL
+drop table t1;
+set names utf8mb4;
+set names utf8mb4;
+select  'вася'  rlike '[[:<:]]вася[[:>:]]';
+'вася'  rlike '[[:<:]]в+1
+select ' вася'  rlike '[[:<:]]вася[[:>:]]';
+' вася'  rlike '[[:<:]]вася[[:>:]]'
+1
+select ' вася ' rlike '[[:<:]]вася[[:>:]]';
+' вася ' rlike '[[:<:]]вася[[:>:]]'
+1
+select  'васяz' rlike '[[:<:]]вася[[:>:]]';
+'васяz' rlike '[[:<:]]вася[[:>:]]'
+0
+select 'zвася'  rlike '[[:<:]]вася[[:>:]]';
+'zвася'  rlike '[[:<:]]вася[[:>:]]'
+0
+select 'zвасяz' rlike '[[:<:]]вася[[:>:]]';
+'zвасяz' rlike '[[:<:]]вася[[:>:]]'
+0
+CREATE TABLE t1 (a enum ('Y', 'N') DEFAULT 'N' COLLATE utf8mb4_unicode_ci) ENGINE InnoDB;
+ALTER TABLE t1 ADD COLUMN b CHAR(20);
+DROP TABLE t1;
+set names utf8mb4;
+create table t1 (a enum('aaaa','проба') character set utf8mb4) engine InnoDB;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` enum('aaaa','проба') CHARACTER SET utf8mb4 DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+insert into t1 values ('проба');
+select * from t1;
+a
+проба
+create table t2 engine InnoDB select ifnull(a,a) from t1;
+show create table t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `ifnull(a,a)` varchar(5) CHARACTER SET utf8mb4 DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+select * from t2;
+ifnull(a,a)
+проба
+drop table t1;
+drop table t2;
+create table t1 (c varchar(30) character set utf8mb4, unique(c(10))) engine InnoDB;
+insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z');
+insert into t1 values ('aaaaaaaaaa');
+insert into t1 values ('aaaaaaaaaaa');
+ERROR 23000: Duplicate entry 'aaaaaaaaaa' for key 'c'
+insert into t1 values ('aaaaaaaaaaaa');
+ERROR 23000: Duplicate entry 'aaaaaaaaaa' for key 'c'
+insert into t1 values (repeat('b',20));
+select c c1 from t1 where c='1';
+c1
+1
+select c c2 from t1 where c='2';
+c2
+2
+select c c3 from t1 where c='3';
+c3
+3
+select c cx from t1 where c='x';
+cx
+x
+select c cy from t1 where c='y';
+cy
+y
+select c cz from t1 where c='z';
+cz
+z
+select c ca10 from t1 where c='aaaaaaaaaa';
+ca10
+aaaaaaaaaa
+select c cb20 from t1 where c=repeat('b',20);
+cb20
+bbbbbbbbbbbbbbbbbbbb
+drop table t1;
+create table t1 (c varchar(30) character set utf8mb4, unique(c(10))) engine=InnoDB;
+insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z');
+insert into t1 values ('aaaaaaaaaa');
+insert into t1 values ('aaaaaaaaaaa');
+ERROR 23000: Duplicate entry 'aaaaaaaaaa' for key 'c'
+insert into t1 values ('aaaaaaaaaaaa');
+ERROR 23000: Duplicate entry 'aaaaaaaaaa' for key 'c'
+insert into t1 values (repeat('b',20));
+select c c1 from t1 where c='1';
+c1
+1
+select c c2 from t1 where c='2';
+c2
+2
+select c c3 from t1 where c='3';
+c3
+3
+select c cx from t1 where c='x';
+cx
+x
+select c cy from t1 where c='y';
+cy
+y
+select c cz from t1 where c='z';
+cz
+z
+select c ca10 from t1 where c='aaaaaaaaaa';
+ca10
+aaaaaaaaaa
+select c cb20 from t1 where c=repeat('b',20);
+cb20
+bbbbbbbbbbbbbbbbbbbb
+drop table t1;
+create table t1 (c char(3) character set utf8mb4, unique (c(2))) engine InnoDB;
+insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z');
+insert into t1 values ('a');
+insert into t1 values ('aa');
+insert into t1 values ('aaa');
+ERROR 23000: Duplicate entry 'aa' for key 'c'
+insert into t1 values ('b');
+insert into t1 values ('bb');
+insert into t1 values ('bbb');
+ERROR 23000: Duplicate entry 'bb' for key 'c'
+insert into t1 values ('а');
+insert into t1 values ('аа');
+insert into t1 values ('ааа');
+ERROR 23000: Duplicate entry 'аа' for key 'c'
+insert into t1 values ('б');
+insert into t1 values ('бб');
+insert into t1 values ('ббб');
+ERROR 23000: Duplicate entry 'into t1 values ('ꪪꪪ');
+insert into t1 values ('ꪪ'
+drop table t1;
+create table t1 (c char(3) character set utf8mb4, unique (c(2))) engine=InnoDB;
+insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z');
+insert into t1 values ('a');
+insert into t1 values ('aa');
+insert into t1 values ('aaa');
+ERROR 23000: Duplicate entry 'aa' for key 'c'
+insert into t1 values ('b');
+insert into t1 values ('bb');
+insert into t1 values ('bbb');
+ERROR 23000: Duplicate entry 'bb' for key 'c'
+insert into t1 values ('а');
+insert into t1 values ('аа');
+insert into t1 values ('ааа');
+ERROR 23000: Duplicate entry 'аа' for key 'c'
+insert into t1 values ('б');
+insert into t1 values ('бб');
+insert into t1 values ('ббб');
+ERROR 23000: Duplicate entry 'бб' for key 'c'
+insert into t1 values ('ꪪ');
+insert into t1 values ('ꪪꪪ');
+insert into t1 values ('ꪪꪪꪪ');
+ERROR 23000: Duplicate entry 'ꪪꪪ' for key 'c'
+drop table t1;
+create table t1 (
+c char(10) character set utf8mb4,
+unique key a using hash (c(1))
+) engine=InnoDB;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c` char(10) CHARACTER SET utf8mb4 DEFAULT NULL,
+  UNIQUE KEY `a` (`c`(1)) USING HASH
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
+insert into t1 values ('aa');
+ERROR 23000: Duplicate entry 'a' for key 'a'
+insert into t1 values ('aaa');
+ERROR 23000: Duplicate entry 'a' for key 'a'
+insert into t1 values ('б');
+insert into t1 values ('бб');
+ERROR 23000: Duplicate entry 'б' for key 'a'
+insert into t1 values ('ббб');
+ERROR 23000: Duplicate entry 'б' for key 'a'
+select c as c_all from t1 order by c;
+c_all
+a
+b
+c
+d
+e
+f
+б
+select c as c_a from t1 where c='a';
+c_a
+a
+select c as c_a from t1 where c='б';
+c_a
+б
+drop table t1;
+create table t1 (
+c char(10) character set utf8mb4,
+unique key a using btree (c(1))
+) engine=InnoDB;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c` char(10) CHARACTER SET utf8mb4 DEFAULT NULL,
+  UNIQUE KEY `a` (`c`(1)) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
+insert into t1 values ('aa');
+ERROR 23000: Duplicate entry 'a' for key 'a'
+insert into t1 values ('aaa');
+ERROR 23000: Duplicate entry 'a' for key 'a'
+insert into t1 values ('б');
+insert into t1 values ('бб');
+ERROR 23000: Duplicate entry 'б' for key 'a'
+insert into t1 values ('ббб');
+ERROR 23000: Duplicate entry 'б' for key 'a'
+select c as c_all from t1 order by c;
+c_all
+a
+b
+c
+d
+e
+f
+б
+select c as c_a from t1 where c='a';
+c_a
+a
+select c as c_a from t1 where c='б';
+c_a
+б
+drop table t1;
+create table t1 (
+c char(10) character set utf8mb4,
+unique key a (c(1))
+) engine=InnoDB;
+insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
+insert into t1 values ('aa');
+ERROR 23000: Duplicate entry 'a' for key 'a'
+insert into t1 values ('aaa');
+ERROR 23000: Duplicate entry 'a' for key 'a'
+insert into t1 values ('б');
+insert into t1 values ('бб');
+ERROR 23000: Duplicate entry 'б' for key 'a'
+insert into t1 values ('ббб');
+ERROR 23000: Duplicate entry 'б' for key 'a'
+select c as c_all from t1 order by c;
+c_all
+a
+b
+c
+d
+e
+f
+б
+select c as c_a from t1 where c='a';
+c_a
+a
+select c as c_a from t1 where c='б';
+c_a
+б
+drop table t1;
+create table t1 (c varchar(30) character set utf8mb4 collate utf8mb4_bin, unique(c(10))) engine InnoDB;
+insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z');
+insert into t1 values ('aaaaaaaaaa');
+insert into t1 values ('aaaaaaaaaaa');
+ERROR 23000: Duplicate entry 'aaaaaaaaaa' for key 'c'
+insert into t1 values ('aaaaaaaaaaaa');
+ERROR 23000: Duplicate entry 'aaaaaaaaaa' for key 'c'
+insert into t1 values (repeat('b',20));
+select c c1 from t1 where c='1';
+c1
+1
+select c c2 from t1 where c='2';
+c2
+2
+select c c3 from t1 where c='3';
+c3
+3
+select c cx from t1 where c='x';
+cx
+x
+select c cy from t1 where c='y';
+cy
+y
+select c cz from t1 where c='z';
+cz
+z
+select c ca10 from t1 where c='aaaaaaaaaa';
+ca10
+aaaaaaaaaa
+select c cb20 from t1 where c=repeat('b',20);
+cb20
+bbbbbbbbbbbbbbbbbbbb
+drop table t1;
+create table t1 (c char(3) character set utf8mb4 collate utf8mb4_bin, unique (c(2))) engine InnoDB;
+insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z');
+insert into t1 values ('a');
+insert into t1 values ('aa');
+insert into t1 values ('aaa');
+ERROR 23000: Duplicate entry 'aa' for key 'c'
+insert into t1 values ('b');
+insert into t1 values ('bb');
+insert into t1 values ('bbb');
+ERROR 23000: Duplicate entry 'bb' for key 'c'
+insert into t1 values ('а');
+insert into t1 values ('аа');
+insert into t1 values ('ааа');
+ERROR 23000: Duplicate entry 'аа' for key 'c'
+insert into t1 values ('б');
+insert into t1 values ('бб');
+insert into t1 values ('ббб');
+ERROR 23000: Duplicate entry 'бб' for key 'c'
+insert into t1 values ('ꪪ');
+insert into t1 values ('ꪪꪪ');
+insert into t1 values ('ꪪꪪꪪ');
+ERROR 23000: Duplicate entry 'ꪪꪪ' for key 'c'
+drop table t1;
+create table t1 (
+c char(10) character set utf8mb4 collate utf8mb4_bin,
+unique key a using hash (c(1))
+) engine=InnoDB;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
+  UNIQUE KEY `a` (`c`(1)) USING HASH
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
+insert into t1 values ('aa');
+ERROR 23000: Duplicate entry 'a' for key 'a'
+insert into t1 values ('aaa');
+ERROR 23000: Duplicate entry 'a' for key 'a'
+insert into t1 values ('б');
+insert into t1 values ('бб');
+ERROR 23000: Duplicate entry 'б' for key 'a'
+insert into t1 values ('бlect c as c_all from t1 order by c;
+c_all
+a
+b
+c
+d
+e
+f
+б
+select c as c_a from t1 where c='a';
+c_a
+a
+select c as c_a from t1 where c='б';
+c_a
+б
+drop table t1;
+create table t1 (
+c char(10) character set utf8mb4 collate utf8mb4_bin,
+unique key a using btree (c(1))
+) engine=InnoDB;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
+  UNIQUE KEY `a` (`c`(1)) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
+insert into t1 values ('aa');
+ERROR 23000: Duplicate entry 'a' for key 'a'
+insert into t1 values ('aaa');
+ERROR 23000: Duplicate entry 'a' for key 'a'
+insert into t1 values ('б');
+insert into t1 values ('бб');
+ERROR 23000: Duplicate entry 'б' for key 'a'
+insert into t1 values ('ббб');
+ERROR 23000: Duplicate entry 'б' for key 'a'
+select c as c_all from t1 order by c;
+c_all
+a
+b
+c
+d
+e
+f
+б
+select c as c_a from t1 where c='a';
+c_a
+a
+select c as c_a from t1 where c='б';
+c_a
+б
+drop table t1;
+create table t1 (
+c char(10) character set utf8mb4 collate utf8mb4_bin,
+unique key a (c(1))
+) engine=InnoDB;
+insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
+insert into t1 values ('aa');
+ERROR 23000: Duplicate entry 'a' for key 'a'
+insert into t1 values ('aaa');
+ERROR 23000: Duplicate entry 'a' for key 'a'
+insert into t1 values ('б');
+insert into t1 values ('бб');
+ERROR 23000: Duplicate entry 'б' for key 'a'
+insert into t1 values ('ббб');
+ERROR 23000: Duplicate entry 'б' for key 'a'
+select c as c_all from t1 order by c;
+c_all
+a
+b
+c
+d
+e
+f
+б
+select c as c_a from t1 where c='a';
+c_a
+a
+select c as c_a from t1 where c='б';
+c_a
+б
+drop table t1;
+create table t1 (
+str varchar(255) character set utf8mb4 not null,
+key str  (str(2))
+) engine=InnoDB;
+INSERT INTO t1 VALUES ('str');
+INSERT INTO t1 VALUES ('str2');
+select * from t1 where str='str';
+str
+str
+drop table t1;
+create table t1 (
+str varchar(255) character set utf8mb4 not null,
+key str  (str(2))
+) engine=InnoDB;
+INSERT INTO t1 VALUES ('str');
+INSERT INTO t1 VALUES ('str2');
+select * from t1 where str='str';
+str
+str
+drop table t1;
+create table t1 (
+str varchar(255) character set utf8mb4 not null,
+key str using btree (str(2))
+) engine=InnoDB;
+INSERT INTO t1 VALUES ('str');
+INSERT INTO t1 VALUES ('str2');
+select * from t1 where str='str';
+str
+str
+drop table t1;
+create table t1 (
+str varchar(255) character set utf8mb4 not null,
+key str using hash (str(2))
+) engine=InnoDB;
+INSERT INTO t1 VALUES ('str');
+INSERT INTO t1 VALUES ('str2');
+select * from t1 where str='str';
+str
+str
+drop table t1;
+create table t1 (
+str varchar(255) character set utf8mb4 not null,
+key str (str(2))
+) engine= InnoDB;
+INSERT INTO t1 VALUES ('str');
+INSERT INTO t1 VALUES ('str2');
+select * from t1 where str='str';
+str
+str
+drop table t1;
+CREATE TABLE t1 (a varchar(32) BINARY) CHARACTER SET utf8mb4 ENGINE InnoDB;
+INSERT INTO t1 VALUES ('test');
+SELECT a FROM t1 WHERE a LIKE '%te';
+a
+DROP TABLE t1;
+SET NAMES utf8mb4;
+CREATE TABLE t1 (
+subject varchar(255) character set utf8mb4 collate utf8mb4_unicode_ci,
+p varchar(15) character set utf8mb4
+) ENGINE= InnoDB DEFAULT CHARSET=latin1;
+INSERT INTO t1 VALUES ('谷川俊二と申しますが、インターネット予約の会員登録をしましたところ、メールアドレスを間違えてしまい会員IDが受け取ることが出来ませんでした。間違えアドレスはtani-shun@strippedを書き込みまし等は間違えありません。連絡ください。よろしくお願いします。m(__)m','040312-000057');
+INSERT INTO t1 VALUES ('aaa','bbb');
+SELECT length(subject) FROM t1;
+length(subject)
+3
+432
+SELECT length(subject) FROM t1 ORDER BY 1;
+length(subject)
+3
+432
+DROP TABLE t1;
+CREATE TABLE t1 (
+id       int unsigned NOT NULL auto_increment,
+list_id  smallint unsigned NOT NULL,
+term     TEXT NOT NULL,
+PRIMARY KEY(id),
+INDEX(list_id, term(4))
+) ENGINE=InnoDB CHARSET=utf8mb4;
+INSERT INTO t1 SET list_id = 1, term = "letterc";
+INSERT INTO t1 SET list_id = 1, term = "letterb";
+INSERT INTO t1 SET list_id = 1, term = "lettera";
+INSERT INTO t1 SET list_id = 1, term = "letterd";
+SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterc");
+id
+1
+SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterb");
+id
+2
+SELECT id FROM t1 WHERE (list_id = 1) AND (term = "lettera");
+id
+3
+SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterd");
+id
+4
+DROP TABLE t1;
+SET NAMES latin1;
+CREATE TABLE t1 (
+id int unsigned NOT NULL auto_increment,
+list_id smallint unsigned NOT NULL,
+term text NOT NULL,
+PRIMARY KEY(id),
+INDEX(list_id, term(19))
+) ENGINE=InnoDB CHARSET=utf8mb4;
+INSERT INTO t1 set list_id = 1, term = "test�st";
+INSERT INTO t1 set list_id = 1, term = "testetest";
+INSERT INTO t1 set list_id = 1, term = "test�st";
+SELECT id, term FROM t1 where (list_id = 1) AND (term = "test�st");
+id	term
+1	test�st
+2	testetest
+3	test�st
+SELECT id, term FROM t1 where (list_id = 1) AND (term = "testetest");
+id	term
+1	test�st
+2	testetest
+3	test�st
+SELECT id, term FROM t1 where (list_id = 1) AND (term = "test�st");
+id	term
+1	test�st
+2	testetest
+3	test�st
+DROP TABLE t1;
+set names utf8mb4;
+create table t1 (
+a int primary key,
+b varchar(6),
+index b3(b(3))
+) engine=InnoDB character set=utf8mb4;
+insert into t1 values(1,'foo'),(2,'foobar');
+select * from t1 where b like 'foob%';
+a	b
+2	foobar
+alter table t1 engine=innodb;
+select * from t1 where b like 'foob%';
+a	b
+2	foobar
+drop table t1;
+create table t1 (
+a enum('петя','вася','анюта') character set utf8mb4 not null default 'анюта',
+b set('петя','вася','анюта') character set utf8mb4 not null default 'анюта'
+) engine InnoDB;
+create table t2 engine InnoDB select concat(a,_utf8mb4'') as a, concat(b,_utf8mb4'')as b from t1;
+show create table t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `a` varchar(5) CHARACTER SET utf8mb4 NOT NULL DEFAULT '',
+  `b` varchar(15) CHARACTER SET utf8mb4 NOT NULL DEFAULT ''
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop table t2;
+drop table t1;
+select 'c' like '\_' as want0;
+want0
+0
+SELECT SUBSTR('вас integer, a varchar(100) character set utf8mb4 collate utf8mb4_unicode_ci) engine InnoDB;
+insert into t1 values (1, 'Test');
+select * from t1 where soundex(a) = soundex('Test');
+id	a
+1	Test
+select * from t1 where soundex(a) = soundex('TEST');
+id	a
+1	Test
+select * from t1 where soundex(a) = soundex('test');
+id	a
+1	Test
+drop table t1;
+select soundex(_utf8mb4 0xE99885E8A788E99A8FE697B6E69BB4E696B0E79A84E696B0E997BB);
+soundex(_utf8mb4 0xE99885E8A788E99A8FE697B6E69BB4E696B0E79A84E696B0E997BB)
+阅000
+select hex(soundex(_utf8mb4 0xE99885E8A788E99A8FE697B6E69BB4E696B0E79A84E696B0E997BB));
+hex(soundex(_utf8mb4 0xE99885E8A788E99A8FE697B6E69BB4E696B0E79A84E696B0E997BB))
+E99885303030
+select soundex(_utf8mb4 0xD091D092D093);
+soundex(_utf8mb4 0xD091D092D093)
+Б000
+select hex(soundex(_utf8mb4 0xD091D092D093));
+hex(soundex(_utf8mb4 0xD091D092D093))
+D091303030
+SET collation_connection='utf8mb4_general_ci';
+create table t1 select repeat('a',4000) a;
+delete from t1;
+insert into t1 values ('a'), ('a '), ('a\t');
+select collation(a),hex(a) from t1 order by a;
+collation(a)	hex(a)
+utf8mb4_general_ci	6109
+utf8mb4_general_ci	61
+utf8mb4_general_ci	6120
+drop table t1;
+select @@collation_connection;
+@@collation_connection
+utf8mb4_general_ci
+create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ;
+insert into t1 values('abcdef');
+insert into t1 values('_bcdef');
+insert into t1 values('a_cdef');
+insert into t1 values('ab_def');
+insert into t1 values('abc_ef');
+insert into t1 values('abcd_f');
+insert into t1 values('abcde_');
+select c1 as c1u from t1 where c1 like 'ab\_def';
+c1u
+ab_def
+select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
+c2h
+ab_def
+drop table t1;
+drop table if exists t1;
+create table t1 as select repeat(' ', 64) as s1;
+select collation(s1) from t1;
+collation(s1)
+utf8mb4_general_ci
+delete from t1;
+insert into t1 values ('a'),('ae'),(_latin1 0xE4);
+insert into t1 values ('o'),('oe'),(_latin1 0xF6);
+insert into t1 values ('s'),('ss'),(_latin1 0xDF);
+insert into t1 values ('u'),('ue'),(_latin1 0xFC);
+select s1, hex(s1) from t1 order by s1, binary s1;
+s1	hex(s1)
+a	61
+ä	C3A4
+ae	6165
+o	6F
+ö	C3B6
+oe	6F65
+s	73
+ß	C39F
+ss	7373
+u	75
+ü	C3BC
+ue	7565
+select group_concat(s1 order by binary s1) from t1 group by s1;
+group_concat(s1 order by binary s1)
+a,ä
+ae
+o,ö
+oe
+s,ß
+ss
+u,ü
+ue
+drop table t1;
+SET collation_connection='utf8mb4_bin';
+create table t1 select repeat('a',4000) a;
+delete from t1;
+insert into t1 values ('a'), ('a '), ('a\t');
+select collation(a),hex(a) from t1 order by a;
+collation(a)	hex(a)
+utf8mb4_bin	6109
+utf8mb4_bin	61
+utf8mb4_bin	6120
+drop table t1;
+select @@collation_connection;
+@@collation_connection
+utf8mb4_bin
+create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ;
+insert into t1 values('abcdef');
+insert into t1 values('_bcdef');
+insert into t1 values('a_cdef');
+insert into t1 values('ab_def');
+insert into t1 values('abc_ef');
+insert into t1 values('abcd_f');
+insert into t1 values('abcde_');
+select c1 as c1u from t1 where c1 like 'ab\_def';
+c1u
+ab_def
+select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
+c2h
+ab_def
+drop table t1;
+CREATE TABLE t1 (
+user varchar(255) NOT NULL default ''
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+INSERT INTO t1 VALUES ('one'),('two');
+SELECT CHARSET('a');
+CHARSET('a')
+utf8mb4
+SELECT user, CONCAT('<', user, '>') AS c FROM t1;
+user	c
+one	<one>
+two	<two>
+DROP TABLE t1;
+create table t1 (f1 varchar(1) not null) default charset utf8mb4 engine InnoDB;
+insert into t1 values (''), ('');
+select concat(concat(_latin1'->',f1),_latin1'<-') from t1;
+concat(concat(_latin1'->',f1),_latin1'<-')
+-><-
+-><-
+drop table t1;
+select convert(_koi8r'� using utf8mb4) < convert(_koi8r'� using utf8mb4);
+convert(_koi8r'?' using utf8mb4) < convert(_koi8r'?' using utf8mb4)
+1
+set names latin1;
+create table t1 (a varchar(10)) character set utf8mb4 engine InnoDB;
+insert into t1 values ('test');
+select ifnull(a,'') from t1;
+ifnull(a,'')
+test
+drop table t1;
+select repeat(_utf8mb4'+',3) as h union select NULL;
+h
++++
+NULL
+select ifnull(NULL, _utf8mb4'string');
+ifnull(NULL, _utf8mb4'string')
+string
+set names utf8mb4;
+create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_lithuanian_ci) engine InnoDB;
+insert into t1 values ('I'),('K'),('Y');
+select * from t1 where s1 < 'K' and s1 = 'Y';
+s1
+I
+Y
+select * from t1 where 'K' > s1 and s1 = 'Y';
+s1
+I
+Y
+drop table t1;
+create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_czech_ci) engine InnoDB;
+insert into t1 values ('c'),('d'),('h'),('ch'),('CH'),('cH'),('Ch'),('i');
+select * from t1 where s1 > 'd' and s1 = 'CH';
+s1
+CH
+Ch
+ch
+select * from t1 where 'd' < s1 and s1 = 'CH';
+s1
+CH
+Ch
+ch
+select * from t1 where s1 = 'cH' and s1 <> 'ch';
+s1
+cH
+select * from t1 where 'cH' = s1 and s1 <> 'ch';
+s1
+cH
+drop table t1;
+create table t1 (a varchar(255)) default character set utf8mb4 engine InnoDB;
+insert into t1 values (1.0);
+drop table t1;
+create table t1 (
+id int not null,
+city varchar(20) not null,
+key (city(7),id)
+) character set=utf8mb4 engine InnoDB;
+insert into t1 values (1,'Durban North');
+insert into t1 values (2,'Durban');
+select * from t1 where city = 'Durban';
+id	city
+2	Durban
+select * from t1 where city = 'Durban ';
+id	city
+2	Durban
+drop table t1;
+create table t1 (x set('A', 'B') default 0) character set utf8mb4 engine InnoDB;
+ERROR 42000: Invalid default value for 'x'
+create table t1 (x enum('A', 'B') default 0) character set utf8mb4 engine InnoDB;
+ERROR 42000: Invalid default value for 'x'
+SET NAMES UTF8;
+CREATE TABLE t1 (
+`id` int(20) NOT NULL auto_increment,
+`country` varchar(100) NOT NULL default '',
+`shortcode` varchar(100) NOT NULL default '',
+`operator` varchar(100) NOT NULL default '',
+`momid` varchar(30) NOT NULL default '',
+`keyword` varchar(160) NOT NULL default '',
+`content` varchar(160) NOT NULL default '',
+`second_token` varchar(160) default NULL,
+`gateway_id` int(11) NOT NULL default '0',
+`created` datetime NOT NULL default '0000-00-00 00:00:00',
+`msisdn` varchar(15) NOT NULL default '',
+PRIMARY KEY  (`id`),
+UNIQUE KEY `MSCCSPK_20030521130957121` (`momid`),
+KEY `IX_mobile_originated_message_keyword` (`keyword`),
+KEY `IX_mobile_originated_message_created` (`created`),
+KEY `IX_mobile_originated_message_support` (`msisdn`,`momid`,`keyword`,`gateway_id`,`created`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+INSERT INTO t1 VALUES 
+(1,'blah','464','aaa','fkc1c9ilc20x0hgae7lx6j09','ERR','ERR Имри.Афимим.Аеимимримдмримрмрирор имримримримр имридм ирбднримрфмририримрфмфмим.Ад.мримримр м.Дадимфшьмримд им.АдИМРИМДМРИМРМРИРОР',3,'2005-06-01 17:30:43','1234567890'),
+(2,'blah','464','aaa','haxpl2ilc20x00bj4tt2m5ti','11','11 g','G',3,'2005-06-02 22:43:10','1234567890');
+CREATE TABLE t2 (
+`msisdn` varchar(15) NOT NULL default '',
+`operator_id` int(11) NOT NULL default '0',
+`created` datetime NOT NULL default '0000-00-00 00:00:00',
+UNIQUE KEY `PK_user` (`msisdn`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+INSERT INTO t2 VALUES ('1234567890',2,'2005-05-24 13:53:25');
+SELECT content, t2.msisdn FROM t1, t2 WHERE t1.msisdn = '1234567890';
+content	msisdn
+ERR Имри.Афимим.Аеимимримдмримрмрирор имримримримр имридм ирбднримрфмририримрфмфмим.Ад.Д имдимримрад.Адимримримрмдиримримримр м.Дадимфшьмримд им.АдимBLE t1,t2;
+create table t1 (a char(20) character set utf8mb4) engine InnoDB;
+insert into t1 values ('123456'),('андрей');
+alter table t1 modify a char(2) character set utf8mb4;
+Warnings:
+Warning	1265	Data truncated for column 'a' at row 1
+Warning	1265	Data truncated for column 'a' at row 2
+select char_length(a), length(a), a from t1 order by a;
+char_length(a)	length(a)	a
+2	2	12
+2	4	ан
+drop table t1;
+set names utf8mb4;
+select 'andre%' like 'andreñ%' escape 'ñ';
+'andre%' like 'andreñ%' escape 'ñ'
+1
+set names utf8mb4;
+select 'a\\' like 'a\\';
+'a\\' like 'a\\'
+1
+select 'aa\\' like 'a%\\';
+'aa\\' like 'a%\\'
+1
+create table t1 (a char(10), key(a)) character set utf8mb4 engine InnoDB;
+insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test");
+select * from t1 where a like "abc%";
+a
+abc
+abcd
+select * from t1 where a like concat("abc","%");
+a
+abc
+abcd
+select * from t1 where a like "ABC%";
+a
+abc
+abcd
+select * from t1 where a like "test%";
+a
+test
+select * from t1 where a like "te_t";
+a
+test
+select * from t1 where a like "%a%";
+a
+a
+abc
+abcd
+select * from t1 where a like "%abcd%";
+a
+abcd
+select * from t1 where a like "%abc\d%";
+a
+abcd
+drop table t1;
+CREATE TABLE t1 (
+a varchar(255) NOT NULL default '',
+KEY a (a)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;
+Warnings:
+Warning	1071	Specified key was too long; max key length is 767 bytes
+insert into t1 values (_utf8mb4 0xe880bd);
+insert into t1 values (_utf8mb4 0x5b);
+select hex(a) from t1;
+hex(a)
+5B
+E880BD
+drop table t1;
+set names 'latin1';
+create table t1 (a varchar(255)) default charset=utf8mb4 engine InnoDB;
+select * from t1 where find_in_set('-1', a);
+a
+drop table t1;
+create table t1 (a int) engine InnoDB;
+insert into t1 values (48),(49),(50);
+set names utf8mb4;
+select distinct char(a) from t1;
+char(a)
+0
+1
+2
+drop table t1;
+CREATE TABLE t1 (t TINYTEXT CHARACTER SET utf8mb4) ENGINE InnoDB;
+INSERT INTO t1 VALUES(REPEAT('a', 100));
+CREATE TEMPORARY TABLE t2 ENGINE InnoDB SELECT COALESCE(t) AS bug FROM t1;
+SELECT LENGTH(bug) FROM t2;
+LENGTH(bug)
+100
+DROP TABLE t2;
+DROP TABLE t1;
+CREATE TABLE t1 (item varchar(255)) default character set utf8mb4 ENGINE InnoDB;
+INSERT INTO t1 VALUES (N'\\');
+INSERT INTO t1 VALUES (_utf8mb4'\\');
+INSERT INTO t1 VALUES (N'Cote d\'Ivoire');
+INSERT INTO t1 VALUES (_utf8mb4'Cote d\'Ivoire');
+SELECT item FROM t1 ORDER BY item;
+item
+Cote d'Ivoire
+Cote d'Ivoire
+\
+\
+DROP TABLE t1;
+SET NAMES utf8mb4;
+DROP TABLE IF EXISTS t1;
+Warnings:
+Note	1051	Unknown table 't1'
+CREATE TABLE t1(a VARCHAR(255), KEY(a)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+Warnings:
+Warning	1071	Specified key was too long; max key length is 767 bytes
+INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb');
+INSERT INTO t1 VALUES('uu');
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	status	OK
+INSERT INTO t1 VALUES('uU');
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	status	OK
+INSERT INTO t1 VALUES('uu');
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	status	OK
+INSERT INTO t1 VALUES('uuABC');
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	status	OK
+INSERT INTO t1 VALUES('UuABC');
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	status	OK
+INSERT INTO t1 VALUES('uuABC');
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	status	OK
+alter table t1 add b int;
+INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',1);
+INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',2);
+delete from t1 where b=1;
+INSERT INTO t1 VALUES('UUABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',1);
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	status	OK
+INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',3);
+INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',4);
+delete from t1 where b=3;
+INSERT INTO t1 VALUES('uUABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',3);
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	status	OK
+drop table t1;
+set names utf8mb4;
+create table t1 (s1 char(5) character set utf8mb4) engine InnoDB;
+insert into t1 values
+('a'),('b'),(null),('ペテルt s1 as before_delete_general_ci from t1 where s1 like 'te from t1 where s1 = 'Y';
+select s1 as after_delete_general_ci from t1 where s1 like 'ペテ%';
+after_delete_general_ci
+ペテルグル
+drop table t1;
+set names utf8mb4;
+create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_unicode_ci) engine InnoDB;
+insert into t1 values
+('a'),('b'),(null),('ペテルグル'),('ü'),('Y');
+create index it1 on t1 (s1);
+select s1 as before_delete_unicode_ci from t1 where s1 like 'ペテ%';
+before_delete_unicode_ci
+ペテルグル
+delete from t1 where s1 = 'Y';
+select s1 as after_delete_unicode_ci from t1 where s1 like 'ペテ%';
+after_delete_unicode_ci
+ペテルグル
+drop table t1;
+set names utf8mb4;
+create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_bin) engine InnoDB;
+insert into t1 values
+('a'),('b'),(null),('ペテルグル'),('ü'),('Y');
+create index it1 on t1 (s1);
+select s1 as before_delete_bin from t1 where s1 like 'ペテ%';
+before_delete_bin
+ペテルグル
+delete from t1 where s1 = 'Y';
+select s1 as after_delete_bin from t1 where s1 like 'ペテ%';
+after_delete_bin
+ペテルグル
+drop table t1;
+set names utf8mb4;
+create table t1 (a varchar(30) not null primary key)
+engine=InnoDB default character set utf8mb4 collate utf8mb4_general_ci;
+insert into t1 values ('あいうえおかきくけこさしすせそ');
+insert into t1 values ('さしi1 from t1 where a like 'さしすせそかきくけこいうえお
+select a as gci2 from t1 where a like 'あうえおかきくけこさしすせそ
+drop table t1;
+set names utf8mb4;
+create table t1 (a varchar(30) not null primary key)
+engine=InnoDB default character set utf8mb4 collate utf8mb4_unicode_ci;
+insert into t1 values ('あいうえおかきくけこさしすせそ');
+insert into t1 values ('さしすせそかきくけこあいうせそかきくけこあいうえお
+select a as uci2 from t1 where a like 'あいうえおかきくけこさしせそ
+drop table t1;
+set names utf8mb4;
+create table t1 (a varchar(30) not null primary key)
+engine=InnoDB default character set utf8mb4 collate utf8mb4_bin;
+insert into t1 values ('あいうえおかきくけこさしす a like 'さしすせそかきくけこあいうえお%';
+bin1
+さしすせそかきくけこあいうえお
+select a as bin2 from t1 where a like 'あいうえおか4;
+CREATE TABLE t1 (id int PRIMARY KEY,
+a varchar(16) collate utf8mb4_unicode_ci NOT NULL default '',
+b int,
+f varchar(128) default 'XXX',
+INDEX (a(4))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+INSERT INTO t1(id, a, b) VALUES
+(1, 'cccc', 50), (2, 'cccc', 70), (3, 'cccc', 30),
+(4, 'cccc', 30), (5, 'cccc', 20), (6, 'bbbbbb', 40),
+(7, 'dddd', 30), (8, 'aaaa', 10), (9, 'aaaa', 50),
+(10, 'eeeee', 40), (11, 'bbbbbb', 60);
+SELECT id, a, b FROM t1;
+id	a	b
+1	cccc	50
+10	eeeee	40
+11	bbbbbb	60
+2	cccc	70
+3	cccc	30
+4	cccc	30
+5	cccc	20
+6	bbbbbb	40
+7	dddd	30
+8	aaaa	10
+9	aaaa	50
+SELECT id, a, b FROM t1 WHERE a BETWEEN 'aaaa' AND 'bbbbbb';
+id	a	b
+11	bbbbbb	60
+6	bbbbbb	40
+8	aaaa	10
+9	aaaa	50
+SELECT id, a FROM t1 WHERE a='bbbbbb';
+id	a
+11	bbbbbb
+6	bbbbbb
+SELECT id, a FROM t1 WHERE a='bbbbbb' ORDER BY b;
+id	a
+6	bbbbbb
+11	bbbbbb
+DROP TABLE t1;
+SET NAMES utf8mb4;
+CREATE TABLE t1 (
+a CHAR(13) DEFAULT '',
+INDEX(a)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+INSERT INTO t1 VALUES 
+('Käli Käli 2-4'), ('Käli Käli 2-4'),
+('Käli Käli 2+4'), ('Käli KSERT INTO t1 SELECT * FROM t1;
+CREATE TABLE t2 (
+a CHAR(13) DEFAULT '',
+INDEX(a)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
+INSERT INTO t2 VALUES
+('Kali Kali 2-4'), ('Kali Kali 2-4'),
+('Kali Kali 2+4'), ('Kali Kali 2+4'),
+('Kali Kali 2-6'), ('Kali Kali 2-6');
+INSERT INTO t2 SELECT * FROM t2;
+SELECT a FROM t1 WHERE a LIKE 'Käli Käli 2+4';
+a
+Käli Käli 2+4
+Käli Käli 2+4
+Käli Käli 2+4
+Käli Käli 2+4
+SELECT a FROM t2 WHERE a LIKE 'Kali Kali 2+4';
+a
+Kali Kali 2+4
+Kali Kali 2+4
+Kali Kali 2+4
+Kali Kali 2+4
+EXPLAIN SELECT a FROM t1 WHERE a LIKE 'Käli Käli 2+4';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	a	a	53	NULL	4	Using where; Using index
+EXPLAIN SELECT a FROM t1 WHERE a = 'Käli Käli 2+4';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ref	a	a	53	const	4	Using where; Using index
+EXPLAIN SELECT a FROM t2 WHERE a LIKE 'Kali Kali 2+4';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t2	range	a	a	14	NULL	4	Using where; Using index
+EXPLAIN SELECT a FROM t2 WHERE a = 'Kali Kali 2+4';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t2	ref	a	a	14	const	4	Using where; Using index
+DROP TABLE t1,t2;
+CREATE TABLE t1 (
+a char(255) DEFAULT '', 
+KEY(a(10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+INSERT INTO t1 VALUES ('Käli Käli 2-4');
+SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%';
+a
+Käli Käli 2-4
+INSERT INTO t1 VALUES ('Käli Käli 2-4');
+SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%';
+a
+Käli Käli 2-4
+Käli Käli 2-4
+DROP TABLE t1;
+CREATE TABLE t1 (
+a char(255) DEFAULT ''
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+INSERT INTO t1 VALUES ('K');
+SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%';
+a
+Käli Käli 2-4
+Käli Käli 2-4
+ALTER TABLE t1 ADD KEY (a(10));
+SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%';
+a
+Käli Käli 2-4
+Käli Käli 2-4
+DROP TABLE t1;
+SET NAMES latin2;
+CREATE TABLE t1 (
+id int(11) NOT NULL default '0',
+tid int(11) NOT NULL default '0',
+val text NOT NULL,
+INDEX idx(tid, val(10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+INSERT INTO t1 VALUES
+(40988,72,'VOLN�ADSL'),(41009,72,'VOLN�ADSL'),
+(41032,72,'VOLN�ADSL'),(41038,72,'VOLN�ADSL'),
+(41063,72,'VOLN�ADSL'),(41537,72,'VOLN�ADSL Office'),
+(42141,72,'VOLN�ADSL'),(42565,72,'VOLN�ADSL Combi'),
+(42749,72,'VOLN�ADSL'),(44205,72,'VOLN�ADSL');
+SELECT * FROM t1 WHERE tid=72 and val LIKE 'VOLNY ADSL';
+id	tid	val
+40988	72	VOLN�ADSL
+41009	72	VOLN�ADSL
+41032	72	VOLN�ADSL
+41038	72	VOLN�ADSL
+41063	72	VOLN�ADSL
+42141	72	VOLN�ADSL
+42749	72	VOLN�ADSL
+44205	72	VOLN�ADSL
+SELECT * FROM t1 WHERE tid=72 and val LIKE 'VOLN�ADSL';
+id	tid	val
+40988	72	VOLN�ADSL
+41009	72	VOLN�ADSL
+41032	72	VOLN�ADSL
+41038	72	VOLN�ADSL
+41063	72	VOLN�ADSL
+42141	72	VOLN�ADSL
+42749	72	VOLN�ADSL
+44205	72	VOLN�ADSL
+SELECT * FROM t1 WHERE tid=72 and val LIKE '%VOLN�ADSL';
+id	tid	val
+40988	72	VOLN�ADSL
+41009	72	VOLN�ADSL
+41032	72	VOLN�ADSL
+41038	72	VOLN�ADSL
+41063	72	VOLN�ADSL
+42141	72	VOLN�ADSL
+42749	72	VOLN�ADSL
+44205	72	VOLN�ADSL
+ALTER TABLE t1 DROP KEY idx;
+ALTER TABLE t1 ADD KEY idx (tid,val(11));
+SELECT * FROM t1 WHERE tid=72 and val LIKE 'VOLN�ADSL';
+id	tid	val
+40988	72	VOLN�ADSL
+41009	72	VOLN�ADSL
+41032	72	VOLN�ADSL
+41038	72	VOLN�ADSL
+41063	72	VOLN�ADSL
+42141	72	VOLN�ADSL
+42749	72	VOLN�ADSL
+44205	72	VOLN�ADSL
+DROP TABLE t1;
+create table t1(a char(200) collate utf8mb4_unicode_ci NOT NULL default '')
+default charset=utf8mb4 collate=utf8mb4_unicode_ci engine InnoDB;
+insert into t1 values (unhex('65')), (unhex('C3A9')), (unhex('65'));
+explain select distinct a from t1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	Using temporary
+SELECT COUNT(*) FROM (SELECT DISTINCT a FROM t1) AS t2;
+COUNT(*)
+1
+explain select a from t1 group by a;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	Using temporary; Using filesort
+SELECT COUNT(*) FROM (SELECT a FROM t1 GROUP BY a) AS t2;
+COUNT(*)
+1
+drop table t1;
+create table t1(a char(10)) default charset utf8mb4 engine InnoDB;
+insert into t1 values ('123'), ('456');
+explain
+select substr(Z.a,-1), Z.a from t1 as Y join t1 as Z on Y.a=Z.a order by 1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	Y	ALL	NULL	NULL	NULL	NULL	2	Using temporary; Using filesort
+1	SIMPLE	Z	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer
+select substr(Z.a,-1), Z.a from t1 as Y join t1 as Z on Y.a=Z.a order by 1;
+substr(Z.a,-1)	a
+3	123
+6	456
+drop table t1;
+SET CHARACTER SET utf8mb4;
+SHOW VARIABLES LIKE 'character\_set\_%';
+Variable_name	Value
+character_set_client	utf8mb4
+character_set_connection	latin1
+character_set_database	latin1
+character_set_filesystem	binary
+character_set_results	utf8mb4
+character_set_server	latin1
+character_set_system	utf8
+CREATE DATABASE crashtest DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
+USE crashtest;
+CREATE TABLE crashtest (crash char(10)) DEFAULT CHARSET=utf8mb4 ENGINE InnoDB;
+INSERT INTO crashtest VALUES ('35'), ('36'), ('37');
+SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8mb4);
+crash
+35
+36
+37
+INSERT INTO crashtest VALUES ('-1000');
+EXPLAIN SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8mb4);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	crashtest	ALL	NULL	NULL	NULL	NULL	4	Using filesort
+SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8mb4);
+crash
+-1000
+35
+36
+37
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FFFFFC'
+DROP TABLE crashtest;
+DROP DATABASE crashtest;
+USE test;
+SET CHARACTER SET default;
+CREATE TABLE t1(id varchar(20) NOT NULL) DEFAULT CHARSET=utf8mb4 ENGINE InnoDB;
+INSERT INTO t1 VALUES ('xxx'), ('aa'), ('yyy'), ('aa');
+SELECT id FROM t1;
+id
+aa
+aa
+xxx
+yyy
+SELECT DISTINCT id FROM t1;
+id
+aa
+xxx
+yyy
+SELECT DISTINCT id FROM t1 ORDER BY id;
+id
+aa
+xxx
+yyy
+DROP TABLE t1;
+create table t1 (
+a varchar(26) not null
+) default character set utf8mb4 ENGINE InnoDB;
+insert into t1 (a) values ('abcdefghijklmnopqrstuvwxyz');
+select * from t1;
+a
+abcdefghijklmnopqrstuvwxyz
+alter table t1 change a a varchar(20) character set utf8mb4 not null;
+Warnings:
+Warning	1265	Data truncated for column 'a' at row 1
+select * from t1;
+a
+abcdefghijklmnopqrst
+alter table t1 change a a char(15) character set utf8mb4 not null;
+Warnings:
+Warning	1265	Data truncated for column 'a' at row 1
+select * from t1;
+a
+abcdefghijklmno
+alter table t1 change a a char(10) character set utf8mb4 not null;
+Warnings:
+Warning	1265	Data truncated for column 'a' at row 1
+select * from t1;
+a
+abcdefghij
+alter table t1 change a a varchar(5) character set utf8mb4 not null;
+Warnings:
+Warning	1265	Data truncated for column 'a' at row 1
+select * from t1;
+a
+abcde
+drop table t1;
+create table t1 (
+a varchar(4000) not null
+) default character set utf8mb4 engine InnoDB;
+insert into t1 values (repeat('a',4000));
+alter table t1 change a a varchar(3000) character set utf8mb4 not null;
+Warnings:
+Warning	1265	Data truncated for column 'a' at row 1
+select length(a) from t1;
+length(a)
+3000
+drop table t1;
+set names utf8mb4;
+select hex(char(1 using utf8mb4));
+hex(char(1 using utf8mb4))
+01
+select char(0xd1,0x8f using utf8mb4);
+char(0xd1,0x8f using utf8mb4)
+я
+select char(0xd18f using utf8mb4);
+char(0xd18f using utf8mb4)
+я
+select char(53647 using utf8mb4);
+char(53647 using utf8mb4)
+я
+select char(0xff,0x8f using utf8mb4);
+char(0xff,0x8f using utf8mb4)
+
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FF8F'
+select convert(char(0xff,0x8f) using utf8mb4);
+convert(char(0xff,0x8f) using utf8mb4)
+
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FF8F'
+set sql_mode=traditional;
+select char(0xff,0x8f using utf8mb4);
+char(0xff,0x8f using utf8mb4)
+NULL
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FF8F'
+select char(195 using utf8mb4);
+char(195 using utf8mb4)
+NULL
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'C3'
+select char(196 using utf8mb4);
+char(196 using utf8mb4)
+NULL
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'C4'
+select char(2557 using utf8mb4);
+char(2557 using utf8mb4)
+NULL
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FD'
+select convert(char(0xff,0x8f) using utf8mb4);
+convert(char(0xff,0x8f) using utf8mb4)
+NULL
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FF8F'
+select hex(convert(char(2557 using latin1) using utf8mb4));
+hex(convert(char(2557 using latin1) using utf8mb4))
+09C3BD
+select hex(char(195));
+hex(char(195))
+C3
+select hex(char(196));
+hex(char(196))
+C4
+select hex(char(2557));
+hex(char(2557))
+09FD
+set names utf8mb4;
+create table t1 (a char(1)) default character set utf8mb4 engine InnoDB;
+create table t2 (a char(1)) default character set utf8mb4 engine InnoDB;
+insert into t1 values('a'),('a'),(0xE38182),(0xE38182);
+insert into t1 values('i'),('i'),(0xE38184),(0xE38184);
+select * from t1 union distinct select * from t2;
+a
+a
+i
+あ
+い
+drop table t1,t2;
+set names utf8mb4;
+create table t1 (a char(10), b varchar(10)) engine InnoDB;
+insert into t1 values ('bar','kostja');
+insert into t1 values ('kostja','bar');
+prepare my_stmt from "select * from t1 where a=?";
+set @a:='bar';
+execute my_stmt using @a;
+a	b
+bar	kostja
+set @a:='kostja';
+execute my_stmt using @a;
+a	b
+kostja	bar
+set @a:=null;
+execute my_stmt using @a;
+a	b
+drop table if exists t1;
+drop table if exists t1;
+drop view if exists v1, v2;
+set names utf8mb4;
+create table t1(col1 varchar(12) character set utf8mb4 collate utf8mb4_unicode_ci) engine InnoDB;
+insert into t1 values('t1_val');
+create view v1 as select 'v1_val' as col1;
+select coercibility(col1), collation(col1) from v1;
+coercibility(col1)	collation(col1)
+4	utf8mb4_general_ci
+create view v2 as select col1 from v1 union select col1 from t1;
+select coercibility(col1), collation(col1)from v2;
+coercibility(col1)	collation(col1)
+2	utf8mb4_unicode_ci
+2	utf8mb4_unicode_ci
+drop view v1, v2;
+create view v1 as select 'v1_val' collate utf8mb4_swedish_ci as col1;
+select coercibility(col1), collation(col1) from v1;
+coercibility(col1)	collation(col1)
+0	utf8mb4_swedish_ci
+create view v2 as select col1 from v1 union select col1 from t1;
+select coercibility(col1), collation(col1) from v2;
+coercibility(col1)	collation(col1)
+0	utf8mb4_swedish_ci
+0	utf8mb4_swedish_ci
+drop view v1, v2;
+drop table t1;
+set names utf8mb4;
+create table t1 (a varchar(10) character set latin1, b int) engine InnoDB;
+insert into t1 values ('a',1);
+select concat(a, if(b>10, N'x', N'y')) from t1;
+concat(a, if(b>10, N'x', N'y'))
+ay
+select concat(a, if(b>10, N'æ', N'ß')) from t1;
+ERROR HY000: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation 'concat'
+drop table t1;
+set names utf8mb4;
+create table t1 (a varchar(10) character set latin1, b int) engine InnoDB;
+insert into t1 values ('a',1);
+select concat(a, if(b>10, _utf8mb4'x', _utf8mb4'y')) from t1;
+concat(a, if(b>10, _utf8mb4'x', _utf8mb4'y'))
+ay
+select concat(a, if(b>10, _utf8mb4'æ', _utf8mb4'tin1_swedish_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation 'concat'
+drop table t1;
+set names utf8mb4;
+create table t1 (a varchar(10) character set latin1, b int) engine InnoDB;
+insert into t1 values ('a',1);
+select concat(a, if(b>10, _utf8mb4 0x78, _utf8mb4 0x79)) from t1;
+concat(a, if(b>10, _utf8mb4 0x78, _utf8mb4 0x79))
+ay
+select concat(a, if(b>10, _utf8mb4 0xC3A6, _utf8mb4 0xC3AF)) from t1;
+ERROR HY000: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation 'concat'
+drop table t1;
+set names utf8mb4;
+create table t1 (a varchar(10) character set latin1, b int) engine InnoDB;
+insert into t1 values ('a',1);
+select concat(a, if(b>10, 'x' 'x', 'y' 'y')) from t1;
+concat(a, if(b>10, 'x' 'x', 'y' 'y'))
+ayy
+select concat(a, if(b>10, 'x' 'æ', 'y' 'ß')) from t1;
+ERROR HY000: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation 'concat'
+drop table t1;
+CREATE TABLE t1 (
+colA int(11) NOT NULL,
+colB varchar(255) character set utf8mb4 NOT NULL,
+PRIMARY KEY  (colA)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+INSERT INTO t1 (colA, colB) VALUES (1, 'foo'), (2, 'foo bar');
+CREATE TABLE t2 (
+colA int(11) NOT NULL,
+colB varchar(255) character set utf8mb4 NOT NULL,
+KEY bad  (colA,colB(3))
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+INSERT INTO t2 (colA, colB) VALUES (1, 'foo'),(2, 'foo bar');
+SELECT * FROM t1 JOIN t2 ON t1.colA=t2.colA AND t1.colB=t2.colB
+WHERE t1.colA < 3;
+colA	colB	colA	colB
+1	foo	1	foo
+2	foo bar	2	foo bar
+DROP TABLE t1, t2;
+SELECT 'н1234567890' UNION SELECT _binary '1';
+н1234567890
+н1234567890
+1
+SELECT 'н1234567890' UNION SELECT 1;
+н1234567890
+н1234567890
+1
+SELECT '1' UNION SELECT 'н1234567890';
+1
+1
+н1234567890
+SELECT 1 UNION SELECT 'н1234567890';
+1
+1
+н1234567890
+CREATE TABLE t1 (c VARCHAR(11)) CHARACTER SET utf8mb4 ENGINE InnoDB;
+CREATE TABLE t2 (b CHAR(1) CHARACTER SET binary, i INT) ENGINE InnoDB;
+INSERT INTO t1 (c) VALUES ('н1234567890');
+INSERT INTO t2 (b, i) VALUES ('1', 1);
+SELECT c FROM t1 UNION SELECT b FROM t2;
+c
+н1234567890
+1
+SELECT c FROM t1 UNION SELECT i FROM t2;
+c
+н1234567890
+1
+SELECT b FROM t2 UNION SELECT c FROM t1;
+b
+1
+н1234567890
+SELECT i FROM t2 UNION SELECT c FROM t1;
+i
+1
+н1234567890
+DROP TABLE t1, t2;
+set sql_mode=traditional;
+select hex(char(0xFF using utf8mb4));
+hex(char(0xFF using utf8mb4))
+NULL
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FF'
+select hex(convert(0xFF using utf8mb4));
+hex(convert(0xFF using utf8mb4))
+NULL
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FF'
+select hex(_utf8mb4 0x616263FF);
+ERROR HY000: Invalid utf8mb4 character string: 'FF'
+select hex(_utf8mb4 X'616263FF');
+ERROR HY000: Invalid utf8mb4 character string: 'FF'
+select hex(_utf8mb4 B'001111111111');
+ERROR HY000: Invalid utf8mb4 character string: 'FF'
+select (_utf8mb4 X'616263FF');
+ERROR HY000: Invalid utf8mb4 character string: 'FF'
+set sql_mode=default;
+select hex(char(0xFF using utf8mb4));
+hex(char(0xFF using utf8mb4))
+
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FF'
+select hex(convert(0xFF using utf8mb4));
+hex(convert(0xFF using utf8mb4))
+
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FF'
+select hex(_utf8mb4 0x616263FF);
+ERROR HY000: Invalid utf8mb4 character string: 'FF'
+select hex(_utf8mb4 X'616263FF');
+ERROR HY000: Invalid utf8mb4 character string: 'FF'
+select hex(_utf8mb4 B'001111111111');
+ERROR HY000: Invalid utf8mb4 character string: 'FF'
+select (_utf8mb4 X'616263FF');
+ERROR HY000: Invalid utf8mb4 character string: 'FF'
+CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL) ENGINE InnoDB;
+INSERT INTO t1 VALUES (70000, 1092), (70001, 1085), (70002, 1065);
+SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b;
+CONVERT(a, CHAR)	CONVERT(b, CHAR)
+70000	1092
+70001	1085
+70002	1065
+SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1;
+CONVERT(a, CHAR)	CONVERT(b, CHAR)
+70000	1092
+70001	1085
+70002	1065
+ALTER TABLE t1 ADD UNIQUE (b);
+SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b;
+CONVERT(a, CHAR)	CONVERT(b, CHAR)
+70000	1092
+70001	1085
+70002	1065
+DROP INDEX b ON t1;
+SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b;
+CONVERT(a, CHAR)	CONVERT(b, CHAR)
+70000	1092
+70001	1085
+70002	1065
+ALTER TABLE t1 ADD INDEX (b);
+SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) from t1 GROUP BY b;
+CONVERT(a, CHAR)	CONVERT(b, CHAR)
+70000	1092
+70001	1085
+70002	1065
+DROP TABLE t1;
+#
+# Bug#26474: Add Sinhala script (Sri Lanka) collation to MySQL
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+predicted_order int NOT NULL,
+utf8mb4_encoding VARCHAR(10) NOT NULL
+) CHARACTER SET utf8mb4 ENGINE InnoDB;
+INSERT INTO t1 VALUES (19, x'E0B696'), (30, x'E0B69AE0B798'), (61, x'E0B6AF'), (93, x'E0B799'), (52, x'E0B6A6'), (73, x'E0B6BBE0B78AE2808D'), (3, x'E0B686'), (56, x'E0B6AA'), (55, x'E0B6A9'), (70, x'E0B6B9'), (94, x'E0B79A'), (80, x'E0B785'), (25, x'E0B69AE0B791'), (48, x'E0B6A2'), (13, x'E0B690'), (86, x'E0B793'), (91, x'E0B79F'), (81, x'E0B786'), (79, x'E0B784'), (14, x'E0B691'), (99, x'E0B78A'), (8, x'E0B68B'), (68, x'E0B6B7'), (22, x'E0B69A'), (16, x'E0B693'), (33, x'E0B69AE0B7B3'), (38, x'E0B69AE0B79D'), (21, x'E0B683'), (11, x'E0B68E'), (77, x'E0B782'), (40, x'E0B69AE0B78A'), (101, x'E0B78AE2808DE0B6BB'), (35, x'E0B69AE0B79A'), (1, x'E0B7B4'), (9, x'E0B68C'), (96, x'E0B79C'), (6, x'E0B689'), (95, x'E0B79B'), (88, x'E0B796'), (64, x'E0B6B3'), (26, x'E0B69AE0B792'), (82, x'E0B78F'), (28, x'E0B69AE0B794'), (39, x'E0B69AE0B79E'), (97, x'E0B79D'), (2, x'E0B685'), (75, x'E0B780'), (34, x'E0B69AE0B799'), (69, x'E0B6B8'), (83, x'E0B790'), (18, x'E0B695'), (90, x'E0B7B2'), (17, x'E0B694'), (72, x'E0B6BB'), (66, x'E0B6B5'), (59, x'E0B6AD'), (44, x'E0B69E'), (15, x'E0B692'), (23, x'E0B69AE0B78F'), (65, x'E0B6B4'), (42, x'E0B69C'), (63, x'E0B6B1'), (85, x'E0B792'), (47, x'E0B6A1'), (49, x'E0B6A3'), (92, x'E0B7B3'), (78, x'E0B783'), (36, x'E0B69AE0B79B'), (4, x'E0B687'), (24, x'E0B69AE0B790'), (87, x'E0B794'), (37, x'E0B69AE0B79C'), (32, x'E0B69AE0B79F'), (29, x'E0B69AE0B796'), (43, x'E0B69D'), (62, x'E0B6B0'), (100, x'E0B78AE2808DE0B6BA'), (60, x'E0B6AE'), (45, x'E0B69F'), (12, x'E0B68F'), (46, x'E0B6A0'), (50, x'E0B6A5'), (51, x'E0B6A4'), (5, x'E0B688'), (76, x'E0B781'), (89, x'E0B798'), (74, x'E0B6BD'), (10, x'E0B68D'), (57, x'E0B6AB'), (71, x'E0B6BA'), (58, x'E0B6AC'), (27, x'E0B69AE0B793'), (54, x'E0B6A8'), (84, x'E0B791'), (31, x'E0B69AE0B7B2'), (98, x'E0B79E'), (53, x'E0B6A7'), (41, x'E0B69B'), (67, x'E0B6B6'), (7, x'E0B68A'), (20, x'E0B682');
+SELECT predicted_order, hex(utf8mb4_encoding) FROM t1 ORDER BY utf8mb4_encoding COLLATE utf8mb4_sinhala_ci;
+predicted_order	hex(utf8mb4_encoding)
+1	E0B7B4
+2	E0B685
+3	E0B686
+4	E0B687
+5	E0B688
+6	E0B689
+7	E0B68A
+8	E0B68B
+9	E0B68C
+10	E0B68D
+11	E0B68E
+12	E0B68F
+13	E0B690
+14	E0B691
+15	E0B692
+16	E0B693
+17	E0B694
+18	E0B695
+19	E0B696
+20	E0B682
+21	E0B683
+22	E0B69A
+23	E0B69AE0B78F
+24	E0B69AE0B790
+25	E0B69AE0B791
+26	E0B69AE0B792
+27	E0B69AE0B793
+28	E0B69AE0B794
+29	E0B69AE0B796
+30	E0B69AE0B798
+31	E0B69AE0B7B2
+32	E0B69AE0B79F
+33	E0B69AE0B7B3
+34	E0B69AE0B799
+35	E0B69AE0B79A
+36	E0B69AE0B79B
+37	E0B69AE0B79C
+38	E0B69AE0B79D
+39	E0B69AE0B79E
+40	E0B69AE0B78A
+41	E0B69B
+42	E0B69C
+43	E0B69D
+44	E0B69E
+45	E0B69F
+46	E0B6A0
+47	E0B6A1
+48	E0B6A2
+49	E0B6A3
+50	E0B6A5
+51	E0B6A4
+52	E0B6A6
+53	E0B6A7
+54	E0B6A8
+55	E0B6A9
+56	E0B6AA
+57	E0B6AB
+58	E0B6AC
+59	E0B6AD
+60	E0B6AE
+61	E0B6AF
+62	E0B6B0
+63	E0B6B1
+64	E0B6B3
+65	E0B6B4
+66	E0B6B5
+67	E0B6B6
+68	E0B6B7
+69	E0B6B8
+70	E0B6B9
+71	E0B6BA
+72	E0B6BB
+73	E0B6BBE0B78AE2808D
+74	E0B6BD
+75	E0B780
+76	E0B781
+77	E0B782
+78	E0B783
+79	E0B784
+80	E0B785
+81	E0B786
+82	E0B78F
+83	E0B790
+84	E0B791
+85	E0B792
+86	E0B793
+87	E0B794
+88	E0B796
+89	E0B798
+90	E0B7B2
+91	E0B79F
+92	E0B7B3
+93	E0B799
+94	E0B79A
+95	E0B79B
+96	E0B79C
+97	E0B79D
+98	E0B79E
+99	E0B78A
+100	E0B78AE2808DE0B6BA
+101	E0B78AE2808DE0B6BB
+DROP TABLE t1;
+#
+# Bug#32914 Character sets: illegal characters in utf8mb4 and utf32 columns
+#
+create table t1 (utf8mb4 char(1) character set utf8mb4) engine InnoDB;
+Testing [F0][90..BF][80..BF][80..BF]
+insert into t1 values (0xF0908080);
+insert into t1 values (0xF0BFBFBF);
+insert into t1 values (0xF08F8080);
+Warnings:
+Warning	1366	Incorrect string value: '\xF0\x8F\x80\x80' for column 'utf8mb4' at row 1
+select hex(utf8mb4) from t1;
+hex(utf8mb4)
+
+F0908080
+F0BFBFBF
+delete from t1;
+Testing [F2..F3][80..BF][80..BF][80..BF]
+insert into t1 values (0xF2808080);
+insert into t1 values (0xF2BFBFBF);
+select hex(utf8mb4) from t1;
+hex(utf8mb4)
+F2808080
+F2BFBFBF
+delete from t1;
+Testing [F4][80..8F][80..BF][80..BF]
+insert into t1 values (0xF4808080);
+insert into t1 values (0xF48F8080);
+insert into t1 values (0xF4908080);
+Warnings:
+Warning	1366	Incorrect string value: '\xF4\x90\x80\x80' for column 'utf8mb4' at row 1
+select hex(utf8mb4) from t1;
+hex(utf8mb4)
+
+F4808080
+F48F8080
+drop table t1;
+#
+# Check strnxfrm() with odd length
+#
+set max_sort_length=5;
+select @@max_sort_length;
+@@max_sort_length
+5
+create table t1 (a varchar(128) character set utf8mb4 collate utf8mb4_general_ci) engine InnoDB;
+insert into t1 values ('a'),('b'),('c');
+select * from t1 order by a;
+a
+a
+b
+c
+alter table t1 modify a varchar(128) character set utf8mb4 collate utf8mb4_bin;
+select * from t1 order by a;
+a
+a
+b
+c
+drop table t1;
+set max_sort_length=default;
+#
+# Bug#26180: Can't add columns to tables created with utf8mb4 text indexes
+#
+CREATE TABLE t1 (
+clipid INT NOT NULL,
+Tape TINYTEXT,
+PRIMARY KEY (clipid),
+KEY tape(Tape(255))
+) CHARACTER SET=utf8mb4 ENGINE InnoDB;
+Warnings:
+Warning	1071	Specified key was too long; max key length is 767 bytes
+ALTER TABLE t1 ADD mos TINYINT DEFAULT 0 AFTER clipid;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `clipid` int(11) NOT NULL,
+  `mos` tinyint(4) DEFAULT '0',
+  `Tape` tinytext,
+  PRIMARY KEY (`clipid`),
+  KEY `tape` (`Tape`(191))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
+DROP TABLE t1;
+#
+# Testing 4-byte values.
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+u_decimal int NOT NULL,
+utf8mb4_encoding VARCHAR(10) NOT NULL
+) CHARACTER SET utf8mb4 ENGINE InnoDB;
+INSERT INTO t1 VALUES (119040, x'f09d8480'),
+# G CLEF
+(119070, x'f09d849e'),
+# HALF NOTE
+(119134, x'f09d859e'),
+# MUSICAL SYMBOL CROIX
+(119247, x'f09d878f'),
+# MATHEMATICAL BOLD ITALIC CAPITAL DELTA
+(120607, x'f09d9c9f'),
+# SANS-SERIF BOLD ITALIC CAPITAL PI
+(120735, x'f09d9e9f'),
+# <Plane 16 Private Use, Last> (last 4 byte character)
+(1114111, x'f48fbfbf'),
+# VARIATION SELECTOR-256
+(917999, x'f3a087af');
+INSERT INTO t1 VALUES (119070, x'f09d849ef09d859ef09d859ef09d8480f09d859ff09d859ff09d859ff09d85a0f09d85a0f09d8480');
+INSERT INTO t1 VALUES (65131, x'efb9abf09d849ef09d859ef09d859ef09d8480f09d859fefb9abefb9abf09d85a0efb9ab');
+INSERT INTO t1 VALUES (119070, x'f09d849ef09d859ef09d859ef09d8480f09d859ff09d859ff09d859ff09d85a0f09d85a0f09d8480f09d85a0');
+Warnings:
+Warning	1265	Data truncated for column 'utf8mb4_encoding' at row 1
+SELECT u_decimal, hex(utf8mb4_encoding) FROM t1 ORDER BY utf8mb4_encoding COLLATE utf8mb4_general_ci, BINARY utf8mb4_encoding;
+u_decimal	hex(utf8mb4_encoding)
+1114111	F48FBFBF
+119040	F09D8480
+119070	F09D849E
+119070	F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480
+119070	F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480
+119134	F09D859E
+119247	F09D878F
+120607	F09D9C9F
+120735	F09D9E9F
+65131	EFB9ABF09D849EF09D859EF09D859EF09D8480F09D859FEFB9ABEFB9ABF09D85A0EFB9AB
+917999	F3A087AF
+INSERT INTO t1 VALUES (1114111, x'f5808080');
+Warnings:
+Warning	1366	Incorrect string value: '\xF5\x80\x80\x80' for column 'utf8mb4_encoding' at row 1
+SELECT character_maximum_length, character_octet_length FROM information_schema.columns WHERE
+table_name= 't1' AND column_name= 'utf8mb4_encoding';
+character_maximum_length	character_octet_length
+10	40
+DROP TABLE IF EXISTS t2;
+CREATE TABLE t2 (
+u_decimal int NOT NULL,
+utf8mb3_encoding VARCHAR(10) NOT NULL
+) CHARACTER SET utf8mb3 ENGINE InnoDB;
+INSERT INTO t2 VALUES (42856, x'ea9da8');
+INSERT INTO t2 VALUES (65131, x'efb9ab');
+INSERT INTO t2 VALUES (1114111, x'f48fbfbf');
+Warnings:
+Warning	1366	Incorrect string value: '\xF4\x8F\xBF\xBF' for column 'utf8mb3_encoding' at row 1
+SELECT character_maximum_length, character_octet_length FROM information_schema.columns WHERE
+table_name= 't2' AND column_name= 'utf8mb3_encoding';
+character_maximum_length	character_octet_length
+10	30
+UPDATE t2 SET utf8mb3_encoding= x'f48fbfbd' where u_decimal= 42856;
+Warnings:
+Warning	1366	Incorrect string value: '\xF4\x8F\xBF\xBD' for column 'utf8mb3_encoding' at row 1
+UPDATE t2 SET utf8mb3_encoding= _utf8mb4 x'ea9da8' where u_decimal= 42856;
+SELECT HEX(CONCAT(utf8mb4_encoding, _utf8 x'ea9da8')) FROM t1;
+HEX(CONCAT(utf8mb4_encoding, _utf8 x'ea9da8'))
+EA9DA8
+EFB9ABF09D849EF09D859EF09D859EF09D8480F09D859FEFB9ABEFB9ABF09D85A0EFB9ABEA9DA8
+F09D8480EA9DA8
+F09D849EEA9DA8
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480EA9DA8
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480EA9DA8
+F09D859EEA9DA8
+F09D878FEA9DA8
+F09D9C9FEA9DA8
+F09D9E9FEA9DA8
+F3A087AFEA9DA8
+F48FBFBFEA9DA8
+SELECT HEX(CONCAT(utf8mb4_encoding, utf8mb3_encoding)) FROM t1,t2;
+HEX(CONCAT(utf8mb4_encoding, utf8mb3_encoding))
+
+EA9DA8
+EFB9AB
+EFB9ABF09D849EF09D859EF09D859EF09D8480F09D859FEFB9ABEFB9ABF09D85A0EFB9AB
+EFB9ABF09D849EF09D859EF09D859EF09D8480F09D859FEFB9ABEFB9ABF09D85A0EFB9ABEA9DA8
+EFB9ABF09D849EF09D859EF09D859EF09D8480F09D859FEFB9ABEFB9ABF09D85A0EFB9ABEFB9AB
+F09D8480
+F09D8480EA9DA8
+F09D8480EFB9AB
+F09D849E
+F09D849EEA9DA8
+F09D849EEFB9AB
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480EA9DA8
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480EA9DA8
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480EFB9AB
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480EFB9AB
+F09D859E
+F09D859EEA9DA8
+F09D859EEFB9AB
+F09D878F
+F09D878FEA9DA8
+F09D878FEFB9AB
+F09D9C9F
+F09D9C9FEA9DA8
+F09D9C9FEFB9AB
+F09D9E9F
+F09D9E9FEA9DA8
+F09D9E9FEFB9AB
+F3A087AF
+F3A087AFEA9DA8
+F3A087AFEFB9AB
+F48FBFBF
+F48FBFBFEA9DA8
+F48FBFBFEFB9AB
+SELECT count(*) FROM t1, t2
+WHERE t1.utf8mb4_encoding > t2.utf8mb3_encoding;
+count(*)
+33
+ALTER TABLE t1 CONVERT TO CHARACTER SET utf8;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `u_decimal` int(11) NOT NULL,
+  `utf8mb4_encoding` varchar(10) NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8
+SELECT u_decimal,hex(utf8mb4_encoding),utf8mb4_encoding FROM t1;
+u_decimal	hex(utf8mb4_encoding)	utf8mb4_encoding
+1114111		
+1114111	3F	?
+119040	3F	?
+119070	3F	?
+119070	3F3F3F3F3F3F3F3F3F3F	??????????
+119070	3F3F3F3F3F3F3F3F3F3F	??????????
+119134	3F	?
+119247	3F	?
+120607	3F	?
+120735	3F	?
+65131	EFB9AB3F3F3F3F3FEFB9ABEFB9AB3FEFB9AB	﹫?????﹫﹫?﹫
+917999	3F	?
+ALTER TABLE t2 CONVERT TO CHARACTER SET utf8mb4;
+SHOW CREATE TABLE t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `u_decimal` int(11) NOT NULL,
+  `utf8mb3_encoding` varchar(10) NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
+SELECT u_decimal,hex(utf8mb3_encoding) FROM t2;
+u_decimal	hex(utf8mb3_encoding)
+1114111	
+42856	EA9DA8
+65131	EFB9AB
+ALTER TABLE t2 CONVERT TO CHARACTER SET utf8mb3;
+SHOW CREATE TABLE t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `u_decimal` int(11) NOT NULL,
+  `utf8mb3_encoding` varchar(10) NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8
+SELECT u_decimal,hex(utf8mb3_encoding) FROM t2;
+u_decimal	hex(utf8mb3_encoding)
+1114111	
+42856	EA9DA8
+65131	EFB9AB
+ALTER TABLE t1 MODIFY utf8mb4_encoding VARCHAR(10) CHARACTER SET utf8mb3;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `u_decimal` int(11) NOT NULL,
+  `utf8mb4_encoding` varchar(10) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8
+SELECT u_decimal,hex(utf8mb4_encoding) FROM t1;
+u_decimal	hex(utf8mb4_encoding)
+1114111	
+1114111	3F
+119040	3F
+119070	3F
+119070	3F3F3F3F3F3F3F3F3F3F
+119070	3F3F3F3F3F3F3F3F3F3F
+119134	3F
+119247	3F
+120607	3F
+120735	3F
+65131	EFB9AB3F3F3F3F3FEFB9ABEFB9AB3FEFB9AB
+917999	3F
+ALTER TABLE t1 MODIFY utf8mb4_encoding VARCHAR(10) CHARACTER SET utf8mb4;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `u_decimal` int(11) NOT NULL,
+  `utf8mb4_encoding` varchar(10) CHARACTER SET utf8mb4 DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8
+SELECT u_decimal,hex(utf8mb4_encoding) FROM t1;
+u_decimal	hex(utf8mb4_encoding)
+1114111	
+1114111	3F
+119040	3F
+119070	3F
+119070	3F3F3F3F3F3F3F3F3F3F
+119070	3F3F3F3F3F3F3F3F3F3F
+119134	3F
+119247	3F
+120607	3F
+120735	3F
+65131	EFB9AB3F3F3F3F3FEFB9ABEFB9AB3FEFB9AB
+917999	3F
+ALTER TABLE t2 MODIFY utf8mb3_encoding VARCHAR(10) CHARACTER SET utf8mb4;
+SHOW CREATE TABLE t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `u_decimal` int(11) NOT NULL,
+  `utf8mb3_encoding` varchar(10) CHARACTER SET utf8mb4 DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8
+SELECT u_decimal,hex(utf8mb3_encoding) FROM t2;
+u_decimal	hex(utf8mb3_encoding)
+1114111	
+42856	EA9DA8
+65131	EFB9AB
+DROP TABLE IF EXISTS t3;
+CREATE TABLE t3 (
+u_decimal int NOT NULL,
+utf8mb3_encoding VARCHAR(10) NOT NULL
+) CHARACTER SET utf8 ENGINE InnoDB;
+INSERT INTO t3 SELECT * FROM t1;
+DROP TABLE IF EXISTS t4;
+CREATE TABLE t4 (
+u_decimal int NOT NULL,
+utf8mb4_encoding VARCHAR(10) NOT NULL
+) CHARACTER SET utf8mb4 ENGINE InnoDB;
+INSERT INTO t3 SELECT * FROM t2;
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+DROP TABLE t4;
+#
+# Testing that mixing utf8 and utf8mb4 collations returns utf8mb4
+#
+SELECT CHARSET(CONCAT(_utf8mb4'a',_utf8'b'));
+CHARSET(CONCAT(_utf8mb4'a',_utf8'b'))
+utf8mb4
+CREATE TABLE t1 (utf8mb4 VARCHAR(10) CHARACTER SET utf8mb4 NOT NULL) ENGINE InnoDB;
+INSERT INTO t1 VALUES (x'ea9da8'),(x'f48fbfbf');
+SELECT CONCAT(utf8mb4, _utf8 x'ea9da8') FROM t1 LIMIT 0;
+CONCAT(utf8mb4, _utf8 x'ea9da8')
+CREATE TABLE t2 (utf8mb3 VARCHAR(10) CHARACTER SET utf8mb3 NOT NULL) ENGINE InnoDB;
+INSERT INTO t2 VALUES (x'ea9da8');
+SELECT HEX(CONCAT(utf8mb4, utf8mb3)) FROM t1,t2 ORDER BY 1;
+HEX(CONCAT(utf8mb4, utf8mb3))
+EA9DA8EA9DA8
+F48FBFBFEA9DA8
+SELECT CHARSET(CONCAT(utf8mb4, utf8mb3)) FROM t1, t2 LIMIT 1;
+CHARSET(CONCAT(utf8mb4, utf8mb3))
+utf8mb4
+CREATE TEMPORARY TABLE t3 ENGINE InnoDB AS SELECT *, concat(utf8mb4,utf8mb3) FROM t1, t2;
+SHOW CREATE TABLE t3;
+Table	Create Table
+t3	CREATE TEMPORARY TABLE `t3` (
+  `utf8mb4` varchar(10) CHARACTER SET utf8mb4 NOT NULL,
+  `utf8mb3` varchar(10) CHARACTER SET utf8 NOT NULL,
+  `concat(utf8mb4,utf8mb3)` varchar(20) CHARACTER SET utf8mb4 NOT NULL DEFAULT ''
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+DROP TEMPORARY TABLE t3;
+SELECT * FROM t1, t2 WHERE t1.utf8mb4 > t2.utf8mb3;
+utf8mb4	utf8mb3
+􏿿	Ꝩ
+SELECT * FROM t1, t2 WHERE t1.utf8mb4 = t2.utf8mb3;
+utf8mb4	utf8mb3
+Ꝩ	Ꝩ
+SELECT * FROM t1, t2 WHERE t1.utf8mb4 < t2.utf8mb3;
+utf8mb4	utf8mb3
+DROP TABLE t1;
+DROP TABLE t2;
+#
+# Check that mixing utf8mb4 with an invalid utf8 constant returns error
+#
+CREATE TABLE t1 (utf8mb4 VARCHAR(10) CHARACTER SET utf8mb4) ENGINE InnoDB;
+INSERT INTO t1 VALUES (x'f48fbfbf');
+SELECT CONCAT(utf8mb4, _utf8 '�') FROM t1;
+ERROR HY000: Illegal mix of collations (utf8mb4_general_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation 'concat'
+SELECT CONCAT('a', _utf8 '�') FROM t1;
+ERROR HY000: Illegal mix of collations (utf8mb4_general_ci,COERCIBLE) and (utf8_general_ci,COERCIBLE) for operation 'concat'
+DROP TABLE t1;
+#
+# End of 5.5 tests
+#
+#
+# End of tests
+#

=== added file 'mysql-test/r/ctype_utf8mb4_myisam.result'
--- a/mysql-test/r/ctype_utf8mb4_myisam.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/ctype_utf8mb4_myisam.result	2010-03-05 08:17:19 +0000
@@ -0,0 +1,2407 @@
+drop table if exists t1,t2;
+#
+# Start of 5.5 tests
+#
+set names utf8mb4;
+select left(_utf8mb4 0xD0B0D0B1D0B2,1);
+left(_utf8mb4 0xD0B0D0B1D0B2,1)
+а
+select right(_utf8mb4 0xD0B0D0B2D0B2,1);
+right(_utf8mb4 0xD0B0D0B2D0B2,1)
+в
+select locate('he','hello');
+locate('he','hello')
+1
+select locate('he','hello',2);
+locate('he','hello',2)
+0
+select locate('lo','hello',2);
+locate('lo','hello',2)
+4
+select locate('HE','hello');
+locate('HE','hello')
+1
+select locate('HE','hello',2);
+locate('HE','hello',2)
+0
+select locate('LO','hello',2);
+locate('LO','hello',2)
+4
+select locate('HE','hello' collate utf8mb4_bin);
+locate('HE','hello' collate utf8mb4_bin)
+0
+select locate('HE','hello' collate utf8mb4_bin,2);
+locate('HE','hello' collate utf8mb4_bin,2)
+0
+select locate('LO','hello' collate utf8mb4_bin,2);
+locate('LO','hello' collate utf8mb4_bin,2)
+0
+select locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D0B1D0B2);
+locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D0B1D0B2)
+2
+select locate(_utf8mb4 0xD091, _utf8mb4 0xD0B0D0B1D0B2);
+locate(_utf8mb4 0xD091, _utf8mb4 0xD0B0D0B1D0B2)
+2
+select locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D091D0B2);
+locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D091D0B2)
+2
+select locate(_utf8mb4 0xD091, _utf8mb4 0xD0B0D0B1D0B2 collate utf8mb4_bin);
+locate(_utf8mb4 0xD091, _utf8mb4 0xD0B0D0B1D0B2 collate utf8mb4_bin)
+0
+select locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D091D0B2 collate utf8mb4_bin);
+locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D091D0B2 collate utf8mb4_bin)
+0
+select length(_utf8mb4 0xD0B1), bit_length(_utf8mb4 0xD0B1), char_length(_utf8mb4 0xD0B1);
+length(_utf8mb4 0xD0B1)	bit_length(_utf8mb4 0xD0B1)	char_length(_utf8mb4 0xD0B1)
+2	16	1
+select 'a' like 'a';
+'a' like 'a'
+1
+select 'A' like 'a';
+'A' like 'a'
+1
+select 'A' like 'a' collate utf8mb4_bin;
+'A' like 'a' collate utf8mb4_bin
+0
+select _utf8mb4 0xD0B0D0B1D0B2 like concat(_utf8mb4'%',_utf8mb4 0xD0B1,_utf8mb4 '%');
+_utf8mb4 0xD0B0D0B1D0B2 like concat(_utf8mb4'%',_utf8mb4 0xD0B1,_utf8mb4 '%')
+1
+select convert(_latin1'G�Andr�using utf8mb4) like CONVERT(_latin1'G�TER%' USING utf8mb4);
+convert(_latin1'G?nter Andr?' using utf8mb4) like CONVERT(_latin1'G?NTER%' USING utf8mb4)
+1
+select CONVERT(_koi8r'��' USING utf8mb4) LIKE CONVERT(_koi8r'�' USING utf8mb4);
+CONVERT(_koi8r'????' USING utf8mb4) LIKE CONVERT(_koi8r'????' USING utf8mb4)
+1
+select CONVERT(_koi8r'�' USING utf8mb4) LIKE CONVERT(_koi8r'��' USING utf8mb4);
+CONVERT(_koi8r'????' USING utf8mb4) LIKE CONVERT(_koi8r'????' USING utf8mb4)
+1
+SELECT 'a' = 'a ';
+'a' = 'a '
+1
+SELECT 'a\0' < 'a';
+'a\0' < 'a'
+1
+SELECT 'a\0' < 'a ';
+'a\0' < 'a '
+1
+SELECT 'a\t' < 'a';
+'a\t' < 'a'
+1
+SELECT 'a\t' < 'a ';
+'a\t' < 'a '
+1
+SELECT 'a' = 'a ' collate utf8mb4_bin;
+'a' = 'a ' collate utf8mb4_bin
+1
+SELECT 'a\0' < 'a' collate utf8mb4_bin;
+'a\0' < 'a' collate utf8mb4_bin
+1
+SELECT 'a\0' < 'a ' collate utf8mb4_bin;
+'a\0' < 'a ' collate utf8mb4_bin
+1
+SELECT 'a\t' < 'a' collate utf8mb4_bin;
+'a\t' < 'a' collate utf8mb4_bin
+1
+SELECT 'a\t' < 'a ' collate utf8mb4_bin;
+'a\t' < 'a ' collate utf8mb4_bin
+1
+CREATE TABLE t1 (a char(10) character set utf8mb4 not null) ENGINE MyISAM;
+INSERT INTO t1 VALUES ('a'),('a\0'),('a\t'),('a ');
+SELECT hex(a),STRCMP(a,'a'), STRCMP(a,'a ') FROM t1;
+hex(a)	STRCMP(a,'a')	STRCMP(a,'a ')
+61	0	0
+61	0	0
+6100	-1	-1
+6109	-1	-1
+DROP TABLE t1;
+select insert('txs',2,1,'hi'),insert('is ',4,0,'a'),insert('txxxxt',2,4,'es');
+insert('txs',2,1,'hi')	insert('is ',4,0,'a')	insert('txxxxt',2,4,'es')
+this	is a	test
+select insert("aa",100,1,"b"),insert("aa",1,3,"b");
+insert("aa",100,1,"b")	insert("aa",1,3,"b")
+aa	b
+select char_length(left(@a:='тт',5))	length(@a)	@a
+4	8	тест
+create table t1 ENGINE MyISAM 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")` varchar(10) CHARACTER SET utf8mb4 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 utf8mb4;
+set LC_TIME_NAMES='fr_FR';
+create table t1 (s1 char(20) character set latin1) engine MyISAM;
+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) engine MyISAM;
+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
+E6C5D7	Фев
+E6C5D7D2C1CCD1	Февраля
+F0CEC4	Пнble t1;
+set LC_TIME_NAMES='en_US';
+set names koi8r;
+create table t1 (s1 char(1) character set utf8mb4) engine MyISAM;
+insert into t1 values (_koi8r'�');
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+select s1,hex(s1),char_length(s1),octet_length(s1) from t1;
+s1	hex(s1)	char_length(s1)	octet_length(s1)
+�D0B0	1	2
+drop table t1;
+create table t1 (s1 tinytext character set utf8mb4) engine MyISAM;
+insert into t1 select repeat('a',300);
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+insert into t1 select repeat('�,300);
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+insert into t1 select repeat('a�,300);
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+insert into t1 select repeat('�',300);
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+insert into t1 select repeat('�',300);
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+select hex(s1) from t1;
+hex(s1)
+616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161
+61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F
+D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61
+D18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18F
+D18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18F
+select length(s1),char_length(s1) from t1;
+length(s1)	char_length(s1)
+254	127
+254	127
+255	170
+255	170
+255	255
+drop table t1;
+create table t1 (s1 text character set utf8mb4) engine MyISAM;
+insert into t1 select repeat('a',66000);
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+insert into t1 select repeat('�,66000);
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+insert into t1 select repeat('a�,66000);
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+insert into t1 select repeat('�',66000);
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+insert into t1 select repeat('�',66000);
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+select length(s1),char_length(s1) from t1;
+length(s1)	char_length(s1)
+65534	32767
+65534	32767
+65535	43690
+65535	43690
+65535	65535
+drop table t1;
+create table t1 (s1 char(10) character set utf8mb4) engine MyISAM;
+insert into t1 values (0x41FF);
+Warnings:
+Warning	1366	Incorrect string value: '\xFF' for column 's1' at row 1
+select hex(s1) from t1;
+hex(s1)
+41
+drop table t1;
+create table t1 (s1 varchar(10) character set utf8mb4) engine MyISAM;
+insert into t1 values (0x41FF);
+Warnings:
+Warning	1366	Incorrect string value: '\xFF' for column 's1' at row 1
+select hex(s1) from t1;
+hex(s1)
+41
+drop table t1;
+create table t1 (s1 text character set utf8mb4) engine MyISAM;
+insert into t1 values (0x41FF);
+Warnings:
+Warning	1366	Incorrect string value: '\xFF' for column 's1' at row 1
+select hex(s1) from t1;
+hex(s1)
+41
+drop table t1;
+create table t1 (a text character set utf8mb4, primary key(a(371))) engine MyISAM;
+ERROR 42000: Specified key was too long; max key length is 1000 bytes
+CREATE TABLE t1 ( a varchar(10) ) CHARACTER SET utf8mb4 ENGINE MyISAM;
+INSERT INTO t1 VALUES ( 'test' );
+SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = b.a;
+a	a
+test	test
+SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = 'test' and b.a = 'test';
+a	a
+test	test
+SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = b.a and a.a = 'test';
+a	a
+test	test
+DROP TABLE t1;
+create table t1 (a char(255) character set utf8mb4) engine MyISAM;
+insert into t1 values('b'),('b');
+select * from t1 where a = 'b';
+a
+b
+b
+select * from t1 where a = 'b' and a = 'b';
+a
+b
+b
+select * from t1 where a = 'b' and a != 'b';
+a
+drop table t1;
+set collation_connection=utf8mb4_general_ci;
+drop table if exists t1;
+create table t1 as
+select repeat(' ', 64) as s1, repeat(' ',64) as s2
+union
+select null, null;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `s1` varchar(64) CHARACTER SET utf8mb4 DEFAULT NULL,
+  `s2` varchar(64) CHARACTER SET utf8mb4 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+delete from t1;
+insert into t1 values('aaa','aaa');
+insert into t1 values('aaa|qqq','qqq');
+insert into t1 values('gheis','^[^a-dXYZ]+$');
+insert into t1 values('aab','^aa?b');
+insert into t1 values('Baaan','^Ba*n');
+insert into t1 values('aaa','qqq|aaa');
+insert into t1 values('qqq','qqq|aaa');
+insert into t1 values('bbb','qqq|aaa');
+insert into t1 values('bbb','qqq');
+insert into t1 values('aaa','aba');
+insert into t1 values(null,'abc');
+insert into t1 values('def',null);
+insert into t1 values(null,null);
+insert into t1 values('ghi','ghi[');
+select HIGH_PRIORITY s1 regexp s2 from t1;
+s1 regexp s2
+1
+1
+1
+1
+1
+1
+1
+0
+0
+0
+NULL
+NULL
+NULL
+NULL
+drop table t1;
+set names utf8mb4;
+set names utf8mb4;
+select  'вася'  rlike '[[:<:]]вася[[:>:]]';
+'вася'  rlike '[[:<:]]вася[[:>:]]'
+1
+select  'вася ' rlike '[[:<:]]вася[[:>:]]';
+'вася ' rlike '[[:<:]]вася[[:>:]]'
+1
+select ' вася'  rlike '[[:<:]]вася[[:>:]]';
+' вася'  rlike '[[:<:]]вася[[:>:]]'
+1
+select ' вася ' rlike '[[:<:]]вася[[:>:]]';
+' вася ' rlike '[[:<:]]вася[[:>:]]'
+1
+select  'васяz' rlike '[[:<:]]вася[[:>:]]';
+'васяz' rlike '[[:<:]]вася[[:>:]]'
+0
+select 'zвася'  rlike '[[:<:]]вася[[:>:]]';
+'zвася'  rlike '[[:<:]]вася[[:>:]]'
+0
+select 'zвасяz' rlike '[[:<:]]вася[[:>:]]';
+'zвасяz' rlike '[[:<:]]вася[[:>:]]'
+0
+CREATE TABLE t1 (a enum ('Y', 'N') DEFAULT 'N' COLLATE utf8mb4_unicode_ci) ENGINE MyISAM;
+ALTER TABLE t1 ADD COLUMN b CHAR(20);
+DROP TABLE t1;
+set names utf8mb4;
+create table t1 (a enum('aaaa','проба') character set utf8mb4) engine MyISAM;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` enum('aaaa','проба') CHARACTER SET utf8mb4 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+insert into t1 values ('про engine MyISAM select ifnull(a,a) from t1;
+show create table t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `ifnull(a,a)` varchar(5) CHARACTER SET utf8mb4 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+select * from t2;
+ifnull(a,a)
+проба
+drop table t1;
+drop table t2;
+create table t1 (c varchar(30) character set utf8mb4, unique(c(10))) engine MyISAM;
+insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z');
+insert into t1 values ('aaaaaaaaaa');
+insert into t1 values ('aaaaaaaaaaa');
+ERROR 23000: Duplicate entry 'aaaaaaaaaa' for key 'c'
+insert into t1 values ('aaaaaaaaaaaa');
+ERROR 23000: Duplicate entry 'aaaaaaaaaa' for key 'c'
+insert into t1 values (repeat('b',20));
+select c c1 from t1 where c='1';
+c1
+1
+select c c2 from t1 where c='2';
+c2
+2
+select c c3 from t1 where c='3';
+c3
+3
+select c cx from t1 where c='x';
+cx
+x
+select c cy from t1 where c='y';
+cy
+y
+select c cz from t1 where c='z';
+cz
+z
+select c ca10 from t1 where c='aaaaaaaaaa';
+ca10
+aaaaaaaaaa
+select c cb20 from t1 where c=repeat('b',20);
+cb20
+bbbbbbbbbbbbbbbbbbbb
+drop table t1;
+create table t1 (c varchar(30) character set utf8mb4, unique(c(10))) engine=MyISAM;
+insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z');
+insert into t1 values ('aaaaaaaaaa');
+insert into t1 values ('aaaaaaaaaaa');
+ERROR 23000: Duplicate entry 'aaaaaaaaaa' for key 'c'
+insert into t1 values ('aaaaaaaaaaaa');
+ERROR 23000: Duplicate entry 'aaaaaaaaaa' for key 'c'
+insert into t1 values (repeat('b',20));
+select c c1 from t1 where c='1';
+c1
+1
+select c c2 from t1 where c='2';
+c2
+2
+select c c3 from t1 where c='3';
+c3
+3
+select c cx from t1 where c='x';
+cx
+x
+select c cy from t1 where c='y';
+cy
+y
+select c cz from t1 where c='z';
+cz
+z
+select c ca10 from t1 where c='aaaaaaaaaa';
+ca10
+aaaaaaaaaa
+select c cb20 from t1 where c=repeat('b',20);
+cb20
+bbbbbbbbbbbbbbbbbbbb
+drop table t1;
+create table t1 (c char(3) character set utf8mb4, unique (c(2))) engine MyISAM;
+insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z');
+insert into t1 values ('a');
+insert into t1 values ('aa');
+insert into t1 values ('aaa');
+ERROR 23000: Duplicate entry 'aa' for key 'c'
+insert into t1 values ('b');
+insert into t1 values ('bb');
+insert into t1 values ('bbb');
+ERROR 23000: Duplicate entry 'bb' for key 'c'
+insert into t1 values ('а');
+insert into t1 values ('аа');
+insert into t1 values ('ааа');
+ERROR 23000: Duplicate entry 'аа' for key 'c'
+insert into t1 values ('б');
+insert into t1 values ('бб');
+insert into t1 values ('ббб');
+ERROR 23000: Duplicate entry 'бб' for key 'c'
+insert into t1 values ('ꪪ');
+insert into t1 values ('ꪪꪪ');
+insert into t1 values ('ꪪꪪꪪ');
+ERROR 23000: Duplicate entry 'ꪪꪪ' for key 'c'
+drop table t1;
+create table t1 (c char(3) character set utf8mb4, unique (c(2))) engine=MyISAM;
+insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z');
+insert into t1 values ('a');
+insert into t1 values ('aa');
+insert into t1 values ('aaa');
+ERROR 23000: Duplicate entry 'aa' for key 'c'
+insert into t1 values ('b');
+insert into t1 values ('bb');
+insert into t1 values ('bbb');
+ERROR 23000: Duplicate entry 'bb' for key 'c'
+insert into t1 values ('а');
+insert into t1 values ('аа');
+insert into t1 values ('ааа');
+ERROR 23000: Duplicate entry 'аа' for key 'c'
+insert into t1 values ('б');
+insert into t1 values ('бб');
+insert into t1 values ('ббб');
+ERROR 23000: Duplicate entry 'бб' for key 'c'
+insert into t1 values ('ꪪ');
+insert into t1 values ('ꪪꪪ');
+insert into t1 values ('ꪪꪪꪪ');
+ERROR 23000: Duplicate entry 'ꪪꪪ' for key 'c'
+drop table t1;
+create table t1 (
+c char(10) character set utf8mb4,
+unique key a using hash (c(1))
+) engine=MyISAM;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c` char(10) CHARACTER SET utf8mb4 DEFAULT NULL,
+  UNIQUE KEY `a` (`c`(1)) USING HASH
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
+insert into t1 values ('aa');
+ERROR 23000: Duplicate entry 'a' for key 'a'
+insert into t1 values ('aaa');
+ERROR 23000: Duplicate entry 'a' for key 'a'
+insert into t1 values ('б');
+insert into t1 values ('бб');
+ERROR 23000: Duplicate entry 'б' for key 'a'
+insert into t1 values ('ббб');
+ERROR 23000: Duplicate entry 'б' for key 'a'
+select c as c_all from t1 order by c;
+c_all
+a
+b
+c
+d
+e
+f
+б
+select c as c_a from t1 where c='a';
+c_a
+a
+select c as c_a from t1 where c='б';
+c_a
+б
+drop table t1;
+create table t1 (
+c char(10) character set utf8mb4,
+unique key a using btree (c(1))
+) engine=MyISAM;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c` char(10) CHARACTER SET utf8mb4 DEFAULT NULL,
+  UNIQUE KEY `a` (`c`(1)) USING BTREE
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
+insert into t1 values ('aa');
+ERROR 23000: Duplicate entry 'a' for key 'a'
+insert into t1 values ('aaa');
+ERROR 23000: Duplicate entry 'a' for key 'a'
+insert into t1 values ('б');
+insert into t1 values ('бб');
+ERROR 23000: Duplicate entry 'б' for key 'a'
+insert into t1 values ('ббб');
+ERROR 23000: Duplicate entry 'б' for key 'a'
+select c as c_all from t1 order by c;
+c_all
+a
+b
+c
+d
+e
+f
+б
+select c as c_a from t1 where c='a';
+c_a
+a
+select c as c_a from t1 where c='б';
+c_a
+б
+drop table t1;
+create table t1 (
+c char(10) character set utf8mb4,
+unique key a (c(1))
+) engine=MyISAM;
+insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
+insert into t1 values ('aa');
+ERROR 23000: Duplicate entry 'a' for key 'a'
+insert into t1 values ('aaa');
+ERROR 23000: Duplicate entry 'a' for key 'a'
+insert into t1 values ('б');
+insert into t1 values ('бб');
+ERROR 23000: Duplicate entry 'б' for key 'a'
+insert into t1 values ('ббб');
+ERROR 23000: Duplicate entry 'б' for key 'a'
+select c as c_all from t1 order by c;
+c_all
+a
+b
+c
+d
+e
+f
+б
+select c as c_a from t1 where c='a';
+c_a
+a
+select c as c_a from t1 where c='б';
+c_a
+б
+drop table t1;
+create table t1 (c varchar(30) character set utf8mb4 collate utf8mb4_bin, unique(c(10))) engine MyISAM;
+insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z');
+insert into t1 values ('aaaaaaaaaa');
+insert into t1 values ('aaaaaaaaaaa');
+ERROR 23000: Duplicate entry 'aaaaaaaaaa' for key 'c'
+insert into t1 values ('aaaaaaaaaaaa');
+ERROR 23000: Duplicate entry 'aaaaaaaaaa' for key 'c'
+insert into t1 values (repeat('b',20));
+select c c1 from t1 where c='1';
+c1
+1
+select c c2 from t1 where c='2';
+c2
+2
+select c c3 from t1 where c='3';
+c3
+3
+select c cx from t1 where c='x';
+cx
+x
+select c cy from t1 where c='y';
+cy
+y
+select c cz from t1 where c='z';
+cz
+z
+select c ca10 from t1 where c='aaaaaaaaaa';
+ca10
+aaaaaaaaaa
+select c cb20 from t1 where c=repeat('b',20);
+cb20
+bbbbbbbbbbbbbbbbbbbb
+drop table t1;
+create table t1 (c char(3) character set utf8mb4 collate utf8mb4_bin, unique (c(2))) engine MyISAM;
+insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z');
+insert into t1 values ('a');
+insert into t1 values ('aa');
+insert into t1 values ('aaa');
+ERROR 23000: Duplicate entry 'aa' for key 'c'
+insert into t1 values ('b');
+insert into t1 values ('bb');
+insert into t1 values ('bbb');
+ERROR 23000: Duplicate entry 'bb' for key 'c'
+insert into t1 values ('а');
+insert into t1 values ('аа');
+insert into t1 values ('ааа');
+ERROR 23000: Duplicate entry 'аа' for key 'c'
+insert into t1 values ('б');
+insert into t1 values ('бб');
+insert into t1 values ('ббб');
+ERROR 23000: Duplicate entry 'бб' for key 'c'
+insert into t1 values ('ꪪ');
+insert into t1 values ('ꪪꪪ');
+insert into t1 values ('ꪪꪪꪪ');
+ERROR 23000: Duplicate entry 'ꪪꪪ' for key 'c'
+drop table t1;
+create table t1 (
+c char(10) character set utf8mb4 collate utf8mb4_bin,
+unique key a using hash (c(1))
+) engine=MyISAM;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
+  UNIQUE KEY `a` (`c`(1)) USING HASH
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
+insert into t1 values ('aa');
+ERROR 23000: Duplicate entry 'a' for key 'a'
+insert into t1 values ('aaa');
+ERROR 23000: Duplicate entry 'a' for key 'a'
+insert into t1 values ('б');
+insert into t1 values ('бб');
+ERROR 23000: Duplicate entry 'б' for key 'a'
+insert into t1 values ('ббб');
+ERROR 23000: Duplicate entry 'б' for key 'a'
+select c as c_all from t1 order by c;
+c_all
+a
+b
+c
+d
+e
+f
+б
+select c as c_a from t1 where c='a';
+c_a
+a
+select c as c_a from t1 where c='б';
+c_a
+б
+drop table t1;
+create table t1 (
+c char(10) character set utf8mb4 collate utf8mb4_bin,
+unique key a using btree (c(1))
+) engine=MyISAM;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
+  UNIQUE KEY `a` (`c`(1)) USING BTREE
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
+insert into t1 values ('aa');
+ERROR 23000: Duplicate entry 'a' for key 'a'
+insert into t1 values ('aaa');
+ERROR 23000: Duplicate entry 'a' for key 'a'
+insert into t1 values ('б');
+insert into t1 values ('бб');
+ERROR 23000: Duplicate entry 'б' for key 'a'
+insert into t1 values ('ббб');
+ERROR 23000: Duplicate entry 'б' for key 'a'
+select c as c_all from t1 order by c;
+c_all
+a
+b
+c
+d
+e
+f
+б
+select c as c_a from t1 where c='a';
+c_a
+a
+select c as c_a from t1 where c='б';
+c_a
+б
+drop table t1;
+create table t1 (
+c char(10) character set utf8mb4 collate utf8mb4_bin,
+unique key a (c(1))
+) engine=MyISAM;
+insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
+insert into t1 values ('aa');
+ERROR 23000: Duplicate entry 'a' for key 'a'
+insert into t1 values ('aaa');
+ERROR 23000: Duplicate entry 'a' for key 'a'
+insert into t1 values ('б');
+insert into t1 values ('бб');
+ERROR 23000: Duplicate entry 'б' for key 'a'
+insert into t1 values ('ббб');
+ERROR 23000: Duplicate entry 'б' for key 'a'
+select c as c_all from t1 order by c;
+c_all
+a
+b
+c
+d
+e
+f
+б
+select c as c_a from t1 where c='a';
+c_a
+a
+select c as c_a from t1 where c='б';
+c_a
+б
+drop table t1;
+create table t1 (
+str varchar(255) character set utf8mb4 not null,
+key str  (str(2))
+) engine=MyISAM;
+INSERT INTO t1 VALUES ('str');
+INSERT INTO t1 VALUES ('str2');
+select * from t1 where str='str';
+str
+str
+drop table t1;
+create table t1 (
+str varchar(255) character set utf8mb4 not null,
+key str  (str(2))
+) engine=MyISAM;
+INSERT INTO t1 VALUES ('str');
+INSERT INTO t1 VALUES ('str2');
+select * from t1 where str='str';
+str
+str
+drop table t1;
+create table t1 (
+str varchar(255) character set utf8mb4 not null,
+key str using btree (str(2))
+) engine=MyISAM;
+INSERT INTO t1 VALUES ('str');
+INSERT INTO t1 VALUES ('str2');
+select * from t1 where str='str';
+str
+str
+drop table t1;
+create table t1 (
+str varchar(255) character set utf8mb4 not null,
+key str using hash (str(2))
+) engine=MyISAM;
+INSERT INTO t1 VALUES ('str');
+INSERT INTO t1 VALUES ('str2');
+select * from t1 where str='str';
+str
+str
+drop table t1;
+create table t1 (
+str varchar(255) character set utf8mb4 not null,
+key str (str(2))
+) engine= MyISAM;
+INSERT INTO t1 VALUES ('str');
+INSERT INTO t1 VALUES ('str2');
+select * from t1 where str='str';
+str
+str
+drop table t1;
+CREATE TABLE t1 (a varchar(32) BINARY) CHARACTER SET utf8mb4 ENGINE MyISAM;
+INSERT INTO t1 VALUES ('test');
+SELECT a FROM t1 WHERE a LIKE '%te';
+a
+DROP TABLE t1;
+SET NAMES utf8mb4;
+CREATE TABLE t1 (
+subject varchar(255) character set utf8mb4 collate utf8mb4_unicode_ci,
+p varchar(15) character set utf8mb4
+) ENGINE= MyISAM DEFAULT CHARSET=latin1;
+INSERT INTO t1 VALUES ('谷川俊二と申しますが、インターネ');
+INSERT INTO t1 VALUES ('aaa','bbb');
+SELECT length(subject) FROM t1;
+length(subject)
+3
+432
+SELECT length(subject) FROM t1 ORDER BY 1;
+length(subject)
+3
+432
+DROP TABLE t1;
+CREATE TABLE t1 (
+id       int unsigned NOT NULL auto_increment,
+list_id  smallint unsigned NOT NULL,
+term     TEXT NOT NULL,
+PRIMARY KEY(id),
+INDEX(list_id, term(4))
+) ENGINE=MyISAM CHARSET=utf8mb4;
+INSERT INTO t1 SET list_id = 1, term = "letterc";
+INSERT INTO t1 SET list_id = 1, term = "letterb";
+INSERT INTO t1 SET list_id = 1, term = "lettera";
+INSERT INTO t1 SET list_id = 1, term = "letterd";
+SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterc");
+id
+1
+SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterb");
+id
+2
+SELECT id FROM t1 WHERE (list_id = 1) AND (term = "lettera");
+id
+3
+SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterd");
+id
+4
+DROP TABLE t1;
+SET NAMES latin1;
+CREATE TABLE t1 (
+id int unsigned NOT NULL auto_increment,
+list_id smallint unsigned NOT NULL,
+term text NOT NULL,
+PRIMARY KEY(id),
+INDEX(list_id, term(19))
+) ENGINE=MyISAM CHARSET=utf8mb4;
+INSERT INTO t1 set list_id = 1, term = "test�st";
+INSERT INTO t1 set list_id = 1, term = "testetest";
+INSERT INTO t1 set list_id = 1, term = "test�st";
+SELECT id, term FROM t1 where (list_id = 1) AND (term = "test�st");
+id	term
+1	test�st
+2	testetest
+3	test�st
+SELECT id, term FROM t1 where (list_id = 1) AND (term = "testetest");
+id	term
+1	test�st
+2	testetest
+3	test�st
+SELECT id, term FROM t1 where (list_id = 1) AND (term = "test�st");
+id	term
+1	test�st
+2	testetest
+3	test�st
+DROP TABLE t1;
+set names utf8mb4;
+create table t1 (
+a int primary key,
+b varchar(6),
+index b3(b(3))
+) engine=MyISAM character set=utf8mb4;
+insert into t1 values(1,'foo'),(2,'foobar');
+select * from t1 where b like 'foob%';
+a	b
+2	foobar
+alter table t1 engine=innodb;
+select * from t1 where b like 'foob%';
+a	b
+2	foobar
+drop table t1;
+create table t1 (
+a enum('петя','вася','анюта') character set utf8mb4 not null default 'анюта',
+b set('петя','ault 'анюта'
+) engine MyISAM;
+create table t2 engine MyISAM select concat(a,_utf8mb4'') as a, concat(b,_utf8mb4'')as b from t1;
+show create table t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `a` varchar(5) CHARACTER SET utf8mb4 NOT NULL DEFAULT '',
+  `b` varchar(15) CHARACTER SET utf8mb4 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t2;
+drop table t1;
+select 'c' like '\_' as want0;
+want0
+0
+SELECT SUBSTR('вася',-2);
+SUBSTR('вася',-2)
+ся
+create table t1 (id integer, a varchar(100) character set utf8mb4 collate utf8mb4_unicode_ci) engine MyISAM;
+insert into t1 values (1, 'Test');
+select * from t1 where soundex(a) = soundex('Test');
+id	a
+1	Test
+select * from t1 where soundex(a) = soundex('TEST');
+id	a
+1	Test
+select * from t1 where soundex(a) = soundex('test');
+id	a
+1	Test
+drop table t1;
+select soundex(_utf8mb4 0xE99885E8A788E99A8FE697B6E69BB4E696B0E79A84E696B0E997BB);
+soundex(_utf8mb4 0xE99885E8A788E99A8FE697B6E69BB4E696B0E79A84E696B0E997BB)
+97B6E69BB4E696B0E79A84E696B0E997BB));
+hex(soundex(_utf8mb4 0xE99885E8A788E99A8FE697B6E69BB4E696B0E79A84E696B0E997BB))
+E99885303030
+select soundex(_utf8mb4 0xD091D092D093);
+soundex(_utf8mb4 0xD091D092D093)
+Б000
+select hex(soundex(_utf8mb4 0xD091D092D093));
+hex(soundex(_utf8mb4 0xD091D092D093))
+D091303030
+SET collation_connection='utf8mb4_general_ci';
+create table t1 select repeat('a',4000) a;
+delete from t1;
+insert into t1 values ('a'), ('a '), ('a\t');
+select collation(a),hex(a) from t1 order by a;
+collation(a)	hex(a)
+utf8mb4_general_ci	6109
+utf8mb4_general_ci	61
+utf8mb4_general_ci	6120
+drop table t1;
+select @@collation_connection;
+@@collation_connection
+utf8mb4_general_ci
+create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ;
+insert into t1 values('abcdef');
+insert into t1 values('_bcdef');
+insert into t1 values('a_cdef');
+insert into t1 values('ab_def');
+insert into t1 values('abc_ef');
+insert into t1 values('abcd_f');
+insert into t1 values('abcde_');
+select c1 as c1u from t1 where c1 like 'ab\_def';
+c1u
+ab_def
+select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
+c2h
+ab_def
+drop table t1;
+drop table if exists t1;
+create table t1 as select repeat(' ', 64) as s1;
+select collation(s1) from t1;
+collation(s1)
+utf8mb4_general_ci
+delete from t1;
+insert into t1 values ('a'),('ae'),(_latin1 0xE4);
+insert into t1 values ('o'),('oe'),(_latin1 0xF6);
+insert into t1 values ('s'),('ss'),(_latin1 0xDF);
+insert into t1 values ('u'),('ue'),(_latin1 0xFC);
+select s1, hex(s1) from t1 order by s1, binary s1;
+s1	hex(s1)
+a	61
+ä	C3A4
+ae	6165
+o	6F
+ö	C3B6
+oe	6F65
+s	73
+ß	C39F
+ss	7373
+u	75
+ü	C3BC
+ue	7565
+select group_concat(s1 order by binary s1) from t1 group by s1;
+group_concat(s1 order by binary s1)
+a,ä
+ae
+o,ö
+oe
+s,ß
+ss
+u,ü
+ue
+drop table t1;
+SET collation_connection='utf8mb4_bin';
+create table t1 select repeat('a',4000) a;
+delete from t1;
+insert into t1 values ('a'), ('a '), ('a\t');
+select collation(a),hex(a) from t1 order by a;
+collation(a)	hex(a)
+utf8mb4_bin	6109
+utf8mb4_bin	61
+utf8mb4_bin	6120
+drop table t1;
+select @@collation_connection;
+@@collation_connection
+utf8mb4_bin
+create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ;
+insert into t1 values('abcdef');
+insert into t1 values('_bcdef');
+insert into t1 values('a_cdef');
+insert into t1 values('ab_def');
+insert into t1 values('abc_ef');
+insert into t1 values('abcd_f');
+insert into t1 values('abcde_');
+select c1 as c1u from t1 where c1 like 'ab\_def';
+c1u
+ab_def
+select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
+c2h
+ab_def
+drop table t1;
+CREATE TABLE t1 (
+user varchar(255) NOT NULL default ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+INSERT INTO t1 VALUES ('one'),('two');
+SELECT CHARSET('a');
+CHARSET('a')
+utf8mb4
+SELECT user, CONCAT('<', user, '>') AS c FROM t1;
+user	c
+one	<one>
+two	<two>
+DROP TABLE t1;
+create table t1 (f1 varchar(1) not null) default charset utf8mb4 engine MyISAM;
+insert into t1 values (''), ('');
+select concat(concat(_latin1'->',f1),_latin1'<-') from t1;
+concat(concat(_latin1'->',f1),_latin1'<-')
+-><-
+-><-
+drop table t1;
+select convert(_koi8r'� using utf8mb4) < convert(_koi8r'� using utf8mb4);
+convert(_koi8r'?' using utf8mb4) < convert(_koi8r'?' using utf8mb4)
+1
+set names latin1;
+create table t1 (a varchar(10)) character set utf8mb4 engine MyISAM;
+insert into t1 values ('test');
+select ifnull(a,'') from t1;
+ifnull(a,'')
+test
+drop table t1;
+select repeat(_utf8mb4'+',3) as h union select NULL;
+h
++++
+NULL
+select ifnull(NULL, _utf8mb4'string');
+ifnull(NULL, _utf8mb4'string')
+string
+set names utf8mb4;
+create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_lithuanian_ci) engine MyISAM;
+insert into t1 values ('I'),('K'),('Y');
+select * from t1 where s1 < 'K' and s1 = 'Y';
+s1
+I
+Y
+select * from t1 where 'K' > s1 and s1 = 'Y';
+s1
+I
+Y
+drop table t1;
+create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_czech_ci) engine MyISAM;
+insert into t1 values ('c'),('d'),('h'),('ch'),('CH'),('cH'),('Ch'),('i');
+select * from t1 where s1 > 'd' and s1 = 'CH';
+s1
+CH
+Ch
+ch
+select * from t1 where 'd' < s1 and s1 = 'CH';
+s1
+CH
+Ch
+ch
+select * from t1 where s1 = 'cH' and s1 <> 'ch';
+s1
+cH
+select * from t1 where 'cH' = s1 and s1 <> 'ch';
+s1
+cH
+drop table t1;
+create table t1 (a varchar(255)) default character set utf8mb4 engine MyISAM;
+insert into t1 values (1.0);
+drop table t1;
+create table t1 (
+id int not null,
+city varchar(20) not null,
+key (city(7),id)
+) character set=utf8mb4 engine MyISAM;
+insert into t1 values (1,'Durban North');
+insert into t1 values (2,'Durban');
+select * from t1 where city = 'Durban';
+id	city
+2	Durban
+select * from t1 where city = 'Durban ';
+id	city
+2	Durban
+drop table t1;
+create table t1 (x set('A', 'B') default 0) character set utf8mb4 engine MyISAM;
+ERROR 42000: Invalid default value for 'x'
+create table t1 (x enum('A', 'B') default 0) character set utf8mb4 engine MyISAM;
+ERROR 42000: Invalid default value for 'x'
+SET NAMES UTF8;
+CREATE TABLE t1 (
+`id` int(20) NOT NULL auto_increment,
+`country` varchar(100) NOT NULL default '',
+`shortcode` varchar(100) NOT NULL default '',
+`operator` varchar(100) NOT NULL default '',
+`momid` varchar(30) NOT NULL default '',
+`keyword` varchar(160) NOT NULL default '',
+`content` varchar(160) NOT NULL default '',
+`second_token` varchar(160) default NULL,
+`gateway_id` int(11) NOT NULL default '0',
+`created` datetime NOT NULL default '0000-00-00 00:00:00',
+`msisdn` varchar(15) NOT NULL default '',
+PRIMARY KEY  (`id`),
+UNIQUE KEY `MSCCSPK_20030521130957121` (`momid`),
+KEY `IX_mobile_originated_message_keyword` (`keyword`),
+KEY `IX_mobile_originated_message_created` (`created`),
+KEY `IX_mobile_originated_message_support` (`msisdn`,`momid`,`keyword`,`gateway_id`,`created`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
+INSERT INTO t1 VALUES 
+(1,'blah','464','aaa','fkc1c9ilc20x0hgae7lx6j09','ERR','ERR Имри.Афимим.Аеимимримдм ирбднримрфмририримрфмфмим.Адимимрн имадми','ИМРИ.АФИМИМ.А:30:43','1234567890'),
+(2,'blah','464','aaa','haxpl2ilc20x00bj4tt2m5ti','11','11 g','G',3,'2005-06-02 22:43:10','1234567890');
+CREATE TABLE t2 (
+`msisdn` varchar(15) NOT NULL default '',
+`operator_id` int(11) NOT NULL default '0',
+`created` datetime NOT NULL default '0000-00-00 00:00:00',
+UNIQUE KEY `PK_user` (`msisdn`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
+INSERT INTO t2 VALUES ('1234567890',2,'2005-05-24 13:53:25');
+SELECT content, t2.msisdn FROM t1, t2 WHERE t1.msisdn = '1234567890';
+content	msisdn
+ERR Имри.Афимим.Аеимимримдм ирбднримрфмририримрфмфмим.Ад.Д имдимримрад.Адимримримрмдиримимрн имадми	1234567890
+11 g	1234567890
+DROP TABLE t1,t2;
+create table t1 (a char(20) character set utf8mb4) engine MyISAM;
+insert into t1 values ('123456'),('андрей');
+alter table t1 modify a char(2) character set utf8mb4;
+Warnings:
+Warning	1265	Data truncated for column 'a' at row 1
+Warning	1265	Data truncated for column 'a' at row 2
+select char_length(a), length(a), a from t1 order by a;
+char_length(a)	length(a)	a
+2	2	12
+2	4	ан
+drop table t1;
+set names utf8mb4;
+select 'andre%' like 'andreñ%' escape 'ñ';
+'andre%' like 'andreñ%' escape 'ñ'
+1
+set names utf8mb4;
+select 'a\\' like 'a\\';
+'a\\' like 'a\\'
+1
+select 'aa\\' like 'a%\\';
+'aa\\' like 'a%\\'
+1
+create table t1 (a char(10), key(a)) character set utf8mb4 engine MyISAM;
+insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test");
+select * from t1 where a like "abc%";
+a
+abc
+abcd
+select * from t1 where a like concat("abc","%");
+a
+abc
+abcd
+select * from t1 where a like "ABC%";
+a
+abc
+abcd
+select * from t1 where a like "test%";
+a
+test
+select * from t1 where a like "te_t";
+a
+test
+select * from t1 where a like "%a%";
+a
+a
+abc
+abcd
+select * from t1 where a like "%abcd%";
+a
+abcd
+select * from t1 where a like "%abc\d%";
+a
+abcd
+drop table t1;
+CREATE TABLE t1 (
+a varchar(255) NOT NULL default '',
+KEY a (a)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;
+Warnings:
+Warning	1071	Specified key was too long; max key length is 1000 bytes
+insert into t1 values (_utf8mb4 0xe880bd);
+insert into t1 values (_utf8mb4 0x5b);
+select hex(a) from t1;
+hex(a)
+5B
+E880BD
+drop table t1;
+set names 'latin1';
+create table t1 (a varchar(255)) default charset=utf8mb4 engine MyISAM;
+select * from t1 where find_in_set('-1', a);
+a
+drop table t1;
+create table t1 (a int) engine MyISAM;
+insert into t1 values (48),(49),(50);
+set names utf8mb4;
+select distinct char(a) from t1;
+char(a)
+0
+1
+2
+drop table t1;
+CREATE TABLE t1 (t TINYTEXT CHARACTER SET utf8mb4) ENGINE MyISAM;
+INSERT INTO t1 VALUES(REPEAT('a', 100));
+CREATE TEMPORARY TABLE t2 ENGINE MyISAM SELECT COALESCE(t) AS bug FROM t1;
+SELECT LENGTH(bug) FROM t2;
+LENGTH(bug)
+100
+DROP TABLE t2;
+DROP TABLE t1;
+CREATE TABLE t1 (item varchar(255)) default character set utf8mb4 ENGINE MyISAM;
+INSERT INTO t1 VALUES (N'\\');
+INSERT INTO t1 VALUES (_utf8mb4'\\');
+INSERT INTO t1 VALUES (N'Cote d\'Ivoire');
+INSERT INTO t1 VALUES (_utf8mb4'Cote d\'Ivoire');
+SELECT item FROM t1 ORDER BY item;
+item
+Cote d'Ivoire
+Cote d'Ivoire
+\
+\
+DROP TABLE t1;
+SET NAMES utf8mb4;
+DROP TABLE IF EXISTS t1;
+Warnings:
+Note	1051	Unknown table 't1'
+CREATE TABLE t1(a VARCHAR(255), KEY(a)) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
+Warnings:
+Warning	1071	Specified key was too long; max key length is 1000 bytes
+INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb');
+INSERT INTO t1 VALUES('uu');
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	status	OK
+INSERT INTO t1 VALUES('uU');
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	status	OK
+INSERT INTO t1 VALUES('uu');
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	status	OK
+INSERT INTO t1 VALUES('uuABC');
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	status	OK
+INSERT INTO t1 VALUES('UuABC');
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	status	OK
+INSERT INTO t1 VALUES('uuABC');
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	status	OK
+alter table t1 add b int;
+INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',1);
+INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',2);
+delete from t1 where b=1;
+INSERT INTO t1 VALUES('UUABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',1);
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	status	OK
+INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',3);
+INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',4);
+delete from t1 where b=3;
+INSERT INTO t1 VALUES('uUABCDEFGHIGKLMNOPRSTUVWXYZbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',3);
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	status	OK
+drop table t1;
+set names utf8mb4;
+create table t1 (s1 char(5) character set utf8mb4) engine MyISAM;
+insert into t1 values
+('a'),('b'),(null),('ペ
+select s1 as before_delete_general_ci from t1 where s1 like 'ペテ%';
+before_delete_general_ci
+ペテルグete_general_ci from t1 where s1 like 'ペテ%';
+after_delete_general_ci
+ペテルグル
+drop table t1;
+set names utf8mb4;
+create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_unicode_ci) engine MyISAM;
+insert into t1 values
+('a'),('b'),(null),('ペテルグル'),('ü'),('Y');
+create index it1 on t1 (s1);
+select s1 as before_delete_unicode_ci from t1 where s1 like 'ペテ%';
+before_delete_unicode_ci
+ペテルグル
+delete from t1 where s1 = 'Y';
+select s1 as after_delete_unicode_ci from t1 where s1 like 'ペテ%';
+after_delete_unicode_ci
+ペテルグル
+drop table t1;
+set names utf8mb4;
+create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_bin) engine MyISAM;
+insert into t1 values
+('a'),('b'),(null),('ペテルグル'),('ü'),('Y');
+create index it1 on t1 (s1);
+select s1 as before_delete_bin from t1 where s1 like 'ペテ%';
+before_delete_bin
+ペテル_delete_bin from t1 where s1 like 'ペテ%';
+after_delete_bin
+ペテルグル
+drop table t1;
+set names utf8mb4;
+create table t1 (a varchar(30) not null primary key)
+engine=MyISAM default character set utf8mb4 collate utf8mb4_general_ci;
+insert into t1 values ('あいうえおさしすせそかきくけこあいうえお');
+select a as gci1 from t1 where a like 'さしすせそかきくe 'あいうえおかきくけこさしすせそ';
+gci2
+あいうえおかきくけこさしすせそ
+drop table t1;
+set names utf8mb4;
+create table t1 (a varchar(30) not null primary key)
+engine=MyISAM default character set utf8mb4 collate utf8mb4_unicode_ci;
+insert into t1 values ('あいうえおかきくけこさしすせそ');
+insert into t1 values ('さしすせそかきくけこあいうえお');
+select a as uci1 from t1 where a like 'uci2 from t1 where a like 'あいうえおかきくけこさしすせそ';
+uci2
+あいうえおかきくけこ table t1 (a varchar(30) not null primary key)
+engine=MyISAM default character set utf8mb4 collate utf8mb4_bin;
+insert into t1 values ('あいうえおかきくけこさしすせそ');
+insert into t1 values ('さしすせそ1 where a like 'さしすせそかきくけこあいうお
+select a as bin2 from t1 where a like 'あいうえかきくけこさしすせそ
+drop table t1;
+SET NAMES utf8mb4;
+CREATE TABLE t1 (id int PRIMARY KEY,
+a varchar(16) collate utf8mb4_unicode_ci NOT NULL default '',
+b int,
+f varchar(128) default 'XXX',
+INDEX (a(4))
+) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+INSERT INTO t1(id, a, b) VALUES
+(1, 'cccc', 50), (2, 'cccc', 70), (3, 'cccc', 30),
+(4, 'cccc', 30), (5, 'cccc', 20), (6, 'bbbbbb', 40),
+(7, 'dddd', 30), (8, 'aaaa', 10), (9, 'aaaa', 50),
+(10, 'eeeee', 40), (11, 'bbbbbb', 60);
+SELECT id, a, b FROM t1;
+id	a	b
+1	cccc	50
+10	eeeee	40
+11	bbbbbb	60
+2	cccc	70
+3	cccc	30
+4	cccc	30
+5	cccc	20
+6	bbbbbb	40
+7	dddd	30
+8	aaaa	10
+9	aaaa	50
+SELECT id, a, b FROM t1 WHERE a BETWEEN 'aaaa' AND 'bbbbbb';
+id	a	b
+11	bbbbbb	60
+6	bbbbbb	40
+8	aaaa	10
+9	aaaa	50
+SELECT id, a FROM t1 WHERE a='bbbbbb';
+id	a
+11	bbbbbb
+6	bbbbbb
+SELECT id, a FROM t1 WHERE a='bbbbbb' ORDER BY b;
+id	a
+6	bbbbbb
+11	bbbbbb
+DROP TABLE t1;
+SET NAMES utf8mb4;
+CREATE TABLE t1 (
+a CHAR(13) DEFAULT '',
+INDEX(a)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+INSERT INTO t1 VALUES 
+('Käli Käli Käli 2+4'),
+('Käli Käli 2-6'), ('Käli Käli 2-6');
+INSERT INTO t1 SELECT * FROM t1;
+CREATE TABLE t2 (
+a CHAR(13) DEFAULT '',
+INDEX(a)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
+INSERT INTO t2 VALUES
+('Kali Kali 2-4'), ('Kali Kali 2-4'),
+('Kali Kali 2+4'), ('Kali Kali 2+4'),
+('Kali Kali 2-6'), ('Kali Kali 2-6');
+INSERT INTO t2 SELECT * FROM t2;
+SELECT a FROM t1 WHERE a LIKE 'Käli Käli 2+4';
+a
+Käli Käli 2+4
+Käli Käli 2+4
+Käli Käli 2+4
+Käli Käli 2+4
+SELECT a FROM t2 WHERE a LIKE 'Kali Kali 2+4';
+a
+Kali Kali 2+4
+Kali Kali 2+4
+Kali Kali 2+4
+Kali Kali 2+4
+EXPLAIN SELECT a FROM t1 WHERE a LIKE 'Käli Käli 2+4';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	a	a	53	NULL	4	Using where; Using index
+EXPLAIN SELECT a FROM t1 WHERE a = 'Käli Käli 2+4';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ref	a	a	53	const	4	Using where; Using index
+EXPLAIN SELECT a FROM t2 WHERE a LIKE 'Kali Kali 2+4';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t2	range	a	a	14	NULL	4	Using where; Using index
+EXPLAIN SELECT a FROM t2 WHERE a = 'Kali Kali 2+4';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t2	ref	a	a	14	const	4	Using where; Using index
+DROP TABLE t1,t2;
+CREATE TABLE t1 (
+a char(255) DEFAULT '', 
+KEY(a(10))
+) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+INSERT INTO t1 VALUES ('Käli Käli 2-4');
+SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%';
+a
+Käli Käli 2-4
+INSERT INTO t1 VALUES ('Käli Käli 2-4');
+SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%';
+a
+Käli Käli 2-4
+Käli Käli 2-4
+DROP TABLE t1;
+CREATE TABLE t1 (
+a char(255) DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+INSERT INTO t1 VALUES ('Käli Käli 2-4');
+INSERT INTO t1 VALUES ('Käli K';
+a
+Käli Käli 2-4
+Käli Käli 2-4
+ALTER TABLE t1 ADD KEY (a(10));
+SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%';
+a
+Käli Käli 2-4
+Käli Käli 2-4
+DROP TABLE t1;
+SET NAMES latin2;
+CREATE TABLE t1 (
+id int(11) NOT NULL default '0',
+tid int(11) NOT NULL default '0',
+val text NOT NULL,
+INDEX idx(tid, val(10))
+) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
+INSERT INTO t1 VALUES
+(40988,72,'VOLN�ADSL'),(41009,72,'VOLN�ADSL'),
+(41032,72,'VOLN�ADSL'),(41038,72,'VOLN�ADSL'),
+(41063,72,'VOLNN�ADSL'),(42565,72,'VOLN�ADSL Combi'),
+(42749,72,'VOLN�ADSL'),(44205,72,'VOLN�ADSL');
+SELECT * FROM t1 WHERE tid=72 and val LIKE 'VOLNY ADSL';
+id	tid	val
+40988	72	VOLN�ADSL
+41009	72	VOLN�ADSL
+41032	72	VOLN�ADSL
+41038	72	VOLN�ADSL
+41063	72	VOLN�ADSL
+42141	72	VOLN�ADSL
+42749	72	VOLN�ADSL
+44205	72	VOLN�ADSL
+SELECT * FROM t1 WHERE tid=72 and val LIKE 'VOLN�ADSL';
+id	tid	val
+40988	72	VOLN�ADSL
+41009	72	VOLN�ADSL
+41032	72	VOLN�ADSL
+41038	72	VOLN�ADSL
+41063	72	VOLN�ADSL
+42141	72	VOLN�ADSL
+42749	72	VOLN�ADSL
+44205	72	VOLN�ADSL
+SELECT * FROM t1 WHERE tid=72 and val LIKE '%VOLN�ADSL';
+id	tid	val
+40988	72	VOLN�ADSL
+41009	72	VOLN�ADSL
+41032	72	VOLN�ADSL
+41038	72	VOLN	72	VOLN�ADSL
+44205	72	VOLN�ADSL
+ALTER TABLE t1 DROP KEY idx;
+ALTER TABLE t1 ADD KEY idx (tid,val(11));
+SELECT * FROM t1 WHERE tid=72 and val LIKE 'VOLN�ADSL';
+id	tid	val
+40988	72	VOLN�ADSL
+41009	72	VOLN�ADSL
+41032	72	VOLN�ADSL
+41038	72	VOLN�ADSL
+41063	72	VOLN	72	VOLN�ADSL
+DROP TABLE t1;
+create table t1(a char(200) collate utf8mb4_unicode_ci NOT NULL default '')
+default charset=utf8mb4 collate=utf8mb4_unicode_ci engine MyISAM;
+insert into t1 values (unhex('65')), (unhex('C3A9')), (unhex('65'));
+explain select distinct a from t1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	Using temporary
+SELECT COUNT(*) FROM (SELECT DISTINCT a FROM t1) AS t2;
+COUNT(*)
+1
+explain select a from t1 group by a;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	Using temporary; Using filesort
+SELECT COUNT(*) FROM (SELECT a FROM t1 GROUP BY a) AS t2;
+COUNT(*)
+1
+drop table t1;
+create table t1(a char(10)) default charset utf8mb4 engine MyISAM;
+insert into t1 values ('123'), ('456');
+explain
+select substr(Z.a,-1), Z.a from t1 as Y join t1 as Z on Y.a=Z.a order by 1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	Y	ALL	NULL	NULL	NULL	NULL	2	Using temporary; Using filesort
+1	SIMPLE	Z	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer
+select substr(Z.a,-1), Z.a from t1 as Y join t1 as Z on Y.a=Z.a order by 1;
+substr(Z.a,-1)	a
+3	123
+6	456
+drop table t1;
+SET CHARACTER SET utf8mb4;
+SHOW VARIABLES LIKE 'character\_set\_%';
+Variable_name	Value
+character_set_client	utf8mb4
+character_set_connection	latin1
+character_set_database	latin1
+character_set_filesystem	binary
+character_set_results	utf8mb4
+character_set_server	latin1
+character_set_system	utf8
+CREATE DATABASE crashtest DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
+USE crashtest;
+CREATE TABLE crashtest (crash char(10)) DEFAULT CHARSET=utf8mb4 ENGINE MyISAM;
+INSERT INTO crashtest VALUES ('35'), ('36'), ('37');
+SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8mb4);
+crash
+35
+36
+37
+INSERT INTO crashtest VALUES ('-1000');
+EXPLAIN SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8mb4);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	crashtest	ALL	NULL	NULL	NULL	NULL	4	Using filesort
+SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8mb4);
+crash
+-1000
+35
+36
+37
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FFFFFC'
+DROP TABLE crashtest;
+DROP DATABASE crashtest;
+USE test;
+SET CHARACTER SET default;
+CREATE TABLE t1(id varchar(20) NOT NULL) DEFAULT CHARSET=utf8mb4 ENGINE MyISAM;
+INSERT INTO t1 VALUES ('xxx'), ('aa'), ('yyy'), ('aa');
+SELECT id FROM t1;
+id
+aa
+aa
+xxx
+yyy
+SELECT DISTINCT id FROM t1;
+id
+aa
+xxx
+yyy
+SELECT DISTINCT id FROM t1 ORDER BY id;
+id
+aa
+xxx
+yyy
+DROP TABLE t1;
+create table t1 (
+a varchar(26) not null
+) default character set utf8mb4 ENGINE MyISAM;
+insert into t1 (a) values ('abcdefghijklmnopqrstuvwxyz');
+select * from t1;
+a
+abcdefghijklmnopqrstuvwxyz
+alter table t1 change a a varchar(20) character set utf8mb4 not null;
+Warnings:
+Warning	1265	Data truncated for column 'a' at row 1
+select * from t1;
+a
+abcdefghijklmnopqrst
+alter table t1 change a a char(15) character set utf8mb4 not null;
+Warnings:
+Warning	1265	Data truncated for column 'a' at row 1
+select * from t1;
+a
+abcdefghijklmno
+alter table t1 change a a char(10) character set utf8mb4 not null;
+Warnings:
+Warning	1265	Data truncated for column 'a' at row 1
+select * from t1;
+a
+abcdefghij
+alter table t1 change a a varchar(5) character set utf8mb4 not null;
+Warnings:
+Warning	1265	Data truncated for column 'a' at row 1
+select * from t1;
+a
+abcde
+drop table t1;
+create table t1 (
+a varchar(4000) not null
+) default character set utf8mb4 engine MyISAM;
+insert into t1 values (repeat('a',4000));
+alter table t1 change a a varchar(3000) character set utf8mb4 not null;
+Warnings:
+Warning	1265	Data truncated for column 'a' at row 1
+select length(a) from t1;
+length(a)
+3000
+drop table t1;
+set names utf8mb4;
+select hex(char(1 using utf8mb4));
+hex(char(1 using utf8mb4))
+01
+select char(0xd1,0x8f using utf8mb4);
+char(0xd1,0x8f using utf8mb4)
+я
+select char(0xd18f using utf8mb4);
+char(0xd18f using utf8mb4)
+я
+select char(53647 using utf8mb4);
+char(53647 using utf8mb4)
+я
+select char(0xff,0x8f using utf8mb4);
+char(0xff,0x8f using utf8mb4)
+
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FF8F'
+select convert(char(0xff,0x8f) using utf8mb4);
+convert(char(0xff,0x8f) using utf8mb4)
+
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FF8F'
+set sql_mode=traditional;
+select char(0xff,0x8f using utf8mb4);
+char(0xff,0x8f using utf8mb4)
+NULL
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FF8F'
+select char(195 using utf8mb4);
+char(195 using utf8mb4)
+NULL
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'C3'
+select char(196 using utf8mb4);
+char(196 using utf8mb4)
+NULL
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'C4'
+select char(2557 using utf8mb4);
+char(2557 using utf8mb4)
+NULL
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FD'
+select convert(char(0xff,0x8f) using utf8mb4);
+convert(char(0xff,0x8f) using utf8mb4)
+NULL
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FF8F'
+select hex(convert(char(2557 using latin1) using utf8mb4));
+hex(convert(char(2557 using latin1) using utf8mb4))
+09C3BD
+select hex(char(195));
+hex(char(195))
+C3
+select hex(char(196));
+hex(char(196))
+C4
+select hex(char(2557));
+hex(char(2557))
+09FD
+set names utf8mb4;
+create table t1 (a char(1)) default character set utf8mb4 engine MyISAM;
+create table t2 (a char(1)) default character set utf8mb4 engine MyISAM;
+insert into t1 values('a'),('a'),(0xE38182),(0xE38182);
+insert into t1 values('i'),('i'),(0xE38184),(0xE38184);
+select * from t1 union distinct select * from t2;
+a
+a
+i
+あ
+い
+drop table t1,t2;
+set names utf8mb4;
+create table t1 (a char(10), b varchar(10)) engine MyISAM;
+insert into t1 values ('bar','kostja');
+insert into t1 values ('kostja','bar');
+prepare my_stmt from "select * from t1 where a=?";
+set @a:='bar';
+execute my_stmt using @a;
+a	b
+bar	kostja
+set @a:='kostja';
+execute my_stmt using @a;
+a	b
+kostja	bar
+set @a:=null;
+execute my_stmt using @a;
+a	b
+drop table if exists t1;
+drop table if exists t1;
+drop view if exists v1, v2;
+set names utf8mb4;
+create table t1(col1 varchar(12) character set utf8mb4 collate utf8mb4_unicode_ci) engine MyISAM;
+insert into t1 values('t1_val');
+create view v1 as select 'v1_val' as col1;
+select coercibility(col1), collation(col1) from v1;
+coercibility(col1)	collation(col1)
+4	utf8mb4_general_ci
+create view v2 as select col1 from v1 union select col1 from t1;
+select coercibility(col1), collation(col1)from v2;
+coercibility(col1)	collation(col1)
+2	utf8mb4_unicode_ci
+2	utf8mb4_unicode_ci
+drop view v1, v2;
+create view v1 as select 'v1_val' collate utf8mb4_swedish_ci as col1;
+select coercibility(col1), collation(col1) from v1;
+coercibility(col1)	collation(col1)
+0	utf8mb4_swedish_ci
+create view v2 as select col1 from v1 union select col1 from t1;
+select coercibility(col1), collation(col1) from v2;
+coercibility(col1)	collation(col1)
+0	utf8mb4_swedish_ci
+0	utf8mb4_swedish_ci
+drop view v1, v2;
+drop table t1;
+set names utf8mb4;
+create table t1 (a varchar(10) character set latin1, b int) engine MyISAM;
+insert into t1 values ('a',1);
+select concat(a, if(b>10, N'x', N'y')) from t1;
+concat(a, if(b>10, N'x', N'y'))
+ay
+select concat(a, if(b>10, N'æ', N'ß')) from t1;
+ERROR HY000: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation 'concat'
+drop table t1;
+set names utf8mb4;
+create table t1 (a varchar(10) character set latin1, b int) engine MyISAM;
+insert into t1 values ('a',1);
+select concat(a, if(b>10, _utf8mb4'x', _utf8mb4'y')) from t1;
+concat(a, if(b>10, _utf8mb4'x', _utf8mb4'y'))
+ay
+select concat(a, if(b>10, _utf8mb4'æ', _utf8mb4'ß')) from t1;
+ERROR HY000: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation 'concat'
+drop table t1;
+set names utf8mb4;
+create table t1 (a varchar(10) character set latin1, b int) engine MyISAM;
+insert into t1 values ('a',1);
+select concat(a, if(b>10, _utf8mb4 0x78, _utf8mb4 0x79)) from t1;
+concat(a, if(b>10, _utf8mb4 0x78, _utf8mb4 0x79))
+ay
+select concat(a, if(b>10, _utf8mb4 0xC3A6, _utf8mb4 0xC3AF)) from t1;
+ERROR HY000: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation 'concat'
+drop table t1;
+set names utf8mb4;
+create table t1 (a varchar(10) character set latin1, b int) engine MyISAM;
+insert into t1 values ('a',1);
+select concat(a, if(b>10, 'x' 'x', 'y' 'y')) from t1;
+concat(a, if(b>10, 'x' 'x', 'y' 'y'))
+ayy
+select concat(a, if(b>10, 'x' 'æ', 'y' 'ß')) from t1;
+ERROR HY000: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation 'concat'
+drop table t1;
+CREATE TABLE t1 (
+colA int(11) NOT NULL,
+colB varchar(255) character set utf8mb4 NOT NULL,
+PRIMARY KEY  (colA)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+INSERT INTO t1 (colA, colB) VALUES (1, 'foo'), (2, 'foo bar');
+CREATE TABLE t2 (
+colA int(11) NOT NULL,
+colB varchar(255) character set utf8mb4 NOT NULL,
+KEY bad  (colA,colB(3))
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+INSERT INTO t2 (colA, colB) VALUES (1, 'foo'),(2, 'foo bar');
+SELECT * FROM t1 JOIN t2 ON t1.colA=t2.colA AND t1.colB=t2.colB
+WHERE t1.colA < 3;
+colA	colB	colA	colB
+1	foo	1	foo
+2	foo bar	2	foo bar
+DROP TABLE t1, t2;
+SELECT 'н1234567890' UNION SELECT _binary '1';
+н1234567890
+н1234567890
+1
+SELECT 'н1234567890' UNION SELECT 1;
+н1234567890
+н1234567890
+1
+SELECT '1' UNION SELECT 'н1234567890';
+1
+1
+н1234567890
+SELECT 1 UNION SELECT 'н1234567890';
+1
+1
+н1234567890
+CREATE TABLE t1 (c VARCHAR(11)) CHARACTER SET utf8mb4 ENGINE MyISAM;
+CREATE TABLE t2 (b CHAR(1) CHARACTER SET binary, i INT) ENGINE MyISAM;
+INSERT INTO t1 (c) VALUES ('н1234567890');
+INSERT INTO t2 (b, i) VALUES ('1', 1);
+SELECT c FROM t1 UNION SELECT b FROM t2;
+c
+н1234567890
+1
+SELECT c FROM t1 UNION SELECT i FROM t2;
+c
+н1234567890
+1
+SELECT b FROM t2 UNION SELECT c FROM t1;
+b
+1
+н1234567890
+SELECT i FROM t2 UNION SELECT c FROM t1;
+i
+1
+н1234567890
+DROP TABLE t1, t2;
+set sql_mode=traditional;
+select hex(char(0xFF using utf8mb4));
+hex(char(0xFF using utf8mb4))
+NULL
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FF'
+select hex(convert(0xFF using utf8mb4));
+hex(convert(0xFF using utf8mb4))
+NULL
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FF'
+select hex(_utf8mb4 0x616263FF);
+ERROR HY000: Invalid utf8mb4 character string: 'FF'
+select hex(_utf8mb4 X'616263FF');
+ERROR HY000: Invalid utf8mb4 character string: 'FF'
+select hex(_utf8mb4 B'001111111111');
+ERROR HY000: Invalid utf8mb4 character string: 'FF'
+select (_utf8mb4 X'616263FF');
+ERROR HY000: Invalid utf8mb4 character string: 'FF'
+set sql_mode=default;
+select hex(char(0xFF using utf8mb4));
+hex(char(0xFF using utf8mb4))
+
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FF'
+select hex(convert(0xFF using utf8mb4));
+hex(convert(0xFF using utf8mb4))
+
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FF'
+select hex(_utf8mb4 0x616263FF);
+ERROR HY000: Invalid utf8mb4 character string: 'FF'
+select hex(_utf8mb4 X'616263FF');
+ERROR HY000: Invalid utf8mb4 character string: 'FF'
+select hex(_utf8mb4 B'001111111111');
+ERROR HY000: Invalid utf8mb4 character string: 'FF'
+select (_utf8mb4 X'616263FF');
+ERROR HY000: Invalid utf8mb4 character string: 'FF'
+CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL) ENGINE MyISAM;
+INSERT INTO t1 VALUES (70000, 1092), (70001, 1085), (70002, 1065);
+SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b;
+CONVERT(a, CHAR)	CONVERT(b, CHAR)
+70000	1092
+70001	1085
+70002	1065
+SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1;
+CONVERT(a, CHAR)	CONVERT(b, CHAR)
+70000	1092
+70001	1085
+70002	1065
+ALTER TABLE t1 ADD UNIQUE (b);
+SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b;
+CONVERT(a, CHAR)	CONVERT(b, CHAR)
+70000	1092
+70001	1085
+70002	1065
+DROP INDEX b ON t1;
+SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b;
+CONVERT(a, CHAR)	CONVERT(b, CHAR)
+70000	1092
+70001	1085
+70002	1065
+ALTER TABLE t1 ADD INDEX (b);
+SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) from t1 GROUP BY b;
+CONVERT(a, CHAR)	CONVERT(b, CHAR)
+70000	1092
+70001	1085
+70002	1065
+DROP TABLE t1;
+#
+# Bug#26474: Add Sinhala script (Sri Lanka) collation to MySQL
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+predicted_order int NOT NULL,
+utf8mb4_encoding VARCHAR(10) NOT NULL
+) CHARACTER SET utf8mb4 ENGINE MyISAM;
+INSERT INTO t1 VALUES (19, x'E0B696'), (30, x'E0B69AE0B798'), (61, x'E0B6AF'), (93, x'E0B799'), (52, x'E0B6A6'), (73, x'E0B6BBE0B78AE2808D'), (3, x'E0B686'), (56, x'E0B6AA'), (55, x'E0B6A9'), (70, x'E0B6B9'), (94, x'E0B79A'), (80, x'E0B785'), (25, x'E0B69AE0B791'), (48, x'E0B6A2'), (13, x'E0B690'), (86, x'E0B793'), (91, x'E0B79F'), (81, x'E0B786'), (79, x'E0B784'), (14, x'E0B691'), (99, x'E0B78A'), (8, x'E0B68B'), (68, x'E0B6B7'), (22, x'E0B69A'), (16, x'E0B693'), (33, x'E0B69AE0B7B3'), (38, x'E0B69AE0B79D'), (21, x'E0B683'), (11, x'E0B68E'), (77, x'E0B782'), (40, x'E0B69AE0B78A'), (101, x'E0B78AE2808DE0B6BB'), (35, x'E0B69AE0B79A'), (1, x'E0B7B4'), (9, x'E0B68C'), (96, x'E0B79C'), (6, x'E0B689'), (95, x'E0B79B'), (88, x'E0B796'), (64, x'E0B6B3'), (26, x'E0B69AE0B792'), (82, x'E0B78F'), (28, x'E0B69AE0B794'), (39, x'E0B69AE0B79E'), (97, x'E0B79D'), (2, x'E0B685'), (75, x'E0B780'), (34, x'E0B69AE0B799'), (69, x'E0B6B8'), (83, x'E0B790'), (18, x'E0B695'), (90, x'E0B7B2'), (17, x'E0B694'), (72, x'E0B6BB'), (66, x'E0B6B5'), (59, x'E0B6AD'), (44, x'E0B69E'), (15, x'E0B692'), (23, x'E0B69AE0B78F'), (65, x'E0B6B4'), (42, x'E0B69C'), (63, x'E0B6B1'), (85, x'E0B792'), (47, x'E0B6A1'), (49, x'E0B6A3'), (92, x'E0B7B3'), (78, x'E0B783'), (36, x'E0B69AE0B79B'), (4, x'E0B687'), (24, x'E0B69AE0B790'), (87, x'E0B794'), (37, x'E0B69AE0B79C'), (32, x'E0B69AE0B79F'), (29, x'E0B69AE0B796'), (43, x'E0B69D'), (62, x'E0B6B0'), (100, x'E0B78AE2808DE0B6BA'), (60, x'E0B6AE'), (45, x'E0B69F'), (12, x'E0B68F'), (46, x'E0B6A0'), (50, x'E0B6A5'), (51, x'E0B6A4'), (5, x'E0B688'), (76, x'E0B781'), (89, x'E0B798'), (74, x'E0B6BD'), (10, x'E0B68D'), (57, x'E0B6AB'), (71, x'E0B6BA'), (58, x'E0B6AC'), (27, x'E0B69AE0B793'), (54, x'E0B6A8'), (84, x'E0B791'), (31, x'E0B69AE0B7B2'), (98, x'E0B79E'), (53, x'E0B6A7'), (41, x'E0B69B'), (67, x'E0B6B6'), (7, x'E0B68A'), (20, x'E0B682');
+SELECT predicted_order, hex(utf8mb4_encoding) FROM t1 ORDER BY utf8mb4_encoding COLLATE utf8mb4_sinhala_ci;
+predicted_order	hex(utf8mb4_encoding)
+1	E0B7B4
+2	E0B685
+3	E0B686
+4	E0B687
+5	E0B688
+6	E0B689
+7	E0B68A
+8	E0B68B
+9	E0B68C
+10	E0B68D
+11	E0B68E
+12	E0B68F
+13	E0B690
+14	E0B691
+15	E0B692
+16	E0B693
+17	E0B694
+18	E0B695
+19	E0B696
+20	E0B682
+21	E0B683
+22	E0B69A
+23	E0B69AE0B78F
+24	E0B69AE0B790
+25	E0B69AE0B791
+26	E0B69AE0B792
+27	E0B69AE0B793
+28	E0B69AE0B794
+29	E0B69AE0B796
+30	E0B69AE0B798
+31	E0B69AE0B7B2
+32	E0B69AE0B79F
+33	E0B69AE0B7B3
+34	E0B69AE0B799
+35	E0B69AE0B79A
+36	E0B69AE0B79B
+37	E0B69AE0B79C
+38	E0B69AE0B79D
+39	E0B69AE0B79E
+40	E0B69AE0B78A
+41	E0B69B
+42	E0B69C
+43	E0B69D
+44	E0B69E
+45	E0B69F
+46	E0B6A0
+47	E0B6A1
+48	E0B6A2
+49	E0B6A3
+50	E0B6A5
+51	E0B6A4
+52	E0B6A6
+53	E0B6A7
+54	E0B6A8
+55	E0B6A9
+56	E0B6AA
+57	E0B6AB
+58	E0B6AC
+59	E0B6AD
+60	E0B6AE
+61	E0B6AF
+62	E0B6B0
+63	E0B6B1
+64	E0B6B3
+65	E0B6B4
+66	E0B6B5
+67	E0B6B6
+68	E0B6B7
+69	E0B6B8
+70	E0B6B9
+71	E0B6BA
+72	E0B6BB
+73	E0B6BBE0B78AE2808D
+74	E0B6BD
+75	E0B780
+76	E0B781
+77	E0B782
+78	E0B783
+79	E0B784
+80	E0B785
+81	E0B786
+82	E0B78F
+83	E0B790
+84	E0B791
+85	E0B792
+86	E0B793
+87	E0B794
+88	E0B796
+89	E0B798
+90	E0B7B2
+91	E0B79F
+92	E0B7B3
+93	E0B799
+94	E0B79A
+95	E0B79B
+96	E0B79C
+97	E0B79D
+98	E0B79E
+99	E0B78A
+100	E0B78AE2808DE0B6BA
+101	E0B78AE2808DE0B6BB
+DROP TABLE t1;
+#
+# Bug#32914 Character sets: illegal characters in utf8mb4 and utf32 columns
+#
+create table t1 (utf8mb4 char(1) character set utf8mb4) engine MyISAM;
+Testing [F0][90..BF][80..BF][80..BF]
+insert into t1 values (0xF0908080);
+insert into t1 values (0xF0BFBFBF);
+insert into t1 values (0xF08F8080);
+Warnings:
+Warning	1366	Incorrect string value: '\xF0\x8F\x80\x80' for column 'utf8mb4' at row 1
+select hex(utf8mb4) from t1;
+hex(utf8mb4)
+
+F0908080
+F0BFBFBF
+delete from t1;
+Testing [F2..F3][80..BF][80..BF][80..BF]
+insert into t1 values (0xF2808080);
+insert into t1 values (0xF2BFBFBF);
+select hex(utf8mb4) from t1;
+hex(utf8mb4)
+F2808080
+F2BFBFBF
+delete from t1;
+Testing [F4][80..8F][80..BF][80..BF]
+insert into t1 values (0xF4808080);
+insert into t1 values (0xF48F8080);
+insert into t1 values (0xF4908080);
+Warnings:
+Warning	1366	Incorrect string value: '\xF4\x90\x80\x80' for column 'utf8mb4' at row 1
+select hex(utf8mb4) from t1;
+hex(utf8mb4)
+
+F4808080
+F48F8080
+drop table t1;
+#
+# Check strnxfrm() with odd length
+#
+set max_sort_length=5;
+select @@max_sort_length;
+@@max_sort_length
+5
+create table t1 (a varchar(128) character set utf8mb4 collate utf8mb4_general_ci) engine MyISAM;
+insert into t1 values ('a'),('b'),('c');
+select * from t1 order by a;
+a
+a
+b
+c
+alter table t1 modify a varchar(128) character set utf8mb4 collate utf8mb4_bin;
+select * from t1 order by a;
+a
+a
+b
+c
+drop table t1;
+set max_sort_length=default;
+#
+# Bug#26180: Can't add columns to tables created with utf8mb4 text indexes
+#
+CREATE TABLE t1 (
+clipid INT NOT NULL,
+Tape TINYTEXT,
+PRIMARY KEY (clipid),
+KEY tape(Tape(255))
+) CHARACTER SET=utf8mb4 ENGINE MyISAM;
+Warnings:
+Warning	1071	Specified key was too long; max key length is 1000 bytes
+ALTER TABLE t1 ADD mos TINYINT DEFAULT 0 AFTER clipid;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `clipid` int(11) NOT NULL,
+  `mos` tinyint(4) DEFAULT '0',
+  `Tape` tinytext,
+  PRIMARY KEY (`clipid`),
+  KEY `tape` (`Tape`(250))
+) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4
+DROP TABLE t1;
+#
+# Testing 4-byte values.
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+u_decimal int NOT NULL,
+utf8mb4_encoding VARCHAR(10) NOT NULL
+) CHARACTER SET utf8mb4 ENGINE MyISAM;
+INSERT INTO t1 VALUES (119040, x'f09d8480'),
+# G CLEF
+(119070, x'f09d849e'),
+# HALF NOTE
+(119134, x'f09d859e'),
+# MUSICAL SYMBOL CROIX
+(119247, x'f09d878f'),
+# MATHEMATICAL BOLD ITALIC CAPITAL DELTA
+(120607, x'f09d9c9f'),
+# SANS-SERIF BOLD ITALIC CAPITAL PI
+(120735, x'f09d9e9f'),
+# <Plane 16 Private Use, Last> (last 4 byte character)
+(1114111, x'f48fbfbf'),
+# VARIATION SELECTOR-256
+(917999, x'f3a087af');
+INSERT INTO t1 VALUES (119070, x'f09d849ef09d859ef09d859ef09d8480f09d859ff09d859ff09d859ff09d85a0f09d85a0f09d8480');
+INSERT INTO t1 VALUES (65131, x'efb9abf09d849ef09d859ef09d859ef09d8480f09d859fefb9abefb9abf09d85a0efb9ab');
+INSERT INTO t1 VALUES (119070, x'f09d849ef09d859ef09d859ef09d8480f09d859ff09d859ff09d859ff09d85a0f09d85a0f09d8480f09d85a0');
+Warnings:
+Warning	1265	Data truncated for column 'utf8mb4_encoding' at row 1
+SELECT u_decimal, hex(utf8mb4_encoding) FROM t1 ORDER BY utf8mb4_encoding COLLATE utf8mb4_general_ci, BINARY utf8mb4_encoding;
+u_decimal	hex(utf8mb4_encoding)
+1114111	F48FBFBF
+119040	F09D8480
+119070	F09D849E
+119070	F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480
+119070	F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480
+119134	F09D859E
+119247	F09D878F
+120607	F09D9C9F
+120735	F09D9E9F
+65131	EFB9ABF09D849EF09D859EF09D859EF09D8480F09D859FEFB9ABEFB9ABF09D85A0EFB9AB
+917999	F3A087AF
+INSERT INTO t1 VALUES (1114111, x'f5808080');
+Warnings:
+Warning	1366	Incorrect string value: '\xF5\x80\x80\x80' for column 'utf8mb4_encoding' at row 1
+SELECT character_maximum_length, character_octet_length FROM information_schema.columns WHERE
+table_name= 't1' AND column_name= 'utf8mb4_encoding';
+character_maximum_length	character_octet_length
+10	40
+DROP TABLE IF EXISTS t2;
+CREATE TABLE t2 (
+u_decimal int NOT NULL,
+utf8mb3_encoding VARCHAR(10) NOT NULL
+) CHARACTER SET utf8mb3 ENGINE MyISAM;
+INSERT INTO t2 VALUES (42856, x'ea9da8');
+INSERT INTO t2 VALUES (65131, x'efb9ab');
+INSERT INTO t2 VALUES (1114111, x'f48fbfbf');
+Warnings:
+Warning	1366	Incorrect string value: '\xF4\x8F\xBF\xBF' for column 'utf8mb3_encoding' at row 1
+SELECT character_maximum_length, character_octet_length FROM information_schema.columns WHERE
+table_name= 't2' AND column_name= 'utf8mb3_encoding';
+character_maximum_length	character_octet_length
+10	30
+UPDATE t2 SET utf8mb3_encoding= x'f48fbfbd' where u_decimal= 42856;
+Warnings:
+Warning	1366	Incorrect string value: '\xF4\x8F\xBF\xBD' for column 'utf8mb3_encoding' at row 1
+UPDATE t2 SET utf8mb3_encoding= _utf8mb4 x'ea9da8' where u_decimal= 42856;
+SELECT HEX(CONCAT(utf8mb4_encoding, _utf8 x'ea9da8')) FROM t1;
+HEX(CONCAT(utf8mb4_encoding, _utf8 x'ea9da8'))
+EA9DA8
+EFB9ABF09D849EF09D859EF09D859EF09D8480F09D859FEFB9ABEFB9ABF09D85A0EFB9ABEA9DA8
+F09D8480EA9DA8
+F09D849EEA9DA8
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480EA9DA8
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480EA9DA8
+F09D859EEA9DA8
+F09D878FEA9DA8
+F09D9C9FEA9DA8
+F09D9E9FEA9DA8
+F3A087AFEA9DA8
+F48FBFBFEA9DA8
+SELECT HEX(CONCAT(utf8mb4_encoding, utf8mb3_encoding)) FROM t1,t2;
+HEX(CONCAT(utf8mb4_encoding, utf8mb3_encoding))
+
+EA9DA8
+EFB9AB
+EFB9ABF09D849EF09D859EF09D859EF09D8480F09D859FEFB9ABEFB9ABF09D85A0EFB9AB
+EFB9ABF09D849EF09D859EF09D859EF09D8480F09D859FEFB9ABEFB9ABF09D85A0EFB9ABEA9DA8
+EFB9ABF09D849EF09D859EF09D859EF09D8480F09D859FEFB9ABEFB9ABF09D85A0EFB9ABEFB9AB
+F09D8480
+F09D8480EA9DA8
+F09D8480EFB9AB
+F09D849E
+F09D849EEA9DA8
+F09D849EEFB9AB
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480EA9DA8
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480EA9DA8
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480EFB9AB
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480EFB9AB
+F09D859E
+F09D859EEA9DA8
+F09D859EEFB9AB
+F09D878F
+F09D878FEA9DA8
+F09D878FEFB9AB
+F09D9C9F
+F09D9C9FEA9DA8
+F09D9C9FEFB9AB
+F09D9E9F
+F09D9E9FEA9DA8
+F09D9E9FEFB9AB
+F3A087AF
+F3A087AFEA9DA8
+F3A087AFEFB9AB
+F48FBFBF
+F48FBFBFEA9DA8
+F48FBFBFEFB9AB
+SELECT count(*) FROM t1, t2
+WHERE t1.utf8mb4_encoding > t2.utf8mb3_encoding;
+count(*)
+33
+ALTER TABLE t1 CONVERT TO CHARACTER SET utf8;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `u_decimal` int(11) NOT NULL,
+  `utf8mb4_encoding` varchar(10) NOT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=utf8
+SELECT u_decimal,hex(utf8mb4_encoding),utf8mb4_encoding FROM t1;
+u_decimal	hex(utf8mb4_encoding)	utf8mb4_encoding
+1114111		
+1114111	3F	?
+119040	3F	?
+119070	3F	?
+119070	3F3F3F3F3F3F3F3F3F3F	??????????
+119070	3F3F3F3F3F3F3F3F3F3F	??????????
+119134	3F	?
+119247	3F	?
+120607	3F	?
+120735	3F	?
+65131	EFB9AB3F3F3F3F3FEFB9ABEFB9AB3FEFB9AB	﹫?????﹫SET utf8mb4;
+SHOW CREATE TABLE t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `u_decimal` int(11) NOT NULL,
+  `utf8mb3_encoding` varchar(10) NOT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4
+SELECT u_decimal,hex(utf8mb3_encoding) FROM t2;
+u_decimal	hex(utf8mb3_encoding)
+1114111	
+42856	EA9DA8
+65131	EFB9AB
+ALTER TABLE t2 CONVERT TO CHARACTER SET utf8mb3;
+SHOW CREATE TABLE t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `u_decimal` int(11) NOT NULL,
+  `utf8mb3_encoding` varchar(10) NOT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=utf8
+SELECT u_decimal,hex(utf8mb3_encoding) FROM t2;
+u_decimal	hex(utf8mb3_encoding)
+1114111	
+42856	EA9DA8
+65131	EFB9AB
+ALTER TABLE t1 MODIFY utf8mb4_encoding VARCHAR(10) CHARACTER SET utf8mb3;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `u_decimal` int(11) NOT NULL,
+  `utf8mb4_encoding` varchar(10) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=utf8
+SELECT u_decimal,hex(utf8mb4_encoding) FROM t1;
+u_decimal	hex(utf8mb4_encoding)
+1114111	
+1114111	3F
+119040	3F
+119070	3F
+119070	3F3F3F3F3F3F3F3F3F3F
+119070	3F3F3F3F3F3F3F3F3F3F
+119134	3F
+119247	3F
+120607	3F
+120735	3F
+65131	EFB9AB3F3F3F3F3FEFB9ABEFB9AB3FEFB9AB
+917999	3F
+ALTER TABLE t1 MODIFY utf8mb4_encoding VARCHAR(10) CHARACTER SET utf8mb4;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `u_decimal` int(11) NOT NULL,
+  `utf8mb4_encoding` varchar(10) CHARACTER SET utf8mb4 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=utf8
+SELECT u_decimal,hex(utf8mb4_encoding) FROM t1;
+u_decimal	hex(utf8mb4_encoding)
+1114111	
+1114111	3F
+119040	3F
+119070	3F
+119070	3F3F3F3F3F3F3F3F3F3F
+119070	3F3F3F3F3F3F3F3F3F3F
+119134	3F
+119247	3F
+120607	3F
+120735	3F
+65131	EFB9AB3F3F3F3F3FEFB9ABEFB9AB3FEFB9AB
+917999	3F
+ALTER TABLE t2 MODIFY utf8mb3_encoding VARCHAR(10) CHARACTER SET utf8mb4;
+SHOW CREATE TABLE t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `u_decimal` int(11) NOT NULL,
+  `utf8mb3_encoding` varchar(10) CHARACTER SET utf8mb4 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=utf8
+SELECT u_decimal,hex(utf8mb3_encoding) FROM t2;
+u_decimal	hex(utf8mb3_encoding)
+1114111	
+42856	EA9DA8
+65131	EFB9AB
+DROP TABLE IF EXISTS t3;
+CREATE TABLE t3 (
+u_decimal int NOT NULL,
+utf8mb3_encoding VARCHAR(10) NOT NULL
+) CHARACTER SET utf8 ENGINE MyISAM;
+INSERT INTO t3 SELECT * FROM t1;
+DROP TABLE IF EXISTS t4;
+CREATE TABLE t4 (
+u_decimal int NOT NULL,
+utf8mb4_encoding VARCHAR(10) NOT NULL
+) CHARACTER SET utf8mb4 ENGINE MyISAM;
+INSERT INTO t3 SELECT * FROM t2;
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+DROP TABLE t4;
+#
+# Testing that mixing utf8 and utf8mb4 collations returns utf8mb4
+#
+SELECT CHARSET(CONCAT(_utf8mb4'a',_utf8'b'));
+CHARSET(CONCAT(_utf8mb4'a',_utf8'b'))
+utf8mb4
+CREATE TABLE t1 (utf8mb4 VARCHAR(10) CHARACTER SET utf8mb4 NOT NULL) ENGINE MyISAM;
+INSERT INTO t1 VALUES (x'ea9da8'),(x'f48fbfbf');
+SELECT CONCAT(utf8mb4, _utf8 x'ea9da8') FROM t1 LIMIT 0;
+CONCAT(utf8mb4, _utf8 x'ea9da8')
+CREATE TABLE t2 (utf8mb3 VARCHAR(10) CHARACTER SET utf8mb3 NOT NULL) ENGINE MyISAM;
+INSERT INTO t2 VALUES (x'ea9da8');
+SELECT HEX(CONCAT(utf8mb4, utf8mb3)) FROM t1,t2 ORDER BY 1;
+HEX(CONCAT(utf8mb4, utf8mb3))
+EA9DA8EA9DA8
+F48FBFBFEA9DA8
+SELECT CHARSET(CONCAT(utf8mb4, utf8mb3)) FROM t1, t2 LIMIT 1;
+CHARSET(CONCAT(utf8mb4, utf8mb3))
+utf8mb4
+CREATE TEMPORARY TABLE t3 ENGINE MyISAM AS SELECT *, concat(utf8mb4,utf8mb3) FROM t1, t2;
+SHOW CREATE TABLE t3;
+Table	Create Table
+t3	CREATE TEMPORARY TABLE `t3` (
+  `utf8mb4` varchar(10) CHARACTER SET utf8mb4 NOT NULL,
+  `utf8mb3` varchar(10) CHARACTER SET utf8 NOT NULL,
+  `concat(utf8mb4,utf8mb3)` varchar(20) CHARACTER SET utf8mb4 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TEMPORARY TABLE t3;
+SELECT * FROM t1, t2 WHERE t1.utf8mb4 > t2.utf8mb3;
+utf8mb4	utf8mb3
+􏿿	Ꝩ
+SELECT * FROM t1, t2 WHERE t1.utf8mb4 = t2.utf8mb3;
+utf8mb4	utf8mb3
+Ꝩ	Ꝩ
+SELECT * FROM t1, t2 WHERE t1.utf8mb4 < t2.utf8mb3;
+utf8mb4	utf8mb3
+DROP TABLE t1;
+DROP TABLE t2;
+#
+# Check that mixing utf8mb4 with an invalid utf8 constant returns error
+#
+CREATE TABLE t1 (utf8mb4 VARCHAR(10) CHARACTER SET utf8mb4) ENGINE MyISAM;
+INSERT INTO t1 VALUES (x'f48fbfbf');
+SELECT CONCAT(utf8mb4, _utf8 '�') FROM t1;
+ERROR HY000: Illegal mix of collations (utf8mb4_general_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation 'concat'
+SELECT CONCAT('a', _utf8 '�') FROM t1;
+ERROR HY000: Illegal mix of collations (utf8mb4_general_ci,COERCIBLE) and (utf8_general_ci,COERCIBLE) for operation 'concat'
+DROP TABLE t1;
+#
+# End of 5.5 tests
+#
+#
+# End of tests
+#

=== added file 'mysql-test/r/ctype_utf8mb4_ndb.result'
--- a/mysql-test/r/ctype_utf8mb4_ndb.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/ctype_utf8mb4_ndb.result	2010-03-05 08:17:19 +0000
@@ -0,0 +1,1876 @@
+drop table if exists t1,t2;
+#
+# Start of 5.5 tests
+#
+set names utf8mb4;
+select left(_utf8mb4 0xD0B0D0B1D0B2,1);
+left(_utf8mb4 0xD0B0D0B1D0B2,1)
+а
+select right(_utf8mb4 0xD0B0D0B2D0B2,1);
+right(_utf8mb4 0xD0B0D0B2D0B2,1)
+в
+select locate('he','hello');
+locate('he','hello')
+1
+select locate('he','hello',2);
+locate('he','hello',2)
+0
+select locate('lo','hello',2);
+locate('lo','hello',2)
+4
+select locate('HE','hello');
+locate('HE','hello')
+1
+select locate('HE','hello',2);
+locate('HE','hello',2)
+0
+select locate('LO','hello',2);
+locate('LO','hello',2)
+4
+select locate('HE','hello' collate utf8mb4_bin);
+locate('HE','hello' collate utf8mb4_bin)
+0
+select locate('HE','hello' collate utf8mb4_bin,2);
+locate('HE','hello' collate utf8mb4_bin,2)
+0
+select locate('LO','hello' collate utf8mb4_bin,2);
+locate('LO','hello' collate utf8mb4_bin,2)
+0
+select locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D0B1D0B2);
+locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D0B1D0B2)
+2
+select locate(_utf8mb4 0xD091, _utf8mb4 0xD0B0D0B1D0B2);
+locate(_utf8mb4 0xD091, _utf8mb4 0xD0B0D0B1D0B2)
+2
+select locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D091D0B2);
+locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D091D0B2)
+2
+select locate(_utf8mb4 0xD091, _utf8mb4 0xD0B0D0B1D0B2 collate utf8mb4_bin);
+locate(_utf8mb4 0xD091, _utf8mb4 0xD0B0D0B1D0B2 collate utf8mb4_bin)
+0
+select locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D091D0B2 collate utf8mb4_bin);
+locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D091D0B2 collate utf8mb4_bin)
+0
+select length(_utf8mb4 0xD0B1), bit_length(_utf8mb4 0xD0B1), char_length(_utf8mb4 0xD0B1);
+length(_utf8mb4 0xD0B1)	bit_length(_utf8mb4 0xD0B1)	char_length(_utf8mb4 0xD0B1)
+2	16	1
+select 'a' like 'a';
+'a' like 'a'
+1
+select 'A' like 'a';
+'A' like 'a'
+1
+select 'A' like 'a' collate utf8mb4_bin;
+'A' like 'a' collate utf8mb4_bin
+0
+select _utf8mb4 0xD0B0D0B1D0B2 like concat(_utf8mb4'%',_utf8mb4 0xD0B1,_utf8mb4 '%');
+_utf8mb4 0xD0B0D0B1D0B2 like concat(_utf8mb4'%',_utf8mb4 0xD0B1,_utf8mb4 '%')
+1
+select convert(_latin1'G�Andr�using utf8mb4) like CONVERT(_latin1'G�TER%' USING utf8mb4);
+convert(_latin1'G?nter Andr?' using utf8mb4) like CONVERT(_latin1'G?NTER%' USING utf8mb4)
+1
+select CONVERT(_koi8r'��' USING utf8mb4) LIKE CONVERT(_koi8r'LIKE CONVERT(_koi8r'????' USING utf8mb4)
+1
+select CONVERT(_koi8r'�' USING utf8mb4) LIKE CONVERT(_koi8r'��' USING utf8mb4);
+CONVERT(_koi8r'????' USING utf8mb4) LIKE CONVERT(_koi8r'????' USING utf8mb4)
+1
+SELECT 'a' = 'a ';
+'a' = 'a '
+1
+SELECT 'a\0' < 'a';
+'a\0' < 'a'
+1
+SELECT 'a\0' < 'a ';
+'a\0' < 'a '
+1
+SELECT 'a\t' < 'a';
+'a\t' < 'a'
+1
+SELECT 'a\t' < 'a ';
+'a\t' < 'a '
+1
+SELECT 'a' = 'a ' collate utf8mb4_bin;
+'a' = 'a ' collate utf8mb4_bin
+1
+SELECT 'a\0' < 'a' collate utf8mb4_bin;
+'a\0' < 'a' collate utf8mb4_bin
+1
+SELECT 'a\0' < 'a ' collate utf8mb4_bin;
+'a\0' < 'a ' collate utf8mb4_bin
+1
+SELECT 'a\t' < 'a' collate utf8mb4_bin;
+'a\t' < 'a' collate utf8mb4_bin
+1
+SELECT 'a\t' < 'a ' collate utf8mb4_bin;
+'a\t' < 'a ' collate utf8mb4_bin
+1
+CREATE TABLE t1 (a char(10) character set utf8mb4 not null) ENGINE ndb;
+INSERT INTO t1 VALUES ('a'),('a\0'),('a\t'),('a ');
+SELECT hex(a),STRCMP(a,'a'), STRCMP(a,'a ') FROM t1;
+hex(a)	STRCMP(a,'a')	STRCMP(a,'a ')
+61	0	0
+61	0	0
+6100	-1	-1
+6109	-1	-1
+DROP TABLE t1;
+select insert('txs',2,1,'hi'),insert('is ',4,0,'a'),insert('txxxxt',2,4,'es');
+insert('txs',2,1,'hi')	insert('is ',4,0,'a')	insert('txxxxt',2,4,'es')
+this	is a	test
+select insert("aa",100,1,"b"),insert("aa",1,3,"b");
+insert("aa",100,1,"b")	insert("aa",1,3,"b")
+aa	b
+select char_length(left(@a:='тес5))	length(@a)	@a
+4	8	тест
+create table t1 ENGINE ndb 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")` varchar(10) CHARACTER SET utf8mb4 DEFAULT NULL
+) ENGINE=ndbcluster 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 utf8mb4;
+set LC_TIME_NAMES='fr_FR';
+create table t1 (s1 char(20) character set latin1) engine ndb;
+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) engine ndb;
+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
+E6C5D7	ФC5C4C5CCD8CEC9CB	Понедельник
+drop table t1;
+set LC_TIME_NAMES='en_US';
+set names koi8r;
+create table t1 (s1 char(1) character set utf8mb4) engine ndb;
+insert into t1 values (_koi8r'�');
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+select s1,hex(s1),char_length(s1),octet_length(s1) from t1;
+s1	hex(s1)	char_length(s1)	octet_length(s1)
+�D0B0	1	2
+drop table t1;
+create table t1 (s1 tinytext character set utf8mb4) engine ndb;
+Warnings:
+Warning	1478	Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK'
+insert into t1 select repeat('a',300);
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+insert into t1 select repeat('�,300);
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+insert into t1 select repeat('amn 's1' at row 1
+insert into t1 select repeat('�',300);
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+insert into t1 select repeat('�',300);
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+select hex(s1) from t1;
+hex(s1)
+616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161
+61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F
+D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61
+D18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18F
+D18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18F
+select length(s1),char_length(s1) from t1;
+length(s1)	char_length(s1)
+254	127
+254	127
+255	170
+255	170
+255	255
+drop table t1;
+create table t1 (s1 text character set utf8mb4) engine ndb;
+Warnings:
+Warning	1478	Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK'
+insert into t1 select repeat('a',66000);
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+insert into t1 select repeat('�,66000);
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+insert into t1 select repeat('a�,66000);
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+insert into t1 select repeat('�',66000);
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+insert into t1 select repeat('�',66000);
+Warnings:
+Warning	1265	Data truncated for column 's1' at row 1
+select length(s1),char_length(s1) from t1;
+length(s1)	char_length(s1)
+65534	32767
+65534	32767
+65535	43690
+65535	43690
+65535	65535
+drop table t1;
+create table t1 (s1 char(10) character set utf8mb4) engine ndb;
+insert into t1 values (0x41FF);
+Warnings:
+Warning	1366	Incorrect string value: '\xFF' for column 's1' at row 1
+select hex(s1) from t1;
+hex(s1)
+41
+drop table t1;
+create table t1 (s1 varchar(10) character set utf8mb4) engine ndb;
+insert into t1 values (0x41FF);
+Warnings:
+Warning	1366	Incorrect string value: '\xFF' for column 's1' at row 1
+select hex(s1) from t1;
+hex(s1)
+41
+drop table t1;
+create table t1 (s1 text character set utf8mb4) engine ndb;
+Warnings:
+Warning	1478	Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK'
+insert into t1 values (0x41FF);
+Warnings:
+Warning	1366	Incorrect string value: '\xFF' for column 's1' at row 1
+select hex(s1) from t1;
+hex(s1)
+41
+drop table t1;
+create table t1 (a text character set utf8mb4, primary key(a(371))) engine ndb;
+ERROR 42000: BLOB column 'a' can't be used in key specification with the used table type
+CREATE TABLE t1 ( a varchar(10) ) CHARACTER SET utf8mb4 ENGINE ndb;
+INSERT INTO t1 VALUES ( 'test' );
+SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = b.a;
+a	a
+test	test
+SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = 'test' and b.a = 'test';
+a	a
+test	test
+SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = b.a and a.a = 'test';
+a	a
+test	test
+DROP TABLE t1;
+create table t1 (a char(255) character set utf8mb4) engine ndb;
+insert into t1 values('b'),('b');
+select * from t1 where a = 'b';
+a
+b
+b
+select * from t1 where a = 'b' and a = 'b';
+a
+b
+b
+select * from t1 where a = 'b' and a != 'b';
+a
+drop table t1;
+set collation_connection=utf8mb4_general_ci;
+drop table if exists t1;
+create table t1 as
+select repeat(' ', 64) as s1, repeat(' ',64) as s2
+union
+select null, null;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `s1` varchar(64) CHARACTER SET utf8mb4 DEFAULT NULL,
+  `s2` varchar(64) CHARACTER SET utf8mb4 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+delete from t1;
+insert into t1 values('aaa','aaa');
+insert into t1 values('aaa|qqq','qqq');
+insert into t1 values('gheis','^[^a-dXYZ]+$');
+insert into t1 values('aab','^aa?b');
+insert into t1 values('Baaan','^Ba*n');
+insert into t1 values('aaa','qqq|aaa');
+insert into t1 values('qqq','qqq|aaa');
+insert into t1 values('bbb','qqq|aaa');
+insert into t1 values('bbb','qqq');
+insert into t1 values('aaa','aba');
+insert into t1 values(null,'abc');
+insert into t1 values('def',null);
+insert into t1 values(null,null);
+insert into t1 values('ghi','ghi[');
+select HIGH_PRIORITY s1 regexp s2 from t1;
+s1 regexp s2
+1
+1
+1
+1
+1
+1
+1
+0
+0
+0
+NULL
+NULL
+NULL
+NULL
+drop table t1;
+set names utf8mb4;
+set names utf8mb4;
+select  'ike '[[:<:]]вася[[:>:]]'
+1
+select  'вася ' rlike '[[:<:]]вася[[:>:]]';
+'вася ' rlike '[[:<:]]вася[[:>:]]'
+1
+select ' вася'  rlike '[[:<:]]вася[[:>:]]';
+' вася'  rlike '[[:<:]]вася[[:>:]]'
+1
+select ' вася ' rlike '[[:<:]]вася[[:>:]]';
+' вася ' rlike '[[:<:]]вася[[:>:]]'
+1
+select  'васяz' rlike '[[:<:]]вася[[:>:]]';
+'васяz' rlike '[[:<:]]вася[[:>:]]'
+0
+select 'zвася'  rlike '[[:<:]]вася[[:>:]]';
+'zвася'  rlike '[[:<:]]вася[[:>:]]'
+0
+select 'zвасяz' rlike '[[:<:]]вася[[:>:]]';
+'zвасяz' rlike '[[:<:]]вася[[:>:]]'
+0
+CREATE TABLE t1 (a enum ('Y', 'N') DEFAULT 'N' COLLATE utf8mb4_unicode_ci) ENGINE ndb;
+ALTER TABLE t1 ADD COLUMN b CHAR(20);
+DROP TABLE t1;
+set names utf8mb4;
+create table t1 (a enum('aaaa','проба') character set utf8mb4) engine ndb;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` enum('aaaa','проба') CHARACTER SET utf8mb4 DEFAULT NULL
+) ENGINE=ndbcluster DEFAULT CHARSET=latin1
+insert into t1 values ('проба');
+select * from t1;
+a
+проба
+create table t2 engine ndb select ifnull(a,a) from t1;
+show create table t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `ifnull(a,a)` varchar(5) CHARACTER SET utf8mb4 DEFAULT NULL
+) ENGINE=ndbcluster DEFAULT CHARSET=latin1
+select * from t2;
+ifnull(a,a)
+проба
+drop table t1;
+drop table t2;
+create table t1 (
+str varchar(255) character set utf8mb4 not null,
+key str  (str(2))
+) engine=ndb;
+INSERT INTO t1 VALUES ('str');
+INSERT INTO t1 VALUES ('str2');
+select * from t1 where str='str';
+str
+str
+drop table t1;
+create table t1 (
+str varchar(255) character set utf8mb4 not null,
+key str  (str(2))
+) engine=ndb;
+INSERT INTO t1 VALUES ('str');
+INSERT INTO t1 VALUES ('str2');
+select * from t1 where str='str';
+str
+str
+drop table t1;
+create table t1 (
+str varchar(255) character set utf8mb4 not null,
+key str using btree (str(2))
+) engine=ndb;
+INSERT INTO t1 VALUES ('str');
+INSERT INTO t1 VALUES ('str2');
+select * from t1 where str='str';
+str
+str
+drop table t1;
+CREATE TABLE t1 (a varchar(32) BINARY) CHARACTER SET utf8mb4 ENGINE ndb;
+INSERT INTO t1 VALUES ('test');
+SELECT a FROM t1 WHERE a LIKE '%te';
+a
+DROP TABLE t1;
+SET NAMES utf8mb4;
+CREATE TABLE t1 (
+subject varchar(255) character set utf8mb4 collate utf8mb4_unicode_ci,
+p varchar(15) character set utf8mb4
+) ENGINE= ndb DEFAULT CHARSET=latin1;
+INSERT INTO t1 VALUES ('谷川俊二と申しますが、インターネッた。どうすればよいですか? その他、住+INSERT INTO t1 VALUES ('aaa','bbb');
+SELECT length(subject) FROM t1;
+length(subject)
+3
+432
+SELECT length(subject) FROM t1 ORDER BY 1;
+length(subject)
+3
+432
+DROP TABLE t1;
+set names utf8mb4;
+create table t1 (
+a int primary key,
+b varchar(6),
+index b3(b(3))
+) engine=ndb character set=utf8mb4;
+insert into t1 values(1,'foo'),(2,'foobar');
+select * from t1 where b like 'foob%';
+a	b
+2	foobar
+alter table t1 engine=innodb;
+select * from t1 where b like 'foob%';
+a	b
+2	foobar
+drop table t1;
+create table t1 (
+a enum('петя','вася','анют+b set('петя','вася','анюта') character set utf8mb4 not null default 'анюта'
+) engine ndb;
+create table t2 engine ndb select concat(a,_utf8mb4'') as a, concat(b,_utf8mb4'')as b from t1;
+show create table t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `a` varchar(5) CHARACTER SET utf8mb4 NOT NULL DEFAULT '',
+  `b` varchar(15) CHARACTER SET utf8mb4 NOT NULL DEFAULT ''
+) ENGINE=ndbcluster DEFAULT CHARSET=latin1
+drop table t2;
+drop table t1;
+select 'c' like '\_' as want0;
+want0
+0
+SELECT SUBSTR('вася',-2);
+SUBSTR('вася',-2)
+ся
+create table t1 (id integer, a varchar(100) character set utf8mb4 collate utf8mb4_unicode_ci) engine ndb;
+insert into t1 values (1, 'Test');
+select * from t1 where soundex(a) = soundex('Test');
+id	a
+1	Test
+select * from t1 where soundex(a) = soundex('TEST');
+id	a
+1	Test
+select * from t1 where soundex(a) = soundex('test');
+id	a
+1	Test
+drop table t1;
+select soundex(_utf8mb4 0xE99885E8A788E99A8FE697B6E69BB4E696B0E79A84E696B0E997BB);
+soundex(_utf8mb4 0xE99885E8A788E99A8FE697B6E69BB4E696B0E79A84E696B0E997BB)
+阅000
+select hex(soundex(_utf8mb4 0xE99885E8A788E99A8FE697B6E69BB4E696B0E79A84E696B0E997BB));
+hex(soundex(_utf8mb4 0xE99885E8A788E99A8FE697B6E69BB4E696B0E79A84E696B0E997BB))
+E99885303030
+select soundex(_utf8mb4 0xD091D092D093);
+soundex(_utf8mb4 0xD091D092D093)
+Б000
+select hex(soundex(_utf8mb4 0xD091D092D093));
+hex(soundex(_utf8mb4 0xD091D092D093))
+D091303030
+SET collation_connection='utf8mb4_general_ci';
+create table t1 select repeat('a',4000) a;
+delete from t1;
+insert into t1 values ('a'), ('a '), ('a\t');
+select collation(a),hex(a) from t1 order by a;
+collation(a)	hex(a)
+utf8mb4_general_ci	6109
+utf8mb4_general_ci	61
+utf8mb4_general_ci	6120
+drop table t1;
+select @@collation_connection;
+@@collation_connection
+utf8mb4_general_ci
+create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ;
+insert into t1 values('abcdef');
+insert into t1 values('_bcdef');
+insert into t1 values('a_cdef');
+insert into t1 values('ab_def');
+insert into t1 values('abc_ef');
+insert into t1 values('abcd_f');
+insert into t1 values('abcde_');
+select c1 as c1u from t1 where c1 like 'ab\_def';
+c1u
+ab_def
+select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
+c2h
+ab_def
+drop table t1;
+drop table if exists t1;
+create table t1 as select repeat(' ', 64) as s1;
+select collation(s1) from t1;
+collation(s1)
+utf8mb4_general_ci
+delete from t1;
+insert into t1 values ('a'),('ae'),(_latin1 0xE4);
+insert into t1 values ('o'),('oe'),(_latin1 0xF6);
+insert into t1 values ('s'),('ss'),(_latin1 0xDF);
+insert into t1 values ('u'),('ue'),(_latin1 0xFC);
+select s1, hex(s1) from t1 order by s1, binary s1;
+s1	hex(s1)
+a	61
+ä	C3A4
+ae	6165
+o	6F
+ö	C3B6
+oe	6F65
+s	73
+ß	C39F
+ss	7373
+u	75
+ü	C3BC
+ue	7565
+select group_concat(s1 order by binary s1) from t1 group by s1;
+group_concat(s1 order by binary s1)
+a,ä
+ae
+o,ö
+oe
+s,ß
+ss
+u,ü
+ue
+drop table t1;
+SET collation_connection='utf8mb4_bin';
+create table t1 select repeat('a',4000) a;
+delete from t1;
+insert into t1 values ('a'), ('a '), ('a\t');
+select collation(a),hex(a) from t1 order by a;
+collation(a)	hex(a)
+utf8mb4_bin	6109
+utf8mb4_bin	61
+utf8mb4_bin	6120
+drop table t1;
+select @@collation_connection;
+@@collation_connection
+utf8mb4_bin
+create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ;
+insert into t1 values('abcdef');
+insert into t1 values('_bcdef');
+insert into t1 values('a_cdef');
+insert into t1 values('ab_def');
+insert into t1 values('abc_ef');
+insert into t1 values('abcd_f');
+insert into t1 values('abcde_');
+select c1 as c1u from t1 where c1 like 'ab\_def';
+c1u
+ab_def
+select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
+c2h
+ab_def
+drop table t1;
+CREATE TABLE t1 (
+user varchar(255) NOT NULL default ''
+) ENGINE=ndb DEFAULT CHARSET=latin1;
+INSERT INTO t1 VALUES ('one'),('two');
+SELECT CHARSET('a');
+CHARSET('a')
+utf8mb4
+SELECT user, CONCAT('<', user, '>') AS c FROM t1;
+user	c
+one	<one>
+two	<two>
+DROP TABLE t1;
+create table t1 (f1 varchar(1) not null) default charset utf8mb4 engine ndb;
+insert into t1 values (''), ('');
+select concat(concat(_latin1'->',f1),_latin1'<-') from t1;
+concat(concat(_latin1'->',f1),_latin1'<-')
+-><-
+-><-
+drop table t1;
+select convert(_koi8r'� using utf8mb4) < convert(_koi8r'� using utf8mb4);
+convert(_koi8r'?' using utf8mb4) < convert(_koi8r'?' using utf8mb4)
+1
+set names latin1;
+create table t1 (a varchar(10)) character set utf8mb4 engine ndb;
+insert into t1 values ('test');
+select ifnull(a,'') from t1;
+ifnull(a,'')
+test
+drop table t1;
+select repeat(_utf8mb4'+',3) as h union select NULL;
+h
++++
+NULL
+select ifnull(NULL, _utf8mb4'string');
+ifnull(NULL, _utf8mb4'string')
+string
+set names utf8mb4;
+create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_lithuanian_ci) engine ndb;
+insert into t1 values ('I'),('K'),('Y');
+select * from t1 where s1 < 'K' and s1 = 'Y';
+s1
+I
+Y
+select * from t1 where 'K' > s1 and s1 = 'Y';
+s1
+I
+Y
+drop table t1;
+create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_czech_ci) engine ndb;
+insert into t1 values ('c'),('d'),('h'),('ch'),('CH'),('cH'),('Ch'),('i');
+select * from t1 where s1 > 'd' and s1 = 'CH';
+s1
+CH
+Ch
+ch
+select * from t1 where 'd' < s1 and s1 = 'CH';
+s1
+CH
+Ch
+ch
+select * from t1 where s1 = 'cH' and s1 <> 'ch';
+s1
+cH
+select * from t1 where 'cH' = s1 and s1 <> 'ch';
+s1
+cH
+drop table t1;
+create table t1 (a varchar(255)) default character set utf8mb4 engine ndb;
+insert into t1 values (1.0);
+drop table t1;
+create table t1 (
+id int not null,
+city varchar(20) not null,
+key (city(7),id)
+) character set=utf8mb4 engine ndb;
+insert into t1 values (1,'Durban North');
+insert into t1 values (2,'Durban');
+select * from t1 where city = 'Durban';
+id	city
+2	Durban
+select * from t1 where city = 'Durban ';
+id	city
+2	Durban
+drop table t1;
+create table t1 (x set('A', 'B') default 0) character set utf8mb4 engine ndb;
+ERROR 42000: Invalid default value for 'x'
+create table t1 (x enum('A', 'B') default 0) character set utf8mb4 engine ndb;
+ERROR 42000: Invalid default value for 'x'
+SET NAMES UTF8;
+CREATE TABLE t1 (
+`id` int(20) NOT NULL auto_increment,
+`country` varchar(100) NOT NULL default '',
+`shortcode` varchar(100) NOT NULL default '',
+`operator` varchar(100) NOT NULL default '',
+`momid` varchar(30) NOT NULL default '',
+`keyword` varchar(160) NOT NULL default '',
+`content` varchar(160) NOT NULL default '',
+`second_token` varchar(160) default NULL,
+`gateway_id` int(11) NOT NULL default '0',
+`created` datetime NOT NULL default '0000-00-00 00:00:00',
+`msisdn` varchar(15) NOT NULL default '',
+PRIMARY KEY  (`id`),
+UNIQUE KEY `MSCCSPK_20030521130957121` (`momid`),
+KEY `IX_mobile_originated_message_keyword` (`keyword`),
+KEY `IX_mobile_originated_message_created` (`created`),
+KEY `IX_mobile_originated_message_support` (`msisdn`,`momid`,`keyword`,`gateway_id`,`created`)
+) ENGINE=ndb DEFAULT CHARSET=utf8mb4;
+INSERT INTO t1 VALUES 
+(1,'blah','464','aaa','fkc1c9ilc20x0hgae7lx6j09','ERR','ERR Имри.Афимим.Аеимимримдмримрмрирор имримримримр имридм ирбднримрфмририримрфмфмим.Ад.Д имдимримрад.Адимримримрмдиримримримр м.Дадимфшьмримд им.АдимимрДМРИМРМРИРОР',3,'2005-06-01 17:30:43','1234567890'),
+(2,'blah','464','aaa','haxpl2ilc20x00bj4tt2m5ti','11','11 g','G',3,'2005-06-02 22:43:10','1234567890');
+CREATE TABLE t2 (
+`msisdn` varchar(15) NOT NULL default '',
+`operator_id` int(11) NOT NULL default '0',
+`created` datetime NOT NULL default '0000-00-00 00:00:00',
+UNIQUE KEY `PK_user` (`msisdn`)
+) ENGINE=ndb DEFAULT CHARSET=utf8mb4;
+INSERT INTO t2 VALUES ('1234567890',2,'2005-05-24 13:53:25');
+SELECT content, t2.msisdn FROM t1, t2 WHERE t1.msisdn = '1234567890';
+content	msisdn
+ERR Имри.Афимим.Аеимимримдмримрмриром.Дадимфшьмримд им.Адимимрн имreate table t1 (a char(20) character set utf8mb4) engine ndb;
+insert into t1 values ('123456'),('андрей');
+alter table t1 modify a char(2) character set utf8mb4;
+Warnings:
+Warning	1265	Data truncated for column 'a' at row 1
+Warning	1265	Data truncated for column 'a' at row 2
+select char_length(a), length(a), a from t1 order by a;
+char_length(a)	length(a)	a
+2	2	12
+2	4	ан
+drop table t1;
+set names utf8mb4;
+select 'andre%' like 'andreñ%' escape 'ñ';
+'andre%' like 'andreñ%' escape 'ñ'
+1
+set names utf8mb4;
+select 'a\\' like 'a\\';
+'a\\' like 'a\\'
+1
+select 'aa\\' like 'a%\\';
+'aa\\' like 'a%\\'
+1
+create table t1 (a char(10), key(a)) character set utf8mb4 engine ndb;
+insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test");
+select * from t1 where a like "abc%";
+a
+abc
+abcd
+select * from t1 where a like concat("abc","%");
+a
+abc
+abcd
+select * from t1 where a like "ABC%";
+a
+abc
+abcd
+select * from t1 where a like "test%";
+a
+test
+select * from t1 where a like "te_t";
+a
+test
+select * from t1 where a like "%a%";
+a
+a
+abc
+abcd
+select * from t1 where a like "%abcd%";
+a
+abcd
+select * from t1 where a like "%abc\d%";
+a
+abcd
+drop table t1;
+CREATE TABLE t1 (
+a varchar(255) NOT NULL default '',
+KEY a (a)
+) ENGINE=ndb DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;
+insert into t1 values (_utf8mb4 0xe880bd);
+insert into t1 values (_utf8mb4 0x5b);
+select hex(a) from t1;
+hex(a)
+5B
+E880BD
+drop table t1;
+set names 'latin1';
+create table t1 (a varchar(255)) default charset=utf8mb4 engine ndb;
+select * from t1 where find_in_set('-1', a);
+a
+drop table t1;
+create table t1 (a int) engine ndb;
+insert into t1 values (48),(49),(50);
+set names utf8mb4;
+select distinct char(a) from t1;
+char(a)
+0
+1
+2
+drop table t1;
+CREATE TABLE t1 (t TINYTEXT CHARACTER SET utf8mb4) ENGINE ndb;
+Warnings:
+Warning	1478	Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK'
+INSERT INTO t1 VALUES(REPEAT('a', 100));
+CREATE TABLE t2 ENGINE ndb SELECT COALESCE(t) AS bug FROM t1;
+Warnings:
+Warning	1478	Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK'
+SELECT LENGTH(bug) FROM t2;
+LENGTH(bug)
+100
+DROP TABLE t2;
+DROP TABLE t1;
+CREATE TABLE t1 (item varchar(255)) default character set utf8mb4 ENGINE ndb;
+INSERT INTO t1 VALUES (N'\\');
+INSERT INTO t1 VALUES (_utf8mb4'\\');
+INSERT INTO t1 VALUES (N'Cote d\'Ivoire');
+INSERT INTO t1 VALUES (_utf8mb4'Cote d\'Ivoire');
+SELECT item FROM t1 ORDER BY item;
+item
+Cote d'Ivoire
+Cote d'Ivoire
+\
+\
+DROP TABLE t1;
+SET NAMES utf8mb4;
+DROP TABLE IF EXISTS t1;
+Warnings:
+Note	1051	Unknown table 't1'
+CREATE TABLE t1(a VARCHAR(255), KEY(a)) ENGINE=ndb DEFAULT CHARSET=utf8mb4;
+INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb');
+INSERT INTO t1 VALUES('uu');
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	note	The storage engine for the table doesn't support check
+INSERT INTO t1 VALUES('uU');
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	note	The storage engine for the table doesn't support check
+INSERT INTO t1 VALUES('uu');
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	note	The storage engine for the table doesn't support check
+INSERT INTO t1 VALUES('uuABC');
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	note	The storage engine for the table doesn't support check
+INSERT INTO t1 VALUES('UuABC');
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	note	The storage engine for the table doesn't support check
+INSERT INTO t1 VALUES('uuABC');
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	note	The storage engine for the table doesn't support check
+alter table t1 add b int;
+INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',1);
+INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',2);
+delete from t1 where b=1;
+INSERT INTO t1 VALUES('UUABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',1);
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	note	The storage engine for the table doesn't support check
+INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',3);
+INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',4);
+delete from t1 where b=3;
+INSERT INTO t1 VALUES('uUABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',3);
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	note	The storage engine for the table doesn't support check
+drop table t1;
+set names utf8mb4;
+create table t1 (s1 char(5) character set utf8mb4) engine ndb;
+insert into t1 values
+('a'),('b'),(null),('ペテルグル'),('ü'),('Y');
+create index it1 on t1 (s1);
+select s1 as before_delete_general_ci from t1 where s1 like 'ペテ%';
+before_delete_general_ci
+ペテer_delete_general_ci from t1 where s1 like 'ペテ%';
+after_delete_general_ci
+ペテルグル
+drop table t1;
+set names utf8mb4;
+create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_unicode_ci) engine ndb;
+insert into t1 values
+('a'),('b'),(null),('ペテルグル'),('ü'),('Y');
+create index it1 on t1 (s1);
+select s1 as before_delete_unicode_ci from t1 where s1 like 'ペテ%';
+before_delete_unicode_ci
+ペテルグル
+delete from t1 where s1 = 'Y';
+select s1 as after_delete_unicode_ci from t1 where s1 like 'ペテ%';
+after_delete_unicode_ci
+ペテルグル
+drop table t1;
+set names utf8mb4;
+create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_bin) engine ndb;
+insert into t1 values
+('a'),('b'),(null),('ペテルグル'),('ü'),('Y');
+create index it1 on t1 (s1);
+select s1 as before_delete_bin from t1 where s1 like 'ペテ%';
+before_delete_bin
+ペテル_delete_bin from t1 where s1 like 'ペテ%';
+after_delete_bin
+ペテルグル
+drop table t1;
+set names utf8mb4;
+create table t1 (a varchar(30) not null primary key)
+engine=ndb default character set utf8mb4 collate utf8mb4_general_ci;
+insert into t1 values ('あいうえおかしすせそかきくけこあいうえお');
+select a as gci1 from t1 where a like 'さしすせそかきくけあいうえおかきくけこさしすせそ';
+gci2
+1;
+set names utf8mb4;
+create table t1 (a varchar(30) not null primary key)
+engine=ndb default character set utf8mb4 collate utf8mb4_unicode_ci;
+insert into t1 values ('あいうえおかきくけこさしすせそ');
+insert into t1 values ('さしすせそかきくけこあいうえお');
+select a as uci1 from t1 where a like 'さしrom t1 where a like 'あいうえおかきくけこさしすせそ';
+uci2
+あいうえおかきくけこさし t1 (a varchar(30) not null primary key)
+engine=ndb default character set utf8mb4 collate utf8mb4_bin;
+insert into t1 values ('あいうえおかきくけこさしすせそ');
+insert into t1 values ('さしすせそかきく like 'さしすせそかきくけこあいうえお%';
+bin1
+さしすせそかきくけこあいうえお
+select a as bin2 from t1 where a like 'あいうえおかきけこさしすせそ
+drop table t1;
+SET NAMES utf8mb4;
+CREATE TABLE t1 (id int PRIMARY KEY,
+a varchar(16) collate utf8mb4_unicode_ci NOT NULL default '',
+b int,
+f varchar(128) default 'XXX',
+INDEX (a(4))
+) ENGINE=ndb DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+INSERT INTO t1(id, a, b) VALUES
+(1, 'cccc', 50), (2, 'cccc', 70), (3, 'cccc', 30),
+(4, 'cccc', 30), (5, 'cccc', 20), (6, 'bbbbbb', 40),
+(7, 'dddd', 30), (8, 'aaaa', 10), (9, 'aaaa', 50),
+(10, 'eeeee', 40), (11, 'bbbbbb', 60);
+SELECT id, a, b FROM t1;
+id	a	b
+1	cccc	50
+10	eeeee	40
+11	bbbbbb	60
+2	cccc	70
+3	cccc	30
+4	cccc	30
+5	cccc	20
+6	bbbbbb	40
+7	dddd	30
+8	aaaa	10
+9	aaaa	50
+SELECT id, a, b FROM t1 WHERE a BETWEEN 'aaaa' AND 'bbbbbb';
+id	a	b
+11	bbbbbb	60
+6	bbbbbb	40
+8	aaaa	10
+9	aaaa	50
+SELECT id, a FROM t1 WHERE a='bbbbbb';
+id	a
+11	bbbbbb
+6	bbbbbb
+SELECT id, a FROM t1 WHERE a='bbbbbb' ORDER BY b;
+id	a
+6	bbbbbb
+11	bbbbbb
+DROP TABLE t1;
+SET NAMES utf8mb4;
+CREATE TABLE t1 (
+a CHAR(13) DEFAULT '',
+INDEX(a)
+) ENGINE=ndb DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+INSERT INTO t1 VALUES 
+('Käli Käli 2-4'), ('K),
+('Käli Käli 2-6'), ('Käli Käli 2-6');
+INSERT INTO t1 SELECT * FROM t1;
+CREATE TABLE t2 (
+a CHAR(13) DEFAULT '',
+INDEX(a)
+) ENGINE=ndb DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
+INSERT INTO t2 VALUES
+('Kali Kali 2-4'), ('Kali Kali 2-4'),
+('Kali Kali 2+4'), ('Kali Kali 2+4'),
+('Kali Kali 2-6'), ('Kali Kali 2-6');
+INSERT INTO t2 SELECT * FROM t2;
+SELECT a FROM t1 WHERE a LIKE 'Käli Käli 2+4';
+a
+Käli Käli 2+4
+Käli Käli 2+4
+Käli Käli 2+4
+Käli Käli 2+4
+SELECT a FROM t2 WHERE a LIKE 'Kali Kali 2+4';
+a
+Kali Kali 2+4
+Kali Kali 2+4
+Kali Kali 2+4
+Kali Kali 2+4
+EXPLAIN SELECT a FROM t1 WHERE a LIKE 'Käli Käli 2+4';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	a	a	53	NULL	10	Using where with pushed condition
+EXPLAIN SELECT a FROM t1 WHERE a = 'Käli Käli 2+4';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ref	a	a	53	const	10	Using where with pushed condition
+EXPLAIN SELECT a FROM t2 WHERE a LIKE 'Kali Kali 2+4';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t2	range	a	a	14	NULL	10	Using where with pushed condition
+EXPLAIN SELECT a FROM t2 WHERE a = 'Kali Kali 2+4';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t2	ref	a	a	14	const	10	Using where with pushed condition
+DROP TABLE t1,t2;
+CREATE TABLE t1 (
+a char(255) DEFAULT '', 
+KEY(a(10))
+) ENGINE=ndb DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+INSERT INTO t1 VALUES ('Käli Käli 2-4');
+SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%';
+a
+Käli Käli 2-4
+INSERT INTO t1 VALUES ('Käli Käli 2-4');
+SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%';
+a
+Käli Käli 2-4
+Käli Käli 2-4
+DROP TABLE t1;
+CREATE TABLE t1 (
+a char(255) DEFAULT ''
+) ENGINE=ndb DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+INSERT INTO t1 VALUES ('Käli Käli 2-4');
+INSERT INTO t1 VALUES ('Käli Käli 2-4');
+SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%';
+a
+Käli Käli 2-4
+Käli Käli 2-4
+ALTER TABLE t1 ADD KEY (a(10));
+SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%';
+a
+Käli Käli 2-4
+Käli Käli 2-4
+DROP TABLE t1;
+SET NAMES latin2;
+create table t1(a char(200) collate utf8mb4_unicode_ci NOT NULL default '')
+default charset=utf8mb4 collate=utf8mb4_unicode_ci engine ndb;
+insert into t1 values (unhex('65')), (unhex('C3A9')), (unhex('65'));
+explain select distinct a from t1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	Using temporary
+SELECT COUNT(*) FROM (SELECT DISTINCT a FROM t1) AS t2;
+COUNT(*)
+1
+explain select a from t1 group by a;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	Using temporary; Using filesort
+SELECT COUNT(*) FROM (SELECT a FROM t1 GROUP BY a) AS t2;
+COUNT(*)
+1
+drop table t1;
+create table t1(a char(10)) default charset utf8mb4 engine ndb;
+insert into t1 values ('123'), ('456');
+explain
+select substr(Z.a,-1), Z.a from t1 as Y join t1 as Z on Y.a=Z.a order by 1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	Y	ALL	NULL	NULL	NULL	NULL	2	Using temporary; Using filesort
+1	SIMPLE	Z	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer
+select substr(Z.a,-1), Z.a from t1 as Y join t1 as Z on Y.a=Z.a order by 1;
+substr(Z.a,-1)	a
+3	123
+6	456
+drop table t1;
+SET CHARACTER SET utf8mb4;
+SHOW VARIABLES LIKE 'character\_set\_%';
+Variable_name	Value
+character_set_client	utf8mb4
+character_set_connection	latin1
+character_set_database	latin1
+character_set_filesystem	binary
+character_set_results	utf8mb4
+character_set_server	latin1
+character_set_system	utf8
+CREATE DATABASE crashtest DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
+USE crashtest;
+CREATE TABLE crashtest (crash char(10)) DEFAULT CHARSET=utf8mb4 ENGINE ndb;
+INSERT INTO crashtest VALUES ('35'), ('36'), ('37');
+SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8mb4);
+crash
+35
+36
+37
+INSERT INTO crashtest VALUES ('-1000');
+EXPLAIN SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8mb4);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	crashtest	ALL	NULL	NULL	NULL	NULL	4	Using filesort
+SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8mb4);
+crash
+-1000
+35
+36
+37
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FFFFFC'
+DROP TABLE crashtest;
+DROP DATABASE crashtest;
+USE test;
+SET CHARACTER SET default;
+CREATE TABLE t1(id varchar(20) NOT NULL) DEFAULT CHARSET=utf8mb4 ENGINE ndb;
+INSERT INTO t1 VALUES ('xxx'), ('aa'), ('yyy'), ('aa');
+SELECT id FROM t1;
+id
+aa
+aa
+xxx
+yyy
+SELECT DISTINCT id FROM t1;
+id
+aa
+xxx
+yyy
+SELECT DISTINCT id FROM t1 ORDER BY id;
+id
+aa
+xxx
+yyy
+DROP TABLE t1;
+create table t1 (
+a varchar(26) not null
+) default character set utf8mb4 ENGINE ndb;
+insert into t1 (a) values ('abcdefghijklmnopqrstuvwxyz');
+select * from t1;
+a
+abcdefghijklmnopqrstuvwxyz
+alter table t1 change a a varchar(20) character set utf8mb4 not null;
+Warnings:
+Warning	1265	Data truncated for column 'a' at row 1
+select * from t1;
+a
+abcdefghijklmnopqrst
+alter table t1 change a a char(15) character set utf8mb4 not null;
+Warnings:
+Warning	1265	Data truncated for column 'a' at row 1
+select * from t1;
+a
+abcdefghijklmno
+alter table t1 change a a char(10) character set utf8mb4 not null;
+Warnings:
+Warning	1265	Data truncated for column 'a' at row 1
+select * from t1;
+a
+abcdefghij
+alter table t1 change a a varchar(5) character set utf8mb4 not null;
+Warnings:
+Warning	1265	Data truncated for column 'a' at row 1
+select * from t1;
+a
+abcde
+drop table t1;
+set names utf8mb4;
+select hex(char(1 using utf8mb4));
+hex(char(1 using utf8mb4))
+01
+select char(0xd1,0x8f using utf8mb4);
+char(0xd1,0x8f using utf8mb4)
+я
+select char(0xd18f using utf8mb4);
+char(0xd18f using utf8mb4)
+я
+select char(53647 using utf8mb4);
+char(53647 using utf8mb4)
+я
+select char(0xff,0x8f using utf8mb4);
+char(0xff,0x8f using utf8mb4)
+
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FF8F'
+select convert(char(0xff,0x8f) using utf8mb4);
+convert(char(0xff,0x8f) using utf8mb4)
+
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FF8F'
+set sql_mode=traditional;
+select char(0xff,0x8f using utf8mb4);
+char(0xff,0x8f using utf8mb4)
+NULL
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FF8F'
+select char(195 using utf8mb4);
+char(195 using utf8mb4)
+NULL
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'C3'
+select char(196 using utf8mb4);
+char(196 using utf8mb4)
+NULL
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'C4'
+select char(2557 using utf8mb4);
+char(2557 using utf8mb4)
+NULL
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FD'
+select convert(char(0xff,0x8f) using utf8mb4);
+convert(char(0xff,0x8f) using utf8mb4)
+NULL
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FF8F'
+select hex(convert(char(2557 using latin1) using utf8mb4));
+hex(convert(char(2557 using latin1) using utf8mb4))
+09C3BD
+select hex(char(195));
+hex(char(195))
+C3
+select hex(char(196));
+hex(char(196))
+C4
+select hex(char(2557));
+hex(char(2557))
+09FD
+set names utf8mb4;
+create table t1 (a char(1)) default character set utf8mb4 engine ndb;
+create table t2 (a char(1)) default character set utf8mb4 engine ndb;
+insert into t1 values('a'),('a'),(0xE38182),(0xE38182);
+insert into t1 values('i'),('i'),(0xE38184),(0xE38184);
+select * from t1 union distinct select * from t2;
+a
+a
+i
+あ
+い
+drop table t1,t2;
+set names utf8mb4;
+create table t1 (a char(10), b varchar(10)) engine ndb;
+insert into t1 values ('bar','kostja');
+insert into t1 values ('kostja','bar');
+prepare my_stmt from "select * from t1 where a=?";
+set @a:='bar';
+execute my_stmt using @a;
+a	b
+bar	kostja
+set @a:='kostja';
+execute my_stmt using @a;
+a	b
+kostja	bar
+set @a:=null;
+execute my_stmt using @a;
+a	b
+drop table if exists t1;
+drop table if exists t1;
+drop view if exists v1, v2;
+set names utf8mb4;
+create table t1(col1 varchar(12) character set utf8mb4 collate utf8mb4_unicode_ci) engine ndb;
+insert into t1 values('t1_val');
+create view v1 as select 'v1_val' as col1;
+select coercibility(col1), collation(col1) from v1;
+coercibility(col1)	collation(col1)
+4	utf8mb4_general_ci
+create view v2 as select col1 from v1 union select col1 from t1;
+select coercibility(col1), collation(col1)from v2;
+coercibility(col1)	collation(col1)
+2	utf8mb4_unicode_ci
+2	utf8mb4_unicode_ci
+drop view v1, v2;
+create view v1 as select 'v1_val' collate utf8mb4_swedish_ci as col1;
+select coercibility(col1), collation(col1) from v1;
+coercibility(col1)	collation(col1)
+0	utf8mb4_swedish_ci
+create view v2 as select col1 from v1 union select col1 from t1;
+select coercibility(col1), collation(col1) from v2;
+coercibility(col1)	collation(col1)
+0	utf8mb4_swedish_ci
+0	utf8mb4_swedish_ci
+drop view v1, v2;
+drop table t1;
+set names utf8mb4;
+create table t1 (a varchar(10) character set latin1, b int) engine ndb;
+insert into t1 values ('a',1);
+select concat(a, if(b>10, N'x', N'y')) from t1;
+concat(a, if(b>10, N'x', N'y'))
+ay
+select concat(a, if(b>10, N'æ', N'ß')) from t1;
+ERROR HY000: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation 'concat'
+drop table t1;
+set names utf8mb4;
+create table t1 (a varchar(10) character set latin1, b int) engine ndb;
+insert into t1 values ('a',1);
+select concat(a, if(b>10, _utf8mb4'x', _utf8mb4'y')) from t1;
+concat(a, if(b>10, _utf8mb4'x', _utf8mb4'y'))
+ay
+select concat(a, if(b>10, _utf8mb4'æ', _utf8mb4'ß')) from t1;
+ERROR HY000: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation 'concat'
+drop table t1;
+set names utf8mb4;
+create table t1 (a varchar(10) character set latin1, b int) engine ndb;
+insert into t1 values ('a',1);
+select concat(a, if(b>10, _utf8mb4 0x78, _utf8mb4 0x79)) from t1;
+concat(a, if(b>10, _utf8mb4 0x78, _utf8mb4 0x79))
+ay
+select concat(a, if(b>10, _utf8mb4 0xC3A6, _utf8mb4 0xC3AF)) from t1;
+ERROR HY000: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation 'concat'
+drop table t1;
+set names utf8mb4;
+create table t1 (a varchar(10) character set latin1, b int) engine ndb;
+insert into t1 values ('a',1);
+select concat(a, if(b>10, 'x' 'x', 'y' 'y')) from t1;
+concat(a, if(b>10, 'x' 'x', 'y' 'y'))
+ayy
+select concat(a, if(b>10, 'x' 'æ', 'y' 'ß')) from t1;
+ERROR HY000: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation 'concat'
+drop table t1;
+CREATE TABLE t1 (
+colA int(11) NOT NULL,
+colB varchar(255) character set utf8mb4 NOT NULL,
+PRIMARY KEY  (colA)
+) ENGINE=ndb DEFAULT CHARSET=latin1;
+INSERT INTO t1 (colA, colB) VALUES (1, 'foo'), (2, 'foo bar');
+CREATE TABLE t2 (
+colA int(11) NOT NULL,
+colB varchar(255) character set utf8mb4 NOT NULL,
+KEY bad  (colA,colB(3))
+) ENGINE=ndb DEFAULT CHARSET=latin1;
+INSERT INTO t2 (colA, colB) VALUES (1, 'foo'),(2, 'foo bar');
+SELECT * FROM t1 JOIN t2 ON t1.colA=t2.colA AND t1.colB=t2.colB
+WHERE t1.colA < 3;
+colA	colB	colA	colB
+1	foo	1	foo
+2	foo bar	2	foo bar
+DROP TABLE t1, t2;
+SELECT 'н1234567890' UNION SELECT _binary '1';
+н1234567890
+н1234567890
+1
+SELECT 'н1234567890' UNION SELECT 1;
+н1234567890
+н1234567890
+1
+SELECT '1' UNION SELECT 'н1234567890';
+1
+1
+н1234567890
+SELECT 1 UNION SELECT 'н1234567890';
+1
+1
+н1234567890
+CREATE TABLE t1 (c VARCHAR(11)) CHARACTER SET utf8mb4 ENGINE ndb;
+CREATE TABLE t2 (b CHAR(1) CHARACTER SET binary, i INT) ENGINE ndb;
+INSERT INTO t1 (c) VALUES ('н1234567890');
+INSERT INTO t2 (b, i) VALUES ('1', 1);
+SELECT c FROM t1 UNION SELECT b FROM t2;
+c
+н1234567890
+1
+SELECT c FROM t1 UNION SELECT i FROM t2;
+c
+н1234567890
+1
+SELECT b FROM t2 UNION SELECT c FROM t1;
+b
+1
+н1234567890
+SELECT i FROM t2 UNION SELECT c FROM t1;
+i
+1
+н1234567890
+DROP TABLE t1, t2;
+set sql_mode=traditional;
+select hex(char(0xFF using utf8mb4));
+hex(char(0xFF using utf8mb4))
+NULL
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FF'
+select hex(convert(0xFF using utf8mb4));
+hex(convert(0xFF using utf8mb4))
+NULL
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FF'
+select hex(_utf8mb4 0x616263FF);
+ERROR HY000: Invalid utf8mb4 character string: 'FF'
+select hex(_utf8mb4 X'616263FF');
+ERROR HY000: Invalid utf8mb4 character string: 'FF'
+select hex(_utf8mb4 B'001111111111');
+ERROR HY000: Invalid utf8mb4 character string: 'FF'
+select (_utf8mb4 X'616263FF');
+ERROR HY000: Invalid utf8mb4 character string: 'FF'
+set sql_mode=default;
+select hex(char(0xFF using utf8mb4));
+hex(char(0xFF using utf8mb4))
+
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FF'
+select hex(convert(0xFF using utf8mb4));
+hex(convert(0xFF using utf8mb4))
+
+Warnings:
+Warning	1300	Invalid utf8mb4 character string: 'FF'
+select hex(_utf8mb4 0x616263FF);
+ERROR HY000: Invalid utf8mb4 character string: 'FF'
+select hex(_utf8mb4 X'616263FF');
+ERROR HY000: Invalid utf8mb4 character string: 'FF'
+select hex(_utf8mb4 B'001111111111');
+ERROR HY000: Invalid utf8mb4 character string: 'FF'
+select (_utf8mb4 X'616263FF');
+ERROR HY000: Invalid utf8mb4 character string: 'FF'
+CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL) ENGINE ndb;
+INSERT INTO t1 VALUES (70000, 1092), (70001, 1085), (70002, 1065);
+SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b;
+CONVERT(a, CHAR)	CONVERT(b, CHAR)
+70000	1092
+70001	1085
+70002	1065
+SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1;
+CONVERT(a, CHAR)	CONVERT(b, CHAR)
+70000	1092
+70001	1085
+70002	1065
+ALTER TABLE t1 ADD UNIQUE (b);
+SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b;
+CONVERT(a, CHAR)	CONVERT(b, CHAR)
+70000	1092
+70001	1085
+70002	1065
+DROP INDEX b ON t1;
+SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b;
+CONVERT(a, CHAR)	CONVERT(b, CHAR)
+70000	1092
+70001	1085
+70002	1065
+ALTER TABLE t1 ADD INDEX (b);
+SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) from t1 GROUP BY b;
+CONVERT(a, CHAR)	CONVERT(b, CHAR)
+70000	1092
+70001	1085
+70002	1065
+DROP TABLE t1;
+#
+# Bug#26474: Add Sinhala script (Sri Lanka) collation to MySQL
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+predicted_order int NOT NULL,
+utf8mb4_encoding VARCHAR(10) NOT NULL
+) CHARACTER SET utf8mb4 ENGINE ndb;
+INSERT INTO t1 VALUES (19, x'E0B696'), (30, x'E0B69AE0B798'), (61, x'E0B6AF'), (93, x'E0B799'), (52, x'E0B6A6'), (73, x'E0B6BBE0B78AE2808D'), (3, x'E0B686'), (56, x'E0B6AA'), (55, x'E0B6A9'), (70, x'E0B6B9'), (94, x'E0B79A'), (80, x'E0B785'), (25, x'E0B69AE0B791'), (48, x'E0B6A2'), (13, x'E0B690'), (86, x'E0B793'), (91, x'E0B79F'), (81, x'E0B786'), (79, x'E0B784'), (14, x'E0B691'), (99, x'E0B78A'), (8, x'E0B68B'), (68, x'E0B6B7'), (22, x'E0B69A'), (16, x'E0B693'), (33, x'E0B69AE0B7B3'), (38, x'E0B69AE0B79D'), (21, x'E0B683'), (11, x'E0B68E'), (77, x'E0B782'), (40, x'E0B69AE0B78A'), (101, x'E0B78AE2808DE0B6BB'), (35, x'E0B69AE0B79A'), (1, x'E0B7B4'), (9, x'E0B68C'), (96, x'E0B79C'), (6, x'E0B689'), (95, x'E0B79B'), (88, x'E0B796'), (64, x'E0B6B3'), (26, x'E0B69AE0B792'), (82, x'E0B78F'), (28, x'E0B69AE0B794'), (39, x'E0B69AE0B79E'), (97, x'E0B79D'), (2, x'E0B685'), (75, x'E0B780'), (34, x'E0B69AE0B799'), (69, x'E0B6B8'), (83, x'E0B790'), (18, x'E0B695'), (90, x'E0B7B2'), (17, x'E0B694'), (72, x'E0B6BB'), (66, x'E0B6B5'), (59, x'E0B6AD'), (44, x'E0B69E'), (15, x'E0B692'), (23, x'E0B69AE0B78F'), (65, x'E0B6B4'), (42, x'E0B69C'), (63, x'E0B6B1'), (85, x'E0B792'), (47, x'E0B6A1'), (49, x'E0B6A3'), (92, x'E0B7B3'), (78, x'E0B783'), (36, x'E0B69AE0B79B'), (4, x'E0B687'), (24, x'E0B69AE0B790'), (87, x'E0B794'), (37, x'E0B69AE0B79C'), (32, x'E0B69AE0B79F'), (29, x'E0B69AE0B796'), (43, x'E0B69D'), (62, x'E0B6B0'), (100, x'E0B78AE2808DE0B6BA'), (60, x'E0B6AE'), (45, x'E0B69F'), (12, x'E0B68F'), (46, x'E0B6A0'), (50, x'E0B6A5'), (51, x'E0B6A4'), (5, x'E0B688'), (76, x'E0B781'), (89, x'E0B798'), (74, x'E0B6BD'), (10, x'E0B68D'), (57, x'E0B6AB'), (71, x'E0B6BA'), (58, x'E0B6AC'), (27, x'E0B69AE0B793'), (54, x'E0B6A8'), (84, x'E0B791'), (31, x'E0B69AE0B7B2'), (98, x'E0B79E'), (53, x'E0B6A7'), (41, x'E0B69B'), (67, x'E0B6B6'), (7, x'E0B68A'), (20, x'E0B682');
+SELECT predicted_order, hex(utf8mb4_encoding) FROM t1 ORDER BY utf8mb4_encoding COLLATE utf8mb4_sinhala_ci;
+predicted_order	hex(utf8mb4_encoding)
+1	E0B7B4
+2	E0B685
+3	E0B686
+4	E0B687
+5	E0B688
+6	E0B689
+7	E0B68A
+8	E0B68B
+9	E0B68C
+10	E0B68D
+11	E0B68E
+12	E0B68F
+13	E0B690
+14	E0B691
+15	E0B692
+16	E0B693
+17	E0B694
+18	E0B695
+19	E0B696
+20	E0B682
+21	E0B683
+22	E0B69A
+23	E0B69AE0B78F
+24	E0B69AE0B790
+25	E0B69AE0B791
+26	E0B69AE0B792
+27	E0B69AE0B793
+28	E0B69AE0B794
+29	E0B69AE0B796
+30	E0B69AE0B798
+31	E0B69AE0B7B2
+32	E0B69AE0B79F
+33	E0B69AE0B7B3
+34	E0B69AE0B799
+35	E0B69AE0B79A
+36	E0B69AE0B79B
+37	E0B69AE0B79C
+38	E0B69AE0B79D
+39	E0B69AE0B79E
+40	E0B69AE0B78A
+41	E0B69B
+42	E0B69C
+43	E0B69D
+44	E0B69E
+45	E0B69F
+46	E0B6A0
+47	E0B6A1
+48	E0B6A2
+49	E0B6A3
+50	E0B6A5
+51	E0B6A4
+52	E0B6A6
+53	E0B6A7
+54	E0B6A8
+55	E0B6A9
+56	E0B6AA
+57	E0B6AB
+58	E0B6AC
+59	E0B6AD
+60	E0B6AE
+61	E0B6AF
+62	E0B6B0
+63	E0B6B1
+64	E0B6B3
+65	E0B6B4
+66	E0B6B5
+67	E0B6B6
+68	E0B6B7
+69	E0B6B8
+70	E0B6B9
+71	E0B6BA
+72	E0B6BB
+73	E0B6BBE0B78AE2808D
+74	E0B6BD
+75	E0B780
+76	E0B781
+77	E0B782
+78	E0B783
+79	E0B784
+80	E0B785
+81	E0B786
+82	E0B78F
+83	E0B790
+84	E0B791
+85	E0B792
+86	E0B793
+87	E0B794
+88	E0B796
+89	E0B798
+90	E0B7B2
+91	E0B79F
+92	E0B7B3
+93	E0B799
+94	E0B79A
+95	E0B79B
+96	E0B79C
+97	E0B79D
+98	E0B79E
+99	E0B78A
+100	E0B78AE2808DE0B6BA
+101	E0B78AE2808DE0B6BB
+DROP TABLE t1;
+#
+# Bug#32914 Character sets: illegal characters in utf8mb4 and utf32 columns
+#
+create table t1 (utf8mb4 char(1) character set utf8mb4) engine ndb;
+Testing [F0][90..BF][80..BF][80..BF]
+insert into t1 values (0xF0908080);
+insert into t1 values (0xF0BFBFBF);
+insert into t1 values (0xF08F8080);
+Warnings:
+Warning	1366	Incorrect string value: '\xF0\x8F\x80\x80' for column 'utf8mb4' at row 1
+select hex(utf8mb4) from t1;
+hex(utf8mb4)
+
+F0908080
+F0BFBFBF
+delete from t1;
+Testing [F2..F3][80..BF][80..BF][80..BF]
+insert into t1 values (0xF2808080);
+insert into t1 values (0xF2BFBFBF);
+select hex(utf8mb4) from t1;
+hex(utf8mb4)
+F2808080
+F2BFBFBF
+delete from t1;
+Testing [F4][80..8F][80..BF][80..BF]
+insert into t1 values (0xF4808080);
+insert into t1 values (0xF48F8080);
+insert into t1 values (0xF4908080);
+Warnings:
+Warning	1366	Incorrect string value: '\xF4\x90\x80\x80' for column 'utf8mb4' at row 1
+select hex(utf8mb4) from t1;
+hex(utf8mb4)
+
+F4808080
+F48F8080
+drop table t1;
+#
+# Check strnxfrm() with odd length
+#
+set max_sort_length=5;
+select @@max_sort_length;
+@@max_sort_length
+5
+create table t1 (a varchar(128) character set utf8mb4 collate utf8mb4_general_ci) engine ndb;
+insert into t1 values ('a'),('b'),('c');
+select * from t1 order by a;
+a
+a
+b
+c
+alter table t1 modify a varchar(128) character set utf8mb4 collate utf8mb4_bin;
+select * from t1 order by a;
+a
+a
+b
+c
+drop table t1;
+set max_sort_length=default;
+#
+# Bug#26180: Can't add columns to tables created with utf8mb4 text indexes
+#
+#
+# Testing 4-byte values.
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+u_decimal int NOT NULL,
+utf8mb4_encoding VARCHAR(10) NOT NULL
+) CHARACTER SET utf8mb4 ENGINE ndb;
+INSERT INTO t1 VALUES (119040, x'f09d8480'),
+# G CLEF
+(119070, x'f09d849e'),
+# HALF NOTE
+(119134, x'f09d859e'),
+# MUSICAL SYMBOL CROIX
+(119247, x'f09d878f'),
+# MATHEMATICAL BOLD ITALIC CAPITAL DELTA
+(120607, x'f09d9c9f'),
+# SANS-SERIF BOLD ITALIC CAPITAL PI
+(120735, x'f09d9e9f'),
+# <Plane 16 Private Use, Last> (last 4 byte character)
+(1114111, x'f48fbfbf'),
+# VARIATION SELECTOR-256
+(917999, x'f3a087af');
+INSERT INTO t1 VALUES (119070, x'f09d849ef09d859ef09d859ef09d8480f09d859ff09d859ff09d859ff09d85a0f09d85a0f09d8480');
+INSERT INTO t1 VALUES (65131, x'efb9abf09d849ef09d859ef09d859ef09d8480f09d859fefb9abefb9abf09d85a0efb9ab');
+INSERT INTO t1 VALUES (119070, x'f09d849ef09d859ef09d859ef09d8480f09d859ff09d859ff09d859ff09d85a0f09d85a0f09d8480f09d85a0');
+Warnings:
+Warning	1265	Data truncated for column 'utf8mb4_encoding' at row 1
+SELECT u_decimal, hex(utf8mb4_encoding) FROM t1 ORDER BY utf8mb4_encoding COLLATE utf8mb4_general_ci, BINARY utf8mb4_encoding;
+u_decimal	hex(utf8mb4_encoding)
+1114111	F48FBFBF
+119040	F09D8480
+119070	F09D849E
+119070	F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480
+119070	F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480
+119134	F09D859E
+119247	F09D878F
+120607	F09D9C9F
+120735	F09D9E9F
+65131	EFB9ABF09D849EF09D859EF09D859EF09D8480F09D859FEFB9ABEFB9ABF09D85A0EFB9AB
+917999	F3A087AF
+INSERT INTO t1 VALUES (1114111, x'f5808080');
+Warnings:
+Warning	1366	Incorrect string value: '\xF5\x80\x80\x80' for column 'utf8mb4_encoding' at row 1
+SELECT character_maximum_length, character_octet_length FROM information_schema.columns WHERE
+table_name= 't1' AND column_name= 'utf8mb4_encoding';
+character_maximum_length	character_octet_length
+10	40
+DROP TABLE IF EXISTS t2;
+CREATE TABLE t2 (
+u_decimal int NOT NULL,
+utf8mb3_encoding VARCHAR(10) NOT NULL
+) CHARACTER SET utf8mb3 ENGINE ndb;
+INSERT INTO t2 VALUES (42856, x'ea9da8');
+INSERT INTO t2 VALUES (65131, x'efb9ab');
+INSERT INTO t2 VALUES (1114111, x'f48fbfbf');
+Warnings:
+Warning	1366	Incorrect string value: '\xF4\x8F\xBF\xBF' for column 'utf8mb3_encoding' at row 1
+SELECT character_maximum_length, character_octet_length FROM information_schema.columns WHERE
+table_name= 't2' AND column_name= 'utf8mb3_encoding';
+character_maximum_length	character_octet_length
+10	30
+UPDATE t2 SET utf8mb3_encoding= x'f48fbfbd' where u_decimal= 42856;
+Warnings:
+Warning	1366	Incorrect string value: '\xF4\x8F\xBF\xBD' for column 'utf8mb3_encoding' at row 1
+UPDATE t2 SET utf8mb3_encoding= _utf8mb4 x'ea9da8' where u_decimal= 42856;
+SELECT HEX(CONCAT(utf8mb4_encoding, _utf8 x'ea9da8')) FROM t1;
+HEX(CONCAT(utf8mb4_encoding, _utf8 x'ea9da8'))
+EA9DA8
+EFB9ABF09D849EF09D859EF09D859EF09D8480F09D859FEFB9ABEFB9ABF09D85A0EFB9ABEA9DA8
+F09D8480EA9DA8
+F09D849EEA9DA8
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480EA9DA8
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480EA9DA8
+F09D859EEA9DA8
+F09D878FEA9DA8
+F09D9C9FEA9DA8
+F09D9E9FEA9DA8
+F3A087AFEA9DA8
+F48FBFBFEA9DA8
+SELECT HEX(CONCAT(utf8mb4_encoding, utf8mb3_encoding)) FROM t1,t2;
+HEX(CONCAT(utf8mb4_encoding, utf8mb3_encoding))
+
+EA9DA8
+EFB9AB
+EFB9ABF09D849EF09D859EF09D859EF09D8480F09D859FEFB9ABEFB9ABF09D85A0EFB9AB
+EFB9ABF09D849EF09D859EF09D859EF09D8480F09D859FEFB9ABEFB9ABF09D85A0EFB9ABEA9DA8
+EFB9ABF09D849EF09D859EF09D859EF09D8480F09D859FEFB9ABEFB9ABF09D85A0EFB9ABEFB9AB
+F09D8480
+F09D8480EA9DA8
+F09D8480EFB9AB
+F09D849E
+F09D849EEA9DA8
+F09D849EEFB9AB
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480EA9DA8
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480EA9DA8
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480EFB9AB
+F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480EFB9AB
+F09D859E
+F09D859EEA9DA8
+F09D859EEFB9AB
+F09D878F
+F09D878FEA9DA8
+F09D878FEFB9AB
+F09D9C9F
+F09D9C9FEA9DA8
+F09D9C9FEFB9AB
+F09D9E9F
+F09D9E9FEA9DA8
+F09D9E9FEFB9AB
+F3A087AF
+F3A087AFEA9DA8
+F3A087AFEFB9AB
+F48FBFBF
+F48FBFBFEA9DA8
+F48FBFBFEFB9AB
+SELECT count(*) FROM t1, t2
+WHERE t1.utf8mb4_encoding > t2.utf8mb3_encoding;
+count(*)
+33
+ALTER TABLE t1 CONVERT TO CHARACTER SET utf8;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `u_decimal` int(11) NOT NULL,
+  `utf8mb4_encoding` varchar(10) NOT NULL
+) ENGINE=ndbcluster DEFAULT CHARSET=utf8
+SELECT u_decimal,hex(utf8mb4_encoding),utf8mb4_encoding FROM t1;
+u_decimal	hex(utf8mb4_encoding)	utf8mb4_encoding
+1114111		
+1114111	3F	?
+119040	3F	?
+119070	3F	?
+119070	3F3F3F3F3F3F3F3F3F3F	??????????
+119070	3F3F3F3F3F3F3F3F3F3F	??????????
+119134	3F	?
+119247	3F	?
+120607	3F	?
+120735	3F	?
+65131	EFB9AB3F3F3F3F3FEFB9ABEFB9AB3FEFB9AB	﹫?????﹫﹫?﹫
+917999	3F	?
+ALTER TABLE t2 CONVERT TO CHARACTER SET utf8mb4;
+SHOW CREATE TABLE t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `u_decimal` int(11) NOT NULL,
+  `utf8mb3_encoding` varchar(10) NOT NULL
+) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4
+SELECT u_decimal,hex(utf8mb3_encoding) FROM t2;
+u_decimal	hex(utf8mb3_encoding)
+1114111	
+42856	EA9DA8
+65131	EFB9AB
+ALTER TABLE t2 CONVERT TO CHARACTER SET utf8mb3;
+SHOW CREATE TABLE t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `u_decimal` int(11) NOT NULL,
+  `utf8mb3_encoding` varchar(10) NOT NULL
+) ENGINE=ndbcluster DEFAULT CHARSET=utf8
+SELECT u_decimal,hex(utf8mb3_encoding) FROM t2;
+u_decimal	hex(utf8mb3_encoding)
+1114111	
+42856	EA9DA8
+65131	EFB9AB
+ALTER TABLE t1 MODIFY utf8mb4_encoding VARCHAR(10) CHARACTER SET utf8mb3;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `u_decimal` int(11) NOT NULL,
+  `utf8mb4_encoding` varchar(10) DEFAULT NULL
+) ENGINE=ndbcluster DEFAULT CHARSET=utf8
+SELECT u_decimal,hex(utf8mb4_encoding) FROM t1;
+u_decimal	hex(utf8mb4_encoding)
+1114111	
+1114111	3F
+119040	3F
+119070	3F
+119070	3F3F3F3F3F3F3F3F3F3F
+119070	3F3F3F3F3F3F3F3F3F3F
+119134	3F
+119247	3F
+120607	3F
+120735	3F
+65131	EFB9AB3F3F3F3F3FEFB9ABEFB9AB3FEFB9AB
+917999	3F
+ALTER TABLE t1 MODIFY utf8mb4_encoding VARCHAR(10) CHARACTER SET utf8mb4;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `u_decimal` int(11) NOT NULL,
+  `utf8mb4_encoding` varchar(10) CHARACTER SET utf8mb4 DEFAULT NULL
+) ENGINE=ndbcluster DEFAULT CHARSET=utf8
+SELECT u_decimal,hex(utf8mb4_encoding) FROM t1;
+u_decimal	hex(utf8mb4_encoding)
+1114111	
+1114111	3F
+119040	3F
+119070	3F
+119070	3F3F3F3F3F3F3F3F3F3F
+119070	3F3F3F3F3F3F3F3F3F3F
+119134	3F
+119247	3F
+120607	3F
+120735	3F
+65131	EFB9AB3F3F3F3F3FEFB9ABEFB9AB3FEFB9AB
+917999	3F
+ALTER TABLE t2 MODIFY utf8mb3_encoding VARCHAR(10) CHARACTER SET utf8mb4;
+SHOW CREATE TABLE t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `u_decimal` int(11) NOT NULL,
+  `utf8mb3_encoding` varchar(10) CHARACTER SET utf8mb4 DEFAULT NULL
+) ENGINE=ndbcluster DEFAULT CHARSET=utf8
+SELECT u_decimal,hex(utf8mb3_encoding) FROM t2;
+u_decimal	hex(utf8mb3_encoding)
+1114111	
+42856	EA9DA8
+65131	EFB9AB
+DROP TABLE IF EXISTS t3;
+CREATE TABLE t3 (
+u_decimal int NOT NULL,
+utf8mb3_encoding VARCHAR(10) NOT NULL
+) CHARACTER SET utf8 ENGINE ndb;
+INSERT INTO t3 SELECT * FROM t1;
+DROP TABLE IF EXISTS t4;
+CREATE TABLE t4 (
+u_decimal int NOT NULL,
+utf8mb4_encoding VARCHAR(10) NOT NULL
+) CHARACTER SET utf8mb4 ENGINE ndb;
+INSERT INTO t3 SELECT * FROM t2;
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+DROP TABLE t4;
+#
+# Testing that mixing utf8 and utf8mb4 collations returns utf8mb4
+#
+SELECT CHARSET(CONCAT(_utf8mb4'a',_utf8'b'));
+CHARSET(CONCAT(_utf8mb4'a',_utf8'b'))
+utf8mb4
+CREATE TABLE t1 (utf8mb4 VARCHAR(10) CHARACTER SET utf8mb4 NOT NULL) ENGINE ndb;
+INSERT INTO t1 VALUES (x'ea9da8'),(x'f48fbfbf');
+SELECT CONCAT(utf8mb4, _utf8 x'ea9da8') FROM t1 LIMIT 0;
+CONCAT(utf8mb4, _utf8 x'ea9da8')
+CREATE TABLE t2 (utf8mb3 VARCHAR(10) CHARACTER SET utf8mb3 NOT NULL) ENGINE ndb;
+INSERT INTO t2 VALUES (x'ea9da8');
+SELECT HEX(CONCAT(utf8mb4, utf8mb3)) FROM t1,t2 ORDER BY 1;
+HEX(CONCAT(utf8mb4, utf8mb3))
+EA9DA8EA9DA8
+F48FBFBFEA9DA8
+SELECT CHARSET(CONCAT(utf8mb4, utf8mb3)) FROM t1, t2 LIMIT 1;
+CHARSET(CONCAT(utf8mb4, utf8mb3))
+utf8mb4
+SELECT * FROM t1, t2 WHERE t1.utf8mb4 > t2.utf8mb3;
+utf8mb4	utf8mb3
+􏿿	Ꝩ
+SELECT * FROM t1, t2 WHERE t1.utf8mb4 = t2.utf8mb3;
+utf8mb4	utf8mb3
+Ꝩ	Ꝩ
+SELECT * FROM t1, t2 WHERE t1.utf8mb4 < t2.utf8mb3;
+utf8mb4	utf8mb3
+DROP TABLE t1;
+DROP TABLE t2;
+#
+# Check that mixing utf8mb4 with an invalid utf8 constant returns error
+#
+CREATE TABLE t1 (utf8mb4 VARCHAR(10) CHARACTER SET utf8mb4) ENGINE ndb;
+INSERT INTO t1 VALUES (x'f48fbfbf');
+SELECT CONCAT(utf8mb4, _utf8 '�') FROM t1;
+ERROR HY000: Illegal mix of collations (utf8mb4_general_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation 'concat'
+SELECT CONCAT('a', _utf8 '�') FROM t1;
+ERROR HY000: Illegal mix of collations (utf8mb4_general_ci,COERCIBLE) and (utf8_general_ci,COERCIBLE) for operation 'concat'
+DROP TABLE t1;
+#
+# End of 5.5 tests
+#
+#
+# End of tests
+#

=== added file 'mysql-test/suite/perfschema/r/pfs_upgrade.result'
--- a/mysql-test/suite/perfschema/r/pfs_upgrade.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/pfs_upgrade.result	2010-03-05 15:31:01 +0000
@@ -0,0 +1,153 @@
+drop table if exists test.user_table;
+drop procedure if exists test.user_proc;
+drop function if exists test.user_func;
+drop event if exists test.user_event;
+"Testing mysql_upgrade with TABLE performance_schema.user_table"
+create table test.user_table(a int);
+use performance_schema;
+show tables like "user_table";
+Tables_in_performance_schema (user_table)
+user_table
+ERROR 1644 (HY000) at line 178: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 203: Table 'COND_INSTANCES' already exists
+ERROR 1050 (42S01) at line 233: Table 'EVENTS_WAITS_CURRENT' already exists
+ERROR 1050 (42S01) at line 247: Table 'EVENTS_WAITS_HISTORY' already exists
+ERROR 1050 (42S01) at line 261: Table 'EVENTS_WAITS_HISTORY_LONG' already exists
+ERROR 1050 (42S01) at line 281: Table 'EVENTS_WAITS_SUMMARY_BY_EVENT_NAME' already exists
+ERROR 1050 (42S01) at line 302: Table 'EVENTS_WAITS_SUMMARY_BY_INSTANCE' already exists
+ERROR 1050 (42S01) at line 323: Table 'EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME' already exists
+ERROR 1050 (42S01) at line 340: Table 'FILE_INSTANCES' already exists
+ERROR 1050 (42S01) at line 359: Table 'FILE_SUMMARY_BY_EVENT_NAME' already exists
+ERROR 1050 (42S01) at line 379: Table 'FILE_SUMMARY_BY_INSTANCE' already exists
+ERROR 1050 (42S01) at line 396: Table 'MUTEX_INSTANCES' already exists
+ERROR 1050 (42S01) at line 414: Table 'PERFORMANCE_TIMERS' already exists
+ERROR 1050 (42S01) at line 431: Table 'PROCESSLIST' already exists
+ERROR 1050 (42S01) at line 449: Table 'RWLOCK_INSTANCES' already exists
+ERROR 1050 (42S01) at line 465: Table 'SETUP_CONSUMERS' already exists
+ERROR 1050 (42S01) at line 482: Table 'SETUP_INSTRUMENTS' already exists
+ERROR 1050 (42S01) at line 502: Table 'SETUP_OBJECTS' already exists
+ERROR 1050 (42S01) at line 518: Table 'SETUP_TIMERS' already exists
+FATAL ERROR: Upgrade failed
+show tables like "user_table";
+Tables_in_performance_schema (user_table)
+user_table
+use test;
+drop table test.user_table;
+"Testing mysql_upgrade with VIEW performance_schema.user_view"
+create view test.user_view as select "Not supposed to be here";
+use performance_schema;
+show tables like "user_view";
+Tables_in_performance_schema (user_view)
+user_view
+ERROR 1644 (HY000) at line 178: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 203: Table 'COND_INSTANCES' already exists
+ERROR 1050 (42S01) at line 233: Table 'EVENTS_WAITS_CURRENT' already exists
+ERROR 1050 (42S01) at line 247: Table 'EVENTS_WAITS_HISTORY' already exists
+ERROR 1050 (42S01) at line 261: Table 'EVENTS_WAITS_HISTORY_LONG' already exists
+ERROR 1050 (42S01) at line 281: Table 'EVENTS_WAITS_SUMMARY_BY_EVENT_NAME' already exists
+ERROR 1050 (42S01) at line 302: Table 'EVENTS_WAITS_SUMMARY_BY_INSTANCE' already exists
+ERROR 1050 (42S01) at line 323: Table 'EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME' already exists
+ERROR 1050 (42S01) at line 340: Table 'FILE_INSTANCES' already exists
+ERROR 1050 (42S01) at line 359: Table 'FILE_SUMMARY_BY_EVENT_NAME' already exists
+ERROR 1050 (42S01) at line 379: Table 'FILE_SUMMARY_BY_INSTANCE' already exists
+ERROR 1050 (42S01) at line 396: Table 'MUTEX_INSTANCES' already exists
+ERROR 1050 (42S01) at line 414: Table 'PERFORMANCE_TIMERS' already exists
+ERROR 1050 (42S01) at line 431: Table 'PROCESSLIST' already exists
+ERROR 1050 (42S01) at line 449: Table 'RWLOCK_INSTANCES' already exists
+ERROR 1050 (42S01) at line 465: Table 'SETUP_CONSUMERS' already exists
+ERROR 1050 (42S01) at line 482: Table 'SETUP_INSTRUMENTS' already exists
+ERROR 1050 (42S01) at line 502: Table 'SETUP_OBJECTS' already exists
+ERROR 1050 (42S01) at line 518: Table 'SETUP_TIMERS' already exists
+FATAL ERROR: Upgrade failed
+show tables like "user_view";
+Tables_in_performance_schema (user_view)
+user_view
+use test;
+drop view test.user_view;
+"Testing mysql_upgrade with PROCEDURE performance_schema.user_proc"
+create procedure test.user_proc()
+select "Not supposed to be here";
+update mysql.proc set db='performance_schema' where name='user_proc';
+ERROR 1644 (HY000) at line 178: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 203: Table 'COND_INSTANCES' already exists
+ERROR 1050 (42S01) at line 233: Table 'EVENTS_WAITS_CURRENT' already exists
+ERROR 1050 (42S01) at line 247: Table 'EVENTS_WAITS_HISTORY' already exists
+ERROR 1050 (42S01) at line 261: Table 'EVENTS_WAITS_HISTORY_LONG' already exists
+ERROR 1050 (42S01) at line 281: Table 'EVENTS_WAITS_SUMMARY_BY_EVENT_NAME' already exists
+ERROR 1050 (42S01) at line 302: Table 'EVENTS_WAITS_SUMMARY_BY_INSTANCE' already exists
+ERROR 1050 (42S01) at line 323: Table 'EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME' already exists
+ERROR 1050 (42S01) at line 340: Table 'FILE_INSTANCES' already exists
+ERROR 1050 (42S01) at line 359: Table 'FILE_SUMMARY_BY_EVENT_NAME' already exists
+ERROR 1050 (42S01) at line 379: Table 'FILE_SUMMARY_BY_INSTANCE' already exists
+ERROR 1050 (42S01) at line 396: Table 'MUTEX_INSTANCES' already exists
+ERROR 1050 (42S01) at line 414: Table 'PERFORMANCE_TIMERS' already exists
+ERROR 1050 (42S01) at line 431: Table 'PROCESSLIST' already exists
+ERROR 1050 (42S01) at line 449: Table 'RWLOCK_INSTANCES' already exists
+ERROR 1050 (42S01) at line 465: Table 'SETUP_CONSUMERS' already exists
+ERROR 1050 (42S01) at line 482: Table 'SETUP_INSTRUMENTS' already exists
+ERROR 1050 (42S01) at line 502: Table 'SETUP_OBJECTS' already exists
+ERROR 1050 (42S01) at line 518: Table 'SETUP_TIMERS' already exists
+FATAL ERROR: Upgrade failed
+select name from mysql.proc where db='performance_schema';
+name
+user_proc
+update mysql.proc set db='test' where name='user_proc';
+drop procedure test.user_proc;
+"Testing mysql_upgrade with FUNCTION performance_schema.user_func"
+create function test.user_func() returns integer
+return 0;
+update mysql.proc set db='performance_schema' where name='user_func';
+ERROR 1644 (HY000) at line 178: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 203: Table 'COND_INSTANCES' already exists
+ERROR 1050 (42S01) at line 233: Table 'EVENTS_WAITS_CURRENT' already exists
+ERROR 1050 (42S01) at line 247: Table 'EVENTS_WAITS_HISTORY' already exists
+ERROR 1050 (42S01) at line 261: Table 'EVENTS_WAITS_HISTORY_LONG' already exists
+ERROR 1050 (42S01) at line 281: Table 'EVENTS_WAITS_SUMMARY_BY_EVENT_NAME' already exists
+ERROR 1050 (42S01) at line 302: Table 'EVENTS_WAITS_SUMMARY_BY_INSTANCE' already exists
+ERROR 1050 (42S01) at line 323: Table 'EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME' already exists
+ERROR 1050 (42S01) at line 340: Table 'FILE_INSTANCES' already exists
+ERROR 1050 (42S01) at line 359: Table 'FILE_SUMMARY_BY_EVENT_NAME' already exists
+ERROR 1050 (42S01) at line 379: Table 'FILE_SUMMARY_BY_INSTANCE' already exists
+ERROR 1050 (42S01) at line 396: Table 'MUTEX_INSTANCES' already exists
+ERROR 1050 (42S01) at line 414: Table 'PERFORMANCE_TIMERS' already exists
+ERROR 1050 (42S01) at line 431: Table 'PROCESSLIST' already exists
+ERROR 1050 (42S01) at line 449: Table 'RWLOCK_INSTANCES' already exists
+ERROR 1050 (42S01) at line 465: Table 'SETUP_CONSUMERS' already exists
+ERROR 1050 (42S01) at line 482: Table 'SETUP_INSTRUMENTS' already exists
+ERROR 1050 (42S01) at line 502: Table 'SETUP_OBJECTS' already exists
+ERROR 1050 (42S01) at line 518: Table 'SETUP_TIMERS' already exists
+FATAL ERROR: Upgrade failed
+select name from mysql.proc where db='performance_schema';
+name
+user_func
+update mysql.proc set db='test' where name='user_func';
+drop function test.user_func;
+"Testing mysql_upgrade with EVENT performance_schema.user_event"
+create event test.user_event on schedule every 1 day do
+select "not supposed to be here";
+update mysql.event set db='performance_schema' where name='user_event';
+ERROR 1644 (HY000) at line 178: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 203: Table 'COND_INSTANCES' already exists
+ERROR 1050 (42S01) at line 233: Table 'EVENTS_WAITS_CURRENT' already exists
+ERROR 1050 (42S01) at line 247: Table 'EVENTS_WAITS_HISTORY' already exists
+ERROR 1050 (42S01) at line 261: Table 'EVENTS_WAITS_HISTORY_LONG' already exists
+ERROR 1050 (42S01) at line 281: Table 'EVENTS_WAITS_SUMMARY_BY_EVENT_NAME' already exists
+ERROR 1050 (42S01) at line 302: Table 'EVENTS_WAITS_SUMMARY_BY_INSTANCE' already exists
+ERROR 1050 (42S01) at line 323: Table 'EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME' already exists
+ERROR 1050 (42S01) at line 340: Table 'FILE_INSTANCES' already exists
+ERROR 1050 (42S01) at line 359: Table 'FILE_SUMMARY_BY_EVENT_NAME' already exists
+ERROR 1050 (42S01) at line 379: Table 'FILE_SUMMARY_BY_INSTANCE' already exists
+ERROR 1050 (42S01) at line 396: Table 'MUTEX_INSTANCES' already exists
+ERROR 1050 (42S01) at line 414: Table 'PERFORMANCE_TIMERS' already exists
+ERROR 1050 (42S01) at line 431: Table 'PROCESSLIST' already exists
+ERROR 1050 (42S01) at line 449: Table 'RWLOCK_INSTANCES' already exists
+ERROR 1050 (42S01) at line 465: Table 'SETUP_CONSUMERS' already exists
+ERROR 1050 (42S01) at line 482: Table 'SETUP_INSTRUMENTS' already exists
+ERROR 1050 (42S01) at line 502: Table 'SETUP_OBJECTS' already exists
+ERROR 1050 (42S01) at line 518: Table 'SETUP_TIMERS' already exists
+FATAL ERROR: Upgrade failed
+select name from mysql.event where db='performance_schema';
+name
+user_event
+update mysql.event set db='test' where name='user_event';
+drop event test.user_event;

=== added file 'mysql-test/suite/perfschema/t/pfs_upgrade.test'
--- a/mysql-test/suite/perfschema/t/pfs_upgrade.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/pfs_upgrade.test	2010-03-05 15:31:01 +0000
@@ -0,0 +1,137 @@
+# Copyright (C) 2010 Oracle and/or its affiliates. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+# Tests for PERFORMANCE_SCHEMA
+# Make sure mysql_upgrade does not destroy data in a 'performance_schema'
+# database.
+# 
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_warnings
+drop table if exists test.user_table;
+drop procedure if exists test.user_proc;
+drop function if exists test.user_func;
+drop event if exists test.user_event;
+--enable_warnings
+
+--echo "Testing mysql_upgrade with TABLE performance_schema.user_table"
+
+create table test.user_table(a int);
+
+let $MYSQLD_DATADIR= `SELECT @@datadir`;
+--copy_file $MYSQLD_DATADIR/test/user_table.frm $MYSQLD_DATADIR/performance_schema/user_table.frm
+
+# Make sure the table is visible
+use performance_schema;
+show tables like "user_table";
+
+--error 1
+--exec $MYSQL_UPGRADE --skip-verbose > $MYSQLTEST_VARDIR/tmp/pfs_upgrade.out 2> $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err
+
+# Verify that mysql_upgrade complained about the performance_schema
+--cat_file $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err
+
+# Make sure the table is still visible
+show tables like "user_table";
+
+use test;
+
+--remove_file $MYSQLD_DATADIR/performance_schema/user_table.frm
+drop table test.user_table;
+
+--echo "Testing mysql_upgrade with VIEW performance_schema.user_view"
+
+create view test.user_view as select "Not supposed to be here";
+
+let $MYSQLD_DATADIR= `SELECT @@datadir`;
+--copy_file $MYSQLD_DATADIR/test/user_view.frm $MYSQLD_DATADIR/performance_schema/user_view.frm
+
+# Make sure the view is visible
+use performance_schema;
+show tables like "user_view";
+
+--error 1
+--exec $MYSQL_UPGRADE --skip-verbose > $MYSQLTEST_VARDIR/tmp/pfs_upgrade.out 2> $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err
+
+# Verify that mysql_upgrade complained about the performance_schema
+--cat_file $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err
+
+# Make sure the view is still visible
+show tables like "user_view";
+
+use test;
+
+--remove_file $MYSQLD_DATADIR/performance_schema/user_view.frm
+drop view test.user_view;
+
+--echo "Testing mysql_upgrade with PROCEDURE performance_schema.user_proc"
+
+create procedure test.user_proc()
+  select "Not supposed to be here";
+
+update mysql.proc set db='performance_schema' where name='user_proc';
+
+--error 1
+--exec $MYSQL_UPGRADE --skip-verbose > $MYSQLTEST_VARDIR/tmp/pfs_upgrade.out 2> $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err
+
+# Verify that mysql_upgrade complained about the performance_schema
+--cat_file $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err
+
+select name from mysql.proc where db='performance_schema';
+
+update mysql.proc set db='test' where name='user_proc';
+drop procedure test.user_proc;
+
+--echo "Testing mysql_upgrade with FUNCTION performance_schema.user_func"
+
+create function test.user_func() returns integer
+  return 0;
+
+update mysql.proc set db='performance_schema' where name='user_func';
+
+--error 1
+--exec $MYSQL_UPGRADE --skip-verbose > $MYSQLTEST_VARDIR/tmp/pfs_upgrade.out 2> $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err
+
+# Verify that mysql_upgrade complained about the performance_schema
+--cat_file $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err
+
+select name from mysql.proc where db='performance_schema';
+
+update mysql.proc set db='test' where name='user_func';
+drop function test.user_func;
+
+--echo "Testing mysql_upgrade with EVENT performance_schema.user_event"
+
+create event test.user_event on schedule every 1 day do
+  select "not supposed to be here";
+
+update mysql.event set db='performance_schema' where name='user_event';
+
+--error 1
+--exec $MYSQL_UPGRADE --skip-verbose > $MYSQLTEST_VARDIR/tmp/pfs_upgrade.out 2> $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err
+
+# Verify that mysql_upgrade complained about the performance_schema
+--cat_file $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err
+
+select name from mysql.event where db='performance_schema';
+
+update mysql.event set db='test' where name='user_event';
+drop event test.user_event;
+
+--remove_file $MYSQLTEST_VARDIR/tmp/pfs_upgrade.out
+--remove_file $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err
+

=== added file 'mysql-test/suite/sys_vars/r/log_error_func.result'
--- a/mysql-test/suite/sys_vars/r/log_error_func.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/r/log_error_func.result	2010-03-05 13:08:21 +0000
@@ -0,0 +1,6 @@
+select (@err_log:=variable_value)*0 from information_schema.global_variables where variable_name="log_error";
+(@err_log:=variable_value)*0
+0
+select instr(@err_log, "some_random_name5435413.err")>0;
+instr(@err_log, "some_random_name5435413.err")>0
+1

=== added file 'mysql-test/suite/sys_vars/r/log_error_func2.result'
--- a/mysql-test/suite/sys_vars/r/log_error_func2.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/r/log_error_func2.result	2010-03-05 13:08:21 +0000
@@ -0,0 +1,6 @@
+select (@err_log:=variable_value)*0 from information_schema.global_variables where variable_name="log_error";
+(@err_log:=variable_value)*0
+0
+select instr(@err_log, ".err")>0;
+instr(@err_log, ".err")>0
+1

=== added file 'mysql-test/suite/sys_vars/r/log_error_func3.result'
--- a/mysql-test/suite/sys_vars/r/log_error_func3.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/r/log_error_func3.result	2010-03-05 13:08:21 +0000
@@ -0,0 +1,3 @@
+select variable_value from information_schema.global_variables where variable_name="log_error";
+variable_value
+

=== added file 'mysql-test/suite/sys_vars/t/log_error_func.cnf'
--- a/mysql-test/suite/sys_vars/t/log_error_func.cnf	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/log_error_func.cnf	2010-03-05 13:08:21 +0000
@@ -0,0 +1,5 @@
+# Use default setting for mysqld processes
+!include include/default_mysqld.cnf
+
+[mysqld.1]
+log-error=some_random_name5435413

=== added file 'mysql-test/suite/sys_vars/t/log_error_func.test'
--- a/mysql-test/suite/sys_vars/t/log_error_func.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/log_error_func.test	2010-03-05 13:08:21 +0000
@@ -0,0 +1,20 @@
+# Test for BUG#51215 "log-error partially works with version 5.5"
+# when --log-error is used without argument
+
+# check displayed value. We can check only the base name, the rest
+# depends on paths, symbolic links, --vardir, etc...
+select (@err_log:=variable_value)*0 from information_schema.global_variables where variable_name="log_error";
+select instr(@err_log, "some_random_name5435413.err")>0;
+
+# Check file's existence. The displayed value may be relative or not.
+let $err_log=`select @err_log`;
+let $err_log_relative=`select instr(@err_log, ".")=1`;
+if ($err_log_relative)
+{
+  let $MYSQLD_DATADIR= `SELECT @@datadir`;
+  file_exists $MYSQLD_DATADIR/$err_log;
+}
+if (!$err_log_relative)
+{
+  file_exists $err_log;
+}

=== added file 'mysql-test/suite/sys_vars/t/log_error_func2.cnf'
--- a/mysql-test/suite/sys_vars/t/log_error_func2.cnf	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/log_error_func2.cnf	2010-03-05 13:08:21 +0000
@@ -0,0 +1,5 @@
+# Use default setting for mysqld processes
+!include include/default_mysqld.cnf
+
+[mysqld.1]
+log-error

=== added file 'mysql-test/suite/sys_vars/t/log_error_func2.test'
--- a/mysql-test/suite/sys_vars/t/log_error_func2.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/log_error_func2.test	2010-03-05 13:08:21 +0000
@@ -0,0 +1,20 @@
+# Test for BUG#51215 "log-error partially works with version 5.5"
+# when --log-error is used without argument
+
+# check displayed value. We can check only the suffix, because
+# the rest depends on paths, symbolic links, --vardir, etc...
+select (@err_log:=variable_value)*0 from information_schema.global_variables where variable_name="log_error";
+select instr(@err_log, ".err")>0;
+
+# Check file's existence. The displayed value may be relative or not.
+let $err_log=`select @err_log`;
+let $err_log_relative=`select instr(@err_log, ".")=1`;
+if ($err_log_relative)
+{
+  let $MYSQLD_DATADIR= `SELECT @@datadir`;
+  file_exists $MYSQLD_DATADIR/$err_log;
+}
+if (!$err_log_relative)
+{
+  file_exists $err_log;
+}

=== added file 'mysql-test/suite/sys_vars/t/log_error_func3.test'
--- a/mysql-test/suite/sys_vars/t/log_error_func3.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/log_error_func3.test	2010-03-05 13:08:21 +0000
@@ -0,0 +1,5 @@
+# Test for BUG#51215 "log-error partially works with version 5.5"
+# when --log-error is not used
+
+# check displayed value. Should be empty.
+select variable_value from information_schema.global_variables where variable_name="log_error";

=== modified file 'mysql-test/t/ctype_utf8mb4.test'
--- a/mysql-test/t/ctype_utf8mb4.test	2010-02-24 15:42:40 +0000
+++ b/mysql-test/t/ctype_utf8mb4.test	2010-03-04 11:00:32 +0000
@@ -1603,6 +1603,8 @@ SELECT u_decimal, hex(utf8mb4_encoding)
 # First invalid 4 byte value
 INSERT INTO t1 VALUES (1114111, x'f5808080');
 
+SELECT character_maximum_length, character_octet_length FROM information_schema.columns WHERE
+       table_name= 't1' AND column_name= 'utf8mb4_encoding';
 
 --disable_warnings
 DROP TABLE IF EXISTS t2;
@@ -1618,11 +1620,84 @@ INSERT INTO t2 VALUES (65131, x'efb9ab')
 # <Plane 16 Private Use, Last> (last 4 byte character)
 INSERT INTO t2 VALUES (1114111, x'f48fbfbf');
 
+SELECT character_maximum_length, character_octet_length FROM information_schema.columns WHERE
+       table_name= 't2' AND column_name= 'utf8mb3_encoding';
+
+#  Update a 3-byte char col with a 4-byte char, error
+UPDATE t2 SET utf8mb3_encoding= x'f48fbfbd' where u_decimal= 42856;
+
+#  Update to a 3-byte char casted to 4-byte, error?
+UPDATE t2 SET utf8mb3_encoding= _utf8mb4 x'ea9da8' where u_decimal= 42856;
+
+# Returns utfmb4
+SELECT HEX(CONCAT(utf8mb4_encoding, _utf8 x'ea9da8')) FROM t1;
+SELECT HEX(CONCAT(utf8mb4_encoding, utf8mb3_encoding)) FROM t1,t2;
+
+#--error ER_INVALID_CHARACTER_STRING
+#SELECT CONCAT(_utf8 utf8mb4_encoding, _utf8 '|') FROM t1;
+#--error ER_INVALID_CHARACTER_STRING
+#SELECT CONCAT(_utf8mb3 utf8mb4_encoding, _utf8 '|') FROM t1;
+
+SELECT count(*) FROM t1, t2
+   WHERE t1.utf8mb4_encoding > t2.utf8mb3_encoding;
+
+# Alter from 4-byte charset to 3-byte charset, error
+ALTER TABLE t1 CONVERT TO CHARACTER SET utf8;
+SHOW CREATE TABLE t1;
+SELECT u_decimal,hex(utf8mb4_encoding),utf8mb4_encoding FROM t1;
+
+# Alter table from utf8 to utf8mb4
+ALTER TABLE t2 CONVERT TO CHARACTER SET utf8mb4;
+SHOW CREATE TABLE t2;
+SELECT u_decimal,hex(utf8mb3_encoding) FROM t2;
+
+# Alter table back from utf8mb4 to utf8
+ALTER TABLE t2 CONVERT TO CHARACTER SET utf8mb3;
+SHOW CREATE TABLE t2;
+SELECT u_decimal,hex(utf8mb3_encoding) FROM t2;
+
+# ALter of utf8mb4 column to utf8
+ALTER TABLE t1 MODIFY utf8mb4_encoding VARCHAR(10) CHARACTER SET utf8mb3;
+SHOW CREATE TABLE t1;
+SELECT u_decimal,hex(utf8mb4_encoding) FROM t1;
+
+# ALter of utf8 column to utf8mb4
+ALTER TABLE t1 MODIFY utf8mb4_encoding VARCHAR(10) CHARACTER SET utf8mb4;
 SHOW CREATE TABLE t1;
+SELECT u_decimal,hex(utf8mb4_encoding) FROM t1;
+
+# ALter of utf8 column to utf8mb4
+ALTER TABLE t2 MODIFY utf8mb3_encoding VARCHAR(10) CHARACTER SET utf8mb4;
 SHOW CREATE TABLE t2;
+SELECT u_decimal,hex(utf8mb3_encoding) FROM t2;
+
+--disable_warnings
+DROP TABLE IF EXISTS t3;
+--enable_warnings
+CREATE TABLE t3 (
+        u_decimal int NOT NULL,
+        utf8mb3_encoding VARCHAR(10) NOT NULL
+) CHARACTER SET utf8;
+
+# Insert select utf8mb4 (4-byte) into utf8 (3-byte), error
+#--error ER_INVALID_CHARACTER_STRING
+INSERT INTO t3 SELECT * FROM t1;
+
+--disable_warnings
+DROP TABLE IF EXISTS t4;
+--enable_warnings
+CREATE TABLE t4 (
+        u_decimal int NOT NULL,
+        utf8mb4_encoding VARCHAR(10) NOT NULL
+) CHARACTER SET utf8mb4;
+
+# Insert select utf8 (3-byte) into utf8mb4 (4-byte)
+INSERT INTO t3 SELECT * FROM t2;
 
 DROP TABLE t1;
 DROP TABLE t2;
+DROP TABLE t3;
+DROP TABLE t4;
 
 --echo #
 --echo # Testing that mixing utf8 and utf8mb4 collations returns utf8mb4
@@ -1662,6 +1737,51 @@ SELECT CONCAT(utf8mb4, _utf8 '�') FROM t
 SELECT CONCAT('a', _utf8 '�') FROM t1;
 DROP TABLE t1;
 
+
+--echo #
+--echo # Bug#51675 Server crashes on inserting 4 byte char.
+--echo # after ALTER TABLE to 'utf8mb4' 
+--echo #
+SET NAMES utf8;
+CREATE TABLE t1 ( 
+  subject varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci, 
+  p VARCHAR(15) CHARACTER SET utf8 
+) DEFAULT CHARSET=latin1; 
+
+# Alter old table, add index 
+ALTER TABLE t1 ADD INDEX (subject); 
+
+# Alter old 'utf8' table to new 'utf8mb4'
+ALTER TABLE t1
+  DEFAULT CHARACTER SET utf8,
+  MODIFY subject varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
+  MODIFY p varchar(255) CHARACTER SET utf8;
+SHOW CREATE TABLE t1; 
+
+INSERT INTO t1(subject) VALUES ('abcd'); 
+# Insert 4 byte characters
+INSERT INTO t1(subject) VALUES(x'f0909080');
+DROP TABLE t1;
+
+--echo #
+--echo # Bug #51676 Server crashes on SELECT, ORDER BY on 'utf8mb4' column
+--echo #
+SET NAMES utf8mb4; 
+CREATE TABLE t1 ( 
+  subject varchar(255) character set utf8mb4 collate utf8mb4_unicode_ci, 
+  p varchar(15) character set utf8mb4 
+) DEFAULT CHARSET=latin1; 
+# Insert 4 byte characters 
+# 4byte character 
+INSERT INTO t1(subject) VALUES(0xF0909080);
+# mix of 3 byte & 4 byte 
+INSERT INTO t1(subject) VALUES(0x616263F0909080646566);
+SHOW CREATE TABLE t1; 
+SELECT *  FROM t1 ORDER BY 1;
+SELECT hex(subject), length(subject), char_length(subject), octet_length(subject) FROM t1 ORDER BY 1; 
+SELECT subject FROM t1 ORDER BY 1;
+DROP TABLE t1;
+
 --echo #
 --echo # End of 5.5 tests
 --echo #

=== added file 'mysql-test/t/ctype_utf8mb4_heap.test'
--- a/mysql-test/t/ctype_utf8mb4_heap.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/ctype_utf8mb4_heap.test	2010-03-04 07:34:44 +0000
@@ -0,0 +1,6 @@
+--source include/have_utf8mb4.inc
+
+let $engine= heap;
+let $is_heap= 1;
+--source include/ctype_utf8mb4.inc
+

=== added file 'mysql-test/t/ctype_utf8mb4_innodb.test'
--- a/mysql-test/t/ctype_utf8mb4_innodb.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/ctype_utf8mb4_innodb.test	2010-03-04 07:34:44 +0000
@@ -0,0 +1,6 @@
+--source include/have_utf8mb4.inc
+--source include/have_innodb.inc
+
+let $engine= InnoDB;
+--source include/ctype_utf8mb4.inc
+

=== added file 'mysql-test/t/ctype_utf8mb4_myisam.test'
--- a/mysql-test/t/ctype_utf8mb4_myisam.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/ctype_utf8mb4_myisam.test	2010-03-04 07:34:44 +0000
@@ -0,0 +1,5 @@
+--source include/have_utf8mb4.inc
+
+let $engine= MyISAM;
+--source include/ctype_utf8mb4.inc
+

=== added file 'mysql-test/t/ctype_utf8mb4_ndb.test'
--- a/mysql-test/t/ctype_utf8mb4_ndb.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/ctype_utf8mb4_ndb.test	2010-03-04 07:34:44 +0000
@@ -0,0 +1,7 @@
+--source include/have_utf8mb4.inc
+--source include/have_ndb.inc
+
+let $engine= ndb;
+let $is_ndb= 1;
+--source include/ctype_utf8mb4.inc
+

=== modified file 'scripts/mysql_system_tables.sql'
--- a/scripts/mysql_system_tables.sql	2010-01-12 01:47:27 +0000
+++ b/scripts/mysql_system_tables.sql	2010-03-05 15:31:01 +0000
@@ -1,4 +1,4 @@
--- Copyright (C) 2008-2009 Sun Microsystems, Inc
+-- Copyright (C) 2008, 2010 Oracle and/or its affiliates. All rights reserved.
 --
 -- This program is free software; you can redistribute it and/or modify
 -- it under the terms of the GNU General Public License as published by
@@ -100,18 +100,92 @@ CREATE TABLE IF NOT EXISTS event ( db ch
 
 CREATE TABLE IF NOT EXISTS ndb_binlog_index (Position BIGINT UNSIGNED NOT NULL, File VARCHAR(255) NOT NULL, epoch BIGINT UNSIGNED NOT NULL, inserts BIGINT UNSIGNED NOT NULL, updates BIGINT UNSIGNED NOT NULL, deletes BIGINT UNSIGNED NOT NULL, schemaops BIGINT UNSIGNED NOT NULL, PRIMARY KEY(epoch)) ENGINE=MYISAM;
 
+--
+-- PERFORMANCE SCHEMA INSTALLATION
+-- Note that this script is also reused by mysql_upgrade,
+-- so we have to be very careful here to not destroy any
+-- existing database named 'performance_schema' if it
+-- can contain user data.
+-- In case of downgrade, it's ok to drop unknown tables
+-- from a future version, as long as they belong to the
+-- performance schema engine.
+--
+
+set @have_old_pfs= (select count(*) from information_schema.schemata where schema_name='performance_schema');
+
+SET @l1="SET @broken_tables = (select count(*) from information_schema.tables";
+SET @l2=" where engine != \'PERFORMANCE_SCHEMA\' and table_schema=\'performance_schema\')";
+SET @cmd=concat(@l1,@l2);
+
+-- Work around for bug#49542
+SET @str = IF(@have_old_pfs = 1, @cmd, 'SET @broken_tables = 0');
+PREPARE stmt FROM @str;
+EXECUTE stmt;
+DROP PREPARE stmt;
+
+SET @l1="SET @broken_views = (select count(*) from information_schema.views";
+SET @l2=" where table_schema='performance_schema')";
+SET @cmd=concat(@l1,@l2);
+
+-- Work around for bug#49542
+SET @str = IF(@have_old_pfs = 1, @cmd, 'SET @broken_views = 0');
+PREPARE stmt FROM @str;
+EXECUTE stmt;
+DROP PREPARE stmt;
+
+SET @broken_routines = (select count(*) from mysql.proc where db='performance_schema');
+
+SET @broken_events = (select count(*) from mysql.event where db='performance_schema');
+
+SET @broken_pfs= (select @broken_tables + @broken_views + @broken_routines + @broken_events);
 
 --
 -- The performance schema database.
--- This database is always created, even in --without-perfschema builds,
+-- Only drop and create the database if this is safe (no broken_pfs).
+-- This database is created, even in --without-perfschema builds,
 -- so that the database name is always reserved by the MySQL implementation.
 --
 
-set @have_pfs= (select count(engine) from information_schema.engines where engine='PERFORMANCE_SCHEMA' and support != 'NO');
+SET @cmd= "DROP DATABASE IF EXISTS performance_schema";
+
+SET @str = IF(@broken_pfs = 0, @cmd, 'SET @dummy = 0');
+PREPARE stmt FROM @str;
+EXECUTE stmt;
+DROP PREPARE stmt;
+
+SET @cmd= "CREATE DATABASE performance_schema character set utf8";
 
-DROP DATABASE IF EXISTS performance_schema;
+SET @str = IF(@broken_pfs = 0, @cmd, 'SET @dummy = 0');
+PREPARE stmt FROM @str;
+EXECUTE stmt;
+DROP PREPARE stmt;
+
+--
+-- Unlike 'performance_schema', the 'mysql' database is reserved already,
+-- so no user procedure is supposed to be there
+--
+drop procedure if exists mysql.die;
+create procedure mysql.die() signal sqlstate 'HY000' set message_text='Unexpected content found in the performance_schema database.';
+
+--
+-- For broken upgrades, SIGNAL the error
+--
+
+SET @cmd="call mysql.die()";
 
-CREATE DATABASE performance_schema character set utf8;
+SET @str = IF(@broken_pfs > 0, @cmd, 'SET @dummy = 0');
+PREPARE stmt FROM @str;
+EXECUTE stmt;
+DROP PREPARE stmt;
+
+drop procedure mysql.die;
+
+--
+-- From this point, only create the performance schema tables
+-- if the server is build with performance schema
+--
+
+set @have_pfs= (select count(engine) from information_schema.engines where engine='PERFORMANCE_SCHEMA' and support != 'NO');
 
 --
 -- TABLE COND_INSTANCES

=== modified file 'sql-common/client.c'
--- a/sql-common/client.c	2009-12-16 08:33:54 +0000
+++ b/sql-common/client.c	2010-03-04 11:13:46 +0000
@@ -1961,7 +1961,7 @@ const MY_CSET_OS_NAME charsets[]=
   {"cp10029",        "macce",    my_cs_exact},
   {"cp12001",        "utf32",    my_cs_unsupp},
   {"cp20107",        "swe7",     my_cs_exact},
-  {"cp20127",        "ascii",    my_cs_exact},
+  {"cp20127",        "latin1",   my_cs_approx},
   {"cp20866",        "koi8r",    my_cs_exact},
   {"cp20932",        "ujis",     my_cs_exact},
   {"cp20936",        "gb2312",   my_cs_approx},
@@ -1989,11 +1989,11 @@ const MY_CSET_OS_NAME charsets[]=
 #else /* not Windows */
 
   {"646",            "latin1",   my_cs_approx}, /* Default on Solaris */
-  {"ANSI_X3.4-1968", "ascii",    my_cs_exact},
+  {"ANSI_X3.4-1968", "latin1",   my_cs_approx},
   {"ansi1251",       "cp1251",   my_cs_exact},
   {"armscii8",       "armscii8", my_cs_exact},
   {"armscii-8",      "armscii8", my_cs_exact},
-  {"ASCII",          "ascii",    my_cs_exact},
+  {"ASCII",          "latin1",   my_cs_approx},
   {"Big5",           "big5",     my_cs_exact},
   {"cp1251",         "cp1251",   my_cs_exact},
   {"cp1255",         "hebrew",   my_cs_approx},
@@ -2066,7 +2066,7 @@ const MY_CSET_OS_NAME charsets[]=
 
   {"ujis",           "ujis",     my_cs_exact},
 
-  {"US-ASCII",       "ascii",    my_cs_exact},
+  {"US-ASCII",       "latin1",   my_cs_approx},
 
   {"utf8",           "utf8",     my_cs_exact},
   {"utf-8",          "utf8",     my_cs_exact},

=== modified file 'sql/mysql_priv.h'
--- a/sql/mysql_priv.h	2010-03-03 19:22:02 +0000
+++ b/sql/mysql_priv.h	2010-03-05 13:08:21 +0000
@@ -2687,7 +2687,8 @@ enum options_mysqld
   OPT_SSL_CIPHER,
   OPT_SSL_KEY,
   OPT_WANT_CORE,
-  OPT_ENGINE_CONDITION_PUSHDOWN
+  OPT_ENGINE_CONDITION_PUSHDOWN,
+  OPT_LOG_ERROR
 };
 
 #endif /* MYSQL_SERVER */

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2010-03-03 19:22:02 +0000
+++ b/sql/mysqld.cc	2010-03-05 13:08:21 +0000
@@ -3962,6 +3962,11 @@ static int init_server_components()
     else
       fn_format(log_error_file, log_error_file_ptr, mysql_data_home, ".err",
                 MY_UNPACK_FILENAME | MY_SAFE_PATH);
+    /*
+      _ptr may have been set to my_disabled_option or "" if no argument was
+      passed, but we need to show the real name in SHOW VARIABLES:
+    */
+    log_error_file_ptr= log_error_file;
     if (!log_error_file[0])
       opt_error_log= 0;                         // Too long file name
     else
@@ -7357,6 +7362,14 @@ mysqld_get_one_option(int optid,
       global_system_variables.optimizer_switch&=
         ~OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN;
     break;
+  case OPT_LOG_ERROR:
+    /*
+      "No --log-error" == "write errors to stderr",
+      "--log-error without argument" == "write errors to a file".
+    */
+    if (argument == NULL) /* no argument */
+      log_error_file_ptr= const_cast<char*>("");
+    break;
   }
   return 0;
 }

=== modified file 'sql/sys_vars.cc'
--- a/sql/sys_vars.cc	2010-03-03 19:22:02 +0000
+++ b/sql/sys_vars.cc	2010-03-05 13:08:21 +0000
@@ -895,7 +895,8 @@ static Sys_var_mybool Sys_trust_function
 
 static Sys_var_charptr Sys_log_error(
        "log_error", "Error log file",
-       READ_ONLY GLOBAL_VAR(log_error_file_ptr), CMD_LINE(OPT_ARG),
+       READ_ONLY GLOBAL_VAR(log_error_file_ptr),
+       CMD_LINE(OPT_ARG, OPT_LOG_ERROR),
        IN_FS_CHARSET, DEFAULT(disabled_my_option));
 
 static Sys_var_mybool Sys_log_queries_not_using_indexes(

=== modified file 'storage/perfschema/pfs_instr.cc'
--- a/storage/perfschema/pfs_instr.cc	2010-03-02 00:10:01 +0000
+++ b/storage/perfschema/pfs_instr.cc	2010-03-05 01:36:54 +0000
@@ -746,6 +746,26 @@ find_or_create_file(PFS_thread *thread,
     }
   }
 
+  char safe_buffer[FN_REFLEN];
+  const char *safe_filename;
+
+  if (len >= FN_REFLEN)
+  {
+    /*
+      The instrumented code uses file names that exceeds FN_REFLEN.
+      This could be legal for instrumentation on non mysys APIs,
+      so we support it.
+      Truncate the file name so that:
+      - it fits into pfs->m_filename
+      - it is safe to use mysys apis to normalize the file name.
+    */
+    memcpy(safe_buffer, filename, FN_REFLEN - 2);
+    safe_buffer[FN_REFLEN - 1]= 0;
+    safe_filename= safe_buffer;
+  }
+  else
+    safe_filename= filename;
+
   /*
     Normalize the file name to avoid duplicates when using aliases:
     - absolute or relative paths
@@ -759,7 +779,7 @@ find_or_create_file(PFS_thread *thread,
     Ignore errors, the file may not exist.
     my_realpath always provide a best effort result in buffer.
   */
-  (void) my_realpath(buffer, filename, MYF(0));
+  (void) my_realpath(buffer, safe_filename, MYF(0));
 
   normalized_filename= buffer;
   normalized_length= strlen(normalized_filename);

=== modified file 'strings/ctype-uca.c'
--- a/strings/ctype-uca.c	2010-02-24 09:15:34 +0000
+++ b/strings/ctype-uca.c	2010-03-04 12:02:30 +0000
@@ -6983,9 +6983,18 @@ static int my_uca_scanner_next_any(my_uc
                                           scanner->send)) <= 0))
       return -1;
     
-    scanner->page= wc >> 8;
-    scanner->code= wc & 0xFF;
     scanner->sbeg+= mb_len;
+    if (wc > 0xFFFF)
+    {
+      /* Return 0xFFFD as weight for all characters outside BMP */
+      scanner->wbeg= nochar;
+      return 0xFFFD;
+    }
+    else
+    {
+      scanner->page= wc >> 8;
+      scanner->code= wc & 0xFF;
+    }
     
     if (scanner->contractions && !scanner->page &&
         (scanner->code > 0x40) && (scanner->code < 0x80))

=== modified file 'strings/ctype-ucs2.c'
--- a/strings/ctype-ucs2.c	2010-02-27 07:43:32 +0000
+++ b/strings/ctype-ucs2.c	2010-03-04 15:39:32 +0000
@@ -50,8 +50,6 @@
 static unsigned long lfactor[9]=
 { 1L, 10L, 100L, 1000L, 10000L, 100000L, 1000000L, 10000000L, 100000000L };
 
-#define REPLACEMENT_CHAR 0xFFFD;
-
 
 
 #ifdef HAVE_CHARSET_mb2_or_mb4
@@ -1145,7 +1143,7 @@ my_tosort_utf16(MY_UNICASE_INFO **uni_pl
   }
   else
   {
-    *wc= REPLACEMENT_CHAR;
+    *wc= MY_CS_REPLACEMENT_CHARACTER;
   }
 }
 
@@ -1874,7 +1872,7 @@ my_tosort_utf32(MY_UNICASE_INFO **uni_pl
   }
   else
   {
-    *wc= REPLACEMENT_CHAR;
+    *wc= MY_CS_REPLACEMENT_CHARACTER;
   }
 }
 

=== modified file 'strings/ctype-utf8.c'
--- a/strings/ctype-utf8.c	2010-02-24 09:15:34 +0000
+++ b/strings/ctype-utf8.c	2010-03-04 11:00:32 +0000
@@ -1720,9 +1720,6 @@ MY_UNICASE_INFO *my_unicase_turkish[256]
 };
 
 
-#define REPLACEMENT_CHAR 0xFFFD;
-
-
 static inline void
 my_tosort_unicode(MY_UNICASE_INFO **uni_plane, my_wc_t *wc)
 {
@@ -1734,7 +1731,7 @@ my_tosort_unicode(MY_UNICASE_INFO **uni_
   }
   else
   {
-    *wc= REPLACEMENT_CHAR;
+    *wc= MY_CS_REPLACEMENT_CHARACTER;
   }
 }
 
@@ -1757,7 +1754,7 @@ my_wildcmp_unicode(CHARSET_INFO *cs,
 {
   int result= -1;                             /* Not found, using wildcards */
   my_wc_t s_wc, w_wc;
-  int scan, plane;
+  int scan;
   int (*mb_wc)(struct charset_info_st *, my_wc_t *,
                const uchar *, const uchar *);
   mb_wc= cs->cset->mb_wc;

Attachment: [text/bzr-bundle] bzr/marc.alff@oracle.com-20100307174151-fv8e7yzesez1dua2.bundle
Thread
bzr commit into mysql-next-mr-bugfixing branch (marc.alff:3123) Marc Alff7 Mar