From 435c2e5763d5070a609e73bf897cb0eb201d72ce Mon Sep 17 00:00:00 2001 From: op1 Date: Mon, 15 Apr 2019 14:50:50 +0800 Subject: [PATCH 1/5] update git ignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 78eb4275e..9553bab7b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ *.oo *.oo2 *.pyc +*ycm_extra_conf.py # Libraries *.lib From 1b14ebedd199b635df19b63915c3c883305d424a Mon Sep 17 00:00:00 2001 From: op1 Date: Tue, 16 Apr 2019 02:05:57 +0800 Subject: [PATCH 2/5] support select @@identity like LAST_INSERT_ID --- lib/MySQL_Session.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/MySQL_Session.cpp b/lib/MySQL_Session.cpp index 49788cba3..a2998b1ae 100644 --- a/lib/MySQL_Session.cpp +++ b/lib/MySQL_Session.cpp @@ -15,6 +15,10 @@ #define SELECT_LAST_INSERT_ID_LEN 23 #define SELECT_LAST_INSERT_ID_LIMIT1 "SELECT LAST_INSERT_ID() LIMIT 1" #define SELECT_LAST_INSERT_ID_LIMIT1_LEN 31 +#define SELECT_VARIABLE_IDENTITY "SELECT @@IDENTITY" +#define SELECT_VARIABLE_IDENTITY_LEN 17 +#define SELECT_VARIABLE_IDENTITY_LIMIT1 "SELECT @@IDENTITY LIMIT 1" +#define SELECT_VARIABLE_IDENTITY_LIMIT1_LEN 25 #define EXPMARIA @@ -4449,7 +4453,7 @@ bool MySQL_Session::handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_C // handle case #1421 , about LAST_INSERT_ID if (CurrentQuery.QueryParserArgs.digest_text) { char *dig=CurrentQuery.QueryParserArgs.digest_text; - if (strcasestr(dig,"LAST_INSERT_ID")) { + if (strcasestr(dig,"LAST_INSERT_ID") || strcasestr(dig,"@@IDENTITY")) { // we need to try to execute it where the last write was successful if (last_HG_affected_rows >= 0) { MySQL_Backend * _mybe = NULL; @@ -4468,19 +4472,29 @@ bool MySQL_Session::handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_C } } // if we reached here, we don't know the right backend - // we try to determine if it is a simple "SELECT LAST_INSERT_ID()" and we return mysql->last_insert_id + // we try to determine if it is a simple "SELECT LAST_INSERT_ID()" or "SELECT @@IDENTITY" and we return mysql->last_insert_id if ( (pkt->size==SELECT_LAST_INSERT_ID_LEN+5 && strncasecmp((char *)SELECT_LAST_INSERT_ID,(char *)pkt->ptr+5,pkt->size-5)==0) || (pkt->size==SELECT_LAST_INSERT_ID_LIMIT1_LEN+5 && strncasecmp((char *)SELECT_LAST_INSERT_ID_LIMIT1,(char *)pkt->ptr+5,pkt->size-5)==0) + || + (pkt->size==SELECT_VARIABLE_IDENTITY_LEN+5 && strncasecmp((char *)SELECT_VARIABLE_IDENTITY,(char *)pkt->ptr+5,pkt->size-5)==0) + || + (pkt->size==SELECT_VARIABLE_IDENTITY_LIMIT1_LEN+5 && strncasecmp((char *)SELECT_VARIABLE_IDENTITY_LIMIT1,(char *)pkt->ptr+5,pkt->size-5)==0) ) { char buf[32]; sprintf(buf,"%llu",last_insert_id); char buf2[32]; - int l0=strlen("LAST_INSERT_ID()"); - memcpy(buf2,(char *)pkt->ptr+5+SELECT_LAST_INSERT_ID_LEN-l0,l0); + int l0=0; + if (strcasestr(dig,"LAST_INSERT_ID")){ + l0=strlen("LAST_INSERT_ID()"); + memcpy(buf2,(char *)pkt->ptr+5+SELECT_LAST_INSERT_ID_LEN-l0,l0); + }else if(strcasestr(dig,"@@IDENTITY")){ + l0=strlen("@@IDENTITY"); + memcpy(buf2,(char *)pkt->ptr+5+SELECT_VARIABLE_IDENTITY_LEN-l0,l0); + } buf2[l0]=0; unsigned int nTrx=NumActiveTransactions(); uint16_t setStatus = (nTrx ? SERVER_STATUS_IN_TRANS : 0 ); From 29073a7717832eda7bf7224b2a851aef4f41f570 Mon Sep 17 00:00:00 2001 From: op1 Date: Tue, 16 Apr 2019 03:06:48 +0800 Subject: [PATCH 3/5] update git ignore --- .gitignore | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.gitignore b/.gitignore index 9553bab7b..366f7fa5d 100644 --- a/.gitignore +++ b/.gitignore @@ -152,3 +152,9 @@ heaptrack.* .cproject .project .settings/ + +*GPATH +*GRTAGS +*GTAGS + +*.pem From 4995b25bb8112b695f66cf2e1166ccebd8efcdbc Mon Sep 17 00:00:00 2001 From: zhangyanjun Date: Tue, 16 Apr 2019 03:07:25 +0800 Subject: [PATCH 4/5] Revert "update git ignore" This reverts commit 435c2e5763d5070a609e73bf897cb0eb201d72ce. --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 366f7fa5d..ea0d11d9a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,6 @@ *.oo *.oo2 *.pyc -*ycm_extra_conf.py # Libraries *.lib From ad2b052208f7157ad9f3556430c7e56ff92a0f60 Mon Sep 17 00:00:00 2001 From: zhangyanjun Date: Tue, 16 Apr 2019 03:13:59 +0800 Subject: [PATCH 5/5] Revert "update git ignore" This reverts commit 29073a7717832eda7bf7224b2a851aef4f41f570. --- .gitignore | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.gitignore b/.gitignore index ea0d11d9a..78eb4275e 100644 --- a/.gitignore +++ b/.gitignore @@ -151,9 +151,3 @@ heaptrack.* .cproject .project .settings/ - -*GPATH -*GRTAGS -*GTAGS - -*.pem