MySQL 8.0.29
Source Code Documentation
binary_log_funcs.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2014, 2021, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is also distributed with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have included with MySQL.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24/*
25 * Functions exported from this package.
26 */
27
28#ifndef BINARY_LOG_FUNCS_INCLUDED
29#define BINARY_LOG_FUNCS_INCLUDED
30
31// We use cstdint if this is 2011 standard (or later)
32#if __cplusplus > 201100L
33#include <cstdint>
34enum enum_field_types : int;
35#else
36#include <stdint.h>
37#include "field_types.h" // enum_field_types
38#endif
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44unsigned int my_time_binary_length(unsigned int dec);
45unsigned int my_datetime_binary_length(unsigned int dec);
46unsigned int my_timestamp_binary_length(unsigned int dec);
47
48/**
49 This helper function calculates the size in bytes of a particular field in a
50 row type event as defined by the field_ptr and metadata_ptr arguments.
51
52 @param col Field type code
53 @param master_data The field data
54 @param metadata The field metadata
55
56 @note We need the actual field data because the string field size is not
57 part of the meta data. :(
58
59 @return The size in bytes of a particular field
60*/
61uint32_t calc_field_size(unsigned char col, const unsigned char *master_data,
62 unsigned int metadata);
63
64/**
65 Compute the maximum display length of a field.
66
67 @param sql_type Type of the field
68 @param metadata The metadata from the master for the field.
69 @return Maximum length of the field in bytes.
70 */
72 unsigned int metadata);
73
74/**
75 Returns the size of array to hold a binary representation of a decimal
76 @param precision number of significant digits in a particular radix R
77 where R is either 2 or 10.
78 @param scale to what position to round.
79 @return size in bytes
80*/
81int decimal_binary_size(int precision, int scale);
82
83#ifdef __cplusplus
84}
85#endif // __cplusplus
86
87#endif /* BINARY_LOG_FUNCS_INCLUDED */
unsigned int my_time_binary_length(unsigned int dec)
Calculate binary size of packed numeric time representation.
Definition: binary_log_funcs.cpp:55
unsigned int max_display_length_for_field(enum_field_types sql_type, unsigned int metadata)
Compute the maximum display length of a field.
Definition: binary_log_funcs.cpp:96
unsigned int my_timestamp_binary_length(unsigned int dec)
Calculate on-disk size of a timestamp value.
Definition: binary_log_funcs.cpp:84
int decimal_binary_size(int precision, int scale)
Returns the size of array to hold a binary representation of a decimal.
Definition: binary_log_funcs.cpp:201
uint32_t calc_field_size(unsigned char col, const unsigned char *master_data, unsigned int metadata)
This helper function calculates the size in bytes of a particular field in a row type event as define...
Definition: binary_log_funcs.cpp:211
unsigned int my_datetime_binary_length(unsigned int dec)
Calculate binary size of packed datetime representation.
Definition: binary_log_funcs.cpp:69
This file contains the field type.
enum_field_types
Column types for MySQL.
Definition: field_types.h:57
static const std::string dec("DECRYPTION")