473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

4.0.15 foreign key creation bug?

The table creation script(at the end of this post) works fine on
4.0.1-alpha-win, but the foreign key constraints fail on 4.0.15-win. I
am starting the server with the same command for both versions:

mysqld-max-nt --console --transaction-isolation=SERIALIZABLE

In 4.0.15-win I can extract the following error after I run the table
creation script:

[test01] ERROR 1005: Can't create table '.\ibdata\#sql-a14_3.frm'
(errno: 150)

Also, the InnoDB status in 4.0.150-win shows:
------------------------
LATEST FOREIGN KEY ERROR
------------------------
030930 19:38:49 Error in foreign key constraint of table
ibdata/#sql-a14_3:
Cannot find an index in the referenced table where the
referenced columns appear as the first columns, or column types
in the table and the referenced table do not match for constraint:
FOREIGN KEY (contactInfo_fk) REFERENCES contact(pk) ON DELETE SET NULL
See http://www.innodb.com/ibman.html for correct foreign key
definition.

But the above is wrong. I DO have an index defined on the foreign key,
it IS the first column in the index, and their IS NO type mismatch.
Since this works on 4.0.1, I have to think this is a bug. I need a
working version of the server that supports transaction savepoints.
Any help appreciated!!

# Connection: test01
# Host: localhost
# Saved: 2003-09-29 18:16:42
#
CREATE TABLE orderjoin (
owner BIGINT,owned BIGINT
) TYPE=InnoDB;
CREATE TABLE orders (
pk BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, last_modified
TIMESTAMP,date DATETIME, PRIMARY KEY (pk)
) TYPE=InnoDB;
CREATE TABLE lineitem (
pk BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, last_modified
TIMESTAMP,orderFk BIGINT,description VARCHAR(128),price DOUBLE,
PRIMARY KEY (pk)
) TYPE=InnoDB;
CREATE TABLE alias (
customer_fk BIGINT,alias_str VARCHAR(128)
) TYPE=InnoDB;
CREATE TABLE address (
address_pk BIGINT UNSIGNED AUTO_INCREMENT NOT NULL,
last_modified TIMESTAMP,address2 VARCHAR(128),zip
VARCHAR(128),address1 VARCHAR(128),discriminator VARCHAR(128), PRIMARY
KEY (address_pk)
) TYPE=InnoDB;
CREATE TABLE contact (
pk BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, last_modified
TIMESTAMP,email VARCHAR(128),phone VARCHAR(128), PRIMARY KEY (pk)
) TYPE=InnoDB;
CREATE TABLE discount (
pk BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, last_modified
TIMESTAMP,percent FLOAT,discount_plan_name VARCHAR(128), PRIMARY KEY
(pk)
) TYPE=InnoDB;
CREATE TABLE customer (
pk BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, last_modified
TIMESTAMP,address2 VARCHAR(128),lname VARCHAR(128),address1
VARCHAR(128),discount_fk BIGINT,gender VARCHAR(128),fname
VARCHAR(128),discriminator VARCHAR(128),zip
VARCHAR(128),contactInfo_fk BIGINT, PRIMARY KEY (pk)
) TYPE=InnoDB;
ALTER TABLE orderjoin ADD INDEX (owner);
ALTER TABLE orderjoin ADD FOREIGN KEY (owner) REFERENCES customer(pk)
ON DELETE SET NULL;
ALTER TABLE orderjoin ADD INDEX (owned);
ALTER TABLE orderjoin ADD FOREIGN KEY (owned) REFERENCES orders(pk) ON
DELETE SET NULL;
ALTER TABLE lineitem ADD INDEX (orderFk);
ALTER TABLE lineitem ADD FOREIGN KEY (orderFk) REFERENCES orders(pk)
ON DELETE SET NULL;
ALTER TABLE alias ADD INDEX (customer_fk);
ALTER TABLE alias ADD FOREIGN KEY (customer_fk) REFERENCES
customer(pk) ON DELETE SET NULL;
ALTER TABLE discount ADD UNIQUE uindex (discount_plan_name);
ALTER TABLE customer ADD INDEX (discount_fk);
ALTER TABLE customer ADD FOREIGN KEY (discount_fk) REFERENCES
discount(pk) ON DELETE SET NULL;
ALTER TABLE customer ADD INDEX (contactInfo_fk);
ALTER TABLE customer ADD FOREIGN KEY (contactInfo_fk) REFERENCES
contact(pk) ON DELETE SET NULL;
ALTER TABLE customer ADD UNIQUE uindex (lname);
Jul 19 '05 #1
2 3892
SOLVED the problem. Yes it is a different behavior between the two
versions. in 4.0.1-alpha-win the difference between BIGINT and BIGINT
UNSIGNED slipped through. On 4.0.15-win, the foreign key creation
process distinguished the difference and considers the types
different, thus not allowing the foreign key to be created.

