MySQL 8.0.39
Source Code Documentation
ut0ut.cc File Reference

Various utilities for Innobase. More...

#include "my_config.h"
#include <errno.h>
#include <time.h>
#include <string>
#include "ha_prototypes.h"
#include <mysql_com.h>
#include "my_compiler.h"
#include "os0thread.h"
#include "ut0ut.h"
#include "sql/log.h"
#include "trx0trx.h"
#include "clone0api.h"
#include "mysql/components/services/log_builtins.h"
#include "sql/derror.h"

Namespaces

namespace  ut
 This file contains a set of libraries providing overloads for regular dynamic allocation routines which allow for opt-in memory instrumentation through performance schema memory engine (PFS).
 
namespace  ib
 

Functions

ulint ut_delay (ulint delay)
 Runs an idle loop on CPU. More...
 
ulint ut_2_power_up (ulint n)
 Calculates fast the number rounded up to the nearest power of 2. More...
 
std::string ut_get_name (const trx_t *trx, const char *name)
 Get a fixed-length string, quoted as an SQL identifier. More...
 
void ut_print_name (FILE *f, const trx_t *trx, const char *name)
 Outputs a fixed-length string, quoted as an SQL identifier. More...
 
char * ut_format_name (const char *name, char *formatted, ulint formatted_size)
 Format a table name, quoted as an SQL identifier. More...
 
void ut_copy_file (FILE *dest, FILE *src)
 Catenate files. More...
 
void ut_format_byte_value (uint64_t data_bytes, std::string &data_str)
 Convert byte value to string with unit. More...
 
const char * ut_strerr (dberr_t num)
 Convert an error number to a human readable text message. More...
 

Detailed Description

Various utilities for Innobase.

Created 5/11/1994 Heikki Tuuri

Function Documentation

◆ ut_2_power_up()

ulint ut_2_power_up ( ulint  n)

Calculates fast the number rounded up to the nearest power of 2.

Returns
first power of 2 which is >= n
Parameters
nin: number != 0

◆ ut_copy_file()

void ut_copy_file ( FILE *  dest,
FILE *  src 
)

Catenate files.

Parameters
[in]destOutput file
[in]srcInput file to be appended to output

◆ ut_delay()

ulint ut_delay ( ulint  delay)

Runs an idle loop on CPU.

The argument gives the desired delay in microseconds on 100 MHz Pentium + Visual C++. The actual duration depends on a product of delay and the current value of @innodb_spin_wait_pause_multiplier.

Parameters
[in]delaydelay in microseconds on 100 MHz Pentium, assuming spin_wait_pause_multiplier is 50 (default).
Returns
dummy value

◆ ut_format_byte_value()

void ut_format_byte_value ( uint64_t  data_bytes,
std::string &  data_str 
)

Convert byte value to string with unit.

Parameters
[in]data_bytesbyte value
[out]data_strformatted string

◆ ut_format_name()

char * ut_format_name ( const char *  name,
char *  formatted,
ulint  formatted_size 
)

Format a table name, quoted as an SQL identifier.

If the name contains a slash '/', the result will contain two identifiers separated by a period (.), as in SQL database_name.table_name.

See also
table_name_t
Parameters
[in]nametable or index name
[out]formattedformatted result, will be NUL-terminated
[in]formatted_sizesize of the buffer in bytes
Returns
pointer to 'formatted'

◆ ut_get_name()

std::string ut_get_name ( const trx_t trx,
const char *  name 
)

Get a fixed-length string, quoted as an SQL identifier.

If the string contains a slash '/', the string will be output as two identifiers separated by a period (.), as in SQL database_name.identifier.

Parameters
[in]trxtransaction (NULL=no quotes).
[in]nametable name.
Return values
Stringquoted as an SQL identifier.

◆ ut_print_name()

void ut_print_name ( FILE *  f,
const trx_t trx,
const char *  name 
)

Outputs a fixed-length string, quoted as an SQL identifier.

If the string contains a slash '/', the string will be output as two identifiers separated by a period (.), as in SQL database_name.identifier.

Parameters
fin: output stream
trxin: transaction
namein: name to print

◆ ut_strerr()

const char * ut_strerr ( dberr_t  num)

Convert an error number to a human readable text message.

The returned string is static and should not be freed or modified.

Parameters
[in]numInnoDB internal error number
Returns
string, describing the error