In the last episode (May 24), Michael Widenius said:
>  -----  Message from "Joshua J. Kugler" <[EMAIL PROTECTED]> -----
> 
> Joshua> So, I can "SELECT id FROM table_name WHERE id IS NULL" as many times as I 
> Joshua> need/want to, and it will return the proper value.  Very nice.
> 
> Joshua> So, that was my problem, and the solution.  Could these be changed in the 
> Joshua> official distribution?  Or at least a compile time option?  I see no reason 
> Joshua> why the SELECT NULL behavior cannot mirror the behavior of LAST_INSERT_ID. 
> 
> The reason for the above is mainly a security thing. I think the
> above usage of id IS NULL is very dangerous as a general feature as
> it could have strange side effects for applications that are not
> aware of this.
> 
> To minimize the side effects, we clear the flag after one search to
> not affect the rest of the application.  I don't know if this is the
> best thing to do, but this is the first time we hear about any
> problems regarding this.  The question is of we should add a separate
> option for to get both behavour's or just remove the 'clear for next
> request'.

I had the same problem last November, and worked around it by editing
the source and removing the OPTION_AUTO_IS_NULL flag from
thd_startup_options.  Joshua's solution is better, though, as it allows
"IS NULL" selects and "last_insert_id()" selects to coexist.

Considering that there is no other reason to do an IS NULL query on an
autonumber field, and considering that Access and MS SQL both use this
behaviour, I don't think there is much risk in applying Joshua's patch.

-- 
        Dan Nelson
        [EMAIL PROTECTED]


Hi everybody!
Im writing a client in vbasic that insert data on a mysql 3.23.27-beta
database using myodbc 2.50.31.00 on Win2k, and after insert a new record
when I check for: 
Recordset.Open "SELECT LAST_INSERT_ID();", conection 
it gets empty. Im being using DAO with perl writing asp over windows NT
without any problems.

Any Idea?

Thanks very much,

Jose Albert


-- 
---------------------------------------------------------------------
Please check "http://www.mysql.com/documentation/manual.php"; before
posting. To request this thread, e-mail [EMAIL PROTECTED]

To unsubscribe, send a message to:
    <[EMAIL PROTECTED]>

If you have a broken mail client that cannot send a message to
the above address (Microsoft Outlook), you can use:
    http://lists.mysql.com/php/unsubscribe.php




In the last episode (Nov 26), Jose Albert (personal) said:
> Hi everybody!
> Im writing a client in vbasic that insert data on a mysql
> 3.23.27-beta database using myodbc 2.50.31.00 on Win2k, and after
> insert a new record when I check for: Recordset.Open "SELECT
> LAST_INSERT_ID();", conection it gets empty. Im being using DAO with
> perl writing asp over windows NT without any problems.

This might be the same problem I've seen in MS Access when I do
something similar.  I think the mysql "auto_is_null" option has a bug
where it zeroes the last_insert_id value.  You insert a record, ODBC
does a "SELECT WHERE key IS NULL" behind your back, mysql zeroes
last_insert_id, you try to "SELECT last_insert_id()", and it returns
zero.

My fix has been to edit mysqld.cc and remove the AUTO_IS_NULL option
from thd_startup_options, but a better fix would probably be to remove
line 3047 from sql_select.cc (the "thd->insert_id(0);" line).

-- 
        Dan Nelson
        [EMAIL PROTECTED]

-- 
---------------------------------------------------------------------
Please check "http://www.mysql.com/documentation/manual.php"; before
posting. To request this thread, e-mail [EMAIL PROTECTED]

To unsubscribe, send a message to:
    <[EMAIL PROTECTED]>

If you have a broken mail client that cannot send a message to
the above address (Microsoft Outlook), you can use:
    http://lists.mysql.com/php/unsubscribe.php



---------------------------------------------------------------------
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