List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:March 12 2003 4:28pm
Subject:RE: automatically incrementing an int value
View as plain text  
At 10:22 -0500 3/12/03, Douglas B. Jones wrote:
>Hi,
>
>I just tried the below:
>
>create table virus (
>         n int auto_increment not null,
>         name char(128) not null,
>         primary key(n),
>         unique(name(100))
>);
>
>with a data file that has 122,111 sql commands like:
>
>replace into virus values(NULL,"VBS/LoveLet-E");
>replace into virus values(NULL,"VBS/LoveLet-E");
>replace into virus values(NULL,"VBS/LoveLet-E");
>replace into virus values(NULL,"VBS/LoveLet-G");
>replace into virus values(NULL,"WM97/Myna-C");
>replace into virus values(NULL,"VBS/LoveLet-G");
>replace into virus values(NULL,"WM97/Myna-C");
>replace into virus values(NULL,"VBS/LoveLet-G");
>replace into virus values(NULL,"VBS/LoveLet-G");
>replace into virus values(NULL,"W32/Sircam-A");
>
>Now when I do a:
>
>grep VBS/LoveLet-G sqlfile | wc
>
>I get:
>
>        123       492      6027
>
>123 entries for VBS/LoveLet-G in the file. When I do a mysqldump of
>the data file and just grep for VBS:
>
>mysqldump virus|grep VBS
>
>INSERT INTO virus VALUES (3,'VBS/LoveLet-E');
>INSERT INTO virus VALUES (111009,'VBS/LoveLet-G');
>INSERT INTO virus VALUES (55841,'VBS/Stages-A');
>INSERT INTO virus VALUES (121521,'VBS/LoveLet-AS');
>INSERT INTO virus VALUES (1208,'VBS/SST-A');
>INSERT INTO virus VALUES (85602,'VBS/VBSWG-X');
>INSERT INTO virus VALUES (1215,'VBS/VBSWG-Z');
>INSERT INTO virus VALUES (5846,'VBS/LoveLet-CL');
>INSERT INTO virus VALUES (5996,'VBS/VBSWG-Fam');
>INSERT INTO virus VALUES (83835,'VBS/Haptime-Fam');
>INSERT INTO virus VALUES (55356,'VBS/LoveLet-F');
>INSERT INTO virus VALUES (55546,'VBS/FreeLinks');
>INSERT INTO virus VALUES (91207,'VBS/Kakworm');
>INSERT INTO virus VALUES (117623,'VBS/Redlof-A');
>
>As you can see, the numbers (n field) are way to high? Is this a bug

Why do you say that?  You indicated that the data file has 122,111 statements
in it.  I see no values for the n column that are larger than that value.
REPLACE will increment the value of n when you specify a value of NULL
for that column.  It's behaving as it's supposed to.  Perhaps you should
use INSERT instead of REPLACE and process the file with mysql --force
to ignore duplicate key errors.  Specify the statements like this:

INSERT INTO virus (name) VALUES('VBS/xxx');

>in mysql or n the sql? Even if I say unique(name) instead of
>unique(name(100)),
>I get the same results. Please note that I have tried destroying the
>table
>as well as the db, still get the same results.
>
>Any ideas?
>
>Thanks,
>Cheers,
>Douglas

Thread
automatically incrementing an int valueDouglas B. Jones10 Mar
Re: automatically incrementing an int valueAlec.Cawley10 Mar
  • RE: automatically incrementing an int valueDouglas B. Jones10 Mar
    • RE: automatically incrementing an int valuePaul DuBois10 Mar
      • RE: automatically incrementing an int valueDouglas B. Jones12 Mar
        • RE: automatically incrementing an int valueDouglas B. Jones12 Mar
        • RE: automatically incrementing an int valuePaul DuBois12 Mar
          • RE: automatically incrementing an int valueDouglas B. Jones12 Mar
            • RE: automatically incrementing an int valuePaul DuBois12 Mar
              • Re: automatically incrementing an int valueBenjamin Pflugmann12 Mar
            • Re: automatically incrementing an int valueJoseph Bueno12 Mar
            • RE: automatically incrementing an int valueKeith C. Ivey12 Mar
        • RE: automatically incrementing an int valueKeith C. Ivey12 Mar
          • RE: automatically incrementing an int valueDouglas B. Jones12 Mar
          • RE: automatically incrementing an int valuePaul DuBois12 Mar
RE: automatically incrementing an int valueAlec.Cawley12 Mar
  • RE: automatically incrementing an int valueDouglas B. Jones12 Mar