gh******@telcontar.com (geoff) wrote in message news:<99**************************@posting.google. com>...
The table creation script(at the end of this post) works fine on
4.0.1-alpha-win, but the foreign key constraints fail on 4.0.15-win. I
am starting the server with the same command for both versions:

mysqld-max-nt --console --transaction-isolation=SERIALIZABLE

In 4.0.15-win I can extract the following error after I run the table
creation script:

[test01] ERROR 1005: Can't create table '.\ibdata\#sql-a14_3.frm'
(errno: 150)

Also, the InnoDB status in 4.0.150-win shows:
------------------------
LATEST FOREIGN KEY ERROR
------------------------
030930 19:38:49 Error in foreign key constraint of table
ibdata/#sql-a14_3:
Cannot find an index in the referenced table where the
referenced columns appear as the first columns, or column types
in the table and the referenced table do not match for constraint:
FOREIGN KEY (contactInfo_fk) REFERENCES contact(pk) ON DELETE SET NULL
See http://www.innodb.com/ibman.html for correct foreign key
definition.

But the above is wrong. I DO have an index defined on the foreign key,
it IS the first column in the index, and their IS NO type mismatch.
Since this works on 4.0.1, I have to think this is a bug. I need a
working version of the server that supports transaction savepoints.
Any help appreciated!!

# Connection: test01
# Host: localhost
# Saved: 2003-09-29 18:16:42
#
CREATE TABLE orderjoin (
owner BIGINT,owned BIGINT
) TYPE=InnoDB;
CREATE TABLE orders (
pk BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, last_modified
TIMESTAMP,date DATETIME, PRIMARY KEY (pk)
) TYPE=InnoDB;
CREATE TABLE lineitem (
pk BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, last_modified
TIMESTAMP,orderFk BIGINT,description VARCHAR(128),price DOUBLE,
PRIMARY KEY (pk)
) TYPE=InnoDB;
CREATE TABLE alias (
customer_fk BIGINT,alias_str VARCHAR(128)
) TYPE=InnoDB;
CREATE TABLE address (
address_pk BIGINT UNSIGNED AUTO_INCREMENT NOT NULL,
last_modified TIMESTAMP,address2 VARCHAR(128),zip
VARCHAR(128),address1 VARCHAR(128),discriminator VARCHAR(128), PRIMARY
KEY (address_pk)
) TYPE=InnoDB;
CREATE TABLE contact (
pk BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, last_modified
TIMESTAMP,email VARCHAR(128),phone VARCHAR(128), PRIMARY KEY (pk)
) TYPE=InnoDB;
CREATE TABLE discount (
pk BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, last_modified
TIMESTAMP,percent FLOAT,discount_plan_name VARCHAR(128), PRIMARY KEY
(pk)
) TYPE=InnoDB;
CREATE TABLE customer (
pk BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, last_modified
TIMESTAMP,address2 VARCHAR(128),lname VARCHAR(128),address1
VARCHAR(128),discount_fk BIGINT,gender VARCHAR(128),fname
VARCHAR(128),discriminator VARCHAR(128),zip
VARCHAR(128),contactInfo_fk BIGINT, PRIMARY KEY (pk)
) TYPE=InnoDB;
ALTER TABLE orderjoin ADD INDEX (owner);
ALTER TABLE orderjoin ADD FOREIGN KEY (owner) REFERENCES customer(pk)
ON DELETE SET NULL;
ALTER TABLE orderjoin ADD INDEX (owned);
ALTER TABLE orderjoin ADD FOREIGN KEY (owned) REFERENCES orders(pk) ON
DELETE SET NULL;
ALTER TABLE lineitem ADD INDEX (orderFk);
ALTER TABLE lineitem ADD FOREIGN KEY (orderFk) REFERENCES orders(pk)
ON DELETE SET NULL;
ALTER TABLE alias ADD INDEX (customer_fk);
ALTER TABLE alias ADD FOREIGN KEY (customer_fk) REFERENCES
customer(pk) ON DELETE SET NULL;
ALTER TABLE discount ADD UNIQUE uindex (discount_plan_name);
ALTER TABLE customer ADD INDEX (discount_fk);
ALTER TABLE customer ADD FOREIGN KEY (discount_fk) REFERENCES
discount(pk) ON DELETE SET NULL;
ALTER TABLE customer ADD INDEX (contactInfo_fk);
ALTER TABLE customer ADD FOREIGN KEY (contactInfo_fk) REFERENCES
contact(pk) ON DELETE SET NULL;
ALTER TABLE customer ADD UNIQUE uindex (lname);

