@@ -256,60 +256,13 @@ field_store_string(
256
256
const char * str) /* !< in: NUL-terminated utf-8 string,
257
257
or NULL */
258
258
{
259
- int ret;
260
-
261
- if (str != NULL ) {
262
-
263
- ret = field->store (str, static_cast <uint>(strlen (str)),
264
- system_charset_info);
265
- field->set_notnull ();
266
- } else {
267
-
268
- ret = 0 ; /* success */
259
+ if (!str) {
269
260
field->set_null ();
270
- }
271
-
272
- return (ret);
273
- }
274
-
275
- /* ******************************************************************/ /* *
276
- Store the name of an index in a MYSQL_TYPE_VARCHAR field.
277
- Handles the names of incomplete secondary indexes.
278
- @return 0 on success */
279
- static
280
- int
281
- field_store_index_name (
282
- /* ===================*/
283
- Field* field, /* !< in/out: target field for
284
- storage */
285
- const char * index_name) /* !< in: NUL-terminated utf-8
286
- index name, possibly starting with
287
- TEMP_INDEX_PREFIX */
288
- {
289
- int ret;
290
-
291
- ut_ad (index_name != NULL );
292
- ut_ad (field->real_type () == MYSQL_TYPE_VARCHAR ||
293
- field->real_type () == MYSQL_TYPE_NULL);
294
-
295
- /* Since TEMP_INDEX_PREFIX is not a valid UTF8, we need to convert
296
- it to something else. */
297
- if (*index_name == *TEMP_INDEX_PREFIX_STR) {
298
- char buf[NAME_LEN + 1 ];
299
- buf[0 ] = ' ?' ;
300
- memcpy (buf + 1 , index_name + 1 , strlen (index_name));
301
- ret = field->store (
302
- buf, static_cast <uint>(strlen (buf)),
303
- system_charset_info);
304
- } else {
305
- ret = field->store (
306
- index_name, static_cast <uint>(strlen (index_name)),
307
- system_charset_info);
261
+ return 0 ;
308
262
}
309
263
310
264
field->set_notnull ();
311
-
312
- return (ret);
265
+ return field->store (str, uint (strlen (str)), system_charset_info);
313
266
}
314
267
315
268
/* ******************************************************************/ /* *
@@ -932,12 +885,8 @@ fill_innodb_locks_from_cache(
932
885
buf, uint (bufend - buf), system_charset_info));
933
886
934
887
/* lock_index */
935
- if (row->lock_index != NULL ) {
936
- OK (field_store_index_name (fields[IDX_LOCK_INDEX],
937
- row->lock_index ));
938
- } else {
939
- fields[IDX_LOCK_INDEX]->set_null ();
940
- }
888
+ OK (field_store_string (fields[IDX_LOCK_INDEX],
889
+ row->lock_index ));
941
890
942
891
/* lock_space */
943
892
OK (field_store_ulint (fields[IDX_LOCK_SPACE],
@@ -1711,7 +1660,6 @@ i_s_cmp_per_index_fill_low(
1711
1660
1712
1661
for (iter = snap.begin (), i = 0 ; iter != snap.end (); iter++, i++) {
1713
1662
1714
- char name[192 ];
1715
1663
dict_index_t * index = dict_index_find_on_id_low (iter->first );
1716
1664
1717
1665
if (index != NULL ) {
@@ -1722,47 +1670,49 @@ i_s_cmp_per_index_fill_low(
1722
1670
db_utf8, sizeof (db_utf8),
1723
1671
table_utf8, sizeof (table_utf8));
1724
1672
1725
- field_store_string (fields[IDX_DATABASE_NAME], db_utf8);
1726
- field_store_string (fields[IDX_TABLE_NAME], table_utf8);
1727
- field_store_index_name (fields[IDX_INDEX_NAME],
1728
- index->name );
1673
+ status = field_store_string (fields[IDX_DATABASE_NAME],
1674
+ db_utf8)
1675
+ || field_store_string (fields[IDX_TABLE_NAME],
1676
+ table_utf8)
1677
+ || field_store_string (fields[IDX_INDEX_NAME],
1678
+ index->name );
1729
1679
} else {
1730
1680
/* index not found */
1731
- snprintf (name, sizeof (name),
1732
- " index_id:" IB_ID_FMT, iter->first );
1733
- field_store_string (fields[IDX_DATABASE_NAME],
1734
- " unknown" );
1735
- field_store_string (fields[IDX_TABLE_NAME],
1736
- " unknown" );
1737
- field_store_string (fields[IDX_INDEX_NAME],
1738
- name);
1681
+ char name[MY_INT64_NUM_DECIMAL_DIGITS
1682
+ + sizeof " index_id: " ];
1683
+ fields[IDX_DATABASE_NAME]->set_null ();
1684
+ fields[IDX_TABLE_NAME]->set_null ();
1685
+ fields[IDX_INDEX_NAME]->set_notnull ();
1686
+ status = fields[IDX_INDEX_NAME]->store (
1687
+ name,
1688
+ uint (snprintf (name, sizeof name,
1689
+ " index_id: " IB_ID_FMT,
1690
+ iter->first )),
1691
+ system_charset_info);
1739
1692
}
1740
1693
1741
- fields[IDX_COMPRESS_OPS]->store (
1742
- iter->second .compressed , true );
1743
-
1744
- fields[IDX_COMPRESS_OPS_OK]->store (
1745
- iter->second .compressed_ok , true );
1746
-
1747
- fields[IDX_COMPRESS_TIME]->store (
1748
- iter->second .compressed_usec / 1000000 , true );
1749
-
1750
- fields[IDX_UNCOMPRESS_OPS]->store (
1751
- iter->second .decompressed , true );
1752
-
1753
- fields[IDX_UNCOMPRESS_TIME]->store (
1754
- iter->second .decompressed_usec / 1000000 , true );
1755
-
1756
- if (schema_table_store_record (thd, table)) {
1694
+ if (status
1695
+ || fields[IDX_COMPRESS_OPS]->store (
1696
+ iter->second .compressed , true )
1697
+ || fields[IDX_COMPRESS_OPS_OK]->store (
1698
+ iter->second .compressed_ok , true )
1699
+ || fields[IDX_COMPRESS_TIME]->store (
1700
+ iter->second .compressed_usec / 1000000 , true )
1701
+ || fields[IDX_UNCOMPRESS_OPS]->store (
1702
+ iter->second .decompressed , true )
1703
+ || fields[IDX_UNCOMPRESS_TIME]->store (
1704
+ iter->second .decompressed_usec / 1000000 , true )
1705
+ || schema_table_store_record (thd, table)) {
1757
1706
status = 1 ;
1758
1707
break ;
1759
1708
}
1760
1709
/* Release and reacquire the dict mutex to allow other
1761
1710
threads to proceed. This could eventually result in the
1762
1711
contents of INFORMATION_SCHEMA.innodb_cmp_per_index being
1763
1712
inconsistent, but it is an acceptable compromise. */
1764
- if (i % 1000 == 0 ) {
1713
+ if (i == 1000 ) {
1765
1714
mutex_exit (&dict_sys->mutex );
1715
+ i = 0 ;
1766
1716
mutex_enter (&dict_sys->mutex );
1767
1717
}
1768
1718
}
@@ -4914,9 +4864,11 @@ i_s_innodb_buffer_page_fill(
4914
4864
4915
4865
mutex_enter (&dict_sys->mutex );
4916
4866
4917
- if (const dict_index_t * index =
4918
- dict_index_get_if_in_cache_low (
4919
- page_info->index_id )) {
4867
+ const dict_index_t * index =
4868
+ dict_index_get_if_in_cache_low (
4869
+ page_info->index_id );
4870
+
4871
+ if (index) {
4920
4872
table_name_end = innobase_convert_name (
4921
4873
table_name, sizeof (table_name),
4922
4874
index->table ->name .m_name ,
@@ -4929,17 +4881,22 @@ i_s_innodb_buffer_page_fill(
4929
4881
table_name_end
4930
4882
- table_name),
4931
4883
system_charset_info)
4932
- || field_store_index_name (
4933
- fields
4934
- [IDX_BUFFER_PAGE_INDEX_NAME] ,
4935
- index-> name );
4884
+ || fields[IDX_BUFFER_PAGE_INDEX_NAME]
4885
+ -> store (index-> name ,
4886
+ uint ( strlen (index-> name )) ,
4887
+ system_charset_info );
4936
4888
}
4937
4889
4938
4890
mutex_exit (&dict_sys->mutex );
4939
4891
4940
4892
OK (ret);
4941
4893
4942
- fields[IDX_BUFFER_PAGE_TABLE_NAME]->set_notnull ();
4894
+ if (index) {
4895
+ fields[IDX_BUFFER_PAGE_TABLE_NAME]
4896
+ ->set_notnull ();
4897
+ fields[IDX_BUFFER_PAGE_INDEX_NAME]
4898
+ ->set_notnull ();
4899
+ }
4943
4900
}
4944
4901
4945
4902
OK (fields[IDX_BUFFER_PAGE_NUM_RECS]->store (
@@ -5630,9 +5587,11 @@ i_s_innodb_buf_page_lru_fill(
5630
5587
5631
5588
mutex_enter (&dict_sys->mutex );
5632
5589
5633
- if (const dict_index_t * index =
5634
- dict_index_get_if_in_cache_low (
5635
- page_info->index_id )) {
5590
+ const dict_index_t * index =
5591
+ dict_index_get_if_in_cache_low (
5592
+ page_info->index_id );
5593
+
5594
+ if (index) {
5636
5595
table_name_end = innobase_convert_name (
5637
5596
table_name, sizeof (table_name),
5638
5597
index->table ->name .m_name ,
@@ -5645,17 +5604,22 @@ i_s_innodb_buf_page_lru_fill(
5645
5604
table_name_end
5646
5605
- table_name),
5647
5606
system_charset_info)
5648
- || field_store_index_name (
5649
- fields
5650
- [IDX_BUF_LRU_PAGE_INDEX_NAME] ,
5651
- index-> name );
5607
+ || fields[IDX_BUF_LRU_PAGE_INDEX_NAME]
5608
+ -> store (index-> name ,
5609
+ uint ( strlen (index-> name )) ,
5610
+ system_charset_info );
5652
5611
}
5653
5612
5654
5613
mutex_exit (&dict_sys->mutex );
5655
5614
5656
5615
OK (ret);
5657
5616
5658
- fields[IDX_BUF_LRU_PAGE_TABLE_NAME]->set_notnull ();
5617
+ if (index) {
5618
+ fields[IDX_BUF_LRU_PAGE_TABLE_NAME]
5619
+ ->set_notnull ();
5620
+ fields[IDX_BUF_LRU_PAGE_INDEX_NAME]
5621
+ ->set_notnull ();
5622
+ }
5659
5623
}
5660
5624
5661
5625
OK (fields[IDX_BUF_LRU_PAGE_NUM_RECS]->store (
@@ -6601,7 +6565,15 @@ i_s_dict_fill_sys_indexes(
6601
6565
6602
6566
fields = table_to_fill->field ;
6603
6567
6604
- OK (field_store_index_name (fields[SYS_INDEX_NAME], index->name ));
6568
+ if (*index->name == *TEMP_INDEX_PREFIX_STR) {
6569
+ /* Since TEMP_INDEX_PREFIX_STR is not valid UTF-8, we
6570
+ need to convert it to something else. */
6571
+ *const_cast <char *>(index->name ()) = ' ?' ;
6572
+ }
6573
+
6574
+ OK (fields[SYS_INDEX_NAME]->store (index->name ,
6575
+ uint (strlen (index->name )),
6576
+ system_charset_info));
6605
6577
6606
6578
OK (fields[SYS_INDEX_ID]->store (longlong (index->id ), true ));
6607
6579
0 commit comments