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:
parent
9d8a49af5d
commit
7b001994b4
@ -2004,9 +2004,26 @@ public:
|
||||
|
||||
if (pSelect->pInto)
|
||||
{
|
||||
// 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;
|
||||
const ExprList* pInto = pSelect->pInto;
|
||||
mxb_assert(pInto->nExpr >= 1);
|
||||
|
||||
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.
|
||||
}
|
||||
|
@ -1177,8 +1177,20 @@ select_into_opt(A) ::= select_into(X). {A = X;}
|
||||
%type select_into {ExprList*}
|
||||
%destructor select_into {sqlite3ExprListDelete(pParse->db, $$);}
|
||||
select_into(A) ::= INTO variables(X). {A = X;}
|
||||
select_into(A) ::= INTO DUMPFILE STRING. {A = sqlite3ExprListAppend(pParse, 0, 0);}
|
||||
select_into(A) ::= INTO OUTFILE STRING. {A = sqlite3ExprListAppend(pParse, 0, 0);}
|
||||
// In order to allow us to distinguish between "INTO @var" and
|
||||
// "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}
|
||||
select_options(A) ::= . {A = 0;}
|
||||
|
@ -25,8 +25,6 @@ QUERY_TYPE_READ|QUERY_TYPE_WRITE
|
||||
QUERY_TYPE_READ|QUERY_TYPE_WRITE
|
||||
QUERY_TYPE_DEALLOC_PREPARE
|
||||
QUERY_TYPE_WRITE
|
||||
QUERY_TYPE_WRITE
|
||||
QUERY_TYPE_WRITE
|
||||
QUERY_TYPE_GSYSVAR_WRITE
|
||||
QUERY_TYPE_GSYSVAR_WRITE
|
||||
QUERY_TYPE_GSYSVAR_WRITE
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user