MySQL 26.10.0
Source Code Documentation
binary_log_funcs.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2014, 2026, 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 designed to work 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 either included with
14 the program or referenced in the documentation.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License, version 2.0, for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
24
25/*
26 * Functions exported from this package.
27 */
28
29#ifndef MYSQL_BINLOG_EVENT_EXPORT_BINARY_LOG_FUNCS_H
30#define MYSQL_BINLOG_EVENT_EXPORT_BINARY_LOG_FUNCS_H
31
32#include <stddef.h>
33#include <stdint.h>
34#include "field_types.h" // enum_field_types
35
36#ifdef __cplusplus
37extern "C" {
38#endif
39
40unsigned int my_time_binary_length(unsigned int dec);
41unsigned int my_datetime_binary_length(unsigned int dec);
42unsigned int my_timestamp_binary_length(unsigned int dec);
43
44/**
45 This helper function calculates the size in bytes of a particular field in a
46 row type event as defined by the field_ptr and metadata_ptr arguments.
47
48 @param col Field type code
49 @param master_data The field data
50 @param metadata The field metadata
51
52 @note We need the actual field data because the string field size is not
53 part of the meta data. :(
54
55 @return The size in bytes of a particular field
56*/
57uint32_t calc_field_size(unsigned char col, const unsigned char *master_data,
58 unsigned int metadata);
59
64};
65
66/**
67 This helper function calculates the size in bytes of a particular field in a
68 row type event, after checking that all bytes read from master_data fit in
69 the available input.
70
71 @param col Field type code
72 @param master_data The field data
73 @param metadata The field metadata
74 @param available Number of bytes available from master_data
75 @param field_size The size in bytes of the field, on success
76
77 @retval CALC_FIELD_SIZE_OK The field size was calculated successfully.
78 @retval CALC_FIELD_SIZE_TRUNCATED The field length prefix or value exceeds
79 the available input.
80 @retval CALC_FIELD_SIZE_INVALID_TYPE The field type or metadata is invalid.
81*/
83 unsigned char col, const unsigned char *master_data, unsigned int metadata,
84 size_t available, uint32_t *field_size);
85
86/**
87 Compute the maximum display length of a field.
88
89 @param sql_type Type of the field
90 @param metadata The metadata from the master for the field.
91 @return Maximum length of the field in bytes.
92 */
94 unsigned int metadata);
95
96/**
97 Returns the size of array to hold a binary representation of a decimal
98 @param precision number of significant digits in a particular radix R
99 where R is either 2 or 10.
100 @param scale to what position to round.
101 @return size in bytes
102*/
103int decimal_binary_size(int precision, int scale);
104
105#ifdef __cplusplus
106}
107#endif // __cplusplus
108
109#endif // MYSQL_BINLOG_EVENT_EXPORT_BINARY_LOG_FUNCS_H
enum_calc_field_size_status
Definition: binary_log_funcs.h:60
@ CALC_FIELD_SIZE_OK
Definition: binary_log_funcs.h:61
@ CALC_FIELD_SIZE_INVALID_TYPE
Definition: binary_log_funcs.h:63
@ CALC_FIELD_SIZE_TRUNCATED
Definition: binary_log_funcs.h:62
unsigned int my_time_binary_length(unsigned int dec)
Calculate binary size of packed numeric time representation.
Definition: binary_log_funcs.cpp:56
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:97
unsigned int my_timestamp_binary_length(unsigned int dec)
Calculate on-disk size of a timestamp value.
Definition: binary_log_funcs.cpp:85
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:202
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:412
enum enum_calc_field_size_status calc_field_size_checked(unsigned char col, const unsigned char *master_data, unsigned int metadata, size_t available, uint32_t *field_size)
This helper function calculates the size in bytes of a particular field in a row type event,...
Definition: binary_log_funcs.cpp:419
unsigned int my_datetime_binary_length(unsigned int dec)
Calculate binary size of packed datetime representation.
Definition: binary_log_funcs.cpp:70
This file contains the field type.
enum_field_types
Column types for MySQL Note: Keep include/mysql/components/services/bits/stored_program_bits....
Definition: field_types.h:56
static const std::string dec("DECRYPTION")