MXS-1043: Handle @@identity like @@last_insert_id
The type of @@identity, @@last_insert_id and last_insert_id() is now the same, that is, QUERY_TYPE_READ|QUERY_TYPE_MASTER_READ.
This commit is contained in:
@ -928,11 +928,23 @@ static uint32_t resolve_query_type(parsing_info_t *pi, THD* thd)
|
|||||||
|
|
||||||
/** System session variable */
|
/** System session variable */
|
||||||
case Item_func::GSYSVAR_FUNC:
|
case Item_func::GSYSVAR_FUNC:
|
||||||
func_qtype |= QUERY_TYPE_SYSVAR_READ;
|
{
|
||||||
MXS_DEBUG("%lu [resolve_query_type] "
|
const char* name = item->name;
|
||||||
"functype GSYSVAR_FUNC, system "
|
if (name &&
|
||||||
"variable read.",
|
((strcasecmp(name, "@@last_insert_id") == 0) ||
|
||||||
pthread_self());
|
(strcasecmp(name, "@@identity") == 0)))
|
||||||
|
{
|
||||||
|
func_qtype |= QUERY_TYPE_MASTER_READ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
func_qtype |= QUERY_TYPE_SYSVAR_READ;
|
||||||
|
}
|
||||||
|
MXS_DEBUG("%lu [resolve_query_type] "
|
||||||
|
"functype GSYSVAR_FUNC, system "
|
||||||
|
"variable read.",
|
||||||
|
pthread_self());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/** User-defined variable read */
|
/** User-defined variable read */
|
||||||
|
@ -833,7 +833,15 @@ static void update_field_infos(QC_SQLITE_INFO* info,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
info->types |= QUERY_TYPE_SYSVAR_READ;
|
if ((strcasecmp(&zToken[2], "identity") == 0) ||
|
||||||
|
(strcasecmp(&zToken[2], "last_insert_id") == 0))
|
||||||
|
{
|
||||||
|
info->types |= QUERY_TYPE_MASTER_READ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
info->types |= QUERY_TYPE_SYSVAR_READ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -12,3 +12,6 @@ QUERY_TYPE_BEGIN_TRX
|
|||||||
QUERY_TYPE_ROLLBACK
|
QUERY_TYPE_ROLLBACK
|
||||||
QUERY_TYPE_COMMIT
|
QUERY_TYPE_COMMIT
|
||||||
QUERY_TYPE_SESSION_WRITE
|
QUERY_TYPE_SESSION_WRITE
|
||||||
|
QUERY_TYPE_READ|QUERY_TYPE_MASTER_READ
|
||||||
|
QUERY_TYPE_READ|QUERY_TYPE_MASTER_READ
|
||||||
|
QUERY_TYPE_READ|QUERY_TYPE_MASTER_READ
|
||||||
|
@ -12,3 +12,6 @@ BEGIN;
|
|||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
COMMIT;
|
COMMIT;
|
||||||
use X;
|
use X;
|
||||||
|
select last_insert_id();
|
||||||
|
select @@last_insert_id;
|
||||||
|
select @@identity;
|
||||||
|
Reference in New Issue
Block a user