Make modutil_create_query parameters const
The parameters to modutil_create_query are not modified so they can be declared const.
This commit is contained in:
parent
cfaf03de3c
commit
875766cf62
@ -57,7 +57,7 @@ int modutil_MySQL_query_len(GWBUF* buf, int* nbytes_missing);
|
||||
void modutil_reply_parse_error(DCB* backend_dcb, char* errstr, uint32_t flags);
|
||||
void modutil_reply_auth_error(DCB* backend_dcb, char* errstr, uint32_t flags);
|
||||
int modutil_count_statements(GWBUF* buffer);
|
||||
GWBUF* modutil_create_query(char* query);
|
||||
GWBUF* modutil_create_query(const char* query);
|
||||
GWBUF* modutil_create_mysql_err_msg(int packet_number,
|
||||
int affected_rows,
|
||||
int merrno,
|
||||
|
@ -987,25 +987,20 @@ bool is_mysql_sp_end(const char* start, int len)
|
||||
/**
|
||||
* Create a COM_QUERY packet from a string.
|
||||
* @param query Query to create.
|
||||
* @return Pointer to GWBUF with the query or NULL if an error occurred.
|
||||
* @return Pointer to GWBUF with the query or NULL if memory allocation failed
|
||||
*/
|
||||
GWBUF* modutil_create_query(char* query)
|
||||
GWBUF* modutil_create_query(const char* query)
|
||||
{
|
||||
if (query == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GWBUF* rval = gwbuf_alloc(strlen(query) + 5);
|
||||
int pktlen = strlen(query) + 1;
|
||||
unsigned char* ptr;
|
||||
ss_dassert(query);
|
||||
size_t len = strlen(query) + 1; // Query plus the command byte
|
||||
GWBUF* rval = gwbuf_alloc(len + MYSQL_HEADER_LEN);
|
||||
|
||||
if (rval)
|
||||
{
|
||||
ptr = (unsigned char*)rval->start;
|
||||
*ptr++ = (pktlen);
|
||||
*ptr++ = (pktlen) >> 8;
|
||||
*ptr++ = (pktlen) >> 16;
|
||||
uint8_t *ptr = (uint8_t*)rval->start;
|
||||
*ptr++ = (len);
|
||||
*ptr++ = (len) >> 8;
|
||||
*ptr++ = (len) >> 16;
|
||||
*ptr++ = 0x0;
|
||||
*ptr++ = 0x03;
|
||||
memcpy(ptr, query, strlen(query));
|
||||
|
@ -587,7 +587,7 @@ static int routeQuery(FILTER *instance, void *session, GWBUF *queue)
|
||||
if (lua_isstring(my_session->lua_state, -1))
|
||||
{
|
||||
gwbuf_free(forward);
|
||||
forward = modutil_create_query((char*)lua_tostring(my_session->lua_state, -1));
|
||||
forward = modutil_create_query(lua_tostring(my_session->lua_state, -1));
|
||||
}
|
||||
else if (lua_isboolean(my_session->lua_state, -1))
|
||||
{
|
||||
@ -622,8 +622,7 @@ static int routeQuery(FILTER *instance, void *session, GWBUF *queue)
|
||||
if (lua_isstring(my_instance->global_lua_state, -1))
|
||||
{
|
||||
gwbuf_free(forward);
|
||||
forward = modutil_create_query((char*)
|
||||
lua_tostring(my_instance->global_lua_state, -1));
|
||||
forward = modutil_create_query(lua_tostring(my_instance->global_lua_state, -1));
|
||||
}
|
||||
else if (lua_isboolean(my_instance->global_lua_state, -1))
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user