Skip to content

Commit a7d68e7

Browse files
committed
MDEV-25791: Remove UNIV_INTERN
Back in 2006 or 2007, when MySQL AB and Innobase Oy existed as separately controlled entities (Innobase had been acquired by Oracle Corporation), MySQL 5.1 introduced a storage engine plugin interface and Oracle made use of it by distributing a separate InnoDB Plugin, which would contain some more bug fixes and improvements, compared to the version of InnoDB that was statically linked with the mysqld server that was distributed by MySQL AB. The built-in InnoDB would export global symbols, which would clash with the symbols of the dynamic InnoDB Plugin (which was supposed to override the built-in one when present). The solution to this problem was to declare all global symbols with UNIV_INTERN, so that they would get the GCC function attribute that specifies hidden visibility. Later, in MariaDB Server, something based on Percona XtraDB (a fork of MySQL InnoDB) became the statically linked implementation, and something closer to MySQL InnoDB was available as a dynamic plugin. Starting with version 10.2, MariaDB Server includes only one InnoDB implementation, and hence any reason to have the UNIV_INTERN definition was lost. btr_get_size_and_reserved(): Move to the same compilation unit with the only caller. innodb_set_buf_pool_size(): Remove. Modify innobase_buffer_pool_size directly. fil_crypt_calculate_checksum(): Merge to the only caller. ha_innobase::innobase_reset_autoinc(): Merge to the only caller. thd_query_start_micro(): Remove. Call thd_start_utime() directly.
1 parent 9ec2129 commit a7d68e7

27 files changed

+170
-427
lines changed

storage/innobase/btr/btr0btr.cc

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -605,52 +605,6 @@ btr_get_size(
605605
return(n);
606606
}
607607

