├── .clang-format ├── .gitignore ├── .gitmodules ├── ACKNOWLEDGEMENTS ├── AMBuildScript ├── AMBuilder ├── LICENSE ├── PackageScript ├── README.md ├── configure.py ├── network_connection.pb.h ├── scripts ├── check-newlines.sh └── format.sh ├── sql_mm.sln ├── sql_mm.vcxproj ├── sql_mm.vcxproj.filters ├── sql_mm.vcxproj.user ├── src ├── common │ ├── database.h │ ├── interface.h │ └── memtable.h ├── mysql │ ├── mysql_client.cpp │ ├── mysql_client.h │ ├── mysql_database.cpp │ ├── mysql_database.h │ ├── mysql_result.cpp │ ├── mysql_result.h │ └── operations │ │ ├── mysql_connect.cpp │ │ ├── mysql_connect.h │ │ ├── mysql_query.cpp │ │ ├── mysql_query.h │ │ ├── mysql_transact.cpp │ │ └── mysql_transact.h ├── public │ ├── mysql_mm.h │ ├── sql_mm.h │ └── sqlite_mm.h ├── sql_mm.cpp ├── sql_mm.h ├── sqlite │ ├── operations │ │ ├── sqlite_connectop.cpp │ │ ├── sqlite_connectop.h │ │ ├── sqlite_queryop.cpp │ │ ├── sqlite_queryop.h │ │ ├── sqlite_transactop.cpp │ │ └── sqlite_transactop.h │ ├── sqlite_client.cpp │ ├── sqlite_client.h │ ├── sqlite_database.cpp │ ├── sqlite_database.h │ ├── sqlite_query.cpp │ ├── sqlite_query.h │ ├── sqlite_result.cpp │ └── sqlite_result.h └── utils │ ├── module.h │ ├── plat.h │ ├── plat_linux.cpp │ └── plat_win.cpp └── vendor ├── mysql ├── include │ ├── big_endian.h │ ├── binary_log_types.h │ ├── byte_order_generic.h │ ├── byte_order_generic_x86.h │ ├── decimal.h │ ├── errmsg.h │ ├── keycache.h │ ├── little_endian.h │ ├── m_ctype.h │ ├── m_string.h │ ├── my_alloc.h │ ├── my_byteorder.h │ ├── my_command.h │ ├── my_compiler.h │ ├── my_config.h │ ├── my_dbug.h │ ├── my_dir.h │ ├── my_getopt.h │ ├── my_global.h │ ├── my_list.h │ ├── my_sys.h │ ├── my_thread.h │ ├── my_thread_local.h │ ├── my_xml.h │ ├── mysql.h │ ├── mysql │ │ ├── client_authentication.h │ │ ├── client_plugin.h │ │ ├── client_plugin.h.pp │ │ ├── com_data.h │ │ ├── get_password.h │ │ ├── group_replication_priv.h │ │ ├── innodb_priv.h │ │ ├── mysql_lex_string.h │ │ ├── plugin.h │ │ ├── plugin_audit.h │ │ ├── plugin_audit.h.pp │ │ ├── plugin_auth.h │ │ ├── plugin_auth.h.pp │ │ ├── plugin_auth_common.h │ │ ├── plugin_ftparser.h │ │ ├── plugin_ftparser.h.pp │ │ ├── plugin_group_replication.h │ │ ├── plugin_keyring.h │ │ ├── plugin_keyring.h.pp │ │ ├── plugin_trace.h │ │ ├── plugin_validate_password.h │ │ ├── psi │ │ │ ├── mysql_file.h │ │ │ ├── mysql_idle.h │ │ │ ├── mysql_mdl.h │ │ │ ├── mysql_memory.h │ │ │ ├── mysql_ps.h │ │ │ ├── mysql_socket.h │ │ │ ├── mysql_sp.h │ │ │ ├── mysql_stage.h │ │ │ ├── mysql_statement.h │ │ │ ├── mysql_table.h │ │ │ ├── mysql_thread.h │ │ │ ├── mysql_transaction.h │ │ │ ├── psi.h │ │ │ ├── psi_base.h │ │ │ └── psi_memory.h │ │ ├── service_command.h │ │ ├── service_locking.h │ │ ├── service_my_plugin_log.h │ │ ├── service_my_snprintf.h │ │ ├── service_mysql_alloc.h │ │ ├── service_mysql_keyring.h │ │ ├── service_mysql_password_policy.h │ │ ├── service_mysql_string.h │ │ ├── service_parser.h │ │ ├── service_rpl_transaction_ctx.h │ │ ├── service_rpl_transaction_write_set.h │ │ ├── service_rules_table.h │ │ ├── service_security_context.h │ │ ├── service_srv_session.h │ │ ├── service_srv_session_info.h │ │ ├── service_ssl_wrapper.h │ │ ├── service_thd_alloc.h │ │ ├── service_thd_engine_lock.h │ │ ├── service_thd_wait.h │ │ ├── service_thread_scheduler.h │ │ ├── services.h │ │ ├── services.h.pp │ │ ├── thread_pool_priv.h │ │ └── thread_type.h │ ├── mysql_com.h │ ├── mysql_com_server.h │ ├── mysql_embed.h │ ├── mysql_time.h │ ├── mysql_version.h │ ├── mysqld_ername.h │ ├── mysqld_error.h │ ├── mysqlx_ername.h │ ├── mysqlx_error.h │ ├── mysqlx_version.h │ ├── plugin.h │ ├── plugin_audit.h │ ├── plugin_ftparser.h │ ├── plugin_group_replication.h │ ├── plugin_keyring.h │ ├── plugin_validate_password.h │ ├── sql_common.h │ ├── sql_state.h │ ├── sslopt-case.h │ ├── sslopt-longopts.h │ ├── sslopt-vars.h │ ├── thr_cond.h │ ├── thr_mutex.h │ ├── thr_rwlock.h │ └── typelib.h └── lib │ └── mysqlclient.lib └── sqlite-source ├── sqlite3.c └── sqlite3.h /.clang-format: -------------------------------------------------------------------------------- 1 | Language: Cpp 2 | Standard: Cpp11 3 | 4 | AccessModifierOffset: -4 5 | AlignConsecutiveMacros: Consecutive 6 | AlignEscapedNewlines: DontAlign 7 | AllowShortBlocksOnASingleLine: Never 8 | AllowShortCaseLabelsOnASingleLine: false 9 | AllowShortEnumsOnASingleLine: false 10 | AllowShortFunctionsOnASingleLine: Empty 11 | AllowShortIfStatementsOnASingleLine: Never 12 | AllowShortLoopsOnASingleLine: false 13 | BitFieldColonSpacing: After 14 | BreakArrays: true 15 | BreakBeforeBinaryOperators: NonAssignment 16 | BreakBeforeBraces: Allman 17 | BreakBeforeTernaryOperators: true 18 | AlwaysBreakTemplateDeclarations: true 19 | ColumnLimit: 150 20 | CompactNamespaces: false 21 | EmptyLineBeforeAccessModifier: Always 22 | IncludeBlocks: Preserve 23 | IndentCaseLabels: true 24 | InsertBraces: true 25 | InsertNewlineAtEOF: true 26 | KeepEmptyLinesAtTheStartOfBlocks: false 27 | LineEnding: LF 28 | MaxEmptyLinesToKeep: 1 29 | NamespaceIndentation: All 30 | PointerAlignment: Right 31 | ReferenceAlignment: Right 32 | SeparateDefinitionBlocks: Always 33 | SortIncludes: Never 34 | SpaceAfterCStyleCast: false 35 | SpaceAfterLogicalNot: false 36 | SpaceAfterTemplateKeyword: false 37 | SpaceBeforeAssignmentOperators: true 38 | SpaceBeforeCaseColon: false 39 | SpaceBeforeCpp11BracedList: true 40 | SpaceBeforeCtorInitializerColon: true 41 | SpaceBeforeInheritanceColon: true 42 | SpaceBeforeParens: ControlStatementsExceptControlMacros 43 | SpaceBeforeRangeBasedForLoopColon: true 44 | SpaceBeforeSquareBrackets: false 45 | SpaceInEmptyBlock: false 46 | SpacesInAngles: Never 47 | SpacesInSquareBrackets: false 48 | UseTab: Never 49 | IndentWidth: 4 50 | TabWidth: 4 51 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vs 2 | .vscode 3 | build* 4 | winbuild 5 | package -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "hl2sdk-manifests"] 2 | path = hl2sdk-manifests 3 | url = https://github.com/alliedmodders/hl2sdk-manifests 4 | -------------------------------------------------------------------------------- /ACKNOWLEDGEMENTS: -------------------------------------------------------------------------------- 1 | /** 2 | * ============================================================================= 3 | * CS2Fixes 4 | * Copyright (C) 2023 Source2ZE 5 | * ============================================================================= 6 | * 7 | * This program is free software; you can redistribute it and/or modify it under 8 | * the terms of the GNU General Public License, version 3.0, as published by the 9 | * Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 14 | * details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * this program. If not, see . 18 | */ 19 | -------------------------------------------------------------------------------- /AMBuilder: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et ft=python: 2 | import os 3 | 4 | # Here only one sdk should be available to generate only one executable in the end, 5 | # as multi-sdk loading isn't supported out of the box by metamod, and would require specifying the full path in the vdf 6 | # which in the end would ruin the multi-platform (unix, win etc) loading by metamod as it won't be able to append platform specific extension 7 | # so just fall back to the single binary. 8 | # Multi-sdk solutions should be manually loaded with a custom plugin loader (examples being sourcemod, stripper:source) 9 | for sdk_target in MMSPlugin.sdk_targets: 10 | sdk = sdk_target.sdk 11 | cxx = sdk_target.cxx 12 | 13 | binary = MMSPlugin.HL2Library(builder, cxx, MMSPlugin.plugin_name, sdk) 14 | 15 | binary.compiler.cxxincludes += [ 16 | os.path.join(builder.sourcePath, 'src'), 17 | ] 18 | 19 | binary.sources += [ 20 | 'src/sql_mm.cpp', 21 | 22 | 'src/mysql/operations/mysql_connect.cpp', 23 | 'src/mysql/operations/mysql_query.cpp', 24 | 'src/mysql/operations/mysql_transact.cpp', 25 | 'src/mysql/mysql_database.cpp', 26 | 'src/mysql/mysql_result.cpp', 27 | 'src/mysql/mysql_client.cpp', 28 | 29 | 'vendor/sqlite-source/sqlite3.c', 30 | 'src/sqlite/operations/sqlite_connectop.cpp', 31 | 'src/sqlite/operations/sqlite_queryop.cpp', 32 | 'src/sqlite/operations/sqlite_transactop.cpp', 33 | 'src/sqlite/sqlite_client.cpp', 34 | 'src/sqlite/sqlite_database.cpp', 35 | 'src/sqlite/sqlite_result.cpp', 36 | 'src/sqlite/sqlite_query.cpp', 37 | ] 38 | 39 | binary.compiler.defines += [ 40 | 'SQLITE_OMIT_LOAD_EXTENSION', 41 | 'SQLITE_THREADSAFE', 42 | 'SQLITE_USE_URI', 43 | 'SQLITE_ALLOW_URI_AUTHORITY', 44 | ] 45 | 46 | if binary.compiler.target.platform == 'linux': 47 | binary.sources += [ 48 | 'src/utils/plat_linux.cpp' 49 | ] 50 | binary.compiler.postlink += [ 51 | '/usr/lib/x86_64-linux-gnu/libmysqlclient.a', 52 | '-ldl', 53 | '-lz', 54 | '-lpthread', 55 | '-lm', 56 | ] 57 | binary.compiler.postlink += ['-lrt', '-lssl', '-lcrypto'] 58 | 59 | if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang': 60 | binary.compiler.cxxflags += ['-fno-rtti'] 61 | 62 | if binary.compiler.target.platform == 'windows': 63 | binary.compiler.defines += ['WIN32_LEAN_AND_MEAN'] 64 | binary.compiler.cxxincludes += [ 65 | os.path.join(builder.sourcePath, 'vendor', 'mysql', 'include'), 66 | ] 67 | binary.compiler.postlink += [ 68 | 'crypt32.lib', 69 | os.path.join(builder.sourcePath, 'vendor', 'mysql', 'lib', 'mysqlclient.lib'), 70 | ] 71 | 72 | binary.custom = [builder.tools.Protoc(protoc = sdk_target.protoc, sources = [ 73 | os.path.join(sdk['path'], 'common', 'network_connection.proto'), 74 | ])] 75 | 76 | nodes = builder.Add(binary) 77 | MMSPlugin.binaries += [nodes] 78 | -------------------------------------------------------------------------------- /PackageScript: -------------------------------------------------------------------------------- 1 | # vim: set ts=2 sw=2 tw=99 noet ft=python: 2 | import os 3 | 4 | builder.SetBuildFolder('package') 5 | 6 | metamod_folder = builder.AddFolder(os.path.join('addons', 'metamod')) 7 | bin_folder_path = os.path.join('addons', MMSPlugin.plugin_name, 'bin') 8 | bin_folder = builder.AddFolder(bin_folder_path) 9 | 10 | for cxx in MMSPlugin.all_targets: 11 | if cxx.target.arch == 'x86_64': 12 | if cxx.target.platform == 'windows': 13 | bin64_folder_path = os.path.join('addons', MMSPlugin.plugin_name, 'bin', 'win64') 14 | bin64_folder = builder.AddFolder(bin64_folder_path) 15 | elif cxx.target.platform == 'linux': 16 | bin64_folder_path = os.path.join('addons', MMSPlugin.plugin_name, 'bin', 'linuxsteamrt64') 17 | bin64_folder = builder.AddFolder(bin64_folder_path) 18 | elif cxx.target.platform == 'mac': 19 | bin64_folder_path = os.path.join('addons', MMSPlugin.plugin_name, 'bin', 'osx64') 20 | bin64_folder = builder.AddFolder(bin64_folder_path) 21 | 22 | pdb_list = [] 23 | for task in MMSPlugin.binaries: 24 | # This hardly assumes there's only 1 targetted platform and would be overwritten 25 | # with whatever comes last if multiple are used! 26 | with open(os.path.join(builder.buildPath, MMSPlugin.plugin_name + '.vdf'), 'w') as fp: 27 | fp.write('"Metamod Plugin"\n') 28 | fp.write('{\n') 29 | fp.write(f'\t"alias"\t"{MMSPlugin.plugin_alias}"\n') 30 | if task.target.arch == 'x86_64': 31 | fp.write(f'\t"file"\t"{os.path.join(bin64_folder_path, MMSPlugin.plugin_name)}"\n') 32 | else: 33 | fp.write(f'\t"file"\t"{os.path.join(bin_folder_path, MMSPlugin.plugin_name)}"\n') 34 | fp.write('}\n') 35 | 36 | if task.target.arch == 'x86_64': 37 | builder.AddCopy(task.binary, bin64_folder) 38 | else: 39 | builder.AddCopy(task.binary, bin_folder) 40 | 41 | if task.debug: 42 | pdb_list.append(task.debug) 43 | 44 | builder.AddCopy(os.path.join(builder.buildPath, MMSPlugin.plugin_name + '.vdf'), metamod_folder) 45 | 46 | # Generate PDB info. 47 | with open(os.path.join(builder.buildPath, 'pdblog.txt'), 'wt') as fp: 48 | for line in pdb_list: 49 | fp.write(line.path + '\n') -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SQLMM 2 | 3 | SQLMM provides simple non-blocking MySQL/SQLite connectors for MetaMod. 4 | 5 | > [!IMPORTANT] 6 | > Linux build requires `libmysqlclient-dev` package to be installed. 7 | 8 | # Features 9 | 10 | - Non-blocking MySQL/SQLite queries/transactions 11 | - Windows & Linux support 12 | - Simple API 13 | 14 | # Interface 15 | 16 | SQLMM will expose an interface in `OnMetamodQuery` which can then be queried with `(ISQLInterface*)g_SMAPI->MetaFactory(SQLMM_INTERFACE, &ret, NULL);` by other plugins. 17 | Example: 18 | ```c++ 19 | ISQLiteClient *g_pSQLiteClient; 20 | g_pSQLiteClient = ((ISQLInterface *)g_SMAPI->MetaFactory(SQLMM_INTERFACE, nullptr, nullptr))->GetSQLiteClient(); 21 | g_SMAPI->PathFormat(buffer, sizeof(buffer), "path/to/database/db.sqlite3"); 22 | if (g_pSQLiteClient) 23 | { 24 | SQLiteConnectionInfo info; 25 | info.database = buffer; 26 | conn = g_pSQLiteClient->CreateSQLiteConnection(info); 27 | conn->Connect( 28 | [](bool success) 29 | { 30 | //... 31 | }); 32 | } 33 | ``` 34 | 35 | Interface definition can be found in `src/public`. 36 | 37 | ## Compilation 38 | 39 | ### Requirements 40 | 41 | - [Metamod:Source](https://www.sourcemm.net/downloads.php/?branch=master) (build 1219 or higher) 42 | - [AMBuild](https://wiki.alliedmods.net/Ambuild) 43 | 44 | ```bash 45 | git clone https://github.com/zer0k-z/sql_mm && cd sql_mm 46 | 47 | export MMSOURCE112=/path/to/metamod/ 48 | export HL2SDKCS2=/path/to/hl2sdk-cs2 49 | 50 | mkdir build && cd build 51 | python3 ../configure.py -s cs2 52 | ambuild 53 | ``` 54 | -------------------------------------------------------------------------------- /configure.py: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et: 2 | import sys 3 | try: 4 | from ambuild2 import run, util 5 | except: 6 | try: 7 | import ambuild 8 | sys.stderr.write('It looks like you have AMBuild 1 installed, but this project uses AMBuild 2.\n') 9 | sys.stderr.write('Upgrade to the latest version of AMBuild to continue.\n') 10 | except: 11 | sys.stderr.write('AMBuild must be installed to build this project.\n') 12 | sys.stderr.write('http://www.alliedmods.net/ambuild\n') 13 | sys.exit(1) 14 | 15 | # Hack to show a decent upgrade message, which wasn't done until 2.2. 16 | ambuild_version = getattr(run, 'CURRENT_API', '2.1') 17 | if ambuild_version.startswith('2.1'): 18 | sys.stderr.write("AMBuild 2.2 or higher is required; please update\n") 19 | sys.exit(1) 20 | 21 | parser = run.BuildParser(sourcePath=sys.path[0], api='2.2') 22 | parser.options.add_argument('-n', '--plugin-name', type=str, dest='plugin_name', default=None, 23 | help='Plugin name') 24 | parser.options.add_argument('-a', '--plugin-alias', type=str, dest='plugin_alias', default=None, 25 | help='Plugin alias') 26 | parser.options.add_argument('--hl2sdk-root', type=str, dest='hl2sdk_root', default=None, 27 | help='Root search folder for HL2SDKs') 28 | parser.options.add_argument('--hl2sdk-manifests', type=str, dest='hl2sdk_manifests', default=None, 29 | help='HL2SDK manifests source tree folder') 30 | parser.options.add_argument('--mms_path', type=str, dest='mms_path', default=None, 31 | help='Metamod:Source source tree folder') 32 | parser.options.add_argument('--enable-debug', action='store_const', const='1', dest='debug', 33 | help='Enable debugging symbols') 34 | parser.options.add_argument('--enable-optimize', action='store_const', const='1', dest='opt', 35 | help='Enable optimization') 36 | parser.options.add_argument('-s', '--sdks', default='all', dest='sdks', 37 | help='Build against specified SDKs; valid args are "all", "present", or ' 38 | 'comma-delimited list of engine names (default: "all")') 39 | parser.options.add_argument('--targets', type=str, dest='targets', default=None, 40 | help="Override the target architecture (use commas to separate multiple targets).") 41 | parser.Configure() 42 | -------------------------------------------------------------------------------- /network_connection.pb.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef int ENetworkDisconnectionReason; -------------------------------------------------------------------------------- /scripts/check-newlines.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | EXIT_CODE=0 4 | 5 | if grep -r $'\r' ./src/; then 6 | echo "found CRLF lines" 7 | EXIT_CODE=1 8 | fi 9 | 10 | for file in $(find ./src/ -type f); do 11 | if [[ $(tail -c1 $file | grep $'\n') ]]; then 12 | echo "missing final newline: $file" 13 | EXIT_CODE=1 14 | fi 15 | done 16 | 17 | exit "$EXIT_CODE" 18 | -------------------------------------------------------------------------------- /scripts/format.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | clang-format -i $(find src -type f -name '*.cpp' -o -name '*.h') 4 | -------------------------------------------------------------------------------- /sql_mm.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.3.32825.248 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sql_mm", "sql_mm.vcxproj", "{2A734041-5881-4EA1-BF05-46F361443AF3}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {2A734041-5881-4EA1-BF05-46F361443AF3}.Debug|x64.ActiveCfg = Debug|x64 17 | {2A734041-5881-4EA1-BF05-46F361443AF3}.Debug|x64.Build.0 = Debug|x64 18 | {2A734041-5881-4EA1-BF05-46F361443AF3}.Debug|x86.ActiveCfg = Debug|Win32 19 | {2A734041-5881-4EA1-BF05-46F361443AF3}.Debug|x86.Build.0 = Debug|Win32 20 | {2A734041-5881-4EA1-BF05-46F361443AF3}.Release|x64.ActiveCfg = Release|x64 21 | {2A734041-5881-4EA1-BF05-46F361443AF3}.Release|x64.Build.0 = Release|x64 22 | {2A734041-5881-4EA1-BF05-46F361443AF3}.Release|x86.ActiveCfg = Release|Win32 23 | {2A734041-5881-4EA1-BF05-46F361443AF3}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {12C11272-4784-4DD0-A905-B564ECADA421} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /sql_mm.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | E:\SteamLibrary\steamapps\common\Counter-Strike Global Offensive\game\bin\win64\cs2.exe 5 | -insecure +sv_lan 1 -debug -dev -dedicated +map kz3 +sv_hibernate_when_empty false 6 | WindowsLocalDebugger 7 | 8 | -------------------------------------------------------------------------------- /src/common/database.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class ThreadOperation 4 | { 5 | public: 6 | virtual void RunThreadPart() = 0; 7 | virtual void CancelThinkPart() = 0; 8 | virtual void RunThinkPart() = 0; 9 | 10 | private: 11 | }; 12 | -------------------------------------------------------------------------------- /src/common/interface.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "public/sql_mm.h" 3 | 4 | class SQLInterface : public ISQLInterface 5 | { 6 | IMySQLClient *GetMySQLClient(); 7 | ISQLiteClient *GetSQLiteClient(); 8 | }; 9 | -------------------------------------------------------------------------------- /src/common/memtable.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class BaseMemTable 7 | { 8 | public: 9 | BaseMemTable(unsigned int init_size) 10 | { 11 | membase = (unsigned char *)malloc(init_size); 12 | size = init_size; 13 | tail = 0; 14 | } 15 | 16 | ~BaseMemTable() 17 | { 18 | free(membase); 19 | membase = NULL; 20 | } 21 | 22 | public: 23 | /** 24 | * Allocates 'size' bytes of memory. 25 | * Optionally outputs the address through 'addr'. 26 | * Returns an index >= 0 on success, < 0 on failure. 27 | */ 28 | int CreateMem(unsigned int addsize, void **addr) 29 | { 30 | int idx = (int)tail; 31 | 32 | while (tail + addsize >= size) 33 | { 34 | size *= 2; 35 | membase = (unsigned char *)realloc(membase, size); 36 | } 37 | 38 | tail += addsize; 39 | if (addr) 40 | { 41 | *addr = (void *)&membase[idx]; 42 | } 43 | 44 | return idx; 45 | } 46 | 47 | /** 48 | * Given an index into the memory table, returns its address. 49 | * Returns NULL if invalid. 50 | */ 51 | void *GetAddress(int index) 52 | { 53 | if (index < 0 || (unsigned int)index >= tail) 54 | { 55 | return NULL; 56 | } 57 | return &membase[index]; 58 | } 59 | 60 | /** 61 | * Scraps the memory table. For caching purposes, the memory 62 | * is not freed, however subsequent calls to CreateMem() will 63 | * begin at the first index again. 64 | */ 65 | void Reset() 66 | { 67 | tail = 0; 68 | } 69 | 70 | inline unsigned int GetMemUsage() 71 | { 72 | return size; 73 | } 74 | 75 | inline unsigned int GetActualMemUsed() 76 | { 77 | return tail; 78 | } 79 | 80 | private: 81 | unsigned char *membase; 82 | unsigned int size; 83 | unsigned int tail; 84 | }; 85 | 86 | class BaseStringTable 87 | { 88 | public: 89 | BaseStringTable(unsigned int init_size) : m_table(init_size) {} 90 | 91 | public: 92 | /** 93 | * Adds a string to the string table and returns its index. 94 | */ 95 | int AddString(const char *string) 96 | { 97 | return AddString(string, strlen(string)); 98 | } 99 | 100 | /** 101 | * Adds a string to the string table and returns its index. 102 | */ 103 | int AddString(const char *string, size_t length) 104 | { 105 | size_t len = length + 1; 106 | int idx; 107 | char *addr; 108 | 109 | idx = m_table.CreateMem(len, (void **)&addr); 110 | memcpy(addr, string, length + 1); 111 | return idx; 112 | } 113 | 114 | /** 115 | * Given an index into the string table, returns the associated string. 116 | */ 117 | inline const char *GetString(int str) 118 | { 119 | return (const char *)m_table.GetAddress(str); 120 | } 121 | 122 | /** 123 | * Scraps the string table. For caching purposes, the memory 124 | * is not freed, however subsequent calls to AddString() will 125 | * begin at the first index again. 126 | */ 127 | void Reset() 128 | { 129 | m_table.Reset(); 130 | } 131 | 132 | /** 133 | * Returns the parent BaseMemTable that this string table uses. 134 | */ 135 | inline BaseMemTable *GetMemTable() 136 | { 137 | return &m_table; 138 | } 139 | 140 | private: 141 | BaseMemTable m_table; 142 | }; 143 | -------------------------------------------------------------------------------- /src/mysql/mysql_client.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * ============================================================================= 3 | * CS2Fixes 4 | * Copyright (C) 2023 Source2ZE 5 | * ============================================================================= 6 | * 7 | * This program is free software; you can redistribute it and/or modify it under 8 | * the terms of the GNU General Public License, version 3.0, as published by the 9 | * Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 14 | * details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * this program. If not, see . 18 | */ 19 | 20 | #include "mysql_client.h" 21 | #include "mysql_database.h" 22 | #include "tier0/dbg.h" 23 | 24 | extern std::vector g_vecMysqlConnections; 25 | 26 | IMySQLConnection *CMySQLClient::CreateMySQLConnection(MySQLConnectionInfo info) 27 | { 28 | auto connection = new MySQLConnection(info); 29 | g_vecMysqlConnections.push_back(connection); 30 | 31 | return connection; 32 | } 33 | -------------------------------------------------------------------------------- /src/mysql/mysql_client.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ============================================================================= 3 | * CS2Fixes 4 | * Copyright (C) 2023 Source2ZE 5 | * ============================================================================= 6 | * 7 | * This program is free software; you can redistribute it and/or modify it under 8 | * the terms of the GNU General Public License, version 3.0, as published by the 9 | * Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 14 | * details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * this program. If not, see . 18 | */ 19 | 20 | #pragma once 21 | 22 | #include "public/mysql_mm.h" 23 | 24 | class CMySQLClient : public IMySQLClient 25 | { 26 | public: 27 | IMySQLConnection *CreateMySQLConnection(MySQLConnectionInfo info); 28 | }; 29 | -------------------------------------------------------------------------------- /src/mysql/mysql_database.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ============================================================================= 3 | * CS2Fixes 4 | * Copyright (C) 2023 Source2ZE 5 | * ============================================================================= 6 | * 7 | * This program is free software; you can redistribute it and/or modify it under 8 | * the terms of the GNU General Public License, version 3.0, as published by the 9 | * Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 14 | * details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * this program. If not, see . 18 | */ 19 | 20 | #pragma once 21 | 22 | #ifdef WIN32 23 | #include 24 | #include 25 | #else 26 | #include 27 | #endif 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include "common/database.h" 34 | #include "public/mysql_mm.h" 35 | 36 | class MySQLConnection : public IMySQLConnection 37 | { 38 | public: 39 | MySQLConnection(const MySQLConnectionInfo info); 40 | ~MySQLConnection(); 41 | void Connect(ConnectCallbackFunc callback); 42 | void Query(char *query, QueryCallbackFunc callback); 43 | void Query(const char *query, QueryCallbackFunc callback, ...); 44 | 45 | void ExecuteTransaction(Transaction txn, TransactionSuccessCallbackFunc success, TransactionFailureCallbackFunc failure); 46 | 47 | void Destroy(); 48 | void RunFrame(); 49 | 50 | void SetDatabase(MYSQL *db) 51 | { 52 | m_pDatabase = db; 53 | } 54 | 55 | MYSQL *GetDatabase() 56 | { 57 | return m_pDatabase; 58 | } 59 | 60 | unsigned int GetInsertID(); 61 | unsigned int GetAffectedRows(); 62 | std::string Escape(char *string); 63 | std::string Escape(const char *string); 64 | 65 | MySQLConnectionInfo m_info; 66 | 67 | private: 68 | void ThreadRun(); 69 | void AddToThreadQueue(ThreadOperation *threadOperation); 70 | 71 | std::queue m_threadQueue; 72 | std::queue m_ThinkQueue; 73 | std::unique_ptr m_thread; 74 | std::condition_variable m_QueueEvent; 75 | std::mutex m_Lock; 76 | std::mutex m_ThinkLock; 77 | bool m_Terminate = false; 78 | MYSQL *m_pDatabase = nullptr; 79 | }; 80 | -------------------------------------------------------------------------------- /src/mysql/mysql_result.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ============================================================================= 3 | * CS2Fixes 4 | * Copyright (C) 2023 Source2ZE 5 | * Original code from SourceMod 6 | * Copyright (C) 2004-2014 AlliedModders LLC 7 | * ============================================================================= 8 | * 9 | * This program is free software; you can redistribute it and/or modify it under 10 | * the terms of the GNU General Public License, version 3.0, as published by the 11 | * Free Software Foundation. 12 | * 13 | * This program is distributed in the hope that it will be useful, but WITHOUT 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 16 | * details. 17 | * 18 | * You should have received a copy of the GNU General Public License along with 19 | * this program. If not, see . 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "mysql_database.h" 25 | #include "public/mysql_mm.h" 26 | 27 | class MySQLConnection; 28 | class CMySQLQuery; 29 | 30 | class CMySQLResult : public ISQLResult, ISQLRow 31 | { 32 | friend class CMySQLQuery; 33 | 34 | public: 35 | CMySQLResult(MYSQL_RES *res); 36 | 37 | void Update(); 38 | 39 | int GetRowCount(); 40 | int GetFieldCount(); 41 | bool FieldNameToNum(const char *name, unsigned int *columnId); 42 | const char *FieldNumToName(unsigned int colId); 43 | bool MoreRows(); 44 | ISQLRow *FetchRow(); 45 | ISQLRow *CurrentRow(); 46 | bool Rewind(); 47 | int GetFieldType(unsigned int field); 48 | const char *GetString(unsigned int columnId, size_t *length = nullptr); 49 | size_t GetDataSize(unsigned int columnId); 50 | float GetFloat(unsigned int columnId); 51 | int GetInt(unsigned int columnId); 52 | bool IsNull(unsigned int columnId); 53 | int64_t GetInt64(unsigned int columnId); 54 | 55 | private: 56 | // MYSQL* m_pDatabase; 57 | MYSQL_RES *m_pRes; 58 | 59 | unsigned int m_ColCount = 0; 60 | unsigned int m_RowCount = 0; 61 | unsigned int m_CurRow = 0; 62 | MYSQL_ROW m_Row; 63 | unsigned long *m_Lengths = 0; 64 | }; 65 | 66 | class CMySQLQuery : public ISQLQuery 67 | { 68 | friend class CMySQLResult; 69 | 70 | public: 71 | CMySQLQuery(MySQLConnection *db, MYSQL_RES *res); 72 | ~CMySQLQuery(); 73 | ISQLResult *GetResultSet(); 74 | bool FetchMoreResults(); 75 | unsigned int GetInsertId(); 76 | unsigned int GetAffectedRows(); 77 | 78 | private: 79 | MySQLConnection *m_pDatabase; 80 | CMySQLResult m_res; 81 | unsigned int m_insertId; 82 | unsigned int m_affectedRows; 83 | }; 84 | -------------------------------------------------------------------------------- /src/mysql/operations/mysql_connect.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * ============================================================================= 3 | * CS2Fixes 4 | * Copyright (C) 2023 Source2ZE 5 | * Original code from SourceMod 6 | * Copyright (C) 2004-2014 AlliedModders LLC 7 | * ============================================================================= 8 | * 9 | * This program is free software; you can redistribute it and/or modify it under 10 | * the terms of the GNU General Public License, version 3.0, as published by the 11 | * Free Software Foundation. 12 | * 13 | * This program is distributed in the hope that it will be useful, but WITHOUT 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 16 | * details. 17 | * 18 | * You should have received a copy of the GNU General Public License along with 19 | * this program. If not, see . 20 | */ 21 | 22 | #include "mysql_connect.h" 23 | #include "tier0/dbg.h" 24 | 25 | void TMySQLConnectOp::RunThreadPart() 26 | { 27 | m_szError[0] = '\0'; 28 | MYSQL *mysql = mysql_init(NULL); 29 | 30 | if (!mysql) 31 | { 32 | Error("Uh oh, mysql is null!"); 33 | } 34 | 35 | const char *host = NULL, *socket = NULL; 36 | 37 | int timeout = 60; 38 | 39 | mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (const char *)&timeout); 40 | mysql_options(mysql, MYSQL_OPT_READ_TIMEOUT, (const char *)&timeout); 41 | mysql_options(mysql, MYSQL_OPT_WRITE_TIMEOUT, (const char *)&timeout); 42 | 43 | bool my_true = true; 44 | mysql_options(mysql, MYSQL_OPT_RECONNECT, (const char *)&my_true); // deprecated 45 | 46 | if (m_pCon->m_info.host[0] == '/') 47 | { 48 | host = "localhost"; 49 | socket = host; 50 | } 51 | else 52 | { 53 | host = m_pCon->m_info.host; 54 | socket = NULL; 55 | } 56 | 57 | if (!mysql_real_connect(mysql, host, m_pCon->m_info.user, m_pCon->m_info.pass, m_pCon->m_info.database, m_pCon->m_info.port, socket, ((1) << 17))) 58 | { 59 | mysql_close(mysql); 60 | strncpy(m_szError, mysql_error(mysql), sizeof m_szError); 61 | return; 62 | } 63 | 64 | m_pDatabase = mysql; 65 | } 66 | 67 | void TMySQLConnectOp::RunThinkPart() 68 | { 69 | if (m_szError[0]) 70 | { 71 | ConMsg("Failed to establish a MySQL connection: %s\n", m_szError); 72 | } 73 | 74 | m_pCon->SetDatabase(m_pDatabase); 75 | m_callback(m_pDatabase != nullptr); 76 | } 77 | 78 | void TMySQLConnectOp::CancelThinkPart() 79 | { 80 | mysql_close(m_pDatabase); 81 | m_pCon->SetDatabase(nullptr); 82 | } 83 | -------------------------------------------------------------------------------- /src/mysql/operations/mysql_connect.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ============================================================================= 3 | * CS2Fixes 4 | * Copyright (C) 2023 Source2ZE 5 | * Original code from SourceMod 6 | * Copyright (C) 2004-2014 AlliedModders LLC 7 | * ============================================================================= 8 | * 9 | * This program is free software; you can redistribute it and/or modify it under 10 | * the terms of the GNU General Public License, version 3.0, as published by the 11 | * Free Software Foundation. 12 | * 13 | * This program is distributed in the hope that it will be useful, but WITHOUT 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 16 | * details. 17 | * 18 | * You should have received a copy of the GNU General Public License along with 19 | * this program. If not, see . 20 | */ 21 | 22 | #pragma once 23 | #include "../mysql_database.h" 24 | 25 | class TMySQLConnectOp : public ThreadOperation 26 | { 27 | public: 28 | TMySQLConnectOp(MySQLConnection *con, ConnectCallbackFunc func) : m_pCon(con), m_callback(func) {} 29 | 30 | void RunThreadPart(); 31 | void CancelThinkPart(); 32 | void RunThinkPart(); 33 | 34 | private: 35 | MySQLConnection *m_pCon; 36 | ConnectCallbackFunc m_callback; 37 | MYSQL *m_pDatabase = nullptr; 38 | char m_szError[255] {}; 39 | }; 40 | -------------------------------------------------------------------------------- /src/mysql/operations/mysql_query.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * ============================================================================= 3 | * CS2Fixes 4 | * Copyright (C) 2023 Source2ZE 5 | * Original code from SourceMod 6 | * Copyright (C) 2004-2014 AlliedModders LLC 7 | * ============================================================================= 8 | * 9 | * This program is free software; you can redistribute it and/or modify it under 10 | * the terms of the GNU General Public License, version 3.0, as published by the 11 | * Free Software Foundation. 12 | * 13 | * This program is distributed in the hope that it will be useful, but WITHOUT 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 16 | * details. 17 | * 18 | * You should have received a copy of the GNU General Public License along with 19 | * this program. If not, see . 20 | */ 21 | 22 | #include "mysql_query.h" 23 | #include "tier0/dbg.h" 24 | #include "../mysql_result.h" 25 | 26 | TMySQLQueryOp::~TMySQLQueryOp() 27 | { 28 | delete m_pQuery; 29 | } 30 | 31 | void TMySQLQueryOp::RunThreadPart() 32 | { 33 | auto pDatabase = m_pCon->GetDatabase(); 34 | m_szError[0] = '\0'; 35 | if (mysql_query(pDatabase, m_szQuery.c_str())) 36 | { 37 | V_snprintf(m_szError, sizeof m_szError, "MySQL query error: %s\n", mysql_error(pDatabase)); 38 | return; 39 | } 40 | 41 | if (mysql_field_count(pDatabase)) 42 | { 43 | m_res = mysql_store_result(pDatabase); 44 | } 45 | } 46 | 47 | void TMySQLQueryOp::RunThinkPart() 48 | { 49 | if (m_szError[0]) 50 | { 51 | ConMsg("%s\n", m_szError); 52 | return; 53 | } 54 | 55 | m_pQuery = new CMySQLQuery(m_pCon, m_res); 56 | m_callback(m_pQuery); 57 | } 58 | 59 | void TMySQLQueryOp::CancelThinkPart() 60 | { 61 | mysql_close(m_pCon->GetDatabase()); 62 | m_pCon->SetDatabase(nullptr); 63 | } 64 | -------------------------------------------------------------------------------- /src/mysql/operations/mysql_query.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ============================================================================= 3 | * CS2Fixes 4 | * Copyright (C) 2023 Source2ZE 5 | * Original code from SourceMod 6 | * Copyright (C) 2004-2014 AlliedModders LLC 7 | * ============================================================================= 8 | * 9 | * This program is free software; you can redistribute it and/or modify it under 10 | * the terms of the GNU General Public License, version 3.0, as published by the 11 | * Free Software Foundation. 12 | * 13 | * This program is distributed in the hope that it will be useful, but WITHOUT 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 16 | * details. 17 | * 18 | * You should have received a copy of the GNU General Public License along with 19 | * this program. If not, see . 20 | */ 21 | 22 | #pragma once 23 | #include "../mysql_database.h" 24 | #include "../mysql_result.h" 25 | 26 | class TMySQLQueryOp : public ThreadOperation 27 | { 28 | public: 29 | TMySQLQueryOp(MySQLConnection *con, std::string query, QueryCallbackFunc func) : m_pCon(con), m_szQuery(query), m_callback(func) {} 30 | 31 | ~TMySQLQueryOp(); 32 | 33 | void RunThreadPart(); 34 | void CancelThinkPart(); 35 | void RunThinkPart(); 36 | 37 | private: 38 | MySQLConnection *m_pCon; 39 | std::string m_szQuery; 40 | QueryCallbackFunc m_callback; 41 | MYSQL_RES *m_res = nullptr; 42 | CMySQLQuery *m_pQuery = nullptr; 43 | char m_szError[255] {}; 44 | }; 45 | -------------------------------------------------------------------------------- /src/mysql/operations/mysql_transact.cpp: -------------------------------------------------------------------------------- 1 | #include "mysql_transact.h" 2 | #include "tier0/dbg.h" 3 | #include "sql_mm.h" 4 | 5 | TMySQLTransactOp::~TMySQLTransactOp() 6 | { 7 | for (auto query : m_pQueries) 8 | { 9 | delete query; 10 | } 11 | m_pQueries.clear(); 12 | } 13 | 14 | void TMySQLTransactOp::RunThreadPart() 15 | { 16 | if (!this->DoSimpleQuery("BEGIN")) 17 | { 18 | return; 19 | } 20 | for (size_t i = 0; i < this->m_txn.queries.size(); i++) 21 | { 22 | CMySQLQuery *result = DoQuery(this->m_txn.queries[i].c_str()); 23 | if (!result) 24 | { 25 | this->DoSimpleQuery("ROLLBACK"); 26 | m_failIndex = (int)i; 27 | return; 28 | } 29 | this->m_pQueries.push_back(result); 30 | } 31 | if (!this->DoSimpleQuery("COMMIT")) 32 | { 33 | this->DoSimpleQuery("ROLLBACK"); 34 | return; 35 | } 36 | } 37 | 38 | void TMySQLTransactOp::CancelThinkPart() 39 | { 40 | mysql_close(m_pCon->GetDatabase()); 41 | m_pCon->SetDatabase(nullptr); 42 | } 43 | 44 | void TMySQLTransactOp::RunThinkPart() 45 | { 46 | if (!m_szError[0]) 47 | { 48 | m_successCallback(m_pQueries); 49 | m_pQueries.clear(); 50 | return; 51 | } 52 | META_CONPRINTF("TMySQLTransactOp ERROR: %s\n", m_szError); 53 | m_failureCallback(m_szError, m_failIndex); 54 | } 55 | 56 | bool TMySQLTransactOp::DoSimpleQuery(const char *query) 57 | { 58 | auto pQuery = DoQuery(query); 59 | if (!pQuery) 60 | { 61 | return false; 62 | } 63 | delete pQuery; 64 | return true; 65 | } 66 | 67 | CMySQLQuery *TMySQLTransactOp::DoQuery(const char *query) 68 | { 69 | auto pDatabase = m_pCon->GetDatabase(); 70 | if (mysql_query(pDatabase, query)) 71 | { 72 | V_snprintf(m_szError, sizeof m_szError, "MySQL query error: %s\n", mysql_error(pDatabase)); 73 | return NULL; 74 | } 75 | 76 | MYSQL_RES *res = NULL; 77 | if (mysql_field_count(pDatabase)) 78 | { 79 | res = mysql_store_result(pDatabase); 80 | if (!res) 81 | { 82 | return NULL; 83 | } 84 | } 85 | return new CMySQLQuery(m_pCon, res); 86 | } 87 | -------------------------------------------------------------------------------- /src/mysql/operations/mysql_transact.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../mysql_database.h" 3 | #include "../mysql_result.h" 4 | 5 | class TMySQLTransactOp : public ThreadOperation 6 | { 7 | public: 8 | TMySQLTransactOp(MySQLConnection *con, Transaction txn, TransactionSuccessCallbackFunc success, TransactionFailureCallbackFunc failure) 9 | : m_pCon(con), m_txn(txn), m_successCallback(success), m_failureCallback(failure) 10 | { 11 | } 12 | 13 | ~TMySQLTransactOp(); 14 | 15 | void RunThreadPart(); 16 | void CancelThinkPart(); 17 | void RunThinkPart(); 18 | 19 | private: 20 | MySQLConnection *m_pCon; 21 | Transaction m_txn; 22 | TransactionSuccessCallbackFunc m_successCallback; 23 | TransactionFailureCallbackFunc m_failureCallback; 24 | std::vector m_pQueries; 25 | char m_szError[255] {}; 26 | int m_failIndex; 27 | 28 | bool DoSimpleQuery(const char *query); 29 | CMySQLQuery *DoQuery(const char *query); 30 | }; 31 | -------------------------------------------------------------------------------- /src/public/mysql_mm.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ============================================================================= 3 | * CS2Fixes 4 | * Copyright (C) 2023 Source2ZE 5 | * Original code from SourceMod 6 | * Copyright (C) 2004-2014 AlliedModders LLC 7 | * ============================================================================= 8 | * 9 | * This program is free software; you can redistribute it and/or modify it under 10 | * the terms of the GNU General Public License, version 3.0, as published by the 11 | * Free Software Foundation. 12 | * 13 | * This program is distributed in the hope that it will be useful, but WITHOUT 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 16 | * details. 17 | * 18 | * You should have received a copy of the GNU General Public License along with 19 | * this program. If not, see . 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "sql_mm.h" 25 | 26 | typedef enum EMySQLType 27 | { 28 | MM_MYSQL_TYPE_DECIMAL, 29 | MM_MYSQL_TYPE_TINY, 30 | MM_MYSQL_TYPE_SHORT, 31 | MM_MYSQL_TYPE_LONG, 32 | MM_MYSQL_TYPE_FLOAT, 33 | MM_MYSQL_TYPE_DOUBLE, 34 | MM_MYSQL_TYPE_NULL, 35 | MM_MYSQL_TYPE_TIMESTAMP, 36 | MM_MYSQL_TYPE_LONGLONG, 37 | MM_MYSQL_TYPE_INT24, 38 | MM_MYSQL_TYPE_DATE, 39 | MM_MYSQL_TYPE_TIME, 40 | MM_MYSQL_TYPE_DATETIME, 41 | MM_MYSQL_TYPE_YEAR, 42 | MM_MYSQL_TYPE_NEWDATE, 43 | MM_MYSQL_TYPE_VARCHAR, 44 | MM_MYSQL_TYPE_BIT, 45 | MM_MYSQL_TYPE_TIMESTAMP2, 46 | MM_MYSQL_TYPE_DATETIME2, 47 | MM_MYSQL_TYPE_TIME2, 48 | MM_MYSQL_TYPE_UNKNOWN, 49 | MM_MYSQL_TYPE_JSON = 245, 50 | MM_MYSQL_TYPE_NEWDECIMAL = 246, 51 | MM_MYSQL_TYPE_ENUM = 247, 52 | MM_MYSQL_TYPE_SET = 248, 53 | MM_MYSQL_TYPE_TINY_BLOB = 249, 54 | MM_MYSQL_TYPE_MEDIUM_BLOB = 250, 55 | MM_MYSQL_TYPE_LONG_BLOB = 251, 56 | MM_MYSQL_TYPE_BLOB = 252, 57 | MM_MYSQL_TYPE_VAR_STRING = 253, 58 | MM_MYSQL_TYPE_STRING = 254, 59 | MM_MYSQL_TYPE_GEOMETRY = 255 60 | } EMySQLType; 61 | 62 | struct MySQLConnectionInfo 63 | { 64 | const char *host; 65 | const char *user; 66 | const char *pass; 67 | const char *database; 68 | int port = 3306; 69 | int timeout = 60; 70 | }; 71 | 72 | class IMySQLConnection : public ISQLConnection 73 | { 74 | }; 75 | 76 | class IMySQLClient 77 | { 78 | public: 79 | virtual IMySQLConnection *CreateMySQLConnection(MySQLConnectionInfo info) = 0; 80 | }; 81 | -------------------------------------------------------------------------------- /src/public/sql_mm.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #define SQLMM_INTERFACE "SQLInterface" 7 | 8 | class ISQLQuery; 9 | 10 | typedef std::function ConnectCallbackFunc; 11 | typedef std::function QueryCallbackFunc; 12 | typedef std::function)> TransactionSuccessCallbackFunc; 13 | typedef std::function TransactionFailureCallbackFunc; 14 | 15 | struct Transaction 16 | { 17 | std::vector queries; 18 | }; 19 | 20 | class ISQLRow 21 | { 22 | public: 23 | }; 24 | 25 | class ISQLResult 26 | { 27 | public: 28 | virtual int GetRowCount() = 0; 29 | virtual int GetFieldCount() = 0; 30 | virtual bool FieldNameToNum(const char *name, unsigned int *columnId) = 0; 31 | virtual const char *FieldNumToName(unsigned int colId) = 0; 32 | virtual bool MoreRows() = 0; 33 | virtual ISQLRow *FetchRow() = 0; 34 | virtual ISQLRow *CurrentRow() = 0; 35 | virtual bool Rewind() = 0; 36 | virtual int GetFieldType(unsigned int field) = 0; 37 | virtual const char *GetString(unsigned int columnId, size_t *length = nullptr) = 0; 38 | virtual size_t GetDataSize(unsigned int columnId) = 0; 39 | virtual float GetFloat(unsigned int columnId) = 0; 40 | virtual int GetInt(unsigned int columnId) = 0; 41 | virtual bool IsNull(unsigned int columnId) = 0; 42 | virtual int64_t GetInt64(unsigned int columnId) = 0; 43 | }; 44 | 45 | class ISQLQuery 46 | { 47 | public: 48 | virtual ISQLResult *GetResultSet() = 0; 49 | virtual bool FetchMoreResults() = 0; 50 | virtual unsigned int GetInsertId() = 0; 51 | virtual unsigned int GetAffectedRows() = 0; 52 | }; 53 | 54 | class ISQLConnection 55 | { 56 | public: 57 | virtual void Connect(ConnectCallbackFunc callback) = 0; 58 | virtual void Query(char *query, QueryCallbackFunc callback) = 0; 59 | virtual void Query(const char *query, QueryCallbackFunc callback, ...) = 0; 60 | virtual void ExecuteTransaction(Transaction txn, TransactionSuccessCallbackFunc success, TransactionFailureCallbackFunc failure) = 0; 61 | virtual void Destroy() = 0; 62 | virtual std::string Escape(char *string) = 0; 63 | virtual std::string Escape(const char *string) = 0; 64 | }; 65 | 66 | class IMySQLClient; 67 | class ISQLiteClient; 68 | 69 | class ISQLInterface 70 | { 71 | public: 72 | virtual IMySQLClient *GetMySQLClient() = 0; 73 | virtual ISQLiteClient *GetSQLiteClient() = 0; 74 | }; 75 | -------------------------------------------------------------------------------- /src/public/sqlite_mm.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "sql_mm.h" 3 | 4 | struct SQLiteConnectionInfo 5 | { 6 | // Relative to the base game directory. 7 | const char *database; 8 | }; 9 | 10 | class ISQLiteClient 11 | { 12 | public: 13 | virtual ISQLConnection *CreateSQLiteConnection(SQLiteConnectionInfo info) = 0; 14 | }; 15 | -------------------------------------------------------------------------------- /src/sql_mm.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ============================================================================= 3 | * CS2Fixes 4 | * Copyright (C) 2023 Source2ZE 5 | * ============================================================================= 6 | * 7 | * This program is free software; you can redistribute it and/or modify it under 8 | * the terms of the GNU General Public License, version 3.0, as published by the 9 | * Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 14 | * details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * this program. If not, see . 18 | */ 19 | 20 | #ifndef _INCLUDE_METAMOD_SOURCE_STUB_PLUGIN_H_ 21 | #define _INCLUDE_METAMOD_SOURCE_STUB_PLUGIN_H_ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include "igamesystem.h" 28 | 29 | class SQLPlugin : public ISmmPlugin, public IMetamodListener 30 | { 31 | public: 32 | bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late); 33 | bool Unload(char *error, size_t maxlen); 34 | void *OnMetamodQuery(const char *iface, int *ret); 35 | 36 | public: // hooks 37 | void Hook_ServerGamePostSimulate(const EventServerGamePostSimulate_t *); 38 | 39 | public: 40 | const char *GetAuthor(); 41 | const char *GetName(); 42 | const char *GetDescription(); 43 | const char *GetURL(); 44 | const char *GetLicense(); 45 | const char *GetVersion(); 46 | const char *GetDate(); 47 | const char *GetLogTag(); 48 | }; 49 | 50 | extern SQLPlugin g_SQLPlugin; 51 | 52 | PLUGIN_GLOBALVARS(); 53 | 54 | size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...); 55 | unsigned int strncopy(char *dest, const char *src, size_t count); 56 | 57 | #endif //_INCLUDE_METAMOD_SOURCE_STUB_PLUGIN_H_ 58 | -------------------------------------------------------------------------------- /src/sqlite/operations/sqlite_connectop.cpp: -------------------------------------------------------------------------------- 1 | #include "sqlite_connectop.h" 2 | #include "sql_mm.h" 3 | #include "filesystem.h" 4 | #include "bufferstring.h" 5 | 6 | int busy_handler(void *unused1, int unused2) 7 | { 8 | #if defined PLATFORM_WINDOWS 9 | Sleep(100); 10 | #elif defined PLATFORM_POSIX 11 | usleep(100000); 12 | #endif 13 | return 1; 14 | } 15 | 16 | void TSQLiteConnectOp::RunThreadPart() 17 | { 18 | m_szError[0] = '\0'; 19 | 20 | /* Try to open a new connection */ 21 | sqlite3 *sql; 22 | g_pFullFileSystem->CreateDirHierarchyForFile(m_pCon->info.database, nullptr); 23 | 24 | /* Get directory path and file name*/ 25 | char directory[MAX_PATH]; 26 | V_ExtractFilePath(m_pCon->info.database, directory, MAX_PATH); 27 | const char *fileName = V_UnqualifiedFileName(m_pCon->info.database); 28 | 29 | /* Convert directory path to full path */ 30 | CBufferStringGrowable fullPathBuffer; 31 | const char *path = g_pFullFileSystem->RelativePathToFullPath(directory, nullptr, fullPathBuffer); 32 | 33 | /* Merge the abs path and file name */ 34 | char fullPath[MAX_PATH]; 35 | V_ComposeFileName(fullPathBuffer.Get(), fileName, fullPath, MAX_PATH); 36 | 37 | int err = sqlite3_open(fullPath, &sql); 38 | if (err != SQLITE_OK) 39 | { 40 | strncopy(m_szError, sqlite3_errmsg(sql), sizeof(m_szError)); 41 | sqlite3_close(sql); 42 | return; 43 | } 44 | 45 | sqlite3_busy_handler(sql, busy_handler, NULL); 46 | 47 | m_pDatabase = sql; 48 | } 49 | 50 | void TSQLiteConnectOp::CancelThinkPart() 51 | { 52 | sqlite3_close(m_pDatabase); 53 | m_pCon->SetDatabase(nullptr); 54 | } 55 | 56 | void TSQLiteConnectOp::RunThinkPart() 57 | { 58 | if (m_szError[0]) 59 | { 60 | META_CONPRINTF("Failed to establish a SQLite connection: %s\n", m_szError); 61 | } 62 | 63 | m_pCon->SetDatabase(m_pDatabase); 64 | m_callback(m_pDatabase != nullptr); 65 | } 66 | -------------------------------------------------------------------------------- /src/sqlite/operations/sqlite_connectop.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../sqlite_database.h" 3 | 4 | class TSQLiteConnectOp : public ThreadOperation 5 | { 6 | public: 7 | TSQLiteConnectOp(SqConnection *con, ConnectCallbackFunc func) : m_pCon(con), m_callback(func) {} 8 | 9 | void RunThreadPart(); 10 | void CancelThinkPart(); 11 | void RunThinkPart(); 12 | 13 | private: 14 | SqConnection *m_pCon; 15 | ConnectCallbackFunc m_callback; 16 | sqlite3 *m_pDatabase = nullptr; 17 | char m_szError[255] {}; 18 | }; 19 | -------------------------------------------------------------------------------- /src/sqlite/operations/sqlite_queryop.cpp: -------------------------------------------------------------------------------- 1 | #include "sqlite_queryop.h" 2 | #include "tier0/dbg.h" 3 | #include "../sqlite_query.h" 4 | #include "sql_mm.h" 5 | 6 | TSQLiteQueryOp::~TSQLiteQueryOp() 7 | { 8 | delete m_pQuery; 9 | } 10 | 11 | void TSQLiteQueryOp::RunThreadPart() 12 | { 13 | auto pDatabase = m_pCon->GetDatabase(); 14 | m_pQuery = m_pCon->PrepareQuery(m_szQuery.c_str(), m_szError, sizeof(m_szError), NULL); 15 | if (!m_pQuery) 16 | { 17 | return; 18 | } 19 | if (!m_pQuery->Execute()) 20 | { 21 | strncopy(m_szError, m_pQuery->GetError(), sizeof(m_szError)); 22 | m_pQuery->Destroy(); 23 | } 24 | } 25 | 26 | void TSQLiteQueryOp::CancelThinkPart() 27 | { 28 | sqlite3_close(m_pCon->GetDatabase()); 29 | m_pCon->SetDatabase(nullptr); 30 | } 31 | 32 | void TSQLiteQueryOp::RunThinkPart() 33 | { 34 | if (m_szError[0]) 35 | { 36 | META_CONPRINTF("TSQLiteQueryOp ERROR: %s\n", m_szError); 37 | return; 38 | } 39 | m_callback(m_pQuery); 40 | } 41 | -------------------------------------------------------------------------------- /src/sqlite/operations/sqlite_queryop.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../sqlite_database.h" 3 | #include "../sqlite_result.h" 4 | #include "common/database.h" 5 | class SqConnection; 6 | class SqResults; 7 | class SqQuery; 8 | 9 | class TSQLiteQueryOp : public ThreadOperation 10 | { 11 | public: 12 | TSQLiteQueryOp(SqConnection *con, std::string query, QueryCallbackFunc func) : m_pCon(con), m_szQuery(query), m_callback(func) {} 13 | 14 | ~TSQLiteQueryOp(); 15 | 16 | void RunThreadPart(); 17 | void CancelThinkPart(); 18 | void RunThinkPart(); 19 | 20 | private: 21 | SqConnection *m_pCon; 22 | std::string m_szQuery; 23 | char m_szError[256] {}; 24 | QueryCallbackFunc m_callback; 25 | SqQuery *m_pQuery = nullptr; 26 | }; 27 | -------------------------------------------------------------------------------- /src/sqlite/operations/sqlite_transactop.cpp: -------------------------------------------------------------------------------- 1 | #include "sqlite_transactop.h" 2 | #include "tier0/dbg.h" 3 | #include "../sqlite_query.h" 4 | #include "sql_mm.h" 5 | 6 | TSQLiteTransactOp::~TSQLiteTransactOp() 7 | { 8 | for (auto query : m_pQueries) 9 | { 10 | delete query; 11 | } 12 | m_pQueries.clear(); 13 | } 14 | 15 | void TSQLiteTransactOp::RunThreadPart() 16 | { 17 | if (!this->DoSimpleQuery("BEGIN")) 18 | { 19 | return; 20 | } 21 | for (size_t i = 0; i < this->m_txn.queries.size(); i++) 22 | { 23 | SqQuery *result = DoQuery(this->m_txn.queries[i].c_str()); 24 | if (!result) 25 | { 26 | this->DoSimpleQuery("ROLLBACK"); 27 | m_failIndex = (int)i; 28 | return; 29 | } 30 | this->m_pQueries.push_back(result); 31 | } 32 | if (!this->DoSimpleQuery("COMMIT")) 33 | { 34 | this->DoSimpleQuery("ROLLBACK"); 35 | return; 36 | } 37 | } 38 | 39 | void TSQLiteTransactOp::CancelThinkPart() 40 | { 41 | sqlite3_close(m_pCon->GetDatabase()); 42 | m_pCon->SetDatabase(nullptr); 43 | } 44 | 45 | void TSQLiteTransactOp::RunThinkPart() 46 | { 47 | if (!m_szError[0]) 48 | { 49 | m_successCallback(m_pQueries); 50 | m_pQueries.clear(); 51 | return; 52 | } 53 | META_CONPRINTF("TSQLiteTransactOp ERROR: %s\n", m_szError); 54 | m_failureCallback(m_szError, m_failIndex); 55 | } 56 | 57 | bool TSQLiteTransactOp::DoSimpleQuery(const char *query) 58 | { 59 | auto pDatabase = m_pCon->GetDatabase(); 60 | auto pQuery = m_pCon->PrepareQuery(query, m_szError, sizeof(m_szError), NULL); 61 | if (!pQuery) 62 | { 63 | return false; 64 | } 65 | if (!pQuery->Execute()) 66 | { 67 | strncopy(m_szError, pQuery->GetError(), sizeof(m_szError)); 68 | pQuery->Destroy(); 69 | return false; 70 | } 71 | pQuery->Destroy(); 72 | return true; 73 | } 74 | 75 | SqQuery *TSQLiteTransactOp::DoQuery(const char *query) 76 | { 77 | auto pDatabase = m_pCon->GetDatabase(); 78 | auto pQuery = m_pCon->PrepareQuery(query, m_szError, sizeof(m_szError), NULL); 79 | if (!pQuery) 80 | { 81 | return nullptr; 82 | } 83 | if (!pQuery->Execute()) 84 | { 85 | strncopy(m_szError, pQuery->GetError(), sizeof(m_szError)); 86 | pQuery->Destroy(); 87 | return nullptr; 88 | } 89 | return pQuery; 90 | } 91 | -------------------------------------------------------------------------------- /src/sqlite/operations/sqlite_transactop.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../sqlite_database.h" 3 | #include "../sqlite_result.h" 4 | #include "common/database.h" 5 | class SqConnection; 6 | class SqResults; 7 | class SqQuery; 8 | 9 | class TSQLiteTransactOp : public ThreadOperation 10 | { 11 | public: 12 | TSQLiteTransactOp(SqConnection *con, Transaction txn, TransactionSuccessCallbackFunc success, TransactionFailureCallbackFunc failure) 13 | : m_pCon(con), m_txn(txn), m_successCallback(success), m_failureCallback(failure) 14 | { 15 | } 16 | 17 | ~TSQLiteTransactOp(); 18 | 19 | void RunThreadPart(); 20 | void CancelThinkPart(); 21 | void RunThinkPart(); 22 | 23 | private: 24 | SqConnection *m_pCon; 25 | Transaction m_txn; 26 | char m_szError[256] {}; 27 | int m_failIndex = -1; 28 | TransactionSuccessCallbackFunc m_successCallback; 29 | TransactionFailureCallbackFunc m_failureCallback; 30 | std::vector m_pQueries; 31 | 32 | bool DoSimpleQuery(const char *query); 33 | SqQuery *DoQuery(const char *query); 34 | }; 35 | -------------------------------------------------------------------------------- /src/sqlite/sqlite_client.cpp: -------------------------------------------------------------------------------- 1 | #include "sqlite_client.h" 2 | #include "sqlite_database.h" 3 | 4 | extern std::vector g_vecSqliteConnections; 5 | 6 | ISQLConnection *SqClient::CreateSQLiteConnection(SQLiteConnectionInfo info) 7 | { 8 | auto connection = new SqConnection(info); 9 | g_vecSqliteConnections.push_back(connection); 10 | 11 | return connection; 12 | } 13 | -------------------------------------------------------------------------------- /src/sqlite/sqlite_client.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "public/sqlite_mm.h" 3 | 4 | class SqClient : public ISQLiteClient 5 | { 6 | public: 7 | ISQLConnection *CreateSQLiteConnection(SQLiteConnectionInfo info); 8 | }; 9 | -------------------------------------------------------------------------------- /src/sqlite/sqlite_database.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "public/sqlite_mm.h" 9 | #include "vendor/sqlite-source/sqlite3.h" 10 | #include "operations/sqlite_queryop.h" 11 | #include "common/database.h" 12 | class SqQuery; 13 | 14 | class SqConnection : public ISQLConnection 15 | { 16 | public: 17 | SqConnection(const SQLiteConnectionInfo info); 18 | ~SqConnection(); 19 | void Connect(ConnectCallbackFunc callback); 20 | void Query(char *query, QueryCallbackFunc callback); 21 | void Query(const char *query, QueryCallbackFunc callback, ...); 22 | void ExecuteTransaction(Transaction txn, TransactionSuccessCallbackFunc success, TransactionFailureCallbackFunc failure); 23 | void Destroy(); 24 | void RunFrame(); 25 | std::string Escape(char *string); 26 | std::string Escape(const char *string); 27 | 28 | void SetDatabase(sqlite3 *db) 29 | { 30 | m_pDatabase = db; 31 | } 32 | 33 | SqQuery *PrepareQuery(const char *query, char *error, size_t maxlength, int *errCode = NULL); 34 | 35 | sqlite3 *GetDatabase() 36 | { 37 | return m_pDatabase; 38 | } 39 | 40 | SQLiteConnectionInfo info; 41 | 42 | private: 43 | void ThreadRun(); 44 | void AddToThreadQueue(ThreadOperation *threadOperation); 45 | 46 | std::queue m_threadQueue; 47 | std::queue m_ThinkQueue; 48 | std::unique_ptr m_thread; 49 | std::condition_variable m_QueueEvent; 50 | std::mutex m_Lock; 51 | std::mutex m_ThinkLock; 52 | bool m_Terminate = false; 53 | 54 | sqlite3 *m_pDatabase; 55 | std::string m_LastError; 56 | int m_LastErrorCode; 57 | }; 58 | 59 | inline bool IsPathSepChar(char c) 60 | { 61 | #ifdef WIN32 62 | return (c == '\\' || c == '/'); 63 | #else 64 | return (c == '/'); 65 | #endif 66 | } 67 | -------------------------------------------------------------------------------- /src/sqlite/sqlite_query.cpp: -------------------------------------------------------------------------------- 1 | #include "sqlite_query.h" 2 | #include "sqlite_result.h" 3 | 4 | SqQuery::SqQuery(SqConnection *conn, sqlite3_stmt *stmt) : m_pCon(conn), m_pStmt(stmt), m_pResults(NULL), m_AffectedRows(0), m_InsertID(0) 5 | { 6 | m_ParamCount = sqlite3_bind_parameter_count(m_pStmt); 7 | m_ColCount = sqlite3_column_count(m_pStmt); 8 | } 9 | 10 | SqQuery::~SqQuery() 11 | { 12 | delete m_pResults; 13 | sqlite3_finalize(m_pStmt); 14 | } 15 | 16 | ISQLResult *SqQuery::GetResultSet() 17 | { 18 | return m_pResults; 19 | } 20 | 21 | bool SqQuery::Execute() 22 | { 23 | int rc; 24 | 25 | if (!m_pResults && m_ColCount) 26 | { 27 | m_pResults = new SqResults(this); 28 | } 29 | 30 | if (m_pResults) 31 | { 32 | m_pResults->ResetResultCount(); 33 | } 34 | 35 | while ((rc = sqlite3_step(m_pStmt)) == SQLITE_ROW) 36 | { 37 | if (!m_pResults) 38 | { 39 | m_pResults = new SqResults(this); 40 | } 41 | m_pResults->PushResult(); 42 | } 43 | 44 | sqlite3 *db = m_pCon->GetDatabase(); 45 | if (rc != SQLITE_OK && rc != SQLITE_DONE && rc == sqlite3_errcode(db)) 46 | { 47 | m_LastErrorCode = rc; 48 | m_LastError.assign(sqlite3_errmsg(db)); 49 | m_AffectedRows = 0; 50 | m_InsertID = 0; 51 | } 52 | else 53 | { 54 | m_LastErrorCode = SQLITE_OK; 55 | m_AffectedRows = (unsigned int)sqlite3_changes(db); 56 | m_InsertID = (unsigned int)sqlite3_last_insert_rowid(db); 57 | } 58 | 59 | sqlite3_reset(m_pStmt); 60 | sqlite3_clear_bindings(m_pStmt); 61 | 62 | return (m_LastErrorCode == SQLITE_OK); 63 | } 64 | 65 | void SqQuery::Destroy() 66 | { 67 | delete this; 68 | } 69 | 70 | const char *SqQuery::GetError() 71 | { 72 | return m_LastError.c_str(); 73 | } 74 | 75 | unsigned int SqQuery::GetAffectedRows() 76 | { 77 | return m_AffectedRows; 78 | } 79 | 80 | unsigned int SqQuery::GetInsertId() 81 | { 82 | return m_InsertID; 83 | } 84 | 85 | sqlite3_stmt *SqQuery::GetStmt() 86 | { 87 | return m_pStmt; 88 | } 89 | -------------------------------------------------------------------------------- /src/sqlite/sqlite_query.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "sqlite_database.h" 4 | #include "public/sqlite_mm.h" 5 | #include "vendor/sqlite-source/sqlite3.h" 6 | class SqResults; 7 | class SqDatabase; 8 | 9 | class SqQuery : public ISQLQuery 10 | { 11 | friend class SqResults; 12 | 13 | public: 14 | SqQuery(SqConnection *conn, sqlite3_stmt *stmt); 15 | ~SqQuery(); 16 | 17 | public: // IQuery 18 | ISQLResult *GetResultSet(); 19 | 20 | bool FetchMoreResults() 21 | { 22 | return false; 23 | } 24 | 25 | bool Execute(); 26 | void Destroy(); 27 | 28 | public: // IPreparedQuery 29 | const char *GetError(); 30 | unsigned int GetAffectedRows(); 31 | unsigned int GetInsertId(); 32 | #if 0 33 | public: //IResultSet 34 | unsigned int GetRowCount(); 35 | unsigned int GetFieldCount(); 36 | const char *FieldNumToName(unsigned int columnId); 37 | bool FieldNameToNum(const char *name, unsigned int *columnId); 38 | bool MoreRows(); 39 | IResultRow *FetchRow(); 40 | IResultRow *CurrentRow(); 41 | bool Rewind(); 42 | DBType GetFieldType(unsigned int field); 43 | DBType GetFieldDataType(unsigned int field); 44 | public: //IResultRow 45 | DBResult GetString(unsigned int columnId, const char **pString, size_t *length); 46 | DBResult CopyString(unsigned int columnId, 47 | char *buffer, 48 | size_t maxlength, 49 | size_t *written); 50 | DBResult GetFloat(unsigned int columnId, float *pFloat); 51 | DBResult GetInt(unsigned int columnId, int *pInt); 52 | bool IsNull(unsigned int columnId); 53 | size_t GetDataSize(unsigned int columnId); 54 | DBResult GetBlob(unsigned int columnId, const void **pData, size_t *length); 55 | DBResult CopyBlob(unsigned int columnId, void *buffer, size_t maxlength, size_t *written); 56 | #endif 57 | 58 | public: 59 | sqlite3_stmt *GetStmt(); 60 | 61 | private: 62 | SqConnection *m_pCon; 63 | sqlite3_stmt *m_pStmt; 64 | SqResults *m_pResults; 65 | unsigned int m_ParamCount; 66 | std::string m_LastError; 67 | int m_LastErrorCode; 68 | unsigned int m_AffectedRows; 69 | unsigned int m_InsertID; 70 | unsigned int m_ColCount; 71 | }; 72 | -------------------------------------------------------------------------------- /src/sqlite/sqlite_result.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "sqlite_database.h" 4 | #include "public/sqlite_mm.h" 5 | #include "common/memtable.h" 6 | #include "common/database.h" 7 | #include "vendor/sqlite-source/sqlite3.h" 8 | class SqQuery; 9 | 10 | struct SqField 11 | { 12 | int type; 13 | 14 | union 15 | { 16 | long long idx; 17 | double d; 18 | } u; 19 | 20 | size_t size; 21 | }; 22 | 23 | class SqResults : public ISQLResult, ISQLRow 24 | { 25 | friend class SqQuery; 26 | 27 | public: 28 | SqResults(SqQuery *query); 29 | ~SqResults(); 30 | 31 | public: // IResultSet 32 | int GetRowCount(); 33 | int GetFieldCount(); 34 | const char *FieldNumToName(unsigned int columnId); 35 | bool FieldNameToNum(const char *name, unsigned int *columnId); 36 | bool MoreRows(); 37 | ISQLRow *FetchRow(); 38 | ISQLRow *CurrentRow(); 39 | bool Rewind(); 40 | 41 | public: // IResultRow 42 | int GetFieldType(unsigned int field) 43 | { 44 | return 0; 45 | } 46 | 47 | const char *GetString(unsigned int columnId, size_t *length = nullptr); 48 | size_t GetDataSize(unsigned int columnId); 49 | float GetFloat(unsigned int columnId); 50 | int GetInt(unsigned int columnId); 51 | bool IsNull(unsigned int columnId); 52 | int64_t GetInt64(unsigned int columnId); 53 | 54 | void ResetResultCount(); 55 | void PushResult(); 56 | 57 | private: 58 | SqField *GetField(unsigned int col); 59 | 60 | private: 61 | sqlite3_stmt *m_pStmt; /** DOES NOT CHANGE */ 62 | std::string *m_ColNames; /** DOES NOT CHANGE */ 63 | unsigned int m_ColCount; /** DOES NOT CHANGE */ 64 | BaseStringTable m_Strings; /** DOES NOT CHANGE */ 65 | BaseMemTable *m_pMemory; /** DOES NOT CHANGE */ 66 | int m_RowCount; 67 | int m_MaxRows; 68 | SqField *m_Rows; 69 | int m_CurRow; 70 | int m_NextRow; 71 | }; 72 | -------------------------------------------------------------------------------- /src/utils/module.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "dbg.h" 3 | #include "interface.h" 4 | #include "strtools.h" 5 | #include "plat.h" 6 | 7 | #include 8 | #include 9 | 10 | #ifdef _WIN32 11 | #include 12 | #endif 13 | 14 | enum SigError 15 | { 16 | SIG_OK, 17 | SIG_NOT_FOUND, 18 | SIG_FOUND_MULTIPLE, 19 | }; 20 | 21 | // equivalent to FindSignature, but allows for multiple signatures to be found and iterated over 22 | class SignatureIterator 23 | { 24 | public: 25 | SignatureIterator(void *pBase, size_t iSize, const byte *pSignature, size_t iSigLength) 26 | : m_pBase((byte *)pBase), m_iSize(iSize), m_pSignature(pSignature), m_iSigLength(iSigLength) 27 | { 28 | m_pCurrent = m_pBase; 29 | } 30 | 31 | void *FindNext(bool allowWildcard) 32 | { 33 | for (size_t i = 0; i < m_iSize; i++) 34 | { 35 | size_t Matches = 0; 36 | while (*(m_pCurrent + i + Matches) == m_pSignature[Matches] || (allowWildcard && m_pSignature[Matches] == '\x2A')) 37 | { 38 | Matches++; 39 | if (Matches == m_iSigLength) 40 | { 41 | m_pCurrent += i + 1; 42 | return m_pCurrent - 1; 43 | } 44 | } 45 | } 46 | 47 | return nullptr; 48 | } 49 | 50 | private: 51 | byte *m_pBase; 52 | size_t m_iSize; 53 | const byte *m_pSignature; 54 | size_t m_iSigLength; 55 | byte *m_pCurrent; 56 | }; 57 | 58 | class CModule 59 | { 60 | public: 61 | CModule(const char *path, const char *module) : m_pszModule(module), m_pszPath(path) 62 | { 63 | char szModule[MAX_PATH]; 64 | 65 | V_snprintf(szModule, MAX_PATH, "%s%s%s%s%s", Plat_GetGameDirectory(), path, MODULE_PREFIX, m_pszModule, MODULE_EXT); 66 | 67 | m_hModule = dlmount(szModule); 68 | 69 | if (!m_hModule) 70 | { 71 | Error("Could not find %s\n", szModule); 72 | } 73 | 74 | #ifdef _WIN32 75 | MODULEINFO m_hModuleInfo; 76 | GetModuleInformation(GetCurrentProcess(), m_hModule, &m_hModuleInfo, sizeof(m_hModuleInfo)); 77 | 78 | m_base = (void *)m_hModuleInfo.lpBaseOfDll; 79 | m_size = m_hModuleInfo.SizeOfImage; 80 | InitializeSections(); 81 | #else 82 | if (int e = GetModuleInformation(m_hModule, &m_base, &m_size, m_sections)) 83 | { 84 | Error("Failed to get module info for %s, error %d\n", szModule, e); 85 | } 86 | #endif 87 | } 88 | 89 | void *FindSignature(const byte *pData, size_t iSigLength, int &error) 90 | { 91 | unsigned char *pMemory; 92 | void *return_addr = nullptr; 93 | error = 0; 94 | 95 | pMemory = (byte *)m_base; 96 | 97 | for (size_t i = 0; i < m_size; i++) 98 | { 99 | size_t Matches = 0; 100 | while (*(pMemory + i + Matches) == pData[Matches] || pData[Matches] == '\x2A') 101 | { 102 | Matches++; 103 | if (Matches == iSigLength) 104 | { 105 | if (return_addr) 106 | { 107 | error = SIG_FOUND_MULTIPLE; 108 | return return_addr; 109 | } 110 | 111 | return_addr = (void *)(pMemory + i); 112 | break; 113 | } 114 | } 115 | } 116 | 117 | if (!return_addr) 118 | { 119 | error = SIG_NOT_FOUND; 120 | } 121 | 122 | return return_addr; 123 | } 124 | 125 | void *FindInterface(const char *name) 126 | { 127 | CreateInterfaceFn fn = (CreateInterfaceFn)dlsym(m_hModule, "CreateInterface"); 128 | 129 | if (!fn) 130 | { 131 | Error("Could not find CreateInterface in %s\n", m_pszModule); 132 | } 133 | 134 | void *pInterface = fn(name, nullptr); 135 | 136 | if (!pInterface) 137 | { 138 | Error("Could not find %s in %s\n", name, m_pszModule); 139 | } 140 | 141 | return pInterface; 142 | } 143 | 144 | Section *GetSection(const std::string_view name) 145 | { 146 | for (auto §ion : m_sections) 147 | { 148 | if (section.m_szName == name) 149 | { 150 | return §ion; 151 | } 152 | } 153 | 154 | return nullptr; 155 | } 156 | #ifdef _WIN32 157 | void InitializeSections(); 158 | #endif 159 | void *FindVirtualTable(const std::string &name); 160 | 161 | public: 162 | const char *m_pszModule; 163 | const char *m_pszPath; 164 | HINSTANCE m_hModule; 165 | void *m_base; 166 | size_t m_size; 167 | std::vector
m_sections; 168 | }; 169 | -------------------------------------------------------------------------------- /src/utils/plat.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include "metamod_oslink.h" 6 | 7 | struct Section 8 | { 9 | std::string m_szName; 10 | void *m_pBase; 11 | size_t m_iSize; 12 | }; 13 | 14 | #if defined(_WIN32) 15 | #define FASTCALL __fastcall 16 | #define THISCALL __thiscall 17 | #else 18 | #define THISCALL 19 | #define strtok_s strtok_r 20 | #endif 21 | 22 | struct Module 23 | { 24 | #ifndef _WIN32 25 | void *pHandle; 26 | #endif 27 | uint8_t *pBase; 28 | unsigned int nSize; 29 | }; 30 | 31 | #ifndef _WIN32 32 | int GetModuleInformation(HINSTANCE module, void **base, size_t *length, std::vector
&m_sections); 33 | #endif 34 | 35 | #ifdef _WIN32 36 | #define MODULE_PREFIX "" 37 | #define MODULE_EXT ".dll" 38 | #else 39 | #define MODULE_PREFIX "lib" 40 | #define MODULE_EXT ".so" 41 | #endif 42 | 43 | void Plat_WriteMemory(void *pPatchAddress, uint8_t *pPatch, int iPatchSize); 44 | -------------------------------------------------------------------------------- /src/utils/plat_win.cpp: -------------------------------------------------------------------------------- 1 | #include "plat.h" 2 | #include "module.h" 3 | 4 | #include "tier0/memdbgon.h" 5 | 6 | void Plat_WriteMemory(void *pPatchAddress, uint8_t *pPatch, int iPatchSize) 7 | { 8 | WriteProcessMemory(GetCurrentProcess(), pPatchAddress, (void *)pPatch, iPatchSize, nullptr); 9 | } 10 | 11 | void CModule::InitializeSections() 12 | { 13 | IMAGE_DOS_HEADER *pDosHeader = reinterpret_cast(m_hModule); 14 | IMAGE_NT_HEADERS *pNtHeader = reinterpret_cast(reinterpret_cast(m_hModule) + pDosHeader->e_lfanew); 15 | 16 | IMAGE_SECTION_HEADER *pSectionHeader = IMAGE_FIRST_SECTION(pNtHeader); 17 | 18 | for (int i = 0; i < pNtHeader->FileHeader.NumberOfSections; i++) 19 | { 20 | Section section; 21 | section.m_szName = (char *)pSectionHeader[i].Name; 22 | section.m_pBase = (void *)((uint8_t *)m_base + pSectionHeader[i].VirtualAddress); 23 | section.m_iSize = pSectionHeader[i].SizeOfRawData; 24 | 25 | m_sections.push_back(std::move(section)); 26 | } 27 | } 28 | 29 | void *CModule::FindVirtualTable(const std::string &name) 30 | { 31 | auto runTimeData = GetSection(".data"); 32 | auto readOnlyData = GetSection(".rdata"); 33 | 34 | if (!runTimeData || !readOnlyData) 35 | { 36 | Warning("Failed to find .data or .rdata section\n"); 37 | return nullptr; 38 | } 39 | 40 | std::string decoratedTableName = ".?AV" + name + "@@"; 41 | 42 | SignatureIterator sigIt(runTimeData->m_pBase, runTimeData->m_iSize, (const byte *)decoratedTableName.c_str(), decoratedTableName.size() + 1); 43 | void *typeDescriptor = sigIt.FindNext(false); 44 | 45 | if (!typeDescriptor) 46 | { 47 | Warning("Failed to find type descriptor for %s\n", name.c_str()); 48 | return nullptr; 49 | } 50 | 51 | typeDescriptor = (void *)((uintptr_t)typeDescriptor - 0x10); 52 | 53 | const uint32_t rttiTDRva = (uintptr_t)typeDescriptor - (uintptr_t)m_base; 54 | 55 | DevMsg("RTTI Type Descriptor RVA: 0x%p\n", rttiTDRva); 56 | 57 | SignatureIterator sigIt2(readOnlyData->m_pBase, readOnlyData->m_iSize, (const byte *)&rttiTDRva, sizeof(uint32_t)); 58 | 59 | while (void *completeObjectLocator = sigIt2.FindNext(false)) 60 | { 61 | auto completeObjectLocatorHeader = (uintptr_t)completeObjectLocator - 0xC; 62 | // check RTTI Complete Object Locator header, always 0x1 63 | if (*(int32_t *)(completeObjectLocatorHeader) != 1) 64 | { 65 | continue; 66 | } 67 | 68 | // check RTTI Complete Object Locator vtable offset 69 | if (*(int32_t *)((uintptr_t)completeObjectLocator - 0x8) != 0) 70 | { 71 | continue; 72 | } 73 | 74 | SignatureIterator sigIt3(readOnlyData->m_pBase, readOnlyData->m_iSize, (const byte *)&completeObjectLocatorHeader, sizeof(void *)); 75 | void *vtable = sigIt3.FindNext(false); 76 | 77 | if (!vtable) 78 | { 79 | Warning("Failed to find vtable for %s\n", name.c_str()); 80 | return nullptr; 81 | } 82 | 83 | return (void *)((uintptr_t)vtable + 0x8); 84 | } 85 | 86 | Warning("Failed to find RTTI Complete Object Locator for %s\n", name.c_str()); 87 | return nullptr; 88 | } 89 | -------------------------------------------------------------------------------- /vendor/mysql/include/big_endian.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License, version 2.0, for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 22 | 23 | #include 24 | 25 | /* 26 | Data in big-endian format. 27 | */ 28 | static inline void float4store(uchar *T, float A) 29 | { *(T)= ((uchar *) &A)[3]; 30 | *((T)+1)=(char) ((uchar *) &A)[2]; 31 | *((T)+2)=(char) ((uchar *) &A)[1]; 32 | *((T)+3)=(char) ((uchar *) &A)[0]; } 33 | 34 | static inline void float4get (float *V, const uchar *M) 35 | { float def_temp; 36 | ((uchar*) &def_temp)[0]=(M)[3]; 37 | ((uchar*) &def_temp)[1]=(M)[2]; 38 | ((uchar*) &def_temp)[2]=(M)[1]; 39 | ((uchar*) &def_temp)[3]=(M)[0]; 40 | (*V)=def_temp; } 41 | 42 | static inline void float8store(uchar *T, double V) 43 | { *(T)= ((uchar *) &V)[7]; 44 | *((T)+1)=(char) ((uchar *) &V)[6]; 45 | *((T)+2)=(char) ((uchar *) &V)[5]; 46 | *((T)+3)=(char) ((uchar *) &V)[4]; 47 | *((T)+4)=(char) ((uchar *) &V)[3]; 48 | *((T)+5)=(char) ((uchar *) &V)[2]; 49 | *((T)+6)=(char) ((uchar *) &V)[1]; 50 | *((T)+7)=(char) ((uchar *) &V)[0]; } 51 | 52 | static inline void float8get (double *V, const uchar *M) 53 | { double def_temp; 54 | ((uchar*) &def_temp)[0]=(M)[7]; 55 | ((uchar*) &def_temp)[1]=(M)[6]; 56 | ((uchar*) &def_temp)[2]=(M)[5]; 57 | ((uchar*) &def_temp)[3]=(M)[4]; 58 | ((uchar*) &def_temp)[4]=(M)[3]; 59 | ((uchar*) &def_temp)[5]=(M)[2]; 60 | ((uchar*) &def_temp)[6]=(M)[1]; 61 | ((uchar*) &def_temp)[7]=(M)[0]; 62 | (*V) = def_temp; } 63 | 64 | static inline void ushortget(uint16 *V, const uchar *pM) 65 | { *V = (uint16) (((uint16) ((uchar) (pM)[1]))+ 66 | ((uint16) ((uint16) (pM)[0]) << 8)); } 67 | static inline void shortget (int16 *V, const uchar *pM) 68 | { *V = (short) (((short) ((uchar) (pM)[1]))+ 69 | ((short) ((short) (pM)[0]) << 8)); } 70 | static inline void longget (int32 *V, const uchar *pM) 71 | { int32 def_temp; 72 | ((uchar*) &def_temp)[0]=(pM)[0]; 73 | ((uchar*) &def_temp)[1]=(pM)[1]; 74 | ((uchar*) &def_temp)[2]=(pM)[2]; 75 | ((uchar*) &def_temp)[3]=(pM)[3]; 76 | (*V)=def_temp; } 77 | static inline void ulongget (uint32 *V, const uchar *pM) 78 | { uint32 def_temp; 79 | ((uchar*) &def_temp)[0]=(pM)[0]; 80 | ((uchar*) &def_temp)[1]=(pM)[1]; 81 | ((uchar*) &def_temp)[2]=(pM)[2]; 82 | ((uchar*) &def_temp)[3]=(pM)[3]; 83 | (*V)=def_temp; } 84 | static inline void shortstore(uchar *T, int16 A) 85 | { uint def_temp=(uint) (A) ; 86 | *(((char*)T)+1)=(char)(def_temp); 87 | *(((char*)T)+0)=(char)(def_temp >> 8); } 88 | static inline void longstore (uchar *T, int32 A) 89 | { *(((char*)T)+3)=((A)); 90 | *(((char*)T)+2)=(((A) >> 8)); 91 | *(((char*)T)+1)=(((A) >> 16)); 92 | *(((char*)T)+0)=(((A) >> 24)); } 93 | 94 | static inline void floatget(float *V, const uchar *M) 95 | { 96 | memcpy(V, (M), sizeof(float)); 97 | } 98 | 99 | static inline void floatstore(uchar *T, float V) 100 | { 101 | memcpy((T), (&V), sizeof(float)); 102 | } 103 | 104 | static inline void doubleget(double *V, const uchar *M) 105 | { 106 | memcpy(V, (M), sizeof(double)); 107 | } 108 | 109 | static inline void doublestore(uchar *T, double V) 110 | { 111 | memcpy((T), &V, sizeof(double)); 112 | } 113 | 114 | static inline void longlongget(longlong *V, const uchar *M) 115 | { 116 | memcpy(V, (M), sizeof(ulonglong)); 117 | } 118 | static inline void longlongstore(uchar *T, longlong V) 119 | { 120 | memcpy((T), &V, sizeof(ulonglong)); 121 | } 122 | -------------------------------------------------------------------------------- /vendor/mysql/include/binary_log_types.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | Without limiting anything contained in the foregoing, this file, 15 | which is part of C Driver for MySQL (Connector/C), is also subject to the 16 | Universal FOSS Exception, version 1.0, a copy of which can be found at 17 | http://oss.oracle.com/licenses/universal-foss-exception. 18 | 19 | This program is distributed in the hope that it will be useful, 20 | but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | GNU General Public License, version 2.0, for more details. 23 | 24 | You should have received a copy of the GNU General Public License 25 | along with this program; if not, write to the Free Software 26 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 27 | 28 | /** 29 | @file binary_log_types.h 30 | 31 | @brief This file contains the field type. 32 | 33 | 34 | @note This file can be imported both from C and C++ code, so the 35 | definitions have to be constructed to support this. 36 | */ 37 | 38 | #ifndef BINARY_LOG_TYPES_INCLUDED 39 | #define BINARY_LOG_TYPES_INCLUDED 40 | 41 | #ifdef __cplusplus 42 | extern "C" 43 | { 44 | #endif 45 | 46 | /* 47 | * Constants exported from this package. 48 | */ 49 | 50 | typedef enum enum_field_types { 51 | MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY, 52 | MYSQL_TYPE_SHORT, MYSQL_TYPE_LONG, 53 | MYSQL_TYPE_FLOAT, MYSQL_TYPE_DOUBLE, 54 | MYSQL_TYPE_NULL, MYSQL_TYPE_TIMESTAMP, 55 | MYSQL_TYPE_LONGLONG,MYSQL_TYPE_INT24, 56 | MYSQL_TYPE_DATE, MYSQL_TYPE_TIME, 57 | MYSQL_TYPE_DATETIME, MYSQL_TYPE_YEAR, 58 | MYSQL_TYPE_NEWDATE, MYSQL_TYPE_VARCHAR, 59 | MYSQL_TYPE_BIT, 60 | MYSQL_TYPE_TIMESTAMP2, 61 | MYSQL_TYPE_DATETIME2, 62 | MYSQL_TYPE_TIME2, 63 | MYSQL_TYPE_JSON=245, 64 | MYSQL_TYPE_NEWDECIMAL=246, 65 | MYSQL_TYPE_ENUM=247, 66 | MYSQL_TYPE_SET=248, 67 | MYSQL_TYPE_TINY_BLOB=249, 68 | MYSQL_TYPE_MEDIUM_BLOB=250, 69 | MYSQL_TYPE_LONG_BLOB=251, 70 | MYSQL_TYPE_BLOB=252, 71 | MYSQL_TYPE_VAR_STRING=253, 72 | MYSQL_TYPE_STRING=254, 73 | MYSQL_TYPE_GEOMETRY=255 74 | } enum_field_types; 75 | 76 | #define DATETIME_MAX_DECIMALS 6 77 | 78 | #ifdef __cplusplus 79 | } 80 | #endif // __cplusplus 81 | 82 | #endif /* BINARY_LOG_TYPES_INCLUDED */ 83 | -------------------------------------------------------------------------------- /vendor/mysql/include/byte_order_generic.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2001, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License, version 2.0, for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 22 | 23 | /* 24 | Endianness-independent definitions for architectures other 25 | than the x86 architecture. 26 | */ 27 | static inline int16 sint2korr(const uchar *A) 28 | { 29 | return 30 | (int16) (((int16) (A[0])) + 31 | ((int16) (A[1]) << 8)) 32 | ; 33 | } 34 | 35 | static inline int32 sint4korr(const uchar *A) 36 | { 37 | return 38 | (int32) (((int32) (A[0])) + 39 | (((int32) (A[1]) << 8)) + 40 | (((int32) (A[2]) << 16)) + 41 | (((int32) (A[3]) << 24))) 42 | ; 43 | } 44 | 45 | static inline uint16 uint2korr(const uchar *A) 46 | { 47 | return 48 | (uint16) (((uint16) (A[0])) + 49 | ((uint16) (A[1]) << 8)) 50 | ; 51 | } 52 | 53 | static inline uint32 uint4korr(const uchar *A) 54 | { 55 | return 56 | (uint32) (((uint32) (A[0])) + 57 | (((uint32) (A[1])) << 8) + 58 | (((uint32) (A[2])) << 16) + 59 | (((uint32) (A[3])) << 24)) 60 | ; 61 | } 62 | 63 | static inline ulonglong uint8korr(const uchar *A) 64 | { 65 | return 66 | ((ulonglong)(((uint32) (A[0])) + 67 | (((uint32) (A[1])) << 8) + 68 | (((uint32) (A[2])) << 16) + 69 | (((uint32) (A[3])) << 24)) + 70 | (((ulonglong) (((uint32) (A[4])) + 71 | (((uint32) (A[5])) << 8) + 72 | (((uint32) (A[6])) << 16) + 73 | (((uint32) (A[7])) << 24))) << 74 | 32)) 75 | ; 76 | } 77 | 78 | static inline longlong sint8korr(const uchar *A) 79 | { 80 | return (longlong) uint8korr(A); 81 | } 82 | 83 | static inline void int2store(uchar *T, uint16 A) 84 | { 85 | uint def_temp= A ; 86 | *(T)= (uchar)(def_temp); 87 | *(T+1)= (uchar)(def_temp >> 8); 88 | } 89 | 90 | static inline void int4store(uchar *T, uint32 A) 91 | { 92 | *(T)= (uchar) (A); 93 | *(T+1)=(uchar) (A >> 8); 94 | *(T+2)=(uchar) (A >> 16); 95 | *(T+3)=(uchar) (A >> 24); 96 | } 97 | 98 | static inline void int8store(uchar *T, ulonglong A) 99 | { 100 | uint def_temp= (uint) A, 101 | def_temp2= (uint) (A >> 32); 102 | int4store(T, def_temp); 103 | int4store(T+4,def_temp2); 104 | } 105 | -------------------------------------------------------------------------------- /vendor/mysql/include/byte_order_generic_x86.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2001, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | Without limiting anything contained in the foregoing, this file, 15 | which is part of C Driver for MySQL (Connector/C), is also subject to the 16 | Universal FOSS Exception, version 1.0, a copy of which can be found at 17 | http://oss.oracle.com/licenses/universal-foss-exception. 18 | 19 | This program is distributed in the hope that it will be useful, 20 | but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | GNU General Public License, version 2.0, for more details. 23 | 24 | You should have received a copy of the GNU General Public License 25 | along with this program; if not, write to the Free Software 26 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 27 | 28 | /* 29 | Optimized functions for the x86 architecture (_WIN32 included). 30 | 31 | x86 handles misaligned reads and writes just fine, so suppress 32 | UBSAN warnings for these functions. 33 | */ 34 | static inline int16 sint2korr(const uchar *A) SUPPRESS_UBSAN; 35 | static inline int16 sint2korr(const uchar *A) { return *((int16*) A); } 36 | 37 | static inline int32 sint4korr(const uchar *A) SUPPRESS_UBSAN; 38 | static inline int32 sint4korr(const uchar *A) { return *((int32*) A); } 39 | 40 | static inline uint16 uint2korr(const uchar *A) SUPPRESS_UBSAN; 41 | static inline uint16 uint2korr(const uchar *A) { return *((uint16*) A); } 42 | 43 | static inline uint32 uint4korr(const uchar *A) SUPPRESS_UBSAN; 44 | static inline uint32 uint4korr(const uchar *A) { return *((uint32*) A); } 45 | 46 | static inline ulonglong uint8korr(const uchar *A) SUPPRESS_UBSAN; 47 | static inline ulonglong uint8korr(const uchar *A) { return *((ulonglong*) A);} 48 | 49 | static inline longlong sint8korr(const uchar *A) SUPPRESS_UBSAN; 50 | static inline longlong sint8korr(const uchar *A) { return *((longlong*) A); } 51 | 52 | static inline void int2store(uchar *T, uint16 A) SUPPRESS_UBSAN; 53 | static inline void int2store(uchar *T, uint16 A) 54 | { 55 | *((uint16*) T)= A; 56 | } 57 | 58 | static inline void int4store(uchar *T, uint32 A) SUPPRESS_UBSAN; 59 | static inline void int4store(uchar *T, uint32 A) 60 | { 61 | *((uint32*) T)= A; 62 | } 63 | 64 | static inline void int8store(uchar *T, ulonglong A) SUPPRESS_UBSAN; 65 | static inline void int8store(uchar *T, ulonglong A) 66 | { 67 | *((ulonglong*) T)= A; 68 | } 69 | -------------------------------------------------------------------------------- /vendor/mysql/include/little_endian.h: -------------------------------------------------------------------------------- 1 | #ifndef LITTLE_ENDIAN_INCLUDED 2 | #define LITTLE_ENDIAN_INCLUDED 3 | /* Copyright (c) 2012, 2023, Oracle and/or its affiliates. 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License, version 2.0, 7 | as published by the Free Software Foundation. 8 | 9 | This program is also distributed with certain software (including 10 | but not limited to OpenSSL) that is licensed under separate terms, 11 | as designated in a particular file or component or in included license 12 | documentation. The authors of MySQL hereby grant you an additional 13 | permission to link the program and your derivative works with the 14 | separately licensed software that they have included with MySQL. 15 | 16 | Without limiting anything contained in the foregoing, this file, 17 | which is part of C Driver for MySQL (Connector/C), is also subject to the 18 | Universal FOSS Exception, version 1.0, a copy of which can be found at 19 | http://oss.oracle.com/licenses/universal-foss-exception. 20 | 21 | This program is distributed in the hope that it will be useful, 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 | GNU General Public License, version 2.0, for more details. 25 | 26 | You should have received a copy of the GNU General Public License 27 | along with this program; if not, write to the Free Software 28 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 29 | 30 | /* 31 | Data in little-endian format. 32 | */ 33 | 34 | #include 35 | 36 | static inline void float4get (float *V, const uchar *M) 37 | { 38 | memcpy(V, (M), sizeof(float)); 39 | } 40 | 41 | static inline void float4store(uchar *V, float M) 42 | { 43 | memcpy(V, (&M), sizeof(float)); 44 | } 45 | 46 | static inline void float8get (double *V, const uchar *M) 47 | { 48 | memcpy(V, M, sizeof(double)); 49 | } 50 | 51 | static inline void float8store(uchar *V, double M) 52 | { 53 | memcpy(V, &M, sizeof(double)); 54 | } 55 | 56 | static inline void floatget (float *V, const uchar *M) { float4get(V, M); } 57 | static inline void floatstore (uchar *V, float M) { float4store(V, M); } 58 | 59 | /* Bi-endian hardware.... */ 60 | #if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN) 61 | static inline void doublestore(uchar *T, double V) 62 | { *(((char*)T)+0)=(char) ((uchar *) &V)[4]; 63 | *(((char*)T)+1)=(char) ((uchar *) &V)[5]; 64 | *(((char*)T)+2)=(char) ((uchar *) &V)[6]; 65 | *(((char*)T)+3)=(char) ((uchar *) &V)[7]; 66 | *(((char*)T)+4)=(char) ((uchar *) &V)[0]; 67 | *(((char*)T)+5)=(char) ((uchar *) &V)[1]; 68 | *(((char*)T)+6)=(char) ((uchar *) &V)[2]; 69 | *(((char*)T)+7)=(char) ((uchar *) &V)[3]; } 70 | static inline void doubleget(double *V, const uchar *M) 71 | { double def_temp; 72 | ((uchar*) &def_temp)[0]=(M)[4]; 73 | ((uchar*) &def_temp)[1]=(M)[5]; 74 | ((uchar*) &def_temp)[2]=(M)[6]; 75 | ((uchar*) &def_temp)[3]=(M)[7]; 76 | ((uchar*) &def_temp)[4]=(M)[0]; 77 | ((uchar*) &def_temp)[5]=(M)[1]; 78 | ((uchar*) &def_temp)[6]=(M)[2]; 79 | ((uchar*) &def_temp)[7]=(M)[3]; 80 | (*V) = def_temp; } 81 | 82 | #else /* Bi-endian hardware.... */ 83 | 84 | static inline void doublestore(uchar *T, double V) { memcpy(T, &V, sizeof(double)); } 85 | static inline void doubleget (double *V, const uchar *M) { memcpy(V, M, sizeof(double)); } 86 | 87 | #endif /* Bi-endian hardware.... */ 88 | 89 | static inline void ushortget(uint16 *V, const uchar *pM) { *V= uint2korr(pM); } 90 | static inline void shortget (int16 *V, const uchar *pM) { *V= sint2korr(pM); } 91 | static inline void longget (int32 *V, const uchar *pM) { *V= sint4korr(pM); } 92 | static inline void ulongget (uint32 *V, const uchar *pM) { *V= uint4korr(pM); } 93 | static inline void shortstore(uchar *T, int16 V) { int2store(T, V); } 94 | static inline void longstore (uchar *T, int32 V) { int4store(T, V); } 95 | 96 | static inline void longlongget(longlong *V, const uchar *M) 97 | { 98 | memcpy(V, (M), sizeof(ulonglong)); 99 | } 100 | static inline void longlongstore(uchar *T, longlong V) 101 | { 102 | memcpy((T), &V, sizeof(ulonglong)); 103 | } 104 | 105 | #endif /* LITTLE_ENDIAN_INCLUDED */ 106 | -------------------------------------------------------------------------------- /vendor/mysql/include/my_alloc.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2000, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | Without limiting anything contained in the foregoing, this file, 15 | which is part of C Driver for MySQL (Connector/C), is also subject to the 16 | Universal FOSS Exception, version 1.0, a copy of which can be found at 17 | http://oss.oracle.com/licenses/universal-foss-exception. 18 | 19 | This program is distributed in the hope that it will be useful, 20 | but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | GNU General Public License, version 2.0, for more details. 23 | 24 | You should have received a copy of the GNU General Public License 25 | along with this program; if not, write to the Free Software 26 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 27 | 28 | /* 29 | Data structures for mysys/my_alloc.c (root memory allocator) 30 | */ 31 | 32 | #ifndef _my_alloc_h 33 | #define _my_alloc_h 34 | 35 | #define ALLOC_MAX_BLOCK_TO_DROP 4096 36 | #define ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP 10 37 | 38 | /* PSI_memory_key */ 39 | #include "mysql/psi/psi_memory.h" 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | typedef struct st_used_mem 46 | { /* struct for once_alloc (block) */ 47 | struct st_used_mem *next; /* Next block in use */ 48 | unsigned int left; /* memory left in block */ 49 | unsigned int size; /* size of block */ 50 | } USED_MEM; 51 | 52 | 53 | typedef struct st_mem_root 54 | { 55 | USED_MEM *free; /* blocks with free memory in it */ 56 | USED_MEM *used; /* blocks almost without free memory */ 57 | USED_MEM *pre_alloc; /* preallocated block */ 58 | /* if block have less memory it will be put in 'used' list */ 59 | size_t min_malloc; 60 | size_t block_size; /* initial block size */ 61 | unsigned int block_num; /* allocated blocks counter */ 62 | /* 63 | first free block in queue test counter (if it exceed 64 | MAX_BLOCK_USAGE_BEFORE_DROP block will be dropped in 'used' list) 65 | */ 66 | unsigned int first_block_usage; 67 | 68 | /* 69 | Maximum amount of memory this mem_root can hold. A value of 0 70 | implies there is no limit. 71 | */ 72 | size_t max_capacity; 73 | 74 | /* Allocated size for this mem_root */ 75 | 76 | size_t allocated_size; 77 | 78 | /* Enable this for error reporting if capacity is exceeded */ 79 | my_bool error_for_capacity_exceeded; 80 | 81 | void (*error_handler)(void); 82 | 83 | PSI_memory_key m_psi_key; 84 | } MEM_ROOT; 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /vendor/mysql/include/my_command.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | Without limiting anything contained in the foregoing, this file, 15 | which is part of C Driver for MySQL (Connector/C), is also subject to the 16 | Universal FOSS Exception, version 1.0, a copy of which can be found at 17 | http://oss.oracle.com/licenses/universal-foss-exception. 18 | 19 | This program is distributed in the hope that it will be useful, 20 | but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | GNU General Public License, version 2.0, for more details. 23 | 24 | You should have received a copy of the GNU General Public License 25 | along with this program; if not, write to the Free Software 26 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 27 | 28 | #ifndef _mysql_command_h 29 | #define _mysql_command_h 30 | 31 | /** 32 | @enum enum_server_command 33 | @brief You should add new commands to the end of this list, otherwise old 34 | servers won't be able to handle them as 'unsupported'. 35 | */ 36 | enum enum_server_command 37 | { 38 | COM_SLEEP, 39 | COM_QUIT, 40 | COM_INIT_DB, 41 | COM_QUERY, 42 | COM_FIELD_LIST, 43 | COM_CREATE_DB, 44 | COM_DROP_DB, 45 | COM_REFRESH, 46 | COM_SHUTDOWN, 47 | COM_STATISTICS, 48 | COM_PROCESS_INFO, 49 | COM_CONNECT, 50 | COM_PROCESS_KILL, 51 | COM_DEBUG, 52 | COM_PING, 53 | COM_TIME, 54 | COM_DELAYED_INSERT, 55 | COM_CHANGE_USER, 56 | COM_BINLOG_DUMP, 57 | COM_TABLE_DUMP, 58 | COM_CONNECT_OUT, 59 | COM_REGISTER_SLAVE, 60 | COM_STMT_PREPARE, 61 | COM_STMT_EXECUTE, 62 | COM_STMT_SEND_LONG_DATA, 63 | COM_STMT_CLOSE, 64 | COM_STMT_RESET, 65 | COM_SET_OPTION, 66 | COM_STMT_FETCH, 67 | COM_DAEMON, 68 | COM_BINLOG_DUMP_GTID, 69 | COM_RESET_CONNECTION, 70 | /* don't forget to update const char *command_name[] in sql_parse.cc */ 71 | 72 | /* Must be last */ 73 | COM_END 74 | }; 75 | 76 | #endif /* _mysql_command_h */ 77 | -------------------------------------------------------------------------------- /vendor/mysql/include/my_dir.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2000, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License, version 2.0, for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 22 | 23 | #ifndef MY_DIR_H 24 | #define MY_DIR_H 25 | 26 | #include "my_global.h" 27 | 28 | #include 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | /* Defines for my_dir and my_stat */ 35 | 36 | #ifdef _WIN32 37 | #define S_IROTH _S_IREAD 38 | #define S_IFIFO _S_IFIFO 39 | #endif 40 | 41 | #define MY_S_IFMT S_IFMT /* type of file */ 42 | #define MY_S_IFDIR S_IFDIR /* directory */ 43 | #define MY_S_IFCHR S_IFCHR /* character special */ 44 | #define MY_S_IFBLK S_IFBLK /* block special */ 45 | #define MY_S_IFREG S_IFREG /* regular */ 46 | #define MY_S_IFIFO S_IFIFO /* fifo */ 47 | #define MY_S_ISUID S_ISUID /* set user id on execution */ 48 | #define MY_S_ISGID S_ISGID /* set group id on execution */ 49 | #define MY_S_ISVTX S_ISVTX /* save swapped text even after use */ 50 | #define MY_S_IREAD S_IREAD /* read permission, owner */ 51 | #define MY_S_IWRITE S_IWRITE /* write permission, owner */ 52 | #define MY_S_IEXEC S_IEXEC /* execute/search permission, owner */ 53 | 54 | #define MY_S_ISDIR(m) (((m) & MY_S_IFMT) == MY_S_IFDIR) 55 | #define MY_S_ISCHR(m) (((m) & MY_S_IFMT) == MY_S_IFCHR) 56 | #define MY_S_ISBLK(m) (((m) & MY_S_IFMT) == MY_S_IFBLK) 57 | #define MY_S_ISREG(m) (((m) & MY_S_IFMT) == MY_S_IFREG) 58 | #define MY_S_ISFIFO(m) (((m) & MY_S_IFMT) == MY_S_IFIFO) 59 | 60 | #define MY_DONT_SORT 512 /* my_lib; Don't sort files */ 61 | #define MY_WANT_STAT 1024 /* my_lib; stat files */ 62 | 63 | /* typedefs for my_dir & my_stat */ 64 | 65 | #if(_MSC_VER) 66 | #define MY_STAT struct _stati64 /* 64 bit file size */ 67 | #else 68 | #define MY_STAT struct stat /* Orginal struct have what we need */ 69 | #endif 70 | 71 | /* Struct describing one file returned from my_dir */ 72 | typedef struct fileinfo 73 | { 74 | char *name; 75 | MY_STAT *mystat; 76 | } FILEINFO; 77 | 78 | typedef struct st_my_dir /* Struct returned from my_dir */ 79 | { 80 | /* 81 | These members are just copies of parts of DYNAMIC_ARRAY structure, 82 | which is allocated right after the end of MY_DIR structure (MEM_ROOT 83 | for storing names is also resides there). We've left them here because 84 | we don't want to change code that uses my_dir. 85 | */ 86 | struct fileinfo *dir_entry; 87 | uint number_off_files; 88 | } MY_DIR; 89 | 90 | extern MY_DIR *my_dir(const char *path,myf MyFlags); 91 | extern void my_dirend(MY_DIR *buffer); 92 | extern MY_STAT *my_stat(const char *path, MY_STAT *stat_area, myf my_flags); 93 | extern int my_fstat(int filenr, MY_STAT *stat_area, myf MyFlags); 94 | 95 | #ifdef __cplusplus 96 | } 97 | #endif 98 | 99 | #endif /* MY_DIR_H */ 100 | 101 | -------------------------------------------------------------------------------- /vendor/mysql/include/my_list.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2000, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | Without limiting anything contained in the foregoing, this file, 15 | which is part of C Driver for MySQL (Connector/C), is also subject to the 16 | Universal FOSS Exception, version 1.0, a copy of which can be found at 17 | http://oss.oracle.com/licenses/universal-foss-exception. 18 | 19 | This program is distributed in the hope that it will be useful, 20 | but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | GNU General Public License, version 2.0, for more details. 23 | 24 | You should have received a copy of the GNU General Public License 25 | along with this program; if not, write to the Free Software 26 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 27 | 28 | #ifndef _list_h_ 29 | #define _list_h_ 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | typedef struct st_list { 36 | struct st_list *prev,*next; 37 | void *data; 38 | } LIST; 39 | 40 | typedef int (*list_walk_action)(void *,void *); 41 | 42 | extern LIST *list_add(LIST *root,LIST *element); 43 | extern LIST *list_delete(LIST *root,LIST *element); 44 | extern LIST *list_cons(void *data,LIST *root); 45 | extern LIST *list_reverse(LIST *root); 46 | extern void list_free(LIST *root,unsigned int free_data); 47 | extern unsigned int list_length(LIST *); 48 | extern int list_walk(LIST *,list_walk_action action,unsigned char * argument); 49 | 50 | #define list_rest(a) ((a)->next) 51 | #define list_push(a,b) (a)=list_cons((b),(a)) 52 | #define list_pop(A) {LIST *old=(A); (A)=list_delete(old,old); my_free(old); } 53 | 54 | #ifdef __cplusplus 55 | } 56 | #endif 57 | #endif 58 | -------------------------------------------------------------------------------- /vendor/mysql/include/my_thread_local.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2000, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License, version 2.0, for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ 22 | 23 | #ifndef MY_THREAD_LOCAL_INCLUDED 24 | #define MY_THREAD_LOCAL_INCLUDED 25 | 26 | #ifndef _WIN32 27 | #include 28 | #endif 29 | 30 | struct _db_code_state_; 31 | typedef uint32 my_thread_id; 32 | 33 | C_MODE_START 34 | 35 | #ifdef _WIN32 36 | typedef DWORD thread_local_key_t; 37 | #else 38 | typedef pthread_key_t thread_local_key_t; 39 | #endif 40 | 41 | static inline int my_create_thread_local_key(thread_local_key_t *key, 42 | void (*destructor)(void *)) 43 | { 44 | #ifdef _WIN32 45 | *key= TlsAlloc(); 46 | return (*key == TLS_OUT_OF_INDEXES); 47 | #else 48 | return pthread_key_create(key, destructor); 49 | #endif 50 | } 51 | 52 | static inline int my_delete_thread_local_key(thread_local_key_t key) 53 | { 54 | #ifdef _WIN32 55 | return !TlsFree(key); 56 | #else 57 | return pthread_key_delete(key); 58 | #endif 59 | } 60 | 61 | static inline void* my_get_thread_local(thread_local_key_t key) 62 | { 63 | #ifdef _WIN32 64 | return TlsGetValue(key); 65 | #else 66 | return pthread_getspecific(key); 67 | #endif 68 | } 69 | 70 | static inline int my_set_thread_local(thread_local_key_t key, 71 | void *value) 72 | { 73 | #ifdef _WIN32 74 | return !TlsSetValue(key, value); 75 | #else 76 | return pthread_setspecific(key, value); 77 | #endif 78 | } 79 | 80 | /** 81 | Retrieve the MySQL thread-local storage variant of errno. 82 | */ 83 | int my_errno(); 84 | 85 | /** 86 | Set the MySQL thread-local storage variant of errno. 87 | */ 88 | void set_my_errno(int my_errno); 89 | 90 | #ifdef _WIN32 91 | /* 92 | thr_winerr is used for returning the original OS error-code in Windows, 93 | my_osmaperr() returns EINVAL for all unknown Windows errors, hence we 94 | preserve the original Windows Error code in thr_winerr. 95 | */ 96 | int thr_winerr(); 97 | 98 | void set_thr_winerr(int winerr); 99 | 100 | #endif 101 | 102 | #ifndef NDEBUG 103 | /* Return pointer to DBUG for holding current state */ 104 | struct _db_code_state_ **my_thread_var_dbug(); 105 | 106 | my_thread_id my_thread_var_id(); 107 | 108 | void set_my_thread_var_id(my_thread_id id); 109 | 110 | #endif 111 | 112 | C_MODE_END 113 | 114 | #endif // MY_THREAD_LOCAL_INCLUDED 115 | -------------------------------------------------------------------------------- /vendor/mysql/include/my_xml.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2000, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License, version 2.0, for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ 22 | 23 | 24 | #ifndef _my_xml_h 25 | #define _my_xml_h 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | 32 | #define MY_XML_OK 0 33 | #define MY_XML_ERROR 1 34 | 35 | /* 36 | A flag whether to use absolute tag names in call-back functions, 37 | like "a", "a.b" and "a.b.c" (used in character set file parser), 38 | or relative names like "a", "b" and "c". 39 | */ 40 | #define MY_XML_FLAG_RELATIVE_NAMES 1 41 | 42 | /* 43 | A flag whether to skip normilization of text values before calling 44 | call-back functions: i.e. skip leading/trailing spaces, 45 | \r, \n, \t characters. 46 | */ 47 | #define MY_XML_FLAG_SKIP_TEXT_NORMALIZATION 2 48 | 49 | enum my_xml_node_type 50 | { 51 | MY_XML_NODE_TAG, /* can have TAG, ATTR and TEXT children */ 52 | MY_XML_NODE_ATTR, /* can have TEXT children */ 53 | MY_XML_NODE_TEXT /* cannot have children */ 54 | }; 55 | 56 | typedef struct xml_stack_st 57 | { 58 | int flags; 59 | enum my_xml_node_type current_node_type; 60 | char errstr[128]; 61 | 62 | struct { 63 | char static_buffer[128]; 64 | char *buffer; 65 | size_t buffer_size; 66 | char *start; 67 | char *end; 68 | } attr; 69 | 70 | const char *beg; 71 | const char *cur; 72 | const char *end; 73 | void *user_data; 74 | int (*enter)(struct xml_stack_st *st,const char *val, size_t len); 75 | int (*value)(struct xml_stack_st *st,const char *val, size_t len); 76 | int (*leave_xml)(struct xml_stack_st *st,const char *val, size_t len); 77 | } MY_XML_PARSER; 78 | 79 | void my_xml_parser_create(MY_XML_PARSER *st); 80 | void my_xml_parser_free(MY_XML_PARSER *st); 81 | int my_xml_parse(MY_XML_PARSER *st,const char *str, size_t len); 82 | 83 | void my_xml_set_value_handler(MY_XML_PARSER *st, int (*)(MY_XML_PARSER *, 84 | const char *, 85 | size_t len)); 86 | void my_xml_set_enter_handler(MY_XML_PARSER *st, int (*)(MY_XML_PARSER *, 87 | const char *, 88 | size_t len)); 89 | void my_xml_set_leave_handler(MY_XML_PARSER *st, int (*)(MY_XML_PARSER *, 90 | const char *, 91 | size_t len)); 92 | void my_xml_set_user_data(MY_XML_PARSER *st, void *); 93 | 94 | size_t my_xml_error_pos(MY_XML_PARSER *st); 95 | uint my_xml_error_lineno(MY_XML_PARSER *st); 96 | 97 | const char *my_xml_error_string(MY_XML_PARSER *st); 98 | 99 | #ifdef __cplusplus 100 | } 101 | #endif 102 | 103 | #endif /* _my_xml_h */ 104 | -------------------------------------------------------------------------------- /vendor/mysql/include/mysql/client_authentication.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License, version 2.0, for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 22 | #ifndef CLIENT_AUTHENTICATION_H 23 | #define CLIENT_AUTHENTICATION_H 24 | #include 25 | #include "mysql.h" 26 | #include "mysql/client_plugin.h" 27 | 28 | C_MODE_START 29 | int sha256_password_auth_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql); 30 | int sha256_password_init(char *, size_t, int, va_list); 31 | int sha256_password_deinit(void); 32 | int caching_sha2_password_auth_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql); 33 | int caching_sha2_password_init(char *, size_t, int, va_list); 34 | int caching_sha2_password_deinit(void); 35 | C_MODE_END 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /vendor/mysql/include/mysql/client_plugin.h.pp: -------------------------------------------------------------------------------- 1 | struct st_mysql_client_plugin 2 | { 3 | int type; unsigned int interface_version; const char *name; const char *author; const char *desc; unsigned int version[3]; const char *license; void *mysql_api; int (*init)(char *, size_t, int, va_list); int (*deinit)(void); int (*options)(const char *option, const void *); 4 | }; 5 | struct st_mysql; 6 | #include "plugin_auth_common.h" 7 | typedef struct st_plugin_vio_info 8 | { 9 | enum { MYSQL_VIO_INVALID, MYSQL_VIO_TCP, MYSQL_VIO_SOCKET, 10 | MYSQL_VIO_PIPE, MYSQL_VIO_MEMORY } protocol; 11 | int socket; 12 | } MYSQL_PLUGIN_VIO_INFO; 13 | typedef struct st_plugin_vio 14 | { 15 | int (*read_packet)(struct st_plugin_vio *vio, 16 | unsigned char **buf); 17 | int (*write_packet)(struct st_plugin_vio *vio, 18 | const unsigned char *packet, 19 | int packet_len); 20 | void (*info)(struct st_plugin_vio *vio, struct st_plugin_vio_info *info); 21 | } MYSQL_PLUGIN_VIO; 22 | struct st_mysql_client_plugin_AUTHENTICATION 23 | { 24 | int type; unsigned int interface_version; const char *name; const char *author; const char *desc; unsigned int version[3]; const char *license; void *mysql_api; int (*init)(char *, size_t, int, va_list); int (*deinit)(void); int (*options)(const char *option, const void *); 25 | int (*authenticate_user)(MYSQL_PLUGIN_VIO *vio, struct st_mysql *mysql); 26 | }; 27 | struct st_mysql_client_plugin * 28 | mysql_load_plugin(struct st_mysql *mysql, const char *name, int type, 29 | int argc, ...); 30 | struct st_mysql_client_plugin * 31 | mysql_load_plugin_v(struct st_mysql *mysql, const char *name, int type, 32 | int argc, va_list args); 33 | struct st_mysql_client_plugin * 34 | mysql_client_find_plugin(struct st_mysql *mysql, const char *name, int type); 35 | struct st_mysql_client_plugin * 36 | mysql_client_register_plugin(struct st_mysql *mysql, 37 | struct st_mysql_client_plugin *plugin); 38 | int mysql_plugin_options(struct st_mysql_client_plugin *plugin, 39 | const char *option, const void *value); 40 | -------------------------------------------------------------------------------- /vendor/mysql/include/mysql/com_data.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License, version 2.0, for more details. 18 | 19 | You should have received a copy of the GNU General Public License along 20 | with this program; if not, write to the Free Software Foundation, Inc., 51 21 | Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 22 | #ifndef PLUGIN_PROTOCOL_INCLUDED 23 | #define PLUGIN_PROTOCOL_INCLUDED 24 | 25 | #ifndef MYSQL_ABI_CHECK 26 | #include "my_global.h" /* Needed for my_bool in mysql_com.h */ 27 | #include "mysql_com.h" /* mysql_enum_shutdown_level */ 28 | #endif 29 | 30 | 31 | /** 32 | @file 33 | Definition of COM_DATA to be used with the Command service as data input 34 | structure. 35 | */ 36 | 37 | 38 | typedef struct st_com_init_db_data 39 | { 40 | const char *db_name; 41 | unsigned long length; 42 | } COM_INIT_DB_DATA; 43 | 44 | typedef struct st_com_refresh_data 45 | { 46 | unsigned char options; 47 | } COM_REFRESH_DATA; 48 | 49 | typedef struct st_com_shutdown_data 50 | { 51 | enum mysql_enum_shutdown_level level; 52 | } COM_SHUTDOWN_DATA; 53 | 54 | typedef struct st_com_kill_data 55 | { 56 | unsigned long id; 57 | } COM_KILL_DATA; 58 | 59 | typedef struct st_com_set_option_data 60 | { 61 | unsigned int opt_command; 62 | } COM_SET_OPTION_DATA; 63 | 64 | typedef struct st_com_stmt_execute_data 65 | { 66 | unsigned long stmt_id; 67 | unsigned long flags; 68 | unsigned char *params; 69 | unsigned long params_length; 70 | } COM_STMT_EXECUTE_DATA; 71 | 72 | typedef struct st_com_stmt_fetch_data 73 | { 74 | unsigned long stmt_id; 75 | unsigned long num_rows; 76 | } COM_STMT_FETCH_DATA; 77 | 78 | typedef struct st_com_stmt_send_long_data_data 79 | { 80 | unsigned long stmt_id; 81 | unsigned int param_number; 82 | unsigned char *longdata; 83 | unsigned long length; 84 | } COM_STMT_SEND_LONG_DATA_DATA; 85 | 86 | typedef struct st_com_stmt_prepare_data 87 | { 88 | const char *query; 89 | unsigned int length; 90 | } COM_STMT_PREPARE_DATA; 91 | 92 | typedef struct st_stmt_close_data 93 | { 94 | unsigned int stmt_id; 95 | } COM_STMT_CLOSE_DATA; 96 | 97 | typedef struct st_com_stmt_reset_data 98 | { 99 | unsigned int stmt_id; 100 | } COM_STMT_RESET_DATA; 101 | 102 | typedef struct st_com_query_data 103 | { 104 | const char *query; 105 | unsigned int length; 106 | } COM_QUERY_DATA; 107 | 108 | typedef struct st_com_field_list_data 109 | { 110 | unsigned char *table_name; 111 | unsigned int table_name_length; 112 | const unsigned char *query; 113 | unsigned int query_length; 114 | } COM_FIELD_LIST_DATA; 115 | 116 | union COM_DATA { 117 | COM_INIT_DB_DATA com_init_db; 118 | COM_REFRESH_DATA com_refresh; 119 | COM_SHUTDOWN_DATA com_shutdown; 120 | COM_KILL_DATA com_kill; 121 | COM_SET_OPTION_DATA com_set_option; 122 | COM_STMT_EXECUTE_DATA com_stmt_execute; 123 | COM_STMT_FETCH_DATA com_stmt_fetch; 124 | COM_STMT_SEND_LONG_DATA_DATA com_stmt_send_long_data; 125 | COM_STMT_PREPARE_DATA com_stmt_prepare; 126 | COM_STMT_CLOSE_DATA com_stmt_close; 127 | COM_STMT_RESET_DATA com_stmt_reset; 128 | COM_QUERY_DATA com_query; 129 | COM_FIELD_LIST_DATA com_field_list; 130 | }; 131 | 132 | #endif /* PLUGIN_PROTOCOL_INCLUDED */ 133 | -------------------------------------------------------------------------------- /vendor/mysql/include/mysql/get_password.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2000, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License, version 2.0, for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 22 | 23 | /* 24 | ** Ask for a password from tty 25 | ** This is an own file to avoid conflicts with curses 26 | */ 27 | 28 | #ifndef MYSQL_GET_PASSWORD_H_INCLUDED 29 | #define MYSQL_GET_PASSWORD_H_INCLUDED 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | typedef char *(* strdup_handler_t)(const char *, int); 36 | char *get_tty_password_ext(const char *opt_message, 37 | strdup_handler_t strdup_function); 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | #endif /* ! MYSQL_GET_PASSWORD_H_INCLUDED */ 44 | -------------------------------------------------------------------------------- /vendor/mysql/include/mysql/innodb_priv.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2010, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License, version 2.0, for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ 22 | 23 | #ifndef INNODB_PRIV_INCLUDED 24 | #define INNODB_PRIV_INCLUDED 25 | 26 | /** @file Declaring server-internal functions that are used by InnoDB. */ 27 | 28 | class THD; 29 | 30 | int get_quote_char_for_identifier(THD *thd, const char *name, size_t length); 31 | bool schema_table_store_record(THD *thd, TABLE *table); 32 | void localtime_to_TIME(MYSQL_TIME *to, struct tm *from); 33 | bool check_global_access(THD *thd, ulong want_access); 34 | size_t strconvert(CHARSET_INFO *from_cs, const char *from, 35 | CHARSET_INFO *to_cs, char *to, size_t to_length, 36 | uint *errors); 37 | void sql_print_error(const char *format, ...); 38 | 39 | /** 40 | Store record to I_S table, convert HEAP table to InnoDB table if necessary. 41 | 42 | @param[in] thd thread handler 43 | @param[in] table Information schema table to be updated 44 | @param[in] make_ondisk if true, convert heap table to on disk table. 45 | default value is true. 46 | @return 0 on success 47 | @return error code on failure. 48 | */ 49 | int schema_table_store_record2(THD *thd, TABLE *table, bool make_ondisk); 50 | 51 | /** 52 | Convert HEAP table to InnoDB table if necessary 53 | 54 | @param[in] thd thread handler 55 | @param[in] table Information schema table to be converted. 56 | @param[in] error the error code returned previously. 57 | @return false on success, true on error. 58 | */ 59 | bool convert_heap_table_to_ondisk(THD *thd, TABLE *table, int error); 60 | 61 | 62 | #endif /* INNODB_PRIV_INCLUDED */ 63 | -------------------------------------------------------------------------------- /vendor/mysql/include/mysql/mysql_lex_string.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License, version 2.0, for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 22 | 23 | #ifndef MYSQL_LEX_STRING_INCLUDED 24 | #define MYSQL_LEX_STRING_INCLUDED 25 | 26 | struct st_mysql_lex_string 27 | { 28 | char *str; 29 | size_t length; 30 | }; 31 | typedef struct st_mysql_lex_string MYSQL_LEX_STRING; 32 | 33 | struct st_mysql_const_lex_string 34 | { 35 | const char *str; 36 | size_t length; 37 | }; 38 | typedef struct st_mysql_const_lex_string MYSQL_LEX_CSTRING; 39 | 40 | #endif // MYSQL_LEX_STRING_INCLUDED 41 | -------------------------------------------------------------------------------- /vendor/mysql/include/mysql/plugin_validate_password.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License, version 2.0, for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 22 | 23 | #ifndef MYSQL_PLUGIN_VALIDATE_PASSWORD_INCLUDED 24 | #define MYSQL_PLUGIN_VALIDATE_PASSWORD_INCLUDED 25 | 26 | /* API for validate_password plugin. (MYSQL_VALIDATE_PASSWORD_PLUGIN) */ 27 | 28 | #include 29 | #define MYSQL_VALIDATE_PASSWORD_INTERFACE_VERSION 0x0100 30 | 31 | /* 32 | The descriptor structure for the plugin, that is referred from 33 | st_mysql_plugin. 34 | */ 35 | 36 | typedef void* mysql_string_handle; 37 | 38 | struct st_mysql_validate_password 39 | { 40 | int interface_version; 41 | /* 42 | This function retuns TRUE for passwords which satisfy the password 43 | policy (as choosen by plugin variable) and FALSE for all other 44 | password 45 | */ 46 | int (*validate_password)(mysql_string_handle password); 47 | /* 48 | This function returns the password strength (0-100) depending 49 | upon the policies 50 | */ 51 | int (*get_password_strength)(mysql_string_handle password); 52 | }; 53 | #endif 54 | -------------------------------------------------------------------------------- /vendor/mysql/include/mysql/psi/mysql_idle.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License, version 2.0, for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software Foundation, 21 | 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ 22 | 23 | #ifndef MYSQL_IDLE_H 24 | #define MYSQL_IDLE_H 25 | 26 | /** 27 | @file mysql/psi/mysql_idle.h 28 | Instrumentation helpers for idle waits. 29 | */ 30 | 31 | #include "mysql/psi/psi.h" 32 | 33 | #ifndef PSI_IDLE_CALL 34 | #define PSI_IDLE_CALL(M) PSI_DYNAMIC_CALL(M) 35 | #endif 36 | 37 | /** 38 | @defgroup Idle_instrumentation Idle Instrumentation 39 | @ingroup Instrumentation_interface 40 | @{ 41 | */ 42 | 43 | /** 44 | @def MYSQL_START_IDLE_WAIT 45 | Instrumentation helper for table io_waits. 46 | This instrumentation marks the start of a wait event. 47 | @param LOCKER the locker 48 | @param STATE the locker state 49 | @sa MYSQL_END_IDLE_WAIT. 50 | */ 51 | #ifdef HAVE_PSI_IDLE_INTERFACE 52 | #define MYSQL_START_IDLE_WAIT(LOCKER, STATE) \ 53 | LOCKER= inline_mysql_start_idle_wait(STATE, __FILE__, __LINE__) 54 | #else 55 | #define MYSQL_START_IDLE_WAIT(LOCKER, STATE) \ 56 | do {} while (0) 57 | #endif 58 | 59 | /** 60 | @def MYSQL_END_IDLE_WAIT 61 | Instrumentation helper for idle waits. 62 | This instrumentation marks the end of a wait event. 63 | @param LOCKER the locker 64 | @sa MYSQL_START_IDLE_WAIT. 65 | */ 66 | #ifdef HAVE_PSI_IDLE_INTERFACE 67 | #define MYSQL_END_IDLE_WAIT(LOCKER) \ 68 | inline_mysql_end_idle_wait(LOCKER) 69 | #else 70 | #define MYSQL_END_IDLE_WAIT(LOCKER) \ 71 | do {} while (0) 72 | #endif 73 | 74 | #ifdef HAVE_PSI_IDLE_INTERFACE 75 | /** 76 | Instrumentation calls for MYSQL_START_IDLE_WAIT. 77 | @sa MYSQL_END_IDLE_WAIT. 78 | */ 79 | static inline struct PSI_idle_locker * 80 | inline_mysql_start_idle_wait(PSI_idle_locker_state *state, 81 | const char *src_file, int src_line) 82 | { 83 | struct PSI_idle_locker *locker; 84 | locker= PSI_IDLE_CALL(start_idle_wait)(state, src_file, src_line); 85 | return locker; 86 | } 87 | 88 | /** 89 | Instrumentation calls for MYSQL_END_IDLE_WAIT. 90 | @sa MYSQL_START_IDLE_WAIT. 91 | */ 92 | static inline void 93 | inline_mysql_end_idle_wait(struct PSI_idle_locker *locker) 94 | { 95 | if (likely(locker != NULL)) 96 | PSI_IDLE_CALL(end_idle_wait)(locker); 97 | } 98 | #endif 99 | 100 | /** @} (end of group Idle_instrumentation) */ 101 | 102 | #endif 103 | 104 | -------------------------------------------------------------------------------- /vendor/mysql/include/mysql/psi/mysql_mdl.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License, version 2.0, for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software Foundation, 21 | 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ 22 | 23 | #ifndef MYSQL_MDL_H 24 | #define MYSQL_MDL_H 25 | 26 | /** 27 | @file mysql/psi/mysql_mdl.h 28 | Instrumentation helpers for metadata locks. 29 | */ 30 | 31 | #include "mysql/psi/psi.h" 32 | 33 | #ifndef PSI_METADATA_CALL 34 | #define PSI_METADATA_CALL(M) PSI_DYNAMIC_CALL(M) 35 | #endif 36 | 37 | /** 38 | @defgroup Thread_instrumentation Metadata Instrumentation 39 | @ingroup Instrumentation_interface 40 | @{ 41 | */ 42 | 43 | /** 44 | @def mysql_mdl_create(K, M, A) 45 | Instrumented metadata lock creation. 46 | @param I Metadata lock identity 47 | @param K Metadata key 48 | @param T Metadata lock type 49 | @param D Metadata lock duration 50 | @param S Metadata lock status 51 | @param F request source file 52 | @param L request source line 53 | */ 54 | 55 | #ifdef HAVE_PSI_METADATA_INTERFACE 56 | #define mysql_mdl_create(I, K, T, D, S, F, L) \ 57 | inline_mysql_mdl_create(I, K, T, D, S, F, L) 58 | #else 59 | #define mysql_mdl_create(I, K, T, D, S, F, L) NULL 60 | #endif 61 | 62 | #ifdef HAVE_PSI_METADATA_INTERFACE 63 | #define mysql_mdl_set_status(L, S) \ 64 | inline_mysql_mdl_set_status(L, S) 65 | #else 66 | #define mysql_mdl_set_status(L, S) \ 67 | do {} while (0) 68 | #endif 69 | 70 | 71 | /** 72 | @def mysql_mdl_destroy(M) 73 | Instrumented metadata lock destruction. 74 | @param M Metadata lock 75 | */ 76 | #ifdef HAVE_PSI_METADATA_INTERFACE 77 | #define mysql_mdl_destroy(M) \ 78 | inline_mysql_mdl_destroy(M, __FILE__, __LINE__) 79 | #else 80 | #define mysql_mdl_destroy(M) \ 81 | do {} while (0) 82 | #endif 83 | 84 | #ifdef HAVE_PSI_METADATA_INTERFACE 85 | 86 | static inline PSI_metadata_lock * 87 | inline_mysql_mdl_create(void *identity, 88 | const MDL_key *mdl_key, 89 | enum_mdl_type mdl_type, 90 | enum_mdl_duration mdl_duration, 91 | MDL_ticket::enum_psi_status mdl_status, 92 | const char *src_file, uint src_line) 93 | { 94 | PSI_metadata_lock *result; 95 | 96 | /* static_cast: Fit a round C++ enum peg into a square C int hole ... */ 97 | result= PSI_METADATA_CALL(create_metadata_lock) 98 | (identity, 99 | mdl_key, 100 | static_cast (mdl_type), 101 | static_cast (mdl_duration), 102 | static_cast (mdl_status), 103 | src_file, src_line); 104 | 105 | return result; 106 | } 107 | 108 | static inline void inline_mysql_mdl_set_status( 109 | PSI_metadata_lock *psi, 110 | MDL_ticket::enum_psi_status mdl_status) 111 | { 112 | if (psi != NULL) 113 | PSI_METADATA_CALL(set_metadata_lock_status)(psi, mdl_status); 114 | } 115 | 116 | static inline void inline_mysql_mdl_destroy( 117 | PSI_metadata_lock *psi, 118 | const char *src_file, uint src_line) 119 | { 120 | if (psi != NULL) 121 | PSI_METADATA_CALL(destroy_metadata_lock)(psi); 122 | } 123 | #endif /* HAVE_PSI_METADATA_INTERFACE */ 124 | 125 | /** @} (end of group Metadata_instrumentation) */ 126 | 127 | #endif 128 | 129 | -------------------------------------------------------------------------------- /vendor/mysql/include/mysql/psi/mysql_memory.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License, version 2.0, for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software Foundation, 21 | 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ 22 | 23 | #ifndef MYSQL_MEMORY_H 24 | #define MYSQL_MEMORY_H 25 | 26 | /** 27 | @file mysql/psi/mysql_memory.h 28 | Instrumentation helpers for memory allocation. 29 | */ 30 | 31 | #include "mysql/psi/psi.h" 32 | 33 | #ifndef PSI_MEMORY_CALL 34 | #define PSI_MEMORY_CALL(M) PSI_DYNAMIC_CALL(M) 35 | #endif 36 | 37 | /** 38 | @defgroup Memory_instrumentation Memory Instrumentation 39 | @ingroup Instrumentation_interface 40 | @{ 41 | */ 42 | 43 | /** 44 | @def mysql_memory_register(P1, P2, P3) 45 | Memory registration. 46 | */ 47 | #define mysql_memory_register(P1, P2, P3) \ 48 | inline_mysql_memory_register(P1, P2, P3) 49 | 50 | static inline void inline_mysql_memory_register( 51 | #ifdef HAVE_PSI_MEMORY_INTERFACE 52 | const char *category, 53 | PSI_memory_info *info, 54 | int count) 55 | #else 56 | const char *category MY_ATTRIBUTE((unused)), 57 | void *info MY_ATTRIBUTE((unused)), 58 | int count MY_ATTRIBUTE((unused))) 59 | #endif 60 | { 61 | #ifdef HAVE_PSI_MEMORY_INTERFACE 62 | PSI_MEMORY_CALL(register_memory)(category, info, count); 63 | #endif 64 | } 65 | 66 | /** @} (end of group Memory_instrumentation) */ 67 | 68 | #endif 69 | 70 | -------------------------------------------------------------------------------- /vendor/mysql/include/mysql/psi/mysql_ps.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License, version 2.0, for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 22 | 23 | #ifndef MYSQL_PS_H 24 | #define MYSQL_PS_H 25 | 26 | /** 27 | @file mysql/psi/mysql_ps.h 28 | Instrumentation helpers for prepared statements. 29 | */ 30 | 31 | #include "mysql/psi/psi.h" 32 | 33 | #ifndef PSI_PS_CALL 34 | #define PSI_PS_CALL(M) PSI_DYNAMIC_CALL(M) 35 | #endif 36 | 37 | #ifdef HAVE_PSI_PS_INTERFACE 38 | #define MYSQL_CREATE_PS(IDENTITY, ID, LOCKER, NAME, NAME_LENGTH, SQLTEXT, SQLTEXT_LENGTH) \ 39 | inline_mysql_create_prepared_stmt(IDENTITY, ID, LOCKER, NAME, NAME_LENGTH, SQLTEXT, SQLTEXT_LENGTH) 40 | #define MYSQL_EXECUTE_PS(LOCKER, PREPARED_STMT) \ 41 | inline_mysql_execute_prepared_stmt(LOCKER, PREPARED_STMT) 42 | #define MYSQL_DESTROY_PS(PREPARED_STMT) \ 43 | inline_mysql_destroy_prepared_stmt(PREPARED_STMT) 44 | #define MYSQL_REPREPARE_PS(PREPARED_STMT) \ 45 | inline_mysql_reprepare_prepared_stmt(PREPARED_STMT) 46 | #define MYSQL_SET_PS_TEXT(PREPARED_STMT, SQLTEXT, SQLTEXT_LENGTH) \ 47 | inline_mysql_set_prepared_stmt_text(PREPARED_STMT, SQLTEXT, SQLTEXT_LENGTH) 48 | #else 49 | #define MYSQL_CREATE_PS(IDENTITY, ID, LOCKER, NAME, NAME_LENGTH, SQLTEXT, SQLTEXT_LENGTH) \ 50 | NULL 51 | #define MYSQL_EXECUTE_PS(LOCKER, PREPARED_STMT) \ 52 | do {} while (0) 53 | #define MYSQL_DESTROY_PS(PREPARED_STMT) \ 54 | do {} while (0) 55 | #define MYSQL_REPREPARE_PS(PREPARED_STMT) \ 56 | do {} while (0) 57 | #define MYSQL_SET_PS_TEXT(PREPARED_STMT, SQLTEXT, SQLTEXT_LENGTH) \ 58 | do {} while (0) 59 | #endif 60 | 61 | #ifdef HAVE_PSI_PS_INTERFACE 62 | static inline struct PSI_prepared_stmt* 63 | inline_mysql_create_prepared_stmt(void *identity, uint stmt_id, 64 | PSI_statement_locker *locker, 65 | const char *stmt_name, size_t stmt_name_length, 66 | const char *sqltext, size_t sqltext_length) 67 | { 68 | if (locker == NULL) 69 | return NULL; 70 | return PSI_PS_CALL(create_prepared_stmt)(identity, stmt_id, 71 | locker, 72 | stmt_name, stmt_name_length, 73 | sqltext, sqltext_length); 74 | } 75 | 76 | static inline void 77 | inline_mysql_execute_prepared_stmt(PSI_statement_locker *locker, 78 | PSI_prepared_stmt* prepared_stmt) 79 | { 80 | if (prepared_stmt != NULL && locker != NULL) 81 | PSI_PS_CALL(execute_prepared_stmt)(locker, prepared_stmt); 82 | } 83 | 84 | static inline void 85 | inline_mysql_destroy_prepared_stmt(PSI_prepared_stmt *prepared_stmt) 86 | { 87 | if (prepared_stmt != NULL) 88 | PSI_PS_CALL(destroy_prepared_stmt)(prepared_stmt); 89 | } 90 | 91 | static inline void 92 | inline_mysql_reprepare_prepared_stmt(PSI_prepared_stmt *prepared_stmt) 93 | { 94 | if (prepared_stmt != NULL) 95 | PSI_PS_CALL(reprepare_prepared_stmt)(prepared_stmt); 96 | } 97 | 98 | static inline void 99 | inline_mysql_set_prepared_stmt_text(PSI_prepared_stmt *prepared_stmt, 100 | const char *text, 101 | uint text_len) 102 | { 103 | if (prepared_stmt != NULL) 104 | { 105 | PSI_PS_CALL(set_prepared_stmt_text)(prepared_stmt, text, text_len); 106 | } 107 | } 108 | #endif 109 | 110 | #endif 111 | -------------------------------------------------------------------------------- /vendor/mysql/include/mysql/psi/mysql_sp.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License, version 2.0, for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 22 | 23 | #ifndef MYSQL_SP_H 24 | #define MYSQL_SP_H 25 | 26 | /** 27 | @file mysql/psi/mysql_sp.h 28 | Instrumentation helpers for stored programs. 29 | */ 30 | 31 | #include "mysql/psi/psi.h" 32 | 33 | #ifndef PSI_SP_CALL 34 | #define PSI_SP_CALL(M) PSI_DYNAMIC_CALL(M) 35 | #endif 36 | 37 | #ifdef HAVE_PSI_SP_INTERFACE 38 | #define MYSQL_START_SP(STATE, SP_SHARE) \ 39 | inline_mysql_start_sp(STATE, SP_SHARE) 40 | #else 41 | #define MYSQL_START_SP(STATE, SP_SHARE) \ 42 | NULL 43 | #endif 44 | 45 | 46 | #ifdef HAVE_PSI_SP_INTERFACE 47 | #define MYSQL_END_SP(LOCKER) \ 48 | inline_mysql_end_sp(LOCKER) 49 | #else 50 | #define MYSQL_END_SP(LOCKER) \ 51 | do {} while (0) 52 | #endif 53 | 54 | #ifdef HAVE_PSI_SP_INTERFACE 55 | #define MYSQL_DROP_SP(OT, SN, SNL, ON, ONL) \ 56 | inline_mysql_drop_sp(OT, SN, SNL, ON, ONL) 57 | #else 58 | #define MYSQL_DROP_SP(OT, SN, SNL, ON, ONL) \ 59 | do {} while (0) 60 | #endif 61 | 62 | #ifdef HAVE_PSI_SP_INTERFACE 63 | #define MYSQL_GET_SP_SHARE(OT, SN, SNL, ON, ONL) \ 64 | inline_mysql_get_sp_share(OT, SN, SNL, ON, ONL) 65 | #else 66 | #define MYSQL_GET_SP_SHARE(OT, SN, SNL, ON, ONL) \ 67 | NULL 68 | #endif 69 | 70 | #ifdef HAVE_PSI_SP_INTERFACE 71 | static inline struct PSI_sp_locker* 72 | inline_mysql_start_sp(PSI_sp_locker_state *state, PSI_sp_share *sp_share) 73 | { 74 | return PSI_SP_CALL(start_sp)(state, sp_share); 75 | } 76 | 77 | static inline void inline_mysql_end_sp(PSI_sp_locker *locker) 78 | { 79 | if (likely(locker != NULL)) 80 | PSI_SP_CALL(end_sp)(locker); 81 | } 82 | 83 | static inline void 84 | inline_mysql_drop_sp(uint sp_type, 85 | const char* schema_name, uint shcema_name_length, 86 | const char* object_name, uint object_name_length) 87 | { 88 | PSI_SP_CALL(drop_sp)(sp_type, 89 | schema_name, shcema_name_length, 90 | object_name, object_name_length); 91 | } 92 | 93 | static inline PSI_sp_share* 94 | inline_mysql_get_sp_share(uint sp_type, 95 | const char* schema_name, uint shcema_name_length, 96 | const char* object_name, uint object_name_length) 97 | { 98 | return PSI_SP_CALL(get_sp_share)(sp_type, 99 | schema_name, shcema_name_length, 100 | object_name, object_name_length); 101 | } 102 | #endif 103 | 104 | #endif 105 | -------------------------------------------------------------------------------- /vendor/mysql/include/mysql/service_my_plugin_log.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License, version 2.0, for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 22 | 23 | /** 24 | @file 25 | This service provides functions to report error conditions and log to 26 | mysql error log. 27 | */ 28 | 29 | #ifndef MYSQL_SERVICE_MY_PLUGIN_LOG_INCLUDED 30 | #define MYSQL_SERVICE_MY_PLUGIN_LOG_INCLUDED 31 | 32 | #ifndef MYSQL_ABI_CHECK 33 | #include 34 | #endif 35 | 36 | /* keep in sync with the loglevel enum in my_sys.h */ 37 | enum plugin_log_level 38 | { 39 | MY_ERROR_LEVEL, 40 | MY_WARNING_LEVEL, 41 | MY_INFORMATION_LEVEL 42 | }; 43 | 44 | 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | extern struct my_plugin_log_service 50 | { 51 | /** write a message to the log */ 52 | int (*my_plugin_log_message)(MYSQL_PLUGIN *, enum plugin_log_level, const char *, ...); 53 | } *my_plugin_log_service; 54 | 55 | #ifdef MYSQL_DYNAMIC_PLUGIN 56 | 57 | #define my_plugin_log_message my_plugin_log_service->my_plugin_log_message 58 | 59 | #else 60 | 61 | int my_plugin_log_message(MYSQL_PLUGIN *plugin, enum plugin_log_level level, 62 | const char *format, ...); 63 | 64 | #endif 65 | 66 | #ifdef __cplusplus 67 | } 68 | #endif 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /vendor/mysql/include/mysql/service_my_snprintf.h: -------------------------------------------------------------------------------- 1 | #ifndef MYSQL_SERVICE_MY_SNPRINTF_INCLUDED 2 | #define MYSQL_SERVICE_MY_SNPRINTF_INCLUDED 3 | /* Copyright (c) 2009, 2023, Oracle and/or its affiliates. 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License, version 2.0, 7 | as published by the Free Software Foundation. 8 | 9 | This program is also distributed with certain software (including 10 | but not limited to OpenSSL) that is licensed under separate terms, 11 | as designated in a particular file or component or in included license 12 | documentation. The authors of MySQL hereby grant you an additional 13 | permission to link the program and your derivative works with the 14 | separately licensed software that they have included with MySQL. 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 | @file 27 | my_snprintf service 28 | 29 | Portable and limited vsnprintf() implementation. 30 | 31 | This is a portable, limited vsnprintf() implementation, with some 32 | extra features. "Portable" means that it'll produce identical result 33 | on all platforms (for example, on Windows and Linux system printf %e 34 | formats the exponent differently, on different systems %p either 35 | prints leading 0x or not, %s may accept null pointer or crash on 36 | it). "Limited" means that it does not support all the C89 features. 37 | But it supports few extensions, not in any standard. 38 | 39 | my_vsnprintf(to, n, fmt, ap) 40 | 41 | @param[out] to A buffer to store the result in 42 | @param[in] n Store up to n-1 characters, followed by an end 0 43 | @param[in] fmt printf-like format string 44 | @param[in] ap Arguments 45 | 46 | @return a number of bytes written to a buffer *excluding* terminating '\0' 47 | 48 | @post 49 | The syntax of a format string is generally the same: 50 | % 51 | where everithing but the format is optional. 52 | 53 | Three one-character flags are recognized: 54 | '0' has the standard zero-padding semantics; 55 | '-' is parsed, but silently ignored; 56 | '`' (backtick) is only supported for strings (%s) and means that the 57 | string will be quoted according to MySQL identifier quoting rules. 58 | 59 | Both and can be specified as numbers or '*'. 60 | If an asterisk is used, an argument of type int is consumed. 61 | 62 | can be 'l', 'll', or 'z'. 63 | 64 | Supported formats are 's' (null pointer is accepted, printed as 65 | "(null)"), 'b' (extension, see below), 'c', 'd', 'i', 'u', 'x', 'o', 66 | 'X', 'p' (works as 0x%x). 67 | 68 | Standard syntax for positional arguments $n is supported. 69 | 70 | Extensions: 71 | 72 | Flag '`' (backtick): see above. 73 | 74 | Format 'b': binary buffer, prints exactly bytes from the 75 | argument, without stopping at '\0'. 76 | */ 77 | 78 | #ifdef __cplusplus 79 | extern "C" { 80 | #endif 81 | 82 | #ifndef MYSQL_ABI_CHECK 83 | #include 84 | #include 85 | #endif 86 | 87 | extern struct my_snprintf_service_st { 88 | size_t (*my_snprintf_type)(char*, size_t, const char*, ...); 89 | size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list); 90 | } *my_snprintf_service; 91 | 92 | #ifdef MYSQL_DYNAMIC_PLUGIN 93 | 94 | #define my_vsnprintf my_snprintf_service->my_vsnprintf_type 95 | #define my_snprintf my_snprintf_service->my_snprintf_type 96 | 97 | #else 98 | 99 | size_t my_snprintf(char* to, size_t n, const char* fmt, ...); 100 | size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap); 101 | 102 | #endif 103 | 104 | #ifdef __cplusplus 105 | } 106 | #endif 107 | 108 | #endif /* #define MYSQL_SERVICE_MY_SNPRINTF_INCLUDED */ 109 | -------------------------------------------------------------------------------- /vendor/mysql/include/mysql/service_mysql_alloc.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License, version 2.0, for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 22 | 23 | #ifndef MYSQL_SERVICE_MYSQL_ALLOC_INCLUDED 24 | #define MYSQL_SERVICE_MYSQL_ALLOC_INCLUDED 25 | 26 | #ifndef MYSQL_ABI_CHECK 27 | #include 28 | #endif 29 | 30 | /* PSI_memory_key */ 31 | #include "mysql/psi/psi_memory.h" 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* myf */ 38 | typedef int myf_t; 39 | 40 | typedef void * (*mysql_malloc_t)(PSI_memory_key key, size_t size, myf_t flags); 41 | typedef void * (*mysql_realloc_t)(PSI_memory_key key, void *ptr, size_t size, myf_t flags); 42 | typedef void (*mysql_claim_t)(void *ptr); 43 | typedef void (*mysql_free_t)(void *ptr); 44 | typedef void * (*my_memdup_t)(PSI_memory_key key, const void *from, size_t length, myf_t flags); 45 | typedef char * (*my_strdup_t)(PSI_memory_key key, const char *from, myf_t flags); 46 | typedef char * (*my_strndup_t)(PSI_memory_key key, const char *from, size_t length, myf_t flags); 47 | 48 | struct mysql_malloc_service_st 49 | { 50 | mysql_malloc_t mysql_malloc; 51 | mysql_realloc_t mysql_realloc; 52 | mysql_claim_t mysql_claim; 53 | mysql_free_t mysql_free; 54 | my_memdup_t my_memdup; 55 | my_strdup_t my_strdup; 56 | my_strndup_t my_strndup; 57 | }; 58 | 59 | extern struct mysql_malloc_service_st *mysql_malloc_service; 60 | 61 | #ifdef MYSQL_DYNAMIC_PLUGIN 62 | 63 | #define my_malloc mysql_malloc_service->mysql_malloc 64 | #define my_realloc mysql_malloc_service->mysql_realloc 65 | #define my_claim mysql_malloc_service->mysql_claim 66 | #define my_free mysql_malloc_service->mysql_free 67 | #define my_memdup mysql_malloc_service->my_memdup 68 | #define my_strdup mysql_malloc_service->my_strdup 69 | #define my_strndup mysql_malloc_service->my_strndup 70 | 71 | #else 72 | 73 | extern void * my_malloc(PSI_memory_key key, size_t size, myf_t flags); 74 | extern void * my_realloc(PSI_memory_key key, void *ptr, size_t size, myf_t flags); 75 | extern void my_claim(void *ptr); 76 | extern void my_free(void *ptr); 77 | extern void * my_memdup(PSI_memory_key key, const void *from, size_t length, myf_t flags); 78 | extern char * my_strdup(PSI_memory_key key, const char *from, myf_t flags); 79 | extern char * my_strndup(PSI_memory_key key, const char *from, size_t length, myf_t flags); 80 | 81 | #endif 82 | 83 | #ifdef __cplusplus 84 | } 85 | #endif 86 | 87 | #endif 88 | 89 | -------------------------------------------------------------------------------- /vendor/mysql/include/mysql/service_mysql_keyring.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License, version 2.0, for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 22 | 23 | #ifndef MYSQL_SERVICE_MYSQL_PLUGIN_KEYRING_INCLUDED 24 | #define MYSQL_SERVICE_MYSQL_PLUGIN_KEYRING_INCLUDED 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | extern struct mysql_keyring_service_st 31 | { 32 | int (*my_key_store_func)(const char *, const char *, const char *, 33 | const void *, size_t); 34 | int (*my_key_fetch_func)(const char *, char **, const char *, void **, 35 | size_t *); 36 | int (*my_key_remove_func)(const char *, const char *); 37 | int (*my_key_generate_func)(const char *, const char *, const char *, 38 | size_t); 39 | } *mysql_keyring_service; 40 | 41 | #ifdef MYSQL_DYNAMIC_PLUGIN 42 | 43 | #define my_key_store(key_id, key_type, user_id, key, key_len) \ 44 | mysql_keyring_service->my_key_store_func(key_id, key_type, user_id, key, \ 45 | key_len) 46 | #define my_key_fetch(key_id, key_type, user_id, key, key_len) \ 47 | mysql_keyring_service->my_key_fetch_func(key_id, key_type, user_id, key, \ 48 | key_len) 49 | #define my_key_remove(key_id, user_id) \ 50 | mysql_keyring_service->my_key_remove_func(key_id, user_id) 51 | #define my_key_generate(key_id, key_type, user_id, key_len) \ 52 | mysql_keyring_service->my_key_generate_func(key_id, key_type, user_id, \ 53 | key_len) 54 | #else 55 | 56 | int my_key_store(const char *, const char *, const char *, const void *, size_t); 57 | int my_key_fetch(const char *, char **, const char *, void **, 58 | size_t *); 59 | int my_key_remove(const char *, const char *); 60 | int my_key_generate(const char *, const char *, const char *, size_t); 61 | 62 | #endif 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | 68 | #endif //MYSQL_SERVICE_MYSQL_PLUGIN_KEYRING_INCLUDED 69 | 70 | -------------------------------------------------------------------------------- /vendor/mysql/include/mysql/service_mysql_password_policy.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License, version 2.0, for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 22 | 23 | #ifndef MYSQL_SERVICE_MYSQL_PLUGIN_AUTH_INCLUDED 24 | #define MYSQL_SERVICE_MYSQL_PLUGIN_AUTH_INCLUDED 25 | 26 | /** 27 | @file include/mysql/service_mysql_plugin_auth.h 28 | This service provides functions to validatete password, check for strength 29 | of password based on common policy. 30 | 31 | SYNOPSIS 32 | my_validate_password_policy() - function to validate password 33 | based on defined policy 34 | const char* buffer holding the password value 35 | unsigned int buffer length 36 | 37 | my_calculate_password_strength() - function to calculate strength 38 | of the password based on the policies defined. 39 | const char* buffer holding the password value 40 | unsigned int buffer length 41 | 42 | Both the service function returns 0 on SUCCESS and 1 incase input password does not 43 | match against the policy rules defined. 44 | */ 45 | 46 | #ifdef __cplusplus 47 | extern "C" { 48 | #endif 49 | 50 | extern struct mysql_password_policy_service_st { 51 | int (*my_validate_password_policy_func)(const char *, unsigned int); 52 | int (*my_calculate_password_strength_func)(const char *, unsigned int); 53 | } *mysql_password_policy_service; 54 | 55 | #ifdef MYSQL_DYNAMIC_PLUGIN 56 | 57 | #define my_validate_password_policy(buffer, length) \ 58 | mysql_password_policy_service->my_validate_password_policy_func(buffer, length) 59 | #define my_calculate_password_strength(buffer, length) \ 60 | mysql_password_policy_service->my_calculate_password_strength_func(buffer, length) 61 | 62 | #else 63 | 64 | int my_validate_password_policy(const char *, unsigned int); 65 | int my_calculate_password_strength(const char *, unsigned int); 66 | 67 | #endif 68 | 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /vendor/mysql/include/mysql/service_rpl_transaction_ctx.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License, version 2.0, for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 22 | 23 | #ifndef MYSQL_SERVICE_RPL_TRANSACTION_CTX_INCLUDED 24 | 25 | /** 26 | @file include/mysql/service_rpl_transaction_ctx.h 27 | This service provides a function for plugins to report if a transaction of a 28 | given THD should continue or be aborted. 29 | 30 | SYNOPSIS 31 | set_transaction_ctx() 32 | should be called during RUN_HOOK macro, on which we know that thread is 33 | on plugin context and it is before 34 | Rpl_transaction_ctx::is_transaction_rollback() check. 35 | */ 36 | 37 | #ifndef MYSQL_ABI_CHECK 38 | #include 39 | #endif 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | struct st_transaction_termination_ctx 46 | { 47 | unsigned long m_thread_id; 48 | unsigned int m_flags; // reserved 49 | 50 | /* 51 | If the instruction is to rollback the transaction, 52 | then this flag is set to false. 53 | Note: type is char like on my_bool. 54 | */ 55 | char m_rollback_transaction; 56 | 57 | /* 58 | If the plugin has generated a GTID, then the follwoing 59 | fields MUST be set. 60 | Note: type is char like on my_bool. 61 | */ 62 | char m_generated_gtid; 63 | int m_sidno; 64 | long long int m_gno; 65 | }; 66 | typedef struct st_transaction_termination_ctx Transaction_termination_ctx; 67 | 68 | extern struct rpl_transaction_ctx_service_st { 69 | int (*set_transaction_ctx)(Transaction_termination_ctx transaction_termination_ctx); 70 | } *rpl_transaction_ctx_service; 71 | 72 | #ifdef MYSQL_DYNAMIC_PLUGIN 73 | 74 | #define set_transaction_ctx(transaction_termination_ctx) \ 75 | (rpl_transaction_ctx_service->set_transaction_ctx((transaction_termination_ctx))) 76 | 77 | #else 78 | 79 | int set_transaction_ctx(Transaction_termination_ctx transaction_termination_ctx); 80 | 81 | #endif 82 | 83 | #ifdef __cplusplus 84 | } 85 | #endif 86 | 87 | #define MYSQL_SERVICE_RPL_TRANSACTION_CTX_INCLUDED 88 | #endif 89 | -------------------------------------------------------------------------------- /vendor/mysql/include/mysql/service_rpl_transaction_write_set.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License, version 2.0, for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 22 | 23 | #ifndef MYSQL_SERVICE_TRANSACTION_WRITE_SET_INCLUDED 24 | 25 | /** 26 | @file include/mysql/service_rpl_transaction_write_set.h 27 | This service provides a function for plugins to get the write set of a given 28 | transaction. 29 | 30 | SYNOPSIS 31 | get_transaction_write_set() 32 | This service is used to fetch the write_set extracted for the currently 33 | executing transaction by passing the thread_id as an input parameter for 34 | the method. 35 | 36 | @param [in] - thread_id - It is the thread identifier of the currently 37 | executing thread. 38 | 39 | In the current implementation it is being called during RUN_HOOK macro, 40 | on which we know that thread is on plugin context. 41 | 42 | Cleanup : 43 | The service caller must take of the memory allocated during the service 44 | call to prevent memory leaks. 45 | */ 46 | 47 | #ifndef MYSQL_ABI_CHECK 48 | #include 49 | #endif 50 | 51 | #ifdef __cplusplus 52 | extern "C" { 53 | #endif 54 | 55 | /** 56 | This structure is used to keep the list of the hash values of the records 57 | changed in the transaction. 58 | */ 59 | struct st_trans_write_set 60 | { 61 | unsigned int m_flags; // reserved 62 | unsigned long write_set_size; // Size of the PKE set of the transaction. 63 | unsigned long long* write_set; // A pointer to the PKE set. 64 | }; 65 | typedef struct st_trans_write_set Transaction_write_set; 66 | 67 | extern struct transaction_write_set_service_st { 68 | Transaction_write_set* (*get_transaction_write_set)(unsigned long m_thread_id); 69 | void (*require_full_write_set)(int requires_ws); 70 | void (*set_write_set_memory_size_limit)(long long size_limit); 71 | void (*update_write_set_memory_size_limit)(long long size_limit); 72 | } *transaction_write_set_service; 73 | 74 | #ifdef MYSQL_DYNAMIC_PLUGIN 75 | 76 | #define get_transaction_write_set(m_thread_id) \ 77 | (transaction_write_set_service->get_transaction_write_set((m_thread_id))) 78 | #define require_full_write_set(requires_ws) \ 79 | transaction_write_set_service->require_full_write_set(requires_ws) 80 | #define set_write_set_memory_size_limit(size_limit) \ 81 | transaction_write_set_service->set_write_set_memory_size_limit(size_limit) 82 | #define update_write_set_memory_size_limit(size_limit) \ 83 | transaction_write_set_service->update_write_set_memory_size_limit(size_limit) 84 | 85 | #else 86 | 87 | Transaction_write_set* get_transaction_write_set(unsigned long m_thread_id); 88 | 89 | void require_full_write_set(int requires_ws); 90 | 91 | void set_write_set_memory_size_limit(long long size_limit); 92 | 93 | void update_write_set_memory_size_limit(long long size_limit); 94 | 95 | #endif 96 | 97 | #ifdef __cplusplus 98 | } 99 | #endif 100 | 101 | #define MYSQL_SERVICE_TRANSACTION_WRITE_SET_INCLUDED 102 | #endif 103 | -------------------------------------------------------------------------------- /vendor/mysql/include/mysql/service_security_context.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License, version 2.0, for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 22 | 23 | #ifndef MYSQL_SERVICE_SECURITY_CONTEXT 24 | #define MYSQL_SERVICE_SECURITY_CONTEXT 25 | 26 | /** 27 | @file include/mysql/service_security_context.h 28 | 29 | This service provides functions for plugins and storage engines to 30 | manipulate the thread's security context. 31 | */ 32 | 33 | #ifdef __cplusplus 34 | class Security_context; 35 | #define MYSQL_SECURITY_CONTEXT Security_context* 36 | #else 37 | #define MYSQL_SECURITY_CONTEXT void* 38 | #endif 39 | typedef char my_svc_bool; 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | extern struct security_context_service_st { 46 | my_svc_bool (*thd_get_security_context)(MYSQL_THD, MYSQL_SECURITY_CONTEXT *out_ctx); 47 | my_svc_bool (*thd_set_security_context)(MYSQL_THD, MYSQL_SECURITY_CONTEXT in_ctx); 48 | 49 | my_svc_bool (*security_context_create)(MYSQL_SECURITY_CONTEXT *out_ctx); 50 | my_svc_bool (*security_context_destroy)(MYSQL_SECURITY_CONTEXT); 51 | my_svc_bool (*security_context_copy)(MYSQL_SECURITY_CONTEXT in_ctx, MYSQL_SECURITY_CONTEXT *out_ctx); 52 | 53 | my_svc_bool (*security_context_lookup)(MYSQL_SECURITY_CONTEXT ctx, 54 | const char *user, const char *host, 55 | const char *ip, const char *db); 56 | 57 | my_svc_bool (*security_context_get_option)(MYSQL_SECURITY_CONTEXT, const char *name, void *inout_pvalue); 58 | my_svc_bool (*security_context_set_option)(MYSQL_SECURITY_CONTEXT, const char *name, void *pvalue); 59 | } *security_context_service; 60 | 61 | #ifdef MYSQL_DYNAMIC_PLUGIN 62 | 63 | #define thd_get_security_context(_THD, _CTX) \ 64 | security_context_service->thd_get_security_context(_THD, _CTX) 65 | #define thd_set_security_context(_THD, _CTX) \ 66 | security_context_service->thd_set_security_context(_THD, _CTX) 67 | 68 | #define security_context_create(_CTX) \ 69 | security_context_service->security_context_create(_CTX) 70 | #define security_context_destroy(_CTX) \ 71 | security_context_service->security_context_destroy(_CTX) 72 | #define security_context_copy(_CTX1, _CTX2) \ 73 | security_context_service->security_context_copy(_CTX1,_CTX2) 74 | 75 | #define security_context_lookup(_CTX, _U, _H, _IP, _DB) \ 76 | security_context_service->security_context_lookup(_CTX, _U, _H, _IP, _DB) 77 | 78 | #define security_context_get_option(_SEC_CTX, _NAME, _VALUE) \ 79 | security_context_service->security_context_get_option(_SEC_CTX, _NAME, _VALUE) 80 | #define security_context_set_option(_SEC_CTX, _NAME, _VALUE) \ 81 | security_context_service->security_context_set_option(_SEC_CTX, _NAME, _VALUE) 82 | #else 83 | my_svc_bool thd_get_security_context(MYSQL_THD, MYSQL_SECURITY_CONTEXT *out_ctx); 84 | my_svc_bool thd_set_security_context(MYSQL_THD, MYSQL_SECURITY_CONTEXT in_ctx); 85 | 86 | my_svc_bool security_context_create(MYSQL_SECURITY_CONTEXT *out_ctx); 87 | my_svc_bool security_context_destroy(MYSQL_SECURITY_CONTEXT ctx); 88 | my_svc_bool security_context_copy(MYSQL_SECURITY_CONTEXT in_ctx, MYSQL_SECURITY_CONTEXT *out_ctx); 89 | 90 | my_svc_bool security_context_lookup(MYSQL_SECURITY_CONTEXT ctx, 91 | const char *user, const char *host, 92 | const char *ip, const char *db); 93 | 94 | my_svc_bool security_context_get_option(MYSQL_SECURITY_CONTEXT, const char *name, void *inout_pvalue); 95 | my_svc_bool security_context_set_option(MYSQL_SECURITY_CONTEXT, const char *name, void *pvalue); 96 | #endif /* !MYSQL_DYNAMIC_PLUGIN */ 97 | 98 | #ifdef __cplusplus 99 | } 100 | #endif /* _cplusplus */ 101 | 102 | #endif /* !MYSQL_SERVICE_SECURITY_CONTEXT */ 103 | -------------------------------------------------------------------------------- /vendor/mysql/include/mysql/service_thd_engine_lock.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License, version 2.0, for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 22 | 23 | #ifndef MYSQL_SERVICE_THD_EGINE_LOCK_INCLUDED 24 | #define MYSQL_SERVICE_THD_EGINE_LOCK_INCLUDED 25 | 26 | /** 27 | @file include/mysql/service_thd_engine_lock.h 28 | This service provides functions for storage engines to report 29 | lock related activities. 30 | 31 | SYNOPSIS 32 | thd_row_lock_wait() - call it just when the engine find a transaction should wait 33 | another transaction to realease a row lock 34 | thd The session which is waiting for the row lock to release. 35 | thd_wait_for The session which is holding the row lock. 36 | */ 37 | 38 | #ifdef __cplusplus 39 | class THD; 40 | #else 41 | #define THD void 42 | #endif 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | void thd_report_row_lock_wait(THD* self, THD *wait_for); 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /vendor/mysql/include/mysql/service_thd_wait.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2010, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License, version 2.0, for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 22 | 23 | #ifndef MYSQL_SERVICE_THD_WAIT_INCLUDED 24 | #define MYSQL_SERVICE_THD_WAIT_INCLUDED 25 | 26 | /** 27 | @file include/mysql/service_thd_wait.h 28 | This service provides functions for plugins and storage engines to report 29 | when they are going to sleep/stall. 30 | 31 | SYNOPSIS 32 | thd_wait_begin() - call just before a wait begins 33 | thd Thread object 34 | Use NULL if the thd is NOT known. 35 | wait_type Type of wait 36 | 1 -- short wait (e.g. for mutex) 37 | 2 -- medium wait (e.g. for disk io) 38 | 3 -- large wait (e.g. for locked row/table) 39 | NOTES 40 | This is used by the threadpool to have better knowledge of which 41 | threads that currently are actively running on CPUs. When a thread 42 | reports that it's going to sleep/stall, the threadpool scheduler is 43 | free to start another thread in the pool most likely. The expected wait 44 | time is simply an indication of how long the wait is expected to 45 | become, the real wait time could be very different. 46 | 47 | thd_wait_end() called immediately after the wait is complete 48 | 49 | thd_wait_end() MUST be called if thd_wait_begin() was called. 50 | 51 | Using thd_wait_...() service is optional but recommended. Using it will 52 | improve performance as the thread pool will be more active at managing the 53 | thread workload. 54 | */ 55 | 56 | #ifdef __cplusplus 57 | class THD; 58 | #define MYSQL_THD THD* 59 | #else 60 | #define MYSQL_THD void* 61 | #endif 62 | 63 | #ifdef __cplusplus 64 | extern "C" { 65 | #endif 66 | 67 | /* 68 | One should only report wait events that could potentially block for a 69 | long time. A mutex wait is too short of an event to report. The reason 70 | is that an event which is reported leads to a new thread starts 71 | executing a query and this has a negative impact of usage of CPU caches 72 | and thus the expected gain of starting a new thread must be higher than 73 | the expected cost of lost performance due to starting a new thread. 74 | 75 | Good examples of events that should be reported are waiting for row locks 76 | that could easily be for many milliseconds or even seconds and the same 77 | holds true for global read locks, table locks and other meta data locks. 78 | Another event of interest is going to sleep for an extended time. 79 | 80 | Note that user-level locks no longer use THD_WAIT_USER_LOCK wait type. 81 | Since their implementation relies on metadata locks manager it uses 82 | THD_WAIT_META_DATA_LOCK instead. 83 | */ 84 | typedef enum _thd_wait_type_e { 85 | THD_WAIT_SLEEP= 1, 86 | THD_WAIT_DISKIO= 2, 87 | THD_WAIT_ROW_LOCK= 3, 88 | THD_WAIT_GLOBAL_LOCK= 4, 89 | THD_WAIT_META_DATA_LOCK= 5, 90 | THD_WAIT_TABLE_LOCK= 6, 91 | THD_WAIT_USER_LOCK= 7, 92 | THD_WAIT_BINLOG= 8, 93 | THD_WAIT_GROUP_COMMIT= 9, 94 | THD_WAIT_SYNC= 10, 95 | THD_WAIT_LAST= 11 96 | } thd_wait_type; 97 | 98 | extern struct thd_wait_service_st { 99 | void (*thd_wait_begin_func)(MYSQL_THD, int); 100 | void (*thd_wait_end_func)(MYSQL_THD); 101 | } *thd_wait_service; 102 | 103 | #ifdef MYSQL_DYNAMIC_PLUGIN 104 | 105 | #define thd_wait_begin(_THD, _WAIT_TYPE) \ 106 | thd_wait_service->thd_wait_begin_func(_THD, _WAIT_TYPE) 107 | #define thd_wait_end(_THD) thd_wait_service->thd_wait_end_func(_THD) 108 | 109 | #else 110 | 111 | void thd_wait_begin(MYSQL_THD thd, int wait_type); 112 | void thd_wait_end(MYSQL_THD thd); 113 | 114 | #endif 115 | 116 | #ifdef __cplusplus 117 | } 118 | #endif 119 | 120 | #endif 121 | 122 | -------------------------------------------------------------------------------- /vendor/mysql/include/mysql/service_thread_scheduler.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010, 2023, 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 | #ifndef SERVICE_THREAD_SCHEDULER_INCLUDED 26 | #define SERVICE_THREAD_SCHEDULER_INCLUDED 27 | 28 | #ifdef __cplusplus 29 | extern "C" { 30 | #endif 31 | 32 | struct Connection_handler_functions; 33 | struct THD_event_functions; 34 | 35 | extern struct my_thread_scheduler_service { 36 | int (*connection_handler_set)(struct Connection_handler_functions *, 37 | struct THD_event_functions *); 38 | int (*connection_handler_reset)(); 39 | } *my_thread_scheduler_service; 40 | 41 | 42 | #ifdef MYSQL_DYNAMIC_PLUGIN 43 | 44 | #define my_connection_handler_set(F, M) \ 45 | my_thread_scheduler_service->connection_handler_set((F), (M)) 46 | #define my_connection_handler_reset() \ 47 | my_thread_scheduler_service->connection_handler_reset() 48 | 49 | #else 50 | 51 | /** 52 | Instantiates Plugin_connection_handler based on the supplied 53 | Conection_handler_functions and sets it as the current 54 | connection handler. 55 | 56 | Also sets the THD_event_functions functions which will 57 | be called by the server when e.g. begining a wait. 58 | 59 | Remembers the existing connection handler so that it can be restored later. 60 | 61 | @param chf struct with functions to be called when e.g. handling 62 | new clients. 63 | @param tef struct with functions to be called when events 64 | (e.g. lock wait) happens. 65 | 66 | @note Both pointers (i.e. not the structs themselves) will be copied, 67 | so the structs must not disappear. 68 | 69 | @note We don't support dynamically loading more than one connection handler. 70 | 71 | @retval 1 failure 72 | @retval 0 success 73 | */ 74 | int my_connection_handler_set(struct Connection_handler_functions *chf, 75 | struct THD_event_functions *tef); 76 | 77 | /** 78 | Destroys the current connection handler and restores the previous. 79 | Should only be called after calling my_connection_handler_set(). 80 | 81 | @retval 1 failure 82 | @retval 0 success 83 | */ 84 | int my_connection_handler_reset(); 85 | 86 | #endif /* MYSQL_DYNAMIC_PLUGIN */ 87 | 88 | #ifdef __cplusplus 89 | } 90 | #endif 91 | 92 | #endif /* SERVICE_THREAD_SCHEDULER_INCLUDED */ 93 | -------------------------------------------------------------------------------- /vendor/mysql/include/mysql/services.h: -------------------------------------------------------------------------------- 1 | #ifndef MYSQL_SERVICES_INCLUDED 2 | /* Copyright (c) 2009, 2023, 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 | /* 26 | Out of extern because of inclusion of files which include my_compiler.h 27 | which in turn complains about C-linkage of templates. 28 | service_srv_session.h and service_command.h use proper extern "C" for 29 | their exported symbols. 30 | */ 31 | #ifndef EMBEDDED_LIBRARY 32 | #include 33 | #include 34 | #include 35 | #endif 36 | 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include 55 | #include 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #ifdef __cplusplus 62 | #include 63 | #endif 64 | 65 | #define MYSQL_SERVICES_INCLUDED 66 | #endif /* MYSQL_SERVICES_INCLUDED */ 67 | -------------------------------------------------------------------------------- /vendor/mysql/include/mysql/thread_type.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2000, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License, version 2.0, for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ 22 | 23 | /* Defines to make different thread packages compatible */ 24 | 25 | #ifndef THREAD_TYPE_INCLUDED 26 | #define THREAD_TYPE_INCLUDED 27 | 28 | #ifdef __cplusplus 29 | extern "C"{ 30 | #endif 31 | 32 | /* Flags for the THD::system_thread variable */ 33 | enum enum_thread_type 34 | { 35 | NON_SYSTEM_THREAD= 0, 36 | SYSTEM_THREAD_SLAVE_IO= 1, 37 | SYSTEM_THREAD_SLAVE_SQL= 2, 38 | SYSTEM_THREAD_NDBCLUSTER_BINLOG= 4, 39 | SYSTEM_THREAD_EVENT_SCHEDULER= 8, 40 | SYSTEM_THREAD_EVENT_WORKER= 16, 41 | SYSTEM_THREAD_INFO_REPOSITORY= 32, 42 | SYSTEM_THREAD_SLAVE_WORKER= 64, 43 | SYSTEM_THREAD_COMPRESS_GTID_TABLE= 128, 44 | SYSTEM_THREAD_BACKGROUND= 256 45 | }; 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif /* THREAD_TYPE_INCLUDED */ 52 | -------------------------------------------------------------------------------- /vendor/mysql/include/mysql_com_server.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License, version 2.0, for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 22 | 23 | /* 24 | Definitions private to the server, 25 | used in the networking layer to notify specific events. 26 | */ 27 | 28 | #ifndef _mysql_com_server_h 29 | #define _mysql_com_server_h 30 | 31 | struct st_net_server; 32 | 33 | typedef void (*before_header_callback_fn) 34 | (struct st_net *net, void *user_data, size_t count); 35 | 36 | typedef void (*after_header_callback_fn) 37 | (struct st_net *net, void *user_data, size_t count, my_bool rc); 38 | 39 | struct st_net_server 40 | { 41 | before_header_callback_fn m_before_header; 42 | after_header_callback_fn m_after_header; 43 | void *m_user_data; 44 | my_bool timeout_on_full_packet; 45 | 46 | st_net_server() { 47 | m_before_header = NULL; 48 | m_after_header = NULL; 49 | m_user_data = NULL; 50 | timeout_on_full_packet = FALSE; 51 | } 52 | }; 53 | 54 | typedef struct st_net_server NET_SERVER; 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /vendor/mysql/include/mysql_embed.h: -------------------------------------------------------------------------------- 1 | #ifndef MYSQL_EMBED_INCLUDED 2 | #define MYSQL_EMBED_INCLUDED 3 | 4 | /* Copyright (c) 2000, 2023, Oracle and/or its affiliates. 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License, version 2.0, 8 | as published by the Free Software Foundation. 9 | 10 | This program is also distributed with certain software (including 11 | but not limited to OpenSSL) that is licensed under separate terms, 12 | as designated in a particular file or component or in included license 13 | documentation. The authors of MySQL hereby grant you an additional 14 | permission to link the program and your derivative works with the 15 | separately licensed software that they have included with MySQL. 16 | 17 | This program is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU General Public License, version 2.0, for more details. 21 | 22 | You should have received a copy of the GNU General Public License 23 | along with this program; if not, write to the Free Software 24 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 25 | 26 | /* Defines that are unique to the embedded version of MySQL */ 27 | 28 | #ifdef EMBEDDED_LIBRARY 29 | 30 | /* Things we don't need in the embedded version of MySQL */ 31 | /* TODO HF add #undef HAVE_VIO if we don't want client in embedded library */ 32 | 33 | #undef HAVE_DLOPEN /* No udf functions */ 34 | 35 | #endif /* EMBEDDED_LIBRARY */ 36 | #endif /* MYSQL_EMBED_INCLUDED */ 37 | -------------------------------------------------------------------------------- /vendor/mysql/include/mysql_time.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2004, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | Without limiting anything contained in the foregoing, this file, 15 | which is part of C Driver for MySQL (Connector/C), is also subject to the 16 | Universal FOSS Exception, version 1.0, a copy of which can be found at 17 | http://oss.oracle.com/licenses/universal-foss-exception. 18 | 19 | This program is distributed in the hope that it will be useful, 20 | but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | GNU General Public License, version 2.0, for more details. 23 | 24 | You should have received a copy of the GNU General Public License 25 | along with this program; if not, write to the Free Software 26 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ 27 | 28 | #ifndef _mysql_time_h_ 29 | #define _mysql_time_h_ 30 | 31 | /* 32 | Time declarations shared between the server and client API: 33 | you should not add anything to this header unless it's used 34 | (and hence should be visible) in mysql.h. 35 | If you're looking for a place to add new time-related declaration, 36 | it's most likely my_time.h. See also "C API Handling of Date 37 | and Time Values" chapter in documentation. 38 | */ 39 | 40 | enum enum_mysql_timestamp_type 41 | { 42 | MYSQL_TIMESTAMP_NONE= -2, MYSQL_TIMESTAMP_ERROR= -1, 43 | MYSQL_TIMESTAMP_DATE= 0, MYSQL_TIMESTAMP_DATETIME= 1, MYSQL_TIMESTAMP_TIME= 2 44 | }; 45 | 46 | 47 | /* 48 | Structure which is used to represent datetime values inside MySQL. 49 | 50 | We assume that values in this structure are normalized, i.e. year <= 9999, 51 | month <= 12, day <= 31, hour <= 23, hour <= 59, hour <= 59. Many functions 52 | in server such as my_system_gmt_sec() or make_time() family of functions 53 | rely on this (actually now usage of make_*() family relies on a bit weaker 54 | restriction). Also functions that produce MYSQL_TIME as result ensure this. 55 | There is one exception to this rule though if this structure holds time 56 | value (time_type == MYSQL_TIMESTAMP_TIME) days and hour member can hold 57 | bigger values. 58 | */ 59 | typedef struct st_mysql_time 60 | { 61 | unsigned int year, month, day, hour, minute, second; 62 | unsigned long second_part; /**< microseconds */ 63 | my_bool neg; 64 | enum enum_mysql_timestamp_type time_type; 65 | } MYSQL_TIME; 66 | 67 | #endif /* _mysql_time_h_ */ 68 | -------------------------------------------------------------------------------- /vendor/mysql/include/mysql_version.h: -------------------------------------------------------------------------------- 1 | /* Copyright Abandoned 1996,1999 TCX DataKonsult AB & Monty Program KB 2 | & Detron HB, 1996, 1999-2004, 2007 MySQL AB. 3 | This file is public domain and comes with NO WARRANTY of any kind 4 | */ 5 | 6 | /* Version numbers for protocol & mysqld */ 7 | 8 | #ifndef _mysql_version_h 9 | #define _mysql_version_h 10 | 11 | #define PROTOCOL_VERSION 10 12 | #define MYSQL_SERVER_VERSION "5.7.44" 13 | #define MYSQL_BASE_VERSION "mysqld-5.7" 14 | #define MYSQL_SERVER_SUFFIX_DEF "" 15 | #define FRM_VER 6 16 | #define MYSQL_VERSION_ID 50744 17 | #define MYSQL_PORT 3306 18 | #define MYSQL_PORT_DEFAULT 0 19 | #define MYSQL_UNIX_ADDR "/tmp/mysql.sock" 20 | #define MYSQL_CONFIG_NAME "my" 21 | #define MYSQL_COMPILATION_COMMENT "MySQL Community Server (GPL)" 22 | #define LIBMYSQL_VERSION "5.7.44" 23 | #define LIBMYSQL_VERSION_ID 50744 24 | #define SYS_SCHEMA_VERSION "1.5.2" 25 | 26 | #ifndef LICENSE 27 | #define LICENSE GPL 28 | #endif /* LICENSE */ 29 | 30 | #endif /* _mysql_version_h */ 31 | -------------------------------------------------------------------------------- /vendor/mysql/include/mysqlx_ername.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, 2023, 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 23 | * 02110-1301 USA 24 | */ 25 | 26 | /* Autogenerated file, please don't edit */ 27 | 28 | #include "mysqlx_error.h" 29 | 30 | {"ER_X_BAD_MESSAGE", ER_X_BAD_MESSAGE, ""}, 31 | {"ER_X_CAPABILITIES_PREPARE_FAILED", ER_X_CAPABILITIES_PREPARE_FAILED, ""}, 32 | {"ER_X_CAPABILITY_NOT_FOUND", ER_X_CAPABILITY_NOT_FOUND, ""}, 33 | {"ER_X_INVALID_PROTOCOL_DATA", ER_X_INVALID_PROTOCOL_DATA, ""}, 34 | {"ER_X_SERVICE_ERROR", ER_X_SERVICE_ERROR, ""}, 35 | {"ER_X_SESSION", ER_X_SESSION, ""}, 36 | {"ER_X_INVALID_ARGUMENT", ER_X_INVALID_ARGUMENT, ""}, 37 | {"ER_X_MISSING_ARGUMENT", ER_X_MISSING_ARGUMENT, ""}, 38 | {"ER_X_BAD_INSERT_DATA", ER_X_BAD_INSERT_DATA, ""}, 39 | {"ER_X_CMD_NUM_ARGUMENTS", ER_X_CMD_NUM_ARGUMENTS, ""}, 40 | {"ER_X_CMD_ARGUMENT_TYPE", ER_X_CMD_ARGUMENT_TYPE, ""}, 41 | {"ER_X_CMD_ARGUMENT_VALUE", ER_X_CMD_ARGUMENT_VALUE, ""}, 42 | {"ER_X_BAD_UPDATE_DATA", ER_X_BAD_UPDATE_DATA, ""}, 43 | {"ER_X_BAD_TYPE_OF_UPDATE", ER_X_BAD_TYPE_OF_UPDATE, ""}, 44 | {"ER_X_BAD_COLUMN_TO_UPDATE", ER_X_BAD_COLUMN_TO_UPDATE, ""}, 45 | {"ER_X_BAD_MEMBER_TO_UPDATE", ER_X_BAD_MEMBER_TO_UPDATE, ""}, 46 | {"ER_X_BAD_STATEMENT_ID", ER_X_BAD_STATEMENT_ID, ""}, 47 | {"ER_X_BAD_CURSOR_ID", ER_X_BAD_CURSOR_ID, ""}, 48 | {"ER_X_BAD_SCHEMA", ER_X_BAD_SCHEMA, ""}, 49 | {"ER_X_BAD_TABLE", ER_X_BAD_TABLE, ""}, 50 | {"ER_X_BAD_PROJECTION", ER_X_BAD_PROJECTION, ""}, 51 | {"ER_X_DOC_ID_MISSING", ER_X_DOC_ID_MISSING, ""}, 52 | {"ER_X_DOC_ID_DUPLICATE", ER_X_DOC_ID_DUPLICATE, ""}, 53 | {"ER_X_DOC_REQUIRED_FIELD_MISSING", ER_X_DOC_REQUIRED_FIELD_MISSING, ""}, 54 | {"ER_X_PROJ_BAD_KEY_NAME", ER_X_PROJ_BAD_KEY_NAME, ""}, 55 | {"ER_X_BAD_DOC_PATH", ER_X_BAD_DOC_PATH, ""}, 56 | {"ER_X_CURSOR_EXISTS", ER_X_CURSOR_EXISTS, ""}, 57 | {"ER_X_EXPR_BAD_OPERATOR", ER_X_EXPR_BAD_OPERATOR, ""}, 58 | {"ER_X_EXPR_BAD_NUM_ARGS", ER_X_EXPR_BAD_NUM_ARGS, ""}, 59 | {"ER_X_EXPR_MISSING_ARG", ER_X_EXPR_MISSING_ARG, ""}, 60 | {"ER_X_EXPR_BAD_TYPE_VALUE", ER_X_EXPR_BAD_TYPE_VALUE, ""}, 61 | {"ER_X_EXPR_BAD_VALUE", ER_X_EXPR_BAD_VALUE, ""}, 62 | {"ER_X_INVALID_COLLECTION", ER_X_INVALID_COLLECTION, ""}, 63 | {"ER_X_INVALID_ADMIN_COMMAND", ER_X_INVALID_ADMIN_COMMAND, ""}, 64 | {"ER_X_EXPECT_NOT_OPEN", ER_X_EXPECT_NOT_OPEN, ""}, 65 | {"ER_X_EXPECT_FAILED", ER_X_EXPECT_FAILED, ""}, 66 | {"ER_X_EXPECT_BAD_CONDITION", ER_X_EXPECT_BAD_CONDITION, ""}, 67 | {"ER_X_EXPECT_BAD_CONDITION_VALUE", ER_X_EXPECT_BAD_CONDITION_VALUE, ""}, 68 | {"ER_X_INVALID_NAMESPACE", ER_X_INVALID_NAMESPACE, ""}, 69 | {"ER_X_BAD_NOTICE", ER_X_BAD_NOTICE, ""}, 70 | {"ER_X_CANNOT_DISABLE_NOTICE", ER_X_CANNOT_DISABLE_NOTICE, ""}, 71 | {"ER_X_BAD_CONFIGURATION", ER_X_BAD_CONFIGURATION, ""}, 72 | {"ER_X_MYSQLX_ACCOUNT_MISSING_PERMISSIONS", ER_X_MYSQLX_ACCOUNT_MISSING_PERMISSIONS, ""}, 73 | 74 | -------------------------------------------------------------------------------- /vendor/mysql/include/mysqlx_error.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License, version 2.0, for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 22 | 23 | 24 | #ifndef _MYSQLX_ERROR_H_ 25 | #define _MYSQLX_ERROR_H_ 26 | 27 | #define ER_X_BAD_MESSAGE 5000 28 | #define ER_X_CAPABILITIES_PREPARE_FAILED 5001 29 | #define ER_X_CAPABILITY_NOT_FOUND 5002 30 | #define ER_X_INVALID_PROTOCOL_DATA 5003 31 | 32 | #define ER_X_SERVICE_ERROR 5010 33 | #define ER_X_SESSION 5011 34 | #define ER_X_INVALID_ARGUMENT 5012 35 | #define ER_X_MISSING_ARGUMENT 5013 36 | #define ER_X_BAD_INSERT_DATA 5014 37 | #define ER_X_CMD_NUM_ARGUMENTS 5015 38 | #define ER_X_CMD_ARGUMENT_TYPE 5016 39 | #define ER_X_CMD_ARGUMENT_VALUE 5017 40 | #define ER_X_BAD_UPDATE_DATA 5050 41 | #define ER_X_BAD_TYPE_OF_UPDATE 5051 42 | #define ER_X_BAD_COLUMN_TO_UPDATE 5052 43 | #define ER_X_BAD_MEMBER_TO_UPDATE 5053 44 | #define ER_X_BAD_STATEMENT_ID 5110 45 | #define ER_X_BAD_CURSOR_ID 5111 46 | #define ER_X_BAD_SCHEMA 5112 47 | #define ER_X_BAD_TABLE 5113 48 | #define ER_X_BAD_PROJECTION 5114 49 | #define ER_X_DOC_ID_MISSING 5115 50 | #define ER_X_DOC_ID_DUPLICATE 5116 51 | #define ER_X_DOC_REQUIRED_FIELD_MISSING 5117 52 | #define ER_X_PROJ_BAD_KEY_NAME 5120 53 | #define ER_X_BAD_DOC_PATH 5121 54 | #define ER_X_CURSOR_EXISTS 5122 55 | #define ER_X_EXPR_BAD_OPERATOR 5150 56 | #define ER_X_EXPR_BAD_NUM_ARGS 5151 57 | #define ER_X_EXPR_MISSING_ARG 5152 58 | #define ER_X_EXPR_BAD_TYPE_VALUE 5153 59 | #define ER_X_EXPR_BAD_VALUE 5154 60 | #define ER_X_INVALID_COLLECTION 5156 61 | #define ER_X_INVALID_ADMIN_COMMAND 5157 62 | #define ER_X_EXPECT_NOT_OPEN 5158 63 | #define ER_X_EXPECT_FAILED 5159 64 | #define ER_X_EXPECT_BAD_CONDITION 5160 65 | #define ER_X_EXPECT_BAD_CONDITION_VALUE 5161 66 | #define ER_X_INVALID_NAMESPACE 5162 67 | #define ER_X_BAD_NOTICE 5163 68 | #define ER_X_CANNOT_DISABLE_NOTICE 5164 69 | #define ER_X_BAD_CONFIGURATION 5165 70 | #define ER_X_MYSQLX_ACCOUNT_MISSING_PERMISSIONS 5167 71 | 72 | #endif // _MYSQLX_ERROR_H_ 73 | -------------------------------------------------------------------------------- /vendor/mysql/include/mysqlx_version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, 2023, 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 23 | * 02110-1301 USA 24 | */ 25 | 26 | /* Version numbers for X Plugin */ 27 | 28 | #ifndef _MYSQLX_VERSION_H_ 29 | #define _MYSQLX_VERSION_H_ 30 | 31 | #define MYSQLX_PLUGIN_VERSION_MAJOR 1 32 | #define MYSQLX_PLUGIN_VERSION_MINOR 0 33 | #define MYSQLX_PLUGIN_VERSION_PATCH 2 34 | 35 | #define MYSQLX_PLUGIN_NAME "mysqlx" 36 | #define MYSQLX_STATUS_VARIABLE_PREFIX(NAME) "Mysqlx_" NAME 37 | #define MYSQLX_SYSTEM_VARIABLE_PREFIX(NAME) "mysqlx_" NAME 38 | 39 | #define MYSQLX_TCP_PORT 33060U 40 | #define MYSQLX_UNIX_ADDR "/tmp/mysqlx.sock" 41 | 42 | #define MYSQLX_PLUGIN_VERSION ( (MYSQLX_PLUGIN_VERSION_MAJOR << 8) | MYSQLX_PLUGIN_VERSION_MINOR ) 43 | #define MYSQLX_PLUGIN_VERSION_STRING "1.0.2" 44 | 45 | #endif // _MYSQLX_VERSION_H_ 46 | -------------------------------------------------------------------------------- /vendor/mysql/include/plugin_validate_password.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License, version 2.0, for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 22 | 23 | #ifndef MYSQL_PLUGIN_VALIDATE_PASSWORD_INCLUDED 24 | #define MYSQL_PLUGIN_VALIDATE_PASSWORD_INCLUDED 25 | 26 | /* API for validate_password plugin. (MYSQL_VALIDATE_PASSWORD_PLUGIN) */ 27 | 28 | #include 29 | #define MYSQL_VALIDATE_PASSWORD_INTERFACE_VERSION 0x0100 30 | 31 | /* 32 | The descriptor structure for the plugin, that is referred from 33 | st_mysql_plugin. 34 | */ 35 | 36 | typedef void* mysql_string_handle; 37 | 38 | struct st_mysql_validate_password 39 | { 40 | int interface_version; 41 | /* 42 | This function retuns TRUE for passwords which satisfy the password 43 | policy (as choosen by plugin variable) and FALSE for all other 44 | password 45 | */ 46 | int (*validate_password)(mysql_string_handle password); 47 | /* 48 | This function returns the password strength (0-100) depending 49 | upon the policies 50 | */ 51 | int (*get_password_strength)(mysql_string_handle password); 52 | }; 53 | #endif 54 | -------------------------------------------------------------------------------- /vendor/mysql/include/sslopt-case.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2000, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License, version 2.0, for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 22 | 23 | #if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) 24 | 25 | #ifndef MYSQL_CLIENT 26 | #error This header is supposed to be used only in the client 27 | #endif 28 | 29 | case OPT_SSL_MODE: 30 | opt_ssl_mode= find_type_or_exit(argument, &ssl_mode_typelib, 31 | opt->name); 32 | ssl_mode_set_explicitly= TRUE; 33 | break; 34 | case OPT_SSL_SSL: 35 | CLIENT_WARN_DEPRECATED("--ssl", "--ssl-mode"); 36 | if (!opt_use_ssl_arg) 37 | opt_ssl_mode= SSL_MODE_DISABLED; 38 | else if (opt_ssl_mode < SSL_MODE_REQUIRED) 39 | opt_ssl_mode= SSL_MODE_REQUIRED; 40 | break; 41 | case OPT_SSL_VERIFY_SERVER_CERT: 42 | CLIENT_WARN_DEPRECATED("--ssl-verify-server-cert", 43 | "--ssl-mode=VERIFY_IDENTITY"); 44 | if (!opt_ssl_verify_server_cert_arg) 45 | { 46 | if (opt_ssl_mode >= SSL_MODE_VERIFY_IDENTITY) 47 | opt_ssl_mode= SSL_MODE_VERIFY_CA; 48 | } 49 | else 50 | opt_ssl_mode= SSL_MODE_VERIFY_IDENTITY; 51 | break; 52 | case OPT_SSL_CA: 53 | case OPT_SSL_CAPATH: 54 | /* Don't change ssl-mode if set explicitly. */ 55 | if (!ssl_mode_set_explicitly) 56 | opt_ssl_mode= SSL_MODE_VERIFY_CA; 57 | break; 58 | case OPT_SSL_KEY: 59 | case OPT_SSL_CERT: 60 | case OPT_SSL_CIPHER: 61 | case OPT_SSL_CRL: 62 | case OPT_SSL_CRLPATH: 63 | case OPT_TLS_VERSION: 64 | break; 65 | #endif /* HAVE_OPENSSL */ 66 | -------------------------------------------------------------------------------- /vendor/mysql/include/sslopt-longopts.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2000, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License, version 2.0, for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 22 | 23 | #if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) 24 | #ifdef MYSQL_CLIENT 25 | {"ssl-mode", OPT_SSL_MODE, 26 | "SSL connection mode.", 27 | 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 28 | {"ssl", OPT_SSL_SSL, 29 | "Deprecated. Use --ssl-mode instead.", 30 | &opt_use_ssl_arg, &opt_use_ssl_arg, 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0}, 31 | {"ssl-verify-server-cert", OPT_SSL_VERIFY_SERVER_CERT, 32 | "Deprecated. Use --ssl-mode=VERIFY_IDENTITY instead.", 33 | &opt_ssl_verify_server_cert_arg, &opt_ssl_verify_server_cert_arg, 34 | 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0}, 35 | #else 36 | {"ssl", OPT_SSL_SSL, 37 | "If set to ON, this option enforces that SSL is established before client " 38 | "attempts to authenticate to the server. To disable client SSL capabilities " 39 | "use --ssl=OFF.", 40 | &opt_use_ssl, &opt_use_ssl, 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0}, 41 | #endif 42 | {"ssl-ca", OPT_SSL_CA, 43 | "CA file in PEM format.", 44 | &opt_ssl_ca, &opt_ssl_ca, 0, GET_STR, REQUIRED_ARG, 45 | 0, 0, 0, 0, 0, 0}, 46 | {"ssl-capath", OPT_SSL_CAPATH, 47 | "CA directory.", 48 | &opt_ssl_capath, &opt_ssl_capath, 0, GET_STR, REQUIRED_ARG, 49 | 0, 0, 0, 0, 0, 0}, 50 | {"ssl-cert", OPT_SSL_CERT, "X509 cert in PEM format.", 51 | &opt_ssl_cert, &opt_ssl_cert, 0, GET_STR, REQUIRED_ARG, 52 | 0, 0, 0, 0, 0, 0}, 53 | {"ssl-cipher", OPT_SSL_CIPHER, "SSL cipher to use.", 54 | &opt_ssl_cipher, &opt_ssl_cipher, 0, GET_STR, REQUIRED_ARG, 55 | 0, 0, 0, 0, 0, 0}, 56 | {"ssl-key", OPT_SSL_KEY, "X509 key in PEM format.", 57 | &opt_ssl_key, &opt_ssl_key, 0, GET_STR, REQUIRED_ARG, 58 | 0, 0, 0, 0, 0, 0}, 59 | {"ssl-crl", OPT_SSL_CRL, "Certificate revocation list.", 60 | &opt_ssl_crl, &opt_ssl_crl, 0, GET_STR, REQUIRED_ARG, 61 | 0, 0, 0, 0, 0, 0}, 62 | {"ssl-crlpath", OPT_SSL_CRLPATH, 63 | "Certificate revocation list path.", 64 | &opt_ssl_crlpath, &opt_ssl_crlpath, 0, GET_STR, REQUIRED_ARG, 65 | 0, 0, 0, 0, 0, 0}, 66 | {"tls-version", OPT_TLS_VERSION, "TLS version to use, " 67 | "permitted values are: TLSv1, TLSv1.1, TLSv1.2", 68 | &opt_tls_version, &opt_tls_version, 0, GET_STR, REQUIRED_ARG, 69 | 0, 0, 0, 0, 0, 0}, 70 | #endif /* HAVE_OPENSSL */ 71 | -------------------------------------------------------------------------------- /vendor/mysql/include/sslopt-vars.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2000, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License, version 2.0, for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 22 | 23 | #ifndef SSLOPT_VARS_INCLUDED 24 | #define SSLOPT_VARS_INCLUDED 25 | 26 | #if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) 27 | 28 | #ifndef MYSQL_CLIENT 29 | #error This header is supposed to be used only in the client 30 | #endif 31 | 32 | const char *ssl_mode_names_lib[] = 33 | {"DISABLED", "PREFERRED", "REQUIRED", "VERIFY_CA", "VERIFY_IDENTITY", 34 | NullS }; 35 | TYPELIB ssl_mode_typelib = {array_elements(ssl_mode_names_lib) - 1, "", 36 | ssl_mode_names_lib, NULL}; 37 | 38 | static uint opt_ssl_mode = SSL_MODE_PREFERRED; 39 | static char *opt_ssl_ca = 0; 40 | static char *opt_ssl_capath = 0; 41 | static char *opt_ssl_cert = 0; 42 | static char *opt_ssl_cipher = 0; 43 | static char *opt_ssl_key = 0; 44 | static char *opt_ssl_crl = 0; 45 | static char *opt_ssl_crlpath = 0; 46 | static char *opt_tls_version = 0; 47 | static my_bool ssl_mode_set_explicitly= FALSE; 48 | static my_bool opt_use_ssl_arg= TRUE; 49 | static my_bool opt_ssl_verify_server_cert_arg= FALSE; 50 | 51 | static void set_client_ssl_options(MYSQL *mysql) 52 | { 53 | /* 54 | Print a warning if explicitly defined combination of --ssl-mode other than 55 | VERIFY_CA or VERIFY_IDENTITY with explicit --ssl-ca or --ssl-capath values. 56 | */ 57 | if (ssl_mode_set_explicitly && 58 | opt_ssl_mode < SSL_MODE_VERIFY_CA && 59 | (opt_ssl_ca || opt_ssl_capath)) 60 | { 61 | fprintf(stderr, "WARNING: no verification of server certificate will be done. " 62 | "Use --ssl-mode=VERIFY_CA or VERIFY_IDENTITY.\n"); 63 | } 64 | 65 | /* Set SSL parameters: key, cert, ca, capath, cipher, clr, clrpath. */ 66 | if (opt_ssl_mode >= SSL_MODE_VERIFY_CA) 67 | mysql_ssl_set(mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca, 68 | opt_ssl_capath, opt_ssl_cipher); 69 | else 70 | mysql_ssl_set(mysql, opt_ssl_key, opt_ssl_cert, NULL, 71 | NULL, opt_ssl_cipher); 72 | mysql_options(mysql, MYSQL_OPT_SSL_CRL, opt_ssl_crl); 73 | mysql_options(mysql, MYSQL_OPT_SSL_CRLPATH, opt_ssl_crlpath); 74 | mysql_options(mysql, MYSQL_OPT_TLS_VERSION, opt_tls_version); 75 | mysql_options(mysql, MYSQL_OPT_SSL_MODE, &opt_ssl_mode); 76 | } 77 | 78 | #define SSL_SET_OPTIONS(mysql) set_client_ssl_options(mysql); 79 | #else 80 | #define SSL_SET_OPTIONS(mysql) do { } while(0) 81 | #endif 82 | #endif /* SSLOPT_VARS_INCLUDED */ 83 | -------------------------------------------------------------------------------- /vendor/mysql/include/typelib.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2000, 2023, Oracle and/or its affiliates. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License, version 2.0, 5 | as published by the Free Software Foundation. 6 | 7 | This program is also distributed with certain software (including 8 | but not limited to OpenSSL) that is licensed under separate terms, 9 | as designated in a particular file or component or in included license 10 | documentation. The authors of MySQL hereby grant you an additional 11 | permission to link the program and your derivative works with the 12 | separately licensed software that they have included with MySQL. 13 | 14 | Without limiting anything contained in the foregoing, this file, 15 | which is part of C Driver for MySQL (Connector/C), is also subject to the 16 | Universal FOSS Exception, version 1.0, a copy of which can be found at 17 | http://oss.oracle.com/licenses/universal-foss-exception. 18 | 19 | This program is distributed in the hope that it will be useful, 20 | but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | GNU General Public License, version 2.0, for more details. 23 | 24 | You should have received a copy of the GNU General Public License 25 | along with this program; if not, write to the Free Software 26 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ 27 | 28 | 29 | #ifndef _typelib_h 30 | #define _typelib_h 31 | 32 | #include "my_alloc.h" 33 | 34 | typedef struct st_typelib { /* Different types saved here */ 35 | unsigned int count; /* How many types */ 36 | const char *name; /* Name of typelib */ 37 | const char **type_names; 38 | unsigned int *type_lengths; 39 | } TYPELIB; 40 | 41 | extern my_ulonglong find_typeset(char *x, TYPELIB *typelib,int *error_position); 42 | extern int find_type_or_exit(const char *x, TYPELIB *typelib, 43 | const char *option); 44 | #define FIND_TYPE_BASIC 0 45 | /** makes @c find_type() require the whole name, no prefix */ 46 | #define FIND_TYPE_NO_PREFIX (1 << 0) 47 | /** always implicitely on, so unused, but old code may pass it */ 48 | #define FIND_TYPE_NO_OVERWRITE (1 << 1) 49 | /** makes @c find_type() accept a number */ 50 | #define FIND_TYPE_ALLOW_NUMBER (1 << 2) 51 | /** makes @c find_type() treat ',' as terminator */ 52 | #define FIND_TYPE_COMMA_TERM (1 << 3) 53 | 54 | extern int find_type(const char *x, const TYPELIB *typelib, unsigned int flags); 55 | extern void make_type(char *to,unsigned int nr,TYPELIB *typelib); 56 | extern const char *get_type(TYPELIB *typelib,unsigned int nr); 57 | extern TYPELIB *copy_typelib(MEM_ROOT *root, TYPELIB *from); 58 | 59 | extern TYPELIB sql_protocol_typelib; 60 | 61 | my_ulonglong find_set_from_flags(const TYPELIB *lib, unsigned int default_name, 62 | my_ulonglong cur_set, my_ulonglong default_set, 63 | const char *str, unsigned int length, 64 | char **err_pos, unsigned int *err_len); 65 | 66 | #endif /* _typelib_h */ 67 | -------------------------------------------------------------------------------- /vendor/mysql/lib/mysqlclient.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zer0k-z/sql_mm/61703ed430332ebdef2b2d14332fc91320b25013/vendor/mysql/lib/mysqlclient.lib --------------------------------------------------------------------------------