Issues

ZF-3167: pdo_mysqli describeTable primaryposition may be incorrect

Issue Type: Bug Created: 2008-04-23T11:06:33.000+0000 Last Updated: 2011-09-23T17:08:37.000+0000 Status: Closed Fix version(s): - Next Major Release ()

Reporter: Ryan Korczykowski (theos) Assignee: Adam Lundrigan (adamlundrigan) Tags: - Zend_Db_Adapter_Mysqli

  • zf-caretaker-adamlundrigan

Related issues: Attachments:

Description

Assuming:

CREATE TABLE test ( one varchar(10) NOT NULL default '', two varchar(10) NOT NULL default '', three tinyint(4) NOT NULL default '0', PRIMARY KEY (two,one) )

and DESCRIBE test:

Field Type Null Key Default Extra one varchar(10) NO PRI two varchar(10) NO PRI three tinyint(4) NO 0

describeTable assumes that that the column order in the primary key order matches the column order of the table ( see $primaryPosition = $p; where is the p index of key == pri from the DESCRIBE TABLE result) - A contradiction to : PRIMARY_POSITION => integer; position of column in primary key

As a result, the primary positions of the table are (one => 1, two =>2) instead of (two=>1, one=>2)

You will need to parse the CREATE TABLE to get the ordering of the columns in the primary key.

Comments

Posted by Wil Sinclair (wil) on 2008-06-09T13:55:11.000+0000

Please evaluate and fix/categorize as necessary.

Posted by Mickael Perraud (mikaelkael) on 2008-11-28T06:48:46.000+0000

We could add a ``` after DESCRIBE request to retrieve the position in 'Seq_in_index' field.

Posted by Ralph Schindler (ralph) on 2009-01-10T11:59:00.000+0000

will review within 2 weeks

Posted by Ralph Schindler (ralph) on 2009-12-21T13:03:27.000+0000

describeTable() returns the position in the table not in the index correct? Isn't the current behavior correct?

-ralph

Posted by Richard Fisher (agentforsythe) on 2010-11-18T01:51:34.000+0000

The current behaviour is neither correct nor useful.

COLUMN_POSITION shows the position of the field in the table.

PRIMARY_POSITION should show the position of the field in the primary key, but instead currently shows the order that primary key fields appear in the table.

Posted by Adam Lundrigan (adamlundrigan) on 2011-09-23T15:09:11.000+0000

Is this still an issue? Is describeTable supposed to return position of pkey fields in table or of the fields in the pkey index?

If this is an issue, can it be fixed in ZF1 at this late stage in it's lifecycle, or should it be pushed up to ZF2?

EDIT: Pastie with an example of the problem reported by OP: http://pastie.org/2580094

Posted by Adam Lundrigan (adamlundrigan) on 2011-09-23T17:08:37.000+0000

After consulting with [~ralph] we've decided to mark this issue as "Won't Fix" for ZF1. The implemented behavior is wrong but is well established and poses too great a risk to change at this stage in ZF1's lifecycle.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts