Erling and MySQL guys,

On Fri, Mar 16, 2001 at 02:18:55AM +0100, Erling Paulsen wrote:
> I just exported (via myodbc) an old access database for my sportsclub to
> mysql (the tables). The ms-access database application still works nicely on
> the new linked tables in mysql. However, I'm now also writing a php based
> client to use the database over the web and the problem is as follows:
> 
> They guy that developed the access database used `#' (comment character)
> characters to name certain columns. i.e. "Person#". How can manually select
> such a column in a mysql query (ex. via the mysql client)?  - since it seems
> whatever i enclose the column name in, the rest of the query is interpreted
> as a comment!
> 

The mysql client doesn't know about backticks and therefore handles the #
(and '-- ') as the beginning of a comment. It wouldn't do that for quoted
and double-quoted strings.

I see no workaround other than to change the client/mysql.cc source and
recompile.

Line 983 of client/mysql.cc (in the add_line function) should be changed from:
      else if (!*in_string && (inchar == '\'' || inchar == '"'))
to
      else if (!*in_string && (inchar == '\'' || inchar == '"' || inchar == '`'))

This is for version 3.23.33. The line number may be different for other
versions.

If you want to see the correct continuation character for multi-line
backticks, you would change a few occurrances in read_lines of:

      tee_fputs(glob_buffer.is_empty() ? "mysql> " :
                !in_string ? "    -> " :
                in_string == '\'' ?
                "    '> " : "    \"> ",stdout);

to

      tee_fputs(glob_buffer.is_empty() ? "mysql> " :
                !in_string ? "    -> " :
                in_string == '\`' ? "    `> " :
                in_string == '\'' ?
                "    '> " : "    \"> ",stdout);


I cc'ed this to the bugs mailing list, so it may be fixed in a next
release.

Looking at the sources, the MySQL server will handle this just fine,
so your PHP scripts should run unless PHP does its own parsing of SQL.
(I never use PHP, but I guess it does no such thing).


Regards,

Fred.

-- 
Fred van Engen                              XO Communications B.V.
email: [EMAIL PROTECTED]             Televisieweg 2
tel: +31 36 5462400                         1322 AC  Almere
fax: +31 36 5462424                         The Netherlands

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to