-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix #15093: Add additional field type metadata for pdo_mysql in getColumnMeta response. #15114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
ba3c4c9
19b7a9e
398200f
8bd06a7
7d3aba9
fb9a2ac
0d19718
ba7c8d2
d31423e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
--TEST-- | ||
GH-15093: Add support for all flags from mysql in the PDO MySql driver in the getColumnMeta function. | ||
--EXTENSIONS-- | ||
pdo_mysql | ||
--SKIPIF-- | ||
<?php | ||
require_once __DIR__ . '/inc/mysql_pdo_test.inc'; | ||
MySQLPDOTest::skip(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
By using the above codes, you can separate the tests for mysqlnd and libmysql. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed the code to use skipNotMySQLnd(), but in retrospect I think you were suggesting to write two separate tests. Given the differences regarding the NUM_FLAG above, separating them does seem like a good idea at first. However, one would expect the two to be functionally equivalent in this test. |
||
?> | ||
--FILE-- | ||
<?php | ||
require_once __DIR__ . '/inc/mysql_pdo_test.inc'; | ||
$db = MySQLPDOTest::factory(); | ||
|
||
$db->exec(" | ||
CREATE TABLE `gh_15093` ( | ||
`id` INT NOT NULL AUTO_INCREMENT, | ||
`uuid` BINARY(16) DEFAULT (uuid_to_bin(uuid())), | ||
`blob` BLOB, | ||
`ts` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | ||
`set` SET('one', 'two'), | ||
`enum` ENUM('a', 'b', 'c'), | ||
`num` INT(11) UNSIGNED ZEROFILL DEFAULT 0, | ||
PRIMARY KEY(`id`), | ||
UNIQUE KEY `UUID` (`uuid`) | ||
) | ||
"); | ||
|
||
$stmt = $db->prepare('SELECT `id`, `uuid`, `blob`, `ts`, `set`, `enum`, `num` FROM gh_15093'); | ||
$stmt->execute(); | ||
|
||
$n = $stmt->columnCount(); | ||
$meta = []; | ||
|
||
for ($i = 0; $i < $n; ++$i) { | ||
$m = $stmt->getColumnMeta($i); | ||
|
||
// libmysql and mysqlnd will show the pdo_type entry at a different position in the hash | ||
// and will report a different type, as mysqlnd returns native types. | ||
unset($m['pdo_type']); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: that or that might be ways around it. e.g. sorting. even for the type display, you re using EXPECTF after all. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This section was pulled from another test. As stated in the comment, the value of the pdo_type may differ based on which driver is used. I only modify the flags and added a native_flags attribute, which is really what the test is meant to cover. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fair enough, anyhow the maintainer will review all properly soon :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to split the tests per driver and check the value of |
||
|
||
$meta[$i] = $m; | ||
} | ||
|
||
print_r($meta); | ||
?> | ||
--CLEAN-- | ||
<?php | ||
require_once __DIR__ . '/inc/mysql_pdo_test.inc'; | ||
$db = MySQLPDOTest::factory(); | ||
$db->exec('DROP TABLE IF EXISTS gh_15093'); | ||
?> | ||
--EXPECTF-- | ||
Array | ||
( | ||
[0] => Array | ||
( | ||
[native_type] => LONG | ||
[flags] => Array | ||
( | ||
[0] => not_null | ||
[1] => primary_key | ||
[2] => auto_increment | ||
[3] => num | ||
) | ||
|
||
[native_flags] => 49667 | ||
[table] => gh_15093 | ||
[name] => id | ||
[len] => 11 | ||
[precision] => 0 | ||
) | ||
|
||
[1] => Array | ||
( | ||
[native_type] => STRING | ||
[flags] => Array | ||
( | ||
[0] => unique_key | ||
[1] => binary | ||
) | ||
|
||
[native_flags] => 16516 | ||
[table] => gh_15093 | ||
[name] => uuid | ||
[len] => 16 | ||
[precision] => 0 | ||
) | ||
|
||
[2] => Array | ||
( | ||
[native_type] => BLOB | ||
[flags] => Array | ||
( | ||
[0] => blob | ||
[1] => binary | ||
) | ||
|
||
[native_flags] => 144 | ||
[table] => gh_15093 | ||
[name] => blob | ||
[len] => 65535 | ||
[precision] => 0 | ||
) | ||
|
||
[3] => Array | ||
( | ||
[native_type] => TIMESTAMP | ||
[flags] => Array | ||
( | ||
[0] => binary | ||
[1] => timestamp | ||
[2] => on_update_now | ||
) | ||
|
||
[native_flags] => 9344 | ||
[table] => gh_15093 | ||
[name] => ts | ||
[len] => 19 | ||
[precision] => 0 | ||
) | ||
|
||
[4] => Array | ||
( | ||
[native_type] => STRING | ||
[flags] => Array | ||
( | ||
[0] => set | ||
) | ||
|
||
[native_flags] => 2048 | ||
[table] => gh_15093 | ||
[name] => set | ||
[len] => 28 | ||
[precision] => 0 | ||
) | ||
|
||
[5] => Array | ||
( | ||
[native_type] => STRING | ||
[flags] => Array | ||
( | ||
[0] => enum | ||
) | ||
|
||
[native_flags] => 256 | ||
[table] => gh_15093 | ||
[name] => enum | ||
[len] => 4 | ||
[precision] => 0 | ||
) | ||
|
||
[6] => Array | ||
( | ||
[native_type] => LONG | ||
[flags] => Array | ||
( | ||
[0] => unsigned | ||
[1] => zerofill | ||
[2] => num | ||
) | ||
|
||
[native_flags] => 32864 | ||
[table] => gh_15093 | ||
[name] => num | ||
[len] => 11 | ||
[precision] => 0 | ||
) | ||
|
||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IS_NUM
condition has changed. What impact does the removed condition have?In other words, what happens in the new logic if the value is
FIELD_TYPE_YEAR
orFIELD_TYPE_NEWDECIMAL
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IS_NUM was declared, but never used by mysqlnd. I suppose this would be a breaking change though for anything that imports this header file externally and uses this definition. Internally, mysqlnd sets the NUM_FLAG under the following conditions:
php-src/ext/mysqlnd/mysqlnd_wireprotocol.c
Lines 1221 to 1228 in 0e33b8d
However, MySql sets the NUM_FLAG based on their definition of IS_NUM here:
https://github.com/mysql/mysql-server/blob/596f0d238489a9cf9f43ce1ff905984f58d227b6/include/mysql.h#L116-L118
Maybe the condition in mysqlnd should be changed to use the condition provided by mysql?