EDIT: I seem to get the error listed below on every insert no matter what data I try to insert. So maybe my table was corrupted or something? Anyway, here's my question:
I have a MySQL table
CREATE TABLE `AcpConfig` (
`ndss_id` int(11) NOT NULL default '0',
`acp_id` int(11) NOT NULL default '0',
`run_date` date NOT NULL default '0000-00-00',
`hw_5_threshold` tinyint(1) NOT NULL default '0',
`stp_on` tinyint(1) NOT NULL default '0',
`sort_on` tinyint(1) NOT NULL default '0',
`afcs_ocr_message_format` tinyint(1) NOT NULL default '0',
`use_hw` tinyint(1) NOT NULL default '0',
`test_mode` tinyint(1) NOT NULL default '0',
`afcs_version` varchar(255) NOT NULL default '',
`acp_build` varchar(255) NOT NULL default '',
`id` int(11) NOT NULL auto_increment,
`swstp_in_acp_rack` int(11) NOT NULL default '0',
`acplookup_id` int(11) NOT NULL default '0',
`bfind_cksum` varchar(255) NOT NULL default '',
`tz_cksum` varchar(255) NOT NULL default '',
`fetched` varchar(4) NOT NULL default '"NO"',
PRIMARY KEY (`id`),
UNIQUE KEY `ndss_id` (`ndss_id`,`acp_id`,`run_date`),
KEY `ndss_acp` (`ndss_id`,`acp_id`),
KEY `ndss_acp_rundate` (`ndss_id`,`acp_id`,`run_date`),
KEY `run_date` (`run_date`),
KEY `acplookup_rundate` (`acplookup_id`,`run_date`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
And it's got about half a million rows. I'm trying to perform a simple INSERT
INSERT INTO AcpConfig (ndss_id, acp_id, run_date, hw_5_threshold, stp_on, sort_on, afcs_ocr_message_format, use_hw, test_mode, afcs_version, acp_build, swstp_in_acp_rack, acplookup_id, bfind_cksum, tz_cksum) VALUES ('75', '5', '2009-07-22', '75', '1', '1', '0', '1', '0', '1.5.2', '041709', '2', '269', '0', '1950359846');
and it gives me the error
ERROR 1062 (23000): Duplicate entry '502831' for key 1
which implies that I'm violating my UNIQUE constraint on the three fields ndss_id, acp_id, and run_date. (The id 502831 is not a row in my table and seems to be the next id that would be used if the row had been inserted.) The problem is, if I SELECT against those fields with the same values
select * from AcpConfig where ndss_id=75 and acp_id=5 and run_date='2009-07-22';
then it returns no results. So I'm not actually duplicating anything. My other keys are all just indexes and not unique constraints; I also have the one UNIQUE constraint as you can see from my CREATE TABLE statement. So why is it telling me that I have a duplicate?