MXS-1978 Change qc_sqlite behaviour and update test
A statement like SELECT ... INTO OUTFILE|DUMPFILE ... is now classified as a QUERY_TYPE_WRITE, instead of as QUERY_TYPE_GSYSVAR_WRITE so that it will be sent only to the master.
This commit is contained in:
@ -2004,9 +2004,26 @@ public:
|
|||||||
|
|
||||||
if (pSelect->pInto)
|
if (pSelect->pInto)
|
||||||
{
|
{
|
||||||
// If there's a single variable, then it's a write.
|
const ExprList* pInto = pSelect->pInto;
|
||||||
// mysql embedded considers it a system var write.
|
mxb_assert(pInto->nExpr >= 1);
|
||||||
m_type_mask = QUERY_TYPE_GSYSVAR_WRITE;
|
|
||||||
|
if ((pInto->nExpr == 1)
|
||||||
|
&& (pInto->a[0].zName)
|
||||||
|
&& ((strcmp(pInto->a[0].zName, ":DUMPFILE:") == 0)
|
||||||
|
|| (strcmp(pInto->a[0].zName, ":OUTFILE:") == 0)))
|
||||||
|
{
|
||||||
|
// If there is exactly one expression that has a name that is either
|
||||||
|
// ":DUMPFILE:" or ":OUTFILE:" then it's a SELECT ... INTO OUTFILE|DUMPFILE
|
||||||
|
// and the statement needs to go to master.
|
||||||
|
// See in parse.y, the rule for select_into.
|
||||||
|
m_type_mask = QUERY_TYPE_WRITE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// If there's a single variable, then it's a write.
|
||||||
|
// mysql embedded considers it a system var write.
|
||||||
|
m_type_mask = QUERY_TYPE_GSYSVAR_WRITE;
|
||||||
|
}
|
||||||
|
|
||||||
// Also INTO {OUTFILE|DUMPFILE} will be typed as QUERY_TYPE_GSYSVAR_WRITE.
|
// Also INTO {OUTFILE|DUMPFILE} will be typed as QUERY_TYPE_GSYSVAR_WRITE.
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1177,8 +1177,20 @@ select_into_opt(A) ::= select_into(X). {A = X;}
|
|||||||
%type select_into {ExprList*}
|
%type select_into {ExprList*}
|
||||||
%destructor select_into {sqlite3ExprListDelete(pParse->db, $$);}
|
%destructor select_into {sqlite3ExprListDelete(pParse->db, $$);}
|
||||||
select_into(A) ::= INTO variables(X). {A = X;}
|
select_into(A) ::= INTO variables(X). {A = X;}
|
||||||
select_into(A) ::= INTO DUMPFILE STRING. {A = sqlite3ExprListAppend(pParse, 0, 0);}
|
// In order to allow us to distinguish between "INTO @var" and
|
||||||
select_into(A) ::= INTO OUTFILE STRING. {A = sqlite3ExprListAppend(pParse, 0, 0);}
|
// "INTO OUTFILE" or "INTO DUMPFILE", we give the expression list
|
||||||
|
// a name that cannot be a variable and look for that in
|
||||||
|
// maxscaleCollectInfoFromSelect().
|
||||||
|
select_into(A) ::= INTO DUMPFILE STRING. {
|
||||||
|
static Token dumpfile = { ":DUMPFILE:", 10 };
|
||||||
|
A = sqlite3ExprListAppend(pParse, 0, 0);
|
||||||
|
sqlite3ExprListSetName(pParse, A, &dumpfile, 1);
|
||||||
|
}
|
||||||
|
select_into(A) ::= INTO OUTFILE STRING. {
|
||||||
|
static Token outfile = { ":OUTFILE:", 9 };
|
||||||
|
A = sqlite3ExprListAppend(pParse, 0, 0);
|
||||||
|
sqlite3ExprListSetName(pParse, A, &outfile, 1);
|
||||||
|
}
|
||||||
|
|
||||||
%type select_options {int}
|
%type select_options {int}
|
||||||
select_options(A) ::= . {A = 0;}
|
select_options(A) ::= . {A = 0;}
|
||||||
|
|||||||
@ -25,8 +25,6 @@ QUERY_TYPE_READ|QUERY_TYPE_WRITE
|
|||||||
QUERY_TYPE_READ|QUERY_TYPE_WRITE
|
QUERY_TYPE_READ|QUERY_TYPE_WRITE
|
||||||
QUERY_TYPE_DEALLOC_PREPARE
|
QUERY_TYPE_DEALLOC_PREPARE
|
||||||
QUERY_TYPE_WRITE
|
QUERY_TYPE_WRITE
|
||||||
|
QUERY_TYPE_WRITE
|
||||||
|
QUERY_TYPE_WRITE
|
||||||
QUERY_TYPE_GSYSVAR_WRITE
|
QUERY_TYPE_GSYSVAR_WRITE
|
||||||
QUERY_TYPE_GSYSVAR_WRITE
|
|
||||||
QUERY_TYPE_GSYSVAR_WRITE
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user