waliwali / ibm-db

Automatically exported from code.google.com/p/ibm-db
0 stars 0 forks source link

Insert into doesn't raise exception when breaking PK constraint #68

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create the table. It's important to have at least one CLOB field.
CREATE TABLE TEST.PKTEST
(
  COL1 VARCHAR(32) NOT NULL, -- PK
  COL2 CLOB(131072) NOT NULL,
  PRIMARY KEY (COL1)
);

2. Connect to the DB by ibm_db_dbi
3. Insert two identical rows to the table:

test_row = ("x", "y")
c = conn.cursor()
c.execute("INSERT INTO TEST.PKTEST (COL1, COL2) VALUES (?, ?)", test_row)
c.execute("INSERT INTO TEST.PKTEST (COL1, COL2) VALUES (?, ?)", test_row)

Inserting rows without parameter binding raises the exception (correct 
behavior):
c.execute("INSERT INTO TEST.PKTEST (COL1, COL2) VALUES ('x', 'y')")
c.execute("INSERT INTO TEST.PKTEST (COL1, COL2) VALUES ('x', 'y')") # <- this 
raises the exception

What is the expected output? What do you see instead?
According to DBAPI 2.0 it should raise an IntegrityError exception.

What version of the product are you using? On what operating system?
It's a Linux 32-bit RHEL 4 - but I think it doesn't depend on any platform.

Python version: 2.6.4
ibm_db version: 1.0.3
DB2 client lib version: 9.5.5

Original issue reported on code.google.com by cserna.z...@gmail.com on 9 Feb 2011 at 9:12

GoogleCodeExporter commented 9 years ago
Hi cserna,
 Thanks a lot for reporting this bug.

I am able to figure-out that why this particular case it doesn't rise an 
exception.
I have made a patch for the same. you can find that on the attachment.

Please download ibm_db.c file from the attachment and replace existing ibm_db.c 
to downloaded one in ibm_db source code folder(ibm_db-1.0.3). If your ibm_db 
source code folder contains build, dist, ibm_db.egg-info folders then first 
delete these folders, and then compile and install it.

please let me know this is working fine for you or not.

Original comment by rahul.pr...@in.ibm.com on 10 Feb 2011 at 11:09

Attachments:

GoogleCodeExporter commented 9 years ago
I confirm that the patch provided by you fixes the problem. Please add it to 
the next release of ibm_db if possible.

Many thanks,
Zsolt

Original comment by cserna.z...@gmail.com on 11 Feb 2011 at 4:29

GoogleCodeExporter commented 9 years ago
we will surely add it to our next release.

Original comment by rahul.pr...@in.ibm.com on 14 Feb 2011 at 7:00

GoogleCodeExporter commented 9 years ago
Fixed in ibm_db-1.0.4.

Original comment by rahul.pr...@in.ibm.com on 18 May 2011 at 5:12