| 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 BINARY_LOG_FUNCS_INCLUDED |
| 30 |
#define BINARY_LOG_FUNCS_INCLUDED |
| 31 |
|
| 32 |
#include <stdint.h> |
| 33 |
#include "field_types.h" // enum_field_types |
| 34 |
|
| 35 |
#ifdef __cplusplus |
| 36 |
extern "C" { |
| 37 |
#endif |
| 38 |
|
| 39 |
unsigned int my_time_binary_length(unsigned int dec); |
| 40 |
unsigned int my_datetime_binary_length(unsigned int dec); |
| 41 |
unsigned int my_timestamp_binary_length(unsigned int dec); |
| 42 |
|
| 43 |
/** |
| 44 |
This helper function calculates the size in bytes of a particular field in a |
| 45 |
row type event as defined by the field_ptr and metadata_ptr arguments. |
| 46 |
|
| 47 |
@param col Field type code |
| 48 |
@param master_data The field data |
| 49 |
@param metadata The field metadata |
| 50 |
|
| 51 |
@note We need the actual field data because the string field size is not |
| 52 |
part of the meta data. :( |
| 53 |
|
| 54 |
@return The size in bytes of a particular field |
| 55 |
*/ |
| 56 |
uint32_t calc_field_size(unsigned char col, const unsigned char *master_data, |
| 57 |
unsigned int metadata); |
| 58 |
|
| 59 |
/** |
| 60 |
Compute the maximum display length of a field. |
| 61 |
|
| 62 |
@param sql_type Type of the field |
| 63 |
@param metadata The metadata from the master for the field. |
| 64 |
@return Maximum length of the field in bytes. |
| 65 |
*/ |
| 66 |
unsigned int max_display_length_for_field(enum_field_types sql_type, |
| 67 |
unsigned int metadata); |
| 68 |
|
| 69 |
/** |
| 70 |
Returns the size of array to hold a binary representation of a decimal |
| 71 |
@param precision number of significant digits in a particular radix R |
| 72 |
where R is either 2 or 10. |
| 73 |
@param scale to what position to round. |
| 74 |
@return size in bytes |
| 75 |
*/ |
| 76 |
int decimal_binary_size(int precision, int scale); |
| 77 |
|
| 78 |
#ifdef __cplusplus |
| 79 |
} |
| 80 |
#endif // __cplusplus |
| 81 |
|
| 82 |
#endif /* BINARY_LOG_FUNCS_INCLUDED */ |