Bug #18494 [Opn->Csd]: _compareIntegerDefinition() ignores length change

From: Date: Thu, 25 Oct 2012 02:32:16 +0000
Subject: Bug #18494 [Opn->Csd]: _compareIntegerDefinition() ignores length change
References: 1  Groups: php.pear.bugs 
Request: Send a blank email to pear-bugs+get-9232@lists.php.net to get a copy of this message
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() ------------------------------------------------------------------------ -- Edit this bug report at https://pear.php.net/bugs/bug.php?id=18494&edit=1

« previous php.pear.bugs (#9232) next »