MCPcopy Create free account
hub / github.com/MariaDB/server / alloc_query

Function alloc_query

sql/sql_parse.cc:2754–2801  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2752*/
2753
2754bool alloc_query(THD *thd, const char *packet, size_t packet_length)
2755{
2756 char *query;
2757 /* Remove garbage at start and end of query */
2758 while (packet_length > 0 && my_isspace(thd->charset(), packet[0]))
2759 {
2760 packet++;
2761 packet_length--;
2762 }
2763 const char *pos= packet + packet_length; // Point at end null
2764 while (packet_length > 0 &&
2765 (pos[-1] == ';' || my_isspace(thd->charset() ,pos[-1])))
2766 {
2767 pos--;
2768 packet_length--;
2769 }
2770 /* We must allocate some extra memory for query cache
2771
2772 The query buffer layout is:
2773 buffer :==
2774 <statement> The input statement(s)
2775 '\0' Terminating null char (1 byte)
2776 <length> Length of following current database name (size_t)
2777 <db_name> Name of current database
2778 <flags> Flags struct
2779 */
2780 if (! (query= (char*) thd->memdup_w_gap(packet,
2781 packet_length,
2782 1 + thd->db.length +
2783 QUERY_CACHE_DB_LENGTH_SIZE +
2784 QUERY_CACHE_FLAGS_SIZE)))
2785 return TRUE;
2786 query[packet_length]= '\0';
2787 /*
2788 Space to hold the name of the current database is allocated. We
2789 also store this length, in case current database is changed during
2790 execution. We might need to reallocate the 'query' buffer
2791 */
2792 int2store(query + packet_length + 1, thd->db.length);
2793
2794 thd->set_query(query, packet_length);
2795
2796 /* Reclaim some memory */
2797 thd->packet.shrink(thd->variables.net_buffer_length);
2798 thd->convert_buffer.shrink(thd->variables.net_buffer_length);
2799
2800 return FALSE;
2801}
2802
2803
2804bool sp_process_definer(THD *thd)

Callers 7

sql_parse.ccFile · 0.85
executeMethod · 0.85
mysqld_stmt_prepareFunction · 0.85
execute_server_codeFunction · 0.85
prepareMethod · 0.85
executeMethod · 0.85

Calls 5

int2storeFunction · 0.85
memdup_w_gapMethod · 0.80
charsetMethod · 0.45
set_queryMethod · 0.45
shrinkMethod · 0.45

Tested by

no test coverage detected