608-
/**************************************************************//**
609-
Gets the number of reserved and used pages in a B-tree.
610-
@return number of pages reserved, or ULINT_UNDEFINED if the index
611-
is unavailable */
612-
UNIV_INTERN
613-
ulint
614-
btr_get_size_and_reserved(
615-
/*======================*/
616-
dict_index_t* index, /*!< in: index */
617-
ulint flag, /*!< in: BTR_N_LEAF_PAGES or BTR_TOTAL_SIZE */
618-
ulint* used, /*!< out: number of pages used (<= reserved) */
619-
mtr_t* mtr) /*!< in/out: mini-transaction where index
620-
is s-latched */
621-
{
622-
ulint dummy;
623-
624-
ut_ad(mtr->memo_contains(index->lock, MTR_MEMO_S_LOCK));
625-
ut_a(flag == BTR_N_LEAF_PAGES || flag == BTR_TOTAL_SIZE);
626-
627-
if (index->page == FIL_NULL
628-
|| dict_index_is_online_ddl(index)
629-
|| !index->is_committed()
630-
|| !index->table->space) {
631-
return(ULINT_UNDEFINED);
632-
}
633-
634-
buf_block_t* root = btr_root_block_get(index, RW_SX_LATCH, mtr);
635-
*used = 0;
636-
if (!root) {
637-
return ULINT_UNDEFINED;
638-
}
639-
640-
mtr->x_lock_space(index->table->space);
641-
642-
ulint n = fseg_n_reserved_pages(*root, PAGE_HEADER + PAGE_BTR_SEG_LEAF
643-
+ root->frame, used, mtr);
644-
if (flag == BTR_TOTAL_SIZE) {
645-
n += fseg_n_reserved_pages(*root,
646-
PAGE_HEADER + PAGE_BTR_SEG_TOP
647-
+ root->frame, &dummy, mtr);
648-
*used += dummy;
649-
}
650-
651-
return(n);
652-
}
653-
654608
/**************************************************************//**
655609
Frees a page used in an ibuf tree. Puts the page to the free list of the
656610
ibuf tree. */
@@ -3206,10 +3160,8 @@ void btr_level_list_remove(const buf_block_t& block, const dict_index_t& index,
32063160
If page is the only on its level, this function moves its records to the
32073161
father page, thus reducing the tree height.
32083162
@return father block */
3209-
UNIV_INTERN
32103163
buf_block_t*
32113164
btr_lift_page_up(
3212-
/*=============*/
32133165
dict_index_t* index, /*!< in: index tree */
32143166
buf_block_t* block, /*!< in: page which is the only on its level;
32153167
must not be empty: use

storage/innobase/btr/btr0defragment.cc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,7 @@ btr_defragment_remove_table(
220220
/*********************************************************************//**
221221
Check whether we should save defragmentation statistics to persistent storage.
222222
Currently we save the stats to persistent storage every 100 updates. */
223-
UNIV_INTERN
224-
void
225-
btr_defragment_save_defrag_stats_if_needed(
226-
dict_index_t* index) /*!< in: index */
223+
void btr_defragment_save_defrag_stats_if_needed(dict_index_t *index)
227224
{
228225
if (srv_defragment_stats_accuracy != 0 // stats tracking disabled
229226
&& index->table->space_id != 0 // do not track system tables
@@ -240,7 +237,7 @@ Main defragment functionalities used by defragment thread.*/
240237
Calculate number of records from beginning of block that can
241238
fit into size_limit
242239
@return number of records */
243-
UNIV_INTERN
240+
static
244241
ulint
245242
btr_defragment_calc_n_recs_for_size(
246243
buf_block_t* block, /*!< in: B-tree page */

storage/innobase/buf/buf0buf.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1995,7 +1995,8 @@ inline void buf_pool_t::resize()
19951995
: my_round_up_to_next_power(static_cast<uint32_t>(s));
19961996
curr_pool_size= n_chunks * srv_buf_pool_chunk_unit;
19971997
srv_buf_pool_curr_size= curr_pool_size;/* FIXME: remove*/
1998-
innodb_set_buf_pool_size(buf_pool_size_align(srv_buf_pool_curr_size));
1998+
extern ulonglong innobase_buffer_pool_size;
1999+
innobase_buffer_pool_size= buf_pool_size_align(srv_buf_pool_curr_size);
19992000

20002001
const bool new_size_too_diff
20012002
= srv_buf_pool_base_size > srv_buf_pool_size * 2

storage/innobase/dict/dict0crea.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1622,7 +1622,7 @@ dict_create_add_foreign_field_to_dictionary(
16221622
/********************************************************************//**
16231623
Construct foreign key constraint defintion from data dictionary information.
16241624
*/
1625-
UNIV_INTERN
1625+
static
16261626
char*
16271627
dict_foreign_def_get(
16281628
/*=================*/

storage/innobase/dict/dict0defrag_bg.cc

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
3-
Copyright (c) 2016, 2019, MariaDB Corporation.
3+
Copyright (c) 2016, 2021, MariaDB Corporation.
44
55
This program is free software; you can redistribute it and/or modify it under
66
the terms of the GNU General Public License as published by the Free Software
@@ -251,6 +251,51 @@ dict_stats_save_defrag_summary(
251251
return (ret);
252252
}
253253

254+
/**************************************************************//**
255+
Gets the number of reserved and used pages in a B-tree.
256+
@return number of pages reserved, or ULINT_UNDEFINED if the index
257+
is unavailable */
258+
static
259+
ulint
260+
btr_get_size_and_reserved(
261+
dict_index_t* index, /*!< in: index */
262+
ulint flag, /*!< in: BTR_N_LEAF_PAGES or BTR_TOTAL_SIZE */
263+
ulint* used, /*!< out: number of pages used (<= reserved) */
264+
mtr_t* mtr) /*!< in/out: mini-transaction where index
265+
is s-latched */
266+
{
267+
ulint dummy;
268+
269+
ut_ad(mtr->memo_contains(index->lock, MTR_MEMO_S_LOCK));
270+
ut_a(flag == BTR_N_LEAF_PAGES || flag == BTR_TOTAL_SIZE);
271+
272+
if (index->page == FIL_NULL
273+
|| dict_index_is_online_ddl(index)
274+
|| !index->is_committed()
275+
|| !index->table->space) {
276+
return(ULINT_UNDEFINED);
277+
}
278+
279+
buf_block_t* root = btr_root_block_get(index, RW_SX_LATCH, mtr);
280+
*used = 0;
281+
if (!root) {
282+
return ULINT_UNDEFINED;
283+
}
284+
285+
mtr->x_lock_space(index->table->space);
286+
287+
ulint n = fseg_n_reserved_pages(*root, PAGE_HEADER + PAGE_BTR_SEG_LEAF
288+
+ root->frame, used, mtr);
289+
if (flag == BTR_TOTAL_SIZE) {
290+
n += fseg_n_reserved_pages(*root,
291+
PAGE_HEADER + PAGE_BTR_SEG_TOP
292+
+ root->frame, &dummy, mtr);
293+
*used += dummy;
294+
}
295+
296+
return(n);
297+
}
298+
254299
/*********************************************************************//**
255300
Save defragmentation stats for a given index.
256301
@return DB_SUCCESS or error code */

storage/innobase/fil/fil0crypt.cc

Lines changed: 18 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,16 @@ Modified Jan Lindström [email protected]
4444
static bool fil_crypt_threads_inited = false;
4545

4646
/** Is encryption enabled/disabled */
47-
UNIV_INTERN ulong srv_encrypt_tables = 0;
47+
ulong srv_encrypt_tables;
4848

4949
/** No of key rotation threads requested */
50-
UNIV_INTERN uint srv_n_fil_crypt_threads = 0;
50+
uint srv_n_fil_crypt_threads;
5151

5252
/** No of key rotation threads started */
53-
UNIV_INTERN uint srv_n_fil_crypt_threads_started = 0;
53+
uint srv_n_fil_crypt_threads_started;
5454

5555
/** At this age or older a space/page will be rotated */
56-
UNIV_INTERN uint srv_fil_crypt_rotate_key_age;
56+
uint srv_fil_crypt_rotate_key_age;
5757

5858
/** Condition variable for srv_n_fil_crypt_threads_started */
5959
static pthread_cond_t fil_crypt_cond;
@@ -69,12 +69,12 @@ static pthread_cond_t fil_crypt_throttle_sleep_cond;
6969
static mysql_mutex_t fil_crypt_threads_mutex;
7070

7171
/** Variable ensuring only 1 thread at time does initial conversion */
72-
static bool fil_crypt_start_converting = false;
72+
static bool fil_crypt_start_converting;
7373

7474
/** Variables for throttling */
75-
UNIV_INTERN uint srv_n_fil_crypt_iops = 100; // 10ms per iop
76-
static uint srv_alloc_time = 3; // allocate iops for 3s at a time
77-
static uint n_fil_crypt_iops_allocated = 0;
75+
uint srv_n_fil_crypt_iops; // 10ms per iop
76+
static constexpr uint srv_alloc_time = 3; // allocate iops for 3s at a time
77+
static uint n_fil_crypt_iops_allocated;
7878

7979
#define DEBUG_KEYROTATION_THROTTLING 0
8080

@@ -226,7 +226,6 @@ Create a fil_space_crypt_t object
226226
227227
@param[in] key_id Encryption key id
228228
@return crypt object */
229-
UNIV_INTERN
230229
fil_space_crypt_t*
231230
fil_space_create_crypt_data(
232231
fil_encryption_t encrypt_mode,
@@ -239,7 +238,7 @@ fil_space_create_crypt_data(
239238
Merge fil_space_crypt_t object
240239
@param[in,out] dst Destination cryp data
241240
@param[in] src Source crypt data */
242-
UNIV_INTERN
241+
static
243242
void
244243
fil_space_merge_crypt_data(
245244
fil_space_crypt_t* dst,
@@ -313,10 +312,7 @@ fil_space_crypt_t* fil_space_read_crypt_data(ulint zip_size, const byte* page)
313312
/******************************************************************
314313
Free a crypt data object
315314
@param[in,out] crypt_data crypt data to be freed */
316-
UNIV_INTERN
317-
void
318-
fil_space_destroy_crypt_data(
319-
fil_space_crypt_t **crypt_data)
315+
void fil_space_destroy_crypt_data(fil_space_crypt_t **crypt_data)
320316
{
321317
if (crypt_data != NULL && (*crypt_data) != NULL) {
322318
fil_space_crypt_t* c;
@@ -466,7 +462,6 @@ static byte* fil_encrypt_buf_for_non_full_checksum(
466462
const byte* src = src_frame + header_len;
467463
byte* dst = dst_frame + header_len;
468464
uint32 dstlen = 0;
469-
ib_uint32_t checksum = 0;
470465

471466
if (page_compressed) {
472467
srclen = mach_read_from_2(src_frame + FIL_PAGE_DATA);
@@ -493,11 +488,12 @@ static byte* fil_encrypt_buf_for_non_full_checksum(
493488
size - (header_len + srclen));
494489
}
495490

496-
checksum = fil_crypt_calculate_checksum(zip_size, dst_frame);
497-
498491
/* store the post-encryption checksum after the key-version */
499492
mach_write_to_4(dst_frame + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION + 4,
500-
checksum);
493+
zip_size
494+
? page_zip_calc_checksum(dst_frame, zip_size,
495+
SRV_CHECKSUM_ALGORITHM_CRC32)
496+
: buf_calc_page_crc32(dst_frame));
501497

502498
ut_ad(fil_space_verify_crypt_checksum(dst_frame, zip_size));
503499

@@ -809,7 +805,6 @@ static bool fil_space_decrypt_for_non_full_checksum(
809805
@param[in,out] src_frame Page to decrypt
810806
@param[out] err DB_SUCCESS or DB_DECRYPTION_FAILED
811807
@return true if page decrypted, false if not.*/
812-
UNIV_INTERN
813808
bool
814809
fil_space_decrypt(
815810
ulint space_id,
@@ -837,7 +832,6 @@ Decrypt a page.
837832
@param[in,out] src_frame Page to decrypt
838833
@return decrypted page, or original not encrypted page if decryption is
839834
not needed.*/
840-
UNIV_INTERN
841835
byte*
842836
fil_space_decrypt(
843837
const fil_space_t* space,
@@ -869,22 +863,6 @@ fil_space_decrypt(
869863
return res;
870864
}
871865

872-
/**
873-
Calculate post encryption checksum
874-
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
875-
@param[in] dst_frame Block where checksum is calculated
876-
@return page checksum
877-
not needed. */
878-
uint32_t
879-
fil_crypt_calculate_checksum(ulint zip_size, const byte* dst_frame)
880-
{
881-
/* For encrypted tables we use only crc32 and strict_crc32 */
882-
return zip_size
883-
? page_zip_calc_checksum(dst_frame, zip_size,
884-
SRV_CHECKSUM_ALGORITHM_CRC32)
885-
: buf_calc_page_crc32(dst_frame);
886-
}
887-
888866
/***********************************************************************/
889867

890868
/** A copy of global key state */
@@ -2158,10 +2136,7 @@ static void fil_crypt_thread()
21582136
/*********************************************************************
21592137
Adjust thread count for key rotation
21602138
@param[in] enw_cnt Number of threads to be used */
2161-
UNIV_INTERN
2162-
void
2163-
fil_crypt_set_thread_cnt(
2164-
const uint new_cnt)
2139+
void fil_crypt_set_thread_cnt(const uint new_cnt)
21652140
{
21662141
if (!fil_crypt_threads_inited) {
21672142
if (srv_shutdown_state != SRV_SHUTDOWN_NONE)
@@ -2305,9 +2280,7 @@ void fil_crypt_threads_init()
23052280

23062281
/*********************************************************************
23072282
Clean up key rotation threads resources */
2308-
UNIV_INTERN
2309-
void
2310-
fil_crypt_threads_cleanup()
2283+
void fil_crypt_threads_cleanup()
23112284
{
23122285
if (!fil_crypt_threads_inited) {
23132286
return;
@@ -2322,10 +2295,7 @@ fil_crypt_threads_cleanup()
23222295
/*********************************************************************
23232296
Wait for crypt threads to stop accessing space
23242297
@param[in] space Tablespace */
2325-
UNIV_INTERN
2326-
void
2327-
fil_space_crypt_close_tablespace(
2328-
const fil_space_t* space)
2298+
void fil_space_crypt_close_tablespace(const fil_space_t *space)
23292299
{
23302300
fil_space_crypt_t* crypt_data = space->crypt_data;
23312301

@@ -2378,7 +2348,6 @@ fil_space_crypt_close_tablespace(
23782348
Get crypt status for a space (used by information_schema)
23792349
@param[in] space Tablespace
23802350
@param[out] status Crypt status */
2381-
UNIV_INTERN
23822351
void
23832352
fil_space_crypt_get_status(
23842353
const fil_space_t* space,
@@ -2428,10 +2397,7 @@ fil_space_crypt_get_status(
24282397
/*********************************************************************
24292398
Return crypt statistics
24302399
@param[out] stat Crypt statistics */
2431-
UNIV_INTERN
2432-
void
2433-
fil_crypt_total_stat(
2434-
fil_crypt_stat_t *stat)
2400+
void fil_crypt_total_stat(fil_crypt_stat_t *stat)
24352401
{
24362402
mysql_mutex_lock(&crypt_stat_mutex);
24372403
*stat = crypt_stat;

storage/innobase/fil/fil0fil.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ initialized. */
187187
fil_system_t fil_system;
188188

189189
/** At this age or older a space/page will be rotated */
190-
UNIV_INTERN extern uint srv_fil_crypt_rotate_key_age;
190+
extern uint srv_fil_crypt_rotate_key_age;
191191

192192
#ifdef UNIV_DEBUG
193193
/** Try fil_validate() every this many times */
@@ -3300,9 +3300,7 @@ test_make_filepath()
33003300
@param[in] space tablespace
33013301
@param[in] offset page number
33023302
@return block size */
3303-
UNIV_INTERN
3304-
ulint
3305-
fil_space_get_block_size(const fil_space_t* space, unsigned offset)
3303+
ulint fil_space_get_block_size(const fil_space_t *space, unsigned offset)
33063304
{
33073305
ulint block_size = 512;
33083306

0 commit comments

Comments
 (0)