@@ -106,6 +106,9 @@ static ST_FIELD_INFO qc_info_fields[]=
106
106
{0 , 0 , MYSQL_TYPE_STRING, 0 , 0 , 0 , 0 }
107
107
};
108
108
109
+
110
+ static const char unknown[]= " #UNKNOWN#" ;
111
+
109
112
static int qc_info_fill_table (THD *thd, TABLE_LIST *tables,
110
113
COND *cond)
111
114
{
@@ -146,7 +149,8 @@ static int qc_info_fill_table(THD *thd, TABLE_LIST *tables,
146
149
147
150
query_cache_block_raw = my_hash_element (queries, i);
148
151
query_cache_block = (Query_cache_block*)query_cache_block_raw;
149
- if (query_cache_block->type != Query_cache_block::QUERY)
152
+ if (unlikely (!query_cache_block ||
153
+ query_cache_block->type != Query_cache_block::QUERY))
150
154
continue ;
151
155
152
156
query_cache_query = query_cache_block->query ();
@@ -169,14 +173,33 @@ static int qc_info_fill_table(THD *thd, TABLE_LIST *tables,
169
173
table->field [COLUMN_GROUP_CONCAT_MAX_LENGTH]->store (flags.group_concat_max_len , 0 );
170
174
171
175
cs_client= get_charset (flags.character_set_client_num , MYF (MY_WME));
172
- table->field [COLUMN_CHARACTER_SET_CLIENT]->store (cs_client->csname , strlen (cs_client->csname ), scs);
176
+ if (likely (cs_client))
177
+ table->field [COLUMN_CHARACTER_SET_CLIENT]->
178
+ store (cs_client->csname , strlen (cs_client->csname ), scs);
179
+ else
180
+ table->field [COLUMN_CHARACTER_SET_CLIENT]->
181
+ store (STRING_WITH_LEN (unknown), scs);
182
+
173
183
cs_result= get_charset (flags.character_set_results_num , MYF (MY_WME));
174
- table->field [COLUMN_CHARACTER_SET_RESULT]->store (cs_result->csname , strlen (cs_result->csname ), scs);
184
+ if (likely (cs_result))
185
+ table->field [COLUMN_CHARACTER_SET_RESULT]->
186
+ store (cs_result->csname , strlen (cs_result->csname ), scs);
187
+ else
188
+ table->field [COLUMN_CHARACTER_SET_RESULT]->
189
+ store (STRING_WITH_LEN (unknown), scs);
190
+
175
191
collation= get_charset (flags.collation_connection_num , MYF (MY_WME));
176
- table->field [COLUMN_COLLATION]->store (collation->name , strlen (collation->name ), scs);
192
+ if (likely (collation))
193
+ table->field [COLUMN_COLLATION]->
194
+ store (collation->name , strlen (collation->name ), scs);
195
+ else
196
+ table->field [COLUMN_COLLATION]-> store (STRING_WITH_LEN (unknown), scs);
177
197
178
198
tz= flags.time_zone ->get_name ();
179
- table->field [COLUMN_TIMEZONE]->store (tz->ptr (), tz->length (), scs);
199
+ if (likely (tz))
200
+ table->field [COLUMN_TIMEZONE]->store (tz->ptr (), tz->length (), scs);
201
+ else
202
+ table->field [COLUMN_TIMEZONE]-> store (STRING_WITH_LEN (unknown), scs);
180
203
table->field [COLUMN_DEFAULT_WEEK_FORMAT]->store (flags.default_week_format , 0 );
181
204
table->field [COLUMN_DIV_PRECISION_INCREMENT]->store (flags.div_precision_increment , 0 );
182
205
@@ -204,7 +227,8 @@ static int qc_info_fill_table(THD *thd, TABLE_LIST *tables,
204
227
205
228
/* If we have result blocks, process them */
206
229
first_result_block= query_cache_query->result ();
207
- if (first_result_block)
230
+ if (query_cache_query->is_results_ready () &&
231
+ first_result_block)
208
232
{
209
233
/* initialize so we can loop over the result blocks*/
210
234
result_block= first_result_block;
@@ -231,7 +255,8 @@ static int qc_info_fill_table(THD *thd, TABLE_LIST *tables,
231
255
}
232
256
table->field [COLUMN_RESULT_BLOCKS_COUNT]->store (result_blocks_count, 0 );
233
257
table->field [COLUMN_RESULT_BLOCKS_SIZE]->store (result_blocks_size, 0 );
234
- table->field [COLUMN_RESULT_BLOCKS_SIZE_USED]->store (result_blocks_size_used, 0 );
258
+ table->field [COLUMN_RESULT_BLOCKS_SIZE_USED]->
259
+ store (result_blocks_size_used, 0 );
235
260
236
261
if (schema_table_store_record (thd, table))
237
262
goto cleanup;
0 commit comments