Merge branch '2.2' into develop

This commit is contained in:
Markus Mäkelä
2018-09-27 11:40:14 +03:00
15 changed files with 281 additions and 28 deletions

View File

@ -2012,7 +2012,14 @@ public:
}
else
{
m_type_mask = QUERY_TYPE_READ;
// Only if the type has explicitly been set to QUERY_TYPE_WRITE
// we don't force it to QUERY_TYPE_READ but with other bits we do.
// This is something of kludge to ensure continued compatibility
// with qc_mysqlembedded.
if (m_type_mask != QUERY_TYPE_WRITE)
{
m_type_mask = QUERY_TYPE_READ;
}
}
QcAliases aliases;
@ -3025,6 +3032,12 @@ public:
m_operation = QUERY_OP_CHANGE_DB;
}
void set_type_mask(uint32_t type_mask)
{
ss_dassert(this_thread.initialized);
m_type_mask = type_mask;
}
private:
QcSqliteInfo(uint32_t cllct)
: m_refs(1)
@ -3330,6 +3343,8 @@ extern "C"
extern void maxscaleUse(Parse*, Token*);
extern void maxscale_update_function_info(const char* name, const Expr* pExpr);
// 'unsigned int' and not 'uint32_t' because 'uint32_t' is unknown in sqlite3 context.
extern void maxscale_set_type_mask(unsigned int type_mask);
extern void maxscaleComment();
extern int maxscaleKeyword(int token);
@ -3716,6 +3731,14 @@ extern void maxscale_update_function_info(const char* name, const Expr* pExpr)
pInfo->update_function_info(NULL, name, pExpr, NULL);
}
extern void maxscale_set_type_mask(unsigned int type_mask)
{
QcSqliteInfo* pInfo = this_thread.pInfo;
ss_dassert(pInfo);
pInfo->set_type_mask(type_mask);
}
static const char* get_token_symbol(int token)
{
switch (token)

View File

@ -131,6 +131,7 @@ extern void maxscaleTruncate(Parse*, Token* pDatabase, Token* pName);
extern void maxscaleUse(Parse*, Token*);
extern void maxscale_update_function_info(const char* name, const Expr* pExpr);
extern void maxscale_set_type_mask(unsigned int type_mask);
// Exposed utility functions
void exposed_sqlite3ExprDelete(sqlite3 *db, Expr *pExpr)
@ -966,6 +967,10 @@ cmd ::= select(X). {
%destructor select {sqlite3SelectDelete(pParse->db, $$);}
%type selectnowith {Select*}
%destructor selectnowith {sqlite3SelectDelete(pParse->db, $$);}
%ifdef MAXSCALE
%type selectnowithsuffix {Select*}
%destructor selectnowithsuffix {sqlite3SelectDelete(pParse->db, $$);}
%endif
%type oneselect {Select*}
%destructor oneselect {sqlite3SelectDelete(pParse->db, $$);}
@ -993,7 +998,12 @@ cmd ::= select(X). {
}
}
%ifdef MAXSCALE
select(A) ::= with(W) selectnowithsuffix(X). {
%endif
%ifndef MAXSCALE
select(A) ::= with(W) selectnowith(X). {
%endif
Select *p = X;
if( p ){
p->pWith = W;
@ -1004,6 +1014,15 @@ select(A) ::= with(W) selectnowith(X). {
A = p;
}
%ifdef MAXSCALE
selectnowithsuffix(A) ::= selectnowith(X). {A = X;}
selectnowithsuffix(A) ::= selectnowith(X) FOR UPDATE. {
A = X;
maxscale_set_type_mask(QUERY_TYPE_WRITE);
}
%endif
selectnowith(A) ::= oneselect(X). {A = X;}
%ifndef SQLITE_OMIT_COMPOUND_SELECT
selectnowith(A) ::= selectnowith(X) multiselect_op(Y) oneselect(Z). {