Jul 19 '05 #2
SOLVED the problem. Yes it is a different behavior between the two
versions. in 4.0.1-alpha-win the difference between BIGINT and BIGINT
UNSIGNED slipped through. On 4.0.15-win, the foreign key creation
process distinguished the difference and considers the types
different, thus not allowing the foreign key to be created.

gh******@telcontar.com (geoff) wrote in message news:<99**************************@posting.google. com>...
The table creation script(at the end of this post) works fine on
4.0.1-alpha-win, but the foreign key constraints fail on 4.0.15-win. I
am starting the server with the same command for both versions:

mysqld-max-nt --console --transaction-isolation=SERIALIZABLE

In 4.0.15-win I can extract the following error after I run the table
creation script:

[test01] ERROR 1005: Can't create table '.\ibdata\#sql-a14_3.frm'
(errno: 150)

Also, the InnoDB status in 4.0.150-win shows:
------------------------
LATEST FOREIGN KEY ERROR
------------------------
030930 19:38:49 Error in foreign key constraint of table
ibdata/#sql-a14_3:
Cannot find an index in the referenced table where the
referenced columns appear as the first columns, or column types
in the table and the referenced table do not match for constraint:
FOREIGN KEY (contactInfo_fk) REFERENCES contact(pk) ON DELETE SET NULL
See http://www.innodb.com/ibman.html for correct foreign key
definition.

But the above is wrong. I DO have an index defined on the foreign key,
it IS the first column in the index, and their IS NO type mismatch.
Since this works on 4.0.1, I have to think this is a bug. I need a
working version of the server that supports transaction savepoints.
Any help appreciated!!

