2 messages in com.mysql.lists.bugsA multiple insert into a table with a...
FromSent OnAttachments
Rafael Kitover09 Jul 2001 16:18 
Timothy Smith09 Jul 2001 16:49 
Subject:A multiple insert into a table with auto_increment breaks last_insert_id()
From:Rafael Kitover (cae@debian.org)
Date:07/09/2001 04:18:40 PM
List:com.mysql.lists.bugs

Description: A multiple insert into a table with auto_increment breaks last_insert_id() How-To-Repeat:

(output edited for noise)

Here is what normally happens: mysql> create table foo (a integer auto_increment primary key, b integer); mysql> insert into foo (b) values (1); mysql> insert into foo (b) values (1); mysql> insert into foo (b) values (1); mysql> insert into foo (b) values (1); mysql> insert into foo (b) values (1); mysql> select * from foo; +---+------+ | a | b | +---+------+ | 1 | 1 | | 2 | 1 | | 3 | 1 | | 4 | 1 | | 5 | 1 | +---+------+ mysql> select last_insert_id(); | 5 |

Here is what happens when a multiple insert is tried:

mysql> create table foo (a integer auto_increment primary key, b integer); mysql> insert into foo (b) values (1),(1),(1),(1),(1); mysql> select * from foo; +---+------+ | a | b | +---+------+ | 1 | 1 | | 2 | 1 | | 3 | 1 | | 4 | 1 | | 5 | 1 | +---+------+ mysql> select last_insert_id(); | 1 |

But it should at this point be 5. Apparently it is only updated for the first value in a multiple insert.

Fix: Originator: Rafael Kitover Organization: Gradience, Inc. MySQL support: none Synopsis: Spurious complaints about duplicate columns in create table/select Severity: non-critical Priority: low Category: mysql Class: sw-bug Release: mysql-3.23.39 (Source distribution)

Environment:

Pentium 3, Debian unstable, i686

ares rkitover 16:11 ~/warehouse > ldd `which mysqld` librt.so.1 => /lib/librt.so.1 (0x4001c000) libwrap.so.0 => /lib/libwrap.so.0 (0x4002e000) libdl.so.2 => /lib/libdl.so.2 (0x40036000) libpthread.so.0 => /lib/libpthread.so.0 (0x4003a000) libz.so.1 => /usr/lib/libz.so.1 (0x40050000) libcrypt.so.1 => /lib/libcrypt.so.1 (0x4005f000) libnsl.so.1 => /lib/libnsl.so.1 (0x4008d000) libstdc++-libc6.2-2.so.3 => /usr/lib/libstdc++-libc6.2-2.so.3 (0x400a3000) libm.so.6 => /lib/libm.so.6 (0x400e9000) libc.so.6 => /lib/libc.so.6 (0x4010b000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)

System: Linux ares 2.2.15 #1 Sat May 20 09:44:52 PDT 2000 i686 unknown Architecture: i686

Some paths: /usr/bin/perl /usr/bin/make /usr/local/bin/gmake /usr/bin/gcc
/usr/bin/cc GCC: Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.3/specs gcc version 2.95.3 20010315 (Debian release) Compilation info: CC='gcc' CFLAGS='-O2 -g' CXX='g++' CXXFLAGS='-O2 -g
-felide-constructors -fno-exceptions -fno-rtti' LDFLAGS='' LIBC: lrwxrwxrwx 1 root root 14 Apr 11 18:44 /lib/libc.so.5 ->
libc.so.5.4.46 -rw-r--r-- 1 root root 589460 Mar 19 05:47 /lib/libc.so.5.4.46 lrwxrwxrwx 1 root root 13 Jun 15 21:24 /lib/libc.so.6 ->
libc-2.2.3.so -rw-r--r-- 1 root root 651436 Feb 20 1999 /lib/libc-2.0.7.so -rwxr-xr-x 1 root root 1124904 Jun 10 07:50 /lib/libc-2.2.3.so -rw-r--r-- 1 root root 2543574 Jun 10 07:52 /usr/lib/libc.a -rw-r--r-- 1 root root 178 Jun 10 07:52 /usr/lib/libc.so Configure command: ./configure --prefix=/usr --exec-prefix=/usr
--libexecdir=/usr/sbin --datadir=/usr/share --sysconfdir=/etc/mysql
--localstatedir=/var/lib/mysql --includedir=/usr/include
--infodir=/usr/share/info --mandir=/usr/share/man --enable-shared --with-libwrap
--enable-assembler --with-berkeley-db --with-innodb --enable-static
--enable-shared --with-raid --enable-thread-safe-client --without-readline
--with-unix-socket-path=/var/run/mysqld/mysqld.sock --with-mysqld-user=mysql
--without-bench --with-extra-charsets=all