{"id":5391,"date":"2020-07-30T00:12:28","date_gmt":"2020-07-29T16:12:28","guid":{"rendered":"http:\/\/39.97.231.10\/?p=5391"},"modified":"2020-07-30T00:12:28","modified_gmt":"2020-07-29T16:12:28","slug":"mysql-5-7-bug-unknown-type-14-in-column-0-of-1-in-binary-encoded-result-set","status":"publish","type":"post","link":"http:\/\/www.weijing.co\/?p=5391","title":{"rendered":"MySQL 5.7 Bug Unknown type &#039;14 in column 0 of 1 in binary-encoded result set"},"content":{"rendered":"<div>\n\u4e00\u3001\u95ee\u9898\u80cc\u666f\n<\/div>\n<div>\n<div>\n\u73af\u5883\uff1a<\/p>\n<ul>\n<li>MySQL\uff1aPercona Server for MySQL 5.7.19<\/li>\n<li>JDBC\uff1amysql connector-J 5.1.45<\/li>\n<\/ul>\n<p>Java\u4ee3\u7801\u901a\u8fc7JDBC\u6267\u884cSQL\u62a5\u9519 \u5982\u4e0b\uff1a<\/p>\n<pre>java.sql.SQLException: Unknown type \\'14 in column 0 of 1 in binary-encoded result set.\n        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:965)\n        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:898)\n        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:887)\n        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:861)\n        at com.mysql.jdbc.MysqlIO.extractNativeEncodedColumn(MysqlIO.java:4558)\n        at com.mysql.jdbc.MysqlIO.unpackBinaryResultSetRow(MysqlIO.java:4472)\n        at com.mysql.jdbc.MysqlIO.nextRow(MysqlIO.java:2045)\n        at com.mysql.jdbc.MysqlIO.readSingleRowSet(MysqlIO.java:3400)\n        at com.mysql.jdbc.MysqlIO.getResultSet(MysqlIO.java:470)\n        at com.mysql.jdbc.MysqlIO.readResultsForQueryOrUpdate(MysqlIO.java:3112)\n        at com.mysql.jdbc.MysqlIO.readAllResults(MysqlIO.java:2341)\n        at com.mysql.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1368)\n        at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:783)\n        at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1966)\n        at JDBCClient.main(JDBCClient.java:39)\n<\/pre>\n<h5>\u4e8c\u3001\u95ee\u9898\u6392\u67e5<\/h5>\n<p>\u901a\u8fc7\u7f51\u7edc\u641c\u7d22\u62a5\u9519\u4fe1\u606f\uff0c\u627e\u5230MySQL\u7684\u4e00\u4e2aBug\u4fe1\u606f\uff0c\u89c1\u94fe\u63a5\uff1a<a href=\\\"https:\/\/bugs.mysql.com\/bug.php?id=87534\\\">https:\/\/bugs.mysql.com\/bug.php?id=87534<\/a><br \/>\n\u8be5Bug\u590d\u73b0\u6761\u4ef6\uff1a<\/p>\n<ul>\n<li>\u5e94\u7528\u7a0b\u5e8f\u4f7f\u7528jdbc\u8fde\u63a5MySQL\u6570\u636e\u5e93\uff0c\u5e76\u4e14\u6253\u5f00jdbc\u9884\u7f16\u8bd1\u53c2\u6570useServerPrepStmts=true<\/li>\n<li>\u5e94\u7528\u7a0b\u5e8f\u4e2d\u6267\u884c\u4e86\u542b\u6709UNION ALL\u7684SQL\uff0c\u5e76\u4e14SQL\u6267\u884c\u8fd4\u56de\u7684\u6570\u636e\u4e2d\u5305\u542b\u6709DATE\u7c7b\u578b\u7684\u5b57\u6bb5<\/li>\n<\/ul>\n<p>\u641c\u7d22MySQL 5.7.19 \u4e4b\u540e\u7248\u672c\u7684Release Note\uff0c\u53d1\u73b0\u57285.7.22 \u7248\u672c\u5bf9\u8fd9\u4e00\u95ee\u9898\u8fdb\u884c\u4e86\u4fee\u590d\uff0c\u89c1\u94fe\u63a5\uff1a<a href=\\\"https:\/\/dev.mysql.com\/doc\/relnotes\/mysql\/5.7\/en\/news-5-7-22.html\\\">https:\/\/dev.mysql.com\/doc\/relnotes\/mysql\/5.7\/en\/news-5-7-22.html<\/a><\/p>\n<pre>Metadata from result sets for UNION ALL queries could say NEWDATE rather than DATE. (Bug #27422376)\n<\/pre>\n<p>\u7ecf\u8fc7\u6d4b\u8bd5\uff0c5.7.21 \u80fd\u591f\u590d\u73b0\u8be5Bug\uff0c5.7.22 \u6ca1\u6709\u590d\u73b0\uff0c\u786e\u8ba4\u8be5Bug \u5728 5.7.22\u4e2d\u5df2\u89e3\u51b3\u3002<\/p>\n<h5>\u4e09\u3001\u6e90\u7801\u5206\u6790<\/h5>\n<p>\uff081\uff09MySQL\u8fd4\u56de\u7684\u662fNEWDATE\uff0c\u800c\u975eDATE\uff1a<br \/>\n\u901a\u8fc7\u5728MySQL \u6e90\u7801\u7684git log\u4e2d\u641c\u7d22\u5185\u90e8Bug\u53f7#27422376\uff0c\u5bf9\u6bd4\u4ee3\u7801\u5dee\u5f02\uff0c\u5b9a\u4f4d\u5230 union all \u5728\u9047\u5230DATE\u7c7b\u578b\u5b57\u6bb5\u65f6\uff0c\u8fd4\u56de\u7684\u662f\u5185\u90e8\u4f7f\u7528\u7684NEWDATE\u7c7b\u578b\uff0c\u5bfc\u81f4jdbc\u63a5\u6536\u5230\u8fd9\u79cdNEWDATE\u7c7b\u578b\u65e0\u6cd5\u8bc6\u522b\uff0c\u62a5\u9519\u3002\u5b98\u65b9\u5728\u4fee\u590d\u8fd9\u4e2a\u95ee\u9898\u65f6\uff0c\u901a\u8fc7real_type_to_type \u8fd9\u4e2a\u51fd\u6570\uff0c\u5c06 MYSQL_TYPE_NEWDATE \u8f6c\u6362\u4e3a MYSQL_TYPE_DATE\u3002<br \/>\nMYSQL_TYPE_NEWDATE \u679a\u4e3e\u7c7b\u578b\uff0c\u503c\u4e3a14\uff0c MYSQL_TYPE_DATE \u503c\u4e3a10\uff0cjdbc \u5728\u6536\u5230 MYSQL_TYPE_NEWDATE (14) \u65e0\u6cd5\u8bc6\u522b\u8be5\u5b57\u6bb5\u7c7b\u578b\uff0c\u6240\u4ee5\u62a5\u9519\u3002<br \/>\n\uff082\uff09jdbc\u65e0\u6cd5\u8bc6\u522bNEWDATE\uff1a<br \/>\n\u901a\u8fc7\u67e5\u770bmysql connector-J 5.1.45 \u6e90\u7801 MysqlIO.java 4558\u884c\u4ee3\u7801\uff0c\u6211\u4eec\u770b\u5230jdbc\u6e90\u7801\u4e2d\u6709\u4e2aswitch\u8bed\u53e5\uff0c\u53ea\u80fd\u8bc6\u522bMysqlDefs.FIELD_TYPE_DATE\uff0c \u867d\u7136MysqlDefs.FIELD_TYPE_NEWDATE\u00a0\u6709\u5b9a\u4e49\uff0c\u4f46\u662f\u5728switch \u8bed\u53e5\u4e2d\u5e76\u6ca1\u6709 case MysqlDefs.FIELD_TYPE_NEWDATE\uff0c \u5bfc\u81f4NEWDATE\u5728\u8fd9\u91cc\u65e0\u6cd5\u88ab\u8bc6\u522b\uff0c\u8d70\u5230default\u7684\u4ee3\u7801\u903b\u8f91\u3002\u7ecf\u8fc7\u793e\u533a\u7684\u8ba8\u8bba\uff0c\u8ba4\u4e3a\u8fd9\u4e2aBug\uff0c\u4e0d\u5e94\u8be5\u7531jdbc\u4fee\u590d\uff0c\u5e94\u5f53\u5728MySQL Server\u4e2d\u4fee\u590d\uff0c \u6bd5\u7adfNEWDATE\u53ea\u662f\u5185\u90e8\u4f7f\u7528\u7684\u4e00\u4e2a\u6570\u636e\u7c7b\u578b\u3002<\/p>\n<h5>\u56db\u3001\u89c4\u907f\u65b9\u6848<\/h5>\n<ul>\n<li>\u5347\u7ea7MySQL\u52305.7.22 \u53ca\u4ee5\u4e0a\u7248\u672c<\/li>\n<li>\u5173\u95edjdbc\u9884\u7f16\u8bd1\u53c2\u6570useServerPrepStmts=false\uff0c\u53ef\u80fd\u6709\u6027\u80fd\u635f\u8017<\/li>\n<li>\u4fee\u6539sql\uff0c\u5728\u5916\u9762\u5305\u88c5\u4e00\u5c42select\uff0c\u5982 select * from &lt;your sql&gt;<\/li>\n<li>\u4fee\u6539\u8868\u7ed3\u6784\uff0c\u4e0d\u4f7f\u7528DATE\u7c7b\u578b\u5b57\u6bb5<\/li>\n<\/ul>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u95ee\u9898\u80cc\u666f \u73af\u5883\uff1a MySQL\uff1aPercona Server for MySQL 5.7.19 JDBC\uff1am &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"http:\/\/www.weijing.co\/?p=5391\"> <span class=\"screen-reader-text\">MySQL 5.7 Bug Unknown type &#039;14 in column 0 of 1 in binary-encoded result set<\/span> \u67e5\u770b\u5168\u6587 &raquo;<\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":""},"categories":[90,88],"tags":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"mailpoet_newsletter_max":false,"woocommerce_thumbnail":false,"woocommerce_single":false,"woocommerce_gallery_thumbnail":false,"shop_catalog":false,"shop_single":false,"shop_thumbnail":false},"uagb_author_info":{"display_name":"weijing","author_link":"http:\/\/www.weijing.co\/?author=4"},"uagb_comment_info":0,"uagb_excerpt":"\u4e00\u3001\u95ee\u9898\u80cc\u666f \u73af\u5883\uff1a MySQL\uff1aPercona Server for MySQL 5.7.19 JDBC\uff1am&hellip;","_links":{"self":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/5391"}],"collection":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5391"}],"version-history":[{"count":0,"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/5391\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5391"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5391"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5391"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}