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

Function read_identifier

sql/sql_digest.cc:92–128  ·  view source on GitHub ↗

Read an identifier from token array. */

Source from the content-addressed store, hash-verified

90 Read an identifier from token array.
91*/
92inline uint read_identifier(const sql_digest_storage* digest_storage,
93 uint index, char ** id_string, int *id_length)
94{
95 uint new_index;
96 uint safe_byte_count= digest_storage->m_byte_count;
97
98 DBUG_ASSERT(index <= safe_byte_count);
99 DBUG_ASSERT(safe_byte_count <= digest_storage->m_token_array_length);
100
101 /*
102 token + length + string are written in an atomic way,
103 so we do always expect a length + string here
104 */
105
106 uint bytes_needed= SIZE_OF_A_TOKEN;
107 /* If we can read token and identifier length */
108 if ((index + bytes_needed) <= safe_byte_count)
109 {
110 const unsigned char *src= & digest_storage->m_token_array[index];
111 /* Read the length of identifier */
112 uint length= src[0] | (src[1] << 8);
113 bytes_needed+= length;
114 /* If we can read entire identifier from token array */
115 if ((index + bytes_needed) <= safe_byte_count)
116 {
117 *id_string= (char *) (src + 2);
118 *id_length= length;
119
120 new_index= index + bytes_needed;
121 DBUG_ASSERT(new_index <= safe_byte_count);
122 return new_index;
123 }
124 }
125
126 /* The input byte stream is exhausted. */
127 return MAX_DIGEST_STORAGE_SIZE + 1;
128}
129
130/**
131 Store an identifier in token array.

Callers 1

compute_digest_textFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected