[MXS-1293] Query classifier should handle COM_STMT_PREPARE Created: 2017-06-22  Updated: 2021-01-18  Resolved: 2021-01-18

Status: Closed
Project: MariaDB MaxScale
Component/s: N/A
Affects Version/s: None
Fix Version/s: N/A

Type: Task Priority: Major
Reporter: Johan Wikman Assignee: markus makela
Resolution: Won't Do Votes: 0
Labels: beginner-friendly

Sprint: MXS-SPRINT-123

 Description   

The query classifier should handle COM_STMT_PREPARE packets so that the following code would be possible.

GWBUF *pBuf = ...;
uint32_t type_mask = qc_get_type_mask(pBuf);
 
if (type_mask & (QUERY_TYPE_PREPARE_NAMED_STMT|QUERY_TYPE_PREPARE_STMT))
{
    GWBUF* pStmt;
    qc_get_preparable_stmt(pBuf, &pStmt);
    type_mask = qc_get_type_mask(pStmt);
}



 Comments   
Comment by markus makela [ 2020-11-24 ]

I think this is already the case: qc_get_type_mask for a COM_STMT_PREPARE is identical to the COM_QUERY version of the query with the exception that it has the QUERY_TYPE_PREPARE_STMT bit set. This means that the type of the statement being prepared can be extracted by ignoring the QUERY_TYPE_PREPARE_STMT bit.

This translates to:

GWBUF *pBuf = ...;
uint32_t type_mask = qc_get_type_mask(pBuf);
type_mask &= ~(QUERY_TYPE_PREPARE_NAMED_STMT|QUERY_TYPE_PREPARE_STMT);

A convenient helper function could be added for this.

Generated at Thu Feb 08 04:05:39 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.