{"id":3941,"date":"2012-11-20T23:13:45","date_gmt":"2012-11-20T15:13:45","guid":{"rendered":"http:\/\/www.orczhou.com\/?p=3941"},"modified":"2012-11-20T23:21:12","modified_gmt":"2012-11-20T15:21:12","slug":"more-about-mysql-item","status":"publish","type":"post","link":"https:\/\/www.orczhou.com\/index.php\/2012\/11\/more-about-mysql-item\/","title":{"rendered":"MySQL\u6e90\u4ee3\u7801\uff1a\u5173\u4e8eMySQL\u7684Item\u5bf9\u8c61"},"content":{"rendered":"<style>\n#content h3{\n  color:red;\n  font-size:14px;\n}\n#content h4{\n  color:blue;\n  font-size:14px;\n}\n#content blockquote{\n  font-family:\"Courier New\",Courier,monospace;\n  white-space:pre;\n}\n<\/style>\n<p><a href=\"http:\/\/www.orczhou.com\/index.php\/2012\/11\/mysql-innodb-source-code-optimization-1\/\" target=\"_blank\">\u524d\u7bc7<\/a>\u4ecb\u7ecd\u4e86MySQL\u5982\u4f55\u4eceSQL\u8bed\u53e5\u8f6c\u6362\u6210\u4e00\u4e2a\u5185\u90e8\u5bf9\u8c61\u3002\u672c\u6587\u662f\u524d\u7bc7\u7684\u5ef6\u7eed\uff0c\u5c06\u66f4\u52a0\u8be6\u7ec6\u7684\u4ecb\u7ecdWHERE\u8bed\u53e5\u5bf9\u5e94\u7684Item\u5bf9\u8c61\u3002<\/p>\n\n<h3>1. Item\u5bf9\u8c61@MySQL Internal<\/h3>\n<p>(\u5efa\u8bae\u9605\u8bfb\uff1a<a href=\"http:\/\/dev.mysql.com\/doc\/internals\/en\/item-class.html\" target=\"_blank\">The Item Class@MySQL Internals Manual<\/a>\uff0c\u5ffd\u7565\u672c\u5c0f\u7ed3)<\/p>\n<p>MySQL Internals Manual\u8f83\u4e3a\u8be6\u7ec6\u7684\u4ecb\u7ecd\u4e86<a href=\"http:\/\/dev.mysql.com\/doc\/internals\/en\/item-class.html\" target=\"_blank\">Item\u5bf9\u8c61<\/a>\u3002Item\u5bf9\u8c61\u7ecf\u5e38\u88ab\u79f0\u4f5c&#8221;thingamabob&#8221;\uff08\tA <a href=\"http:\/\/www.urbandictionary.com\/define.php?term=thingamabob\" target=\"_blank\">thingamabob<\/a> is a noun used to describe items that either you can&#8217;t remember the name of or that don&#8217;t actually exist.\uff09\u3002Item\u662f\u4e00\u4e2a\u7c7b\uff0c\u6bcf\u4e00\u4e2aItem\u5b9e\u4f8b\u90fd\uff1a(1)\u4ee3\u8868\u4e00\u4e2aSQL\u8bed\u53e5\u91cc\u7684\u5bf9\u8c61;(2)\u6709\u53d6\u503c;(3)\u6709\u6570\u636e\u7c7b\u578b\u6307\u9488\u3002<\/p>\n<p>\u4e0b\u9762\u5217\u51fa\u7684\u7684SQL\u76f8\u5173\u7684\u5bf9\u8c61\u90fd\u662f\u4e00\u4e2aItem\u5bf9\u8c61\uff0c\u6216\u8005\u7ee7\u627f\u81f3Item\uff1a(1)\u4e00\u6bb5\u5b57\u7b26; (2)\u6570\u636e\u8868\u7684\u67d0\u5217; (3)\u4e00\u4e2a\u5c40\u90e8\u6216\u5168\u5c40\u53d8\u91cf; (4)\u4e00\u4e2a\u5b58\u50a8\u8fc7\u7a0b\u7684\u53d8\u91cf; (5) \u4e00\u4e2a\u7528\u6237\u53c2\u6570; (6)\u4e00\u4e2a\u51fd\u6570\/\u5b58\u50a8\u8fc7\u7a0b(\u8fd9\u5305\u62ec\u8fd0\u7b97\u7b26+\u3001||\u3001=\u3001like\u7b49) \u3002\u4f8b\u5982\u4e0b\u9762\u7684SQL\u8bed\u53e5\uff1a<!--more--><\/p>\n<p>SELECT UPPER(column1) FROM t WHERE column2 = @x;<\/p>\n<p>MySQL\u9700\u8981\u4e00\u7cfb\u5217\u7684Item\u6765\u63cf\u8ff0\u4e0a\u9762\u7684SQL\uff1a\u4e00\u4e2a\u63cf\u8ff0column1\u5bf9\u8c61\uff0c\u63cf\u8ff0UPPER\u51fd\u6570\u7684\u5bf9\u8c61\uff0c\u8fd8\u6709\u63cf\u8ff0WHERE\u8bed\u53e5\u7684\u51e0\u4e2a\u76f8\u5173\u7684Item\u5bf9\u8c61\u3002Item\u5bf9\u8c61\u53ef\u4ee5\u7406\u89e3\u505a\u4e00\u4e2a\u7279\u6b8a\u7684\u6570\u636e\u5bf9\u8c61\u3002MySQL\u7684Item\u5bf9\u8c61\u5b9a\u4e49\u5728.\/sql\/item.h\u4e2d\uff0c\u5176\u5b50\u7c7b\u90fd\u5b9a\u4e49\u5728.\/sql\/item*.h\u4e2d\uff0c\u4f8b\u5982item_cmpfunc.h, item_func.h\u3002\u5728MySQL Server\u5c42\u4ee3\u7801\u4e2d\u6709\u5927\u91cf\u64cd\u4f5c\u548c\u4f7f\u7528Item\u5bf9\u8c61\u7684\u4ee3\u7801\uff0c\u5efa\u8bae\u9605\u8bfb\u7684\u65f6\u5019\uff0c\u6162\u6162\u7406\u89e3\u3002<\/p>\n<h3>2. WHERE\u5bf9\u5e94\u7684Item\u5bf9\u8c61<\/h3>\n<p>\u672c\u8282\u5c06\u4ecb\u7ecdMySQL\u4e2d\u5982\u4f55\u4f7f\u7528Item\u5bf9\u8c61\u63cf\u8ff0\u4e00\u4e2aWHERE\u6761\u4ef6\u3002\u4e0b\u9762\u4ece\u7b80\u5355\u5230\u590d\u6742\uff0c\u9010\u4e2a\u4ecb\u7ecd\uff1a<\/p>\n<h4>2.1 WHERE id >= 1 and id < 3<\/h4>\n<h4>2.2 WHERE id = 1 or id >10<\/h4>\n<h4>2.3 WHERE id >= 0 and id < 2 or id = 20<\/h4>\n<p><a href=\"http:\/\/www.flickr.com\/photos\/26825745@N06\/8194850939\/\" title=\"WHERE-1 by orczhou, on Flickr\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/farm9.staticflickr.com\/8068\/8194850939_14ac797b86_z.jpg\" width=\"542\" height=\"345\" alt=\"WHERE-1\"><\/a><\/p>\n<p>\u9a8c\u8bc1\uff1a<\/p>\n<pre><blockquote>\r\n(gdb) p ((Item_cond *)conds)->functype()\r\n$5 = Item_func::COND_OR_FUNC<\/blockquote><\/pre>\n<p>\u6253\u5370WHERE(\u4e5f\u5c31\u662fItem_cond_or) List\u4e2d\u7684\u7b2c\u4e00\u4e2a\u5143\u7d20\uff1a<\/p>\n<pre><blockquote>(gdb) p ((Item_cond *)(((Item_cond *)conds)->list->first->info))->functype()\r\n$17 = Item_func::COND_AND_FUNC<\/blockquote><\/pre>\n<p>\u7b2c\u4e8c\u4e2a\u5143\u7d20<\/p>\n<blockquote><p>(gdb) p ((Item_cond *)(((Item_cond *)conds)->list->first->next->info))->functype()<br \/>\n$18 = Item_func::EQ_FUNC<\/p><\/blockquote>\n<h4>2.4 WHERE (id = 10 or &#8230; ) and id >= 15<\/h4>\n<p>WHERE (id = 10 or id < 3 ) and id >= 15<\/p>\n<p><a href=\"http:\/\/www.flickr.com\/photos\/26825745@N06\/8195926356\/\" title=\"WHERE-2 by orczhou, on Flickr\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/farm9.staticflickr.com\/8347\/8195926356_1193d230a8.jpg\" width=\"500\" height=\"365\" alt=\"WHERE-2\"><\/a><\/p>\n<pre><blockquote>(gdb) p ((Item_cond_or *)((Item_cond_and *)conds)->list->first->info)->list->first\r\n$39 = (list_node *) 0x7facfc005698\r\n(gdb) p ((Item_cond_or *)((Item_cond_and *)conds)->list->first->info)->list->first->info\r\n$40 = (void *) 0x7facfc005150\r\n(gdb) p (Item *)$40\r\n$41 = (Item *) 0x7facfc005150\r\n(gdb) p ((Item *)$40)->type()\r\n$42 = Item::FUNC_ITEM\r\n(gdb) p ((Item_func *)$40)->functype()\r\n$43 = Item_func::EQ_FUNC\r\n(gdb) p ((Item_func_eq *)$40)->arg_count\r\n$44 = 2\r\n(gdb) p ((Item_func_eq *)$40)->args[0]\r\n$45 = (Item *) 0x7facfc004fe0<\/blockquote><\/pre>\n<h4>2.5 WHERE id >= 15 or (id > 1 and id  < 10)<\/h4>\n<p><a href=\"http:\/\/www.flickr.com\/photos\/26825745@N06\/8195927280\/\" title=\"WHERE-3 by orczhou, on Flickr\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/farm9.staticflickr.com\/8198\/8195927280_24293097f1.jpg\" width=\"500\" height=\"261\" alt=\"WHERE-3\"><\/a><\/p>\n<pre><blockquote>(gdb) p ((Item *)conds)->type()\r\n$47 = Item::COND_ITEM\r\n(gdb) p ((Item_cond *)conds)->functype()\r\n$48 = Item_func::COND_OR_FUNC\r\n\r\n(gdb) p ((Item_cond_or *)conds)->list->first->next->info\r\n$56 = (void *) 0x7facfc0058b8\r\n(gdb) p ((Item *)$56)->type()\r\n$57 = Item::COND_ITEM\r\n(gdb) p ((Item_cond *)$56)->functype()\r\n$58 = Item_func::COND_AND_FUNC<\/blockquote><\/pre>\n<h4>2.6 WHERE id >= 15 or ( &#8230; and ( &#8230; or &#8230; ))<\/h4>\n<p>WHERE id >= 15 or ( id > 1 and ( id < 4 or id = 0 ))\n\n<a href=\"http:\/\/www.flickr.com\/photos\/26825745@N06\/8195929488\/\" title=\"WHERE-4 by orczhou, on Flickr\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/farm9.staticflickr.com\/8069\/8195929488_6c33d04014_z.jpg\" width=\"554\" height=\"409\" alt=\"WHERE-4\"><\/a><\/p>\n<h3>3. Item\u5bf9\u8c61\u7684\u7ee7\u627f\u5173\u7cfb\u56fe<\/h3>\n<h4>3.1 Item_bool_func\u7684\u7ee7\u627f\u5173\u7cfb\u56fe<\/h4>\n<p><a href=\"http:\/\/www.flickr.com\/photos\/26825745@N06\/8138322215\/\" title=\"classItem__bool__func__inherit__graph by orczhou, on Flickr\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/farm9.staticflickr.com\/8336\/8138322215_6e03ab96ce_z.jpg\" width=\"640\" height=\"288\" alt=\"classItem__bool__func__inherit__graph\"><\/a><\/p>\n<h4>3.2 \u5b8c\u6574Item\u5bf9\u8c61\u7ee7\u627f\u5173\u7cfb\u56fe<\/h4>\n<p>\u5b8c\u6574\u7684Item\u7ee7\u627f\u5173\u7cfb\u56fe\u975e\u5e38\u590d\u6742\uff0c\u4e0b\u9762\u662f\u7f29\u7565\u56fe\uff1a\uff08<a href=\"http:\/\/www.orczhou.com\/wp-content\/uploads\/2012\/11\/classItem__inherit__graph.png\" target=\"_blank\">\u5b8c\u6574\u56fe\uff0c1.8MB\uff0c\u8c28\u614e\u6253\u5f00<\/a>\uff09<\/p>\n<p><a href=\"http:\/\/www.orczhou.com\/wp-content\/uploads\/2012\/11\/classItem__inherit__graph-s.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.orczhou.com\/wp-content\/uploads\/2012\/11\/classItem__inherit__graph-s.png\" alt=\"\" title=\"classItem__inherit__graph-s\" width=\"620\" height=\"3499\" class=\"alignleft size-full wp-image-3963\" srcset=\"https:\/\/www.orczhou.com\/wp-content\/uploads\/2012\/11\/classItem__inherit__graph-s.png 620w, https:\/\/www.orczhou.com\/wp-content\/uploads\/2012\/11\/classItem__inherit__graph-s-53x300.png 53w\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" \/><\/a><\/p>\n<p>\u8fd9\u662f\u4e00\u5e45\u5e9e\u5927\u5173\u7cfb\u56fe,\u4f7f\u7528doxygen+graphviz\u7ed8\u5236\uff08<a href=\"https:\/\/github.com\/orczhou\/dba-tool\/blob\/master\/doxygen.mysql.how.to.txt\" target=\"_blank\">\u5982\u4f55\u4f7f\u7528doxygen<\/a>\uff1b<a href=\"https:\/\/github.com\/orczhou\/dba-tool\/blob\/master\/doxygen.mysql.conf.diff\" target=\"_blank\">\u5982\u4f55\u914d\u7f6edoxygen\u751f\u6210MySQL\u6587\u6863<\/a>\uff09\u3002<\/p>\n<h3>\u53c2\u8003<\/h3>\n<p>MySQL source code<\/p>\n<p>MySQL Internal Manual<\/p>\n<p>Doxygen <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u7bc7\u4ecb\u7ecd\u4e86MySQL\u5982\u4f55\u4eceSQL\u8bed\u53e5\u8f6c\u6362\u6210\u4e00\u4e2a\u5185\u90e8\u5bf9\u8c61\u3002\u672c\u6587\u662f\u524d\u7bc7\u7684\u5ef6\u7eed\uff0c\u5c06\u66f4\u52a0\u8be6\u7ec6\u7684\u4ecb\u7ecdWHERE\u8bed\u53e5\u5bf9\u5e94\u7684Item\u5bf9\u8c61\u3002 1. Item\u5bf9\u8c61@MySQL Internal (\u5efa\u8bae\u9605\u8bfb\uff1aThe Item Class@MySQL Internals Manual\uff0c\u5ffd\u7565\u672c\u5c0f\u7ed3) MySQL Internals Manual\u8f83\u4e3a\u8be6\u7ec6\u7684\u4ecb\u7ecd\u4e86Item\u5bf9\u8c61\u3002Item\u5bf9\u8c61\u7ecf\u5e38\u88ab\u79f0\u4f5c&#8221;thingamabob&#8221;\uff08 A thingamabob is a noun used to describe items that either you can&#8217;t remember the name of or that don&#8217;t actually exist.\uff09\u3002Item\u662f\u4e00\u4e2a\u7c7b\uff0c\u6bcf\u4e00\u4e2aItem\u5b9e\u4f8b\u90fd\uff1a(1)\u4ee3\u8868\u4e00\u4e2aSQL\u8bed\u53e5\u91cc\u7684\u5bf9\u8c61;(2)\u6709\u53d6\u503c;(3)\u6709\u6570\u636e\u7c7b\u578b\u6307\u9488\u3002 \u4e0b\u9762\u5217\u51fa\u7684\u7684SQL\u76f8\u5173\u7684\u5bf9\u8c61\u90fd\u662f\u4e00\u4e2aItem\u5bf9\u8c61\uff0c\u6216\u8005\u7ee7\u627f\u81f3Item\uff1a(1)\u4e00\u6bb5\u5b57\u7b26; (2)\u6570\u636e\u8868\u7684\u67d0\u5217; (3)\u4e00\u4e2a\u5c40\u90e8\u6216\u5168\u5c40\u53d8\u91cf; (4)\u4e00\u4e2a\u5b58\u50a8\u8fc7\u7a0b\u7684\u53d8\u91cf; (5) \u4e00\u4e2a\u7528\u6237\u53c2\u6570; (6)\u4e00\u4e2a\u51fd\u6570\/\u5b58\u50a8\u8fc7\u7a0b(\u8fd9\u5305\u62ec\u8fd0\u7b97\u7b26+\u3001||\u3001=\u3001like\u7b49) \u3002\u4f8b\u5982\u4e0b\u9762\u7684SQL\u8bed\u53e5\uff1a<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_eb_attr":"","inline_featured_image":false,"_tocer_settings":[],"footnotes":""},"categories":[6,4],"tags":[100,118,58,98],"class_list":["post-3941","post","type-post","status-publish","format-standard","hentry","category-mysql","category-code-detail","tag-item","tag-mysql","tag-source-code","tag-sql"],"_links":{"self":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts\/3941","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/comments?post=3941"}],"version-history":[{"count":30,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts\/3941\/revisions"}],"predecessor-version":[{"id":4059,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts\/3941\/revisions\/4059"}],"wp:attachment":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/media?parent=3941"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/categories?post=3941"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/tags?post=3941"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}