Bug #10690 Tool does not recognize || as concat and (probably) translates it to OR
Submitted: 17 May 2005 15:35 Modified: 4 Oct 2005 7:03
Reporter: [ name withheld ] (Basic Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Query Browser Severity:S2 (Serious)
Version:1.1.9 OS:Windows (windows 2000 sp4)
Assigned to: Alfredo Kojima CPU Architecture:Any

[17 May 2005 15:35] [ name withheld ]
Description:
I have my server (MySQL 5.0.4) with sql-mode=ORACLE, if I run this from command line:
mysql> select @@sql_mode;
+-------------------------------------------------------------------------------
---------------------------------------+
| @@sql_mode
                                       |
+-------------------------------------------------------------------------------
---------------------------------------+
| PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ORACLE,NO_KEY_OPTIONS,NO_TABLE_OPTION
S,NO_FIELD_OPTIONS,NO_AUTO_CREATE_USER |
+-------------------------------------------------------------------------------
---------------------------------------+
1 row in set (0.00 sec)

mysql> select 'a' || 'b' union all select concat('a', 'b');
+------------+
| 'a' || 'b' |
+------------+
| ab         |
| ab         |
+------------+
2 rows in set (0.00 sec)

I get the expected results, but if I run the same query from MySQL Query browser I get:

0
ab

It seems to translate || to OR regardless of server settings.

How to repeat:
Run the query:
select 'a' || 'b' union all select concat('a', 'b');

from command line client and from MySQL Query Browser 1.1.9
[17 May 2005 21:41] Hartmut Holzgraefe
Looks as if sql_mode is always overridden on connect if talking to a >=4.1 server

see mysql-gui-common/library/source/myx_library.c:472ff :

  // make sure we're not in ansi_quotes mode, unless asked to
  if (mysql_version_is_later_or_equal_than(mysql,4,1))
  {
    if (connect_options.ansi_quotes)
      mysql_query(mysql, "SET SESSION sql_mode='ANSI_QUOTES'");
    else
      mysql_query(mysql, "SET SESSION sql_mode=''");
  }
[18 May 2005 7:58] [ name withheld ]
Two questions:
1. Why does a client tool set SQL mode? If it's a server setting it must read it from server and behave accordingly.
2. If this is a bug, why bug 10688 (opened by me) has been marked as !bug?

Regards
[4 Oct 2005 7:03] Mike Lischke
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html