FAQ
Edit report at https://pear.php.net/bugs/bug.php?id=18494&edit=1

ID: 18494
Updated by: danielc@analysisandsolutions.com
Reported By: holger dot schletz at web dot de
Summary: _compareIntegerDefinition() ignores length change
-Status: Open
+Status: Closed
Type: Bug
Package: MDB2
Package Version: 2.5.0b3
PHP Version: Irrelevant
-Assigned To:
+Assigned To: danielc
Roadmap Versions:
New Comment:

-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: danielc
Thanks for the patch. Fixed in SVN commit 328137.


Previous Comments:
------------------------------------------------------------------------

[2011-05-01 12:34:50] hschletz

Added #patch
bug:18494;patch:detect_integer_length_change;revision:1304253290;.

------------------------------------------------------------------------

[2011-05-01 12:34:10] hschletz

Description:
------------
Changing a column from Int4 to Int8 and vice versa using MDB2_Schema
fails because _compareIntegerDefinition() does not check for length
changes. The bug would also show up under different circumstances where
this method is called - MDB2_Schema does not need to be involved. It's
actually a bug in the MDB2_Datatype_Common class.

Interesting side note: This bug did not show up for me with PostgreSQL
when 'unsigned' is set to 1 because PostgreSQL does not support unsigned
integers. The result does not contain the 'length' field, but always
'unsigned'. Subsequently, the column is modified and the new length
taken into account, giving the expected result (for a different
reason).

I detected this bug with MySQL which supports unsigned integers. In that
case an empty array was returned and no action was taken.

The attached patch compares the 'length' fields and adds a detected
change to the result. A default length of 4 is assumed if a given length
field is empty.

Test script:
---------------
$previous = array(
'notnull' => null,
'nativetype' => 'int',
'length' => 4,
'unsigned' => 1,
'default' => 42,
'type' => integer,
'mdb2type' => 'integer',
'was' => 'foo'
)
$current = array(
'type' => 'integer',
'length' => 8,
'unsigned' => 1,
'default' => 42,
'was' => 'foo',
'notnull' => null
)
$result = $mdb2->datatype->_compareIntegerDefinition($current,
$previous);

Expected result:
----------------
array(
'length' => 8
)

Actual result:
--------------
array()

------------------------------------------------------------------------

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedOct 25, '12 at 2:32a
activeOct 25, '12 at 2:32a
posts1
users1
websitepear.php.net

1 user in discussion

Danielc: 1 post

People

Translate

site design / logo © 2022 Grokbase