# Connection: test01
# Host: localhost
# Saved: 2003-09-29 18:16:42
#
CREATE TABLE orderjoin (
owner BIGINT,owned BIGINT
) TYPE=InnoDB;
CREATE TABLE orders (
pk BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, last_modified
TIMESTAMP,date DATETIME, PRIMARY KEY (pk)
) TYPE=InnoDB;
CREATE TABLE lineitem (
pk BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, last_modified
TIMESTAMP,orderFk BIGINT,description VARCHAR(128),price DOUBLE,
PRIMARY KEY (pk)
) TYPE=InnoDB;
CREATE TABLE alias (
customer_fk BIGINT,alias_str VARCHAR(128)
) TYPE=InnoDB;
CREATE TABLE address (
address_pk BIGINT UNSIGNED AUTO_INCREMENT NOT NULL,
last_modified TIMESTAMP,address2 VARCHAR(128),zip
VARCHAR(128),address1 VARCHAR(128),discriminator VARCHAR(128), PRIMARY
KEY (address_pk)
) TYPE=InnoDB;
CREATE TABLE contact (
pk BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, last_modified
TIMESTAMP,email VARCHAR(128),phone VARCHAR(128), PRIMARY KEY (pk)
) TYPE=InnoDB;
CREATE TABLE discount (
pk BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, last_modified
TIMESTAMP,percent FLOAT,discount_plan_name VARCHAR(128), PRIMARY KEY
(pk)
) TYPE=InnoDB;
CREATE TABLE customer (
pk BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, last_modified
TIMESTAMP,address2 VARCHAR(128),lname VARCHAR(128),address1
VARCHAR(128),discount_fk BIGINT,gender VARCHAR(128),fname
VARCHAR(128),discriminator VARCHAR(128),zip
VARCHAR(128),contactInfo_fk BIGINT, PRIMARY KEY (pk)
) TYPE=InnoDB;
ALTER TABLE orderjoin ADD INDEX (owner);
ALTER TABLE orderjoin ADD FOREIGN KEY (owner) REFERENCES customer(pk)
ON DELETE SET NULL;
ALTER TABLE orderjoin ADD INDEX (owned);
ALTER TABLE orderjoin ADD FOREIGN KEY (owned) REFERENCES orders(pk) ON
DELETE SET NULL;
ALTER TABLE lineitem ADD INDEX (orderFk);
ALTER TABLE lineitem ADD FOREIGN KEY (orderFk) REFERENCES orders(pk)
ON DELETE SET NULL;
ALTER TABLE alias ADD INDEX (customer_fk);
ALTER TABLE alias ADD FOREIGN KEY (customer_fk) REFERENCES
customer(pk) ON DELETE SET NULL;
ALTER TABLE discount ADD UNIQUE uindex (discount_plan_name);
ALTER TABLE customer ADD INDEX (discount_fk);
ALTER TABLE customer ADD FOREIGN KEY (discount_fk) REFERENCES
discount(pk) ON DELETE SET NULL;
ALTER TABLE customer ADD INDEX (contactInfo_fk);
ALTER TABLE customer ADD FOREIGN KEY (contactInfo_fk) REFERENCES
contact(pk) ON DELETE SET NULL;
ALTER TABLE customer ADD UNIQUE uindex (lname);

Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jeremiah Jacks | last post by:
I just upgraded to MySQL 4.0.14-standard for RedHat Linux and am using = the pre-compiled binaries. I have a database with INNODB tables. When I insert a row into one of the child tables, I get...
10
by: Bodza Bodza | last post by:
I'm having an argument with an incumbent self-taught programmer that it is OK to use null foreign keys in database design. My take is the whole point of a foreign key is that it's not supposed...
31
by: Robert Brown | last post by:
Let's say I have a type hierarchy: (just an example) the general entity customer: CREATE TABLE customer(customer_id int, customer_name varchar(250), customer_type int) three specific...
0
by: Scott Ribe | last post by:
I've got a problem which I think may be a bug in Postgres, but I wonder if I'm missing something. Two tables, A & B have foreign key relations to each other. A 3rd table C, inherits from A. A...
10
by: Shawn Chisholm | last post by:
Hi, I am trying to deal with a deadlock situation caused by foreign key references on insert and I was wondering if anyone knows what order the foreign keys are locked (or evaluated) in for a...
2
by: Ian Davies | last post by:
I have created a database with about 17 tables. I have been creating foreign keys some of which have worked but when creating others I get the message below ************************* 1005...
9
by: sonal | last post by:
Hi all, I hv started with python just recently... and have been assigned to make an utility which would be used for data validations... In short we take up various comma separated data files for...
0
by: ckiraly | last post by:
Greetings everyone - I am new to MSSQL 2005, and have started a database design project for my company. The issue I have is in a specific instance of foreign key creation. Here is the whole...
9
by: sheenaa | last post by:
Hello frdz, I m working with SQL SERVER 2005. My problem is with the creation of foreign key for some table thru which i m not able to insert the data. This table are samples i have included...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.