{"action":"created","comment":{"url":"https://api.github.com/repos/baishancloud/lua-acid/pulls/comments/175318043","pull_request_review_id":104825962,"id":175318043,"diff_hunk":"@@ -0,0 +1,256 @@\n+local mysql = require('resty.mysql')\n+local strutil = require('acid.strutil')\n+local upstream_util = require('acid.dbagent.upstream_util')\n+local util = require('acid.dbagent.util')\n+\n+local to_str = strutil.to_str\n+\n+\n+local _M = {}\n+\n+local TRANSACTION_START = 'START TRANSACTION'\n+local TRANSACTION_ROLLBACK = 'ROLLBACK'\n+local TRANSACTION_COMMIT = 'COMMIT'\n+\n+\n+function _M.connect_db(connection_info, callbacks, query_opts)\n+    local db, err = mysql:new()\n+    if not db then\n+        return nil, 'MysqlNewError', string.format(\n+                'failed to new mysql: %s', err)\n+    end\n+\n+    db:set_timeout(query_opts.timeout or 1000) -- default 1 second\n+\n+    local options = {\n+        host = connection_info.host,\n+        port = connection_info.port,\n+        database = connection_info.database,\n+        user = connection_info.user,\n+        password = connection_info.password,\n+\n+        -- use default\n+        charset = nil,\n+        max_packet_size = nil,\n+        ssl_verify = nil,\n+    }\n+\n+    if callbacks.before_connect_db ~= nil then\n+        callbacks.before_connect_db(connection_info)\n+    end\n+\n+    local ok, err, errcode, sqlstate = db:connect(options)\n+\n+    if callbacks.after_connect_db ~= nil then\n+        callbacks.after_connect_db(connection_info)\n+    end\n+\n+    if not ok then\n+        local error_code = 'MysqlConnectError'\n+        local error_message = string.format(\n+                'failed to connect to: %s, %s, %s, %s, %s',\n+                options.host, tostring(options.port), err,\n+                tostring(errcode), sqlstate)\n+\n+        if callbacks.connect_db_error ~= nil then\n+            callbacks.connect_db_error(error_code, error_message)\n+        end\n+\n+        return nil, error_code, error_message\n+    end\n+\n+    local ident = util.get_connect_ident_str(options.host,","path":"lib/acid/dbagent/mysql_util.lua","position":62,"original_position":62,"commit_id":"fbcdbc86a95844a465fd3ebae0bccb2c2d5afc03","original_commit_id":"fbcdbc86a95844a465fd3ebae0bccb2c2d5afc03","user":{"login":"13yu","id":24269835,"avatar_url":"https://avatars0.githubusercontent.com/u/24269835?v=4","gravatar_id":"","url":"https://api.github.com/users/13yu","html_url":"https://github.com/13yu","followers_url":"https://api.github.com/users/13yu/followers","following_url":"https://api.github.com/users/13yu/following{/other_user}","gists_url":"https://api.github.com/users/13yu/gists{/gist_id}","starred_url":"https://api.github.com/users/13yu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/13yu/subscriptions","organizations_url":"https://api.github.com/users/13yu/orgs","repos_url":"https://api.github.com/users/13yu/repos","events_url":"https://api.github.com/users/13yu/events{/privacy}","received_events_url":"https://api.github.com/users/13yu/received_events","type":"User","site_admin":false},"body":"好","created_at":"2018-03-19T02:15:07Z","updated_at":"2018-03-19T02:15:07Z","html_url":"https://github.com/baishancloud/lua-acid/pull/94#discussion_r175318043","pull_request_url":"https://api.github.com/repos/baishancloud/lua-acid/pulls/94","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/baishancloud/lua-acid/pulls/comments/175318043"},"html":{"href":"https://github.com/baishancloud/lua-acid/pull/94#discussion_r175318043"},"pull_request":{"href":"https://api.github.com/repos/baishancloud/lua-acid/pulls/94"}},"in_reply_to_id":175125574},"pull_request":{"url":"https://api.github.com/repos/baishancloud/lua-acid/pulls/94","id":175228476,"html_url":"https://github.com/baishancloud/lua-acid/pull/94","diff_url":"https://github.com/baishancloud/lua-acid/pull/94.diff","patch_url":"https://github.com/baishancloud/lua-acid/pull/94.patch","issue_url":"https://api.github.com/repos/baishancloud/lua-acid/issues/94","number":94,"state":"open","locked":false,"title":"sql构造和sql查询相关代码","user":{"login":"13yu","id":24269835,"avatar_url":"https://avatars0.githubusercontent.com/u/24269835?v=4","gravatar_id":"","url":"https://api.github.com/users/13yu","html_url":"https://github.com/13yu","followers_url":"https://api.github.com/users/13yu/followers","following_url":"https://api.github.com/users/13yu/following{/other_user}","gists_url":"https://api.github.com/users/13yu/gists{/gist_id}","starred_url":"https://api.github.com/users/13yu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/13yu/subscriptions","organizations_url":"https://api.github.com/users/13yu/orgs","repos_url":"https://api.github.com/users/13yu/repos","events_url":"https://api.github.com/users/13yu/events{/privacy}","received_events_url":"https://api.github.com/users/13yu/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-03-15T11:59:45Z","updated_at":"2018-03-19T02:15:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b8b14122882abf04560cac5e55d17f8d72706693","assignee":null,"assignees":[],"requested_reviewers":[{"login":"sejust","id":2747551,"avatar_url":"https://avatars2.githubusercontent.com/u/2747551?v=4","gravatar_id":"","url":"https://api.github.com/users/sejust","html_url":"https://github.com/sejust","followers_url":"https://api.github.com/users/sejust/followers","following_url":"https://api.github.com/users/sejust/following{/other_user}","gists_url":"https://api.github.com/users/sejust/gists{/gist_id}","starred_url":"https://api.github.com/users/sejust/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sejust/subscriptions","organizations_url":"https://api.github.com/users/sejust/orgs","repos_url":"https://api.github.com/users/sejust/repos","events_url":"https://api.github.com/users/sejust/events{/privacy}","received_events_url":"https://api.github.com/users/sejust/received_events","type":"User","site_admin":false},{"login":"tongwei","id":32157039,"avatar_url":"https://avatars2.githubusercontent.com/u/32157039?v=4","gravatar_id":"","url":"https://api.github.com/users/tongwei","html_url":"https://github.com/tongwei","followers_url":"https://api.github.com/users/tongwei/followers","following_url":"https://api.github.com/users/tongwei/following{/other_user}","gists_url":"https://api.github.com/users/tongwei/gists{/gist_id}","starred_url":"https://api.github.com/users/tongwei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tongwei/subscriptions","organizations_url":"https://api.github.com/users/tongwei/orgs","repos_url":"https://api.github.com/users/tongwei/repos","events_url":"https://api.github.com/users/tongwei/events{/privacy}","received_events_url":"https://api.github.com/users/tongwei/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/baishancloud/lua-acid/pulls/94/commits","review_comments_url":"https://api.github.com/repos/baishancloud/lua-acid/pulls/94/comments","review_comment_url":"https://api.github.com/repos/baishancloud/lua-acid/pulls/comments{/number}","comments_url":"https://api.github.com/repos/baishancloud/lua-acid/issues/94/comments","statuses_url":"https://api.github.com/repos/baishancloud/lua-acid/statuses/fbcdbc86a95844a465fd3ebae0bccb2c2d5afc03","head":{"label":"baishancloud:renzhi_dbagent_mysql","ref":"renzhi_dbagent_mysql","sha":"fbcdbc86a95844a465fd3ebae0bccb2c2d5afc03","user":{"login":"baishancloud","id":22903957,"avatar_url":"https://avatars3.githubusercontent.com/u/22903957?v=4","gravatar_id":"","url":"https://api.github.com/users/baishancloud","html_url":"https://github.com/baishancloud","followers_url":"https://api.github.com/users/baishancloud/followers","following_url":"https://api.github.com/users/baishancloud/following{/other_user}","gists_url":"https://api.github.com/users/baishancloud/gists{/gist_id}","starred_url":"https://api.github.com/users/baishancloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baishancloud/subscriptions","organizations_url":"https://api.github.com/users/baishancloud/orgs","repos_url":"https://api.github.com/users/baishancloud/repos","events_url":"https://api.github.com/users/baishancloud/events{/privacy}","received_events_url":"https://api.github.com/users/baishancloud/received_events","type":"Organization","site_admin":false},"repo":{"id":83309707,"name":"lua-acid","full_name":"baishancloud/lua-acid","owner":{"login":"baishancloud","id":22903957,"avatar_url":"https://avatars3.githubusercontent.com/u/22903957?v=4","gravatar_id":"","url":"https://api.github.com/users/baishancloud","html_url":"https://github.com/baishancloud","followers_url":"https://api.github.com/users/baishancloud/followers","following_url":"https://api.github.com/users/baishancloud/following{/other_user}","gists_url":"https://api.github.com/users/baishancloud/gists{/gist_id}","starred_url":"https://api.github.com/users/baishancloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baishancloud/subscriptions","organizations_url":"https://api.github.com/users/baishancloud/orgs","repos_url":"https://api.github.com/users/baishancloud/repos","events_url":"https://api.github.com/users/baishancloud/events{/privacy}","received_events_url":"https://api.github.com/users/baishancloud/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/baishancloud/lua-acid","description":"A collection of lua util functions","fork":false,"url":"https://api.github.com/repos/baishancloud/lua-acid","forks_url":"https://api.github.com/repos/baishancloud/lua-acid/forks","keys_url":"https://api.github.com/repos/baishancloud/lua-acid/keys{/key_id}","collaborators_url":"https://api.github.com/repos/baishancloud/lua-acid/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/baishancloud/lua-acid/teams","hooks_url":"https://api.github.com/repos/baishancloud/lua-acid/hooks","issue_events_url":"https://api.github.com/repos/baishancloud/lua-acid/issues/events{/number}","events_url":"https://api.github.com/repos/baishancloud/lua-acid/events","assignees_url":"https://api.github.com/repos/baishancloud/lua-acid/assignees{/user}","branches_url":"https://api.github.com/repos/baishancloud/lua-acid/branches{/branch}","tags_url":"https://api.github.com/repos/baishancloud/lua-acid/tags","blobs_url":"https://api.github.com/repos/baishancloud/lua-acid/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/baishancloud/lua-acid/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/baishancloud/lua-acid/git/refs{/sha}","trees_url":"https://api.github.com/repos/baishancloud/lua-acid/git/trees{/sha}","statuses_url":"https://api.github.com/repos/baishancloud/lua-acid/statuses/{sha}","languages_url":"https://api.github.com/repos/baishancloud/lua-acid/languages","stargazers_url":"https://api.github.com/repos/baishancloud/lua-acid/stargazers","contributors_url":"https://api.github.com/repos/baishancloud/lua-acid/contributors","subscribers_url":"https://api.github.com/repos/baishancloud/lua-acid/subscribers","subscription_url":"https://api.github.com/repos/baishancloud/lua-acid/subscription","commits_url":"https://api.github.com/repos/baishancloud/lua-acid/commits{/sha}","git_commits_url":"https://api.github.com/repos/baishancloud/lua-acid/git/commits{/sha}","comments_url":"https://api.github.com/repos/baishancloud/lua-acid/comments{/number}","issue_comment_url":"https://api.github.com/repos/baishancloud/lua-acid/issues/comments{/number}","contents_url":"https://api.github.com/repos/baishancloud/lua-acid/contents/{+path}","compare_url":"https://api.github.com/repos/baishancloud/lua-acid/compare/{base}...{head}","merges_url":"https://api.github.com/repos/baishancloud/lua-acid/merges","archive_url":"https://api.github.com/repos/baishancloud/lua-acid/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/baishancloud/lua-acid/downloads","issues_url":"https://api.github.com/repos/baishancloud/lua-acid/issues{/number}","pulls_url":"https://api.github.com/repos/baishancloud/lua-acid/pulls{/number}","milestones_url":"https://api.github.com/repos/baishancloud/lua-acid/milestones{/number}","notifications_url":"https://api.github.com/repos/baishancloud/lua-acid/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/baishancloud/lua-acid/labels{/name}","releases_url":"https://api.github.com/repos/baishancloud/lua-acid/releases{/id}","deployments_url":"https://api.github.com/repos/baishancloud/lua-acid/deployments","created_at":"2017-02-27T12:49:27Z","updated_at":"2018-03-16T03:54:27Z","pushed_at":"2018-03-16T12:19:57Z","git_url":"git://github.com/baishancloud/lua-acid.git","ssh_url":"git@github.com:baishancloud/lua-acid.git","clone_url":"https://github.com/baishancloud/lua-acid.git","svn_url":"https://github.com/baishancloud/lua-acid","homepage":null,"size":500,"stargazers_count":8,"watchers_count":8,"language":"Lua","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":12,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":2,"open_issues":12,"watchers":8,"default_branch":"master"}},"base":{"label":"baishancloud:master","ref":"master","sha":"99f9b313f4fcbe1d624501f7a5c23f94c2410ee7","user":{"login":"baishancloud","id":22903957,"avatar_url":"https://avatars3.githubusercontent.com/u/22903957?v=4","gravatar_id":"","url":"https://api.github.com/users/baishancloud","html_url":"https://github.com/baishancloud","followers_url":"https://api.github.com/users/baishancloud/followers","following_url":"https://api.github.com/users/baishancloud/following{/other_user}","gists_url":"https://api.github.com/users/baishancloud/gists{/gist_id}","starred_url":"https://api.github.com/users/baishancloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baishancloud/subscriptions","organizations_url":"https://api.github.com/users/baishancloud/orgs","repos_url":"https://api.github.com/users/baishancloud/repos","events_url":"https://api.github.com/users/baishancloud/events{/privacy}","received_events_url":"https://api.github.com/users/baishancloud/received_events","type":"Organization","site_admin":false},"repo":{"id":83309707,"name":"lua-acid","full_name":"baishancloud/lua-acid","owner":{"login":"baishancloud","id":22903957,"avatar_url":"https://avatars3.githubusercontent.com/u/22903957?v=4","gravatar_id":"","url":"https://api.github.com/users/baishancloud","html_url":"https://github.com/baishancloud","followers_url":"https://api.github.com/users/baishancloud/followers","following_url":"https://api.github.com/users/baishancloud/following{/other_user}","gists_url":"https://api.github.com/users/baishancloud/gists{/gist_id}","starred_url":"https://api.github.com/users/baishancloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baishancloud/subscriptions","organizations_url":"https://api.github.com/users/baishancloud/orgs","repos_url":"https://api.github.com/users/baishancloud/repos","events_url":"https://api.github.com/users/baishancloud/events{/privacy}","received_events_url":"https://api.github.com/users/baishancloud/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/baishancloud/lua-acid","description":"A collection of lua util functions","fork":false,"url":"https://api.github.com/repos/baishancloud/lua-acid","forks_url":"https://api.github.com/repos/baishancloud/lua-acid/forks","keys_url":"https://api.github.com/repos/baishancloud/lua-acid/keys{/key_id}","collaborators_url":"https://api.github.com/repos/baishancloud/lua-acid/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/baishancloud/lua-acid/teams","hooks_url":"https://api.github.com/repos/baishancloud/lua-acid/hooks","issue_events_url":"https://api.github.com/repos/baishancloud/lua-acid/issues/events{/number}","events_url":"https://api.github.com/repos/baishancloud/lua-acid/events","assignees_url":"https://api.github.com/repos/baishancloud/lua-acid/assignees{/user}","branches_url":"https://api.github.com/repos/baishancloud/lua-acid/branches{/branch}","tags_url":"https://api.github.com/repos/baishancloud/lua-acid/tags","blobs_url":"https://api.github.com/repos/baishancloud/lua-acid/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/baishancloud/lua-acid/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/baishancloud/lua-acid/git/refs{/sha}","trees_url":"https://api.github.com/repos/baishancloud/lua-acid/git/trees{/sha}","statuses_url":"https://api.github.com/repos/baishancloud/lua-acid/statuses/{sha}","languages_url":"https://api.github.com/repos/baishancloud/lua-acid/languages","stargazers_url":"https://api.github.com/repos/baishancloud/lua-acid/stargazers","contributors_url":"https://api.github.com/repos/baishancloud/lua-acid/contributors","subscribers_url":"https://api.github.com/repos/baishancloud/lua-acid/subscribers","subscription_url":"https://api.github.com/repos/baishancloud/lua-acid/subscription","commits_url":"https://api.github.com/repos/baishancloud/lua-acid/commits{/sha}","git_commits_url":"https://api.github.com/repos/baishancloud/lua-acid/git/commits{/sha}","comments_url":"https://api.github.com/repos/baishancloud/lua-acid/comments{/number}","issue_comment_url":"https://api.github.com/repos/baishancloud/lua-acid/issues/comments{/number}","contents_url":"https://api.github.com/repos/baishancloud/lua-acid/contents/{+path}","compare_url":"https://api.github.com/repos/baishancloud/lua-acid/compare/{base}...{head}","merges_url":"https://api.github.com/repos/baishancloud/lua-acid/merges","archive_url":"https://api.github.com/repos/baishancloud/lua-acid/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/baishancloud/lua-acid/downloads","issues_url":"https://api.github.com/repos/baishancloud/lua-acid/issues{/number}","pulls_url":"https://api.github.com/repos/baishancloud/lua-acid/pulls{/number}","milestones_url":"https://api.github.com/repos/baishancloud/lua-acid/milestones{/number}","notifications_url":"https://api.github.com/repos/baishancloud/lua-acid/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/baishancloud/lua-acid/labels{/name}","releases_url":"https://api.github.com/repos/baishancloud/lua-acid/releases{/id}","deployments_url":"https://api.github.com/repos/baishancloud/lua-acid/deployments","created_at":"2017-02-27T12:49:27Z","updated_at":"2018-03-16T03:54:27Z","pushed_at":"2018-03-16T12:19:57Z","git_url":"git://github.com/baishancloud/lua-acid.git","ssh_url":"git@github.com:baishancloud/lua-acid.git","clone_url":"https://github.com/baishancloud/lua-acid.git","svn_url":"https://github.com/baishancloud/lua-acid","homepage":null,"size":500,"stargazers_count":8,"watchers_count":8,"language":"Lua","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":12,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":2,"open_issues":12,"watchers":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/baishancloud/lua-acid/pulls/94"},"html":{"href":"https://github.com/baishancloud/lua-acid/pull/94"},"issue":{"href":"https://api.github.com/repos/baishancloud/lua-acid/issues/94"},"comments":{"href":"https://api.github.com/repos/baishancloud/lua-acid/issues/94/comments"},"review_comments":{"href":"https://api.github.com/repos/baishancloud/lua-acid/pulls/94/comments"},"review_comment":{"href":"https://api.github.com/repos/baishancloud/lua-acid/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/baishancloud/lua-acid/pulls/94/commits"},"statuses":{"href":"https://api.github.com/repos/baishancloud/lua-acid/statuses/fbcdbc86a95844a465fd3ebae0bccb2c2d5afc03"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"13yu"}}