Bug in primary_key_info & another in DBI::Shell

From: John Cavanaugh (john_p_cavanaugh_at_yahoo.com)
Date: 01/31/04


Date: Sat, 31 Jan 2004 01:19:29 -0800 (PST)
To: matt@sergeant.org, dbi-users@perl.org, tlowery@rparts.us

I have encountered a couple of bugs in some DBI code. (Using perl 5.8.3 & DBI 1.40)
 
 
DBI-Shell Bug
--------------------
This bug is rather simple. In DBI-Shell, there is no function for do_primary_key_info but /primary_key_info is listed as a command. This results in the command not working. Implementation for this is pretty much a clone of do_col_info
 
 
primary_key_info
--------------------------
While using sqlite (Sorry, I havent verified if it behaves the same with other DB's) there is a bug in primary_key_info where if the first column of your table has a primary key reference it the column name wont be listed when you call primary_key_info.
 
Broken Output (if imageid is the first column)
 
TABLE_CAT,TABLE_SCHEM,TABLE_NAME,COLUMN_NAME,KEY_SEQ,PK_NAME
undef,undef,'ExifInfo','',1,'PRIMARY KEY'
 
Correct Output (imageid is anywhere other than first column)

TABLE_CAT,TABLE_SCHEM,TABLE_NAME,COLUMN_NAME,KEY_SEQ,PK_NAME
undef,undef,'ExifInfo','imageid',1,'PRIMARY KEY'

 
Darn thing drove me nuts. For now I have just moved my primary keys such that they are not the first column defined in my tables. Seems like an off by one error to me. I looked at the code in DBD::SQLite but nothing jumped out at me, maybe Tim B knows better since I guess he wrote the code for this.
 

--
John Cavanaugh
---------------------------------
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!