Nulls and unique indexes.

2002-06-18 Thread jon . barker

Description:
  If a null column is used in a unique index then mysql fails to throw a
 key violation when multiple identical inserts (with nulls) are
 performed.
How-To-Repeat:
  create table test (a int null, b int null);
  alter table test add unique index index_ab (a,b);
  insert into test (a,b) values(1,null);
  insert into test (a,b) values(1,null);
  insert into test (a,b) values(1,null);
  select * from test;
  +--+--+
  | a| b|
  +--+--+
  |1 | NULL |
  |1 | NULL |
  |1 | NULL |
  +--+--+
  3 rows in set (0.00 sec)

  insert into test (a,b) values(1,1);
  insert into test (a,b) values(1,1);
  ERROR 1062: Duplicate entry '1-1' for key 1
Fix:
 No fix.

Submitter-Id:  submitter ID
Originator:Jon Barker
Organization:
 
MySQL support: none
Synopsis:  NULLs don't work correctly in unique indexes.
Severity:  serious
Priority:  
Category:  mysql
Class: 
Release:   mysql-3.23.41 (Official MySQL RPM)

Environment:

System: Linux x.catchword.co.uk 2.4.18ptixfs #11 Thu May 2 14:00:21 GMT 2002 i686 
unknown
Architecture: i686

Some paths:  /usr/bin/perl /usr/bin/make /usr/bin/gmake /usr/bin/gcc /usr/bin/cc
GCC: Reading specs from /usr/lib/gcc-lib/i586-mandrake-linux/2.96/specs
gcc version 2.96 2731 (Linux-Mandrake 8.0 2.96-0.48mdk)
Compilation info: CC='egcs'  CFLAGS='-O6 -fno-omit-frame-pointer -mpentium'  
CXX='egcs'  CXXFLAGS='-O6 -fno-omit-frame-pointer-felide-constructors 
-fno-exceptions -fno-rtti -mpentium'  LDFLAGS=''
LIBC: 
lrwxrwxrwx1 root root   13 Sep 28  2001 /lib/libc.so.6 - libc-2.2.2.so
-rwxr-xr-x1 root root  1216268 Feb 21  2001 /lib/libc-2.2.2.so
-rw-r--r--1 root root 26366908 Feb 21  2001 /usr/lib/libc.a
-rw-r--r--1 root root  178 Feb 21  2001 /usr/lib/libc.so
Configure command: ./configure  --disable-shared --with-mysqld-ldflags=-all-static 
--with-client-ldflags=-all-static --without-berkeley-db --without-innodb 
--enable-assembler --with-mysqld-user=mysql 
--with-unix-socket-path=/var/lib/mysql/mysql.sock --prefix=/ 
--with-extra-charsets=complex --exec-prefix=/usr --libexecdir=/usr/sbin 
--sysconfdir=/etc --datadir=/usr/share --localstatedir=/var/lib/mysql 
--infodir=/usr/info --includedir=/usr/include --mandir=/usr/man 
'--with-comment=Official MySQL RPM'


-
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




Re: Nulls and unique indexes.

2002-06-18 Thread Gerald Clark

That is correct.
Use NOT NULL in the definition to force unique keys.

[EMAIL PROTECTED] wrote:

Description:

  If a null column is used in a unique index then mysql fails to throw a
 key violation when multiple identical inserts (with nulls) are
 performed.

How-To-Repeat:

  create table test (a int null, b int null);
  alter table test add unique index index_ab (a,b);
  insert into test (a,b) values(1,null);
  insert into test (a,b) values(1,null);
  insert into test (a,b) values(1,null);
  select * from test;
  +--+--+
  | a| b|
  +--+--+
  |1 | NULL |
  |1 | NULL |
  |1 | NULL |
  +--+--+
  3 rows in set (0.00 sec)

  insert into test (a,b) values(1,1);
  insert into test (a,b) values(1,1);
  ERROR 1062: Duplicate entry '1-1' for key 1

Fix:

 No fix.

Submitter-Id: submitter ID
Originator:   Jon Barker
Organization:

 

MySQL support: none
Synopsis: NULLs don't work correctly in unique indexes.
Severity: serious
Priority: 
Category: mysql
Class:
Release:  mysql-3.23.41 (Official MySQL RPM)


Environment:

   




-
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




Re: Nulls and unique indexes.

2002-06-18 Thread Jon Barker


Doh! Blindsided by an Oracle DBA, the only spec I could get my hands on
is an old draft thing and I have to admit from that it looks like the
correct behaviour.. NULL  NULL and all that.. 

Thanks,
Jon

On Tue, 18 Jun 2002 10:54:15 -0500
Gerald Clark [EMAIL PROTECTED] wrote:
 That is correct.
 Use NOT NULL in the definition to force unique keys.
 
 [EMAIL PROTECTED] wrote:
 
 Description:
 
   If a null column is used in a unique index then mysql fails to throw a
  key violation when multiple identical inserts (with nulls) are
  performed.
 
 How-To-Repeat:
 
   create table test (a int null, b int null);
   alter table test add unique index index_ab (a,b);
   insert into test (a,b) values(1,null);
   insert into test (a,b) values(1,null);
   insert into test (a,b) values(1,null);
   select * from test;
   +--+--+
   | a| b|
   +--+--+
   |1 | NULL |
   |1 | NULL |
   |1 | NULL |
   +--+--+
   3 rows in set (0.00 sec)
 
   insert into test (a,b) values(1,1);
   insert into test (a,b) values(1,1);
   ERROR 1062: Duplicate entry '1-1' for key 1
 
 Fix:
 
  No fix.
 
 Submitter-Id:   submitter ID
 Originator: Jon Barker
 Organization:
 
  
 
 MySQL support: none
 Synopsis:   NULLs don't work correctly in unique indexes.
 Severity:   serious
 Priority:   
 Category:   mysql
 Class:  
 Release:mysql-3.23.41 (Official MySQL RPM)
 
 
 Environment:
 
  
 
 

-
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