mirror of
https://github.com/SphereServer/Source
synced 2026-08-13 10:26:05 -04:00
Updated internal MySQL libs v6.1.10 (MySQL client 5.7.16) to v8.0.46
> [!IMPORTANT] > It's HIGHLY recommended to update MySQL client library to prevent errors when using MySQL > - Windows: replace file `libmysql.dll` with the version included in the downloaded zip > - Linux: > - Debian-based: update package `libmysqlclient20` to `libmysqlclient21` using `sudo apt-get install libmysqlclient21` > - RHEL-based: switch MySQL module stream to v8.0 using `sudo dnf module switch-to mysql:8.0`
This commit is contained in:
parent
6f02c1da16
commit
367f1be296
82 changed files with 7858 additions and 20588 deletions
34
.github/workflows/ci-cd.yml
vendored
34
.github/workflows/ci-cd.yml
vendored
|
|
@ -33,16 +33,16 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@54f647b7e1bb85c95cddabcd46b0c578ec92bc1a # v4.36.3
|
||||
uses: github/codeql-action/init@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3
|
||||
with:
|
||||
languages: actions
|
||||
queries: security-extended
|
||||
|
||||
- name: Perform CodeQL analysis
|
||||
uses: github/codeql-action/analyze@54f647b7e1bb85c95cddabcd46b0c578ec92bc1a # v4.36.3
|
||||
uses: github/codeql-action/analyze@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3
|
||||
with:
|
||||
category: "GitHub Actions"
|
||||
|
||||
|
|
@ -96,12 +96,12 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
fetch-depth: 0 # fetch full history to calculate build number
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@54f647b7e1bb85c95cddabcd46b0c578ec92bc1a # v4.36.3
|
||||
uses: github/codeql-action/init@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3
|
||||
with:
|
||||
languages: c-cpp
|
||||
build-mode: manual
|
||||
|
|
@ -109,16 +109,8 @@ jobs:
|
|||
- name: Set up environment (Linux)
|
||||
if: runner.os == 'Linux'
|
||||
run: |
|
||||
# Remove MySQL 8.0 pre-installed packages
|
||||
sudo apt-get -q remove libmysqlclient-dev
|
||||
|
||||
# Add MySQL 5.7 support to the package repository
|
||||
sudo gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mysql.gpg --keyserver keyserver.ubuntu.com --recv-keys B7B3B788A8D3785C
|
||||
echo "deb [signed-by=/usr/share/keyrings/mysql.gpg] https://repo.mysql.com/apt/ubuntu/ bionic mysql-5.7" | sudo tee /etc/apt/sources.list.d/mysql.list > /dev/null
|
||||
sudo apt-get -qq update
|
||||
|
||||
# Install MySQL 5.7 package
|
||||
sudo apt-get -q install libmysqlclient-dev=5.7*
|
||||
# Ensure MySQL client library is v8.0
|
||||
sudo apt-get -q install libmysqlclient-dev=8.0*
|
||||
|
||||
- name: Set up environment (Windows)
|
||||
if: runner.os == 'Windows'
|
||||
|
|
@ -171,7 +163,7 @@ jobs:
|
|||
fi
|
||||
|
||||
- name: Perform CodeQL analysis
|
||||
uses: github/codeql-action/analyze@54f647b7e1bb85c95cddabcd46b0c578ec92bc1a # v4.36.3
|
||||
uses: github/codeql-action/analyze@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3
|
||||
with:
|
||||
category: "${{ runner.os }} build (${{ runner.arch }})"
|
||||
|
||||
|
|
@ -190,7 +182,7 @@ jobs:
|
|||
-src/common/*/**
|
||||
|
||||
- name: Upload CodeQL results
|
||||
uses: github/codeql-action/upload-sarif@54f647b7e1bb85c95cddabcd46b0c578ec92bc1a # v4.36.3
|
||||
uses: github/codeql-action/upload-sarif@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3
|
||||
with:
|
||||
sarif_file: "${{ env.CODEQL_ACTION_SARIF_RESULTS_OUTPUT_DIR }}/${{ env.CODEQL_TRACER_LANGUAGES }}.sarif"
|
||||
|
||||
|
|
@ -211,7 +203,7 @@ jobs:
|
|||
if [[ "${{ matrix.build-type }}" == "Debug" ]]; then
|
||||
PDB_FILE="./x64/${{ matrix.build-type }}/SphereSvr.pdb"
|
||||
fi
|
||||
7z a -bb1 "artifacts/${ARTIFACT_NAME}-Win64.zip" ${COMMON_DIRS} "./x64/${{ matrix.build-type }}/SphereSvr.exe" ${PDB_FILE} ./src/sphere.ini ./src/sphereCrypt.ini ./src/common/mysql/lib/x64/libmysql.dll
|
||||
7z a -bb1 "artifacts/${ARTIFACT_NAME}-Win64.zip" ${COMMON_DIRS} "./x64/${{ matrix.build-type }}/SphereSvr.exe" ${PDB_FILE} ./src/sphere.ini ./src/sphereCrypt.ini ./src/common/mysql/lib/libmysql.dll
|
||||
fi
|
||||
|
||||
- name: Upload artifact to blob storage
|
||||
|
|
@ -238,7 +230,7 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
|
||||
- name: Download artifacts from blob storage
|
||||
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
||||
|
|
@ -260,7 +252,7 @@ jobs:
|
|||
TITLE="v${BUILD_VERSION_DISPLAY} (build ${BUILD_NUMBER})"
|
||||
|
||||
NOTES_FILE=$(mktemp)
|
||||
printf '%s\n' "${COMMIT_MSG}" > "${NOTES_FILE}"
|
||||
printf '%s' "${COMMIT_MSG}" > "${NOTES_FILE}"
|
||||
|
||||
SCRIPT_PACK_REPOSITORY="${GITHUB_REPOSITORY_OWNER}/Scripts"
|
||||
if SCRIPT_PACK_COMMIT_SHA=$(gh api "repos/${SCRIPT_PACK_REPOSITORY}/commits/master" --jq '.sha' 2>/dev/null); then
|
||||
|
|
@ -281,7 +273,7 @@ jobs:
|
|||
fi
|
||||
done
|
||||
else
|
||||
echo "::notice::Script pack repository '${SCRIPT_PACK_REPOSITORY}' not found"
|
||||
echo "::notice::Cannot attach script pack to the GitHub release because the repository '${SCRIPT_PACK_REPOSITORY}' is missing"
|
||||
fi
|
||||
|
||||
# Clean up stale releases (keep only 100 most recent)
|
||||
|
|
|
|||
166
README.md
166
README.md
|
|
@ -4,143 +4,93 @@ Ultima Online game server, developed in C++
|
|||
|
||||
## Download
|
||||
|
||||
* [GitHub Releases](../../releases)
|
||||
* [SphereServer website](https://forum.spherecommunity.net/sshare.php?srt=4)
|
||||
- [GitHub Releases](../../releases)
|
||||
- [SphereServer Forum](https://forum.spherecommunity.net/sshare.php?srt=4)
|
||||
|
||||
> [!NOTE]
|
||||
> Recommended OS for pre-compiled builds:
|
||||
> - Windows: Windows 10 or later, Windows Server 2016 or later
|
||||
> - Linux: Debian 12 or later, Ubuntu 22.04 or later (requires MySQL client library installed)
|
||||
|
||||
> [!IMPORTANT]
|
||||
> For maximum security, only download builds from official sources and verify the file SHA-256 checksum using the system terminal:
|
||||
> * Windows (PowerShell): `Get-FileHash "path/to/file"`
|
||||
> * Linux: `sha256sum "path/to/file"`
|
||||
> To ensure file integrity, only download builds from official sources and verify the SHA-256 checksum using the system terminal:
|
||||
> - Windows: `certutil -hashfile "path/to/file" SHA256`
|
||||
> - Linux: `sha256sum "path/to/file"`
|
||||
|
||||
## Building on Windows (Visual Studio)
|
||||
|
||||
* Open the project file `SphereSvr.vcxproj` using Visual Studio
|
||||
* On top menu, select the build configuration (Debug/Nightly/Release) and click on `Build > Build Solution` to compile
|
||||
### System requirements
|
||||
|
||||
### Requirements:
|
||||
- OS: Windows 10 or later, Windows Server 2016 or later
|
||||
- IDE: Visual Studio 2022 or later (VS Code is not supported)
|
||||
|
||||
* Windows 10 or later / Windows Server 2016 or later
|
||||
* Visual Studio 2022 or later (VS Code is not supported)
|
||||
* Open `Visual Studio Installer` menu, click on "Modify" and install these components:
|
||||
* Workload: `Desktop Development with C++`
|
||||
* Individual component: `MSVC v143 - VS 2022 C++ x64/x86 build tools`
|
||||
### Set up environment
|
||||
|
||||
Open `Visual Studio Installer`, click on `Modify`, and install the following components:
|
||||
- Workload: `Desktop Development with C++`
|
||||
- Individual component: `MSVC v143 - VS 2022 C++ x64/x86 build tools`
|
||||
|
||||
> [!NOTE]
|
||||
> The project uses `MSVC v143` from VS 2022 for backward compatibility. When using VS newer than 2022, you can either choose to update the project on `Project > Retarget solution` to use the latest version already installed (e.g., `MSVC v145` from VS 2026), or install the `MSVC v143` individual component and safely ignore the message requesting an update to the latest version
|
||||
> The project uses `MSVC v143` platform toolset from VS 2022 for backward compatibility. When opening the project file for the first time using a newer VS, it will request to retarget the project platform toolset to the latest version already installed (e.g., `MSVC v145` from VS 2026). You can either choose to retarget it, or install the `MSVC v143` individual component and safely ignore the request
|
||||
|
||||
### Build the project
|
||||
|
||||
- Open the project file `SphereSvr.vcxproj` using Visual Studio
|
||||
- On the top menu, select the build configuration (`Debug`/`Nightly`/`Release`) and click on `Build > Build Solution`
|
||||
|
||||
## Building on Linux (GCC)
|
||||
|
||||
### Set up environment
|
||||
|
||||
<details>
|
||||
#### Debian-based (Debian 11 or later, Ubuntu 20.04 or later)
|
||||
|
||||
<summary>Ubuntu 14.04 or later (click to expand)</summary>
|
||||
1. Add MySQL 8.0 support to the package repository (only required for Debian 11 or later, Ubuntu 26.04 or later):
|
||||
```
|
||||
curl -fL https://dev.mysql.com/get/mysql-apt-config_0.8.39-1_all.deb -o mysql-apt-config.deb
|
||||
echo "mysql-apt-config mysql-apt-config/select-server select mysql-8.0" | sudo debconf-set-selections
|
||||
sudo DEBIAN_FRONTEND=noninteractive dpkg -i mysql-apt-config.deb
|
||||
sudo apt-get update
|
||||
rm mysql-apt-config.deb
|
||||
```
|
||||
|
||||
#### Add MySQL 5.7 support
|
||||
2. Install required packages:
|
||||
```
|
||||
sudo apt-get install git gcc g++ make libmysqlclient-dev=8.0*
|
||||
```
|
||||
|
||||
* Ubuntu 14.04:
|
||||
* Add MySQL 5.7 support to the package repository
|
||||
```
|
||||
sudo gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mysql.gpg --keyserver keyserver.ubuntu.com --recv-keys B7B3B788A8D3785C
|
||||
echo "deb [signed-by=/usr/share/keyrings/mysql.gpg] https://repo.mysql.com/apt/ubuntu/ bionic mysql-5.7" | sudo tee /etc/apt/sources.list.d/mysql.list > /dev/null
|
||||
sudo apt-get update
|
||||
```
|
||||
* Ubuntu 16.04 to 18.04:
|
||||
* > Skip this step (MySQL 5.7 is already supported)
|
||||
* Ubuntu 20.04 or later:
|
||||
* Remove default MySQL package
|
||||
```
|
||||
sudo apt-get -q remove libmysqlclient-dev
|
||||
```
|
||||
* Add MySQL 5.7 support to the package repository
|
||||
```
|
||||
sudo gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mysql.gpg --keyserver keyserver.ubuntu.com --recv-keys B7B3B788A8D3785C
|
||||
echo "deb [signed-by=/usr/share/keyrings/mysql.gpg] https://repo.mysql.com/apt/ubuntu/ bionic mysql-5.7" | sudo tee /etc/apt/sources.list.d/mysql.list > /dev/null
|
||||
sudo apt-get update
|
||||
```
|
||||
#### RHEL-based (RHEL, Rocky Linux, AlmaLinux, Oracle Linux) 8 or later
|
||||
|
||||
#### Install required packages
|
||||
1. Enable MySQL 8.0 module stream:
|
||||
```
|
||||
sudo dnf module enable mysql:8.0
|
||||
```
|
||||
|
||||
```
|
||||
sudo apt-get install git gcc g++ make libmysqlclient-dev=5.7*
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
|
||||
<summary>RHEL 6 / Oracle Linux 6 / CentOS 6 or later (click to expand)</summary>
|
||||
|
||||
#### Add MySQL support
|
||||
|
||||
* Add MySQL support to the package repository
|
||||
* RHEL 6 / Oracle Linux 6 / CentOS 6:
|
||||
```
|
||||
sudo yum localinstall https://dev.mysql.com/get/mysql80-community-release-el6-11.noarch.rpm
|
||||
```
|
||||
* RHEL 7 / Oracle Linux 7 / CentOS 7:
|
||||
```
|
||||
sudo yum localinstall https://dev.mysql.com/get/mysql84-community-release-el7-4.noarch.rpm
|
||||
```
|
||||
* RHEL 8 / Oracle Linux 8 / CentOS 8:
|
||||
```
|
||||
sudo yum localinstall https://dev.mysql.com/get/mysql84-community-release-el8-3.noarch.rpm
|
||||
sudo yum module disable mysql
|
||||
```
|
||||
* RHEL 9 / Oracle Linux 9 / CentOS 9:
|
||||
```
|
||||
sudo yum localinstall https://dev.mysql.com/get/mysql84-community-release-el9-4.noarch.rpm
|
||||
sudo yum module disable mysql
|
||||
```
|
||||
* RHEL 10 / Oracle Linux 10 / CentOS 10:
|
||||
```
|
||||
sudo yum localinstall https://dev.mysql.com/get/mysql84-community-release-el10-3.noarch.rpm
|
||||
sudo yum module disable mysql
|
||||
```
|
||||
|
||||
* Enable MySQL 5.7 in the package repository
|
||||
```
|
||||
sudo yum-config-manager --disable mysql-8.4-lts-community
|
||||
sudo yum-config-manager --disable mysql80-community
|
||||
sudo yum-config-manager --enable mysql57-community
|
||||
```
|
||||
|
||||
#### Install required packages
|
||||
|
||||
```
|
||||
sudo yum install git gcc-c++ glibc-devel mysql-community-devel
|
||||
```
|
||||
|
||||
</details>
|
||||
2. Install required packages:
|
||||
```
|
||||
sudo dnf install git gcc-c++ glibc-devel mysql-devel
|
||||
```
|
||||
|
||||
### Get the source code
|
||||
|
||||
```
|
||||
git clone https://github.com/SphereServer/Source.git
|
||||
git clone https://github.com/Sphereserver/Source.git
|
||||
cd Source
|
||||
```
|
||||
|
||||
### Compile the source code
|
||||
### Build the project
|
||||
|
||||
* To compile Debug build:
|
||||
```
|
||||
make DEBUG=1
|
||||
```
|
||||
* To compile Nightly build:
|
||||
```
|
||||
make NIGHTLY=1
|
||||
```
|
||||
* To compile Release build:
|
||||
```
|
||||
make
|
||||
```
|
||||
| Build type | Command |
|
||||
| ---------- | ---------------- |
|
||||
| Debug | `make DEBUG=1` |
|
||||
| Nightly | `make NIGHTLY=1` |
|
||||
| Release | `make` |
|
||||
|
||||
## Coding notes for new contributors
|
||||
## Contributing
|
||||
|
||||
* Make sure you can compile and run the program before pushing a commit.
|
||||
* Rebasing instead of pulling the project is a better practice to avoid unnecessary "merge branch master" commits.
|
||||
* To keep backward compatibility, adding/removing/changing anything that was working in one way for years should be followed by an .ini setting when the changes can't be replicated on scripts.
|
||||
* Prefer using C++ named casts (`static_cast<type>(expression)`, `dynamic_cast<type>(expression)`, `const_cast<type>(expression)`, `reinterpret_cast<type>(expression)`) over C-style casts (`(type)expression`) to make sure that invalid casts will throw a compiler error to get fixed at compile-time, preventing the compiler from silently applying an unsafe cast that may throw a runtime error.
|
||||
- Make sure you can compile and run the program before pushing a commit.
|
||||
- Rebasing instead of pulling the project is a better practice to avoid unnecessary "merge branch master" commits.
|
||||
- To keep backward compatibility, adding/removing/changing anything that was working in one way for years should be followed by an .ini setting when the changes can't be replicated on scripts.
|
||||
- Prefer using C++ named casts (`static_cast<type>(expression)`, `dynamic_cast<type>(expression)`, `const_cast<type>(expression)`, `reinterpret_cast<type>(expression)`) over C-style casts (`(type)expression`) to ensure invalid casts will cause a compiler error to get fixed at compile time, preventing the compiler from applying an unsafe cast that may cause runtime errors.
|
||||
|
||||
## License
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>libmysql.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>src\common\mysql\lib\x64</AdditionalLibraryDirectories>
|
||||
<AdditionalLibraryDirectories>src\common\mysql\lib</AdditionalLibraryDirectories>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
</Link>
|
||||
|
|
|
|||
|
|
@ -1879,4 +1879,12 @@ Removed: Obsolete SHRINKMEM function (the OS already manages memory automaticall
|
|||
|
||||
21-07-2026, Coruja
|
||||
Changed: Updated internal Zlib libs v1.2.13 to v1.3.2.
|
||||
Changed: Updated internal SQLite libs v3.30.1 to v3.53.3.
|
||||
Changed: Updated internal SQLite libs v3.30.1 to v3.53.3.
|
||||
|
||||
24-07-2026, Coruja
|
||||
Changed: Updated internal MySQL libs v6.1.10 (MySQL client 5.7.16) to v8.0.46.
|
||||
-IMPORTANT: It's HIGHLY recommended to update MySQL client library to prevent errors when using MySQL
|
||||
-Windows: replace file 'libmysql.dll' with the version included in the downloaded zip
|
||||
-Linux:
|
||||
-Debian-based: update package 'libmysqlclient20' to 'libmysqlclient21' using 'sudo apt-get install libmysqlclient21'
|
||||
-RHEL-based: switch MySQL module stream to v8.0 using 'sudo dnf module switch-to mysql:8.0'
|
||||
|
|
@ -11,8 +11,7 @@ CDataBase::CDataBase()
|
|||
|
||||
CDataBase::~CDataBase()
|
||||
{
|
||||
if ( m_socket )
|
||||
Close();
|
||||
Close();
|
||||
}
|
||||
|
||||
void CDataBase::Connect()
|
||||
|
|
@ -22,43 +21,46 @@ void CDataBase::Connect()
|
|||
if ( m_socket )
|
||||
return;
|
||||
|
||||
#ifdef _WIN32
|
||||
if ( mysql_get_client_version() < LIBMYSQL_VERSION_ID )
|
||||
g_Log.EventWarn("Your MySQL client library %s is outdated. For better compatibility, update your 'libmysql.dll' file to version %s\n", mysql_get_client_info(), LIBMYSQL_VERSION);
|
||||
#else
|
||||
if ( mysql_get_client_version() < MYSQL_VERSION_ID )
|
||||
g_Log.EventWarn("Your MySQL client library %s is outdated. For better compatibility, update your 'libmysqlclient' (Ubuntu) / 'mysql-community-libs' (CentOS / Red Hat) package to version %s\n", mysql_get_client_info(), MYSQL_SERVER_VERSION);
|
||||
#endif
|
||||
|
||||
m_socket = mysql_init(NULL);
|
||||
if ( !m_socket )
|
||||
{
|
||||
g_Log.EventError("Insufficient memory to initialize MySQL client socket\n");
|
||||
g_Log.EventError("Failed to initialize MySQL client (out of memory)\n");
|
||||
return;
|
||||
}
|
||||
|
||||
const char *pszUser = g_Cfg.m_sMySqlUser;
|
||||
const char *pszPassword = g_Cfg.m_sMySqlPass;
|
||||
const char *pszDB = g_Cfg.m_sMySqlDB;
|
||||
const char *pszHost = g_Cfg.m_sMySqlHost;
|
||||
unsigned int uiPort = MYSQL_PORT;
|
||||
|
||||
// If user define server port using hostname:port format, split values into different variables
|
||||
const char *pszArgs = strchr(pszHost, ':');
|
||||
if ( pszArgs )
|
||||
if ( mysql_get_client_version() < LIBMYSQL_VERSION_ID )
|
||||
{
|
||||
char *pszTemp = Str_GetTemp();
|
||||
strncpy(pszTemp, pszHost, HOSTNAME_LENGTH);
|
||||
pszTemp[HOSTNAME_LENGTH - 1] = '\0';
|
||||
*(strchr(pszTemp, ':')) = '\0';
|
||||
uiPort = ATOI(pszArgs + 1);
|
||||
pszHost = pszTemp;
|
||||
#ifdef _WIN32
|
||||
const char *pszLibrary = "libmysql.dll file";
|
||||
#else
|
||||
const char *pszLibrary = "Debian-based: libmysqlclient21 package / RHEL-based: mysql-libs package";
|
||||
#endif
|
||||
g_Log.EventWarn("MySQL client v%s is outdated. For better compatibility, update MySQL client library to v%s (%s)\n", mysql_get_client_info(), LIBMYSQL_VERSION, pszLibrary);
|
||||
}
|
||||
|
||||
if ( mysql_real_connect(m_socket, pszHost, pszUser, pszPassword, pszDB, uiPort, NULL, CLIENT_MULTI_STATEMENTS) )
|
||||
bool fGetServerPublicKey = true;
|
||||
mysql_options(m_socket, MYSQL_OPT_GET_SERVER_PUBLIC_KEY, &fGetServerPublicKey);
|
||||
|
||||
char szHost[CONNECT_STRING_MAXLEN];
|
||||
strncpy(szHost, g_Cfg.m_sMySqlHost, COUNTOF(szHost));
|
||||
szHost[COUNTOF(szHost) - 1] = '\0';
|
||||
|
||||
unsigned int uPort = MYSQL_PORT;
|
||||
char *pszPort = strchr(szHost, ':');
|
||||
if ( pszPort )
|
||||
{
|
||||
*pszPort = '\0';
|
||||
uPort = static_cast<unsigned int>(ATOI(pszPort + 1));
|
||||
}
|
||||
|
||||
const char *pszUser = g_Cfg.m_sMySqlUser;
|
||||
const char *pszPass = g_Cfg.m_sMySqlPass;
|
||||
const char *pszDB = g_Cfg.m_sMySqlDB;
|
||||
|
||||
if ( mysql_real_connect(m_socket, szHost, pszUser, pszPass, pszDB, uPort, NULL, CLIENT_MULTI_STATEMENTS) )
|
||||
{
|
||||
if ( mysql_get_server_version(m_socket) < MYSQL_VERSION_ID )
|
||||
g_Log.EventWarn("Your MySQL server %s is outdated. For better compatibility, update your MySQL server to version %s\n", mysql_get_server_info(m_socket), MYSQL_SERVER_VERSION);
|
||||
g_Log.EventWarn("MySQL server v%s is outdated. For better compatibility, update MySQL server to v%s\n", mysql_get_server_info(m_socket), MYSQL_SERVER_VERSION);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -72,6 +74,9 @@ void CDataBase::Close()
|
|||
{
|
||||
ADDTOCALLSTACK("CDataBase::Close");
|
||||
SimpleThreadLock lock(m_connectionMutex);
|
||||
if ( !m_socket )
|
||||
return;
|
||||
|
||||
mysql_close(m_socket);
|
||||
m_socket = NULL;
|
||||
}
|
||||
|
|
@ -89,62 +94,87 @@ bool CDataBase::Query(LPCTSTR pszQuery, CVarDefMap &mapQueryResult)
|
|||
SimpleThreadLock lock(m_connectionMutex);
|
||||
|
||||
int iResultCode = mysql_query(m_socket, pszQuery);
|
||||
if ( iResultCode == 0 )
|
||||
if ( iResultCode != 0 )
|
||||
{
|
||||
MYSQL_RES *pResult = mysql_store_result(m_socket);
|
||||
if ( !pResult )
|
||||
return false;
|
||||
unsigned int uErrNum = mysql_errno(m_socket);
|
||||
g_Log.EventError("MySQL error #%u: %s [Cmd: \"%s\"]\n", uErrNum, mysql_error(m_socket), pszQuery);
|
||||
|
||||
unsigned int uiNumFields = mysql_num_fields(pResult);
|
||||
char key[64];
|
||||
if ( uiNumFields > COUNTOF(key) )
|
||||
{
|
||||
// This check is not really needed, MySQL client should be able to handle the same columns amount of MySQL server (4096).
|
||||
// But since this value is too big and create an 4096 char array at -every- query call is not performance-friendly, maybe
|
||||
// it's better just use an smaller array to prioritize performance.
|
||||
g_Log.EventError("MySQL query returned too many columns [Max: %" FMTSIZE_T " / Cmd: \"%s\"]\n", COUNTOF(key), pszQuery);
|
||||
mysql_free_result(pResult);
|
||||
return false;
|
||||
}
|
||||
|
||||
MYSQL_FIELD *pFields = mysql_fetch_fields(pResult);
|
||||
mapQueryResult.SetNum("NUMROWS", mysql_num_rows(pResult));
|
||||
mapQueryResult.SetNum("NUMCOLS", uiNumFields);
|
||||
|
||||
int iRowNum = 0;
|
||||
char **pRow = NULL;
|
||||
char *pszKey = Str_GetTemp();
|
||||
char *pszVal = NULL;
|
||||
while ( (pRow = mysql_fetch_row(pResult)) != NULL )
|
||||
{
|
||||
for ( unsigned int i = 0; i < uiNumFields; ++i )
|
||||
{
|
||||
pszVal = pRow[i];
|
||||
if ( !iRowNum )
|
||||
{
|
||||
mapQueryResult.SetStr(ITOA(i, key, 10), true, pszVal);
|
||||
mapQueryResult.SetStr(pFields[i].name, true, pszVal);
|
||||
}
|
||||
|
||||
snprintf(pszKey, 24, "%d.%u", iRowNum, i);
|
||||
mapQueryResult.SetStr(pszKey, true, pszVal);
|
||||
snprintf(pszKey, 76, "%d.%s", iRowNum, pFields[i].name);
|
||||
mapQueryResult.SetStr(pszKey, true, pszVal);
|
||||
}
|
||||
++iRowNum;
|
||||
}
|
||||
|
||||
mysql_free_result(pResult);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_Log.EventError("MySQL error #%u: %s [Cmd: \"%s\"]\n", mysql_errno(m_socket), mysql_error(m_socket), pszQuery);
|
||||
if ( (iResultCode == CR_SERVER_GONE_ERROR) || (iResultCode == CR_SERVER_LOST) )
|
||||
if ( (uErrNum == CR_SERVER_GONE_ERROR) || (uErrNum == CR_SERVER_LOST) )
|
||||
Close();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
MYSQL_RES *pResult = mysql_store_result(m_socket);
|
||||
if ( !pResult )
|
||||
{
|
||||
bool fNoFields = (mysql_field_count(m_socket) == 0);
|
||||
while ( mysql_next_result(m_socket) == 0 )
|
||||
{
|
||||
pResult = mysql_store_result(m_socket);
|
||||
if ( pResult )
|
||||
mysql_free_result(pResult);
|
||||
}
|
||||
return fNoFields;
|
||||
}
|
||||
|
||||
unsigned int uNumFields = mysql_num_fields(pResult);
|
||||
unsigned int uMaxFields = 100;
|
||||
if ( uNumFields > uMaxFields )
|
||||
{
|
||||
// MySQL client can handle the same column amount as MySQL server (4096), but it's
|
||||
// better to limit this to prevent key truncation/collision on query result
|
||||
g_Log.EventError("MySQL query exceeded max columns allowed (%u/%u) [Cmd: \"%s\"]\n", uNumFields, uMaxFields, pszQuery);
|
||||
|
||||
mysql_free_result(pResult);
|
||||
while ( mysql_next_result(m_socket) == 0 )
|
||||
{
|
||||
pResult = mysql_store_result(m_socket);
|
||||
if ( pResult )
|
||||
mysql_free_result(pResult);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
MYSQL_FIELD *pFields = mysql_fetch_fields(pResult);
|
||||
mapQueryResult.SetNum("NUMROWS", mysql_num_rows(pResult));
|
||||
mapQueryResult.SetNum("NUMCOLS", uNumFields);
|
||||
|
||||
int iRowNum = 0;
|
||||
MYSQL_ROW pRow;
|
||||
char szKey[128];
|
||||
char *pszVal = NULL;
|
||||
while ( (pRow = mysql_fetch_row(pResult)) != NULL )
|
||||
{
|
||||
for ( unsigned int i = 0; i < uNumFields; ++i )
|
||||
{
|
||||
pszVal = pRow[i];
|
||||
if ( iRowNum == 0 )
|
||||
{
|
||||
snprintf(szKey, sizeof(szKey), "%u", i);
|
||||
mapQueryResult.SetStr(szKey, true, pszVal);
|
||||
|
||||
snprintf(szKey, sizeof(szKey), "%s", pFields[i].name);
|
||||
mapQueryResult.SetStr(szKey, true, pszVal);
|
||||
}
|
||||
|
||||
snprintf(szKey, sizeof(szKey), "%d.%u", iRowNum, i);
|
||||
mapQueryResult.SetStr(szKey, true, pszVal);
|
||||
|
||||
snprintf(szKey, sizeof(szKey), "%d.%s", iRowNum, pFields[i].name);
|
||||
mapQueryResult.SetStr(szKey, true, pszVal);
|
||||
}
|
||||
++iRowNum;
|
||||
}
|
||||
|
||||
mysql_free_result(pResult);
|
||||
while ( mysql_next_result(m_socket) == 0 )
|
||||
{
|
||||
pResult = mysql_store_result(m_socket);
|
||||
if ( pResult )
|
||||
mysql_free_result(pResult);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool __cdecl CDataBase::Queryf(CVarDefMap &mapQueryResult, char *pFormat, ...)
|
||||
|
|
@ -154,7 +184,7 @@ bool __cdecl CDataBase::Queryf(CVarDefMap &mapQueryResult, char *pFormat, ...)
|
|||
va_list marker;
|
||||
|
||||
va_start(marker, pFormat);
|
||||
_vsnprintf(pszBuffer, pszBuffer.realLength(), pFormat, marker);
|
||||
vsnprintf(pszBuffer, pszBuffer.realLength(), pFormat, marker);
|
||||
va_end(marker);
|
||||
|
||||
return Query(pszBuffer, mapQueryResult);
|
||||
|
|
@ -170,24 +200,29 @@ bool CDataBase::Exec(LPCTSTR pszQuery)
|
|||
SimpleThreadLock lock(m_connectionMutex);
|
||||
|
||||
int iResultCode = mysql_query(m_socket, pszQuery);
|
||||
if ( iResultCode == 0 )
|
||||
if ( iResultCode != 0 )
|
||||
{
|
||||
// Result must be retrieved from server even when no data is expected, otherwise the server will think the client has lost connection
|
||||
MYSQL_RES *pResult = mysql_store_result(m_socket);
|
||||
if ( !pResult )
|
||||
return false;
|
||||
unsigned int uErrNum = mysql_errno(m_socket);
|
||||
g_Log.EventError("MySQL error #%u: %s [Cmd: \"%s\"]\n", uErrNum, mysql_error(m_socket), pszQuery);
|
||||
|
||||
mysql_free_result(pResult);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_Log.EventError("MySQL error #%u: %s [Cmd: \"%s\"]\n", mysql_errno(m_socket), mysql_error(m_socket), pszQuery);
|
||||
if ( (iResultCode == CR_SERVER_GONE_ERROR) || (iResultCode == CR_SERVER_LOST) )
|
||||
if ( (uErrNum == CR_SERVER_GONE_ERROR) || (uErrNum == CR_SERVER_LOST) )
|
||||
Close();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
MYSQL_RES *pResult = mysql_store_result(m_socket);
|
||||
if ( pResult )
|
||||
mysql_free_result(pResult);
|
||||
|
||||
while ( mysql_next_result(m_socket) == 0 )
|
||||
{
|
||||
pResult = mysql_store_result(m_socket);
|
||||
if ( pResult )
|
||||
mysql_free_result(pResult);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool __cdecl CDataBase::Execf(char *pFormat, ...)
|
||||
|
|
@ -197,7 +232,7 @@ bool __cdecl CDataBase::Execf(char *pFormat, ...)
|
|||
va_list marker;
|
||||
|
||||
va_start(marker, pFormat);
|
||||
_vsnprintf(pszBuffer, pszBuffer.realLength(), pFormat, marker);
|
||||
vsnprintf(pszBuffer, pszBuffer.realLength(), pFormat, marker);
|
||||
va_end(marker);
|
||||
|
||||
return Exec(pszBuffer);
|
||||
|
|
@ -261,6 +296,21 @@ void CDataBase::OnTick()
|
|||
}
|
||||
}
|
||||
|
||||
bool CDataBase::r_GetRef(LPCTSTR &pszKey, CScriptObj *&pRef)
|
||||
{
|
||||
ADDTOCALLSTACK("CDataBase::r_GetRef");
|
||||
UNREFERENCED_PARAMETER(pszKey);
|
||||
UNREFERENCED_PARAMETER(pRef);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CDataBase::r_LoadVal(CScript &s)
|
||||
{
|
||||
ADDTOCALLSTACK("CDataBase::r_LoadVal");
|
||||
UNREFERENCED_PARAMETER(s);
|
||||
return false;
|
||||
}
|
||||
|
||||
enum DBO_TYPE
|
||||
{
|
||||
DBO_AEXECUTE,
|
||||
|
|
@ -281,39 +331,6 @@ const LPCTSTR CDataBase::sm_szLoadKeys[DBO_QTY + 1] =
|
|||
NULL
|
||||
};
|
||||
|
||||
enum DBOV_TYPE
|
||||
{
|
||||
DBOV_CLOSE,
|
||||
DBOV_CONNECT,
|
||||
DBOV_EXECUTE,
|
||||
DBOV_QUERY,
|
||||
DBOV_QTY
|
||||
};
|
||||
|
||||
const LPCTSTR CDataBase::sm_szVerbKeys[DBOV_QTY + 1] =
|
||||
{
|
||||
"CLOSE",
|
||||
"CONNECT",
|
||||
"EXECUTE",
|
||||
"QUERY",
|
||||
NULL
|
||||
};
|
||||
|
||||
bool CDataBase::r_GetRef(LPCTSTR &pszKey, CScriptObj *&pRef)
|
||||
{
|
||||
ADDTOCALLSTACK("CDataBase::r_GetRef");
|
||||
UNREFERENCED_PARAMETER(pszKey);
|
||||
UNREFERENCED_PARAMETER(pRef);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CDataBase::r_LoadVal(CScript &s)
|
||||
{
|
||||
ADDTOCALLSTACK("CDataBase::r_LoadVal");
|
||||
UNREFERENCED_PARAMETER(s);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CDataBase::r_WriteVal(LPCTSTR pszKey, CGString &sVal, CTextConsole *pSrc)
|
||||
{
|
||||
ADDTOCALLSTACK("CDataBase::r_WriteVal");
|
||||
|
|
@ -338,7 +355,7 @@ bool CDataBase::r_WriteVal(LPCTSTR pszKey, CGString &sVal, CTextConsole *pSrc)
|
|||
sVal.FormatVal(AsyncQueue((index == DBO_AQUERY), ppArgs[0], ppArgs[1]));
|
||||
else
|
||||
{
|
||||
g_Log.EventError("Invalid %s arguments\n", sm_szLoadKeys[index]);
|
||||
g_Log.EventError("%s: invalid arguments\n", sm_szLoadKeys[index]);
|
||||
sVal = "0";
|
||||
}
|
||||
return true;
|
||||
|
|
@ -354,12 +371,18 @@ bool CDataBase::r_WriteVal(LPCTSTR pszKey, CGString &sVal, CTextConsole *pSrc)
|
|||
GETNONWHITESPACE(pszKey);
|
||||
sVal = "";
|
||||
|
||||
if ( pszKey[0] != '\0' )
|
||||
if ( m_socket && (pszKey[0] != '\0') )
|
||||
{
|
||||
TCHAR *pszEscapedString = Str_GetTemp();
|
||||
SimpleThreadLock lock(m_connectionMutex);
|
||||
if ( m_socket && mysql_real_escape_string(m_socket, pszEscapedString, pszKey, static_cast<unsigned long>(strlen(pszKey))) )
|
||||
sVal = pszEscapedString;
|
||||
char szEscapedString[THREAD_STRING_LENGTH];
|
||||
size_t iLen = strlen(pszKey);
|
||||
if ( iLen > (sizeof(szEscapedString) / 2) - 1 )
|
||||
g_Log.EventError("%s: args exceeded max length allowed (%zu/%zu)\n", sm_szLoadKeys[index], iLen, (sizeof(szEscapedString) / 2) - 1);
|
||||
else
|
||||
{
|
||||
SimpleThreadLock lock(m_connectionMutex);
|
||||
if ( mysql_real_escape_string(m_socket, szEscapedString, pszKey, static_cast<unsigned long>(iLen)) )
|
||||
sVal = szEscapedString;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -375,6 +398,24 @@ bool CDataBase::r_WriteVal(LPCTSTR pszKey, CGString &sVal, CTextConsole *pSrc)
|
|||
}
|
||||
}
|
||||
|
||||
enum DBOV_TYPE
|
||||
{
|
||||
DBOV_CLOSE,
|
||||
DBOV_CONNECT,
|
||||
DBOV_EXECUTE,
|
||||
DBOV_QUERY,
|
||||
DBOV_QTY
|
||||
};
|
||||
|
||||
const LPCTSTR CDataBase::sm_szVerbKeys[DBOV_QTY + 1] =
|
||||
{
|
||||
"CLOSE",
|
||||
"CONNECT",
|
||||
"EXECUTE",
|
||||
"QUERY",
|
||||
NULL
|
||||
};
|
||||
|
||||
bool CDataBase::r_Verb(CScript &s, CTextConsole *pSrc)
|
||||
{
|
||||
ADDTOCALLSTACK("CDataBase::r_Verb");
|
||||
|
|
@ -386,27 +427,21 @@ bool CDataBase::r_Verb(CScript &s, CTextConsole *pSrc)
|
|||
switch ( index )
|
||||
{
|
||||
case DBOV_CLOSE:
|
||||
{
|
||||
if ( m_socket )
|
||||
Close();
|
||||
Close();
|
||||
return true;
|
||||
}
|
||||
|
||||
case DBOV_CONNECT:
|
||||
{
|
||||
if ( !m_socket )
|
||||
Connect();
|
||||
Connect();
|
||||
return true;
|
||||
}
|
||||
|
||||
case DBOV_EXECUTE:
|
||||
{
|
||||
Exec(s.GetArgRaw());
|
||||
return true;
|
||||
}
|
||||
|
||||
case DBOV_QUERY:
|
||||
{
|
||||
Query(s.GetArgRaw(), m_QueryResult);
|
||||
return true;
|
||||
}
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,339 +0,0 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
||||
5360
src/common/mysql/LICENSE
Normal file
5360
src/common/mysql/LICENSE
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -1,660 +1,20 @@
|
|||
MySQL Connector/C 6.1
|
||||
Copyright (c) 2000, 2026, Oracle and/or its affiliates.
|
||||
|
||||
This is a release of MySQL Connector/C, Oracle's dual-
|
||||
license C Driver for MySQL. For the avoidance of
|
||||
doubt, this particular copy of the software is released
|
||||
under the version 2 of the GNU General Public License.
|
||||
MySQL Connector/C is brought to you by Oracle.
|
||||
This is a release of MySQL, an SQL database server.
|
||||
|
||||
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
License information can be found in the LICENSE file.
|
||||
|
||||
License information can be found in the COPYING file.
|
||||
In test packages where this file is renamed README-test, the license
|
||||
file is renamed LICENSE-test.
|
||||
|
||||
MySQL FOSS License Exception
|
||||
We want free and open source software applications under
|
||||
certain licenses to be able to use the GPL-licensed MySQL
|
||||
Connector/C (specified GPL-licensed MySQL client libraries)
|
||||
despite the fact that not all such FOSS licenses are
|
||||
compatible with version 2 of the GNU General Public License.
|
||||
Therefore there are special exceptions to the terms and
|
||||
conditions of the GPLv2 as applied to these client libraries,
|
||||
which are identified and described in more detail in the
|
||||
FOSS License Exception at
|
||||
<http://www.mysql.com/about/legal/licensing/foss-exception/>
|
||||
This distribution may include materials developed by third parties.
|
||||
For license and attribution notices for these materials,
|
||||
please refer to the LICENSE file.
|
||||
|
||||
This software is OSI Certified Open Source Software.
|
||||
OSI Certified is a certification mark of the Open Source Initiative.
|
||||
For further information on MySQL or additional documentation, visit
|
||||
http://dev.mysql.com/doc/
|
||||
|
||||
This distribution may include materials developed by third
|
||||
parties. For license and attribution notices for these
|
||||
materials, please refer to the documentation that accompanies
|
||||
this distribution (see the "Licenses for Third-Party Components"
|
||||
appendix) or view the online documentation at
|
||||
<http://dev.mysql.com/doc/>
|
||||
A copy of the license/notices is also reproduced below.
|
||||
For additional downloads and the source of MySQL, visit
|
||||
http://dev.mysql.com/downloads/
|
||||
|
||||
GPLv2 Disclaimer
|
||||
For the avoidance of doubt, except that if any license choice
|
||||
other than GPL or LGPL is available it will apply instead,
|
||||
Oracle elects to use only the General Public License version 2
|
||||
(GPLv2) at this time for any software where a choice of GPL
|
||||
license versions is made available with the language indicating
|
||||
that GPLv2 or any later version may be used, or where a choice
|
||||
of which version of the GPL is applied is otherwise unspecified.
|
||||
|
||||
CONTENTS
|
||||
|
||||
* Documentation Location
|
||||
* Third-Party Component Notices
|
||||
|
||||
DOCUMENTATION LOCATION
|
||||
|
||||
You may also find the latest copy of the documentation on
|
||||
the MySQL website at
|
||||
<http://dev.mysql.com/doc/connector-c/en/index.html>.
|
||||
|
||||
For the new features/bugfix history, see release notes at
|
||||
<https://dev.mysql.com/doc/relnotes/connector-c/en/news-6-1.html>.
|
||||
|
||||
For installation instructions see
|
||||
<https://dev.mysql.com/doc/connector-c/en/connector-c-installation.html>.
|
||||
|
||||
|
||||
***************************************************************
|
||||
|
||||
Third-Party Component Notices
|
||||
|
||||
****************************************************************
|
||||
Appendix A. Licenses for Third-Party Components
|
||||
|
||||
The following is a list of the libraries we have included with the
|
||||
Connector/C source and components used to test it. We are
|
||||
thankful to all individuals that have created these. Some of the
|
||||
components require that their licensing terms be included in the
|
||||
documentation of products that include them. Cross references to
|
||||
these licensing terms are given with the applicable items in the
|
||||
list.
|
||||
|
||||
* GroupLens Research Project
|
||||
The MySQL Quality Assurance team would like to acknowledge the
|
||||
use of the MovieLens Data Sets (10 million ratings and 100,000
|
||||
tags for 10681 movies by 71567 users) to help test MySQL
|
||||
products and to thank the GroupLens Research Project at the
|
||||
University of Minnesota for making the data sets available.
|
||||
|
||||
|
||||
* Section A.1, "dtoa.c License"
|
||||
* Section A.2, "Fred Fish's Dbug Library License"
|
||||
* Section A.3, "GNU General Public License Version 2.0, June
|
||||
1991"
|
||||
* Section A.4, "md5 (Message-Digest Algorithm 5) License"
|
||||
* Section A.5, "RegEX-Spencer Library License"
|
||||
* Section A.6, "Richard A. O'Keefe String Library License"
|
||||
* Section A.7, "SHA-1 in C License"
|
||||
* Section A.8, "zlib License"
|
||||
|
||||
|
||||
A.1. dtoa.c License
|
||||
----------------------------------------------------------------
|
||||
The following software may be included in this product:
|
||||
|
||||
dtoa.c
|
||||
|
||||
The author of this software is David M. Gay.
|
||||
|
||||
Copyright (c) 1991, 2000, 2001 by Lucent Technologies.
|
||||
|
||||
Permission to use, copy, modify, and distribute this software for
|
||||
any purpose without fee is hereby granted, provided that this entire
|
||||
notice is included in all copies of any software which is or includes
|
||||
|
||||
a copy or modification of this software and in all copies of the
|
||||
supporting documentation for such software.
|
||||
|
||||
THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
|
||||
IMPLIED WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT
|
||||
MAKES ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
|
||||
MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
|
||||
PURPOSE.
|
||||
|
||||
|
||||
A.2. Fred Fish's Dbug Library License
|
||||
----------------------------------------------------------------
|
||||
The following software may be included in this product:
|
||||
|
||||
Fred Fish's Dbug Library
|
||||
N O T I C E
|
||||
|
||||
Copyright Abandoned, 1987, Fred Fish
|
||||
|
||||
This previously copyrighted work has been placed into the public
|
||||
domain by the author and may be freely used for any purpose,
|
||||
private or commercial.
|
||||
|
||||
Because of the number of inquiries I was receiving about the use
|
||||
of this product in commercially developed works I have decided to
|
||||
simply make it public domain to further its unrestricted use. I
|
||||
specifically would be most happy to see this material become a
|
||||
part of the standard Unix distributions by AT&T and the Berkeley
|
||||
Computer Science Research Group, and a standard part of the GNU
|
||||
system from the Free Software Foundation.
|
||||
|
||||
I would appreciate it, as a courtesy, if this notice is left in
|
||||
all copies and derivative works. Thank you.
|
||||
|
||||
The author makes no warranty of any kind with respect to this
|
||||
product and explicitly disclaims any implied warranties of mer-
|
||||
chantability or fitness for any particular purpose.
|
||||
|
||||
The dbug_analyze.c file is subject to the following notice:
|
||||
|
||||
Copyright June 1987, Binayak Banerjee
|
||||
All rights reserved.
|
||||
|
||||
This program may be freely distributed under the same terms and
|
||||
conditions as Fred Fish's Dbug package.
|
||||
|
||||
|
||||
A.3. GNU General Public License Version 2.0, June 1991
|
||||
----------------------------------------------------------------
|
||||
The following applies to all products licensed under the GNU General
|
||||
Public License, Version 2.0: You may not use the identified files
|
||||
except in compliance with the GNU General Public License, Version
|
||||
2.0 (the "License.") You may obtain a copy of the License at
|
||||
http://www.gnu.org/licenses/gpl-2.0.txt. A copy of the license is
|
||||
also reproduced below. Unless required by applicable law or agreed
|
||||
to in writing, software distributed under the License is distributed
|
||||
on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
either express or implied. See the License for the specific language
|
||||
governing permissions and limitations under the License.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim
|
||||
copies of this license document, but changing it is not
|
||||
allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software,
|
||||
and (2) offer you this license which gives you legal permission to
|
||||
copy, distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on,
|
||||
|
||||
we want its recipients to know that what they have is not the original,
|
||||
so that any problems introduced by others will not reflect on the
|
||||
original authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software
|
||||
interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as
|
||||
a special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new
|
||||
versions of the General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Program does not specify a
|
||||
version number of this License, you may choose any version ever
|
||||
published by the Free Software Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the
|
||||
author to ask for permission. For software which is copyrighted by the
|
||||
Free Software Foundation, write to the Free Software Foundation; we
|
||||
sometimes make exceptions for this. Our decision will be guided by the
|
||||
two goals of preserving the free status of all derivatives of our free
|
||||
software and of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND,
|
||||
EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS
|
||||
WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these
|
||||
terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it
|
||||
does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version
|
||||
2 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
|
||||
type 'show w'. This is free software, and you are welcome
|
||||
to redistribute it under certain conditions; type 'show c'
|
||||
for details.
|
||||
|
||||
The hypothetical commands 'show w' and 'show c' should show the
|
||||
appropriate parts of the General Public License. Of course, the
|
||||
commands you use may be called something other than 'show w' and
|
||||
'show c'; they could even be mouse-clicks or menu items--whatever
|
||||
suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
program 'Gnomovision' (which makes passes at compilers) written
|
||||
by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library,
|
||||
you may consider it more useful to permit linking proprietary
|
||||
applications with the library. If this is what you want to do, use
|
||||
the GNU Lesser General Public License instead of this License.
|
||||
|
||||
|
||||
A.4. md5 (Message-Digest Algorithm 5) License
|
||||
----------------------------------------------------------------
|
||||
The following software may be included in this product:
|
||||
|
||||
md5 (Message-Digest Algorithm 5)
|
||||
|
||||
This code implements the MD5 message-digest algorithm.
|
||||
The algorithm is due to Ron Rivest. This code was
|
||||
written by Colin Plumb in 1993, no copyright is claimed.
|
||||
This code is in the public domain; do with it what you wish.
|
||||
|
||||
Equivalent code is available from RSA Data Security, Inc.
|
||||
This code has been tested against that, and is equivalent,
|
||||
except that you don't need to include two pages of legalese
|
||||
with every copy.
|
||||
|
||||
The code has been modified by Mikael Ronstroem to handle
|
||||
calculating a hash value of a key that is always a multiple
|
||||
of 4 bytes long. Word 0 of the calculated 4-word hash value
|
||||
is returned as the hash value.
|
||||
|
||||
|
||||
A.5. RegEX-Spencer Library License
|
||||
----------------------------------------------------------------
|
||||
|
||||
The following software may be included in this product:
|
||||
|
||||
Henry Spencer's Regular-Expression Library (RegEX-Spencer)
|
||||
|
||||
Copyright 1992, 1993, 1994 Henry Spencer. All rights reserved.
|
||||
This software is not subject to any license of the American Telephone
|
||||
and Telegraph Company or of the Regents of the University of California.
|
||||
|
||||
Permission is granted to anyone to use this software for any purposeon
|
||||
any computer system, and to alter it and redistribute it, subject
|
||||
to the following restrictions:
|
||||
|
||||
1. The author is not responsible for the consequences of use of this
|
||||
software, no matter how awful, even if they arise from flaws in it.
|
||||
|
||||
2. The origin of this software must not be misrepresented, either by
|
||||
explicit claim or by omission. Since few users ever read sources,
|
||||
credits must appear in the documentation.
|
||||
|
||||
3. Altered versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software. Since few users
|
||||
ever read sources, credits must appear in the documentation.
|
||||
|
||||
4. This notice may not be removed or altered.
|
||||
|
||||
|
||||
A.6. Richard A. O'Keefe String Library License
|
||||
----------------------------------------------------------------
|
||||
|
||||
The following software may be included in this product:
|
||||
|
||||
Richard A. O'Keefe String Library
|
||||
|
||||
The Richard O'Keefe String Library is subject to the following notice:
|
||||
|
||||
These files are in the public domain. This includes getopt.c, which
|
||||
is the work of Henry Spencer, University of Toronto Zoology, who
|
||||
says of it "None of this software is derived from Bell software. I
|
||||
had no access to the source for Bell's versions at the time I wrote
|
||||
it. This software is hereby explicitly placed in the public domain.
|
||||
It may be used for any purpose on any machine by anyone." I would
|
||||
greatly prefer it if *my* material received no military use.
|
||||
|
||||
The t_ctype.h file is subject to the following notice:
|
||||
|
||||
Copyright (C) 1998, 1999 by Pruet Boonma, all rights reserved.
|
||||
Copyright (C) 1998 by Theppitak Karoonboonyanan, all rights reserved.
|
||||
|
||||
Permission to use, copy, modify, distribute and sell this software
|
||||
and its documentation for any purpose is hereby granted without fee,
|
||||
provided that the above copyright notice appear in all copies.
|
||||
|
||||
Smaphan Raruenrom and Pruet Boonma makes no representations about
|
||||
the suitability of this software for any purpose. It is provided
|
||||
"as is" without express or implied warranty.
|
||||
|
||||
|
||||
A.7. SHA-1 in C License
|
||||
----------------------------------------------------------------
|
||||
The following software may be included in this product:
|
||||
|
||||
SHA-1 in C
|
||||
|
||||
By Steve Reid <steve@edmweb.com>
|
||||
100% Public Domain
|
||||
|
||||
|
||||
A.8. zlib License
|
||||
----------------------------------------------------------------
|
||||
The following software may be included in this product:
|
||||
|
||||
zlib
|
||||
|
||||
Oracle gratefully acknowledges the contributions of Jean-loup Gailly
|
||||
and Mark Adler in creating the zlib general purpose compression library
|
||||
which is used in this product.
|
||||
|
||||
zlib.h -- interface of the 'zlib' general purpose compression library
|
||||
Copyright (C) 1995-2004 Jean-loup Gailly and Mark Adler
|
||||
|
||||
zlib.h -- interface of the 'zlib' general purpose compression library
|
||||
version 1.2.3, July 18th, 2005
|
||||
Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler
|
||||
|
||||
zlib.h -- interface of the 'zlib' general purpose compression library
|
||||
version 1.2.5, April 19th, 2010
|
||||
Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the
|
||||
use of this software. Permission is granted to anyone to use this software
|
||||
for any purpose,including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would
|
||||
be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not
|
||||
be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Jean-loup Gailly jloup@gzip.org
|
||||
Mark Adler madler@alumni.caltech.edu
|
||||
MySQL is brought to you by the MySQL team at Oracle.
|
||||
|
|
|
|||
|
|
@ -1,114 +0,0 @@
|
|||
/* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
Data in big-endian format.
|
||||
*/
|
||||
static inline void float4store(uchar *T, float A)
|
||||
{ *(T)= ((uchar *) &A)[3];
|
||||
*((T)+1)=(char) ((uchar *) &A)[2];
|
||||
*((T)+2)=(char) ((uchar *) &A)[1];
|
||||
*((T)+3)=(char) ((uchar *) &A)[0]; }
|
||||
|
||||
static inline void float4get (float *V, const uchar *M)
|
||||
{ float def_temp;
|
||||
((uchar*) &def_temp)[0]=(M)[3];
|
||||
((uchar*) &def_temp)[1]=(M)[2];
|
||||
((uchar*) &def_temp)[2]=(M)[1];
|
||||
((uchar*) &def_temp)[3]=(M)[0];
|
||||
(*V)=def_temp; }
|
||||
|
||||
static inline void float8store(uchar *T, double V)
|
||||
{ *(T)= ((uchar *) &V)[7];
|
||||
*((T)+1)=(char) ((uchar *) &V)[6];
|
||||
*((T)+2)=(char) ((uchar *) &V)[5];
|
||||
*((T)+3)=(char) ((uchar *) &V)[4];
|
||||
*((T)+4)=(char) ((uchar *) &V)[3];
|
||||
*((T)+5)=(char) ((uchar *) &V)[2];
|
||||
*((T)+6)=(char) ((uchar *) &V)[1];
|
||||
*((T)+7)=(char) ((uchar *) &V)[0]; }
|
||||
|
||||
static inline void float8get (double *V, const uchar *M)
|
||||
{ double def_temp;
|
||||
((uchar*) &def_temp)[0]=(M)[7];
|
||||
((uchar*) &def_temp)[1]=(M)[6];
|
||||
((uchar*) &def_temp)[2]=(M)[5];
|
||||
((uchar*) &def_temp)[3]=(M)[4];
|
||||
((uchar*) &def_temp)[4]=(M)[3];
|
||||
((uchar*) &def_temp)[5]=(M)[2];
|
||||
((uchar*) &def_temp)[6]=(M)[1];
|
||||
((uchar*) &def_temp)[7]=(M)[0];
|
||||
(*V) = def_temp; }
|
||||
|
||||
static inline void ushortget(uint16 *V, const uchar *pM)
|
||||
{ *V = (uint16) (((uint16) ((uchar) (pM)[1]))+
|
||||
((uint16) ((uint16) (pM)[0]) << 8)); }
|
||||
static inline void shortget (int16 *V, const uchar *pM)
|
||||
{ *V = (short) (((short) ((uchar) (pM)[1]))+
|
||||
((short) ((short) (pM)[0]) << 8)); }
|
||||
static inline void longget (int32 *V, const uchar *pM)
|
||||
{ int32 def_temp;
|
||||
((uchar*) &def_temp)[0]=(pM)[0];
|
||||
((uchar*) &def_temp)[1]=(pM)[1];
|
||||
((uchar*) &def_temp)[2]=(pM)[2];
|
||||
((uchar*) &def_temp)[3]=(pM)[3];
|
||||
(*V)=def_temp; }
|
||||
static inline void ulongget (uint32 *V, const uchar *pM)
|
||||
{ uint32 def_temp;
|
||||
((uchar*) &def_temp)[0]=(pM)[0];
|
||||
((uchar*) &def_temp)[1]=(pM)[1];
|
||||
((uchar*) &def_temp)[2]=(pM)[2];
|
||||
((uchar*) &def_temp)[3]=(pM)[3];
|
||||
(*V)=def_temp; }
|
||||
static inline void shortstore(uchar *T, int16 A)
|
||||
{ uint def_temp=(uint) (A) ;
|
||||
*(((char*)T)+1)=(char)(def_temp);
|
||||
*(((char*)T)+0)=(char)(def_temp >> 8); }
|
||||
static inline void longstore (uchar *T, int32 A)
|
||||
{ *(((char*)T)+3)=((A));
|
||||
*(((char*)T)+2)=(((A) >> 8));
|
||||
*(((char*)T)+1)=(((A) >> 16));
|
||||
*(((char*)T)+0)=(((A) >> 24)); }
|
||||
|
||||
static inline void floatget(float *V, const uchar *M)
|
||||
{
|
||||
memcpy(V, (M), sizeof(float));
|
||||
}
|
||||
|
||||
static inline void floatstore(uchar *T, float V)
|
||||
{
|
||||
memcpy((T), (&V), sizeof(float));
|
||||
}
|
||||
|
||||
static inline void doubleget(double *V, const uchar *M)
|
||||
{
|
||||
memcpy(V, (M), sizeof(double));
|
||||
}
|
||||
|
||||
static inline void doublestore(uchar *T, double V)
|
||||
{
|
||||
memcpy((T), &V, sizeof(double));
|
||||
}
|
||||
|
||||
static inline void longlongget(longlong *V, const uchar *M)
|
||||
{
|
||||
memcpy(V, (M), sizeof(ulonglong));
|
||||
}
|
||||
static inline void longlongstore(uchar *T, longlong V)
|
||||
{
|
||||
memcpy((T), &V, sizeof(ulonglong));
|
||||
}
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
/* Copyright (c) 2014, 2015 Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
/**
|
||||
@file binary_log_types.h
|
||||
|
||||
@brief This file contains the field type.
|
||||
|
||||
|
||||
@note This file can be imported both from C and C++ code, so the
|
||||
definitions have to be constructed to support this.
|
||||
*/
|
||||
|
||||
#ifndef BINARY_LOG_TYPES_INCLUDED
|
||||
#define BINARY_LOG_TYPES_INCLUDED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Constants exported from this package.
|
||||
*/
|
||||
|
||||
typedef enum enum_field_types {
|
||||
MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY,
|
||||
MYSQL_TYPE_SHORT, MYSQL_TYPE_LONG,
|
||||
MYSQL_TYPE_FLOAT, MYSQL_TYPE_DOUBLE,
|
||||
MYSQL_TYPE_NULL, MYSQL_TYPE_TIMESTAMP,
|
||||
MYSQL_TYPE_LONGLONG,MYSQL_TYPE_INT24,
|
||||
MYSQL_TYPE_DATE, MYSQL_TYPE_TIME,
|
||||
MYSQL_TYPE_DATETIME, MYSQL_TYPE_YEAR,
|
||||
MYSQL_TYPE_NEWDATE, MYSQL_TYPE_VARCHAR,
|
||||
MYSQL_TYPE_BIT,
|
||||
MYSQL_TYPE_TIMESTAMP2,
|
||||
MYSQL_TYPE_DATETIME2,
|
||||
MYSQL_TYPE_TIME2,
|
||||
MYSQL_TYPE_JSON=245,
|
||||
MYSQL_TYPE_NEWDECIMAL=246,
|
||||
MYSQL_TYPE_ENUM=247,
|
||||
MYSQL_TYPE_SET=248,
|
||||
MYSQL_TYPE_TINY_BLOB=249,
|
||||
MYSQL_TYPE_MEDIUM_BLOB=250,
|
||||
MYSQL_TYPE_LONG_BLOB=251,
|
||||
MYSQL_TYPE_BLOB=252,
|
||||
MYSQL_TYPE_VAR_STRING=253,
|
||||
MYSQL_TYPE_STRING=254,
|
||||
MYSQL_TYPE_GEOMETRY=255
|
||||
} enum_field_types;
|
||||
|
||||
#define DATETIME_MAX_DECIMALS 6
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif /* BINARY_LOG_TYPES_INCLUDED */
|
||||
|
|
@ -1,97 +0,0 @@
|
|||
/* Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
/*
|
||||
Endianness-independent definitions for architectures other
|
||||
than the x86 architecture.
|
||||
*/
|
||||
static inline int16 sint2korr(const uchar *A)
|
||||
{
|
||||
return
|
||||
(int16) (((int16) (A[0])) +
|
||||
((int16) (A[1]) << 8))
|
||||
;
|
||||
}
|
||||
|
||||
static inline int32 sint4korr(const uchar *A)
|
||||
{
|
||||
return
|
||||
(int32) (((int32) (A[0])) +
|
||||
(((int32) (A[1]) << 8)) +
|
||||
(((int32) (A[2]) << 16)) +
|
||||
(((int32) (A[3]) << 24)))
|
||||
;
|
||||
}
|
||||
|
||||
static inline uint16 uint2korr(const uchar *A)
|
||||
{
|
||||
return
|
||||
(uint16) (((uint16) (A[0])) +
|
||||
((uint16) (A[1]) << 8))
|
||||
;
|
||||
}
|
||||
|
||||
static inline uint32 uint4korr(const uchar *A)
|
||||
{
|
||||
return
|
||||
(uint32) (((uint32) (A[0])) +
|
||||
(((uint32) (A[1])) << 8) +
|
||||
(((uint32) (A[2])) << 16) +
|
||||
(((uint32) (A[3])) << 24))
|
||||
;
|
||||
}
|
||||
|
||||
static inline ulonglong uint8korr(const uchar *A)
|
||||
{
|
||||
return
|
||||
((ulonglong)(((uint32) (A[0])) +
|
||||
(((uint32) (A[1])) << 8) +
|
||||
(((uint32) (A[2])) << 16) +
|
||||
(((uint32) (A[3])) << 24)) +
|
||||
(((ulonglong) (((uint32) (A[4])) +
|
||||
(((uint32) (A[5])) << 8) +
|
||||
(((uint32) (A[6])) << 16) +
|
||||
(((uint32) (A[7])) << 24))) <<
|
||||
32))
|
||||
;
|
||||
}
|
||||
|
||||
static inline longlong sint8korr(const uchar *A)
|
||||
{
|
||||
return (longlong) uint8korr(A);
|
||||
}
|
||||
|
||||
static inline void int2store(uchar *T, uint16 A)
|
||||
{
|
||||
uint def_temp= A ;
|
||||
*(T)= (uchar)(def_temp);
|
||||
*(T+1)= (uchar)(def_temp >> 8);
|
||||
}
|
||||
|
||||
static inline void int4store(uchar *T, uint32 A)
|
||||
{
|
||||
*(T)= (uchar) (A);
|
||||
*(T+1)=(uchar) (A >> 8);
|
||||
*(T+2)=(uchar) (A >> 16);
|
||||
*(T+3)=(uchar) (A >> 24);
|
||||
}
|
||||
|
||||
static inline void int8store(uchar *T, ulonglong A)
|
||||
{
|
||||
uint def_temp= (uint) A,
|
||||
def_temp2= (uint) (A >> 32);
|
||||
int4store(T, def_temp);
|
||||
int4store(T+4,def_temp2);
|
||||
}
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
/* Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
/*
|
||||
Optimized functions for the x86 architecture (_WIN32 included).
|
||||
|
||||
x86 handles misaligned reads and writes just fine, so suppress
|
||||
UBSAN warnings for these functions.
|
||||
*/
|
||||
static inline int16 sint2korr(const uchar *A) SUPPRESS_UBSAN;
|
||||
static inline int16 sint2korr(const uchar *A) { return *((int16*) A); }
|
||||
|
||||
static inline int32 sint4korr(const uchar *A) SUPPRESS_UBSAN;
|
||||
static inline int32 sint4korr(const uchar *A) { return *((int32*) A); }
|
||||
|
||||
static inline uint16 uint2korr(const uchar *A) SUPPRESS_UBSAN;
|
||||
static inline uint16 uint2korr(const uchar *A) { return *((uint16*) A); }
|
||||
|
||||
static inline uint32 uint4korr(const uchar *A) SUPPRESS_UBSAN;
|
||||
static inline uint32 uint4korr(const uchar *A) { return *((uint32*) A); }
|
||||
|
||||
static inline ulonglong uint8korr(const uchar *A) SUPPRESS_UBSAN;
|
||||
static inline ulonglong uint8korr(const uchar *A) { return *((ulonglong*) A);}
|
||||
|
||||
static inline longlong sint8korr(const uchar *A) SUPPRESS_UBSAN;
|
||||
static inline longlong sint8korr(const uchar *A) { return *((longlong*) A); }
|
||||
|
||||
static inline void int2store(uchar *T, uint16 A) SUPPRESS_UBSAN;
|
||||
static inline void int2store(uchar *T, uint16 A)
|
||||
{
|
||||
*((uint16*) T)= A;
|
||||
}
|
||||
|
||||
static inline void int4store(uchar *T, uint32 A) SUPPRESS_UBSAN;
|
||||
static inline void int4store(uchar *T, uint32 A)
|
||||
{
|
||||
*((uint32*) T)= A;
|
||||
}
|
||||
|
||||
static inline void int8store(uchar *T, ulonglong A) SUPPRESS_UBSAN;
|
||||
static inline void int8store(uchar *T, ulonglong A)
|
||||
{
|
||||
*((ulonglong*) T)= A;
|
||||
}
|
||||
|
|
@ -1,137 +0,0 @@
|
|||
/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#ifndef DECIMAL_INCLUDED
|
||||
#define DECIMAL_INCLUDED
|
||||
|
||||
typedef enum
|
||||
{TRUNCATE=0, HALF_EVEN, HALF_UP, CEILING, FLOOR}
|
||||
decimal_round_mode;
|
||||
typedef int32 decimal_digit_t;
|
||||
|
||||
/**
|
||||
intg is the number of *decimal* digits (NOT number of decimal_digit_t's !)
|
||||
before the point
|
||||
frac is the number of decimal digits after the point
|
||||
len is the length of buf (length of allocated space) in decimal_digit_t's,
|
||||
not in bytes
|
||||
sign false means positive, true means negative
|
||||
buf is an array of decimal_digit_t's
|
||||
*/
|
||||
typedef struct st_decimal_t {
|
||||
int intg, frac, len;
|
||||
my_bool sign;
|
||||
decimal_digit_t *buf;
|
||||
} decimal_t;
|
||||
|
||||
#ifndef MYSQL_ABI_CHECK
|
||||
int internal_str2dec(const char *from, decimal_t *to, char **end,
|
||||
my_bool fixed);
|
||||
int decimal2string(const decimal_t *from, char *to, int *to_len,
|
||||
int fixed_precision, int fixed_decimals,
|
||||
char filler);
|
||||
int decimal2ulonglong(decimal_t *from, ulonglong *to);
|
||||
int ulonglong2decimal(ulonglong from, decimal_t *to);
|
||||
int decimal2longlong(decimal_t *from, longlong *to);
|
||||
int longlong2decimal(longlong from, decimal_t *to);
|
||||
int decimal2double(const decimal_t *from, double *to);
|
||||
int double2decimal(double from, decimal_t *to);
|
||||
int decimal_actual_fraction(decimal_t *from);
|
||||
int decimal2bin(decimal_t *from, uchar *to, int precision, int scale);
|
||||
int bin2decimal(const uchar *from, decimal_t *to, int precision, int scale);
|
||||
|
||||
/**
|
||||
Convert decimal to lldiv_t.
|
||||
The integer part is stored in to->quot.
|
||||
The fractional part is multiplied to 10^9 and stored to to->rem.
|
||||
@param from Decimal value
|
||||
@param to lldiv_t value
|
||||
@retval 0 on success
|
||||
@retval !0 in error
|
||||
*/
|
||||
int decimal2lldiv_t(const decimal_t *from, lldiv_t *to);
|
||||
|
||||
/**
|
||||
Convert doube to lldiv_t.
|
||||
The integer part is stored in to->quot.
|
||||
The fractional part is multiplied to 10^9 and stored to to->rem.
|
||||
@param from Decimal value
|
||||
@param to lldiv_t value
|
||||
@retval 0 on success
|
||||
@retval !0 in error
|
||||
*/
|
||||
|
||||
int double2lldiv_t(double from, lldiv_t *to);
|
||||
int decimal_size(int precision, int scale);
|
||||
int decimal_bin_size(int precision, int scale);
|
||||
int decimal_result_size(decimal_t *from1, decimal_t *from2, char op,
|
||||
int param);
|
||||
|
||||
int decimal_intg(const decimal_t *from);
|
||||
int decimal_add(const decimal_t *from1, const decimal_t *from2, decimal_t *to);
|
||||
int decimal_sub(const decimal_t *from1, const decimal_t *from2, decimal_t *to);
|
||||
int decimal_cmp(const decimal_t *from1, const decimal_t *from2);
|
||||
int decimal_mul(const decimal_t *from1, const decimal_t *from2, decimal_t *to);
|
||||
int decimal_div(const decimal_t *from1, const decimal_t *from2, decimal_t *to,
|
||||
int scale_incr);
|
||||
int decimal_mod(const decimal_t *from1, const decimal_t *from2, decimal_t *to);
|
||||
int decimal_round(const decimal_t *from, decimal_t *to, int new_scale,
|
||||
decimal_round_mode mode);
|
||||
int decimal_is_zero(const decimal_t *from);
|
||||
void max_decimal(int precision, int frac, decimal_t *to);
|
||||
|
||||
#define string2decimal(A,B,C) internal_str2dec((A), (B), (C), 0)
|
||||
#define string2decimal_fixed(A,B,C) internal_str2dec((A), (B), (C), 1)
|
||||
|
||||
/* set a decimal_t to zero */
|
||||
|
||||
#define decimal_make_zero(dec) do { \
|
||||
(dec)->buf[0]=0; \
|
||||
(dec)->intg=1; \
|
||||
(dec)->frac=0; \
|
||||
(dec)->sign=0; \
|
||||
} while(0)
|
||||
|
||||
/*
|
||||
returns the length of the buffer to hold string representation
|
||||
of the decimal (including decimal dot, possible sign and \0)
|
||||
*/
|
||||
|
||||
#define decimal_string_size(dec) (((dec)->intg ? (dec)->intg : 1) + \
|
||||
(dec)->frac + ((dec)->frac > 0) + 2)
|
||||
|
||||
/*
|
||||
conventions:
|
||||
|
||||
decimal_smth() == 0 -- everything's ok
|
||||
decimal_smth() <= 1 -- result is usable, but precision loss is possible
|
||||
decimal_smth() <= 2 -- result can be unusable, most significant digits
|
||||
could've been lost
|
||||
decimal_smth() > 2 -- no result was generated
|
||||
*/
|
||||
|
||||
#define E_DEC_OK 0
|
||||
#define E_DEC_TRUNCATED 1
|
||||
#define E_DEC_OVERFLOW 2
|
||||
#define E_DEC_DIV_ZERO 4
|
||||
#define E_DEC_BAD_NUM 8
|
||||
#define E_DEC_OOM 16
|
||||
|
||||
#define E_DEC_ERROR 31
|
||||
#define E_DEC_FATAL_ERROR 30
|
||||
|
||||
#endif // !MYSQL_ABI_CHECK
|
||||
|
||||
#endif
|
||||
|
|
@ -1,113 +1,147 @@
|
|||
#ifndef ERRMSG_INCLUDED
|
||||
#define ERRMSG_INCLUDED
|
||||
|
||||
/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
/* Copyright (c) 2000, 2026, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
This program is designed to work with certain software (including
|
||||
but not limited to OpenSSL) that is licensed under separate terms,
|
||||
as designated in a particular file or component or in included license
|
||||
documentation. The authors of MySQL hereby grant you an additional
|
||||
permission to link the program and your derivative works with the
|
||||
separately licensed software that they have either included with
|
||||
the program or referenced in the documentation.
|
||||
|
||||
Without limiting anything contained in the foregoing, this file,
|
||||
which is part of C Driver for MySQL (Connector/C), is also subject to the
|
||||
Universal FOSS Exception, version 1.0, a copy of which can be found at
|
||||
http://oss.oracle.com/licenses/universal-foss-exception.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU General Public License, version 2.0, for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
/* Error messages for MySQL clients */
|
||||
/* (Error messages for the daemon are in sql/share/errmsg.txt) */
|
||||
/**
|
||||
@file include/errmsg.h
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void init_client_errs(void);
|
||||
void finish_client_errs(void);
|
||||
extern const char *client_errors[]; /* Error messages */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
Error messages for MySQL clients.
|
||||
These are constant and use the CR_ prefix.
|
||||
<mysqlclient_ername.h> will contain auto-generated mappings
|
||||
containing the symbolic name and the number from this file,
|
||||
and the english error messages in libmysql/errmsg.c.
|
||||
|
||||
#define CR_MIN_ERROR 2000 /* For easier client code */
|
||||
#define CR_MAX_ERROR 2999
|
||||
#if !defined(ER)
|
||||
#define ER(X) (((X) >= CR_ERROR_FIRST && (X) <= CR_ERROR_LAST)? \
|
||||
client_errors[(X)-CR_ERROR_FIRST]: client_errors[CR_UNKNOWN_ERROR])
|
||||
Dynamic error messages for the daemon are in share/language/errmsg.sys.
|
||||
The server equivalent to <errmsg.h> is <mysqld_error.h>.
|
||||
The server equivalent to <mysqlclient_ername.h> is <mysqld_ername.h>.
|
||||
|
||||
#endif
|
||||
#define CLIENT_ERRMAP 2 /* Errormap used by my_error() */
|
||||
Note that the auth subsystem also uses codes with a CR_ prefix.
|
||||
*/
|
||||
|
||||
void init_client_errs(void);
|
||||
void finish_client_errs(void);
|
||||
extern const char *client_errors[]; /* Error messages */
|
||||
|
||||
#define CR_MIN_ERROR 2000 /* For easier client code */
|
||||
#define CR_MAX_ERROR 2999
|
||||
#define CLIENT_ERRMAP 2 /* Errormap used by my_error() */
|
||||
|
||||
/* Do not add error numbers before CR_ERROR_FIRST. */
|
||||
/* If necessary to add lower numbers, change CR_ERROR_FIRST accordingly. */
|
||||
#define CR_ERROR_FIRST 2000 /*Copy first error nr.*/
|
||||
#define CR_UNKNOWN_ERROR 2000
|
||||
#define CR_SOCKET_CREATE_ERROR 2001
|
||||
#define CR_CONNECTION_ERROR 2002
|
||||
#define CR_CONN_HOST_ERROR 2003
|
||||
#define CR_IPSOCK_ERROR 2004
|
||||
#define CR_UNKNOWN_HOST 2005
|
||||
#define CR_SERVER_GONE_ERROR 2006
|
||||
#define CR_VERSION_ERROR 2007
|
||||
#define CR_OUT_OF_MEMORY 2008
|
||||
#define CR_WRONG_HOST_INFO 2009
|
||||
#define CR_ERROR_FIRST 2000 /*Copy first error nr.*/
|
||||
#define CR_UNKNOWN_ERROR 2000
|
||||
#define CR_SOCKET_CREATE_ERROR 2001
|
||||
#define CR_CONNECTION_ERROR 2002
|
||||
#define CR_CONN_HOST_ERROR 2003
|
||||
#define CR_IPSOCK_ERROR 2004
|
||||
#define CR_UNKNOWN_HOST 2005
|
||||
#define CR_SERVER_GONE_ERROR 2006
|
||||
#define CR_VERSION_ERROR 2007
|
||||
#define CR_OUT_OF_MEMORY 2008
|
||||
#define CR_WRONG_HOST_INFO 2009
|
||||
#define CR_LOCALHOST_CONNECTION 2010
|
||||
#define CR_TCP_CONNECTION 2011
|
||||
#define CR_TCP_CONNECTION 2011
|
||||
#define CR_SERVER_HANDSHAKE_ERR 2012
|
||||
#define CR_SERVER_LOST 2013
|
||||
#define CR_SERVER_LOST 2013
|
||||
#define CR_COMMANDS_OUT_OF_SYNC 2014
|
||||
#define CR_NAMEDPIPE_CONNECTION 2015
|
||||
#define CR_NAMEDPIPEWAIT_ERROR 2016
|
||||
#define CR_NAMEDPIPEOPEN_ERROR 2017
|
||||
#define CR_NAMEDPIPEWAIT_ERROR 2016
|
||||
#define CR_NAMEDPIPEOPEN_ERROR 2017
|
||||
#define CR_NAMEDPIPESETSTATE_ERROR 2018
|
||||
#define CR_CANT_READ_CHARSET 2019
|
||||
#define CR_CANT_READ_CHARSET 2019
|
||||
#define CR_NET_PACKET_TOO_LARGE 2020
|
||||
#define CR_EMBEDDED_CONNECTION 2021
|
||||
#define CR_PROBE_SLAVE_STATUS 2022
|
||||
#define CR_PROBE_SLAVE_HOSTS 2023
|
||||
#define CR_PROBE_SLAVE_CONNECT 2024
|
||||
#define CR_PROBE_MASTER_CONNECT 2025
|
||||
#define CR_EMBEDDED_CONNECTION 2021
|
||||
#define CR_PROBE_REPLICA_STATUS 2022
|
||||
#define CR_PROBE_REPLICA_HOSTS 2023
|
||||
#define CR_PROBE_REPLICA_CONNECT 2024
|
||||
#define CR_PROBE_SOURCE_CONNECT 2025
|
||||
#define CR_SSL_CONNECTION_ERROR 2026
|
||||
#define CR_MALFORMED_PACKET 2027
|
||||
#define CR_WRONG_LICENSE 2028
|
||||
#define CR_MALFORMED_PACKET 2027
|
||||
#define CR_WRONG_LICENSE 2028
|
||||
|
||||
/* new 4.1 error codes */
|
||||
#define CR_NULL_POINTER 2029
|
||||
#define CR_NO_PREPARE_STMT 2030
|
||||
#define CR_PARAMS_NOT_BOUND 2031
|
||||
#define CR_DATA_TRUNCATED 2032
|
||||
#define CR_NULL_POINTER 2029
|
||||
#define CR_NO_PREPARE_STMT 2030
|
||||
#define CR_PARAMS_NOT_BOUND 2031
|
||||
#define CR_DATA_TRUNCATED 2032
|
||||
#define CR_NO_PARAMETERS_EXISTS 2033
|
||||
#define CR_INVALID_PARAMETER_NO 2034
|
||||
#define CR_INVALID_BUFFER_USE 2035
|
||||
#define CR_INVALID_BUFFER_USE 2035
|
||||
#define CR_UNSUPPORTED_PARAM_TYPE 2036
|
||||
|
||||
#define CR_SHARED_MEMORY_CONNECTION 2037
|
||||
#define CR_SHARED_MEMORY_CONNECT_REQUEST_ERROR 2038
|
||||
#define CR_SHARED_MEMORY_CONNECT_ANSWER_ERROR 2039
|
||||
#define CR_SHARED_MEMORY_CONNECTION 2037
|
||||
#define CR_SHARED_MEMORY_CONNECT_REQUEST_ERROR 2038
|
||||
#define CR_SHARED_MEMORY_CONNECT_ANSWER_ERROR 2039
|
||||
#define CR_SHARED_MEMORY_CONNECT_FILE_MAP_ERROR 2040
|
||||
#define CR_SHARED_MEMORY_CONNECT_MAP_ERROR 2041
|
||||
#define CR_SHARED_MEMORY_FILE_MAP_ERROR 2042
|
||||
#define CR_SHARED_MEMORY_MAP_ERROR 2043
|
||||
#define CR_SHARED_MEMORY_EVENT_ERROR 2044
|
||||
#define CR_SHARED_MEMORY_CONNECT_MAP_ERROR 2041
|
||||
#define CR_SHARED_MEMORY_FILE_MAP_ERROR 2042
|
||||
#define CR_SHARED_MEMORY_MAP_ERROR 2043
|
||||
#define CR_SHARED_MEMORY_EVENT_ERROR 2044
|
||||
#define CR_SHARED_MEMORY_CONNECT_ABANDONED_ERROR 2045
|
||||
#define CR_SHARED_MEMORY_CONNECT_SET_ERROR 2046
|
||||
#define CR_CONN_UNKNOW_PROTOCOL 2047
|
||||
#define CR_INVALID_CONN_HANDLE 2048
|
||||
#define CR_UNUSED_1 2049
|
||||
#define CR_FETCH_CANCELED 2050
|
||||
#define CR_NO_DATA 2051
|
||||
#define CR_NO_STMT_METADATA 2052
|
||||
#define CR_NO_RESULT_SET 2053
|
||||
#define CR_NOT_IMPLEMENTED 2054
|
||||
#define CR_SERVER_LOST_EXTENDED 2055
|
||||
#define CR_STMT_CLOSED 2056
|
||||
#define CR_NEW_STMT_METADATA 2057
|
||||
#define CR_ALREADY_CONNECTED 2058
|
||||
#define CR_AUTH_PLUGIN_CANNOT_LOAD 2059
|
||||
#define CR_DUPLICATE_CONNECTION_ATTR 2060
|
||||
#define CR_AUTH_PLUGIN_ERR 2061
|
||||
#define CR_INSECURE_API_ERR 2062
|
||||
#define CR_ERROR_LAST /*Copy last error nr:*/ 2062
|
||||
#define CR_SHARED_MEMORY_CONNECT_SET_ERROR 2046
|
||||
#define CR_CONN_UNKNOW_PROTOCOL 2047
|
||||
#define CR_INVALID_CONN_HANDLE 2048
|
||||
#define CR_UNUSED_1 2049
|
||||
#define CR_FETCH_CANCELED 2050
|
||||
#define CR_NO_DATA 2051
|
||||
#define CR_NO_STMT_METADATA 2052
|
||||
#define CR_NO_RESULT_SET 2053
|
||||
#define CR_NOT_IMPLEMENTED 2054
|
||||
#define CR_SERVER_LOST_EXTENDED 2055
|
||||
#define CR_STMT_CLOSED 2056
|
||||
#define CR_NEW_STMT_METADATA 2057
|
||||
#define CR_ALREADY_CONNECTED 2058
|
||||
#define CR_AUTH_PLUGIN_CANNOT_LOAD 2059
|
||||
#define CR_DUPLICATE_CONNECTION_ATTR 2060
|
||||
#define CR_AUTH_PLUGIN_ERR 2061
|
||||
#define CR_INSECURE_API_ERR 2062
|
||||
#define CR_FILE_NAME_TOO_LONG 2063
|
||||
#define CR_SSL_FIPS_MODE_ERR 2064
|
||||
#define CR_DEPRECATED_COMPRESSION_NOT_SUPPORTED 2065
|
||||
#define CR_COMPRESSION_WRONGLY_CONFIGURED 2066
|
||||
#define CR_KERBEROS_USER_NOT_FOUND 2067
|
||||
#define CR_LOAD_DATA_LOCAL_INFILE_REJECTED 2068
|
||||
#define CR_LOAD_DATA_LOCAL_INFILE_REALPATH_FAIL 2069
|
||||
#define CR_DNS_SRV_LOOKUP_FAILED 2070
|
||||
#define CR_MANDATORY_TRACKER_NOT_FOUND 2071
|
||||
#define CR_INVALID_FACTOR_NO 2072
|
||||
#define CR_CANT_GET_SESSION_DATA 2073
|
||||
#define CR_INVALID_CLIENT_CHARSET 2074
|
||||
#define CR_ERROR_LAST /*Copy last error nr:*/ 2074
|
||||
/* Add error numbers before CR_ERROR_LAST and change it accordingly. */
|
||||
|
||||
/* Visual Studio requires '__inline' for C code */
|
||||
static inline const char *ER_CLIENT(int client_errno) {
|
||||
if (client_errno >= CR_ERROR_FIRST && client_errno <= CR_ERROR_LAST)
|
||||
return client_errors[client_errno - CR_ERROR_FIRST];
|
||||
return client_errors[CR_UNKNOWN_ERROR - CR_ERROR_FIRST];
|
||||
}
|
||||
|
||||
#endif /* ERRMSG_INCLUDED */
|
||||
|
|
|
|||
96
src/common/mysql/include/field_types.h
Normal file
96
src/common/mysql/include/field_types.h
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
/* Copyright (c) 2014, 2026, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
This program is designed to work with certain software (including
|
||||
but not limited to OpenSSL) that is licensed under separate terms,
|
||||
as designated in a particular file or component or in included license
|
||||
documentation. The authors of MySQL hereby grant you an additional
|
||||
permission to link the program and your derivative works with the
|
||||
separately licensed software that they have either included with
|
||||
the program or referenced in the documentation.
|
||||
|
||||
Without limiting anything contained in the foregoing, this file,
|
||||
which is part of C Driver for MySQL (Connector/C), is also subject to the
|
||||
Universal FOSS Exception, version 1.0, a copy of which can be found at
|
||||
http://oss.oracle.com/licenses/universal-foss-exception.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License, version 2.0, for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
/**
|
||||
@file field_types.h
|
||||
|
||||
@brief This file contains the field type.
|
||||
|
||||
|
||||
@note This file can be imported both from C and C++ code, so the
|
||||
definitions have to be constructed to support this.
|
||||
*/
|
||||
|
||||
#ifndef FIELD_TYPES_INCLUDED
|
||||
#define FIELD_TYPES_INCLUDED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* Constants exported from this package.
|
||||
*/
|
||||
|
||||
/**
|
||||
Column types for MySQL
|
||||
*/
|
||||
enum enum_field_types {
|
||||
MYSQL_TYPE_DECIMAL,
|
||||
MYSQL_TYPE_TINY,
|
||||
MYSQL_TYPE_SHORT,
|
||||
MYSQL_TYPE_LONG,
|
||||
MYSQL_TYPE_FLOAT,
|
||||
MYSQL_TYPE_DOUBLE,
|
||||
MYSQL_TYPE_NULL,
|
||||
MYSQL_TYPE_TIMESTAMP,
|
||||
MYSQL_TYPE_LONGLONG,
|
||||
MYSQL_TYPE_INT24,
|
||||
MYSQL_TYPE_DATE,
|
||||
MYSQL_TYPE_TIME,
|
||||
MYSQL_TYPE_DATETIME,
|
||||
MYSQL_TYPE_YEAR,
|
||||
MYSQL_TYPE_NEWDATE, /**< Internal to MySQL. Not used in protocol */
|
||||
MYSQL_TYPE_VARCHAR,
|
||||
MYSQL_TYPE_BIT,
|
||||
MYSQL_TYPE_TIMESTAMP2,
|
||||
MYSQL_TYPE_DATETIME2, /**< Internal to MySQL. Not used in protocol */
|
||||
MYSQL_TYPE_TIME2, /**< Internal to MySQL. Not used in protocol */
|
||||
MYSQL_TYPE_TYPED_ARRAY, /**< Used for replication only */
|
||||
MYSQL_TYPE_INVALID = 243,
|
||||
MYSQL_TYPE_BOOL = 244, /**< Currently just a placeholder */
|
||||
MYSQL_TYPE_JSON = 245,
|
||||
MYSQL_TYPE_NEWDECIMAL = 246,
|
||||
MYSQL_TYPE_ENUM = 247,
|
||||
MYSQL_TYPE_SET = 248,
|
||||
MYSQL_TYPE_TINY_BLOB = 249,
|
||||
MYSQL_TYPE_MEDIUM_BLOB = 250,
|
||||
MYSQL_TYPE_LONG_BLOB = 251,
|
||||
MYSQL_TYPE_BLOB = 252,
|
||||
MYSQL_TYPE_VAR_STRING = 253,
|
||||
MYSQL_TYPE_STRING = 254,
|
||||
MYSQL_TYPE_GEOMETRY = 255
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#else
|
||||
typedef enum enum_field_types enum_field_types;
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* FIELD_TYPES_INCLUDED */
|
||||
|
|
@ -1,156 +0,0 @@
|
|||
/* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
/* Key cache variable structures */
|
||||
|
||||
#ifndef _keycache_h
|
||||
#define _keycache_h
|
||||
|
||||
#include "my_sys.h" /* flush_type */
|
||||
|
||||
C_MODE_START
|
||||
|
||||
/* declare structures that is used by st_key_cache */
|
||||
|
||||
struct st_block_link;
|
||||
typedef struct st_block_link BLOCK_LINK;
|
||||
struct st_hash_link;
|
||||
typedef struct st_hash_link HASH_LINK;
|
||||
|
||||
/* Thread specific variables */
|
||||
typedef struct st_keycache_thread_var
|
||||
{
|
||||
mysql_cond_t suspend;
|
||||
struct st_keycache_thread_var *next,**prev;
|
||||
void *opt_info;
|
||||
} st_keycache_thread_var;
|
||||
|
||||
/* info about requests in a waiting queue */
|
||||
typedef struct st_keycache_wqueue
|
||||
{
|
||||
st_keycache_thread_var *last_thread; /* circular list of waiting threads */
|
||||
} KEYCACHE_WQUEUE;
|
||||
|
||||
#define CHANGED_BLOCKS_HASH 128 /* must be power of 2 */
|
||||
|
||||
/*
|
||||
The key cache structure
|
||||
It also contains read-only statistics parameters.
|
||||
*/
|
||||
|
||||
typedef struct st_key_cache
|
||||
{
|
||||
my_bool key_cache_inited;
|
||||
my_bool in_resize; /* true during resize operation */
|
||||
my_bool resize_in_flush; /* true during flush of resize operation */
|
||||
my_bool can_be_used; /* usage of cache for read/write is allowed */
|
||||
size_t key_cache_mem_size; /* specified size of the cache memory */
|
||||
uint key_cache_block_size; /* size of the page buffer of a cache block */
|
||||
ulonglong min_warm_blocks; /* min number of warm blocks; */
|
||||
ulonglong age_threshold; /* age threshold for hot blocks */
|
||||
ulonglong keycache_time; /* total number of block link operations */
|
||||
uint hash_entries; /* max number of entries in the hash table */
|
||||
int hash_links; /* max number of hash links */
|
||||
int hash_links_used; /* number of hash links currently used */
|
||||
int disk_blocks; /* max number of blocks in the cache */
|
||||
ulong blocks_used; /* maximum number of concurrently used blocks */
|
||||
ulong blocks_unused; /* number of currently unused blocks */
|
||||
ulong blocks_changed; /* number of currently dirty blocks */
|
||||
ulong warm_blocks; /* number of blocks in warm sub-chain */
|
||||
ulong cnt_for_resize_op; /* counter to block resize operation */
|
||||
long blocks_available; /* number of blocks available in the LRU chain */
|
||||
HASH_LINK **hash_root; /* arr. of entries into hash table buckets */
|
||||
HASH_LINK *hash_link_root; /* memory for hash table links */
|
||||
HASH_LINK *free_hash_list; /* list of free hash links */
|
||||
BLOCK_LINK *free_block_list; /* list of free blocks */
|
||||
BLOCK_LINK *block_root; /* memory for block links */
|
||||
uchar *block_mem; /* memory for block buffers */
|
||||
BLOCK_LINK *used_last; /* ptr to the last block of the LRU chain */
|
||||
BLOCK_LINK *used_ins; /* ptr to the insertion block in LRU chain */
|
||||
mysql_mutex_t cache_lock; /* to lock access to the cache structure */
|
||||
KEYCACHE_WQUEUE resize_queue; /* threads waiting during resize operation */
|
||||
/*
|
||||
Waiting for a zero resize count. Using a queue for symmetry though
|
||||
only one thread can wait here.
|
||||
*/
|
||||
KEYCACHE_WQUEUE waiting_for_resize_cnt;
|
||||
KEYCACHE_WQUEUE waiting_for_hash_link; /* waiting for a free hash link */
|
||||
KEYCACHE_WQUEUE waiting_for_block; /* requests waiting for a free block */
|
||||
BLOCK_LINK *changed_blocks[CHANGED_BLOCKS_HASH]; /* hash for dirty file bl.*/
|
||||
BLOCK_LINK *file_blocks[CHANGED_BLOCKS_HASH]; /* hash for other file bl.*/
|
||||
|
||||
/*
|
||||
The following variables are and variables used to hold parameters for
|
||||
initializing the key cache.
|
||||
*/
|
||||
|
||||
ulonglong param_buff_size; /* size the memory allocated for the cache */
|
||||
ulonglong param_block_size; /* size of the blocks in the key cache */
|
||||
ulonglong param_division_limit; /* min. percentage of warm blocks */
|
||||
ulonglong param_age_threshold; /* determines when hot block is downgraded */
|
||||
|
||||
/* Statistics variables. These are reset in reset_key_cache_counters(). */
|
||||
ulong global_blocks_changed; /* number of currently dirty blocks */
|
||||
ulonglong global_cache_w_requests;/* number of write requests (write hits) */
|
||||
ulonglong global_cache_write; /* number of writes from cache to files */
|
||||
ulonglong global_cache_r_requests;/* number of read requests (read hits) */
|
||||
ulonglong global_cache_read; /* number of reads from files to cache */
|
||||
|
||||
int blocks; /* max number of blocks in the cache */
|
||||
my_bool in_init; /* Set to 1 in MySQL during init/resize */
|
||||
} KEY_CACHE;
|
||||
|
||||
/* The default key cache */
|
||||
extern KEY_CACHE dflt_key_cache_var, *dflt_key_cache;
|
||||
|
||||
extern int init_key_cache(KEY_CACHE *keycache, ulonglong key_cache_block_size,
|
||||
size_t use_mem, ulonglong division_limit,
|
||||
ulonglong age_threshold);
|
||||
extern int resize_key_cache(KEY_CACHE *keycache,
|
||||
st_keycache_thread_var *thread_var,
|
||||
ulonglong key_cache_block_size,
|
||||
size_t use_mem, ulonglong division_limit,
|
||||
ulonglong age_threshold);
|
||||
extern uchar *key_cache_read(KEY_CACHE *keycache,
|
||||
st_keycache_thread_var *thread_var,
|
||||
File file, my_off_t filepos, int level,
|
||||
uchar *buff, uint length,
|
||||
uint block_length,int return_buffer);
|
||||
extern int key_cache_insert(KEY_CACHE *keycache,
|
||||
st_keycache_thread_var *thread_var,
|
||||
File file, my_off_t filepos, int level,
|
||||
uchar *buff, uint length);
|
||||
extern int key_cache_write(KEY_CACHE *keycache,
|
||||
st_keycache_thread_var *thread_var,
|
||||
File file, my_off_t filepos, int level,
|
||||
uchar *buff, uint length,
|
||||
uint block_length,int force_write);
|
||||
extern int flush_key_blocks(KEY_CACHE *keycache,
|
||||
st_keycache_thread_var *thread_var,
|
||||
int file, enum flush_type type);
|
||||
extern void end_key_cache(KEY_CACHE *keycache, my_bool cleanup);
|
||||
|
||||
/* Functions to handle multiple key caches */
|
||||
extern my_bool multi_keycache_init(void);
|
||||
extern void multi_keycache_free(void);
|
||||
extern KEY_CACHE *multi_key_cache_search(uchar *key, uint length);
|
||||
extern my_bool multi_key_cache_set(const uchar *key, uint length,
|
||||
KEY_CACHE *key_cache);
|
||||
extern void multi_key_cache_change(KEY_CACHE *old_data,
|
||||
KEY_CACHE *new_data);
|
||||
extern int reset_key_cache_counters(const char *name,
|
||||
KEY_CACHE *key_cache);
|
||||
C_MODE_END
|
||||
#endif /* _keycache_h */
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
#ifndef LITTLE_ENDIAN_INCLUDED
|
||||
#define LITTLE_ENDIAN_INCLUDED
|
||||
/* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
/*
|
||||
Data in little-endian format.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
static inline void float4get (float *V, const uchar *M)
|
||||
{
|
||||
memcpy(V, (M), sizeof(float));
|
||||
}
|
||||
|
||||
static inline void float4store(uchar *V, float M)
|
||||
{
|
||||
memcpy(V, (&M), sizeof(float));
|
||||
}
|
||||
|
||||
static inline void float8get (double *V, const uchar *M)
|
||||
{
|
||||
memcpy(V, M, sizeof(double));
|
||||
}
|
||||
|
||||
static inline void float8store(uchar *V, double M)
|
||||
{
|
||||
memcpy(V, &M, sizeof(double));
|
||||
}
|
||||
|
||||
static inline void floatget (float *V, const uchar *M) { float4get(V, M); }
|
||||
static inline void floatstore (uchar *V, float M) { float4store(V, M); }
|
||||
|
||||
/* Bi-endian hardware.... */
|
||||
#if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN)
|
||||
static inline void doublestore(uchar *T, double V)
|
||||
{ *(((char*)T)+0)=(char) ((uchar *) &V)[4];
|
||||
*(((char*)T)+1)=(char) ((uchar *) &V)[5];
|
||||
*(((char*)T)+2)=(char) ((uchar *) &V)[6];
|
||||
*(((char*)T)+3)=(char) ((uchar *) &V)[7];
|
||||
*(((char*)T)+4)=(char) ((uchar *) &V)[0];
|
||||
*(((char*)T)+5)=(char) ((uchar *) &V)[1];
|
||||
*(((char*)T)+6)=(char) ((uchar *) &V)[2];
|
||||
*(((char*)T)+7)=(char) ((uchar *) &V)[3]; }
|
||||
static inline void doubleget(double *V, const uchar *M)
|
||||
{ double def_temp;
|
||||
((uchar*) &def_temp)[0]=(M)[4];
|
||||
((uchar*) &def_temp)[1]=(M)[5];
|
||||
((uchar*) &def_temp)[2]=(M)[6];
|
||||
((uchar*) &def_temp)[3]=(M)[7];
|
||||
((uchar*) &def_temp)[4]=(M)[0];
|
||||
((uchar*) &def_temp)[5]=(M)[1];
|
||||
((uchar*) &def_temp)[6]=(M)[2];
|
||||
((uchar*) &def_temp)[7]=(M)[3];
|
||||
(*V) = def_temp; }
|
||||
|
||||
#else /* Bi-endian hardware.... */
|
||||
|
||||
static inline void doublestore(uchar *T, double V) { memcpy(T, &V, sizeof(double)); }
|
||||
static inline void doubleget (double *V, const uchar *M) { memcpy(V, M, sizeof(double)); }
|
||||
|
||||
#endif /* Bi-endian hardware.... */
|
||||
|
||||
static inline void ushortget(uint16 *V, const uchar *pM) { *V= uint2korr(pM); }
|
||||
static inline void shortget (int16 *V, const uchar *pM) { *V= sint2korr(pM); }
|
||||
static inline void longget (int32 *V, const uchar *pM) { *V= sint4korr(pM); }
|
||||
static inline void ulongget (uint32 *V, const uchar *pM) { *V= uint4korr(pM); }
|
||||
static inline void shortstore(uchar *T, int16 V) { int2store(T, V); }
|
||||
static inline void longstore (uchar *T, int32 V) { int4store(T, V); }
|
||||
|
||||
static inline void longlongget(longlong *V, const uchar *M)
|
||||
{
|
||||
memcpy(V, (M), sizeof(ulonglong));
|
||||
}
|
||||
static inline void longlongstore(uchar *T, longlong V)
|
||||
{
|
||||
memcpy((T), &V, sizeof(ulonglong));
|
||||
}
|
||||
|
||||
#endif /* LITTLE_ENDIAN_INCLUDED */
|
||||
|
|
@ -1,806 +0,0 @@
|
|||
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
/*
|
||||
A better inplementation of the UNIX ctype(3) library.
|
||||
*/
|
||||
|
||||
#ifndef _m_ctype_h
|
||||
#define _m_ctype_h
|
||||
|
||||
#include "my_global.h" /* uint16, uchar */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define MY_CS_NAME_SIZE 32
|
||||
#define MY_CS_CTYPE_TABLE_SIZE 257
|
||||
#define MY_CS_TO_LOWER_TABLE_SIZE 256
|
||||
#define MY_CS_TO_UPPER_TABLE_SIZE 256
|
||||
#define MY_CS_SORT_ORDER_TABLE_SIZE 256
|
||||
#define MY_CS_TO_UNI_TABLE_SIZE 256
|
||||
|
||||
#define CHARSET_DIR "charsets/"
|
||||
|
||||
#define my_wc_t ulong
|
||||
|
||||
#define MY_CS_REPLACEMENT_CHARACTER 0xFFFD
|
||||
|
||||
/*
|
||||
On i386 we store Unicode->CS conversion tables for
|
||||
some character sets using Big-endian order,
|
||||
to copy two bytes at onces.
|
||||
This gives some performance improvement.
|
||||
*/
|
||||
#ifdef __i386__
|
||||
#define MB2(x) (((x) >> 8) + (((x) & 0xFF) << 8))
|
||||
#define MY_PUT_MB2(s, code) { *((uint16*)(s))= (code); }
|
||||
#else
|
||||
#define MB2(x) (x)
|
||||
#define MY_PUT_MB2(s, code) { (s)[0]= code >> 8; (s)[1]= code & 0xFF; }
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
typedef struct unicase_info_char_st
|
||||
{
|
||||
uint32 toupper;
|
||||
uint32 tolower;
|
||||
uint32 sort;
|
||||
} MY_UNICASE_CHARACTER;
|
||||
|
||||
|
||||
typedef struct unicase_info_st
|
||||
{
|
||||
my_wc_t maxchar;
|
||||
const MY_UNICASE_CHARACTER **page;
|
||||
} MY_UNICASE_INFO;
|
||||
|
||||
|
||||
extern MY_UNICASE_INFO my_unicase_default;
|
||||
extern MY_UNICASE_INFO my_unicase_turkish;
|
||||
extern MY_UNICASE_INFO my_unicase_mysql500;
|
||||
extern MY_UNICASE_INFO my_unicase_unicode520;
|
||||
|
||||
#define MY_UCA_MAX_CONTRACTION 6
|
||||
#define MY_UCA_MAX_WEIGHT_SIZE 8
|
||||
#define MY_UCA_WEIGHT_LEVELS 1
|
||||
|
||||
typedef struct my_contraction_t
|
||||
{
|
||||
my_wc_t ch[MY_UCA_MAX_CONTRACTION]; /* Character sequence */
|
||||
uint16 weight[MY_UCA_MAX_WEIGHT_SIZE];/* Its weight string, 0-terminated */
|
||||
my_bool with_context;
|
||||
} MY_CONTRACTION;
|
||||
|
||||
|
||||
|
||||
typedef struct my_contraction_list_t
|
||||
{
|
||||
size_t nitems; /* Number of items in the list */
|
||||
MY_CONTRACTION *item; /* List of contractions */
|
||||
char *flags; /* Character flags, e.g. "is contraction head") */
|
||||
} MY_CONTRACTIONS;
|
||||
|
||||
|
||||
my_bool my_uca_can_be_contraction_head(const MY_CONTRACTIONS *c, my_wc_t wc);
|
||||
my_bool my_uca_can_be_contraction_tail(const MY_CONTRACTIONS *c, my_wc_t wc);
|
||||
uint16 *my_uca_contraction2_weight(const MY_CONTRACTIONS *c,
|
||||
my_wc_t wc1, my_wc_t wc2);
|
||||
|
||||
|
||||
/* Collation weights on a single level (e.g. primary, secondary, tertiarty) */
|
||||
typedef struct my_uca_level_info_st
|
||||
{
|
||||
my_wc_t maxchar;
|
||||
uchar *lengths;
|
||||
uint16 **weights;
|
||||
MY_CONTRACTIONS contractions;
|
||||
} MY_UCA_WEIGHT_LEVEL;
|
||||
|
||||
|
||||
typedef struct uca_info_st
|
||||
{
|
||||
MY_UCA_WEIGHT_LEVEL level[MY_UCA_WEIGHT_LEVELS];
|
||||
|
||||
/* Logical positions */
|
||||
my_wc_t first_non_ignorable;
|
||||
my_wc_t last_non_ignorable;
|
||||
my_wc_t first_primary_ignorable;
|
||||
my_wc_t last_primary_ignorable;
|
||||
my_wc_t first_secondary_ignorable;
|
||||
my_wc_t last_secondary_ignorable;
|
||||
my_wc_t first_tertiary_ignorable;
|
||||
my_wc_t last_tertiary_ignorable;
|
||||
my_wc_t first_trailing;
|
||||
my_wc_t last_trailing;
|
||||
my_wc_t first_variable;
|
||||
my_wc_t last_variable;
|
||||
|
||||
} MY_UCA_INFO;
|
||||
|
||||
|
||||
|
||||
extern MY_UCA_INFO my_uca_v400;
|
||||
|
||||
|
||||
typedef struct uni_ctype_st
|
||||
{
|
||||
uchar pctype;
|
||||
uchar *ctype;
|
||||
} MY_UNI_CTYPE;
|
||||
|
||||
extern MY_UNI_CTYPE my_uni_ctype[256];
|
||||
|
||||
/* wm_wc and wc_mb return codes */
|
||||
#define MY_CS_ILSEQ 0 /* Wrong by sequence: wb_wc */
|
||||
#define MY_CS_ILUNI 0 /* Cannot encode Unicode to charset: wc_mb */
|
||||
#define MY_CS_TOOSMALL -101 /* Need at least one byte: wc_mb and mb_wc */
|
||||
#define MY_CS_TOOSMALL2 -102 /* Need at least two bytes: wc_mb and mb_wc */
|
||||
#define MY_CS_TOOSMALL3 -103 /* Need at least three bytes: wc_mb and mb_wc */
|
||||
/* These following three are currently not really used */
|
||||
#define MY_CS_TOOSMALL4 -104 /* Need at least 4 bytes: wc_mb and mb_wc */
|
||||
#define MY_CS_TOOSMALL5 -105 /* Need at least 5 bytes: wc_mb and mb_wc */
|
||||
#define MY_CS_TOOSMALL6 -106 /* Need at least 6 bytes: wc_mb and mb_wc */
|
||||
/* A helper macros for "need at least n bytes" */
|
||||
#define MY_CS_TOOSMALLN(n) (-100-(n))
|
||||
|
||||
#define MY_SEQ_INTTAIL 1
|
||||
#define MY_SEQ_SPACES 2
|
||||
|
||||
/* My charsets_list flags */
|
||||
#define MY_CS_COMPILED 1 /* compiled-in sets */
|
||||
#define MY_CS_CONFIG 2 /* sets that have a *.conf file */
|
||||
#define MY_CS_INDEX 4 /* sets listed in the Index file */
|
||||
#define MY_CS_LOADED 8 /* sets that are currently loaded */
|
||||
#define MY_CS_BINSORT 16 /* if binary sort order */
|
||||
#define MY_CS_PRIMARY 32 /* if primary collation */
|
||||
#define MY_CS_STRNXFRM 64 /* if strnxfrm is used for sort */
|
||||
#define MY_CS_UNICODE 128 /* is a charset is BMP Unicode */
|
||||
#define MY_CS_READY 256 /* if a charset is initialized */
|
||||
#define MY_CS_AVAILABLE 512 /* If either compiled-in or loaded*/
|
||||
#define MY_CS_CSSORT 1024 /* if case sensitive sort order */
|
||||
#define MY_CS_HIDDEN 2048 /* don't display in SHOW */
|
||||
#define MY_CS_PUREASCII 4096 /* if a charset is pure ascii */
|
||||
#define MY_CS_NONASCII 8192 /* if not ASCII-compatible */
|
||||
#define MY_CS_UNICODE_SUPPLEMENT 16384 /* Non-BMP Unicode characters */
|
||||
#define MY_CS_LOWER_SORT 32768 /* If use lower case as weight */
|
||||
#define MY_CHARSET_UNDEFINED 0
|
||||
|
||||
/* Character repertoire flags */
|
||||
#define MY_REPERTOIRE_ASCII 1 /* Pure ASCII U+0000..U+007F */
|
||||
#define MY_REPERTOIRE_EXTENDED 2 /* Extended characters: U+0080..U+FFFF */
|
||||
#define MY_REPERTOIRE_UNICODE30 3 /* ASCII | EXTENDED: U+0000..U+FFFF */
|
||||
|
||||
/* Flags for strxfrm */
|
||||
#define MY_STRXFRM_LEVEL1 0x00000001 /* for primary weights */
|
||||
#define MY_STRXFRM_LEVEL2 0x00000002 /* for secondary weights */
|
||||
#define MY_STRXFRM_LEVEL3 0x00000004 /* for tertiary weights */
|
||||
#define MY_STRXFRM_LEVEL4 0x00000008 /* fourth level weights */
|
||||
#define MY_STRXFRM_LEVEL5 0x00000010 /* fifth level weights */
|
||||
#define MY_STRXFRM_LEVEL6 0x00000020 /* sixth level weights */
|
||||
#define MY_STRXFRM_LEVEL_ALL 0x0000003F /* Bit OR for the above six */
|
||||
#define MY_STRXFRM_NLEVELS 6 /* Number of possible levels*/
|
||||
|
||||
#define MY_STRXFRM_PAD_WITH_SPACE 0x00000040 /* if pad result with spaces */
|
||||
#define MY_STRXFRM_PAD_TO_MAXLEN 0x00000080 /* if pad tail(for filesort) */
|
||||
|
||||
#define MY_STRXFRM_DESC_LEVEL1 0x00000100 /* if desc order for level1 */
|
||||
#define MY_STRXFRM_DESC_LEVEL2 0x00000200 /* if desc order for level2 */
|
||||
#define MY_STRXFRM_DESC_LEVEL3 0x00000300 /* if desc order for level3 */
|
||||
#define MY_STRXFRM_DESC_LEVEL4 0x00000800 /* if desc order for level4 */
|
||||
#define MY_STRXFRM_DESC_LEVEL5 0x00001000 /* if desc order for level5 */
|
||||
#define MY_STRXFRM_DESC_LEVEL6 0x00002000 /* if desc order for level6 */
|
||||
#define MY_STRXFRM_DESC_SHIFT 8
|
||||
|
||||
#define MY_STRXFRM_UNUSED_00004000 0x00004000 /* for future extensions */
|
||||
#define MY_STRXFRM_UNUSED_00008000 0x00008000 /* for future extensions */
|
||||
|
||||
#define MY_STRXFRM_REVERSE_LEVEL1 0x00010000 /* if reverse order for level1 */
|
||||
#define MY_STRXFRM_REVERSE_LEVEL2 0x00020000 /* if reverse order for level2 */
|
||||
#define MY_STRXFRM_REVERSE_LEVEL3 0x00040000 /* if reverse order for level3 */
|
||||
#define MY_STRXFRM_REVERSE_LEVEL4 0x00080000 /* if reverse order for level4 */
|
||||
#define MY_STRXFRM_REVERSE_LEVEL5 0x00100000 /* if reverse order for level5 */
|
||||
#define MY_STRXFRM_REVERSE_LEVEL6 0x00200000 /* if reverse order for level6 */
|
||||
#define MY_STRXFRM_REVERSE_SHIFT 16
|
||||
|
||||
|
||||
typedef struct my_uni_idx_st
|
||||
{
|
||||
uint16 from;
|
||||
uint16 to;
|
||||
const uchar *tab;
|
||||
} MY_UNI_IDX;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint beg;
|
||||
uint end;
|
||||
uint mb_len;
|
||||
} my_match_t;
|
||||
|
||||
struct charset_info_st;
|
||||
|
||||
typedef struct my_charset_loader_st
|
||||
{
|
||||
char error[128];
|
||||
void *(*once_alloc)(size_t);
|
||||
void *(*mem_malloc)(size_t);
|
||||
void *(*mem_realloc)(void *, size_t);
|
||||
void (*mem_free)(void *);
|
||||
void (*reporter)(enum loglevel, const char *format, ...);
|
||||
int (*add_collation)(struct charset_info_st *cs);
|
||||
} MY_CHARSET_LOADER;
|
||||
|
||||
|
||||
extern int (*my_string_stack_guard)(int);
|
||||
|
||||
/* See strings/CHARSET_INFO.txt for information about this structure */
|
||||
typedef struct my_collation_handler_st
|
||||
{
|
||||
my_bool (*init)(struct charset_info_st *, MY_CHARSET_LOADER *);
|
||||
/* Collation routines */
|
||||
int (*strnncoll)(const struct charset_info_st *,
|
||||
const uchar *, size_t, const uchar *, size_t, my_bool);
|
||||
int (*strnncollsp)(const struct charset_info_st *,
|
||||
const uchar *, size_t, const uchar *, size_t,
|
||||
my_bool diff_if_only_endspace_difference);
|
||||
size_t (*strnxfrm)(const struct charset_info_st *,
|
||||
uchar *dst, size_t dstlen, uint nweights,
|
||||
const uchar *src, size_t srclen, uint flags);
|
||||
size_t (*strnxfrmlen)(const struct charset_info_st *, size_t);
|
||||
my_bool (*like_range)(const struct charset_info_st *,
|
||||
const char *s, size_t s_length,
|
||||
pchar w_prefix, pchar w_one, pchar w_many,
|
||||
size_t res_length,
|
||||
char *min_str, char *max_str,
|
||||
size_t *min_len, size_t *max_len);
|
||||
int (*wildcmp)(const struct charset_info_st *,
|
||||
const char *str,const char *str_end,
|
||||
const char *wildstr,const char *wildend,
|
||||
int escape,int w_one, int w_many);
|
||||
|
||||
int (*strcasecmp)(const struct charset_info_st *, const char *,
|
||||
const char *);
|
||||
|
||||
uint (*instr)(const struct charset_info_st *,
|
||||
const char *b, size_t b_length,
|
||||
const char *s, size_t s_length,
|
||||
my_match_t *match, uint nmatch);
|
||||
|
||||
/* Hash calculation */
|
||||
void (*hash_sort)(const struct charset_info_st *cs, const uchar *key,
|
||||
size_t len, ulong *nr1, ulong *nr2);
|
||||
my_bool (*propagate)(const struct charset_info_st *cs, const uchar *str,
|
||||
size_t len);
|
||||
} MY_COLLATION_HANDLER;
|
||||
|
||||
extern MY_COLLATION_HANDLER my_collation_mb_bin_handler;
|
||||
extern MY_COLLATION_HANDLER my_collation_8bit_bin_handler;
|
||||
extern MY_COLLATION_HANDLER my_collation_8bit_simple_ci_handler;
|
||||
extern MY_COLLATION_HANDLER my_collation_ucs2_uca_handler;
|
||||
|
||||
/* Some typedef to make it easy for C++ to make function pointers */
|
||||
typedef int (*my_charset_conv_mb_wc)(const struct charset_info_st *,
|
||||
my_wc_t *, const uchar *, const uchar *);
|
||||
typedef int (*my_charset_conv_wc_mb)(const struct charset_info_st *, my_wc_t,
|
||||
uchar *, uchar *);
|
||||
typedef size_t (*my_charset_conv_case)(const struct charset_info_st *,
|
||||
char *, size_t, char *, size_t);
|
||||
|
||||
|
||||
/* See strings/CHARSET_INFO.txt about information on this structure */
|
||||
typedef struct my_charset_handler_st
|
||||
{
|
||||
my_bool (*init)(struct charset_info_st *, MY_CHARSET_LOADER *loader);
|
||||
/* Multibyte routines */
|
||||
uint (*ismbchar)(const struct charset_info_st *, const char *,
|
||||
const char *);
|
||||
uint (*mbcharlen)(const struct charset_info_st *, uint c);
|
||||
size_t (*numchars)(const struct charset_info_st *, const char *b,
|
||||
const char *e);
|
||||
size_t (*charpos)(const struct charset_info_st *, const char *b,
|
||||
const char *e, size_t pos);
|
||||
size_t (*well_formed_len)(const struct charset_info_st *,
|
||||
const char *b,const char *e,
|
||||
size_t nchars, int *error);
|
||||
size_t (*lengthsp)(const struct charset_info_st *, const char *ptr,
|
||||
size_t length);
|
||||
size_t (*numcells)(const struct charset_info_st *, const char *b,
|
||||
const char *e);
|
||||
|
||||
/* Unicode conversion */
|
||||
my_charset_conv_mb_wc mb_wc;
|
||||
my_charset_conv_wc_mb wc_mb;
|
||||
|
||||
/* CTYPE scanner */
|
||||
int (*ctype)(const struct charset_info_st *cs, int *ctype,
|
||||
const uchar *s, const uchar *e);
|
||||
|
||||
/* Functions for case and sort conversion */
|
||||
size_t (*caseup_str)(const struct charset_info_st *, char *);
|
||||
size_t (*casedn_str)(const struct charset_info_st *, char *);
|
||||
|
||||
my_charset_conv_case caseup;
|
||||
my_charset_conv_case casedn;
|
||||
|
||||
/* Charset dependant snprintf() */
|
||||
size_t (*snprintf)(const struct charset_info_st *, char *to, size_t n,
|
||||
const char *fmt,
|
||||
...) MY_ATTRIBUTE((format(printf, 4, 5)));
|
||||
size_t (*long10_to_str)(const struct charset_info_st *, char *to, size_t n,
|
||||
int radix, long int val);
|
||||
size_t (*longlong10_to_str)(const struct charset_info_st *, char *to,
|
||||
size_t n, int radix, longlong val);
|
||||
|
||||
void (*fill)(const struct charset_info_st *, char *to, size_t len,
|
||||
int fill);
|
||||
|
||||
/* String-to-number conversion routines */
|
||||
long (*strntol)(const struct charset_info_st *, const char *s,
|
||||
size_t l, int base, char **e, int *err);
|
||||
ulong (*strntoul)(const struct charset_info_st *, const char *s,
|
||||
size_t l, int base, char **e, int *err);
|
||||
longlong (*strntoll)(const struct charset_info_st *, const char *s,
|
||||
size_t l, int base, char **e, int *err);
|
||||
ulonglong (*strntoull)(const struct charset_info_st *, const char *s,
|
||||
size_t l, int base, char **e, int *err);
|
||||
double (*strntod)(const struct charset_info_st *, char *s,
|
||||
size_t l, char **e, int *err);
|
||||
longlong (*strtoll10)(const struct charset_info_st *cs,
|
||||
const char *nptr, char **endptr, int *error);
|
||||
ulonglong (*strntoull10rnd)(const struct charset_info_st *cs,
|
||||
const char *str, size_t length,
|
||||
int unsigned_fl,
|
||||
char **endptr, int *error);
|
||||
size_t (*scan)(const struct charset_info_st *, const char *b,
|
||||
const char *e, int sq);
|
||||
} MY_CHARSET_HANDLER;
|
||||
|
||||
extern MY_CHARSET_HANDLER my_charset_8bit_handler;
|
||||
extern MY_CHARSET_HANDLER my_charset_ascii_handler;
|
||||
extern MY_CHARSET_HANDLER my_charset_ucs2_handler;
|
||||
|
||||
|
||||
/*
|
||||
We define this CHARSET_INFO_DEFINED here to prevent a repeat of the
|
||||
typedef in hash.c, which will cause a compiler error.
|
||||
*/
|
||||
#define CHARSET_INFO_DEFINED
|
||||
|
||||
/* See strings/CHARSET_INFO.txt about information on this structure */
|
||||
typedef struct charset_info_st
|
||||
{
|
||||
uint number;
|
||||
uint primary_number;
|
||||
uint binary_number;
|
||||
uint state;
|
||||
const char *csname;
|
||||
const char *name;
|
||||
const char *comment;
|
||||
const char *tailoring;
|
||||
const uchar *ctype;
|
||||
const uchar *to_lower;
|
||||
const uchar *to_upper;
|
||||
const uchar *sort_order;
|
||||
MY_UCA_INFO *uca; /* This can be changed in apply_one_rule() */
|
||||
const uint16 *tab_to_uni;
|
||||
const MY_UNI_IDX *tab_from_uni;
|
||||
const MY_UNICASE_INFO *caseinfo;
|
||||
const struct lex_state_maps_st *state_maps; /* parser internal data */
|
||||
const uchar *ident_map; /* parser internal data */
|
||||
uint strxfrm_multiply;
|
||||
uchar caseup_multiply;
|
||||
uchar casedn_multiply;
|
||||
uint mbminlen;
|
||||
uint mbmaxlen;
|
||||
uint mbmaxlenlen;
|
||||
my_wc_t min_sort_char;
|
||||
my_wc_t max_sort_char; /* For LIKE optimization */
|
||||
uchar pad_char;
|
||||
my_bool escape_with_backslash_is_dangerous;
|
||||
uchar levels_for_compare;
|
||||
uchar levels_for_order;
|
||||
|
||||
MY_CHARSET_HANDLER *cset;
|
||||
MY_COLLATION_HANDLER *coll;
|
||||
|
||||
} CHARSET_INFO;
|
||||
#define ILLEGAL_CHARSET_INFO_NUMBER (~0U)
|
||||
|
||||
|
||||
extern MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_bin;
|
||||
extern MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_latin1;
|
||||
extern MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_filename;
|
||||
|
||||
extern CHARSET_INFO my_charset_big5_chinese_ci;
|
||||
extern CHARSET_INFO my_charset_big5_bin;
|
||||
extern CHARSET_INFO my_charset_cp932_japanese_ci;
|
||||
extern CHARSET_INFO my_charset_cp932_bin;
|
||||
extern CHARSET_INFO my_charset_cp1250_czech_ci;
|
||||
extern CHARSET_INFO my_charset_eucjpms_japanese_ci;
|
||||
extern CHARSET_INFO my_charset_eucjpms_bin;
|
||||
extern CHARSET_INFO my_charset_euckr_korean_ci;
|
||||
extern CHARSET_INFO my_charset_euckr_bin;
|
||||
extern CHARSET_INFO my_charset_gb2312_chinese_ci;
|
||||
extern CHARSET_INFO my_charset_gb2312_bin;
|
||||
extern CHARSET_INFO my_charset_gbk_chinese_ci;
|
||||
extern CHARSET_INFO my_charset_gbk_bin;
|
||||
extern CHARSET_INFO my_charset_gb18030_chinese_ci;
|
||||
extern CHARSET_INFO my_charset_gb18030_bin;
|
||||
extern CHARSET_INFO my_charset_latin1_german2_ci;
|
||||
extern CHARSET_INFO my_charset_latin1_bin;
|
||||
extern CHARSET_INFO my_charset_latin2_czech_ci;
|
||||
extern CHARSET_INFO my_charset_sjis_japanese_ci;
|
||||
extern CHARSET_INFO my_charset_sjis_bin;
|
||||
extern CHARSET_INFO my_charset_tis620_thai_ci;
|
||||
extern CHARSET_INFO my_charset_tis620_bin;
|
||||
extern CHARSET_INFO my_charset_ucs2_general_ci;
|
||||
extern CHARSET_INFO my_charset_ucs2_bin;
|
||||
extern CHARSET_INFO my_charset_ucs2_unicode_ci;
|
||||
extern CHARSET_INFO my_charset_ucs2_general_mysql500_ci;
|
||||
extern CHARSET_INFO my_charset_ujis_japanese_ci;
|
||||
extern CHARSET_INFO my_charset_ujis_bin;
|
||||
extern CHARSET_INFO my_charset_utf16_bin;
|
||||
extern CHARSET_INFO my_charset_utf16_general_ci;
|
||||
extern CHARSET_INFO my_charset_utf16_unicode_ci;
|
||||
extern CHARSET_INFO my_charset_utf16le_bin;
|
||||
extern CHARSET_INFO my_charset_utf16le_general_ci;
|
||||
extern CHARSET_INFO my_charset_utf32_bin;
|
||||
extern CHARSET_INFO my_charset_utf32_general_ci;
|
||||
extern CHARSET_INFO my_charset_utf32_unicode_ci;
|
||||
|
||||
extern MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_utf8_general_ci;
|
||||
extern CHARSET_INFO my_charset_utf8_tolower_ci;
|
||||
extern CHARSET_INFO my_charset_utf8_unicode_ci;
|
||||
extern CHARSET_INFO my_charset_utf8_bin;
|
||||
extern CHARSET_INFO my_charset_utf8_general_mysql500_ci;
|
||||
extern CHARSET_INFO my_charset_utf8mb4_bin;
|
||||
extern MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_utf8mb4_general_ci;
|
||||
extern CHARSET_INFO my_charset_utf8mb4_unicode_ci;
|
||||
#define MY_UTF8MB3 "utf8"
|
||||
#define MY_UTF8MB4 "utf8mb4"
|
||||
|
||||
|
||||
/* declarations for simple charsets */
|
||||
extern size_t my_strnxfrm_simple(const CHARSET_INFO *,
|
||||
uchar *dst, size_t dstlen, uint nweights,
|
||||
const uchar *src, size_t srclen, uint flags);
|
||||
size_t my_strnxfrmlen_simple(const CHARSET_INFO *, size_t);
|
||||
extern int my_strnncoll_simple(const CHARSET_INFO *, const uchar *, size_t,
|
||||
const uchar *, size_t, my_bool);
|
||||
|
||||
extern int my_strnncollsp_simple(const CHARSET_INFO *, const uchar *, size_t,
|
||||
const uchar *, size_t,
|
||||
my_bool diff_if_only_endspace_difference);
|
||||
|
||||
extern void my_hash_sort_simple(const CHARSET_INFO *cs,
|
||||
const uchar *key, size_t len,
|
||||
ulong *nr1, ulong *nr2);
|
||||
|
||||
extern size_t my_lengthsp_8bit(const CHARSET_INFO *cs, const char *ptr,
|
||||
size_t length);
|
||||
|
||||
extern uint my_instr_simple(const struct charset_info_st *,
|
||||
const char *b, size_t b_length,
|
||||
const char *s, size_t s_length,
|
||||
my_match_t *match, uint nmatch);
|
||||
|
||||
|
||||
/* Functions for 8bit */
|
||||
extern size_t my_caseup_str_8bit(const CHARSET_INFO *, char *);
|
||||
extern size_t my_casedn_str_8bit(const CHARSET_INFO *, char *);
|
||||
extern size_t my_caseup_8bit(const CHARSET_INFO *, char *src, size_t srclen,
|
||||
char *dst, size_t dstlen);
|
||||
extern size_t my_casedn_8bit(const CHARSET_INFO *, char *src, size_t srclen,
|
||||
char *dst, size_t dstlen);
|
||||
|
||||
extern int my_strcasecmp_8bit(const CHARSET_INFO * cs, const char *,
|
||||
const char *);
|
||||
|
||||
int my_mb_wc_8bit(const CHARSET_INFO *cs,my_wc_t *wc, const uchar *s,
|
||||
const uchar *e);
|
||||
int my_wc_mb_8bit(const CHARSET_INFO *cs,my_wc_t wc, uchar *s, uchar *e);
|
||||
|
||||
int my_mb_ctype_8bit(const CHARSET_INFO *,int *, const uchar *,const uchar *);
|
||||
int my_mb_ctype_mb(const CHARSET_INFO *,int *, const uchar *,const uchar *);
|
||||
|
||||
size_t my_scan_8bit(const CHARSET_INFO *cs, const char *b, const char *e,
|
||||
int sq);
|
||||
|
||||
size_t my_snprintf_8bit(const struct charset_info_st *, char *to, size_t n,
|
||||
const char *fmt, ...)
|
||||
MY_ATTRIBUTE((format(printf, 4, 5)));
|
||||
|
||||
long my_strntol_8bit(const CHARSET_INFO *, const char *s, size_t l,
|
||||
int base, char **e, int *err);
|
||||
ulong my_strntoul_8bit(const CHARSET_INFO *, const char *s, size_t l,
|
||||
int base, char **e, int *err);
|
||||
longlong my_strntoll_8bit(const CHARSET_INFO *, const char *s, size_t l,
|
||||
int base, char **e, int *err);
|
||||
ulonglong my_strntoull_8bit(const CHARSET_INFO *, const char *s, size_t l,
|
||||
int base, char **e, int *err);
|
||||
double my_strntod_8bit(const CHARSET_INFO *, char *s, size_t l, char **e,
|
||||
int *err);
|
||||
size_t my_long10_to_str_8bit(const CHARSET_INFO *, char *to, size_t l,
|
||||
int radix, long int val);
|
||||
size_t my_longlong10_to_str_8bit(const CHARSET_INFO *, char *to, size_t l,
|
||||
int radix, longlong val);
|
||||
|
||||
longlong my_strtoll10_8bit(const CHARSET_INFO *cs,
|
||||
const char *nptr, char **endptr, int *error);
|
||||
longlong my_strtoll10_ucs2(const CHARSET_INFO *cs,
|
||||
const char *nptr, char **endptr, int *error);
|
||||
|
||||
ulonglong my_strntoull10rnd_8bit(const CHARSET_INFO *cs,
|
||||
const char *str, size_t length, int
|
||||
unsigned_fl, char **endptr, int *error);
|
||||
ulonglong my_strntoull10rnd_ucs2(const CHARSET_INFO *cs,
|
||||
const char *str, size_t length,
|
||||
int unsigned_fl, char **endptr, int *error);
|
||||
|
||||
void my_fill_8bit(const CHARSET_INFO *cs, char* to, size_t l, int fill);
|
||||
|
||||
/* For 8-bit character set */
|
||||
my_bool my_like_range_simple(const CHARSET_INFO *cs,
|
||||
const char *ptr, size_t ptr_length,
|
||||
pbool escape, pbool w_one, pbool w_many,
|
||||
size_t res_length,
|
||||
char *min_str, char *max_str,
|
||||
size_t *min_length, size_t *max_length);
|
||||
|
||||
/* For ASCII-based multi-byte character sets with mbminlen=1 */
|
||||
my_bool my_like_range_mb(const CHARSET_INFO *cs,
|
||||
const char *ptr, size_t ptr_length,
|
||||
pbool escape, pbool w_one, pbool w_many,
|
||||
size_t res_length,
|
||||
char *min_str, char *max_str,
|
||||
size_t *min_length, size_t *max_length);
|
||||
|
||||
/* For other character sets, with arbitrary mbminlen and mbmaxlen numbers */
|
||||
my_bool my_like_range_generic(const CHARSET_INFO *cs,
|
||||
const char *ptr, size_t ptr_length,
|
||||
pbool escape, pbool w_one, pbool w_many,
|
||||
size_t res_length,
|
||||
char *min_str, char *max_str,
|
||||
size_t *min_length, size_t *max_length);
|
||||
|
||||
int my_wildcmp_8bit(const CHARSET_INFO *,
|
||||
const char *str,const char *str_end,
|
||||
const char *wildstr,const char *wildend,
|
||||
int escape, int w_one, int w_many);
|
||||
|
||||
int my_wildcmp_bin(const CHARSET_INFO *,
|
||||
const char *str,const char *str_end,
|
||||
const char *wildstr,const char *wildend,
|
||||
int escape, int w_one, int w_many);
|
||||
|
||||
size_t my_numchars_8bit(const CHARSET_INFO *, const char *b, const char *e);
|
||||
size_t my_numcells_8bit(const CHARSET_INFO *, const char *b, const char *e);
|
||||
size_t my_charpos_8bit(const CHARSET_INFO *, const char *b, const char *e,
|
||||
size_t pos);
|
||||
size_t my_well_formed_len_8bit(const CHARSET_INFO *, const char *b,
|
||||
const char *e, size_t pos, int *error);
|
||||
uint my_mbcharlen_8bit(const CHARSET_INFO *, uint c);
|
||||
|
||||
|
||||
/* Functions for multibyte charsets */
|
||||
extern size_t my_caseup_str_mb(const CHARSET_INFO *, char *);
|
||||
extern size_t my_casedn_str_mb(const CHARSET_INFO *, char *);
|
||||
extern size_t my_caseup_mb(const CHARSET_INFO *, char *src, size_t srclen,
|
||||
char *dst, size_t dstlen);
|
||||
extern size_t my_casedn_mb(const CHARSET_INFO *, char *src, size_t srclen,
|
||||
char *dst, size_t dstlen);
|
||||
extern size_t my_caseup_mb_varlen(const CHARSET_INFO *, char *src,
|
||||
size_t srclen, char *dst, size_t dstlen);
|
||||
extern size_t my_casedn_mb_varlen(const CHARSET_INFO *, char *src,
|
||||
size_t srclen, char *dst, size_t dstlen);
|
||||
extern size_t my_caseup_ujis(const CHARSET_INFO *, char *src, size_t srclen,
|
||||
char *dst, size_t dstlen);
|
||||
extern size_t my_casedn_ujis(const CHARSET_INFO *, char *src, size_t srclen,
|
||||
char *dst, size_t dstlen);
|
||||
extern int my_strcasecmp_mb(const CHARSET_INFO * cs,const char *,
|
||||
const char *);
|
||||
|
||||
int my_wildcmp_mb(const CHARSET_INFO *,
|
||||
const char *str,const char *str_end,
|
||||
const char *wildstr,const char *wildend,
|
||||
int escape, int w_one, int w_many);
|
||||
size_t my_numchars_mb(const CHARSET_INFO *, const char *b, const char *e);
|
||||
size_t my_numcells_mb(const CHARSET_INFO *, const char *b, const char *e);
|
||||
size_t my_charpos_mb(const CHARSET_INFO *, const char *b, const char *e,
|
||||
size_t pos);
|
||||
size_t my_well_formed_len_mb(const CHARSET_INFO *, const char *b,
|
||||
const char *e, size_t pos, int *error);
|
||||
uint my_instr_mb(const struct charset_info_st *,
|
||||
const char *b, size_t b_length,
|
||||
const char *s, size_t s_length,
|
||||
my_match_t *match, uint nmatch);
|
||||
|
||||
int my_strnncoll_mb_bin(const CHARSET_INFO * cs,
|
||||
const uchar *s, size_t slen,
|
||||
const uchar *t, size_t tlen,
|
||||
my_bool t_is_prefix);
|
||||
|
||||
int my_strnncollsp_mb_bin(const CHARSET_INFO *cs,
|
||||
const uchar *a, size_t a_length,
|
||||
const uchar *b, size_t b_length,
|
||||
my_bool diff_if_only_endspace_difference);
|
||||
|
||||
int my_wildcmp_mb_bin(const CHARSET_INFO *cs,
|
||||
const char *str,const char *str_end,
|
||||
const char *wildstr,const char *wildend,
|
||||
int escape, int w_one, int w_many);
|
||||
|
||||
int my_strcasecmp_mb_bin(const CHARSET_INFO * cs MY_ATTRIBUTE((unused)),
|
||||
const char *s, const char *t);
|
||||
|
||||
void my_hash_sort_mb_bin(const CHARSET_INFO *cs MY_ATTRIBUTE((unused)),
|
||||
const uchar *key, size_t len,ulong *nr1, ulong *nr2);
|
||||
|
||||
size_t my_strnxfrm_mb(const CHARSET_INFO *,
|
||||
uchar *dst, size_t dstlen, uint nweights,
|
||||
const uchar *src, size_t srclen, uint flags);
|
||||
|
||||
size_t my_strnxfrm_unicode(const CHARSET_INFO *,
|
||||
uchar *dst, size_t dstlen, uint nweights,
|
||||
const uchar *src, size_t srclen, uint flags);
|
||||
|
||||
size_t my_strnxfrm_unicode_full_bin(const CHARSET_INFO *,
|
||||
uchar *dst, size_t dstlen, uint nweights,
|
||||
const uchar *src, size_t srclen, uint flags);
|
||||
size_t my_strnxfrmlen_unicode_full_bin(const CHARSET_INFO *, size_t);
|
||||
|
||||
int my_wildcmp_unicode(const CHARSET_INFO *cs,
|
||||
const char *str, const char *str_end,
|
||||
const char *wildstr, const char *wildend,
|
||||
int escape, int w_one, int w_many,
|
||||
const MY_UNICASE_INFO *weights);
|
||||
|
||||
extern my_bool my_parse_charset_xml(MY_CHARSET_LOADER *loader,
|
||||
const char *buf, size_t buflen);
|
||||
extern char *my_strchr(const CHARSET_INFO *cs, const char *str,
|
||||
const char *end, pchar c);
|
||||
extern size_t my_strcspn(const CHARSET_INFO *cs, const char *str,
|
||||
const char *end, const char *reject,
|
||||
size_t reject_length);
|
||||
|
||||
my_bool my_propagate_simple(const CHARSET_INFO *cs, const uchar *str,
|
||||
size_t len);
|
||||
my_bool my_propagate_complex(const CHARSET_INFO *cs, const uchar *str,
|
||||
size_t len);
|
||||
|
||||
|
||||
uint my_string_repertoire(const CHARSET_INFO *cs, const char *str, size_t len);
|
||||
my_bool my_charset_is_ascii_based(const CHARSET_INFO *cs);
|
||||
my_bool my_charset_is_8bit_pure_ascii(const CHARSET_INFO *cs);
|
||||
uint my_charset_repertoire(const CHARSET_INFO *cs);
|
||||
|
||||
|
||||
uint my_strxfrm_flag_normalize(uint flags, uint nlevels);
|
||||
void my_strxfrm_desc_and_reverse(uchar *str, uchar *strend,
|
||||
uint flags, uint level);
|
||||
size_t my_strxfrm_pad_desc_and_reverse(const CHARSET_INFO *cs,
|
||||
uchar *str, uchar *frmend, uchar *strend,
|
||||
uint nweights, uint flags, uint level);
|
||||
|
||||
my_bool my_charset_is_ascii_compatible(const CHARSET_INFO *cs);
|
||||
|
||||
const MY_CONTRACTIONS *my_charset_get_contractions(const CHARSET_INFO *cs,
|
||||
int level);
|
||||
|
||||
extern size_t my_vsnprintf_ex(const CHARSET_INFO *cs, char *to, size_t n,
|
||||
const char* fmt, va_list ap);
|
||||
|
||||
size_t my_convert(char *to, size_t to_length, const CHARSET_INFO *to_cs,
|
||||
const char *from, size_t from_length,
|
||||
const CHARSET_INFO *from_cs, uint *errors);
|
||||
|
||||
uint my_mbcharlen_ptr(const CHARSET_INFO *cs, const char *s, const char *e);
|
||||
|
||||
#define _MY_U 01 /* Upper case */
|
||||
#define _MY_L 02 /* Lower case */
|
||||
#define _MY_NMR 04 /* Numeral (digit) */
|
||||
#define _MY_SPC 010 /* Spacing character */
|
||||
#define _MY_PNT 020 /* Punctuation */
|
||||
#define _MY_CTR 040 /* Control character */
|
||||
#define _MY_B 0100 /* Blank */
|
||||
#define _MY_X 0200 /* heXadecimal digit */
|
||||
|
||||
|
||||
#define my_isascii(c) (!((c) & ~0177))
|
||||
#define my_toascii(c) ((c) & 0177)
|
||||
#define my_tocntrl(c) ((c) & 31)
|
||||
#define my_toprint(c) ((c) | 64)
|
||||
#define my_toupper(s,c) (char) ((s)->to_upper[(uchar) (c)])
|
||||
#define my_tolower(s,c) (char) ((s)->to_lower[(uchar) (c)])
|
||||
#define my_isalpha(s, c) (((s)->ctype+1)[(uchar) (c)] & (_MY_U | _MY_L))
|
||||
#define my_isupper(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_U)
|
||||
#define my_islower(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_L)
|
||||
#define my_isdigit(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_NMR)
|
||||
#define my_isxdigit(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_X)
|
||||
#define my_isalnum(s, c) (((s)->ctype+1)[(uchar) (c)] & (_MY_U | _MY_L | _MY_NMR))
|
||||
#define my_isspace(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_SPC)
|
||||
#define my_ispunct(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_PNT)
|
||||
#define my_isprint(s, c) (((s)->ctype+1)[(uchar) (c)] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR | _MY_B))
|
||||
#define my_isgraph(s, c) (((s)->ctype+1)[(uchar) (c)] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR))
|
||||
#define my_iscntrl(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_CTR)
|
||||
|
||||
/* Some macros that should be cleaned up a little */
|
||||
#define my_isvar(s,c) (my_isalnum(s,c) || (c) == '_')
|
||||
#define my_isvar_start(s,c) (my_isalpha(s,c) || (c) == '_')
|
||||
|
||||
#define my_binary_compare(s) ((s)->state & MY_CS_BINSORT)
|
||||
#define use_strnxfrm(s) ((s)->state & MY_CS_STRNXFRM)
|
||||
#define my_strnxfrm(cs, d, dl, s, sl) \
|
||||
((cs)->coll->strnxfrm((cs), (d), (dl), (dl), (s), (sl), MY_STRXFRM_PAD_WITH_SPACE))
|
||||
#define my_strnncoll(s, a, b, c, d) ((s)->coll->strnncoll((s), (a), (b), (c), (d), 0))
|
||||
#define my_like_range(s, a, b, c, d, e, f, g, h, i, j) \
|
||||
((s)->coll->like_range((s), (a), (b), (c), (d), (e), (f), (g), (h), (i), (j)))
|
||||
#define my_wildcmp(cs,s,se,w,we,e,o,m) ((cs)->coll->wildcmp((cs),(s),(se),(w),(we),(e),(o),(m)))
|
||||
#define my_strcasecmp(s, a, b) ((s)->coll->strcasecmp((s), (a), (b)))
|
||||
#define my_charpos(cs, b, e, num) (cs)->cset->charpos((cs), (const char*) (b), (const char *)(e), (num))
|
||||
|
||||
|
||||
#define use_mb(s) ((s)->cset->ismbchar != NULL)
|
||||
#define my_ismbchar(s, a, b) ((s)->cset->ismbchar((s), (a), (b)))
|
||||
#define my_mbcharlen(s, a) ((s)->cset->mbcharlen((s),(a)))
|
||||
/**
|
||||
Get the length of gb18030 code by the given two leading bytes
|
||||
|
||||
@param[in] s charset_info
|
||||
@param[in] a first byte of gb18030 code
|
||||
@param[in] b second byte of gb18030 code
|
||||
@return the length of gb18030 code starting with given two bytes,
|
||||
the length would be 2 or 4 for valid gb18030 code,
|
||||
or 0 for invalid gb18030 code
|
||||
*/
|
||||
#define my_mbcharlen_2(s, a, b) ((s)->cset->mbcharlen((s),((((a) & 0xFF) << 8) + ((b) & 0xFF))))
|
||||
/**
|
||||
Get the maximum length of leading bytes needed to determine the length of a
|
||||
multi-byte gb18030 code
|
||||
|
||||
@param[in] s charset_info
|
||||
@return number of leading bytes we need, would be 2 for gb18030
|
||||
and 1 for all other charsets
|
||||
*/
|
||||
#define my_mbmaxlenlen(s) ((s)->mbmaxlenlen)
|
||||
/**
|
||||
Judge if the given byte is a possible leading byte for a charset.
|
||||
For gb18030 whose mbmaxlenlen is 2, we can't determine the length of
|
||||
a multi-byte character by looking at the first byte only
|
||||
|
||||
@param[in] s charset_info
|
||||
@param[in] i possible leading byte
|
||||
@return true if it is, otherwise false
|
||||
*/
|
||||
#define my_ismb1st(s, i) \
|
||||
(my_mbcharlen((s), (i)) > 1 || \
|
||||
(my_mbmaxlenlen((s)) == 2 && my_mbcharlen((s), (i)) == 0))
|
||||
|
||||
#define my_caseup_str(s, a) ((s)->cset->caseup_str((s), (a)))
|
||||
#define my_casedn_str(s, a) ((s)->cset->casedn_str((s), (a)))
|
||||
#define my_strntol(s, a, b, c, d, e) ((s)->cset->strntol((s),(a),(b),(c),(d),(e)))
|
||||
#define my_strntoul(s, a, b, c, d, e) ((s)->cset->strntoul((s),(a),(b),(c),(d),(e)))
|
||||
#define my_strntoll(s, a, b, c, d, e) ((s)->cset->strntoll((s),(a),(b),(c),(d),(e)))
|
||||
#define my_strntoull(s, a, b, c,d, e) ((s)->cset->strntoull((s),(a),(b),(c),(d),(e)))
|
||||
#define my_strntod(s, a, b, c, d) ((s)->cset->strntod((s),(a),(b),(c),(d)))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _m_ctype_h */
|
||||
|
|
@ -1,344 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#ifndef _m_string_h
|
||||
#define _m_string_h
|
||||
|
||||
#include "my_global.h" /* HAVE_* */
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define bfill please_use_memset_rather_than_bfill
|
||||
#define bzero please_use_memset_rather_than_bzero
|
||||
#define bmove please_use_memmove_rather_than_bmove
|
||||
#define strmov please_use_my_stpcpy_or_my_stpmov_rather_than_strmov
|
||||
#define strnmov please_use_my_stpncpy_or_my_stpnmov_rather_than_strnmov
|
||||
|
||||
#include "mysql/service_my_snprintf.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
my_str_malloc(), my_str_realloc() and my_str_free() are assigned to
|
||||
implementations in strings/alloc.c, but can be overridden in
|
||||
the calling program.
|
||||
*/
|
||||
extern void *(*my_str_malloc)(size_t);
|
||||
extern void *(*my_str_realloc)(void *, size_t);
|
||||
extern void (*my_str_free)(void *);
|
||||
|
||||
/* Declared in int2str() */
|
||||
extern char _dig_vec_upper[];
|
||||
extern char _dig_vec_lower[];
|
||||
|
||||
/* Prototypes for string functions */
|
||||
|
||||
extern void bchange(uchar *dst,size_t old_len,const uchar *src,
|
||||
size_t new_len,size_t tot_len);
|
||||
extern void strappend(char *s,size_t len,pchar fill);
|
||||
extern char *strend(const char *s);
|
||||
extern char *strcend(const char *, pchar);
|
||||
extern char *strfill(char * s,size_t len,pchar fill);
|
||||
extern char *strmake(char *dst,const char *src,size_t length);
|
||||
|
||||
extern char *my_stpmov(char *dst,const char *src);
|
||||
extern char *my_stpnmov(char *dst, const char *src, size_t n);
|
||||
extern char *strcont(const char *src, const char *set);
|
||||
extern char *strxmov(char *dst, const char *src, ...);
|
||||
extern char *strxnmov(char *dst, size_t len, const char *src, ...);
|
||||
|
||||
/**
|
||||
Copy a string from src to dst until (and including) terminating null byte.
|
||||
|
||||
@param dst Destination
|
||||
@param src Source
|
||||
|
||||
@note src and dst cannot overlap.
|
||||
Use my_stpmov() if src and dst overlaps.
|
||||
|
||||
@note Unsafe, consider using my_stpnpy() instead.
|
||||
|
||||
@return pointer to terminating null byte.
|
||||
*/
|
||||
static inline char *my_stpcpy(char *dst, const char *src)
|
||||
{
|
||||
#if defined(HAVE_BUILTIN_STPCPY)
|
||||
return __builtin_stpcpy(dst, src);
|
||||
#elif defined(HAVE_STPCPY)
|
||||
return stpcpy(dst, src);
|
||||
#else
|
||||
/* Fallback to implementation supporting overlap. */
|
||||
return my_stpmov(dst, src);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
Copy fixed-size string from src to dst.
|
||||
|
||||
@param dst Destination
|
||||
@param src Source
|
||||
@param n Maximum number of characters to copy.
|
||||
|
||||
@note src and dst cannot overlap
|
||||
Use my_stpnmov() if src and dst overlaps.
|
||||
|
||||
@return pointer to terminating null byte.
|
||||
*/
|
||||
static inline char *my_stpncpy(char *dst, const char *src, size_t n)
|
||||
{
|
||||
#if defined(HAVE_STPNCPY)
|
||||
return stpncpy(dst, src, n);
|
||||
#else
|
||||
/* Fallback to implementation supporting overlap. */
|
||||
return my_stpnmov(dst, src, n);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline longlong my_strtoll(const char *nptr, char **endptr, int base)
|
||||
{
|
||||
#if defined _WIN32
|
||||
return _strtoi64(nptr, endptr, base);
|
||||
#else
|
||||
return strtoll(nptr, endptr, base);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline ulonglong my_strtoull(const char *nptr, char **endptr, int base)
|
||||
{
|
||||
#if defined _WIN32
|
||||
return _strtoui64(nptr, endptr, base);
|
||||
#else
|
||||
return strtoull(nptr, endptr, base);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline char *my_strtok_r(char *str, const char *delim, char **saveptr)
|
||||
{
|
||||
#if defined _WIN32
|
||||
return strtok_s(str, delim, saveptr);
|
||||
#else
|
||||
return strtok_r(str, delim, saveptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* native_ rather than my_ since my_strcasecmp already exists */
|
||||
static inline int native_strcasecmp(const char *s1, const char *s2)
|
||||
{
|
||||
#if defined _WIN32
|
||||
return _stricmp(s1, s2);
|
||||
#else
|
||||
return strcasecmp(s1, s2);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* native_ rather than my_ for consistency with native_strcasecmp */
|
||||
static inline int native_strncasecmp(const char *s1, const char *s2, size_t n)
|
||||
{
|
||||
#if defined _WIN32
|
||||
return _strnicmp(s1, s2, n);
|
||||
#else
|
||||
return strncasecmp(s1, s2, n);
|
||||
#endif
|
||||
}
|
||||
|
||||
size_t my_snprintf(char* to, size_t n, const char* fmt, ...);
|
||||
size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap);
|
||||
|
||||
/* Prototypes of normal stringfunctions (with may ours) */
|
||||
#ifndef HAVE_STRNLEN
|
||||
extern size_t strnlen(const char *s, size_t n);
|
||||
#endif
|
||||
|
||||
extern int is_prefix(const char *, const char *);
|
||||
|
||||
/* Conversion routines */
|
||||
typedef enum {
|
||||
MY_GCVT_ARG_FLOAT,
|
||||
MY_GCVT_ARG_DOUBLE
|
||||
} my_gcvt_arg_type;
|
||||
|
||||
double my_strtod(const char *str, char **end, int *error);
|
||||
double my_atof(const char *nptr);
|
||||
size_t my_fcvt(double x, int precision, char *to, my_bool *error);
|
||||
size_t my_gcvt(double x, my_gcvt_arg_type type, int width, char *to,
|
||||
my_bool *error);
|
||||
|
||||
#define NOT_FIXED_DEC 31
|
||||
|
||||
/*
|
||||
The longest string my_fcvt can return is 311 + "precision" bytes.
|
||||
Here we assume that we never cal my_fcvt() with precision >= NOT_FIXED_DEC
|
||||
(+ 1 byte for the terminating '\0').
|
||||
*/
|
||||
#define FLOATING_POINT_BUFFER (311 + NOT_FIXED_DEC)
|
||||
|
||||
/*
|
||||
We want to use the 'e' format in some cases even if we have enough space
|
||||
for the 'f' one just to mimic sprintf("%.15g") behavior for large integers,
|
||||
and to improve it for numbers < 10^(-4).
|
||||
That is, for |x| < 1 we require |x| >= 10^(-15), and for |x| > 1 we require
|
||||
it to be integer and be <= 10^DBL_DIG for the 'f' format to be used.
|
||||
We don't lose precision, but make cases like "1e200" or "0.00001" look nicer.
|
||||
*/
|
||||
#define MAX_DECPT_FOR_F_FORMAT DBL_DIG
|
||||
|
||||
/*
|
||||
The maximum possible field width for my_gcvt() conversion.
|
||||
(DBL_DIG + 2) significant digits + sign + "." + ("e-NNN" or
|
||||
MAX_DECPT_FOR_F_FORMAT zeros for cases when |x|<1 and the 'f' format is used).
|
||||
*/
|
||||
#define MY_GCVT_MAX_FIELD_WIDTH (DBL_DIG + 4 + MY_MAX(5, MAX_DECPT_FOR_F_FORMAT)) \
|
||||
|
||||
extern char *llstr(longlong value,char *buff);
|
||||
extern char *ullstr(longlong value,char *buff);
|
||||
|
||||
extern char *int2str(long val, char *dst, int radix, int upcase);
|
||||
extern char *int10_to_str(long val,char *dst,int radix);
|
||||
extern char *str2int(const char *src,int radix,long lower,long upper,
|
||||
long *val);
|
||||
longlong my_strtoll10(const char *nptr, char **endptr, int *error);
|
||||
#if SIZEOF_LONG == SIZEOF_LONG_LONG
|
||||
#define ll2str(A,B,C,D) int2str((A),(B),(C),(D))
|
||||
#define longlong10_to_str(A,B,C) int10_to_str((A),(B),(C))
|
||||
#undef strtoll
|
||||
#define strtoll(A,B,C) strtol((A),(B),(C))
|
||||
#define strtoull(A,B,C) strtoul((A),(B),(C))
|
||||
#else
|
||||
extern char *ll2str(longlong val,char *dst,int radix, int upcase);
|
||||
extern char *longlong10_to_str(longlong val,char *dst,int radix);
|
||||
#endif
|
||||
#define longlong2str(A,B,C) ll2str((A),(B),(C),1)
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
LEX_STRING -- a pair of a C-string and its length.
|
||||
(it's part of the plugin API as a MYSQL_LEX_STRING)
|
||||
Ditto LEX_CSTRING/MYSQL_LEX_CSTRING.
|
||||
*/
|
||||
|
||||
#include <mysql/mysql_lex_string.h>
|
||||
typedef struct st_mysql_lex_string LEX_STRING;
|
||||
typedef struct st_mysql_const_lex_string LEX_CSTRING;
|
||||
|
||||
#define STRING_WITH_LEN(X) (X), ((sizeof(X) - 1))
|
||||
#define USTRING_WITH_LEN(X) ((uchar*) X), ((sizeof(X) - 1))
|
||||
#define C_STRING_WITH_LEN(X) ((char *) (X)), ((sizeof(X) - 1))
|
||||
|
||||
|
||||
/**
|
||||
Skip trailing space.
|
||||
|
||||
On most systems reading memory in larger chunks (ideally equal to the size of
|
||||
the chinks that the machine physically reads from memory) causes fewer memory
|
||||
access loops and hence increased performance.
|
||||
This is why the 'int' type is used : it's closest to that (according to how
|
||||
it's defined in C).
|
||||
So when we determine the amount of whitespace at the end of a string we do
|
||||
the following :
|
||||
1. We divide the string into 3 zones :
|
||||
a) from the start of the string (__start) to the first multiple
|
||||
of sizeof(int) (__start_words)
|
||||
b) from the end of the string (__end) to the last multiple of sizeof(int)
|
||||
(__end_words)
|
||||
c) a zone that is aligned to sizeof(int) and can be safely accessed
|
||||
through an int *
|
||||
2. We start comparing backwards from (c) char-by-char. If all we find is
|
||||
space then we continue
|
||||
3. If there are elements in zone (b) we compare them as unsigned ints to a
|
||||
int mask (SPACE_INT) consisting of all spaces
|
||||
4. Finally we compare the remaining part (a) of the string char by char.
|
||||
This covers for the last non-space unsigned int from 3. (if any)
|
||||
|
||||
This algorithm works well for relatively larger strings, but it will slow
|
||||
the things down for smaller strings (because of the additional calculations
|
||||
and checks compared to the naive method). Thus the barrier of length 20
|
||||
is added.
|
||||
|
||||
@param ptr pointer to the input string
|
||||
@param len the length of the string
|
||||
@return the last non-space character
|
||||
*/
|
||||
#if defined(__sparc) || defined(__sparcv9)
|
||||
static inline const uchar *skip_trailing_space(const uchar *ptr,size_t len)
|
||||
{
|
||||
/* SPACE_INT is a word that contains only spaces */
|
||||
#if SIZEOF_INT == 4
|
||||
const unsigned SPACE_INT= 0x20202020U;
|
||||
#elif SIZEOF_INT == 8
|
||||
const unsigned SPACE_INT= 0x2020202020202020ULL;
|
||||
#else
|
||||
#error define the appropriate constant for a word full of spaces
|
||||
#endif
|
||||
|
||||
const uchar *end= ptr + len;
|
||||
|
||||
if (len > 20)
|
||||
{
|
||||
const uchar *end_words= (const uchar *)(intptr)
|
||||
(((ulonglong)(intptr)end) / SIZEOF_INT * SIZEOF_INT);
|
||||
const uchar *start_words= (const uchar *)(intptr)
|
||||
((((ulonglong)(intptr)ptr) + SIZEOF_INT - 1) / SIZEOF_INT * SIZEOF_INT);
|
||||
|
||||
DBUG_ASSERT(end_words > ptr);
|
||||
while (end > end_words && end[-1] == 0x20)
|
||||
end--;
|
||||
if (end[-1] == 0x20 && start_words < end_words)
|
||||
while (end > start_words && ((unsigned *)end)[-1] == SPACE_INT)
|
||||
end -= SIZEOF_INT;
|
||||
}
|
||||
while (end > ptr && end[-1] == 0x20)
|
||||
end--;
|
||||
return (end);
|
||||
}
|
||||
#else
|
||||
/*
|
||||
Reads 8 bytes at a time, ignoring alignment.
|
||||
We use uint8korr, which is fast (it simply reads a *ulonglong)
|
||||
on all platforms, except sparc.
|
||||
*/
|
||||
static inline const uchar *skip_trailing_space(const uchar *ptr, size_t len)
|
||||
{
|
||||
const uchar *end= ptr + len;
|
||||
while (end - ptr >= 8)
|
||||
{
|
||||
if (uint8korr(end-8) != 0x2020202020202020ULL)
|
||||
break;
|
||||
end-= 8;
|
||||
}
|
||||
while (end > ptr && end[-1] == 0x20)
|
||||
end--;
|
||||
return (end);
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline void lex_string_set(LEX_STRING *lex_str, const char *c_str)
|
||||
{
|
||||
lex_str->str= (char *) c_str;
|
||||
lex_str->length= strlen(c_str);
|
||||
}
|
||||
|
||||
static inline void lex_cstring_set(LEX_CSTRING *lex_str, const char *c_str)
|
||||
{
|
||||
lex_str->str= c_str;
|
||||
lex_str->length= strlen(c_str);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
/*
|
||||
Data structures for mysys/my_alloc.c (root memory allocator)
|
||||
*/
|
||||
|
||||
#ifndef _my_alloc_h
|
||||
#define _my_alloc_h
|
||||
|
||||
#define ALLOC_MAX_BLOCK_TO_DROP 4096
|
||||
#define ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP 10
|
||||
|
||||
/* PSI_memory_key */
|
||||
#include "mysql/psi/psi_memory.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct st_used_mem
|
||||
{ /* struct for once_alloc (block) */
|
||||
struct st_used_mem *next; /* Next block in use */
|
||||
unsigned int left; /* memory left in block */
|
||||
unsigned int size; /* size of block */
|
||||
} USED_MEM;
|
||||
|
||||
|
||||
typedef struct st_mem_root
|
||||
{
|
||||
USED_MEM *free; /* blocks with free memory in it */
|
||||
USED_MEM *used; /* blocks almost without free memory */
|
||||
USED_MEM *pre_alloc; /* preallocated block */
|
||||
/* if block have less memory it will be put in 'used' list */
|
||||
size_t min_malloc;
|
||||
size_t block_size; /* initial block size */
|
||||
unsigned int block_num; /* allocated blocks counter */
|
||||
/*
|
||||
first free block in queue test counter (if it exceed
|
||||
MAX_BLOCK_USAGE_BEFORE_DROP block will be dropped in 'used' list)
|
||||
*/
|
||||
unsigned int first_block_usage;
|
||||
|
||||
void (*error_handler)(void);
|
||||
|
||||
PSI_memory_key m_psi_key;
|
||||
} MEM_ROOT;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,213 +0,0 @@
|
|||
#ifndef MY_BYTEORDER_INCLUDED
|
||||
#define MY_BYTEORDER_INCLUDED
|
||||
|
||||
/* Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
|
||||
/*
|
||||
Functions for reading and storing in machine independent
|
||||
format (low byte first). There are 'korr' (assume 'corrector') variants
|
||||
for integer types, but 'get' (assume 'getter') for floating point types.
|
||||
*/
|
||||
#if defined(__i386__) || defined(_WIN32) || defined(__x86_64__)
|
||||
#include "byte_order_generic_x86.h"
|
||||
#else
|
||||
#include "byte_order_generic.h"
|
||||
#endif
|
||||
|
||||
static inline int32 sint3korr(const uchar *A)
|
||||
{
|
||||
return
|
||||
((int32) (((A[2]) & 128) ?
|
||||
(((uint32) 255L << 24) |
|
||||
(((uint32) A[2]) << 16) |
|
||||
(((uint32) A[1]) << 8) |
|
||||
((uint32) A[0])) :
|
||||
(((uint32) A[2]) << 16) |
|
||||
(((uint32) A[1]) << 8) |
|
||||
((uint32) A[0])))
|
||||
;
|
||||
}
|
||||
|
||||
static inline uint32 uint3korr(const uchar *A)
|
||||
{
|
||||
return
|
||||
(uint32) (((uint32) (A[0])) +
|
||||
(((uint32) (A[1])) << 8) +
|
||||
(((uint32) (A[2])) << 16))
|
||||
;
|
||||
}
|
||||
|
||||
static inline ulonglong uint5korr(const uchar *A)
|
||||
{
|
||||
return
|
||||
((ulonglong)(((uint32) (A[0])) +
|
||||
(((uint32) (A[1])) << 8) +
|
||||
(((uint32) (A[2])) << 16) +
|
||||
(((uint32) (A[3])) << 24)) +
|
||||
(((ulonglong) (A[4])) << 32))
|
||||
;
|
||||
}
|
||||
|
||||
static inline ulonglong uint6korr(const uchar *A)
|
||||
{
|
||||
return
|
||||
((ulonglong)(((uint32) (A[0])) +
|
||||
(((uint32) (A[1])) << 8) +
|
||||
(((uint32) (A[2])) << 16) +
|
||||
(((uint32) (A[3])) << 24)) +
|
||||
(((ulonglong) (A[4])) << 32) +
|
||||
(((ulonglong) (A[5])) << 40))
|
||||
;
|
||||
}
|
||||
|
||||
static inline void int3store(uchar *T, uint A)
|
||||
{
|
||||
*(T)= (uchar) (A);
|
||||
*(T+1)= (uchar) (A >> 8);
|
||||
*(T+2)= (uchar) (A >> 16);
|
||||
}
|
||||
|
||||
static inline void int5store(uchar *T, ulonglong A)
|
||||
{
|
||||
*(T)= (uchar) (A);
|
||||
*(T+1)= (uchar) (A >> 8);
|
||||
*(T+2)= (uchar) (A >> 16);
|
||||
*(T+3)= (uchar) (A >> 24);
|
||||
*(T+4)= (uchar) (A >> 32);
|
||||
}
|
||||
|
||||
static inline void int6store(uchar *T, ulonglong A)
|
||||
{
|
||||
*(T)= (uchar) (A);
|
||||
*(T+1)= (uchar) (A >> 8);
|
||||
*(T+2)= (uchar) (A >> 16);
|
||||
*(T+3)= (uchar) (A >> 24);
|
||||
*(T+4)= (uchar) (A >> 32);
|
||||
*(T+5)= (uchar) (A >> 40);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
static inline int16 sint2korr(const char *pT)
|
||||
{
|
||||
return sint2korr(static_cast<const uchar*>(static_cast<const void*>(pT)));
|
||||
}
|
||||
|
||||
static inline uint16 uint2korr(const char *pT)
|
||||
{
|
||||
return uint2korr(static_cast<const uchar*>(static_cast<const void*>(pT)));
|
||||
}
|
||||
|
||||
static inline uint32 uint3korr(const char *pT)
|
||||
{
|
||||
return uint3korr(static_cast<const uchar*>(static_cast<const void*>(pT)));
|
||||
}
|
||||
|
||||
static inline int32 sint3korr(const char *pT)
|
||||
{
|
||||
return sint3korr(static_cast<const uchar*>(static_cast<const void*>(pT)));
|
||||
}
|
||||
|
||||
static inline uint32 uint4korr(const char *pT)
|
||||
{
|
||||
return uint4korr(static_cast<const uchar*>(static_cast<const void*>(pT)));
|
||||
}
|
||||
|
||||
static inline int32 sint4korr(const char *pT)
|
||||
{
|
||||
return sint4korr(static_cast<const uchar*>(static_cast<const void*>(pT)));
|
||||
}
|
||||
|
||||
static inline ulonglong uint6korr(const char *pT)
|
||||
{
|
||||
return uint6korr(static_cast<const uchar*>(static_cast<const void*>(pT)));
|
||||
}
|
||||
|
||||
static inline ulonglong uint8korr(const char *pT)
|
||||
{
|
||||
return uint8korr(static_cast<const uchar*>(static_cast<const void*>(pT)));
|
||||
}
|
||||
|
||||
static inline longlong sint8korr(const char *pT)
|
||||
{
|
||||
return sint8korr(static_cast<const uchar*>(static_cast<const void*>(pT)));
|
||||
}
|
||||
|
||||
|
||||
static inline void int2store(char *pT, uint16 A)
|
||||
{
|
||||
int2store(static_cast<uchar*>(static_cast<void*>(pT)), A);
|
||||
}
|
||||
|
||||
static inline void int3store(char *pT, uint A)
|
||||
{
|
||||
int3store(static_cast<uchar*>(static_cast<void*>(pT)), A);
|
||||
}
|
||||
|
||||
static inline void int4store(char *pT, uint32 A)
|
||||
{
|
||||
int4store(static_cast<uchar*>(static_cast<void*>(pT)), A);
|
||||
}
|
||||
|
||||
static inline void int5store(char *pT, ulonglong A)
|
||||
{
|
||||
int5store(static_cast<uchar*>(static_cast<void*>(pT)), A);
|
||||
}
|
||||
|
||||
static inline void int6store(char *pT, ulonglong A)
|
||||
{
|
||||
int6store(static_cast<uchar*>(static_cast<void*>(pT)), A);
|
||||
}
|
||||
|
||||
static inline void int8store(char *pT, ulonglong A)
|
||||
{
|
||||
int8store(static_cast<uchar*>(static_cast<void*>(pT)), A);
|
||||
}
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
Functions for reading and storing in machine format from/to
|
||||
short/long to/from some place in memory V should be a variable
|
||||
and M a pointer to byte.
|
||||
*/
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
#include "big_endian.h"
|
||||
#else
|
||||
#include "little_endian.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
static inline void float4store(char *V, float M)
|
||||
{
|
||||
float4store(static_cast<uchar*>(static_cast<void*>(V)), M);
|
||||
}
|
||||
|
||||
static inline void float8get(double *V, const char *M)
|
||||
{
|
||||
float8get(V, static_cast<const uchar*>(static_cast<const void*>(M)));
|
||||
}
|
||||
|
||||
static inline void float8store(char *V, double M)
|
||||
{
|
||||
float8store(static_cast<uchar*>(static_cast<void*>(V)), M);
|
||||
}
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* MY_BYTEORDER_INCLUDED */
|
||||
|
|
@ -1,13 +1,26 @@
|
|||
/* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
/* Copyright (c) 2015, 2026, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
This program is designed to work with certain software (including
|
||||
but not limited to OpenSSL) that is licensed under separate terms,
|
||||
as designated in a particular file or component or in included license
|
||||
documentation. The authors of MySQL hereby grant you an additional
|
||||
permission to link the program and your derivative works with the
|
||||
separately licensed software that they have either included with
|
||||
the program or referenced in the documentation.
|
||||
|
||||
Without limiting anything contained in the foregoing, this file,
|
||||
which is part of C Driver for MySQL (Connector/C), is also subject to the
|
||||
Universal FOSS Exception, version 1.0, a copy of which can be found at
|
||||
http://oss.oracle.com/licenses/universal-foss-exception.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU General Public License, version 2.0, for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
|
|
@ -17,48 +30,76 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
|||
#define _mysql_command_h
|
||||
|
||||
/**
|
||||
@enum enum_server_command
|
||||
@brief You should add new commands to the end of this list, otherwise old
|
||||
servers won't be able to handle them as 'unsupported'.
|
||||
@file include/my_command.h
|
||||
*/
|
||||
enum enum_server_command
|
||||
{
|
||||
|
||||
/**
|
||||
@enum enum_server_command
|
||||
|
||||
@brief A list of all MySQL protocol commands.
|
||||
|
||||
These are the top level commands the server can receive
|
||||
while it listens for a new command in ::dispatch_command
|
||||
|
||||
@par Warning
|
||||
Add new commands to the end of this list, otherwise old
|
||||
servers won't be able to handle them as 'unsupported'.
|
||||
*/
|
||||
enum enum_server_command {
|
||||
/**
|
||||
Currently refused by the server. See ::dispatch_command.
|
||||
Also used internally to mark the start of a session.
|
||||
*/
|
||||
COM_SLEEP,
|
||||
COM_QUIT,
|
||||
COM_INIT_DB,
|
||||
COM_QUERY,
|
||||
COM_FIELD_LIST,
|
||||
COM_CREATE_DB,
|
||||
COM_DROP_DB,
|
||||
COM_REFRESH,
|
||||
COM_SHUTDOWN,
|
||||
COM_STATISTICS,
|
||||
COM_PROCESS_INFO,
|
||||
COM_CONNECT,
|
||||
COM_PROCESS_KILL,
|
||||
COM_DEBUG,
|
||||
COM_PING,
|
||||
COM_TIME,
|
||||
COM_DELAYED_INSERT,
|
||||
COM_CHANGE_USER,
|
||||
COM_BINLOG_DUMP,
|
||||
COM_QUIT, /**< See @ref page_protocol_com_quit */
|
||||
COM_INIT_DB, /**< See @ref page_protocol_com_init_db */
|
||||
COM_QUERY, /**< See @ref page_protocol_com_query */
|
||||
COM_FIELD_LIST, /**< Deprecated. See @ref page_protocol_com_field_list */
|
||||
COM_CREATE_DB, /**< Currently refused by the server. See ::dispatch_command */
|
||||
COM_DROP_DB, /**< Currently refused by the server. See ::dispatch_command */
|
||||
COM_REFRESH, /**< Deprecated. See @ref page_protocol_com_refresh */
|
||||
COM_DEPRECATED_1, /**< Deprecated, used to be COM_SHUTDOWN */
|
||||
COM_STATISTICS, /**< See @ref page_protocol_com_statistics */
|
||||
COM_PROCESS_INFO, /**< Deprecated. See @ref page_protocol_com_process_info */
|
||||
COM_CONNECT, /**< Currently refused by the server. */
|
||||
COM_PROCESS_KILL, /**< Deprecated. See @ref page_protocol_com_process_kill */
|
||||
COM_DEBUG, /**< See @ref page_protocol_com_debug */
|
||||
COM_PING, /**< See @ref page_protocol_com_ping */
|
||||
COM_TIME, /**< Currently refused by the server. */
|
||||
COM_DELAYED_INSERT, /**< Functionality removed. */
|
||||
COM_CHANGE_USER, /**< See @ref page_protocol_com_change_user */
|
||||
COM_BINLOG_DUMP, /**< See @ref page_protocol_com_binlog_dump */
|
||||
COM_TABLE_DUMP,
|
||||
COM_CONNECT_OUT,
|
||||
COM_REGISTER_SLAVE,
|
||||
COM_STMT_PREPARE,
|
||||
COM_STMT_EXECUTE,
|
||||
COM_STMT_PREPARE, /**< See @ref page_protocol_com_stmt_prepare */
|
||||
COM_STMT_EXECUTE, /**< See @ref page_protocol_com_stmt_execute */
|
||||
/** See @ref page_protocol_com_stmt_send_long_data */
|
||||
COM_STMT_SEND_LONG_DATA,
|
||||
COM_STMT_CLOSE,
|
||||
COM_STMT_RESET,
|
||||
COM_SET_OPTION,
|
||||
COM_STMT_FETCH,
|
||||
COM_STMT_CLOSE, /**< See @ref page_protocol_com_stmt_close */
|
||||
COM_STMT_RESET, /**< See @ref page_protocol_com_stmt_reset */
|
||||
COM_SET_OPTION, /**< See @ref page_protocol_com_set_option */
|
||||
COM_STMT_FETCH, /**< See @ref page_protocol_com_stmt_fetch */
|
||||
/**
|
||||
Currently refused by the server. See ::dispatch_command.
|
||||
Also used internally to mark the session as a "daemon",
|
||||
i.e. non-client THD. Currently the scheduler and the GTID
|
||||
code does use this state.
|
||||
These threads won't be killed by `KILL`
|
||||
|
||||
@sa Event_scheduler::start, ::init_thd, ::kill_one_thread,
|
||||
::Find_thd_with_id
|
||||
*/
|
||||
COM_DAEMON,
|
||||
COM_BINLOG_DUMP_GTID,
|
||||
COM_RESET_CONNECTION,
|
||||
/* don't forget to update const char *command_name[] in sql_parse.cc */
|
||||
COM_RESET_CONNECTION, /**< See @ref page_protocol_com_reset_connection */
|
||||
COM_CLONE,
|
||||
COM_SUBSCRIBE_GROUP_REPLICATION_STREAM,
|
||||
/* don't forget to update std::string Command_names::m_names[] in sql_parse.cc
|
||||
*/
|
||||
|
||||
/* Must be last */
|
||||
COM_END
|
||||
COM_END /**< Not a real command. Refused. */
|
||||
};
|
||||
|
||||
#endif /* _mysql_command_h */
|
||||
|
|
|
|||
|
|
@ -1,178 +0,0 @@
|
|||
#ifndef MY_COMPILER_INCLUDED
|
||||
#define MY_COMPILER_INCLUDED
|
||||
|
||||
/* Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
/**
|
||||
Header for compiler-dependent features.
|
||||
|
||||
Intended to contain a set of reusable wrappers for preprocessor
|
||||
macros, attributes, pragmas, and any other features that are
|
||||
specific to a target compiler.
|
||||
*/
|
||||
|
||||
#include <stddef.h> /* size_t */
|
||||
|
||||
#if defined __GNUC__
|
||||
/*
|
||||
Convenience macro to test the minimum required GCC version.
|
||||
These should be used with care as Clang also sets __GNUC__ and
|
||||
__GNUC_MINOR__ (currently to 4.2). Prefer using feature specific
|
||||
CMake checks in configure.cmake instead.
|
||||
*/
|
||||
# define MY_GNUC_PREREQ(maj, min) \
|
||||
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
|
||||
# define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
|
||||
#else
|
||||
# define MY_GNUC_PREREQ(maj, min) (0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
The macros below are borrowed from include/linux/compiler.h in the
|
||||
Linux kernel. Use them to indicate the likelyhood of the truthfulness
|
||||
of a condition. This serves two purposes - newer versions of gcc will be
|
||||
able to optimize for branch predication, which could yield siginficant
|
||||
performance gains in frequently executed sections of the code, and the
|
||||
other reason to use them is for documentation
|
||||
*/
|
||||
#ifdef HAVE_BUILTIN_EXPECT
|
||||
|
||||
// likely/unlikely are likely to clash with other symbols, do not #define
|
||||
#if defined(__cplusplus)
|
||||
inline bool likely(bool expr)
|
||||
{
|
||||
return __builtin_expect(expr, true);
|
||||
}
|
||||
inline bool unlikely(bool expr)
|
||||
{
|
||||
return __builtin_expect(expr, false);
|
||||
}
|
||||
#else
|
||||
# define likely(x) __builtin_expect((x),1)
|
||||
# define unlikely(x) __builtin_expect((x),0)
|
||||
#endif
|
||||
|
||||
#else /* HAVE_BUILTIN_EXPECT */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
inline bool likely(bool expr)
|
||||
{
|
||||
return expr;
|
||||
}
|
||||
inline bool unlikely(bool expr)
|
||||
{
|
||||
return expr;
|
||||
}
|
||||
#else
|
||||
# define likely(x) (x)
|
||||
# define unlikely(x) (x)
|
||||
#endif
|
||||
|
||||
#endif /* HAVE_BUILTIN_EXPECT */
|
||||
|
||||
/* Comunicate to the compiler the unreachability of the code. */
|
||||
#ifdef HAVE_BUILTIN_UNREACHABLE
|
||||
# define MY_ASSERT_UNREACHABLE() __builtin_unreachable()
|
||||
#else
|
||||
# define MY_ASSERT_UNREACHABLE() do { assert(0); } while (0)
|
||||
#endif
|
||||
|
||||
#if defined __GNUC__ || defined __SUNPRO_C || defined __SUNPRO_CC
|
||||
/* Specifies the minimum alignment of a type. */
|
||||
# define MY_ALIGNOF(type) __alignof__(type)
|
||||
/* Determine the alignment requirement of a type. */
|
||||
# define MY_ALIGNED(n) __attribute__((__aligned__((n))))
|
||||
/* Microsoft Visual C++ */
|
||||
#elif defined _MSC_VER
|
||||
# define MY_ALIGNOF(type) __alignof(type)
|
||||
# define MY_ALIGNED(n) __declspec(align(n))
|
||||
#else /* Make sure they are defined for other compilers. */
|
||||
# define MY_ALIGNOF(type)
|
||||
# define MY_ALIGNED(size)
|
||||
#endif
|
||||
|
||||
/* Visual Studio requires '__inline' for C code */
|
||||
#if !defined(__cplusplus) && defined(_MSC_VER)
|
||||
# define inline __inline
|
||||
#endif
|
||||
|
||||
/* Provide __func__ macro definition for Visual Studio. */
|
||||
#if defined(_MSC_VER)
|
||||
# define __func__ __FUNCTION__
|
||||
#endif
|
||||
|
||||
/**
|
||||
C++ Type Traits
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
|
||||
/**
|
||||
Opaque storage with a particular alignment.
|
||||
Partial specialization used due to MSVC++.
|
||||
*/
|
||||
template<size_t alignment> struct my_alignment_imp;
|
||||
template<> struct MY_ALIGNED(1) my_alignment_imp<1> {};
|
||||
template<> struct MY_ALIGNED(2) my_alignment_imp<2> {};
|
||||
template<> struct MY_ALIGNED(4) my_alignment_imp<4> {};
|
||||
template<> struct MY_ALIGNED(8) my_alignment_imp<8> {};
|
||||
template<> struct MY_ALIGNED(16) my_alignment_imp<16> {};
|
||||
|
||||
/**
|
||||
A POD type with a given size and alignment.
|
||||
|
||||
@remark If the compiler does not support a alignment attribute
|
||||
(MY_ALIGN macro), the default alignment of a double is
|
||||
used instead.
|
||||
|
||||
@tparam size The minimum size.
|
||||
@tparam alignment The desired alignment: 1, 2, 4, 8 or 16.
|
||||
*/
|
||||
template <size_t size, size_t alignment>
|
||||
struct my_aligned_storage
|
||||
{
|
||||
union
|
||||
{
|
||||
char data[size];
|
||||
my_alignment_imp<alignment> align;
|
||||
};
|
||||
};
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
Disable MY_ATTRIBUTE for Sun Studio and Visual Studio.
|
||||
Note that Sun Studio supports some __attribute__ variants,
|
||||
but not format or unused which we use quite a lot.
|
||||
*/
|
||||
#ifndef MY_ATTRIBUTE
|
||||
#if defined(__GNUC__)
|
||||
# define MY_ATTRIBUTE(A) __attribute__(A)
|
||||
#else
|
||||
# define MY_ATTRIBUTE(A)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0
|
||||
#endif
|
||||
|
||||
#if __has_attribute(no_sanitize_undefined)
|
||||
# define SUPPRESS_UBSAN __attribute__((no_sanitize_undefined))
|
||||
#else
|
||||
# define SUPPRESS_UBSAN
|
||||
#endif
|
||||
|
||||
#endif /* MY_COMPILER_INCLUDED */
|
||||
115
src/common/mysql/include/my_compress.h
Normal file
115
src/common/mysql/include/my_compress.h
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
/* Copyright (c) 2019, 2026, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
This program is designed to work with certain software (including
|
||||
but not limited to OpenSSL) that is licensed under separate terms,
|
||||
as designated in a particular file or component or in included license
|
||||
documentation. The authors of MySQL hereby grant you an additional
|
||||
permission to link the program and your derivative works with the
|
||||
separately licensed software that they have either included with
|
||||
the program or referenced in the documentation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License, version 2.0, for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#ifndef MY_COMPRESS_INCLUDED
|
||||
#define MY_COMPRESS_INCLUDED
|
||||
|
||||
/* List of valid values for compression_algorithm */
|
||||
enum enum_compression_algorithm {
|
||||
MYSQL_UNCOMPRESSED = 1,
|
||||
MYSQL_ZLIB,
|
||||
MYSQL_ZSTD,
|
||||
MYSQL_INVALID
|
||||
};
|
||||
|
||||
/**
|
||||
Compress context information. relating to zlib compression.
|
||||
*/
|
||||
|
||||
typedef struct mysql_zlib_compress_context {
|
||||
/**
|
||||
Compression level to use in zlib compression.
|
||||
*/
|
||||
unsigned int compression_level;
|
||||
} mysql_zlib_compress_context;
|
||||
|
||||
typedef struct ZSTD_CCtx_s ZSTD_CCtx;
|
||||
typedef struct ZSTD_DCtx_s ZSTD_DCtx;
|
||||
|
||||
/**
|
||||
Compress context information relating to zstd compression.
|
||||
*/
|
||||
|
||||
typedef struct mysql_zstd_compress_context {
|
||||
/**
|
||||
Pointer to compressor context.
|
||||
*/
|
||||
ZSTD_CCtx *cctx;
|
||||
/**
|
||||
Pointer to decompressor context.
|
||||
*/
|
||||
ZSTD_DCtx *dctx;
|
||||
/**
|
||||
Compression level to use in zstd compression.
|
||||
*/
|
||||
unsigned int compression_level;
|
||||
} mysql_zstd_compress_context;
|
||||
|
||||
/**
|
||||
Compression context information.
|
||||
It encapsulate the context information based on compression method and
|
||||
presents a generic struct.
|
||||
*/
|
||||
|
||||
typedef struct mysql_compress_context {
|
||||
enum enum_compression_algorithm algorithm; ///< Compression algorithm name.
|
||||
union {
|
||||
mysql_zlib_compress_context zlib_ctx; ///< Context information of zlib.
|
||||
mysql_zstd_compress_context zstd_ctx; ///< Context information of zstd.
|
||||
} u;
|
||||
} mysql_compress_context;
|
||||
|
||||
/**
|
||||
Get default compression level corresponding to a given compression method.
|
||||
|
||||
@param algorithm Compression Method. Possible values are zlib or zstd.
|
||||
|
||||
@return an unsigned int representing default compression level.
|
||||
6 is the default compression level for zlib and 3 is the
|
||||
default compression level for zstd.
|
||||
*/
|
||||
|
||||
unsigned int mysql_default_compression_level(
|
||||
enum enum_compression_algorithm algorithm);
|
||||
|
||||
/**
|
||||
Initialize a compress context object to be associated with a NET object.
|
||||
|
||||
@param cmp_ctx Pointer to compression context.
|
||||
@param algorithm Compression algorithm.
|
||||
@param compression_level Compression level corresponding to the compression
|
||||
algorithm.
|
||||
*/
|
||||
|
||||
void mysql_compress_context_init(mysql_compress_context *cmp_ctx,
|
||||
enum enum_compression_algorithm algorithm,
|
||||
unsigned int compression_level);
|
||||
/**
|
||||
Deinitialize the compression context allocated.
|
||||
|
||||
@param mysql_compress_ctx Pointer to Compression context.
|
||||
*/
|
||||
|
||||
void mysql_compress_context_deinit(mysql_compress_context *mysql_compress_ctx);
|
||||
|
||||
#endif // MY_COMPRESS_INCLUDED
|
||||
|
|
@ -1,475 +0,0 @@
|
|||
/* Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#ifndef MY_CONFIG_H
|
||||
#define MY_CONFIG_H
|
||||
|
||||
/*
|
||||
* From configure.cmake, in order of appearance
|
||||
*/
|
||||
/* #undef HAVE_LLVM_LIBCPP */
|
||||
#define _LARGEFILE_SOURCE 1
|
||||
|
||||
/* Libraries */
|
||||
/* #undef HAVE_LIBM */
|
||||
/* #undef HAVE_LIBNSL */
|
||||
/* #undef HAVE_LIBCRYPT */
|
||||
/* #undef HAVE_LIBSOCKET */
|
||||
/* #undef HAVE_LIBDL */
|
||||
/* #undef HAVE_LIBRT */
|
||||
/* #undef HAVE_LIBWRAP */
|
||||
|
||||
/* Header files */
|
||||
/* #undef HAVE_ALLOCA_H */
|
||||
/* #undef HAVE_ARPA_INET_H */
|
||||
/* #undef HAVE_DIRENT_H */
|
||||
/* #undef HAVE_DLFCN_H */
|
||||
/* #undef HAVE_EXECINFO_H */
|
||||
/* #undef HAVE_FPU_CONTROL_H */
|
||||
/* #undef HAVE_GRP_H */
|
||||
/* #undef HAVE_IEEEFP_H */
|
||||
/* #undef HAVE_LANGINFO_H */
|
||||
#define HAVE_MALLOC_H 1
|
||||
/* #undef HAVE_NETINET_IN_H */
|
||||
/* #undef HAVE_POLL_H */
|
||||
/* #undef HAVE_PWD_H */
|
||||
/* #undef HAVE_STRINGS_H */
|
||||
/* #undef HAVE_SYS_CDEFS_H */
|
||||
/* #undef HAVE_SYS_IOCTL_H */
|
||||
/* #undef HAVE_SYS_MMAN_H */
|
||||
/* #undef HAVE_SYS_RESOURCE_H */
|
||||
/* #undef HAVE_SYS_SELECT_H */
|
||||
/* #undef HAVE_SYS_SOCKET_H */
|
||||
/* #undef HAVE_TERM_H */
|
||||
/* #undef HAVE_TERMIOS_H */
|
||||
/* #undef HAVE_TERMIO_H */
|
||||
/* #undef HAVE_UNISTD_H */
|
||||
/* #undef HAVE_SYS_WAIT_H */
|
||||
/* #undef HAVE_SYS_PARAM_H */
|
||||
/* #undef HAVE_FNMATCH_H */
|
||||
/* #undef HAVE_SYS_UN_H */
|
||||
/* #undef HAVE_VIS_H */
|
||||
/* #undef HAVE_SASL_SASL_H */
|
||||
|
||||
/* Libevent */
|
||||
/* #undef HAVE_DEVPOLL */
|
||||
/* #undef HAVE_SYS_DEVPOLL_H */
|
||||
/* #undef HAVE_SYS_EPOLL_H */
|
||||
/* #undef HAVE_TAILQFOREACH */
|
||||
|
||||
/* Functions */
|
||||
#define HAVE_ALIGNED_MALLOC 1
|
||||
/* #undef HAVE_BACKTRACE */
|
||||
/* #undef HAVE_PRINTSTACK */
|
||||
/* #undef HAVE_INDEX */
|
||||
/* #undef HAVE_CLOCK_GETTIME */
|
||||
/* #undef HAVE_CUSERID */
|
||||
/* #undef HAVE_DIRECTIO */
|
||||
/* #undef HAVE_FTRUNCATE */
|
||||
#define HAVE_COMPRESS 1
|
||||
/* #undef HAVE_CRYPT */
|
||||
/* #undef HAVE_DLOPEN */
|
||||
/* #undef HAVE_FCHMOD */
|
||||
/* #undef HAVE_FCNTL */
|
||||
/* #undef HAVE_FDATASYNC */
|
||||
/* #undef HAVE_DECL_FDATASYNC */
|
||||
/* #undef HAVE_FEDISABLEEXCEPT */
|
||||
/* #undef HAVE_FSEEKO */
|
||||
/* #undef HAVE_FSYNC */
|
||||
/* #undef HAVE_GETHOSTBYADDR_R */
|
||||
/* #undef HAVE_GETHRTIME */
|
||||
#if defined(_WIN64) || defined(x64)
|
||||
#define HAVE_GETNAMEINFO 1
|
||||
#else
|
||||
/* #undef HAVE_GETNAMEINFO */
|
||||
#endif
|
||||
/* #undef HAVE_GETPASS */
|
||||
/* #undef HAVE_GETPASSPHRASE */
|
||||
/* #undef HAVE_GETPWNAM */
|
||||
/* #undef HAVE_GETPWUID */
|
||||
/* #undef HAVE_GETRLIMIT */
|
||||
/* #undef HAVE_GETRUSAGE */
|
||||
/* #undef HAVE_INITGROUPS */
|
||||
/* #undef HAVE_ISSETUGID */
|
||||
/* #undef HAVE_GETUID */
|
||||
/* #undef HAVE_GETEUID */
|
||||
/* #undef HAVE_GETGID */
|
||||
/* #undef HAVE_GETEGID */
|
||||
/* #undef HAVE_LSTAT */
|
||||
/* #undef HAVE_MADVISE */
|
||||
/* #undef HAVE_MALLOC_INFO */
|
||||
/* #undef HAVE_MEMRCHR */
|
||||
/* #undef HAVE_MLOCK */
|
||||
/* #undef HAVE_MLOCKALL */
|
||||
/* #undef HAVE_MMAP64 */
|
||||
/* #undef HAVE_POLL */
|
||||
/* #undef HAVE_POSIX_FALLOCATE */
|
||||
/* #undef HAVE_POSIX_MEMALIGN */
|
||||
/* #undef HAVE_PREAD */
|
||||
/* #undef HAVE_PTHREAD_CONDATTR_SETCLOCK */
|
||||
/* #undef HAVE_PTHREAD_SIGMASK */
|
||||
/* #undef HAVE_READDIR_R */
|
||||
/* #undef HAVE_READLINK */
|
||||
/* #undef HAVE_REALPATH */
|
||||
/* #undef HAVE_SETFD */
|
||||
/* #undef HAVE_SIGACTION */
|
||||
/* #undef HAVE_SLEEP */
|
||||
/* #undef HAVE_STPCPY */
|
||||
/* #undef HAVE_STPNCPY */
|
||||
/* #undef HAVE_STRLCPY */
|
||||
#define HAVE_STRNLEN 1
|
||||
/* #undef HAVE_STRLCAT */
|
||||
/* #undef HAVE_STRSIGNAL */
|
||||
/* #undef HAVE_FGETLN */
|
||||
/* #undef HAVE_STRSEP */
|
||||
#define HAVE_TELL 1
|
||||
/* #undef HAVE_VASPRINTF */
|
||||
/* #undef HAVE_MEMALIGN */
|
||||
/* #undef HAVE_NL_LANGINFO */
|
||||
/* #undef HAVE_HTONLL */
|
||||
/* #undef DNS_USE_CPU_CLOCK_FOR_ID */
|
||||
/* #undef HAVE_EPOLL */
|
||||
/* #undef HAVE_EVENT_PORTS */
|
||||
#if defined(_WIN64) || defined(x64)
|
||||
#define HAVE_INET_NTOP 1
|
||||
#else
|
||||
/* #undef HAVE_INET_NTOP */
|
||||
#endif
|
||||
/* #undef HAVE_WORKING_KQUEUE */
|
||||
/* #undef HAVE_TIMERADD */
|
||||
/* #undef HAVE_TIMERCLEAR */
|
||||
/* #undef HAVE_TIMERCMP */
|
||||
/* #undef HAVE_TIMERISSET */
|
||||
|
||||
/* WL2373 */
|
||||
/* #undef HAVE_SYS_TIME_H */
|
||||
/* #undef HAVE_SYS_TIMES_H */
|
||||
/* #undef HAVE_TIMES */
|
||||
/* #undef HAVE_GETTIMEOFDAY */
|
||||
|
||||
/* Symbols */
|
||||
/* #undef HAVE_LRAND48 */
|
||||
/* #undef GWINSZ_IN_SYS_IOCTL */
|
||||
/* #undef FIONREAD_IN_SYS_IOCTL */
|
||||
/* #undef FIONREAD_IN_SYS_FILIO */
|
||||
/* #undef HAVE_SIGEV_THREAD_ID */
|
||||
/* #undef HAVE_SIGEV_PORT */
|
||||
#define HAVE_LOG2 1
|
||||
|
||||
#define HAVE_ISINF 1
|
||||
|
||||
/* #undef HAVE_KQUEUE_TIMERS */
|
||||
/* #undef HAVE_POSIX_TIMERS */
|
||||
|
||||
/* Endianess */
|
||||
/* #undef WORDS_BIGENDIAN */
|
||||
|
||||
/* Type sizes */
|
||||
#if defined(_WIN64) || defined(x64)
|
||||
#define SIZEOF_VOIDP 8
|
||||
#define SIZEOF_CHARP 8
|
||||
#else
|
||||
#define SIZEOF_VOIDP 4
|
||||
#define SIZEOF_CHARP 4
|
||||
#endif
|
||||
#define SIZEOF_LONG 4
|
||||
#define SIZEOF_SHORT 2
|
||||
#define SIZEOF_INT 4
|
||||
#define SIZEOF_LONG_LONG 8
|
||||
#define SIZEOF_OFF_T 4
|
||||
#define SIZEOF_TIME_T 8
|
||||
/* #undef HAVE_UINT */
|
||||
/* #undef HAVE_ULONG */
|
||||
/* #undef HAVE_U_INT32_T */
|
||||
#define HAVE_STRUCT_TIMESPEC
|
||||
|
||||
/* Support for tagging symbols with __attribute__((visibility("hidden"))) */
|
||||
/* #undef HAVE_VISIBILITY_HIDDEN */
|
||||
|
||||
/* Code tests*/
|
||||
#define STACK_DIRECTION -1
|
||||
/* #undef TIME_WITH_SYS_TIME */
|
||||
#define NO_FCNTL_NONBLOCK 1
|
||||
/* #undef HAVE_PAUSE_INSTRUCTION */
|
||||
/* #undef HAVE_FAKE_PAUSE_INSTRUCTION */
|
||||
/* #undef HAVE_HMT_PRIORITY_INSTRUCTION */
|
||||
/* #undef HAVE_ABI_CXA_DEMANGLE */
|
||||
/* #undef HAVE_BSS_START */
|
||||
/* #undef HAVE_BUILTIN_UNREACHABLE */
|
||||
/* #undef HAVE_BUILTIN_EXPECT */
|
||||
/* #undef HAVE_BUILTIN_STPCPY */
|
||||
/* #undef HAVE_GCC_ATOMIC_BUILTINS */
|
||||
/* #undef HAVE_GCC_SYNC_BUILTINS */
|
||||
/* #undef HAVE_VALGRIND */
|
||||
|
||||
/* IPV6 */
|
||||
/* #undef HAVE_NETINET_IN6_H */
|
||||
#define HAVE_STRUCT_SOCKADDR_IN6 1
|
||||
#define HAVE_STRUCT_IN6_ADDR 1
|
||||
#define HAVE_IPV6 1
|
||||
|
||||
/* #undef ss_family */
|
||||
/* #undef HAVE_SOCKADDR_IN_SIN_LEN */
|
||||
/* #undef HAVE_SOCKADDR_IN6_SIN6_LEN */
|
||||
|
||||
/*
|
||||
* Platform specific CMake files
|
||||
*/
|
||||
#if defined(_WIN64) || defined(x64)
|
||||
#define MACHINE_TYPE "x86_64"
|
||||
#else
|
||||
#define MACHINE_TYPE "AMD64"
|
||||
#endif
|
||||
/* #undef HAVE_LINUX_LARGE_PAGES */
|
||||
/* #undef HAVE_SOLARIS_LARGE_PAGES */
|
||||
/* #undef HAVE_SOLARIS_ATOMIC */
|
||||
/* #undef HAVE_SOLARIS_STYLE_GETHOST */
|
||||
#if defined(_WIN64) || defined(x64)
|
||||
#define SYSTEM_TYPE "Win64"
|
||||
#else
|
||||
#define SYSTEM_TYPE "Win32"
|
||||
#endif
|
||||
/* Windows stuff, mostly functions, that have Posix analogs but named differently */
|
||||
/* #undef IPPROTO_IPV6 */
|
||||
/* #undef IPV6_V6ONLY */
|
||||
/* This should mean case insensitive file system */
|
||||
#define FN_NO_CASE_SENSE 1
|
||||
|
||||
/*
|
||||
* From main CMakeLists.txt
|
||||
*/
|
||||
#define MAX_INDEXES 64U
|
||||
/* #undef WITH_INNODB_MEMCACHED */
|
||||
/* #undef ENABLE_MEMCACHED_SASL */
|
||||
/* #undef ENABLE_MEMCACHED_SASL_PWDB */
|
||||
#define ENABLED_PROFILING 1
|
||||
/* #undef HAVE_ASAN */
|
||||
#define ENABLED_LOCAL_INFILE 1
|
||||
/* #undef OPTIMIZER_TRACE */
|
||||
#define DEFAULT_MYSQL_HOME "C:/Program Files/MySQL/MySQL Server 6.1"
|
||||
#define SHAREDIR "share"
|
||||
#define DEFAULT_BASEDIR "C:/Program Files/MySQL/MySQL Server 6.1"
|
||||
#define MYSQL_DATADIR "C:/Program Files/MySQL/MySQL Server 6.1/data"
|
||||
#define MYSQL_KEYRINGDIR "C:/Program Files/MySQL/MySQL Server 6.1/keyring"
|
||||
#define DEFAULT_CHARSET_HOME "C:/Program Files/MySQL/MySQL Server 6.1"
|
||||
#define PLUGINDIR "C:/Program Files/MySQL/MySQL Server 6.1/lib/plugin"
|
||||
/* #undef DEFAULT_SYSCONFDIR */
|
||||
#define DEFAULT_TMPDIR ""
|
||||
#define INSTALL_SBINDIR "/bin"
|
||||
#define INSTALL_BINDIR "/bin"
|
||||
#define INSTALL_MYSQLSHAREDIR "/share"
|
||||
#define INSTALL_SHAREDIR "/share"
|
||||
#define INSTALL_PLUGINDIR "/lib/plugin"
|
||||
#define INSTALL_INCLUDEDIR "/include"
|
||||
#define INSTALL_SCRIPTDIR "/scripts"
|
||||
#define INSTALL_MYSQLDATADIR "/data"
|
||||
#define INSTALL_MYSQLKEYRINGDIR "/keyring"
|
||||
/* #undef INSTALL_PLUGINTESTDIR */
|
||||
#define INSTALL_INFODIR "/docs"
|
||||
#define INSTALL_MYSQLTESTDIR "/mysql-test"
|
||||
#define INSTALL_DOCREADMEDIR "/."
|
||||
#define INSTALL_DOCDIR "/docs"
|
||||
#define INSTALL_MANDIR "/man"
|
||||
#define INSTALL_SUPPORTFILESDIR "/support-files"
|
||||
#define INSTALL_LIBDIR "/lib"
|
||||
|
||||
/*
|
||||
* Readline
|
||||
*/
|
||||
/* #undef HAVE_MBSTATE_T */
|
||||
/* #undef HAVE_LANGINFO_CODESET */
|
||||
/* #undef HAVE_WCSDUP */
|
||||
/* #undef HAVE_WCHAR_T */
|
||||
/* #undef HAVE_WINT_T */
|
||||
/* #undef HAVE_CURSES_H */
|
||||
/* #undef HAVE_NCURSES_H */
|
||||
/* #undef USE_LIBEDIT_INTERFACE */
|
||||
/* #undef HAVE_HIST_ENTRY */
|
||||
/* #undef USE_NEW_EDITLINE_INTERFACE */
|
||||
|
||||
/*
|
||||
* Libedit
|
||||
*/
|
||||
/* #undef HAVE_DECL_TGOTO */
|
||||
|
||||
/*
|
||||
* DTrace
|
||||
*/
|
||||
/* #undef HAVE_DTRACE */
|
||||
|
||||
/*
|
||||
* Character sets
|
||||
*/
|
||||
#define MYSQL_DEFAULT_CHARSET_NAME "latin1"
|
||||
#define MYSQL_DEFAULT_COLLATION_NAME "latin1_swedish_ci"
|
||||
#define HAVE_CHARSET_armscii8 1
|
||||
#define HAVE_CHARSET_ascii 1
|
||||
#define HAVE_CHARSET_big5 1
|
||||
#define HAVE_CHARSET_cp1250 1
|
||||
#define HAVE_CHARSET_cp1251 1
|
||||
#define HAVE_CHARSET_cp1256 1
|
||||
#define HAVE_CHARSET_cp1257 1
|
||||
#define HAVE_CHARSET_cp850 1
|
||||
#define HAVE_CHARSET_cp852 1
|
||||
#define HAVE_CHARSET_cp866 1
|
||||
#define HAVE_CHARSET_cp932 1
|
||||
#define HAVE_CHARSET_dec8 1
|
||||
#define HAVE_CHARSET_eucjpms 1
|
||||
#define HAVE_CHARSET_euckr 1
|
||||
#define HAVE_CHARSET_gb2312 1
|
||||
#define HAVE_CHARSET_gbk 1
|
||||
#define HAVE_CHARSET_gb18030 1
|
||||
#define HAVE_CHARSET_geostd8 1
|
||||
#define HAVE_CHARSET_greek 1
|
||||
#define HAVE_CHARSET_hebrew 1
|
||||
#define HAVE_CHARSET_hp8 1
|
||||
#define HAVE_CHARSET_keybcs2 1
|
||||
#define HAVE_CHARSET_koi8r 1
|
||||
#define HAVE_CHARSET_koi8u 1
|
||||
#define HAVE_CHARSET_latin1 1
|
||||
#define HAVE_CHARSET_latin2 1
|
||||
#define HAVE_CHARSET_latin5 1
|
||||
#define HAVE_CHARSET_latin7 1
|
||||
#define HAVE_CHARSET_macce 1
|
||||
#define HAVE_CHARSET_macroman 1
|
||||
#define HAVE_CHARSET_sjis 1
|
||||
#define HAVE_CHARSET_swe7 1
|
||||
#define HAVE_CHARSET_tis620 1
|
||||
#define HAVE_CHARSET_ucs2 1
|
||||
#define HAVE_CHARSET_ujis 1
|
||||
#define HAVE_CHARSET_utf8mb4 1
|
||||
/* #undef HAVE_CHARSET_utf8mb3 */
|
||||
#define HAVE_CHARSET_utf8 1
|
||||
#define HAVE_CHARSET_utf16 1
|
||||
#define HAVE_CHARSET_utf32 1
|
||||
#define HAVE_UCA_COLLATIONS 1
|
||||
|
||||
/*
|
||||
* Feature set
|
||||
*/
|
||||
#define WITH_PARTITION_STORAGE_ENGINE 1
|
||||
|
||||
/*
|
||||
* Performance schema
|
||||
*/
|
||||
/* #undef WITH_PERFSCHEMA_STORAGE_ENGINE */
|
||||
/* #undef DISABLE_PSI_THREAD */
|
||||
/* #undef DISABLE_PSI_MUTEX */
|
||||
/* #undef DISABLE_PSI_RWLOCK */
|
||||
/* #undef DISABLE_PSI_COND */
|
||||
/* #undef DISABLE_PSI_FILE */
|
||||
/* #undef DISABLE_PSI_TABLE */
|
||||
/* #undef DISABLE_PSI_SOCKET */
|
||||
/* #undef DISABLE_PSI_STAGE */
|
||||
/* #undef DISABLE_PSI_STATEMENT */
|
||||
/* #undef DISABLE_PSI_SP */
|
||||
/* #undef DISABLE_PSI_PS */
|
||||
/* #undef DISABLE_PSI_IDLE */
|
||||
/* #undef DISABLE_PSI_STATEMENT_DIGEST */
|
||||
/* #undef DISABLE_PSI_METADATA */
|
||||
/* #undef DISABLE_PSI_MEMORY */
|
||||
/* #undef DISABLE_PSI_TRANSACTION */
|
||||
|
||||
/*
|
||||
* syscall
|
||||
*/
|
||||
/* #undef HAVE_SYS_THREAD_SELFID */
|
||||
/* #undef HAVE_SYS_GETTID */
|
||||
/* #undef HAVE_PTHREAD_GETTHREADID_NP */
|
||||
/* #undef HAVE_PTHREAD_SETNAME_NP */
|
||||
/* #undef HAVE_INTEGER_PTHREAD_SELF */
|
||||
|
||||
/* Platform-specific C++ compiler behaviors we rely upon */
|
||||
|
||||
/*
|
||||
This macro defines whether the compiler in use needs a 'typename' keyword
|
||||
to access the types defined inside a class template, such types are called
|
||||
dependent types. Some compilers require it, some others forbid it, and some
|
||||
others may work with or without it. For example, GCC requires the 'typename'
|
||||
keyword whenever needing to access a type inside a template, but msvc
|
||||
forbids it.
|
||||
*/
|
||||
#define HAVE_IMPLICIT_DEPENDENT_NAME_TYPING 1
|
||||
|
||||
|
||||
/*
|
||||
* MySQL version
|
||||
*/
|
||||
#define DOT_FRM_VERSION 6
|
||||
#define MYSQL_VERSION_MAJOR 6
|
||||
#define MYSQL_VERSION_MINOR 1
|
||||
#define MYSQL_VERSION_PATCH 11
|
||||
#define MYSQL_VERSION_EXTRA ""
|
||||
#define PACKAGE "mysql"
|
||||
#define PACKAGE_BUGREPORT ""
|
||||
#define PACKAGE_NAME "MySQL Server"
|
||||
#define PACKAGE_STRING "MySQL Server 6.1.11"
|
||||
#define PACKAGE_TARNAME "mysql"
|
||||
#define PACKAGE_VERSION "6.1.11"
|
||||
#define VERSION "6.1.11"
|
||||
#define PROTOCOL_VERSION 10
|
||||
|
||||
/*
|
||||
* CPU info
|
||||
*/
|
||||
#define CPU_LEVEL1_DCACHE_LINESIZE 64
|
||||
|
||||
/*
|
||||
* NDB
|
||||
*/
|
||||
/* #undef WITH_NDBCLUSTER_STORAGE_ENGINE */
|
||||
/* #undef HAVE_PTHREAD_SETSCHEDPARAM */
|
||||
|
||||
/*
|
||||
* Other
|
||||
*/
|
||||
/* #undef EXTRA_DEBUG */
|
||||
/* #undef HAVE_CHOWN */
|
||||
|
||||
/*
|
||||
* Hardcoded values needed by libevent/NDB/memcached
|
||||
*/
|
||||
#define HAVE_FCNTL_H 1
|
||||
#define HAVE_GETADDRINFO 1
|
||||
#define HAVE_INTTYPES_H 1
|
||||
/* libevent's select.c is not Windows compatible */
|
||||
#ifndef _WIN32
|
||||
#define HAVE_SELECT 1
|
||||
#endif
|
||||
#define HAVE_SIGNAL_H 1
|
||||
#define HAVE_STDARG_H 1
|
||||
#define HAVE_STDINT_H 1
|
||||
#define HAVE_STDLIB_H 1
|
||||
#define HAVE_STRDUP 1
|
||||
#define HAVE_STRTOK_R 1
|
||||
#define HAVE_STRTOLL 1
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
#define SIZEOF_CHAR 1
|
||||
|
||||
/*
|
||||
* Needed by libevent
|
||||
*/
|
||||
/* #undef HAVE_SOCKLEN_T */
|
||||
|
||||
/* For --secure-file-priv */
|
||||
#define DEFAULT_SECURE_FILE_PRIV_DIR "NULL"
|
||||
#define DEFAULT_SECURE_FILE_PRIV_EMBEDDED_DIR "NULL"
|
||||
/* #undef HAVE_LIBNUMA */
|
||||
|
||||
/* For default value of --early_plugin_load */
|
||||
/* #undef DEFAULT_EARLY_PLUGIN_LOAD */
|
||||
|
||||
#endif
|
||||
|
|
@ -1,245 +0,0 @@
|
|||
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#ifndef MY_DBUG_INCLUDED
|
||||
#define MY_DBUG_INCLUDED
|
||||
|
||||
#include "my_global.h" /* MYSQL_PLUGIN_IMPORT */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#if !defined(DBUG_OFF)
|
||||
|
||||
struct _db_stack_frame_ {
|
||||
const char *func; /* function name of the previous stack frame */
|
||||
const char *file; /* filename of the function of previous frame */
|
||||
uint level; /* this nesting level, highest bit enables tracing */
|
||||
struct _db_stack_frame_ *prev; /* pointer to the previous frame */
|
||||
};
|
||||
|
||||
struct _db_code_state_;
|
||||
extern MYSQL_PLUGIN_IMPORT my_bool _dbug_on_;
|
||||
extern my_bool _db_keyword_(struct _db_code_state_ *, const char *, int);
|
||||
extern int _db_explain_(struct _db_code_state_ *cs, char *buf, size_t len);
|
||||
extern int _db_explain_init_(char *buf, size_t len);
|
||||
extern int _db_is_pushed_(void);
|
||||
extern void _db_setjmp_(void);
|
||||
extern void _db_longjmp_(void);
|
||||
extern void _db_process_(const char *name);
|
||||
extern void _db_push_(const char *control);
|
||||
extern void _db_pop_(void);
|
||||
extern void _db_set_(const char *control);
|
||||
extern void _db_set_init_(const char *control);
|
||||
extern void _db_enter_(const char *_func_, const char *_file_, uint _line_,
|
||||
struct _db_stack_frame_ *_stack_frame_);
|
||||
extern void _db_return_(uint _line_, struct _db_stack_frame_ *_stack_frame_);
|
||||
extern void _db_pargs_(uint _line_,const char *keyword);
|
||||
extern int _db_enabled_();
|
||||
extern void _db_doprnt_(const char *format,...)
|
||||
MY_ATTRIBUTE((format(printf, 1, 2)));
|
||||
extern void _db_doputs_(const char *log);
|
||||
extern void _db_dump_(uint _line_,const char *keyword,
|
||||
const unsigned char *memory, size_t length);
|
||||
extern void _db_end_(void);
|
||||
extern void _db_lock_file_(void);
|
||||
extern void _db_unlock_file_(void);
|
||||
extern FILE *_db_fp_(void);
|
||||
extern void _db_flush_();
|
||||
extern const char* _db_get_func_(void);
|
||||
|
||||
#define DBUG_ENTER(a) struct _db_stack_frame_ _db_stack_frame_; \
|
||||
_db_enter_ (a,__FILE__,__LINE__,&_db_stack_frame_)
|
||||
#define DBUG_LEAVE _db_return_ (__LINE__, &_db_stack_frame_)
|
||||
#define DBUG_RETURN(a1) do {DBUG_LEAVE; return(a1);} while(0)
|
||||
#define DBUG_VOID_RETURN do {DBUG_LEAVE; return;} while(0)
|
||||
#define DBUG_EXECUTE(keyword,a1) \
|
||||
do {if (_db_keyword_(0, (keyword), 0)) { a1 }} while(0)
|
||||
#define DBUG_EXECUTE_IF(keyword,a1) \
|
||||
do {if (_db_keyword_(0, (keyword), 1)) { a1 }} while(0)
|
||||
#define DBUG_EVALUATE(keyword,a1,a2) \
|
||||
(_db_keyword_(0,(keyword), 0) ? (a1) : (a2))
|
||||
#define DBUG_EVALUATE_IF(keyword,a1,a2) \
|
||||
(_db_keyword_(0,(keyword), 1) ? (a1) : (a2))
|
||||
#define DBUG_PRINT(keyword,arglist) \
|
||||
do \
|
||||
{ \
|
||||
if (_dbug_on_) \
|
||||
{ \
|
||||
_db_pargs_(__LINE__,keyword); \
|
||||
if (_db_enabled_()) \
|
||||
{ \
|
||||
_db_doprnt_ arglist; \
|
||||
} \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/*
|
||||
An alternate to DBUG_PRINT() macro, which takes a single string
|
||||
as the second argument.
|
||||
*/
|
||||
#define DBUG_PUTS(keyword,arg) \
|
||||
do \
|
||||
{ \
|
||||
if (_dbug_on_) \
|
||||
{ \
|
||||
_db_pargs_(__LINE__,keyword); \
|
||||
if (_db_enabled_()) \
|
||||
{ \
|
||||
_db_doputs_(arg); \
|
||||
} \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define DBUG_PUSH(a1) _db_push_ (a1)
|
||||
#define DBUG_POP() _db_pop_ ()
|
||||
#define DBUG_SET(a1) _db_set_ (a1)
|
||||
#define DBUG_SET_INITIAL(a1) _db_set_init_ (a1)
|
||||
#define DBUG_PROCESS(a1) _db_process_(a1)
|
||||
#define DBUG_FILE _db_fp_()
|
||||
#define DBUG_SETJMP(a1) (_db_setjmp_ (), setjmp (a1))
|
||||
#define DBUG_LONGJMP(a1,a2) (_db_longjmp_ (), longjmp (a1, a2))
|
||||
#define DBUG_DUMP(keyword,a1,a2) _db_dump_(__LINE__,keyword,a1,a2)
|
||||
#define DBUG_END() _db_end_ ()
|
||||
#define DBUG_LOCK_FILE _db_lock_file_()
|
||||
#define DBUG_UNLOCK_FILE _db_unlock_file_()
|
||||
#define DBUG_ASSERT(A) assert(A)
|
||||
#define DBUG_EXPLAIN(buf,len) _db_explain_(0, (buf),(len))
|
||||
#define DBUG_EXPLAIN_INITIAL(buf,len) _db_explain_init_((buf),(len))
|
||||
#define DEBUGGER_OFF do { _dbug_on_= 0; } while(0)
|
||||
#define DEBUGGER_ON do { _dbug_on_= 1; } while(0)
|
||||
#ifndef _WIN32
|
||||
#define DBUG_ABORT() (_db_flush_(), abort())
|
||||
#else
|
||||
/*
|
||||
Avoid popup with abort/retry/ignore buttons. When BUG#31745 is fixed we can
|
||||
call abort() instead of _exit(2) (now it would cause a "test signal" popup).
|
||||
*/
|
||||
#include <crtdbg.h>
|
||||
#define DBUG_ABORT() (_db_flush_(),\
|
||||
(void)_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE),\
|
||||
(void)_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR),\
|
||||
_exit(2))
|
||||
#endif
|
||||
#define DBUG_CHECK_CRASH(func, op) \
|
||||
do { char _dbuf_[255]; strxnmov(_dbuf_, sizeof(_dbuf_)-1, (func), (op)); \
|
||||
DBUG_EXECUTE_IF(_dbuf_, DBUG_ABORT()); } while(0)
|
||||
#define DBUG_CRASH_ENTER(func) \
|
||||
DBUG_ENTER(func); DBUG_CHECK_CRASH(func, "_crash_enter")
|
||||
#define DBUG_CRASH_RETURN(val) \
|
||||
DBUG_CHECK_CRASH(_db_get_func_(), "_crash_return")
|
||||
#define DBUG_CRASH_VOID_RETURN \
|
||||
DBUG_CHECK_CRASH (_db_get_func_(), "_crash_return")
|
||||
|
||||
/*
|
||||
Make the program fail, without creating a core file.
|
||||
abort() will send SIGABRT which (most likely) generates core.
|
||||
Use SIGKILL instead, which cannot be caught.
|
||||
We also pause the current thread, until the signal is actually delivered.
|
||||
An alternative would be to use _exit(EXIT_FAILURE),
|
||||
but then valgrind would report lots of memory leaks.
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
#define DBUG_SUICIDE() DBUG_ABORT()
|
||||
#else
|
||||
extern void _db_suicide_();
|
||||
extern void _db_flush_gcov_();
|
||||
#define DBUG_SUICIDE() (_db_flush_(), _db_suicide_())
|
||||
#endif
|
||||
|
||||
#else /* No debugger */
|
||||
|
||||
#define DBUG_ENTER(a1)
|
||||
#define DBUG_LEAVE
|
||||
#define DBUG_RETURN(a1) do { return(a1); } while(0)
|
||||
#define DBUG_VOID_RETURN do { return; } while(0)
|
||||
#define DBUG_EXECUTE(keyword,a1) do { } while(0)
|
||||
#define DBUG_EXECUTE_IF(keyword,a1) do { } while(0)
|
||||
#define DBUG_EVALUATE(keyword,a1,a2) (a2)
|
||||
#define DBUG_EVALUATE_IF(keyword,a1,a2) (a2)
|
||||
#define DBUG_PRINT(keyword,arglist) do { } while(0)
|
||||
#define DBUG_PUTS(keyword,arg) do { } while(0)
|
||||
#define DBUG_LOG(keyword,arglist) do { } while(0)
|
||||
#define DBUG_PUSH(a1) do { } while(0)
|
||||
#define DBUG_SET(a1) do { } while(0)
|
||||
#define DBUG_SET_INITIAL(a1) do { } while(0)
|
||||
#define DBUG_POP() do { } while(0)
|
||||
#define DBUG_PROCESS(a1) do { } while(0)
|
||||
#define DBUG_SETJMP(a1) setjmp(a1)
|
||||
#define DBUG_LONGJMP(a1) longjmp(a1)
|
||||
#define DBUG_DUMP(keyword,a1,a2) do { } while(0)
|
||||
#define DBUG_END() do { } while(0)
|
||||
#define DBUG_ASSERT(A) do { } while(0)
|
||||
#define DBUG_LOCK_FILE do { } while(0)
|
||||
#define DBUG_FILE (stderr)
|
||||
#define DBUG_UNLOCK_FILE do { } while(0)
|
||||
#define DBUG_EXPLAIN(buf,len)
|
||||
#define DBUG_EXPLAIN_INITIAL(buf,len)
|
||||
#define DEBUGGER_OFF do { } while(0)
|
||||
#define DEBUGGER_ON do { } while(0)
|
||||
#define DBUG_ABORT() do { } while(0)
|
||||
#define DBUG_CRASH_ENTER(func)
|
||||
#define DBUG_CRASH_RETURN(val) do { return(val); } while(0)
|
||||
#define DBUG_CRASH_VOID_RETURN do { return; } while(0)
|
||||
#define DBUG_SUICIDE() do { } while(0)
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef EXTRA_DEBUG
|
||||
/**
|
||||
Sync points allow us to force the server to reach a certain line of code
|
||||
and block there until the client tells the server it is ok to go on.
|
||||
The client tells the server to block with SELECT GET_LOCK()
|
||||
and unblocks it with SELECT RELEASE_LOCK(). Used for debugging difficult
|
||||
concurrency problems
|
||||
*/
|
||||
#define DBUG_SYNC_POINT(lock_name,lock_timeout) \
|
||||
debug_sync_point(lock_name,lock_timeout)
|
||||
void debug_sync_point(const char* lock_name, uint lock_timeout);
|
||||
#else
|
||||
#define DBUG_SYNC_POINT(lock_name,lock_timeout)
|
||||
#endif /* EXTRA_DEBUG */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if !defined(DBUG_OFF)
|
||||
#include <sstream>
|
||||
|
||||
/*
|
||||
A C++ interface to the DBUG_PUTS macro. The DBUG_LOG macro also
|
||||
takes two arguments. The first argument is the keyword, as that of the
|
||||
DBUG_PRINT. The 2nd argument 'v' will be passed to a C++ output stream.
|
||||
This enables the use of C++ style output stream operator. In the code, it
|
||||
will be used as follows:
|
||||
|
||||
DBUG_LOG("blob", "space: " << space_id);
|
||||
|
||||
Note: DBUG_PRINT() has a limitation of 1024 bytes for a single
|
||||
print out. This limitation is not there for DBUG_PUTS and DBUG_LOG
|
||||
macros.
|
||||
*/
|
||||
|
||||
#define DBUG_LOG(keyword, v) do { \
|
||||
std::ostringstream sout; \
|
||||
sout << v; \
|
||||
DBUG_PUTS(keyword, sout.str().c_str()); \
|
||||
} while(0)
|
||||
#endif /* DBUG_OFF */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* MY_DBUG_INCLUDED */
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#ifndef MY_DIR_H
|
||||
#define MY_DIR_H
|
||||
|
||||
#include "my_global.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Defines for my_dir and my_stat */
|
||||
|
||||
#ifdef _WIN32
|
||||
#define S_IROTH _S_IREAD
|
||||
#define S_IFIFO _S_IFIFO
|
||||
#endif
|
||||
|
||||
#define MY_S_IFMT S_IFMT /* type of file */
|
||||
#define MY_S_IFDIR S_IFDIR /* directory */
|
||||
#define MY_S_IFCHR S_IFCHR /* character special */
|
||||
#define MY_S_IFBLK S_IFBLK /* block special */
|
||||
#define MY_S_IFREG S_IFREG /* regular */
|
||||
#define MY_S_IFIFO S_IFIFO /* fifo */
|
||||
#define MY_S_ISUID S_ISUID /* set user id on execution */
|
||||
#define MY_S_ISGID S_ISGID /* set group id on execution */
|
||||
#define MY_S_ISVTX S_ISVTX /* save swapped text even after use */
|
||||
#define MY_S_IREAD S_IREAD /* read permission, owner */
|
||||
#define MY_S_IWRITE S_IWRITE /* write permission, owner */
|
||||
#define MY_S_IEXEC S_IEXEC /* execute/search permission, owner */
|
||||
|
||||
#define MY_S_ISDIR(m) (((m) & MY_S_IFMT) == MY_S_IFDIR)
|
||||
#define MY_S_ISCHR(m) (((m) & MY_S_IFMT) == MY_S_IFCHR)
|
||||
#define MY_S_ISBLK(m) (((m) & MY_S_IFMT) == MY_S_IFBLK)
|
||||
#define MY_S_ISREG(m) (((m) & MY_S_IFMT) == MY_S_IFREG)
|
||||
#define MY_S_ISFIFO(m) (((m) & MY_S_IFMT) == MY_S_IFIFO)
|
||||
|
||||
#define MY_DONT_SORT 512 /* my_lib; Don't sort files */
|
||||
#define MY_WANT_STAT 1024 /* my_lib; stat files */
|
||||
|
||||
/* typedefs for my_dir & my_stat */
|
||||
|
||||
#if(_MSC_VER)
|
||||
#define MY_STAT struct _stati64 /* 64 bit file size */
|
||||
#else
|
||||
#define MY_STAT struct stat /* Orginal struct have what we need */
|
||||
#endif
|
||||
|
||||
/* Struct describing one file returned from my_dir */
|
||||
typedef struct fileinfo
|
||||
{
|
||||
char *name;
|
||||
MY_STAT *mystat;
|
||||
} FILEINFO;
|
||||
|
||||
typedef struct st_my_dir /* Struct returned from my_dir */
|
||||
{
|
||||
/*
|
||||
These members are just copies of parts of DYNAMIC_ARRAY structure,
|
||||
which is allocated right after the end of MY_DIR structure (MEM_ROOT
|
||||
for storing names is also resides there). We've left them here because
|
||||
we don't want to change code that uses my_dir.
|
||||
*/
|
||||
struct fileinfo *dir_entry;
|
||||
uint number_off_files;
|
||||
} MY_DIR;
|
||||
|
||||
extern MY_DIR *my_dir(const char *path,myf MyFlags);
|
||||
extern void my_dirend(MY_DIR *buffer);
|
||||
extern MY_STAT *my_stat(const char *path, MY_STAT *stat_area, myf my_flags);
|
||||
extern int my_fstat(int filenr, MY_STAT *stat_area, myf MyFlags);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MY_DIR_H */
|
||||
|
||||
|
|
@ -1,149 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#ifndef _my_getopt_h
|
||||
#define _my_getopt_h
|
||||
|
||||
#include "my_sys.h" /* loglevel */
|
||||
|
||||
C_MODE_START
|
||||
|
||||
#define GET_NO_ARG 1
|
||||
#define GET_BOOL 2
|
||||
#define GET_INT 3
|
||||
#define GET_UINT 4
|
||||
#define GET_LONG 5
|
||||
#define GET_ULONG 6
|
||||
#define GET_LL 7
|
||||
#define GET_ULL 8
|
||||
#define GET_STR 9
|
||||
#define GET_STR_ALLOC 10
|
||||
#define GET_DISABLED 11
|
||||
#define GET_ENUM 12
|
||||
#define GET_SET 13
|
||||
#define GET_DOUBLE 14
|
||||
#define GET_FLAGSET 15
|
||||
#define GET_PASSWORD 16
|
||||
|
||||
#if SIZEOF_INT == 4
|
||||
#define GET_INT32 GET_INT
|
||||
#define GET_UINT32 GET_UINT
|
||||
#elif SIZEOF_LONG == 4
|
||||
#define GET_INT32 GET_LONG
|
||||
#define GET_UINT32 GET_ULONG
|
||||
#else
|
||||
#error Neither int or long is of 4 bytes width
|
||||
#endif
|
||||
|
||||
#define GET_ASK_ADDR 128
|
||||
#define GET_TYPE_MASK 127
|
||||
|
||||
/**
|
||||
Enumeration of the my_option::arg_type attributes.
|
||||
It should be noted that for historical reasons variables with the combination
|
||||
arg_type=NO_ARG, my_option::var_type=GET_BOOL still accepts
|
||||
arguments. This is someone counter intuitive and care should be taken
|
||||
if the code is refactored.
|
||||
*/
|
||||
enum get_opt_arg_type { NO_ARG, OPT_ARG, REQUIRED_ARG };
|
||||
|
||||
struct st_typelib;
|
||||
|
||||
struct my_option
|
||||
{
|
||||
const char *name; /**< Name of the option. name=NULL
|
||||
marks the end of the my_option[]
|
||||
array.
|
||||
*/
|
||||
int id; /**< For 0<id<=255 it's means one
|
||||
character for a short option
|
||||
(like -A), if >255 no short option
|
||||
is created, but a long option still
|
||||
can be identified uniquely in the
|
||||
my_get_one_option() callback.
|
||||
If an opton needs neither special
|
||||
treatment in the my_get_one_option()
|
||||
nor one-letter short equivalent
|
||||
use id=0.
|
||||
id=-1 is a special case and is used
|
||||
to generate deprecation warnings for
|
||||
plugin options. It should not be
|
||||
used for anything else.
|
||||
*/
|
||||
const char *comment; /**< option comment, for autom. --help.
|
||||
if it's NULL the option is not
|
||||
visible in --help.
|
||||
*/
|
||||
void *value; /**< A pointer to the variable value */
|
||||
void *u_max_value; /**< The user def. max variable value */
|
||||
struct st_typelib *typelib; /**< Pointer to possible values */
|
||||
ulong var_type; /**< GET_BOOL, GET_ULL, etc */
|
||||
enum get_opt_arg_type arg_type; /**< e.g. REQUIRED_ARG or OPT_ARG */
|
||||
longlong def_value; /**< Default value */
|
||||
longlong min_value; /**< Min allowed value (for numbers) */
|
||||
ulonglong max_value; /**< Max allowed value (for numbers) */
|
||||
longlong sub_size; /**< Unused */
|
||||
long block_size; /**< Value should be a mult. of this (for numbers) */
|
||||
void *app_type; /**< To be used by an application */
|
||||
};
|
||||
|
||||
|
||||
typedef my_bool (*my_get_one_option)(int, const struct my_option *, char *);
|
||||
/**
|
||||
Used to retrieve a reference to the object (variable) that holds the value
|
||||
for the given option. For example, if var_type is GET_UINT, the function
|
||||
must return a pointer to a variable of type uint. A argument is stored in
|
||||
the location pointed to by the returned pointer.
|
||||
*/
|
||||
typedef void *(*my_getopt_value)(const char *, size_t, const struct my_option *,
|
||||
int *);
|
||||
|
||||
|
||||
extern char *disabled_my_option;
|
||||
extern my_bool my_getopt_print_errors;
|
||||
extern my_bool my_getopt_skip_unknown;
|
||||
extern my_error_reporter my_getopt_error_reporter;
|
||||
|
||||
extern int handle_options (int *argc, char ***argv,
|
||||
const struct my_option *longopts, my_get_one_option);
|
||||
extern int my_handle_options (int *argc, char ***argv,
|
||||
const struct my_option *longopts,
|
||||
my_get_one_option,
|
||||
const char **command_list, my_bool ignore_unknown_option);
|
||||
extern void print_cmdline_password_warning();
|
||||
extern void my_cleanup_options(const struct my_option *options);
|
||||
extern void my_cleanup_options(const struct my_option *options);
|
||||
extern void my_print_help(const struct my_option *options);
|
||||
extern void my_print_variables(const struct my_option *options);
|
||||
extern void my_print_variables_ex(const struct my_option *options, FILE* file);
|
||||
extern void my_getopt_register_get_addr(my_getopt_value);
|
||||
|
||||
ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp,
|
||||
my_bool *fix);
|
||||
longlong getopt_ll_limit_value(longlong, const struct my_option *,
|
||||
my_bool *fix);
|
||||
double getopt_double_limit_value(double num, const struct my_option *optp,
|
||||
my_bool *fix);
|
||||
my_bool getopt_compare_strings(const char *s, const char *t, uint length);
|
||||
ulonglong max_of_int_range(int var_type);
|
||||
|
||||
ulonglong getopt_double2ulonglong(double);
|
||||
double getopt_ulonglong2double(ulonglong);
|
||||
|
||||
C_MODE_END
|
||||
|
||||
#endif /* _my_getopt_h */
|
||||
|
||||
|
|
@ -1,781 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#ifndef MY_GLOBAL_INCLUDED
|
||||
#define MY_GLOBAL_INCLUDED
|
||||
|
||||
/*
|
||||
This include file should be included first in every header file.
|
||||
|
||||
This makes sure my_config.h is included to get platform specific
|
||||
symbols defined and it makes sure a lot of platform/compiler
|
||||
differences are mitigated.
|
||||
*/
|
||||
|
||||
#include "my_config.h"
|
||||
|
||||
#define __STDC_LIMIT_MACROS /* Enable C99 limit macros */
|
||||
#define __STDC_FORMAT_MACROS /* Enable C99 printf format macros */
|
||||
#define _USE_MATH_DEFINES /* Get access to M_PI, M_E, etc. in math.h */
|
||||
|
||||
#ifdef _WIN32
|
||||
/* Include common headers.*/
|
||||
# include <winsock2.h>
|
||||
# include <ws2tcpip.h> /* SOCKET */
|
||||
# include <io.h> /* access(), chmod() */
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
#include <float.h>
|
||||
#include <fcntl.h>
|
||||
#include <time.h>
|
||||
#include <errno.h> /* Recommended by debian */
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
#if !defined(_WIN32)
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
#ifdef MY_MSCRT_DEBUG
|
||||
#include <crtdbg.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
A lot of our programs uses asserts, so better to always include it
|
||||
This also fixes a problem when people uses DBUG_ASSERT without including
|
||||
assert.h
|
||||
*/
|
||||
#include <assert.h>
|
||||
|
||||
/* Include standard definitions of operator new and delete. */
|
||||
#ifdef __cplusplus
|
||||
# include <new>
|
||||
#endif
|
||||
|
||||
#include "my_compiler.h"
|
||||
|
||||
|
||||
/*
|
||||
InnoDB depends on some MySQL internals which other plugins should not
|
||||
need. This is because of InnoDB's foreign key support, "safe" binlog
|
||||
truncation, and other similar legacy features.
|
||||
|
||||
We define accessors for these internals unconditionally, but do not
|
||||
expose them in mysql/plugin.h. They are declared in ha_innodb.h for
|
||||
InnoDB's use.
|
||||
*/
|
||||
#define INNODB_COMPATIBILITY_HOOKS
|
||||
|
||||
/* Macros to make switching between C and C++ mode easier */
|
||||
#ifdef __cplusplus
|
||||
#define C_MODE_START extern "C" {
|
||||
#define C_MODE_END }
|
||||
#else
|
||||
#define C_MODE_START
|
||||
#define C_MODE_END
|
||||
#endif
|
||||
|
||||
#ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
|
||||
#define HAVE_PSI_INTERFACE
|
||||
#endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */
|
||||
|
||||
/* Make it easier to add conditional code in _expressions_ */
|
||||
#ifdef _WIN32
|
||||
#define IF_WIN(A,B) A
|
||||
#else
|
||||
#define IF_WIN(A,B) B
|
||||
#endif
|
||||
|
||||
#if defined (_WIN32)
|
||||
/*
|
||||
off_t is 32 bit long. We do not use C runtime functions
|
||||
with off_t but native Win32 file IO APIs, that work with
|
||||
64 bit offsets.
|
||||
*/
|
||||
#undef SIZEOF_OFF_T
|
||||
#define SIZEOF_OFF_T 8
|
||||
|
||||
static inline void sleep(unsigned long seconds)
|
||||
{
|
||||
Sleep(seconds * 1000);
|
||||
}
|
||||
|
||||
/* Define missing access() modes. */
|
||||
#define F_OK 0
|
||||
#define W_OK 2
|
||||
#define R_OK 4 /* Test for read permission. */
|
||||
|
||||
/* Define missing file locking constants. */
|
||||
#define F_RDLCK 1
|
||||
#define F_WRLCK 2
|
||||
#define F_UNLCK 3
|
||||
#define F_TO_EOF 0x3FFFFFFF
|
||||
|
||||
#define O_NONBLOCK 1 /* For emulation of fcntl() */
|
||||
|
||||
/*
|
||||
SHUT_RDWR is called SD_BOTH in windows and
|
||||
is defined to 2 in winsock2.h
|
||||
#define SD_BOTH 0x02
|
||||
*/
|
||||
#define SHUT_RDWR 0x02
|
||||
|
||||
/* Shared memory and named pipe connections are supported. */
|
||||
#define shared_memory_buffer_length 16000
|
||||
#define default_shared_memory_base_name "MYSQL"
|
||||
#endif /* _WIN32*/
|
||||
|
||||
/**
|
||||
Cast a member of a structure to the structure that contains it.
|
||||
|
||||
@param ptr Pointer to the member.
|
||||
@param type Type of the structure that contains the member.
|
||||
@param member Name of the member within the structure.
|
||||
*/
|
||||
#define my_container_of(ptr, type, member) \
|
||||
((type *)((char *)ptr - offsetof(type, member)))
|
||||
|
||||
/* an assert that works at compile-time. only for constant expression */
|
||||
#define compile_time_assert(X) \
|
||||
do \
|
||||
{ \
|
||||
typedef char compile_time_assert[(X) ? 1 : -1] MY_ATTRIBUTE((unused)); \
|
||||
} while(0)
|
||||
|
||||
#define QUOTE_ARG(x) #x /* Quote argument (before cpp) */
|
||||
#define STRINGIFY_ARG(x) QUOTE_ARG(x) /* Quote argument, after cpp */
|
||||
|
||||
#ifdef _WIN32
|
||||
#define SO_EXT ".dll"
|
||||
#elif defined(__APPLE__)
|
||||
#define SO_EXT ".dylib"
|
||||
#else
|
||||
#define SO_EXT ".so"
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_UINT)
|
||||
typedef unsigned int uint;
|
||||
typedef unsigned short ushort;
|
||||
#endif
|
||||
|
||||
#define swap_variables(t, a, b) { t dummy; dummy= a; a= b; b= dummy; }
|
||||
#define MY_TEST(a) ((a) ? 1 : 0)
|
||||
#define set_if_bigger(a,b) do { if ((a) < (b)) (a)=(b); } while(0)
|
||||
#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
|
||||
#define test_all_bits(a,b) (((a) & (b)) == (b))
|
||||
#define array_elements(A) ((uint) (sizeof(A)/sizeof(A[0])))
|
||||
|
||||
/* Define some general constants */
|
||||
#ifndef TRUE
|
||||
#define TRUE (1) /* Logical true */
|
||||
#define FALSE (0) /* Logical false */
|
||||
#endif
|
||||
|
||||
/* Some types that is different between systems */
|
||||
|
||||
typedef int File; /* File descriptor */
|
||||
#ifdef _WIN32
|
||||
typedef SOCKET my_socket;
|
||||
#else
|
||||
typedef int my_socket; /* File descriptor for sockets */
|
||||
#define INVALID_SOCKET -1
|
||||
#endif
|
||||
C_MODE_START
|
||||
typedef void (*sig_return)();/* Returns type from signal */
|
||||
C_MODE_END
|
||||
#if defined(__GNUC__)
|
||||
typedef char pchar; /* Mixed prototypes can take char */
|
||||
typedef char pbool; /* Mixed prototypes can take char */
|
||||
#else
|
||||
typedef int pchar; /* Mixed prototypes can't take char */
|
||||
typedef int pbool; /* Mixed prototypes can't take char */
|
||||
#endif
|
||||
C_MODE_START
|
||||
typedef int (*qsort_cmp)(const void *,const void *);
|
||||
typedef int (*qsort_cmp2)(const void*, const void *,const void *);
|
||||
C_MODE_END
|
||||
#ifdef _WIN32
|
||||
typedef int socket_len_t;
|
||||
typedef int sigset_t;
|
||||
typedef int mode_t;
|
||||
typedef SSIZE_T ssize_t;
|
||||
#else
|
||||
typedef socklen_t socket_len_t;
|
||||
#endif
|
||||
typedef socket_len_t SOCKET_SIZE_TYPE; /* Used by NDB */
|
||||
|
||||
/* file create flags */
|
||||
|
||||
#ifndef O_SHARE /* Probably not windows */
|
||||
#define O_SHARE 0 /* Flag to my_open for shared files */
|
||||
#ifndef O_BINARY
|
||||
#define O_BINARY 0 /* Flag to my_open for binary files */
|
||||
#endif
|
||||
#ifndef FILE_BINARY
|
||||
#define FILE_BINARY O_BINARY /* Flag to my_fopen for binary streams */
|
||||
#endif
|
||||
#ifdef HAVE_FCNTL
|
||||
#define HAVE_FCNTL_LOCK
|
||||
#define F_TO_EOF 0L /* Param to lockf() to lock rest of file */
|
||||
#endif
|
||||
#endif /* O_SHARE */
|
||||
|
||||
#ifndef O_TEMPORARY
|
||||
#define O_TEMPORARY 0
|
||||
#endif
|
||||
#ifndef O_SHORT_LIVED
|
||||
#define O_SHORT_LIVED 0
|
||||
#endif
|
||||
#ifndef O_NOFOLLOW
|
||||
#define O_NOFOLLOW 0
|
||||
#endif
|
||||
|
||||
/* additional file share flags for win32 */
|
||||
#ifdef _WIN32
|
||||
#define _SH_DENYRWD 0x110 /* deny read/write mode & delete */
|
||||
#define _SH_DENYWRD 0x120 /* deny write mode & delete */
|
||||
#define _SH_DENYRDD 0x130 /* deny read mode & delete */
|
||||
#define _SH_DENYDEL 0x140 /* deny delete only */
|
||||
#endif /* _WIN32 */
|
||||
|
||||
|
||||
/* General constants */
|
||||
#define FN_LEN 256 /* Max file name len */
|
||||
#define FN_HEADLEN 253 /* Max length of filepart of file name */
|
||||
#define FN_EXTLEN 20 /* Max length of extension (part of FN_LEN) */
|
||||
#define FN_REFLEN 512 /* Max length of full path-name */
|
||||
#define FN_REFLEN_SE 4000 /* Max length of full path-name in SE */
|
||||
#define FN_EXTCHAR '.'
|
||||
#define FN_HOMELIB '~' /* ~/ is used as abbrev for home dir */
|
||||
#define FN_CURLIB '.' /* ./ is used as abbrev for current dir */
|
||||
#define FN_PARENTDIR ".." /* Parent directory; Must be a string */
|
||||
|
||||
#ifdef _WIN32
|
||||
#define FN_LIBCHAR '\\'
|
||||
#define FN_LIBCHAR2 '/'
|
||||
#define FN_DIRSEP "/\\" /* Valid directory separators */
|
||||
#define FN_EXEEXT ".exe"
|
||||
#define FN_SOEXT ".dll"
|
||||
#define FN_ROOTDIR "\\"
|
||||
#define FN_DEVCHAR ':'
|
||||
#define FN_NETWORK_DRIVES /* Uses \\ to indicate network drives */
|
||||
#else
|
||||
#define FN_LIBCHAR '/'
|
||||
#define FN_LIBCHAR2 '/'
|
||||
#define FN_DIRSEP "/" /* Valid directory separators */
|
||||
#define FN_EXEEXT ""
|
||||
#define FN_SOEXT ".so"
|
||||
#define FN_ROOTDIR "/"
|
||||
#endif
|
||||
|
||||
/*
|
||||
MY_FILE_MIN is Windows speciality and is used to quickly detect
|
||||
the mismatch of CRT and mysys file IO usage on Windows at runtime.
|
||||
CRT file descriptors can be in the range 0-2047, whereas descriptors returned
|
||||
by my_open() will start with 2048. If a file descriptor with value less then
|
||||
MY_FILE_MIN is passed to mysys IO function, chances are it stemms from
|
||||
open()/fileno() and not my_open()/my_fileno.
|
||||
|
||||
For Posix, mysys functions are light wrappers around libc, and MY_FILE_MIN
|
||||
is logically 0.
|
||||
*/
|
||||
|
||||
#ifdef _WIN32
|
||||
#define MY_FILE_MIN 2048
|
||||
#else
|
||||
#define MY_FILE_MIN 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
MY_NFILE is the default size of my_file_info array.
|
||||
|
||||
It is larger on Windows, because it all file handles are stored in my_file_info
|
||||
Default size is 16384 and this should be enough for most cases.If it is not
|
||||
enough, --max-open-files with larger value can be used.
|
||||
|
||||
For Posix , my_file_info array is only used to store filenames for
|
||||
error reporting and its size is not a limitation for number of open files.
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
#define MY_NFILE (16384 + MY_FILE_MIN)
|
||||
#else
|
||||
#define MY_NFILE 64
|
||||
#endif
|
||||
|
||||
#define OS_FILE_LIMIT UINT_MAX
|
||||
|
||||
/*
|
||||
Io buffer size; Must be a power of 2 and a multiple of 512. May be
|
||||
smaller what the disk page size. This influences the speed of the
|
||||
isam btree library. eg to big to slow.
|
||||
*/
|
||||
#define IO_SIZE 4096
|
||||
/*
|
||||
How much overhead does malloc have. The code often allocates
|
||||
something like 1024-MALLOC_OVERHEAD bytes
|
||||
*/
|
||||
#define MALLOC_OVERHEAD 8
|
||||
|
||||
/* get memory in huncs */
|
||||
#define ONCE_ALLOC_INIT (uint) (4096-MALLOC_OVERHEAD)
|
||||
/* Typical record cash */
|
||||
#define RECORD_CACHE_SIZE (uint) (64*1024-MALLOC_OVERHEAD)
|
||||
/* Typical key cash */
|
||||
#define KEY_CACHE_SIZE (uint) (8*1024*1024)
|
||||
/* Default size of a key cache block */
|
||||
#define KEY_CACHE_BLOCK_SIZE (uint) 1024
|
||||
|
||||
|
||||
/* Some defines of functions for portability */
|
||||
|
||||
#if (_WIN32)
|
||||
#if !defined(_WIN64)
|
||||
inline double my_ulonglong2double(unsigned long long value)
|
||||
{
|
||||
long long nr=(long long) value;
|
||||
if (nr >= 0)
|
||||
return (double) nr;
|
||||
return (18446744073709551616.0 + (double) nr);
|
||||
}
|
||||
#define ulonglong2double my_ulonglong2double
|
||||
#define my_off_t2double my_ulonglong2double
|
||||
#endif /* _WIN64 */
|
||||
inline unsigned long long my_double2ulonglong(double d)
|
||||
{
|
||||
double t= d - (double) 0x8000000000000000ULL;
|
||||
|
||||
if (t >= 0)
|
||||
return ((unsigned long long) t) + 0x8000000000000000ULL;
|
||||
return (unsigned long long) d;
|
||||
}
|
||||
#define double2ulonglong my_double2ulonglong
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#ifndef ulonglong2double
|
||||
#define ulonglong2double(A) ((double) (ulonglong) (A))
|
||||
#define my_off_t2double(A) ((double) (my_off_t) (A))
|
||||
#endif
|
||||
#ifndef double2ulonglong
|
||||
#define double2ulonglong(A) ((ulonglong) (double) (A))
|
||||
#endif
|
||||
|
||||
#define INT_MIN64 (~0x7FFFFFFFFFFFFFFFLL)
|
||||
#define INT_MAX64 0x7FFFFFFFFFFFFFFFLL
|
||||
#define INT_MIN32 (~0x7FFFFFFFL)
|
||||
#define INT_MAX32 0x7FFFFFFFL
|
||||
#define UINT_MAX32 0xFFFFFFFFL
|
||||
#define INT_MIN24 (~0x007FFFFF)
|
||||
#define INT_MAX24 0x007FFFFF
|
||||
#define UINT_MAX24 0x00FFFFFF
|
||||
#define INT_MIN16 (~0x7FFF)
|
||||
#define INT_MAX16 0x7FFF
|
||||
#define UINT_MAX16 0xFFFF
|
||||
#define INT_MIN8 (~0x7F)
|
||||
#define INT_MAX8 0x7F
|
||||
#define UINT_MAX8 0xFF
|
||||
|
||||
#ifndef SIZE_T_MAX
|
||||
#define SIZE_T_MAX (~((size_t) 0))
|
||||
#endif
|
||||
|
||||
// Our ifdef trickery for my_isfinite does not work with gcc/solaris unless we:
|
||||
#ifdef HAVE_IEEEFP_H
|
||||
#include <ieeefp.h>
|
||||
#endif
|
||||
|
||||
#if (__cplusplus >= 201103L)
|
||||
/* For C++11 use the new std functions rather than C99 macros. */
|
||||
#include <cmath>
|
||||
#define my_isfinite(X) std::isfinite(X)
|
||||
#define my_isnan(X) std::isnan(X)
|
||||
#define my_isinf(X) std::isinf(X)
|
||||
#else
|
||||
#ifdef HAVE_LLVM_LIBCPP /* finite is deprecated in libc++ */
|
||||
#define my_isfinite(X) isfinite(X)
|
||||
#elif defined _WIN32
|
||||
#define my_isfinite(X) _finite(X)
|
||||
#else
|
||||
#define my_isfinite(X) finite(X)
|
||||
#endif
|
||||
#define my_isnan(X) isnan(X)
|
||||
#ifdef HAVE_ISINF
|
||||
/* System-provided isinf() is available and safe to use */
|
||||
#define my_isinf(X) isinf(X)
|
||||
#else /* !HAVE_ISINF */
|
||||
#define my_isinf(X) (!my_isfinite(X) && !my_isnan(X))
|
||||
#endif
|
||||
#endif /* __cplusplus >= 201103L */
|
||||
|
||||
/*
|
||||
Max size that must be added to a so that we know Size to make
|
||||
adressable obj.
|
||||
*/
|
||||
#if SIZEOF_CHARP == 4
|
||||
typedef long my_ptrdiff_t;
|
||||
#else
|
||||
typedef long long my_ptrdiff_t;
|
||||
#endif
|
||||
|
||||
#define MY_ALIGN(A,L) (((A) + (L) - 1) & ~((L) - 1))
|
||||
#define ALIGN_SIZE(A) MY_ALIGN((A),sizeof(double))
|
||||
/* Size to make adressable obj. */
|
||||
#define ADD_TO_PTR(ptr,size,type) (type) ((uchar*) (ptr)+size)
|
||||
#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((uchar*) (A) - (uchar*) (B))
|
||||
|
||||
/*
|
||||
Custom version of standard offsetof() macro which can be used to get
|
||||
offsets of members in class for non-POD types (according to the current
|
||||
version of C++ standard offsetof() macro can't be used in such cases and
|
||||
attempt to do so causes warnings to be emitted, OTOH in many cases it is
|
||||
still OK to assume that all instances of the class has the same offsets
|
||||
for the same members).
|
||||
|
||||
This is temporary solution which should be removed once File_parser class
|
||||
and related routines are refactored.
|
||||
*/
|
||||
|
||||
#define my_offsetof(TYPE, MEMBER) \
|
||||
((size_t)((char *)&(((TYPE *)0x10)->MEMBER) - (char*)0x10))
|
||||
|
||||
#define NullS (char *) 0
|
||||
|
||||
#ifdef _WIN32
|
||||
#define STDCALL __stdcall
|
||||
#else
|
||||
#define STDCALL
|
||||
#endif
|
||||
|
||||
/* Typdefs for easyier portability */
|
||||
|
||||
typedef unsigned char uchar; /* Short for unsigned char */
|
||||
typedef signed char int8; /* Signed integer >= 8 bits */
|
||||
typedef unsigned char uint8; /* Unsigned integer >= 8 bits */
|
||||
typedef short int16;
|
||||
typedef unsigned short uint16;
|
||||
#if SIZEOF_INT == 4
|
||||
typedef int int32;
|
||||
typedef unsigned int uint32;
|
||||
#elif SIZEOF_LONG == 4
|
||||
typedef long int32;
|
||||
typedef unsigned long uint32;
|
||||
#else
|
||||
#error Neither int or long is of 4 bytes width
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_ULONG)
|
||||
typedef unsigned long ulong; /* Short for unsigned long */
|
||||
#endif
|
||||
/*
|
||||
Using [unsigned] long long is preferable as [u]longlong because we use
|
||||
[unsigned] long long unconditionally in many places,
|
||||
for example in constants with [U]LL suffix.
|
||||
*/
|
||||
typedef unsigned long long int ulonglong; /* ulong or unsigned long long */
|
||||
typedef long long int longlong;
|
||||
typedef longlong int64;
|
||||
typedef ulonglong uint64;
|
||||
|
||||
#if defined (_WIN32)
|
||||
typedef unsigned __int64 my_ulonglong;
|
||||
#else
|
||||
typedef unsigned long long my_ulonglong;
|
||||
#endif
|
||||
|
||||
#if SIZEOF_CHARP == SIZEOF_INT
|
||||
typedef int intptr;
|
||||
#elif SIZEOF_CHARP == SIZEOF_LONG
|
||||
typedef long intptr;
|
||||
#elif SIZEOF_CHARP == SIZEOF_LONG_LONG
|
||||
typedef long long intptr;
|
||||
#else
|
||||
#error sizeof(void *) is neither sizeof(int) nor sizeof(long) nor sizeof(long long)
|
||||
#endif
|
||||
|
||||
#define MY_ERRPTR ((void*)(intptr)1)
|
||||
|
||||
#if defined(_WIN32)
|
||||
typedef unsigned long long my_off_t;
|
||||
typedef unsigned long long os_off_t;
|
||||
#else
|
||||
typedef off_t os_off_t;
|
||||
#if SIZEOF_OFF_T > 4
|
||||
typedef ulonglong my_off_t;
|
||||
#else
|
||||
typedef unsigned long my_off_t;
|
||||
#endif
|
||||
#endif /*_WIN32*/
|
||||
#define MY_FILEPOS_ERROR (~(my_off_t) 0)
|
||||
|
||||
/*
|
||||
TODO Convert these to use Bitmap class.
|
||||
*/
|
||||
typedef ulonglong table_map; /* Used for table bits in join */
|
||||
typedef ulonglong nesting_map; /* Used for flags of nesting constructs */
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define socket_errno WSAGetLastError()
|
||||
#define SOCKET_EINTR WSAEINTR
|
||||
#define SOCKET_EAGAIN WSAEINPROGRESS
|
||||
#define SOCKET_EWOULDBLOCK WSAEWOULDBLOCK
|
||||
#define SOCKET_EADDRINUSE WSAEADDRINUSE
|
||||
#define SOCKET_ETIMEDOUT WSAETIMEDOUT
|
||||
#define SOCKET_ECONNRESET WSAECONNRESET
|
||||
#define SOCKET_ENFILE ENFILE
|
||||
#define SOCKET_EMFILE EMFILE
|
||||
#else /* Unix */
|
||||
#define socket_errno errno
|
||||
#define closesocket(A) close(A)
|
||||
#define SOCKET_EINTR EINTR
|
||||
#define SOCKET_EAGAIN EAGAIN
|
||||
#define SOCKET_EWOULDBLOCK EWOULDBLOCK
|
||||
#define SOCKET_EADDRINUSE EADDRINUSE
|
||||
#define SOCKET_ETIMEDOUT ETIMEDOUT
|
||||
#define SOCKET_ECONNRESET ECONNRESET
|
||||
#define SOCKET_ENFILE ENFILE
|
||||
#define SOCKET_EMFILE EMFILE
|
||||
#endif
|
||||
|
||||
typedef int myf; /* Type of MyFlags in my_funcs */
|
||||
typedef char my_bool; /* Small bool */
|
||||
|
||||
/* Macros for converting *constants* to the right type */
|
||||
#define MYF(v) (myf) (v)
|
||||
|
||||
/* Some helper macros */
|
||||
#define YESNO(X) ((X) ? "yes" : "no")
|
||||
|
||||
#define MY_HOW_OFTEN_TO_WRITE 1000 /* How often we want info on screen */
|
||||
|
||||
#include <my_byteorder.h>
|
||||
|
||||
#ifdef HAVE_CHARSET_utf8
|
||||
#define MYSQL_UNIVERSAL_CLIENT_CHARSET "utf8"
|
||||
#else
|
||||
#define MYSQL_UNIVERSAL_CLIENT_CHARSET MYSQL_DEFAULT_CHARSET_NAME
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define dlsym(lib, name) (void*)GetProcAddress((HMODULE)lib, name)
|
||||
#define dlopen(libname, unused) LoadLibraryEx(libname, NULL, 0)
|
||||
#define dlclose(lib) FreeLibrary((HMODULE)lib)
|
||||
#ifndef HAVE_DLOPEN
|
||||
#define HAVE_DLOPEN
|
||||
#endif
|
||||
#define DLERROR_GENERATE(errmsg, error_number) \
|
||||
char win_errormsg[2048]; \
|
||||
if(FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, \
|
||||
0, error_number, 0, win_errormsg, 2048, NULL)) \
|
||||
{ \
|
||||
char *ptr; \
|
||||
for (ptr= &win_errormsg[0] + strlen(win_errormsg) - 1; \
|
||||
ptr >= &win_errormsg[0] && strchr("\r\n\t\0x20", *ptr); \
|
||||
ptr--) \
|
||||
*ptr= 0; \
|
||||
errmsg= win_errormsg; \
|
||||
} \
|
||||
else \
|
||||
errmsg= ""
|
||||
#define dlerror() ""
|
||||
#define dlopen_errno GetLastError()
|
||||
|
||||
#else /* _WIN32 */
|
||||
#define DLERROR_GENERATE(errmsg, error_number) errmsg= dlerror()
|
||||
#define dlopen_errno errno
|
||||
#endif /* _WIN32 */
|
||||
|
||||
/* Length of decimal number represented by INT32. */
|
||||
#define MY_INT32_NUM_DECIMAL_DIGITS 11U
|
||||
|
||||
/* Length of decimal number represented by INT64. */
|
||||
#define MY_INT64_NUM_DECIMAL_DIGITS 21U
|
||||
|
||||
/* Define some useful general macros (should be done after all headers). */
|
||||
#define MY_MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#define MY_MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
|
||||
#if !defined(__cplusplus) && !defined(bool)
|
||||
#define bool In_C_you_should_use_my_bool_instead()
|
||||
#endif
|
||||
|
||||
/*
|
||||
MYSQL_PLUGIN_IMPORT macro is used to export mysqld data
|
||||
(i.e variables) for usage in storage engine loadable plugins.
|
||||
Outside of Windows, it is dummy.
|
||||
*/
|
||||
#if (defined(_WIN32) && defined(MYSQL_DYNAMIC_PLUGIN))
|
||||
#define MYSQL_PLUGIN_IMPORT __declspec(dllimport)
|
||||
#else
|
||||
#define MYSQL_PLUGIN_IMPORT
|
||||
#endif
|
||||
|
||||
#include <my_dbug.h>
|
||||
|
||||
#ifdef EMBEDDED_LIBRARY
|
||||
#define NO_EMBEDDED_ACCESS_CHECKS
|
||||
/* Things we don't need in the embedded version of MySQL */
|
||||
#undef HAVE_OPENSSL
|
||||
#endif /* EMBEDDED_LIBRARY */
|
||||
|
||||
|
||||
enum loglevel {
|
||||
ERROR_LEVEL= 0,
|
||||
WARNING_LEVEL= 1,
|
||||
INFORMATION_LEVEL= 2
|
||||
};
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
/****************************************************************************
|
||||
** Replacements for localtime_r and gmtime_r
|
||||
****************************************************************************/
|
||||
|
||||
static inline struct tm *localtime_r(const time_t *timep, struct tm *tmp)
|
||||
{
|
||||
localtime_s(tmp, timep);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
static inline struct tm *gmtime_r(const time_t *clock, struct tm *res)
|
||||
{
|
||||
gmtime_s(res, clock);
|
||||
return res;
|
||||
}
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#ifndef HAVE_STRUCT_TIMESPEC /* Windows before VS2015 */
|
||||
/*
|
||||
Declare a union to make sure FILETIME is properly aligned
|
||||
so it can be used directly as a 64 bit value. The value
|
||||
stored is in 100ns units.
|
||||
*/
|
||||
union ft64 {
|
||||
FILETIME ft;
|
||||
__int64 i64;
|
||||
};
|
||||
|
||||
struct timespec {
|
||||
union ft64 tv;
|
||||
/* The max timeout value in millisecond for native_cond_timedwait */
|
||||
long max_timeout_msec;
|
||||
};
|
||||
|
||||
#endif /* !HAVE_STRUCT_TIMESPEC */
|
||||
|
||||
C_MODE_START
|
||||
extern ulonglong my_getsystime(void);
|
||||
C_MODE_END
|
||||
|
||||
static inline void set_timespec_nsec(struct timespec *abstime, ulonglong nsec)
|
||||
{
|
||||
#ifdef HAVE_STRUCT_TIMESPEC
|
||||
ulonglong now= my_getsystime() + (nsec / 100);
|
||||
ulonglong tv_sec= now / 10000000ULL;
|
||||
#if SIZEOF_TIME_T < SIZEOF_LONG_LONG
|
||||
/* Ensure that the number of seconds don't overflow. */
|
||||
tv_sec= MY_MIN(tv_sec, ((ulonglong)INT_MAX32));
|
||||
#endif
|
||||
abstime->tv_sec= (time_t)tv_sec;
|
||||
abstime->tv_nsec= (now % 10000000ULL) * 100 + (nsec % 100);
|
||||
#else /* !HAVE_STRUCT_TIMESPEC */
|
||||
ulonglong max_timeout_msec= (nsec / 1000000);
|
||||
union ft64 tv;
|
||||
GetSystemTimeAsFileTime(&tv.ft);
|
||||
abstime->tv.i64= tv.i64 + (__int64)(nsec / 100);
|
||||
#if SIZEOF_LONG < SIZEOF_LONG_LONG
|
||||
/* Ensure that the msec value doesn't overflow. */
|
||||
max_timeout_msec= MY_MIN(max_timeout_msec, ((ulonglong)INT_MAX32));
|
||||
#endif
|
||||
abstime->max_timeout_msec= (long)max_timeout_msec;
|
||||
#endif /* !HAVE_STRUCT_TIMESPEC */
|
||||
}
|
||||
|
||||
static inline void set_timespec(struct timespec *abstime, ulonglong sec)
|
||||
{
|
||||
set_timespec_nsec(abstime, sec * 1000000000ULL);
|
||||
}
|
||||
|
||||
/**
|
||||
Compare two timespec structs.
|
||||
|
||||
@retval 1 If ts1 ends after ts2.
|
||||
@retval -1 If ts1 ends before ts2.
|
||||
@retval 0 If ts1 is equal to ts2.
|
||||
*/
|
||||
static inline int cmp_timespec(struct timespec *ts1, struct timespec *ts2)
|
||||
{
|
||||
#ifdef HAVE_STRUCT_TIMESPEC
|
||||
if (ts1->tv_sec > ts2->tv_sec ||
|
||||
(ts1->tv_sec == ts2->tv_sec && ts1->tv_nsec > ts2->tv_nsec))
|
||||
return 1;
|
||||
if (ts1->tv_sec < ts2->tv_sec ||
|
||||
(ts1->tv_sec == ts2->tv_sec && ts1->tv_nsec < ts2->tv_nsec))
|
||||
return -1;
|
||||
#else
|
||||
if (ts1->tv.i64 > ts2->tv.i64)
|
||||
return 1;
|
||||
if (ts1->tv.i64 < ts2->tv.i64)
|
||||
return -1;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline ulonglong diff_timespec(struct timespec *ts1, struct timespec *ts2)
|
||||
{
|
||||
#ifdef HAVE_STRUCT_TIMESPEC
|
||||
return (ts1->tv_sec - ts2->tv_sec) * 1000000000ULL +
|
||||
ts1->tv_nsec - ts2->tv_nsec;
|
||||
#else
|
||||
return (ts1->tv.i64 - ts2->tv.i64) * 100;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
typedef int MY_MODE;
|
||||
#else
|
||||
typedef mode_t MY_MODE;
|
||||
#endif /* _WIN32 */
|
||||
|
||||
/* File permissions */
|
||||
#define USER_READ (1L << 0)
|
||||
#define USER_WRITE (1L << 1)
|
||||
#define USER_EXECUTE (1L << 2)
|
||||
#define GROUP_READ (1L << 3)
|
||||
#define GROUP_WRITE (1L << 4)
|
||||
#define GROUP_EXECUTE (1L << 5)
|
||||
#define OTHERS_READ (1L << 6)
|
||||
#define OTHERS_WRITE (1L << 7)
|
||||
#define OTHERS_EXECUTE (1L << 8)
|
||||
#define USER_RWX USER_READ | USER_WRITE | USER_EXECUTE
|
||||
#define GROUP_RWX GROUP_READ | GROUP_WRITE | GROUP_EXECUTE
|
||||
#define OTHERS_RWX OTHERS_READ | OTHERS_WRITE | OTHERS_EXECUTE
|
||||
|
||||
/* Defaults */
|
||||
#define DEFAULT_SSL_CA_CERT "ca.pem"
|
||||
#define DEFAULT_SSL_CA_KEY "ca-key.pem"
|
||||
#define DEFAULT_SSL_SERVER_CERT "server-cert.pem"
|
||||
#define DEFAULT_SSL_SERVER_KEY "server-key.pem"
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#define strcasecmp _stricmp
|
||||
#endif
|
||||
#endif // MY_GLOBAL_INCLUDED
|
||||
|
|
@ -1,45 +1,53 @@
|
|||
/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
/* Copyright (c) 2000, 2026, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
This program is designed to work with certain software (including
|
||||
but not limited to OpenSSL) that is licensed under separate terms,
|
||||
as designated in a particular file or component or in included license
|
||||
documentation. The authors of MySQL hereby grant you an additional
|
||||
permission to link the program and your derivative works with the
|
||||
separately licensed software that they have either included with
|
||||
the program or referenced in the documentation.
|
||||
|
||||
Without limiting anything contained in the foregoing, this file,
|
||||
which is part of C Driver for MySQL (Connector/C), is also subject to the
|
||||
Universal FOSS Exception, version 1.0, a copy of which can be found at
|
||||
http://oss.oracle.com/licenses/universal-foss-exception.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU General Public License, version 2.0, for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#ifndef _list_h_
|
||||
#define _list_h_
|
||||
#ifndef MY_LIST_INCLUDED
|
||||
#define MY_LIST_INCLUDED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/**
|
||||
@file include/my_list.h
|
||||
*/
|
||||
|
||||
typedef struct st_list {
|
||||
struct st_list *prev,*next;
|
||||
typedef struct LIST {
|
||||
struct LIST *prev, *next;
|
||||
void *data;
|
||||
} LIST;
|
||||
|
||||
typedef int (*list_walk_action)(void *,void *);
|
||||
typedef int (*list_walk_action)(void *, void *);
|
||||
|
||||
extern LIST *list_add(LIST *root,LIST *element);
|
||||
extern LIST *list_delete(LIST *root,LIST *element);
|
||||
extern LIST *list_cons(void *data,LIST *root);
|
||||
extern LIST *list_add(LIST *root, LIST *element);
|
||||
extern LIST *list_delete(LIST *root, LIST *element);
|
||||
extern LIST *list_cons(void *data, LIST *root);
|
||||
extern LIST *list_reverse(LIST *root);
|
||||
extern void list_free(LIST *root,unsigned int free_data);
|
||||
extern void list_free(LIST *root, unsigned int free_data);
|
||||
extern unsigned int list_length(LIST *);
|
||||
extern int list_walk(LIST *,list_walk_action action,unsigned char * argument);
|
||||
extern int list_walk(LIST *, list_walk_action action, unsigned char *argument);
|
||||
|
||||
#define list_rest(a) ((a)->next)
|
||||
#define list_push(a,b) (a)=list_cons((b),(a))
|
||||
#define list_pop(A) {LIST *old=(A); (A)=list_delete(old,old); my_free(old); }
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif // MY_LIST_INCLUDED
|
||||
|
|
|
|||
|
|
@ -1,960 +0,0 @@
|
|||
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#ifndef _my_sys_h
|
||||
#define _my_sys_h
|
||||
|
||||
#include "my_global.h" /* C_MODE_START, C_MODE_END */
|
||||
#include "m_ctype.h" /* for CHARSET_INFO */
|
||||
|
||||
#include "my_thread.h" /* Needed for psi.h */
|
||||
#include "mysql/psi/psi.h"
|
||||
#include "mysql/service_mysql_alloc.h"
|
||||
#include "mysql/psi/mysql_memory.h"
|
||||
#include "mysql/psi/mysql_thread.h"
|
||||
|
||||
#ifdef HAVE_ALLOCA_H
|
||||
#include <alloca.h>
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
C_MODE_START
|
||||
|
||||
#ifdef HAVE_VALGRIND
|
||||
# include <valgrind/valgrind.h>
|
||||
# define MEM_MALLOCLIKE_BLOCK(p1, p2, p3, p4) VALGRIND_MALLOCLIKE_BLOCK(p1, p2, p3, p4)
|
||||
# define MEM_FREELIKE_BLOCK(p1, p2) VALGRIND_FREELIKE_BLOCK(p1, p2)
|
||||
# include <valgrind/memcheck.h>
|
||||
# define MEM_UNDEFINED(a,len) VALGRIND_MAKE_MEM_UNDEFINED(a,len)
|
||||
# define MEM_NOACCESS(a,len) VALGRIND_MAKE_MEM_NOACCESS(a,len)
|
||||
# define MEM_CHECK_ADDRESSABLE(a,len) VALGRIND_CHECK_MEM_IS_ADDRESSABLE(a,len)
|
||||
#else /* HAVE_VALGRIND */
|
||||
# define MEM_MALLOCLIKE_BLOCK(p1, p2, p3, p4) do {} while (0)
|
||||
# define MEM_FREELIKE_BLOCK(p1, p2) do {} while (0)
|
||||
# define MEM_UNDEFINED(a,len) ((void) 0)
|
||||
# define MEM_NOACCESS(a,len) ((void) 0)
|
||||
# define MEM_CHECK_ADDRESSABLE(a,len) ((void) 0)
|
||||
#endif /* HAVE_VALGRIND */
|
||||
|
||||
#include <typelib.h>
|
||||
|
||||
#define MY_INIT(name) { my_progname= name; my_init(); }
|
||||
|
||||
/**
|
||||
Max length of an error message generated by mysys utilities.
|
||||
Some mysys functions produce error messages. These mostly go
|
||||
to stderr.
|
||||
This constant defines the size of the buffer used to format
|
||||
the message. It should be kept in sync with MYSQL_ERRMSG_SIZE,
|
||||
since sometimes mysys errors are stored in the server diagnostics
|
||||
area, and we would like to avoid unexpected truncation.
|
||||
*/
|
||||
#define MYSYS_ERRMSG_SIZE (512)
|
||||
#define MYSYS_STRERROR_SIZE (128)
|
||||
|
||||
#define MY_FILE_ERROR ((size_t) -1)
|
||||
|
||||
/* General bitmaps for my_func's */
|
||||
#define MY_FFNF 1 /* Fatal if file not found */
|
||||
#define MY_FNABP 2 /* Fatal if not all bytes read/writen */
|
||||
#define MY_NABP 4 /* Error if not all bytes read/writen */
|
||||
#define MY_FAE 8 /* Fatal if any error */
|
||||
#define MY_WME 16 /* Write message on error */
|
||||
#define MY_WAIT_IF_FULL 32 /* Wait and try again if disk full error */
|
||||
#define MY_IGNORE_BADFD 32 /* my_sync: ignore 'bad descriptor' errors */
|
||||
#define MY_SYNC_DIR 8192 /* my_create/delete/rename: sync directory */
|
||||
#define MY_UNUSED 64 /* Unused (was support for RAID) */
|
||||
#define MY_FULL_IO 512 /* For my_read - loop intil I/O is complete */
|
||||
#define MY_DONT_CHECK_FILESIZE 128 /* Option to init_io_cache() */
|
||||
#define MY_LINK_WARNING 32 /* my_redel() gives warning if links */
|
||||
#define MY_COPYTIME 64 /* my_redel() copys time */
|
||||
#define MY_DELETE_OLD 256 /* my_create_with_symlink() */
|
||||
#define MY_RESOLVE_LINK 128 /* my_realpath(); Only resolve links */
|
||||
#define MY_HOLD_ORIGINAL_MODES 128 /* my_copy() holds to file modes */
|
||||
#define MY_REDEL_MAKE_BACKUP 256
|
||||
#define MY_REDEL_NO_COPY_STAT 512 /* my_redel() doesn't call my_copystat() */
|
||||
#define MY_SEEK_NOT_DONE 32 /* my_lock may have to do a seek */
|
||||
#define MY_DONT_WAIT 64 /* my_lock() don't wait if can't lock */
|
||||
#define MY_ZEROFILL 32 /* my_malloc(), fill array with zero */
|
||||
#define MY_ALLOW_ZERO_PTR 64 /* my_realloc() ; zero ptr -> malloc */
|
||||
#define MY_FREE_ON_ERROR 128 /* my_realloc() ; Free old ptr on error */
|
||||
#define MY_HOLD_ON_ERROR 256 /* my_realloc() ; Return old ptr on error */
|
||||
#define MY_DONT_OVERWRITE_FILE 1024 /* my_copy: Don't overwrite file */
|
||||
#define MY_THREADSAFE 2048 /* my_seek(): lock fd mutex */
|
||||
#define MY_SYNC 4096 /* my_copy(): sync dst file */
|
||||
|
||||
#define MYF_RW MYF(MY_WME+MY_NABP) /* For my_read & my_write */
|
||||
|
||||
#define MY_CHECK_ERROR 1 /* Params to my_end; Check open-close */
|
||||
#define MY_GIVE_INFO 2 /* Give time info about process*/
|
||||
#define MY_DONT_FREE_DBUG 4 /* Do not call DBUG_END() in my_end() */
|
||||
|
||||
/* Flags for my_error() */
|
||||
#define ME_BELL 4 /* DEPRECATED: Ring bell then printing message */
|
||||
#define ME_ERRORLOG 64 /* Write the error message to error log */
|
||||
#define ME_FATALERROR 1024 /* Fatal statement error */
|
||||
|
||||
/* Bits in last argument to fn_format */
|
||||
#define MY_REPLACE_DIR 1 /* replace dir in name with 'dir' */
|
||||
#define MY_REPLACE_EXT 2 /* replace extension with 'ext' */
|
||||
#define MY_UNPACK_FILENAME 4 /* Unpack name (~ -> home) */
|
||||
#define MY_PACK_FILENAME 8 /* Pack name (home -> ~) */
|
||||
#define MY_RESOLVE_SYMLINKS 16 /* Resolve all symbolic links */
|
||||
#define MY_RETURN_REAL_PATH 32 /* return full path for file */
|
||||
#define MY_SAFE_PATH 64 /* Return NULL if too long path */
|
||||
#define MY_RELATIVE_PATH 128 /* name is relative to 'dir' */
|
||||
#define MY_APPEND_EXT 256 /* add 'ext' as additional extension*/
|
||||
|
||||
|
||||
/* My seek flags */
|
||||
#define MY_SEEK_SET 0
|
||||
#define MY_SEEK_CUR 1
|
||||
#define MY_SEEK_END 2
|
||||
|
||||
/* Some constants */
|
||||
#define MY_WAIT_FOR_USER_TO_FIX_PANIC 60 /* in seconds */
|
||||
#define MY_WAIT_GIVE_USER_A_MESSAGE 10 /* Every 10 times of prev */
|
||||
#define MIN_COMPRESS_LENGTH 50 /* Don't compress small bl. */
|
||||
#define DFLT_INIT_HITS 3
|
||||
|
||||
/* root_alloc flags */
|
||||
#define MY_KEEP_PREALLOC 1
|
||||
#define MY_MARK_BLOCKS_FREE 2 /* move used to free list and reuse them */
|
||||
|
||||
/* Internal error numbers (for assembler functions) */
|
||||
#define MY_ERRNO_EDOM 33
|
||||
#define MY_ERRNO_ERANGE 34
|
||||
|
||||
/* Bits for get_date timeflag */
|
||||
#define GETDATE_DATE_TIME 1
|
||||
#define GETDATE_SHORT_DATE 2
|
||||
#define GETDATE_HHMMSSTIME 4
|
||||
#define GETDATE_GMT 8
|
||||
#define GETDATE_FIXEDLENGTH 16
|
||||
|
||||
/* defines when allocating data */
|
||||
extern void *my_multi_malloc(PSI_memory_key key, myf flags, ...);
|
||||
|
||||
/*
|
||||
Switch to my_malloc() if the memory block to be allocated is bigger than
|
||||
max_alloca_sz.
|
||||
*/
|
||||
extern PSI_memory_key key_memory_max_alloca;
|
||||
#define my_safe_alloca(size, max_alloca_sz) ((size <= max_alloca_sz) ? \
|
||||
my_alloca(size) : \
|
||||
my_malloc(key_memory_max_alloca, size, MYF(0)))
|
||||
#define my_safe_afree(ptr, size, max_alloca_sz) if (size > max_alloca_sz) \
|
||||
my_free(ptr)
|
||||
|
||||
#if !defined(DBUG_OFF) || defined(HAVE_VALGRIND)
|
||||
/**
|
||||
Put bad content in memory to be sure it will segfault if dereferenced.
|
||||
With Valgrind, verify that memory is addressable, and mark it undefined.
|
||||
We cache value of B because if B is expression which depends on A, memset()
|
||||
trashes value of B.
|
||||
*/
|
||||
#define TRASH(A,B) do { \
|
||||
const size_t l= (B); \
|
||||
MEM_CHECK_ADDRESSABLE(A, l); \
|
||||
memset(A, 0x8F, l); \
|
||||
MEM_UNDEFINED(A, l); \
|
||||
} while (0)
|
||||
#else
|
||||
#define TRASH(A,B) do {} while(0)
|
||||
#endif
|
||||
#if defined(ENABLED_DEBUG_SYNC)
|
||||
extern void (*debug_sync_C_callback_ptr)(const char *, size_t);
|
||||
#define DEBUG_SYNC_C(_sync_point_name_) do { \
|
||||
if (debug_sync_C_callback_ptr != NULL) \
|
||||
(*debug_sync_C_callback_ptr)(STRING_WITH_LEN(_sync_point_name_)); } \
|
||||
while(0)
|
||||
#define DEBUG_SYNC_C_IF_THD(thd, _sync_point_name_) do { \
|
||||
if (debug_sync_C_callback_ptr != NULL && thd) \
|
||||
(*debug_sync_C_callback_ptr)(STRING_WITH_LEN(_sync_point_name_)); } \
|
||||
while(0)
|
||||
#else
|
||||
#define DEBUG_SYNC_C(_sync_point_name_)
|
||||
#define DEBUG_SYNC_C_IF_THD(thd, _sync_point_name_)
|
||||
#endif /* defined(ENABLED_DEBUG_SYNC) */
|
||||
|
||||
#ifdef HAVE_LINUX_LARGE_PAGES
|
||||
extern uint my_get_large_page_size(void);
|
||||
extern uchar * my_large_malloc(PSI_memory_key key, size_t size, myf my_flags);
|
||||
extern void my_large_free(uchar *ptr);
|
||||
extern my_bool my_use_large_pages;
|
||||
extern uint my_large_page_size;
|
||||
#else
|
||||
#define my_get_large_page_size() (0)
|
||||
#define my_large_malloc(A,B,C) my_malloc((A),(B),(C))
|
||||
#define my_large_free(A) my_free((A))
|
||||
#endif /* HAVE_LINUX_LARGE_PAGES */
|
||||
|
||||
#define my_alloca(SZ) alloca((size_t) (SZ))
|
||||
|
||||
#include <errno.h> /* errno is a define */
|
||||
|
||||
extern char *home_dir; /* Home directory for user */
|
||||
extern const char *my_progname; /* program-name (printed in errors) */
|
||||
extern char curr_dir[]; /* Current directory for user */
|
||||
extern void (*error_handler_hook)(uint my_err, const char *str,myf MyFlags);
|
||||
extern void (*fatal_error_handler_hook)(uint my_err, const char *str,
|
||||
myf MyFlags);
|
||||
extern void (*local_message_hook)(enum loglevel ll,
|
||||
const char *format, va_list args);
|
||||
extern uint my_file_limit;
|
||||
extern MYSQL_PLUGIN_IMPORT ulong my_thread_stack_size;
|
||||
|
||||
/*
|
||||
Hooks for reporting execution stage information. The server implementation
|
||||
of these will also set THD::current_cond/current_mutex.
|
||||
By having hooks, we avoid direct dependencies on server code.
|
||||
*/
|
||||
extern void (*enter_cond_hook)(void *opaque_thd,
|
||||
mysql_cond_t *cond,
|
||||
mysql_mutex_t *mutex,
|
||||
const PSI_stage_info *stage,
|
||||
PSI_stage_info *old_stage,
|
||||
const char *src_function,
|
||||
const char *src_file,
|
||||
int src_line);
|
||||
|
||||
extern void (*exit_cond_hook)(void *opaque_thd,
|
||||
const PSI_stage_info *stage,
|
||||
const char *src_function,
|
||||
const char *src_file,
|
||||
int src_line);
|
||||
|
||||
/*
|
||||
Hook for checking if the thread has been killed.
|
||||
*/
|
||||
extern int (*is_killed_hook)(const void *opaque_thd);
|
||||
|
||||
/* charsets */
|
||||
#define MY_ALL_CHARSETS_SIZE 2048
|
||||
extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *default_charset_info;
|
||||
extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *all_charsets[MY_ALL_CHARSETS_SIZE];
|
||||
extern CHARSET_INFO compiled_charsets[];
|
||||
|
||||
/* statistics */
|
||||
extern ulong my_file_opened,my_stream_opened, my_tmp_file_created;
|
||||
extern ulong my_file_total_opened;
|
||||
extern my_bool my_init_done;
|
||||
|
||||
extern MYSQL_PLUGIN_IMPORT int my_umask; /* Default creation mask */
|
||||
extern int my_umask_dir;
|
||||
|
||||
extern ulong my_default_record_cache_size;
|
||||
extern my_bool my_disable_locking,
|
||||
my_enable_symlinks;
|
||||
extern char wild_many,wild_one,wild_prefix;
|
||||
extern const char *charsets_dir;
|
||||
|
||||
enum cache_type
|
||||
{
|
||||
TYPE_NOT_SET= 0, READ_CACHE, WRITE_CACHE,
|
||||
SEQ_READ_APPEND /* sequential read or append */,
|
||||
READ_FIFO, READ_NET,WRITE_NET};
|
||||
|
||||
enum flush_type
|
||||
{
|
||||
FLUSH_KEEP, /* flush block and keep it in the cache */
|
||||
FLUSH_RELEASE, /* flush block and remove it from the cache */
|
||||
FLUSH_IGNORE_CHANGED, /* remove block from the cache */
|
||||
/*
|
||||
As my_disable_flush_pagecache_blocks is always 0, the following option
|
||||
is strictly equivalent to FLUSH_KEEP
|
||||
*/
|
||||
FLUSH_FORCE_WRITE
|
||||
};
|
||||
|
||||
enum file_type
|
||||
{
|
||||
UNOPEN = 0, FILE_BY_OPEN, FILE_BY_CREATE, STREAM_BY_FOPEN, STREAM_BY_FDOPEN,
|
||||
FILE_BY_MKSTEMP, FILE_BY_DUP
|
||||
};
|
||||
|
||||
struct st_my_file_info
|
||||
{
|
||||
char *name;
|
||||
#ifdef _WIN32
|
||||
HANDLE fhandle; /* win32 file handle */
|
||||
int oflag; /* open flags, e.g O_APPEND */
|
||||
#endif
|
||||
enum file_type type;
|
||||
};
|
||||
|
||||
extern struct st_my_file_info *my_file_info;
|
||||
|
||||
/* needed for client-only build */
|
||||
#ifndef PSI_FILE_KEY_DEFINED
|
||||
typedef unsigned int PSI_file_key;
|
||||
#define PSI_FILE_KEY_DEFINED
|
||||
#endif
|
||||
|
||||
typedef struct st_dynamic_array
|
||||
{
|
||||
uchar *buffer;
|
||||
uint elements,max_element;
|
||||
uint alloc_increment;
|
||||
uint size_of_element;
|
||||
PSI_memory_key m_psi_key;
|
||||
} DYNAMIC_ARRAY;
|
||||
|
||||
typedef struct st_my_tmpdir
|
||||
{
|
||||
char **list;
|
||||
uint cur, max;
|
||||
mysql_mutex_t mutex;
|
||||
} MY_TMPDIR;
|
||||
|
||||
typedef struct st_dynamic_string
|
||||
{
|
||||
char *str;
|
||||
size_t length,max_length,alloc_increment;
|
||||
} DYNAMIC_STRING;
|
||||
|
||||
struct st_io_cache;
|
||||
typedef int (*IO_CACHE_CALLBACK)(struct st_io_cache*);
|
||||
|
||||
typedef struct st_io_cache_share
|
||||
{
|
||||
mysql_mutex_t mutex; /* To sync on reads into buffer. */
|
||||
mysql_cond_t cond; /* To wait for signals. */
|
||||
mysql_cond_t cond_writer; /* For a synchronized writer. */
|
||||
/* Offset in file corresponding to the first byte of buffer. */
|
||||
my_off_t pos_in_file;
|
||||
/* If a synchronized write cache is the source of the data. */
|
||||
struct st_io_cache *source_cache;
|
||||
uchar *buffer; /* The read buffer. */
|
||||
uchar *read_end; /* Behind last valid byte of buffer. */
|
||||
int running_threads; /* threads not in lock. */
|
||||
int total_threads; /* threads sharing the cache. */
|
||||
int error; /* Last error. */
|
||||
} IO_CACHE_SHARE;
|
||||
|
||||
typedef struct st_io_cache /* Used when cacheing files */
|
||||
{
|
||||
/* Offset in file corresponding to the first byte of uchar* buffer. */
|
||||
my_off_t pos_in_file;
|
||||
/*
|
||||
The offset of end of file for READ_CACHE and WRITE_CACHE.
|
||||
For SEQ_READ_APPEND it the maximum of the actual end of file and
|
||||
the position represented by read_end.
|
||||
*/
|
||||
my_off_t end_of_file;
|
||||
/* Points to current read position in the buffer */
|
||||
uchar *read_pos;
|
||||
/* the non-inclusive boundary in the buffer for the currently valid read */
|
||||
uchar *read_end;
|
||||
uchar *buffer; /* The read buffer */
|
||||
/* Used in ASYNC_IO */
|
||||
uchar *request_pos;
|
||||
|
||||
/* Only used in WRITE caches and in SEQ_READ_APPEND to buffer writes */
|
||||
uchar *write_buffer;
|
||||
/*
|
||||
Only used in SEQ_READ_APPEND, and points to the current read position
|
||||
in the write buffer. Note that reads in SEQ_READ_APPEND caches can
|
||||
happen from both read buffer (uchar* buffer) and write buffer
|
||||
(uchar* write_buffer).
|
||||
*/
|
||||
uchar *append_read_pos;
|
||||
/* Points to current write position in the write buffer */
|
||||
uchar *write_pos;
|
||||
/* The non-inclusive boundary of the valid write area */
|
||||
uchar *write_end;
|
||||
|
||||
/*
|
||||
Current_pos and current_end are convenience variables used by
|
||||
my_b_tell() and other routines that need to know the current offset
|
||||
current_pos points to &write_pos, and current_end to &write_end in a
|
||||
WRITE_CACHE, and &read_pos and &read_end respectively otherwise
|
||||
*/
|
||||
uchar **current_pos, **current_end;
|
||||
|
||||
/*
|
||||
The lock is for append buffer used in SEQ_READ_APPEND cache
|
||||
need mutex copying from append buffer to read buffer.
|
||||
*/
|
||||
mysql_mutex_t append_buffer_lock;
|
||||
/*
|
||||
The following is used when several threads are reading the
|
||||
same file in parallel. They are synchronized on disk
|
||||
accesses reading the cached part of the file asynchronously.
|
||||
It should be set to NULL to disable the feature. Only
|
||||
READ_CACHE mode is supported.
|
||||
*/
|
||||
IO_CACHE_SHARE *share;
|
||||
|
||||
/*
|
||||
A caller will use my_b_read() macro to read from the cache
|
||||
if the data is already in cache, it will be simply copied with
|
||||
memcpy() and internal variables will be accordinging updated with
|
||||
no functions invoked. However, if the data is not fully in the cache,
|
||||
my_b_read() will call read_function to fetch the data. read_function
|
||||
must never be invoked directly.
|
||||
*/
|
||||
int (*read_function)(struct st_io_cache *,uchar *,size_t);
|
||||
/*
|
||||
Same idea as in the case of read_function, except my_b_write() needs to
|
||||
be replaced with my_b_append() for a SEQ_READ_APPEND cache
|
||||
*/
|
||||
int (*write_function)(struct st_io_cache *,const uchar *,size_t);
|
||||
/*
|
||||
Specifies the type of the cache. Depending on the type of the cache
|
||||
certain operations might not be available and yield unpredicatable
|
||||
results. Details to be documented later
|
||||
*/
|
||||
enum cache_type type;
|
||||
/*
|
||||
Callbacks when the actual read I/O happens. These were added and
|
||||
are currently used for binary logging of LOAD DATA INFILE - when a
|
||||
block is read from the file, we create a block create/append event, and
|
||||
when IO_CACHE is closed, we create an end event. These functions could,
|
||||
of course be used for other things
|
||||
*/
|
||||
IO_CACHE_CALLBACK pre_read;
|
||||
IO_CACHE_CALLBACK post_read;
|
||||
IO_CACHE_CALLBACK pre_close;
|
||||
/*
|
||||
Counts the number of times, when we were forced to use disk. We use it to
|
||||
increase the binlog_cache_disk_use and binlog_stmt_cache_disk_use status
|
||||
variables.
|
||||
*/
|
||||
ulong disk_writes;
|
||||
void* arg; /* for use by pre/post_read */
|
||||
char *file_name; /* if used with 'open_cached_file' */
|
||||
char *dir,*prefix;
|
||||
File file; /* file descriptor */
|
||||
PSI_file_key file_key; /* instrumented file key */
|
||||
|
||||
/*
|
||||
seek_not_done is set by my_b_seek() to inform the upcoming read/write
|
||||
operation that a seek needs to be preformed prior to the actual I/O
|
||||
error is 0 if the cache operation was successful, -1 if there was a
|
||||
"hard" error, and the actual number of I/O-ed bytes if the read/write was
|
||||
partial.
|
||||
*/
|
||||
int seek_not_done,error;
|
||||
/* buffer_length is memory size allocated for buffer or write_buffer */
|
||||
size_t buffer_length;
|
||||
/* read_length is the same as buffer_length except when we use async io */
|
||||
size_t read_length;
|
||||
myf myflags; /* Flags used to my_read/my_write */
|
||||
/*
|
||||
alloced_buffer is 1 if the buffer was allocated by init_io_cache() and
|
||||
0 if it was supplied by the user.
|
||||
Currently READ_NET is the only one that will use a buffer allocated
|
||||
somewhere else
|
||||
*/
|
||||
my_bool alloced_buffer;
|
||||
} IO_CACHE;
|
||||
|
||||
typedef int (*qsort2_cmp)(const void *, const void *, const void *);
|
||||
|
||||
typedef void (*my_error_reporter)(enum loglevel level, const char *format, ...)
|
||||
MY_ATTRIBUTE((format(printf, 2, 3)));
|
||||
|
||||
extern my_error_reporter my_charset_error_reporter;
|
||||
|
||||
/* defines for mf_iocache */
|
||||
extern PSI_file_key key_file_io_cache;
|
||||
|
||||
/* Test if buffer is inited */
|
||||
#define my_b_clear(info) (info)->buffer=0
|
||||
#define my_b_inited(info) (info)->buffer
|
||||
#define my_b_EOF INT_MIN
|
||||
|
||||
#define my_b_read(info,Buffer,Count) \
|
||||
((info)->read_pos + (Count) <= (info)->read_end ?\
|
||||
(memcpy(Buffer,(info)->read_pos,(size_t) (Count)), \
|
||||
((info)->read_pos+=(Count)),0) :\
|
||||
(*(info)->read_function)((info),Buffer,Count))
|
||||
|
||||
#define my_b_write(info,Buffer,Count) \
|
||||
((info)->write_pos + (Count) <=(info)->write_end ?\
|
||||
(memcpy((info)->write_pos, (Buffer), (size_t)(Count)),\
|
||||
((info)->write_pos+=(Count)),0) : \
|
||||
(*(info)->write_function)((info),(uchar *)(Buffer),(Count)))
|
||||
|
||||
#define my_b_get(info) \
|
||||
((info)->read_pos != (info)->read_end ?\
|
||||
((info)->read_pos++, (int) (uchar) (info)->read_pos[-1]) :\
|
||||
_my_b_get(info))
|
||||
|
||||
#define my_b_tell(info) ((info)->pos_in_file + \
|
||||
(size_t) (*(info)->current_pos - (info)->request_pos))
|
||||
|
||||
#define my_b_get_buffer_start(info) (info)->request_pos
|
||||
#define my_b_get_bytes_in_buffer(info) (char*) (info)->read_end - \
|
||||
(char*) my_b_get_buffer_start(info)
|
||||
#define my_b_get_pos_in_file(info) (info)->pos_in_file
|
||||
|
||||
/* tell write offset in the SEQ_APPEND cache */
|
||||
int my_b_copy_to_file(IO_CACHE *cache, FILE *file);
|
||||
my_off_t my_b_append_tell(IO_CACHE* info);
|
||||
my_off_t my_b_safe_tell(IO_CACHE* info); /* picks the correct tell() */
|
||||
|
||||
#define my_b_bytes_in_cache(info) (size_t) (*(info)->current_end - \
|
||||
*(info)->current_pos)
|
||||
|
||||
typedef uint32 ha_checksum;
|
||||
|
||||
#include <my_alloc.h>
|
||||
|
||||
|
||||
/* Prototypes for mysys and my_func functions */
|
||||
|
||||
extern int my_copy(const char *from,const char *to,myf MyFlags);
|
||||
extern int my_delete(const char *name,myf MyFlags);
|
||||
extern int my_getwd(char * buf,size_t size,myf MyFlags);
|
||||
extern int my_setwd(const char *dir,myf MyFlags);
|
||||
extern int my_lock(File fd,int op,my_off_t start, my_off_t length,myf MyFlags);
|
||||
extern void *my_once_alloc(size_t Size,myf MyFlags);
|
||||
extern void my_once_free(void);
|
||||
extern char *my_once_strdup(const char *src,myf myflags);
|
||||
extern void *my_once_memdup(const void *src, size_t len, myf myflags);
|
||||
extern File my_open(const char *FileName,int Flags,myf MyFlags);
|
||||
extern File my_register_filename(File fd, const char *FileName,
|
||||
enum file_type type_of_file,
|
||||
uint error_message_number, myf MyFlags);
|
||||
extern File my_create(const char *FileName,int CreateFlags,
|
||||
int AccessFlags, myf MyFlags);
|
||||
extern int my_close(File Filedes,myf MyFlags);
|
||||
extern int my_mkdir(const char *dir, int Flags, myf MyFlags);
|
||||
extern int my_readlink(char *to, const char *filename, myf MyFlags);
|
||||
extern int my_is_symlink(const char *filename);
|
||||
extern int my_realpath(char *to, const char *filename, myf MyFlags);
|
||||
extern File my_create_with_symlink(const char *linkname, const char *filename,
|
||||
int createflags, int access_flags,
|
||||
myf MyFlags);
|
||||
extern int my_delete_with_symlink(const char *name, myf MyFlags);
|
||||
extern int my_rename_with_symlink(const char *from,const char *to,myf MyFlags);
|
||||
extern int my_symlink(const char *content, const char *linkname, myf MyFlags);
|
||||
extern size_t my_read(File Filedes,uchar *Buffer,size_t Count,myf MyFlags);
|
||||
extern size_t my_pread(File Filedes,uchar *Buffer,size_t Count,my_off_t offset,
|
||||
myf MyFlags);
|
||||
extern int my_rename(const char *from,const char *to,myf MyFlags);
|
||||
extern my_off_t my_seek(File fd,my_off_t pos,int whence,myf MyFlags);
|
||||
extern my_off_t my_tell(File fd,myf MyFlags);
|
||||
extern size_t my_write(File Filedes,const uchar *Buffer,size_t Count,
|
||||
myf MyFlags);
|
||||
extern size_t my_pwrite(File Filedes,const uchar *Buffer,size_t Count,
|
||||
my_off_t offset,myf MyFlags);
|
||||
extern size_t my_fread(FILE *stream,uchar *Buffer,size_t Count,myf MyFlags);
|
||||
extern size_t my_fwrite(FILE *stream,const uchar *Buffer,size_t Count,
|
||||
myf MyFlags);
|
||||
extern my_off_t my_fseek(FILE *stream,my_off_t pos,int whence,myf MyFlags);
|
||||
extern my_off_t my_ftell(FILE *stream,myf MyFlags);
|
||||
|
||||
/* implemented in my_syslog.c */
|
||||
|
||||
// Maximum size of message that will be logged.
|
||||
#define MAX_SYSLOG_MESSAGE_SIZE 1024
|
||||
|
||||
/* Platform-independent SysLog support */
|
||||
|
||||
/* facilities on unixoid syslog. harmless on systemd / Win platforms. */
|
||||
typedef struct st_syslog_facility { int id; const char *name; } SYSLOG_FACILITY;
|
||||
extern SYSLOG_FACILITY syslog_facility[];
|
||||
|
||||
enum my_syslog_options { MY_SYSLOG_PIDS= 1 };
|
||||
|
||||
int my_openlog(const char *eventSourceName, int option, int facility);
|
||||
int my_closelog();
|
||||
int my_syslog(const CHARSET_INFO *cs, enum loglevel level, const char *msg);
|
||||
|
||||
/* implemented in my_memmem.c */
|
||||
extern void *my_memmem(const void *haystack, size_t haystacklen,
|
||||
const void *needle, size_t needlelen);
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
extern int my_access(const char *path, int amode);
|
||||
#else
|
||||
#define my_access access
|
||||
#endif
|
||||
|
||||
extern int check_if_legal_filename(const char *path);
|
||||
extern int check_if_legal_tablename(const char *path);
|
||||
|
||||
#ifdef _WIN32
|
||||
extern my_bool is_filename_allowed(const char *name, size_t length,
|
||||
my_bool allow_current_dir);
|
||||
#else /* _WIN32 */
|
||||
# define is_filename_allowed(name, length, allow_cwd) (TRUE)
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#ifdef _WIN32
|
||||
extern int nt_share_delete(const char *name,myf MyFlags);
|
||||
#define my_delete_allow_opened(fname,flags) nt_share_delete((fname),(flags))
|
||||
#else
|
||||
#define my_delete_allow_opened(fname,flags) my_delete((fname),(flags))
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
/* Windows-only functions (CRT equivalents)*/
|
||||
extern HANDLE my_get_osfhandle(File fd);
|
||||
extern void my_osmaperr(unsigned long last_error);
|
||||
#endif
|
||||
|
||||
extern const char* get_global_errmsg(int nr);
|
||||
extern void wait_for_free_space(const char *filename, int errors);
|
||||
extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags);
|
||||
extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags);
|
||||
extern FILE *my_freopen(const char *path, const char *mode, FILE *stream);
|
||||
extern int my_fclose(FILE *fd,myf MyFlags);
|
||||
extern File my_fileno(FILE *fd);
|
||||
extern int my_chsize(File fd,my_off_t newlength, int filler, myf MyFlags);
|
||||
extern void thr_set_sync_wait_callback(void (*before_sync)(void),
|
||||
void (*after_sync)(void));
|
||||
extern int my_sync(File fd, myf my_flags);
|
||||
extern int my_sync_dir(const char *dir_name, myf my_flags);
|
||||
extern int my_sync_dir_by_file(const char *file_name, myf my_flags);
|
||||
extern char *my_strerror(char *buf, size_t len, int errnum);
|
||||
extern const char *my_get_err_msg(int nr);
|
||||
extern void my_error(int nr,myf MyFlags, ...);
|
||||
extern void my_printf_error(uint my_err, const char *format,
|
||||
myf MyFlags, ...)
|
||||
MY_ATTRIBUTE((format(printf, 2, 4)));
|
||||
extern void my_printv_error(uint error, const char *format, myf MyFlags,
|
||||
va_list ap);
|
||||
extern int my_error_register(const char* (*get_errmsg) (int),
|
||||
int first, int last);
|
||||
extern my_bool my_error_unregister(int first, int last);
|
||||
extern void my_message(uint my_err, const char *str,myf MyFlags);
|
||||
extern void my_message_stderr(uint my_err, const char *str, myf MyFlags);
|
||||
void my_message_local_stderr(enum loglevel ll,
|
||||
const char *format, va_list args);
|
||||
extern void my_message_local(enum loglevel ll, const char *format, ...);
|
||||
extern my_bool my_init(void);
|
||||
extern void my_end(int infoflag);
|
||||
extern int my_redel(const char *from, const char *to, int MyFlags);
|
||||
extern int my_copystat(const char *from, const char *to, int MyFlags);
|
||||
extern char * my_filename(File fd);
|
||||
extern MY_MODE get_file_perm(ulong perm_flags);
|
||||
extern my_bool my_chmod(const char *filename, ulong perm_flags, myf my_flags);
|
||||
|
||||
#ifdef EXTRA_DEBUG
|
||||
void my_print_open_files(void);
|
||||
#else
|
||||
#define my_print_open_files()
|
||||
#endif
|
||||
|
||||
extern my_bool init_tmpdir(MY_TMPDIR *tmpdir, const char *pathlist);
|
||||
extern char *my_tmpdir(MY_TMPDIR *tmpdir);
|
||||
extern void free_tmpdir(MY_TMPDIR *tmpdir);
|
||||
|
||||
extern size_t dirname_part(char * to,const char *name, size_t *to_res_length);
|
||||
extern size_t dirname_length(const char *name);
|
||||
#define base_name(A) (A+dirname_length(A))
|
||||
extern int test_if_hard_path(const char *dir_name);
|
||||
extern my_bool has_path(const char *name);
|
||||
extern char *convert_dirname(char *to, const char *from, const char *from_end);
|
||||
extern void to_unix_path(char * name);
|
||||
extern char * fn_ext(const char *name);
|
||||
extern char * fn_same(char * toname,const char *name,int flag);
|
||||
extern char * fn_format(char * to,const char *name,const char *dir,
|
||||
const char *form, uint flag);
|
||||
extern size_t strlength(const char *str);
|
||||
extern void pack_dirname(char * to,const char *from);
|
||||
extern size_t normalize_dirname(char * to, const char *from);
|
||||
extern size_t unpack_dirname(char * to,const char *from);
|
||||
extern size_t cleanup_dirname(char * to,const char *from);
|
||||
extern size_t system_filename(char * to,const char *from);
|
||||
extern size_t unpack_filename(char * to,const char *from);
|
||||
extern char * intern_filename(char * to,const char *from);
|
||||
extern char * directory_file_name(char * dst, const char *src);
|
||||
extern int pack_filename(char * to, const char *name, size_t max_length);
|
||||
extern char * my_path(char * to,const char *progname,
|
||||
const char *own_pathname_part);
|
||||
extern char * my_load_path(char * to, const char *path,
|
||||
const char *own_path_prefix);
|
||||
extern int wild_compare(const char *str,const char *wildstr,
|
||||
pbool str_is_pattern);
|
||||
extern my_bool array_append_string_unique(const char *str,
|
||||
const char **array, size_t size);
|
||||
extern void get_date(char * to,int timeflag,time_t use_time);
|
||||
extern void soundex(CHARSET_INFO *, char * out_pntr, char * in_pntr,
|
||||
pbool remove_garbage);
|
||||
|
||||
extern my_bool radixsort_is_appliccable(uint n_items, size_t size_of_element);
|
||||
extern void radixsort_for_str_ptr(uchar* base[], uint number_of_elements,
|
||||
size_t size_of_element,uchar *buffer[]);
|
||||
extern void my_qsort(void *base_ptr, size_t total_elems, size_t size,
|
||||
qsort_cmp cmp);
|
||||
extern void my_qsort2(void *base_ptr, size_t total_elems, size_t size,
|
||||
qsort2_cmp cmp, const void *cmp_argument);
|
||||
void my_store_ptr(uchar *buff, size_t pack_length, my_off_t pos);
|
||||
my_off_t my_get_ptr(uchar *ptr, size_t pack_length);
|
||||
extern int init_io_cache_ext(IO_CACHE *info,File file,size_t cachesize,
|
||||
enum cache_type type,my_off_t seek_offset,
|
||||
pbool use_async_io, myf cache_myflags,
|
||||
PSI_file_key file_key);
|
||||
extern int init_io_cache(IO_CACHE *info,File file,size_t cachesize,
|
||||
enum cache_type type,my_off_t seek_offset,
|
||||
pbool use_async_io, myf cache_myflags);
|
||||
extern my_bool reinit_io_cache(IO_CACHE *info,enum cache_type type,
|
||||
my_off_t seek_offset,pbool use_async_io,
|
||||
pbool clear_cache);
|
||||
extern void setup_io_cache(IO_CACHE* info);
|
||||
extern int _my_b_read(IO_CACHE *info,uchar *Buffer,size_t Count);
|
||||
extern int _my_b_read_r(IO_CACHE *info,uchar *Buffer,size_t Count);
|
||||
extern void init_io_cache_share(IO_CACHE *read_cache, IO_CACHE_SHARE *cshare,
|
||||
IO_CACHE *write_cache, uint num_threads);
|
||||
extern void remove_io_thread(IO_CACHE *info);
|
||||
extern int _my_b_seq_read(IO_CACHE *info,uchar *Buffer,size_t Count);
|
||||
extern int _my_b_net_read(IO_CACHE *info,uchar *Buffer,size_t Count);
|
||||
extern int _my_b_get(IO_CACHE *info);
|
||||
extern int _my_b_write(IO_CACHE *info,const uchar *Buffer,size_t Count);
|
||||
extern int my_b_append(IO_CACHE *info,const uchar *Buffer,size_t Count);
|
||||
extern int my_b_safe_write(IO_CACHE *info,const uchar *Buffer,size_t Count);
|
||||
|
||||
extern int my_block_write(IO_CACHE *info, const uchar *Buffer,
|
||||
size_t Count, my_off_t pos);
|
||||
extern int my_b_flush_io_cache(IO_CACHE *info, int need_append_buffer_lock);
|
||||
|
||||
#define flush_io_cache(info) my_b_flush_io_cache((info),1)
|
||||
|
||||
extern int end_io_cache(IO_CACHE *info);
|
||||
extern size_t my_b_fill(IO_CACHE *info);
|
||||
extern void my_b_seek(IO_CACHE *info,my_off_t pos);
|
||||
extern size_t my_b_gets(IO_CACHE *info, char *to, size_t max_length);
|
||||
extern my_off_t my_b_filelength(IO_CACHE *info);
|
||||
extern size_t my_b_printf(IO_CACHE *info, const char* fmt, ...)
|
||||
MY_ATTRIBUTE((format(printf, 2, 3)));
|
||||
extern size_t my_b_vprintf(IO_CACHE *info, const char* fmt, va_list ap);
|
||||
extern my_bool open_cached_file(IO_CACHE *cache,const char *dir,
|
||||
const char *prefix, size_t cache_size,
|
||||
myf cache_myflags);
|
||||
extern my_bool real_open_cached_file(IO_CACHE *cache);
|
||||
extern void close_cached_file(IO_CACHE *cache);
|
||||
File create_temp_file(char *to, const char *dir, const char *pfx,
|
||||
int mode, myf MyFlags);
|
||||
|
||||
// Use Prealloced_array or std::vector or something similar in C++
|
||||
#if defined(__cplusplus)
|
||||
|
||||
#define init_dynamic_array please_use_an_appropriately_typed_container
|
||||
#define my_init_dynamic_array please_use_an_appropriately_typed_container
|
||||
|
||||
#else
|
||||
|
||||
extern my_bool my_init_dynamic_array(DYNAMIC_ARRAY *array,
|
||||
PSI_memory_key key,
|
||||
uint element_size,
|
||||
void *init_buffer,
|
||||
uint init_alloc,
|
||||
uint alloc_increment);
|
||||
/* init_dynamic_array() function is deprecated */
|
||||
extern my_bool init_dynamic_array(DYNAMIC_ARRAY *array, uint element_size,
|
||||
uint init_alloc, uint alloc_increment);
|
||||
#define dynamic_element(array,array_index,type) \
|
||||
((type)((array)->buffer) +(array_index))
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* Some functions are still in use in C++, because HASH uses DYNAMIC_ARRAY */
|
||||
extern my_bool insert_dynamic(DYNAMIC_ARRAY *array, const void *element);
|
||||
extern void *alloc_dynamic(DYNAMIC_ARRAY *array);
|
||||
extern void *pop_dynamic(DYNAMIC_ARRAY*);
|
||||
extern void get_dynamic(DYNAMIC_ARRAY *array, void *element, uint array_index);
|
||||
extern void claim_dynamic(DYNAMIC_ARRAY *array);
|
||||
extern void delete_dynamic(DYNAMIC_ARRAY *array);
|
||||
extern void freeze_size(DYNAMIC_ARRAY *array);
|
||||
static inline void reset_dynamic(DYNAMIC_ARRAY *array)
|
||||
{
|
||||
array->elements= 0;
|
||||
}
|
||||
|
||||
extern my_bool init_dynamic_string(DYNAMIC_STRING *str, const char *init_str,
|
||||
size_t init_alloc,size_t alloc_increment);
|
||||
extern my_bool dynstr_append(DYNAMIC_STRING *str, const char *append);
|
||||
my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append,
|
||||
size_t length);
|
||||
extern my_bool dynstr_append_os_quoted(DYNAMIC_STRING *str, const char *append,
|
||||
...);
|
||||
extern my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str);
|
||||
extern my_bool dynstr_realloc(DYNAMIC_STRING *str, size_t additional_size);
|
||||
extern my_bool dynstr_trunc(DYNAMIC_STRING *str, size_t n);
|
||||
extern void dynstr_free(DYNAMIC_STRING *str);
|
||||
#define alloc_root_inited(A) ((A)->min_malloc != 0)
|
||||
#define ALLOC_ROOT_MIN_BLOCK_SIZE (MALLOC_OVERHEAD + sizeof(USED_MEM) + 8)
|
||||
#define clear_alloc_root(A) do { (A)->free= (A)->used= (A)->pre_alloc= 0; (A)->min_malloc=0;} while(0)
|
||||
extern void init_alloc_root(PSI_memory_key key,
|
||||
MEM_ROOT *mem_root, size_t block_size,
|
||||
size_t pre_alloc_size);
|
||||
extern void *alloc_root(MEM_ROOT *mem_root, size_t Size);
|
||||
extern void *multi_alloc_root(MEM_ROOT *mem_root, ...);
|
||||
extern void claim_root(MEM_ROOT *root);
|
||||
extern void free_root(MEM_ROOT *root, myf MyFLAGS);
|
||||
extern void reset_root_defaults(MEM_ROOT *mem_root, size_t block_size,
|
||||
size_t prealloc_size);
|
||||
extern char *strdup_root(MEM_ROOT *root,const char *str);
|
||||
static inline char *safe_strdup_root(MEM_ROOT *root, const char *str)
|
||||
{
|
||||
return str ? strdup_root(root, str) : 0;
|
||||
}
|
||||
extern char *strmake_root(MEM_ROOT *root,const char *str,size_t len);
|
||||
extern void *memdup_root(MEM_ROOT *root,const void *str, size_t len);
|
||||
extern my_bool my_compress(uchar *, size_t *, size_t *);
|
||||
extern my_bool my_uncompress(uchar *, size_t , size_t *);
|
||||
extern uchar *my_compress_alloc(const uchar *packet, size_t *len,
|
||||
size_t *complen);
|
||||
extern int packfrm(uchar *, size_t, uchar **, size_t *);
|
||||
extern int unpackfrm(uchar **, size_t *, const uchar *);
|
||||
|
||||
extern ha_checksum my_checksum(ha_checksum crc, const uchar *mem,
|
||||
size_t count);
|
||||
|
||||
/* Wait a given number of microseconds */
|
||||
static inline void my_sleep(time_t m_seconds)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
Sleep((DWORD)m_seconds/1000+1); /* Sleep() has millisecond arg */
|
||||
#else
|
||||
struct timeval t;
|
||||
t.tv_sec= m_seconds / 1000000L;
|
||||
t.tv_usec= m_seconds % 1000000L;
|
||||
select(0,0,0,0,&t); /* sleep */
|
||||
#endif
|
||||
}
|
||||
|
||||
extern ulong crc32(ulong crc, const uchar *buf, uint len);
|
||||
extern uint my_set_max_open_files(uint files);
|
||||
void my_free_open_file_info(void);
|
||||
|
||||
extern time_t my_time(myf flags);
|
||||
extern ulonglong my_getsystime(void);
|
||||
extern ulonglong my_micro_time();
|
||||
extern my_bool my_gethwaddr(uchar *to);
|
||||
|
||||
#ifdef HAVE_SYS_MMAN_H
|
||||
#include <sys/mman.h>
|
||||
|
||||
#ifndef MAP_NOSYNC
|
||||
#define MAP_NOSYNC 0
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MMAP64
|
||||
#define my_mmap(a,b,c,d,e,f) mmap64(a,b,c,d,e,f)
|
||||
#else
|
||||
#define my_mmap(a,b,c,d,e,f) mmap(a,b,c,d,e,f)
|
||||
#endif
|
||||
#define my_munmap(a,b) munmap((a),(b))
|
||||
|
||||
#else
|
||||
/* not a complete set of mmap() flags, but only those that nesessary */
|
||||
#define PROT_READ 1
|
||||
#define PROT_WRITE 2
|
||||
#define MAP_NORESERVE 0
|
||||
#define MAP_SHARED 0x0001
|
||||
#define MAP_PRIVATE 0x0002
|
||||
#define MAP_NOSYNC 0x0800
|
||||
#define MAP_FAILED ((void *)-1)
|
||||
#define MS_SYNC 0x0000
|
||||
|
||||
void *my_mmap(void *, size_t, int, int, int, my_off_t);
|
||||
int my_munmap(void *, size_t);
|
||||
#endif
|
||||
|
||||
/* my_getpagesize */
|
||||
static inline int my_getpagesize()
|
||||
{
|
||||
#ifndef _WIN32
|
||||
return getpagesize();
|
||||
#else
|
||||
SYSTEM_INFO si;
|
||||
GetSystemInfo(&si);
|
||||
return (int)si.dwPageSize;
|
||||
#endif
|
||||
}
|
||||
|
||||
int my_msync(int, void *, size_t, int);
|
||||
|
||||
/* character sets */
|
||||
extern void my_charset_loader_init_mysys(MY_CHARSET_LOADER *loader);
|
||||
extern uint get_charset_number(const char *cs_name, uint cs_flags);
|
||||
extern uint get_collation_number(const char *name);
|
||||
extern const char *get_charset_name(uint cs_number);
|
||||
|
||||
extern CHARSET_INFO *get_charset(uint cs_number, myf flags);
|
||||
extern CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags);
|
||||
extern CHARSET_INFO *my_collation_get_by_name(MY_CHARSET_LOADER *loader,
|
||||
const char *name, myf flags);
|
||||
extern CHARSET_INFO *get_charset_by_csname(const char *cs_name,
|
||||
uint cs_flags, myf my_flags);
|
||||
extern CHARSET_INFO *my_charset_get_by_name(MY_CHARSET_LOADER *loader,
|
||||
const char *name,
|
||||
uint cs_flags, myf my_flags);
|
||||
extern my_bool resolve_charset(const char *cs_name,
|
||||
const CHARSET_INFO *default_cs,
|
||||
const CHARSET_INFO **cs);
|
||||
extern my_bool resolve_collation(const char *cl_name,
|
||||
const CHARSET_INFO *default_cl,
|
||||
const CHARSET_INFO **cl);
|
||||
extern void free_charsets(void);
|
||||
extern char *get_charsets_dir(char *buf);
|
||||
extern my_bool my_charset_same(const CHARSET_INFO *cs1,
|
||||
const CHARSET_INFO *cs2);
|
||||
extern my_bool init_compiled_charsets(myf flags);
|
||||
extern void add_compiled_collation(CHARSET_INFO *cs);
|
||||
extern size_t escape_string_for_mysql(const CHARSET_INFO *charset_info,
|
||||
char *to, size_t to_length,
|
||||
const char *from, size_t length);
|
||||
#ifdef _WIN32
|
||||
/* File system character set */
|
||||
extern CHARSET_INFO *fs_character_set(void);
|
||||
#endif
|
||||
extern size_t escape_quotes_for_mysql(CHARSET_INFO *charset_info,
|
||||
char *to, size_t to_length,
|
||||
const char *from, size_t length, char quote);
|
||||
#ifdef _WIN32
|
||||
extern my_bool have_tcpip; /* Is set if tcpip is used */
|
||||
|
||||
/* implemented in my_windac.c */
|
||||
|
||||
int my_security_attr_create(SECURITY_ATTRIBUTES **psa, const char **perror,
|
||||
DWORD owner_rights, DWORD everybody_rights);
|
||||
|
||||
void my_security_attr_free(SECURITY_ATTRIBUTES *sa);
|
||||
|
||||
/* implemented in my_conio.c */
|
||||
my_bool my_win_is_console(FILE *file);
|
||||
char *my_win_console_readline(const CHARSET_INFO *cs, char *mbbuf, size_t mbbufsize,
|
||||
size_t *nread);
|
||||
void my_win_console_write(const CHARSET_INFO *cs, const char *data, size_t datalen);
|
||||
void my_win_console_fputs(const CHARSET_INFO *cs, const char *data);
|
||||
void my_win_console_putc(const CHARSET_INFO *cs, int c);
|
||||
void my_win_console_vfprintf(const CHARSET_INFO *cs, const char *fmt, va_list args);
|
||||
int my_win_translate_command_line_args(const CHARSET_INFO *cs, int *ac, char ***av);
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#ifdef HAVE_PSI_INTERFACE
|
||||
extern MYSQL_PLUGIN_IMPORT struct PSI_bootstrap *PSI_hook;
|
||||
extern void set_psi_server(PSI *psi);
|
||||
void my_init_mysys_psi_keys(void);
|
||||
#endif
|
||||
|
||||
struct st_mysql_file;
|
||||
extern struct st_mysql_file *mysql_stdin;
|
||||
|
||||
C_MODE_END
|
||||
#endif /* _my_sys_h */
|
||||
|
|
@ -1,186 +0,0 @@
|
|||
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
|
||||
|
||||
/* Defines to make different thread packages compatible */
|
||||
|
||||
#ifndef MY_THREAD_INCLUDED
|
||||
#define MY_THREAD_INCLUDED
|
||||
|
||||
#include "my_global.h" /* my_bool */
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
#ifndef ETIME
|
||||
#define ETIME ETIMEDOUT /* For FreeBSD */
|
||||
#endif
|
||||
|
||||
#ifndef ETIMEDOUT
|
||||
#define ETIMEDOUT 145 /* Win32 doesn't have this */
|
||||
#endif
|
||||
|
||||
/*
|
||||
MySQL can survive with 32K, but some glibc libraries require > 128K stack
|
||||
To resolve hostnames. Also recursive stored procedures needs stack.
|
||||
*/
|
||||
#if SIZEOF_CHARP > 4
|
||||
#define DEFAULT_THREAD_STACK (256*1024L)
|
||||
#else
|
||||
#define DEFAULT_THREAD_STACK (192*1024)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERNC extern "C"
|
||||
#else
|
||||
#define EXTERNC
|
||||
#endif
|
||||
|
||||
C_MODE_START
|
||||
|
||||
#ifdef _WIN32
|
||||
typedef volatile LONG my_thread_once_t;
|
||||
typedef DWORD my_thread_t;
|
||||
typedef struct thread_attr
|
||||
{
|
||||
DWORD dwStackSize;
|
||||
int detachstate;
|
||||
} my_thread_attr_t;
|
||||
#define MY_THREAD_CREATE_JOINABLE 0
|
||||
#define MY_THREAD_CREATE_DETACHED 1
|
||||
typedef void * (__cdecl *my_start_routine)(void *);
|
||||
#define MY_THREAD_ONCE_INIT 0
|
||||
#define MY_THREAD_ONCE_INPROGRESS 1
|
||||
#define MY_THREAD_ONCE_DONE 2
|
||||
#else
|
||||
typedef pthread_once_t my_thread_once_t;
|
||||
typedef pthread_t my_thread_t;
|
||||
typedef pthread_attr_t my_thread_attr_t;
|
||||
#define MY_THREAD_CREATE_JOINABLE PTHREAD_CREATE_JOINABLE
|
||||
#define MY_THREAD_CREATE_DETACHED PTHREAD_CREATE_DETACHED
|
||||
typedef void *(* my_start_routine)(void *);
|
||||
#define MY_THREAD_ONCE_INIT PTHREAD_ONCE_INIT
|
||||
#endif
|
||||
|
||||
typedef struct st_my_thread_handle
|
||||
{
|
||||
my_thread_t thread;
|
||||
#ifdef _WIN32
|
||||
HANDLE handle;
|
||||
#endif
|
||||
} my_thread_handle;
|
||||
|
||||
int my_thread_once(my_thread_once_t *once_control, void (*init_routine)(void));
|
||||
|
||||
static inline my_thread_t my_thread_self()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return GetCurrentThreadId();
|
||||
#else
|
||||
return pthread_self();
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int my_thread_equal(my_thread_t t1, my_thread_t t2)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return t1 == t2;
|
||||
#else
|
||||
return pthread_equal(t1, t2);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int my_thread_attr_init(my_thread_attr_t *attr)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
attr->dwStackSize= 0;
|
||||
/* Set to joinable by default to match Linux */
|
||||
attr->detachstate= MY_THREAD_CREATE_JOINABLE;
|
||||
return 0;
|
||||
#else
|
||||
return pthread_attr_init(attr);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int my_thread_attr_destroy(my_thread_attr_t *attr)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
attr->dwStackSize= 0;
|
||||
/* Set to joinable by default to match Linux */
|
||||
attr->detachstate= MY_THREAD_CREATE_JOINABLE;
|
||||
return 0;
|
||||
#else
|
||||
return pthread_attr_destroy(attr);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int my_thread_attr_setstacksize(my_thread_attr_t *attr,
|
||||
size_t stacksize)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
attr->dwStackSize= (DWORD)stacksize;
|
||||
return 0;
|
||||
#else
|
||||
return pthread_attr_setstacksize(attr, stacksize);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int my_thread_attr_setdetachstate(my_thread_attr_t *attr,
|
||||
int detachstate)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
attr->detachstate= detachstate;
|
||||
return 0;
|
||||
#else
|
||||
return pthread_attr_setdetachstate(attr, detachstate);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int my_thread_attr_getstacksize(my_thread_attr_t *attr,
|
||||
size_t *stacksize)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
*stacksize= (size_t)attr->dwStackSize;
|
||||
return 0;
|
||||
#else
|
||||
return pthread_attr_getstacksize(attr, stacksize);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void my_thread_yield()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
SwitchToThread();
|
||||
#else
|
||||
sched_yield();
|
||||
#endif
|
||||
}
|
||||
|
||||
int my_thread_create(my_thread_handle *thread, const my_thread_attr_t *attr,
|
||||
my_start_routine func, void *arg);
|
||||
int my_thread_join(my_thread_handle *thread, void **value_ptr);
|
||||
int my_thread_cancel(my_thread_handle *thread);
|
||||
void my_thread_exit(void *value_ptr);
|
||||
|
||||
|
||||
extern my_bool my_thread_global_init();
|
||||
extern void my_thread_global_reinit();
|
||||
extern void my_thread_global_end();
|
||||
extern my_bool my_thread_init();
|
||||
extern void my_thread_end();
|
||||
|
||||
C_MODE_END
|
||||
|
||||
#endif /* MY_THREAD_INCLUDED */
|
||||
|
|
@ -1,107 +0,0 @@
|
|||
/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
|
||||
|
||||
#ifndef MY_THREAD_LOCAL_INCLUDED
|
||||
#define MY_THREAD_LOCAL_INCLUDED
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
struct _db_code_state_;
|
||||
typedef uint32 my_thread_id;
|
||||
|
||||
C_MODE_START
|
||||
|
||||
#ifdef _WIN32
|
||||
typedef DWORD thread_local_key_t;
|
||||
#else
|
||||
typedef pthread_key_t thread_local_key_t;
|
||||
#endif
|
||||
|
||||
static inline int my_create_thread_local_key(thread_local_key_t *key,
|
||||
void (*destructor)(void *))
|
||||
{
|
||||
#ifdef _WIN32
|
||||
*key= TlsAlloc();
|
||||
return (*key == TLS_OUT_OF_INDEXES);
|
||||
#else
|
||||
return pthread_key_create(key, destructor);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int my_delete_thread_local_key(thread_local_key_t key)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return !TlsFree(key);
|
||||
#else
|
||||
return pthread_key_delete(key);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void* my_get_thread_local(thread_local_key_t key)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return TlsGetValue(key);
|
||||
#else
|
||||
return pthread_getspecific(key);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int my_set_thread_local(thread_local_key_t key,
|
||||
void *value)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return !TlsSetValue(key, value);
|
||||
#else
|
||||
return pthread_setspecific(key, value);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
Retrieve the MySQL thread-local storage variant of errno.
|
||||
*/
|
||||
int my_errno();
|
||||
|
||||
/**
|
||||
Set the MySQL thread-local storage variant of errno.
|
||||
*/
|
||||
void set_my_errno(int my_errno);
|
||||
|
||||
#ifdef _WIN32
|
||||
/*
|
||||
thr_winerr is used for returning the original OS error-code in Windows,
|
||||
my_osmaperr() returns EINVAL for all unknown Windows errors, hence we
|
||||
preserve the original Windows Error code in thr_winerr.
|
||||
*/
|
||||
int thr_winerr();
|
||||
|
||||
void set_thr_winerr(int winerr);
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef DBUG_OFF
|
||||
/* Return pointer to DBUG for holding current state */
|
||||
struct _db_code_state_ **my_thread_var_dbug();
|
||||
|
||||
my_thread_id my_thread_var_id();
|
||||
|
||||
void set_my_thread_var_id(my_thread_id id);
|
||||
|
||||
#endif
|
||||
|
||||
C_MODE_END
|
||||
|
||||
#endif // MY_THREAD_LOCAL_INCLUDED
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
|
||||
|
||||
|
||||
#ifndef _my_xml_h
|
||||
#define _my_xml_h
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#define MY_XML_OK 0
|
||||
#define MY_XML_ERROR 1
|
||||
|
||||
/*
|
||||
A flag whether to use absolute tag names in call-back functions,
|
||||
like "a", "a.b" and "a.b.c" (used in character set file parser),
|
||||
or relative names like "a", "b" and "c".
|
||||
*/
|
||||
#define MY_XML_FLAG_RELATIVE_NAMES 1
|
||||
|
||||
/*
|
||||
A flag whether to skip normilization of text values before calling
|
||||
call-back functions: i.e. skip leading/trailing spaces,
|
||||
\r, \n, \t characters.
|
||||
*/
|
||||
#define MY_XML_FLAG_SKIP_TEXT_NORMALIZATION 2
|
||||
|
||||
enum my_xml_node_type
|
||||
{
|
||||
MY_XML_NODE_TAG, /* can have TAG, ATTR and TEXT children */
|
||||
MY_XML_NODE_ATTR, /* can have TEXT children */
|
||||
MY_XML_NODE_TEXT /* cannot have children */
|
||||
};
|
||||
|
||||
typedef struct xml_stack_st
|
||||
{
|
||||
int flags;
|
||||
enum my_xml_node_type current_node_type;
|
||||
char errstr[128];
|
||||
|
||||
struct {
|
||||
char static_buffer[128];
|
||||
char *buffer;
|
||||
size_t buffer_size;
|
||||
char *start;
|
||||
char *end;
|
||||
} attr;
|
||||
|
||||
const char *beg;
|
||||
const char *cur;
|
||||
const char *end;
|
||||
void *user_data;
|
||||
int (*enter)(struct xml_stack_st *st,const char *val, size_t len);
|
||||
int (*value)(struct xml_stack_st *st,const char *val, size_t len);
|
||||
int (*leave_xml)(struct xml_stack_st *st,const char *val, size_t len);
|
||||
} MY_XML_PARSER;
|
||||
|
||||
void my_xml_parser_create(MY_XML_PARSER *st);
|
||||
void my_xml_parser_free(MY_XML_PARSER *st);
|
||||
int my_xml_parse(MY_XML_PARSER *st,const char *str, size_t len);
|
||||
|
||||
void my_xml_set_value_handler(MY_XML_PARSER *st, int (*)(MY_XML_PARSER *,
|
||||
const char *,
|
||||
size_t len));
|
||||
void my_xml_set_enter_handler(MY_XML_PARSER *st, int (*)(MY_XML_PARSER *,
|
||||
const char *,
|
||||
size_t len));
|
||||
void my_xml_set_leave_handler(MY_XML_PARSER *st, int (*)(MY_XML_PARSER *,
|
||||
const char *,
|
||||
size_t len));
|
||||
void my_xml_set_user_data(MY_XML_PARSER *st, void *);
|
||||
|
||||
size_t my_xml_error_pos(MY_XML_PARSER *st);
|
||||
uint my_xml_error_lineno(MY_XML_PARSER *st);
|
||||
|
||||
const char *my_xml_error_string(MY_XML_PARSER *st);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _my_xml_h */
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,28 +0,0 @@
|
|||
/* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
#ifndef CLIENT_AUTHENTICATION_H
|
||||
#define CLIENT_AUTHENTICATION_H
|
||||
#include <my_global.h>
|
||||
#include "mysql.h"
|
||||
#include "mysql/client_plugin.h"
|
||||
|
||||
C_MODE_START
|
||||
int sha256_password_auth_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql);
|
||||
int sha256_password_init(char *, size_t, int, va_list);
|
||||
int sha256_password_deinit(void);
|
||||
C_MODE_END
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,24 +1,35 @@
|
|||
#ifndef MYSQL_CLIENT_PLUGIN_INCLUDED
|
||||
/* Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
/* Copyright (c) 2010, 2026, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
This program is designed to work with certain software (including
|
||||
but not limited to OpenSSL) that is licensed under separate terms,
|
||||
as designated in a particular file or component or in included license
|
||||
documentation. The authors of MySQL hereby grant you an additional
|
||||
permission to link the program and your derivative works with the
|
||||
separately licensed software that they have either included with
|
||||
the program or referenced in the documentation.
|
||||
|
||||
Without limiting anything contained in the foregoing, this file,
|
||||
which is part of C Driver for MySQL (Connector/C), is also subject to the
|
||||
Universal FOSS Exception, version 1.0, a copy of which can be found at
|
||||
http://oss.oracle.com/licenses/universal-foss-exception.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU General Public License, version 2.0, for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
/**
|
||||
@file
|
||||
|
||||
MySQL Client Plugin API
|
||||
|
||||
@file include/mysql/client_plugin.h
|
||||
MySQL Client Plugin API.
|
||||
This file defines the API for plugins that work on the client side
|
||||
*/
|
||||
#define MYSQL_CLIENT_PLUGIN_INCLUDED
|
||||
|
|
@ -35,79 +46,89 @@
|
|||
for functions.
|
||||
*/
|
||||
|
||||
#undef MYSQL_PLUGIN_EXPORT
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(MYSQL_DYNAMIC_PLUGIN)
|
||||
#ifdef __cplusplus
|
||||
#define MYSQL_PLUGIN_EXPORT extern "C" __declspec(dllexport)
|
||||
#else
|
||||
#define MYSQL_PLUGIN_EXPORT __declspec(dllexport)
|
||||
#endif
|
||||
#else /* MYSQL_DYNAMIC_PLUGIN */
|
||||
#ifdef __cplusplus
|
||||
#define MYSQL_PLUGIN_EXPORT extern "C"
|
||||
#else
|
||||
#define MYSQL_PLUGIN_EXPORT
|
||||
#endif
|
||||
#endif /*MYSQL_DYNAMIC_PLUGIN */
|
||||
#else /*_MSC_VER */
|
||||
#define MYSQL_PLUGIN_EXPORT
|
||||
#if defined(MYSQL_DYNAMIC_CLIENT_PLUGIN)
|
||||
#ifdef __cplusplus
|
||||
#define MYSQL_CLIENT_PLUGIN_EXPORT extern "C" __declspec(dllexport)
|
||||
#else
|
||||
#define MYSQL_CLIENT_PLUGIN_EXPORT __declspec(dllexport)
|
||||
#endif
|
||||
#else /* MYSQL_DYNAMIC_CLIENT_PLUGIN */
|
||||
#ifdef __cplusplus
|
||||
#define MYSQL_CLIENT_PLUGIN_EXPORT extern "C"
|
||||
#else
|
||||
#define MYSQL_CLIENT_PLUGIN_EXPORT
|
||||
#endif
|
||||
#endif /*MYSQL_DYNAMIC_CLIENT_PLUGIN */
|
||||
#else /*_MSC_VER */
|
||||
|
||||
#if defined(MYSQL_DYNAMIC_CLIENT_PLUGIN)
|
||||
#define MYSQL_CLIENT_PLUGIN_EXPORT MY_ATTRIBUTE((visibility("default")))
|
||||
#else
|
||||
#define MYSQL_CLIENT_PLUGIN_EXPORT
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* known plugin types */
|
||||
#define MYSQL_CLIENT_reserved1 0
|
||||
#define MYSQL_CLIENT_reserved2 1
|
||||
#define MYSQL_CLIENT_AUTHENTICATION_PLUGIN 2
|
||||
#define MYSQL_CLIENT_TRACE_PLUGIN 3
|
||||
#define MYSQL_CLIENT_reserved1 0
|
||||
#define MYSQL_CLIENT_reserved2 1
|
||||
#define MYSQL_CLIENT_AUTHENTICATION_PLUGIN 2
|
||||
#define MYSQL_CLIENT_TRACE_PLUGIN 3
|
||||
|
||||
#define MYSQL_CLIENT_AUTHENTICATION_PLUGIN_INTERFACE_VERSION 0x0100
|
||||
#define MYSQL_CLIENT_TRACE_PLUGIN_INTERFACE_VERSION 0x0100
|
||||
#define MYSQL_CLIENT_AUTHENTICATION_PLUGIN_INTERFACE_VERSION 0x0200
|
||||
#define MYSQL_CLIENT_TRACE_PLUGIN_INTERFACE_VERSION 0x0200
|
||||
|
||||
#define MYSQL_CLIENT_MAX_PLUGINS 4
|
||||
#define MYSQL_CLIENT_MAX_PLUGINS 4
|
||||
|
||||
#define mysql_declare_client_plugin(X) \
|
||||
MYSQL_PLUGIN_EXPORT struct st_mysql_client_plugin_ ## X \
|
||||
_mysql_client_plugin_declaration_ = { \
|
||||
MYSQL_CLIENT_ ## X ## _PLUGIN, \
|
||||
MYSQL_CLIENT_ ## X ## _PLUGIN_INTERFACE_VERSION,
|
||||
#define mysql_end_client_plugin }
|
||||
#define MYSQL_CLIENT_PLUGIN_AUTHOR_ORACLE "Oracle Corporation"
|
||||
|
||||
#define mysql_declare_client_plugin(X) \
|
||||
MYSQL_CLIENT_PLUGIN_EXPORT st_mysql_client_plugin_##X \
|
||||
_mysql_client_plugin_declaration_ = { \
|
||||
MYSQL_CLIENT_##X##_PLUGIN, \
|
||||
MYSQL_CLIENT_##X##_PLUGIN_INTERFACE_VERSION,
|
||||
#define mysql_end_client_plugin }
|
||||
|
||||
/* generic plugin header structure */
|
||||
#define MYSQL_CLIENT_PLUGIN_HEADER \
|
||||
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 *);
|
||||
#define MYSQL_CLIENT_PLUGIN_HEADER \
|
||||
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 *); \
|
||||
int (*get_options)(const char *option, void *);
|
||||
|
||||
struct st_mysql_client_plugin
|
||||
{
|
||||
struct st_mysql_client_plugin {
|
||||
MYSQL_CLIENT_PLUGIN_HEADER
|
||||
};
|
||||
|
||||
struct st_mysql;
|
||||
struct MYSQL;
|
||||
|
||||
/******** authentication plugin specific declarations *********/
|
||||
#include "plugin_auth_common.h"
|
||||
|
||||
struct st_mysql_client_plugin_AUTHENTICATION
|
||||
{
|
||||
struct auth_plugin_t {
|
||||
MYSQL_CLIENT_PLUGIN_HEADER
|
||||
int (*authenticate_user)(MYSQL_PLUGIN_VIO *vio, struct st_mysql *mysql);
|
||||
int (*authenticate_user)(MYSQL_PLUGIN_VIO *vio, struct MYSQL *mysql);
|
||||
enum net_async_status (*authenticate_user_nonblocking)(MYSQL_PLUGIN_VIO *vio,
|
||||
struct MYSQL *mysql,
|
||||
int *result);
|
||||
};
|
||||
|
||||
// Needed for the mysql_declare_client_plugin() macro. Do not use elsewhere.
|
||||
typedef struct auth_plugin_t st_mysql_client_plugin_AUTHENTICATION;
|
||||
|
||||
/******** using plugins ************/
|
||||
|
||||
/**
|
||||
|
|
@ -123,9 +144,9 @@ struct st_mysql_client_plugin_AUTHENTICATION
|
|||
@retval
|
||||
a pointer to the loaded plugin, or NULL in case of a failure
|
||||
*/
|
||||
struct st_mysql_client_plugin *
|
||||
mysql_load_plugin(struct st_mysql *mysql, const char *name, int type,
|
||||
int argc, ...);
|
||||
struct st_mysql_client_plugin *mysql_load_plugin(struct MYSQL *mysql,
|
||||
const char *name, int type,
|
||||
int argc, ...);
|
||||
|
||||
/**
|
||||
loads a plugin and initializes it, taking va_list as an argument
|
||||
|
|
@ -143,9 +164,9 @@ mysql_load_plugin(struct st_mysql *mysql, const char *name, int type,
|
|||
@retval
|
||||
a pointer to the loaded plugin, or NULL in case of a failure
|
||||
*/
|
||||
struct st_mysql_client_plugin *
|
||||
mysql_load_plugin_v(struct st_mysql *mysql, const char *name, int type,
|
||||
int argc, va_list args);
|
||||
struct st_mysql_client_plugin *mysql_load_plugin_v(struct MYSQL *mysql,
|
||||
const char *name, int type,
|
||||
int argc, va_list args);
|
||||
|
||||
/**
|
||||
finds an already loaded plugin by name, or loads it, if necessary
|
||||
|
|
@ -157,8 +178,9 @@ mysql_load_plugin_v(struct st_mysql *mysql, const char *name, int type,
|
|||
@retval
|
||||
a pointer to the plugin, or NULL in case of a failure
|
||||
*/
|
||||
struct st_mysql_client_plugin *
|
||||
mysql_client_find_plugin(struct st_mysql *mysql, const char *name, int type);
|
||||
struct st_mysql_client_plugin *mysql_client_find_plugin(struct MYSQL *mysql,
|
||||
const char *name,
|
||||
int type);
|
||||
|
||||
/**
|
||||
adds a plugin structure to the list of loaded plugins
|
||||
|
|
@ -174,9 +196,8 @@ mysql_client_find_plugin(struct st_mysql *mysql, const char *name, int type);
|
|||
@retval
|
||||
a pointer to the plugin, or NULL in case of a failure
|
||||
*/
|
||||
struct st_mysql_client_plugin *
|
||||
mysql_client_register_plugin(struct st_mysql *mysql,
|
||||
struct st_mysql_client_plugin *plugin);
|
||||
struct st_mysql_client_plugin *mysql_client_register_plugin(
|
||||
struct MYSQL *mysql, struct st_mysql_client_plugin *plugin);
|
||||
|
||||
/**
|
||||
set plugin options
|
||||
|
|
@ -193,10 +214,23 @@ mysql_client_register_plugin(struct st_mysql *mysql,
|
|||
int mysql_plugin_options(struct st_mysql_client_plugin *plugin,
|
||||
const char *option, const void *value);
|
||||
|
||||
/**
|
||||
get plugin options
|
||||
|
||||
Can be used to get options from a plugin.
|
||||
This function may be called multiple times to get several options
|
||||
|
||||
@param plugin an st_mysql_client_plugin structure
|
||||
@param option a string which specifies the option to get
|
||||
@param[out] value value for the option.
|
||||
|
||||
@retval 0 on success, 1 in case of failure
|
||||
**/
|
||||
int mysql_plugin_get_option(struct st_mysql_client_plugin *plugin,
|
||||
const char *option, void *value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,39 +0,0 @@
|
|||
struct st_mysql_client_plugin
|
||||
{
|
||||
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 *);
|
||||
};
|
||||
struct st_mysql;
|
||||
#include "plugin_auth_common.h"
|
||||
typedef struct st_plugin_vio_info
|
||||
{
|
||||
enum { MYSQL_VIO_INVALID, MYSQL_VIO_TCP, MYSQL_VIO_SOCKET,
|
||||
MYSQL_VIO_PIPE, MYSQL_VIO_MEMORY } protocol;
|
||||
int socket;
|
||||
} MYSQL_PLUGIN_VIO_INFO;
|
||||
typedef struct st_plugin_vio
|
||||
{
|
||||
int (*read_packet)(struct st_plugin_vio *vio,
|
||||
unsigned char **buf);
|
||||
int (*write_packet)(struct st_plugin_vio *vio,
|
||||
const unsigned char *packet,
|
||||
int packet_len);
|
||||
void (*info)(struct st_plugin_vio *vio, struct st_plugin_vio_info *info);
|
||||
} MYSQL_PLUGIN_VIO;
|
||||
struct st_mysql_client_plugin_AUTHENTICATION
|
||||
{
|
||||
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 *);
|
||||
int (*authenticate_user)(MYSQL_PLUGIN_VIO *vio, struct st_mysql *mysql);
|
||||
};
|
||||
struct st_mysql_client_plugin *
|
||||
mysql_load_plugin(struct st_mysql *mysql, const char *name, int type,
|
||||
int argc, ...);
|
||||
struct st_mysql_client_plugin *
|
||||
mysql_load_plugin_v(struct st_mysql *mysql, const char *name, int type,
|
||||
int argc, va_list args);
|
||||
struct st_mysql_client_plugin *
|
||||
mysql_client_find_plugin(struct st_mysql *mysql, const char *name, int type);
|
||||
struct st_mysql_client_plugin *
|
||||
mysql_client_register_plugin(struct st_mysql *mysql,
|
||||
struct st_mysql_client_plugin *plugin);
|
||||
int mysql_plugin_options(struct st_mysql_client_plugin *plugin,
|
||||
const char *option, const void *value);
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
/*
|
||||
** Ask for a password from tty
|
||||
** This is an own file to avoid conflicts with curses
|
||||
*/
|
||||
|
||||
#ifndef MYSQL_GET_PASSWORD_H_INCLUDED
|
||||
#define MYSQL_GET_PASSWORD_H_INCLUDED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef char *(* strdup_handler_t)(const char *, int);
|
||||
char *get_tty_password_ext(const char *opt_message,
|
||||
strdup_handler_t strdup_function);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ! MYSQL_GET_PASSWORD_H_INCLUDED */
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
/* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#ifndef MYSQL_LEX_STRING_INCLUDED
|
||||
#define MYSQL_LEX_STRING_INCLUDED
|
||||
|
||||
struct st_mysql_lex_string
|
||||
{
|
||||
char *str;
|
||||
size_t length;
|
||||
};
|
||||
typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
|
||||
|
||||
struct st_mysql_const_lex_string
|
||||
{
|
||||
const char *str;
|
||||
size_t length;
|
||||
};
|
||||
typedef struct st_mysql_const_lex_string MYSQL_LEX_CSTRING;
|
||||
|
||||
#endif // MYSQL_LEX_STRING_INCLUDED
|
||||
|
|
@ -1,21 +1,34 @@
|
|||
#ifndef MYSQL_PLUGIN_AUTH_COMMON_INCLUDED
|
||||
/* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
/* Copyright (c) 2010, 2026, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
This program is designed to work with certain software (including
|
||||
but not limited to OpenSSL) that is licensed under separate terms,
|
||||
as designated in a particular file or component or in included license
|
||||
documentation. The authors of MySQL hereby grant you an additional
|
||||
permission to link the program and your derivative works with the
|
||||
separately licensed software that they have either included with
|
||||
the program or referenced in the documentation.
|
||||
|
||||
Without limiting anything contained in the foregoing, this file,
|
||||
which is part of C Driver for MySQL (Connector/C), is also subject to the
|
||||
Universal FOSS Exception, version 1.0, a copy of which can be found at
|
||||
http://oss.oracle.com/licenses/universal-foss-exception.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU General Public License, version 2.0, for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
/**
|
||||
@file
|
||||
@file include/mysql/plugin_auth_common.h
|
||||
|
||||
This file defines constants and data structures that are the same for
|
||||
both client- and server-side authentication plugins.
|
||||
|
|
@ -82,7 +95,12 @@
|
|||
or not.
|
||||
*/
|
||||
#define CR_OK_HANDSHAKE_COMPLETE -2
|
||||
|
||||
/**
|
||||
Authentication was successful with limited operations.
|
||||
It means that the both client and server side plugins decided to allow
|
||||
authentication with very limited operations ALTER USER to do registration.
|
||||
*/
|
||||
#define CR_OK_AUTH_IN_SANDBOX_MODE -3
|
||||
/**
|
||||
Flag to be passed back to server from authentication plugins via
|
||||
authenticated_as when proxy mapping should be done by the server.
|
||||
|
|
@ -93,51 +111,78 @@ authenticated_as when proxy mapping should be done by the server.
|
|||
We need HANDLE definition if on Windows. Define WIN32_LEAN_AND_MEAN (if
|
||||
not already done) to minimize amount of imported declarations.
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32) && !defined(MYSQL_ABI_CHECK)
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
typedef struct st_plugin_vio_info
|
||||
{
|
||||
enum { MYSQL_VIO_INVALID, MYSQL_VIO_TCP, MYSQL_VIO_SOCKET,
|
||||
MYSQL_VIO_PIPE, MYSQL_VIO_MEMORY } protocol;
|
||||
int socket; /**< it's set, if the protocol is SOCKET or TCP */
|
||||
#ifdef _WIN32
|
||||
HANDLE handle; /**< it's set, if the protocol is PIPE or MEMORY */
|
||||
struct MYSQL_PLUGIN_VIO_INFO {
|
||||
enum {
|
||||
MYSQL_VIO_INVALID,
|
||||
MYSQL_VIO_TCP,
|
||||
MYSQL_VIO_SOCKET,
|
||||
MYSQL_VIO_PIPE,
|
||||
MYSQL_VIO_MEMORY
|
||||
} protocol;
|
||||
int socket; /**< it's set, if the protocol is SOCKET or TCP */
|
||||
#if defined(_WIN32) && !defined(MYSQL_ABI_CHECK)
|
||||
HANDLE handle; /**< it's set, if the protocol is PIPE or MEMORY */
|
||||
#endif
|
||||
} MYSQL_PLUGIN_VIO_INFO;
|
||||
};
|
||||
|
||||
/* state of an asynchronous operation */
|
||||
enum net_async_status {
|
||||
NET_ASYNC_COMPLETE = 0,
|
||||
NET_ASYNC_NOT_READY,
|
||||
NET_ASYNC_ERROR,
|
||||
NET_ASYNC_COMPLETE_NO_MORE_RESULTS
|
||||
};
|
||||
|
||||
/**
|
||||
Provides plugin access to communication channel
|
||||
*/
|
||||
typedef struct st_plugin_vio
|
||||
{
|
||||
typedef struct MYSQL_PLUGIN_VIO {
|
||||
/**
|
||||
Plugin provides a pointer reference and this function sets it to the
|
||||
contents of any incoming packet. Returns the packet length, or -1 if
|
||||
the plugin should terminate.
|
||||
*/
|
||||
int (*read_packet)(struct st_plugin_vio *vio,
|
||||
unsigned char **buf);
|
||||
|
||||
int (*read_packet)(struct MYSQL_PLUGIN_VIO *vio, unsigned char **buf);
|
||||
|
||||
/**
|
||||
Plugin provides a buffer with data and the length and this
|
||||
function sends it as a packet. Returns 0 on success, 1 on failure.
|
||||
*/
|
||||
int (*write_packet)(struct st_plugin_vio *vio,
|
||||
const unsigned char *packet,
|
||||
int (*write_packet)(struct MYSQL_PLUGIN_VIO *vio, const unsigned char *packet,
|
||||
int packet_len);
|
||||
|
||||
/**
|
||||
Fills in a st_plugin_vio_info structure, providing the information
|
||||
Fills in a MYSQL_PLUGIN_VIO_INFO structure, providing the information
|
||||
about the connection.
|
||||
*/
|
||||
void (*info)(struct st_plugin_vio *vio, struct st_plugin_vio_info *info);
|
||||
void (*info)(struct MYSQL_PLUGIN_VIO *vio,
|
||||
struct MYSQL_PLUGIN_VIO_INFO *info);
|
||||
|
||||
/**
|
||||
Non blocking version of read_packet. This function points buf to starting
|
||||
position of incoming packet. When this function returns NET_ASYNC_NOT_READY
|
||||
plugin should call this function again until all incoming packets are read.
|
||||
If return code is NET_ASYNC_COMPLETE, plugin can do further processing of
|
||||
read packets.
|
||||
*/
|
||||
enum net_async_status (*read_packet_nonblocking)(struct MYSQL_PLUGIN_VIO *vio,
|
||||
unsigned char **buf,
|
||||
int *result);
|
||||
/**
|
||||
Non blocking version of write_packet. Sends data available in pkt of length
|
||||
pkt_len to server in asynchronous way.
|
||||
*/
|
||||
enum net_async_status (*write_packet_nonblocking)(
|
||||
struct MYSQL_PLUGIN_VIO *vio, const unsigned char *pkt, int pkt_len,
|
||||
int *result);
|
||||
|
||||
} MYSQL_PLUGIN_VIO;
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,349 +0,0 @@
|
|||
/* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#ifndef PLUGIN_TRACE_INCLUDED
|
||||
#define PLUGIN_TRACE_INCLUDED
|
||||
/**
|
||||
@file
|
||||
|
||||
========================================================================
|
||||
Declarations for client-side plugins of type MYSQL_CLIENT_TRACE_PLUGIN
|
||||
========================================================================
|
||||
|
||||
See libmysql/mysql_trace.c for a brief description of the client-side
|
||||
protocol tracing infrastructure.
|
||||
*/
|
||||
|
||||
|
||||
#include <mysql/client_plugin.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
Lists of protocol stages and trace events
|
||||
=========================================
|
||||
|
||||
These lists are defined with PROTOCOL_STAGE_LIST() and TRACE_EVENT_LIST(),
|
||||
respectively. Macros accept a disposition name as an argument.
|
||||
|
||||
For example, to process list of protocol stages using disposition "foo",
|
||||
define protocol_stage_foo(Stage) macro and then put
|
||||
|
||||
PROTOCOL_STAGE_LIST(foo)
|
||||
|
||||
in your code. This will expand to sequence of protocol_stage_foo(X)
|
||||
macros where X ranges over the list of protocol stages, and these macros
|
||||
should generate the actual code. See below how this technique is used
|
||||
to generate protocol_stage and trace_events enums.
|
||||
*/
|
||||
|
||||
/**
|
||||
Protocol stages
|
||||
---------------
|
||||
|
||||
A client following the MySQL protocol goes through several stages of it. Each
|
||||
stage determines what packets can be expected from the server or can be send
|
||||
by the client.
|
||||
|
||||
Upon receiving each trace event, trace plugin will be notified of the current
|
||||
protocol stage so that it can correctly interpret the event.
|
||||
|
||||
These are the possible protocol stages and the transitions between them.
|
||||
|
||||
.. digraph:: protocol_stages
|
||||
|
||||
CONNECTING -> WAIT_FOR_INIT_PACKET;
|
||||
CONNECTING -> DISCONNECTED [ label = "failed connection" ];
|
||||
|
||||
WAIT_FOR_INIT_PACKET -> AUTHENTICATE;
|
||||
WAIT_FOR_INIT_PACKET -> SSL_NEGOTIATION -> AUTHENTICATE;
|
||||
|
||||
AUTHENTICATE -> READY_FOR_COMMAND [ label = "accepted" ];
|
||||
AUTHENTICATE -> DISCONNECTED [ label = "rejected" ];
|
||||
|
||||
READY_FOR_COMMAND -> DISCONNECTED [ label = "COM_QUIT" ];
|
||||
READY_FOR_COMMAND -> AUTHENTICATE [ label="after change user" ];
|
||||
READY_FOR_COMMAND -> WAIT_FOR_PACKET
|
||||
[ label="wait for a single packet after, e.g., COM_STATISTICS" ];
|
||||
READY_FOR_COMMAND -> WAIT_FOR_RESULT;
|
||||
READY_FOR_COMMAND -> WAIT_FOR_PS_DESCRIPTION
|
||||
[ label="after prepare command" ];
|
||||
|
||||
WAIT_FOR_PACKET -> READY_FOR_COMAND;
|
||||
|
||||
WAIT_FOR_RESULT -> READY_FOR_COMMAND [ label="simple reply" ];
|
||||
WAIT_FOR_RESULT -> WAIT_FOR_FIELD_DEF;
|
||||
WAIT_FOR_RESULT -> FILE_REQUEST;
|
||||
|
||||
WAIT_FOR_FIELD_DEF -> WAIT_FOR_ROW [ label="in a resultset" ];
|
||||
WAIT_FOR_FIELD_DEF -> READY_FOR_COMMAND
|
||||
[ label="after describe table or prepare command" ];
|
||||
|
||||
WAIT_FOR_ROW -> READY_FOR_COMMAND;
|
||||
WAIT_FOR_ROW -> WAIT_FOR_RESULT [ label="multi-resultset" ];
|
||||
|
||||
WAIT_FOR_PS_DESCRIPTION -> WAIT_FOR_PARAM_DEF;
|
||||
WAIT_FOR_PS_DESCRIPTION -> READY_FOR_COMMAND
|
||||
[ label="no params and result" ];
|
||||
WAIT_FOR_PS_DESCRIPTION -> WAIT_FOR_FIELD_DEF [ label="no params" ];
|
||||
|
||||
WAIT_FOR_PARAM_DEF -> WAIT_FOR_FIELD_DEF;
|
||||
WAIT_FOR_PARAM_DEF -> READY_FOR_COMMAND [ label="no result" ];
|
||||
|
||||
FILE_REQUEST -> WAIT_FOR_RESULT [label="when whole file sent"];
|
||||
*/
|
||||
|
||||
#define PROTOCOL_STAGE_LIST(X) \
|
||||
protocol_stage_ ## X(CONNECTING) \
|
||||
protocol_stage_ ## X(WAIT_FOR_INIT_PACKET) \
|
||||
protocol_stage_ ## X(AUTHENTICATE) \
|
||||
protocol_stage_ ## X(SSL_NEGOTIATION) \
|
||||
protocol_stage_ ## X(READY_FOR_COMMAND) \
|
||||
protocol_stage_ ## X(WAIT_FOR_PACKET) \
|
||||
protocol_stage_ ## X(WAIT_FOR_RESULT) \
|
||||
protocol_stage_ ## X(WAIT_FOR_FIELD_DEF) \
|
||||
protocol_stage_ ## X(WAIT_FOR_ROW) \
|
||||
protocol_stage_ ## X(FILE_REQUEST) \
|
||||
protocol_stage_ ## X(WAIT_FOR_PS_DESCRIPTION) \
|
||||
protocol_stage_ ## X(WAIT_FOR_PARAM_DEF) \
|
||||
protocol_stage_ ## X(DISCONNECTED)
|
||||
|
||||
/**
|
||||
Trace events
|
||||
------------
|
||||
|
||||
The following events are generated during the various stages of the
|
||||
client-server conversation.
|
||||
|
||||
---------------------- -----------------------------------------------------
|
||||
Connection events
|
||||
---------------------- -----------------------------------------------------
|
||||
CONNECTING Client is connecting to the server.
|
||||
CONNECTED Physical connection has been established.
|
||||
DISCONNECTED Connection with server was broken.
|
||||
---------------------- -----------------------------------------------------
|
||||
SSL events
|
||||
---------------------- -----------------------------------------------------
|
||||
SEND_SSL_REQUEST Client is sending SSL connection request.
|
||||
SSL_CONNECT Client is initiating SSL handshake.
|
||||
SSL_CONNECTED SSL connection has been established.
|
||||
---------------------- -----------------------------------------------------
|
||||
Authentication events
|
||||
---------------------- -----------------------------------------------------
|
||||
CHALLENGE_RECEIVED Client received authentication challenge.
|
||||
AUTH_PLUGIN Client selects an authentication plugin to be used
|
||||
in the following authentication exchange.
|
||||
SEND_AUTH_RESPONSE Client sends response to the authentication
|
||||
challenge.
|
||||
SEND_AUTH_DATA Client sends extra authentication data packet.
|
||||
AUTHENTICATED Server has accepted connection.
|
||||
---------------------- -----------------------------------------------------
|
||||
Command phase events
|
||||
---------------------- -----------------------------------------------------
|
||||
SEND_COMMAND Client is sending a command to the server.
|
||||
SEND_FILE Client is sending local file contents to the server.
|
||||
---------------------- -----------------------------------------------------
|
||||
General events
|
||||
---------------------- -----------------------------------------------------
|
||||
READ_PACKET Client starts waiting for a packet from server.
|
||||
PACKET_RECEIVED A packet from server has been received.
|
||||
PACKET_SENT After successful sending of a packet to the server.
|
||||
ERROR Client detected an error.
|
||||
---------------------- -----------------------------------------------------
|
||||
*/
|
||||
|
||||
#define TRACE_EVENT_LIST(X) \
|
||||
trace_event_ ## X(ERROR) \
|
||||
trace_event_ ## X(CONNECTING) \
|
||||
trace_event_ ## X(CONNECTED) \
|
||||
trace_event_ ## X(DISCONNECTED) \
|
||||
trace_event_ ## X(SEND_SSL_REQUEST) \
|
||||
trace_event_ ## X(SSL_CONNECT) \
|
||||
trace_event_ ## X(SSL_CONNECTED) \
|
||||
trace_event_ ## X(INIT_PACKET_RECEIVED) \
|
||||
trace_event_ ## X(AUTH_PLUGIN) \
|
||||
trace_event_ ## X(SEND_AUTH_RESPONSE) \
|
||||
trace_event_ ## X(SEND_AUTH_DATA) \
|
||||
trace_event_ ## X(AUTHENTICATED) \
|
||||
trace_event_ ## X(SEND_COMMAND) \
|
||||
trace_event_ ## X(SEND_FILE) \
|
||||
trace_event_ ## X(READ_PACKET) \
|
||||
trace_event_ ## X(PACKET_RECEIVED) \
|
||||
trace_event_ ## X(PACKET_SENT)
|
||||
|
||||
/**
|
||||
Some trace events have additional arguments. These are stored in
|
||||
st_trace_event_args structure. Various events store their arguments in the
|
||||
structure as follows. Unused members are set to 0/NULL.
|
||||
|
||||
AUTH_PLUGIN
|
||||
------------- ----------------------------------
|
||||
plugin_name the name of the plugin
|
||||
------------- ----------------------------------
|
||||
|
||||
SEND_COMMAND
|
||||
------------- ----------------------------------
|
||||
cmd the command code
|
||||
hdr pointer to command packet header
|
||||
hdr_len length of the header
|
||||
pkt pointer to command arguments
|
||||
pkt_len length of arguments
|
||||
------------- ----------------------------------
|
||||
|
||||
Other SEND_* and *_RECEIVED events
|
||||
------------- ----------------------------------
|
||||
pkt the data sent or received
|
||||
pkt_len length of the data
|
||||
------------- ----------------------------------
|
||||
|
||||
PACKET_SENT
|
||||
------------- ----------------------------------
|
||||
pkt_len number of bytes sent
|
||||
------------- ----------------------------------
|
||||
*/
|
||||
|
||||
struct st_trace_event_args
|
||||
{
|
||||
const char *plugin_name;
|
||||
int cmd;
|
||||
const unsigned char *hdr;
|
||||
size_t hdr_len;
|
||||
const unsigned char *pkt;
|
||||
size_t pkt_len;
|
||||
};
|
||||
|
||||
|
||||
/* Definitions of protocol_stage and trace_event enums. */
|
||||
|
||||
#define protocol_stage_enum(X) PROTOCOL_STAGE_ ## X,
|
||||
|
||||
enum protocol_stage {
|
||||
PROTOCOL_STAGE_LIST(enum)
|
||||
PROTOCOL_STAGE_LAST
|
||||
};
|
||||
|
||||
#define trace_event_enum(X) TRACE_EVENT_ ## X,
|
||||
|
||||
enum trace_event {
|
||||
TRACE_EVENT_LIST(enum)
|
||||
TRACE_EVENT_LAST
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
Trace plugin methods
|
||||
====================
|
||||
*/
|
||||
|
||||
struct st_mysql_client_plugin_TRACE;
|
||||
struct st_mysql;
|
||||
|
||||
/**
|
||||
Trace plugin tracing_start() method.
|
||||
|
||||
Called when tracing with this plugin starts on a connection. A trace
|
||||
plugin might want to maintain per-connection information. It can
|
||||
return a pointer to memory area holding such information. It will be
|
||||
stored in a connection handle and passed to other plugin methods.
|
||||
|
||||
@param self pointer to the plugin instance
|
||||
@param connection_handle
|
||||
@param stage protocol stage in which tracing has started - currently
|
||||
it is always CONNECTING stage.
|
||||
|
||||
@return A pointer to plugin-specific, per-connection data if any.
|
||||
*/
|
||||
|
||||
typedef
|
||||
void* (tracing_start_callback)(struct st_mysql_client_plugin_TRACE *self,
|
||||
struct st_mysql *connection_handle,
|
||||
enum protocol_stage stage);
|
||||
|
||||
/**
|
||||
Trace plugin tracing_stop() method.
|
||||
|
||||
Called when tracing of the connection has ended. If a plugin
|
||||
allocated any per-connection resources, it should de-allocate them
|
||||
here.
|
||||
|
||||
@param self pointer to the plugin instance
|
||||
@param connection_handle
|
||||
@param plugin_data pointer to plugin's per-connection data.
|
||||
*/
|
||||
|
||||
typedef
|
||||
void (tracing_stop_callback)(struct st_mysql_client_plugin_TRACE *self,
|
||||
struct st_mysql *connection_handle,
|
||||
void *plugin_data);
|
||||
|
||||
/**
|
||||
Trace plugin trace_event() method.
|
||||
|
||||
Called when a trace event occurs. Plugin can decide to stop tracing
|
||||
this connection by returning non-zero value.
|
||||
|
||||
@param self pointer to the plugin instance
|
||||
@param plugin_data pointer to plugin's per-connection data
|
||||
@param connection_handle
|
||||
@param stage current protocol stage
|
||||
@param event the trace event
|
||||
@param args trace event arguments
|
||||
|
||||
@return Non-zero if tracing of the connection should end here.
|
||||
*/
|
||||
|
||||
typedef
|
||||
int (trace_event_handler)(struct st_mysql_client_plugin_TRACE *self,
|
||||
void *plugin_data,
|
||||
struct st_mysql *connection_handle,
|
||||
enum protocol_stage stage,
|
||||
enum trace_event event,
|
||||
struct st_trace_event_args args);
|
||||
|
||||
|
||||
struct st_mysql_client_plugin_TRACE
|
||||
{
|
||||
MYSQL_CLIENT_PLUGIN_HEADER
|
||||
tracing_start_callback *tracing_start;
|
||||
tracing_stop_callback *tracing_stop;
|
||||
trace_event_handler *trace_event;
|
||||
};
|
||||
|
||||
/**
|
||||
The global trace_plugin pointer. If it is not NULL, it points at a
|
||||
loaded trace plugin which should be used to trace all connections made
|
||||
to the server.
|
||||
*/
|
||||
extern
|
||||
struct st_mysql_client_plugin_TRACE *trace_plugin;
|
||||
|
||||
#ifndef DBUG_OFF
|
||||
|
||||
/*
|
||||
Functions for getting names of trace events and protocol
|
||||
stages for debugging purposes.
|
||||
*/
|
||||
const char* protocol_stage_name(enum protocol_stage stage);
|
||||
const char* trace_event_name(enum trace_event ev);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,96 +0,0 @@
|
|||
/* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
|
||||
|
||||
#ifndef MYSQL_IDLE_H
|
||||
#define MYSQL_IDLE_H
|
||||
|
||||
/**
|
||||
@file mysql/psi/mysql_idle.h
|
||||
Instrumentation helpers for idle waits.
|
||||
*/
|
||||
|
||||
#include "mysql/psi/psi.h"
|
||||
|
||||
#ifndef PSI_IDLE_CALL
|
||||
#define PSI_IDLE_CALL(M) PSI_DYNAMIC_CALL(M)
|
||||
#endif
|
||||
|
||||
/**
|
||||
@defgroup Idle_instrumentation Idle Instrumentation
|
||||
@ingroup Instrumentation_interface
|
||||
@{
|
||||
*/
|
||||
|
||||
/**
|
||||
@def MYSQL_START_IDLE_WAIT
|
||||
Instrumentation helper for table io_waits.
|
||||
This instrumentation marks the start of a wait event.
|
||||
@param LOCKER the locker
|
||||
@param STATE the locker state
|
||||
@sa MYSQL_END_IDLE_WAIT.
|
||||
*/
|
||||
#ifdef HAVE_PSI_IDLE_INTERFACE
|
||||
#define MYSQL_START_IDLE_WAIT(LOCKER, STATE) \
|
||||
LOCKER= inline_mysql_start_idle_wait(STATE, __FILE__, __LINE__)
|
||||
#else
|
||||
#define MYSQL_START_IDLE_WAIT(LOCKER, STATE) \
|
||||
do {} while (0)
|
||||
#endif
|
||||
|
||||
/**
|
||||
@def MYSQL_END_IDLE_WAIT
|
||||
Instrumentation helper for idle waits.
|
||||
This instrumentation marks the end of a wait event.
|
||||
@param LOCKER the locker
|
||||
@sa MYSQL_START_IDLE_WAIT.
|
||||
*/
|
||||
#ifdef HAVE_PSI_IDLE_INTERFACE
|
||||
#define MYSQL_END_IDLE_WAIT(LOCKER) \
|
||||
inline_mysql_end_idle_wait(LOCKER)
|
||||
#else
|
||||
#define MYSQL_END_IDLE_WAIT(LOCKER) \
|
||||
do {} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_IDLE_INTERFACE
|
||||
/**
|
||||
Instrumentation calls for MYSQL_START_IDLE_WAIT.
|
||||
@sa MYSQL_END_IDLE_WAIT.
|
||||
*/
|
||||
static inline struct PSI_idle_locker *
|
||||
inline_mysql_start_idle_wait(PSI_idle_locker_state *state,
|
||||
const char *src_file, int src_line)
|
||||
{
|
||||
struct PSI_idle_locker *locker;
|
||||
locker= PSI_IDLE_CALL(start_idle_wait)(state, src_file, src_line);
|
||||
return locker;
|
||||
}
|
||||
|
||||
/**
|
||||
Instrumentation calls for MYSQL_END_IDLE_WAIT.
|
||||
@sa MYSQL_START_IDLE_WAIT.
|
||||
*/
|
||||
static inline void
|
||||
inline_mysql_end_idle_wait(struct PSI_idle_locker *locker)
|
||||
{
|
||||
if (likely(locker != NULL))
|
||||
PSI_IDLE_CALL(end_idle_wait)(locker);
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} (end of group Idle_instrumentation) */
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,121 +0,0 @@
|
|||
/* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
|
||||
|
||||
#ifndef MYSQL_MDL_H
|
||||
#define MYSQL_MDL_H
|
||||
|
||||
/**
|
||||
@file mysql/psi/mysql_mdl.h
|
||||
Instrumentation helpers for metadata locks.
|
||||
*/
|
||||
|
||||
#include "mysql/psi/psi.h"
|
||||
|
||||
#ifndef PSI_METADATA_CALL
|
||||
#define PSI_METADATA_CALL(M) PSI_DYNAMIC_CALL(M)
|
||||
#endif
|
||||
|
||||
/**
|
||||
@defgroup Thread_instrumentation Metadata Instrumentation
|
||||
@ingroup Instrumentation_interface
|
||||
@{
|
||||
*/
|
||||
|
||||
/**
|
||||
@def mysql_mdl_create(K, M, A)
|
||||
Instrumented metadata lock creation.
|
||||
@param I Metadata lock identity
|
||||
@param K Metadata key
|
||||
@param T Metadata lock type
|
||||
@param D Metadata lock duration
|
||||
@param S Metadata lock status
|
||||
@param F request source file
|
||||
@param L request source line
|
||||
*/
|
||||
|
||||
#ifdef HAVE_PSI_METADATA_INTERFACE
|
||||
#define mysql_mdl_create(I, K, T, D, S, F, L) \
|
||||
inline_mysql_mdl_create(I, K, T, D, S, F, L)
|
||||
#else
|
||||
#define mysql_mdl_create(I, K, T, D, S, F, L) NULL
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_METADATA_INTERFACE
|
||||
#define mysql_mdl_set_status(L, S) \
|
||||
inline_mysql_mdl_set_status(L, S)
|
||||
#else
|
||||
#define mysql_mdl_set_status(L, S) \
|
||||
do {} while (0)
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
@def mysql_mdl_destroy(M)
|
||||
Instrumented metadata lock destruction.
|
||||
@param M Metadata lock
|
||||
*/
|
||||
#ifdef HAVE_PSI_METADATA_INTERFACE
|
||||
#define mysql_mdl_destroy(M) \
|
||||
inline_mysql_mdl_destroy(M, __FILE__, __LINE__)
|
||||
#else
|
||||
#define mysql_mdl_destroy(M) \
|
||||
do {} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_METADATA_INTERFACE
|
||||
|
||||
static inline PSI_metadata_lock *
|
||||
inline_mysql_mdl_create(void *identity,
|
||||
const MDL_key *mdl_key,
|
||||
enum_mdl_type mdl_type,
|
||||
enum_mdl_duration mdl_duration,
|
||||
MDL_ticket::enum_psi_status mdl_status,
|
||||
const char *src_file, uint src_line)
|
||||
{
|
||||
PSI_metadata_lock *result;
|
||||
|
||||
/* static_cast: Fit a round C++ enum peg into a square C int hole ... */
|
||||
result= PSI_METADATA_CALL(create_metadata_lock)
|
||||
(identity,
|
||||
mdl_key,
|
||||
static_cast<opaque_mdl_type> (mdl_type),
|
||||
static_cast<opaque_mdl_duration> (mdl_duration),
|
||||
static_cast<opaque_mdl_status> (mdl_status),
|
||||
src_file, src_line);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline void inline_mysql_mdl_set_status(
|
||||
PSI_metadata_lock *psi,
|
||||
MDL_ticket::enum_psi_status mdl_status)
|
||||
{
|
||||
if (psi != NULL)
|
||||
PSI_METADATA_CALL(set_metadata_lock_status)(psi, mdl_status);
|
||||
}
|
||||
|
||||
static inline void inline_mysql_mdl_destroy(
|
||||
PSI_metadata_lock *psi,
|
||||
const char *src_file, uint src_line)
|
||||
{
|
||||
if (psi != NULL)
|
||||
PSI_METADATA_CALL(destroy_metadata_lock)(psi);
|
||||
}
|
||||
#endif /* HAVE_PSI_METADATA_INTERFACE */
|
||||
|
||||
/** @} (end of group Metadata_instrumentation) */
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
/* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
|
||||
|
||||
#ifndef MYSQL_MEMORY_H
|
||||
#define MYSQL_MEMORY_H
|
||||
|
||||
/**
|
||||
@file mysql/psi/mysql_memory.h
|
||||
Instrumentation helpers for memory allocation.
|
||||
*/
|
||||
|
||||
#include "mysql/psi/psi.h"
|
||||
|
||||
#ifndef PSI_MEMORY_CALL
|
||||
#define PSI_MEMORY_CALL(M) PSI_DYNAMIC_CALL(M)
|
||||
#endif
|
||||
|
||||
/**
|
||||
@defgroup Memory_instrumentation Memory Instrumentation
|
||||
@ingroup Instrumentation_interface
|
||||
@{
|
||||
*/
|
||||
|
||||
/**
|
||||
@def mysql_memory_register(P1, P2, P3)
|
||||
Memory registration.
|
||||
*/
|
||||
#define mysql_memory_register(P1, P2, P3) \
|
||||
inline_mysql_memory_register(P1, P2, P3)
|
||||
|
||||
static inline void inline_mysql_memory_register(
|
||||
#ifdef HAVE_PSI_MEMORY_INTERFACE
|
||||
const char *category,
|
||||
PSI_memory_info *info,
|
||||
int count)
|
||||
#else
|
||||
const char *category MY_ATTRIBUTE((unused)),
|
||||
void *info MY_ATTRIBUTE((unused)),
|
||||
int count MY_ATTRIBUTE((unused)))
|
||||
#endif
|
||||
{
|
||||
#ifdef HAVE_PSI_MEMORY_INTERFACE
|
||||
PSI_MEMORY_CALL(register_memory)(category, info, count);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** @} (end of group Memory_instrumentation) */
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,88 +0,0 @@
|
|||
/* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#ifndef MYSQL_PS_H
|
||||
#define MYSQL_PS_H
|
||||
|
||||
/**
|
||||
@file mysql/psi/mysql_ps.h
|
||||
Instrumentation helpers for prepared statements.
|
||||
*/
|
||||
|
||||
#include "mysql/psi/psi.h"
|
||||
|
||||
#ifndef PSI_PS_CALL
|
||||
#define PSI_PS_CALL(M) PSI_DYNAMIC_CALL(M)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_PS_INTERFACE
|
||||
#define MYSQL_CREATE_PS(IDENTITY, ID, LOCKER, NAME, NAME_LENGTH, SQLTEXT, SQLTEXT_LENGTH) \
|
||||
inline_mysql_create_prepared_stmt(IDENTITY, ID, LOCKER, NAME, NAME_LENGTH, SQLTEXT, SQLTEXT_LENGTH)
|
||||
#define MYSQL_EXECUTE_PS(LOCKER, PREPARED_STMT) \
|
||||
inline_mysql_execute_prepared_stmt(LOCKER, PREPARED_STMT)
|
||||
#define MYSQL_DESTROY_PS(PREPARED_STMT) \
|
||||
inline_mysql_destroy_prepared_stmt(PREPARED_STMT)
|
||||
#define MYSQL_REPREPARE_PS(PREPARED_STMT) \
|
||||
inline_mysql_reprepare_prepared_stmt(PREPARED_STMT)
|
||||
#else
|
||||
#define MYSQL_CREATE_PS(IDENTITY, ID, LOCKER, NAME, NAME_LENGTH, SQLTEXT, SQLTEXT_LENGTH) \
|
||||
NULL
|
||||
#define MYSQL_EXECUTE_PS(LOCKER, PREPARED_STMT) \
|
||||
do {} while (0)
|
||||
#define MYSQL_DESTROY_PS(PREPARED_STMT) \
|
||||
do {} while (0)
|
||||
#define MYSQL_REPREPARE_PS(PREPARED_STMT) \
|
||||
do {} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_PS_INTERFACE
|
||||
static inline struct PSI_prepared_stmt*
|
||||
inline_mysql_create_prepared_stmt(void *identity, uint stmt_id,
|
||||
PSI_statement_locker *locker,
|
||||
const char *stmt_name, size_t stmt_name_length,
|
||||
const char *sqltext, size_t sqltext_length)
|
||||
{
|
||||
if (locker == NULL)
|
||||
return NULL;
|
||||
return PSI_PS_CALL(create_prepared_stmt)(identity, stmt_id,
|
||||
locker,
|
||||
stmt_name, stmt_name_length,
|
||||
sqltext, sqltext_length);
|
||||
}
|
||||
|
||||
static inline void
|
||||
inline_mysql_execute_prepared_stmt(PSI_statement_locker *locker,
|
||||
PSI_prepared_stmt* prepared_stmt)
|
||||
{
|
||||
if (prepared_stmt != NULL && locker != NULL)
|
||||
PSI_PS_CALL(execute_prepared_stmt)(locker, prepared_stmt);
|
||||
}
|
||||
|
||||
static inline void
|
||||
inline_mysql_destroy_prepared_stmt(PSI_prepared_stmt *prepared_stmt)
|
||||
{
|
||||
if (prepared_stmt != NULL)
|
||||
PSI_PS_CALL(destroy_prepared_stmt)(prepared_stmt);
|
||||
}
|
||||
|
||||
static inline void
|
||||
inline_mysql_reprepare_prepared_stmt(PSI_prepared_stmt *prepared_stmt)
|
||||
{
|
||||
if (prepared_stmt != NULL)
|
||||
PSI_PS_CALL(reprepare_prepared_stmt)(prepared_stmt);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,97 +0,0 @@
|
|||
/* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#ifndef MYSQL_SP_H
|
||||
#define MYSQL_SP_H
|
||||
|
||||
/**
|
||||
@file mysql/psi/mysql_sp.h
|
||||
Instrumentation helpers for stored programs.
|
||||
*/
|
||||
|
||||
#include "mysql/psi/psi.h"
|
||||
|
||||
#ifndef PSI_SP_CALL
|
||||
#define PSI_SP_CALL(M) PSI_DYNAMIC_CALL(M)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_SP_INTERFACE
|
||||
#define MYSQL_START_SP(STATE, SP_SHARE) \
|
||||
inline_mysql_start_sp(STATE, SP_SHARE)
|
||||
#else
|
||||
#define MYSQL_START_SP(STATE, SP_SHARE) \
|
||||
NULL
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE_PSI_SP_INTERFACE
|
||||
#define MYSQL_END_SP(LOCKER) \
|
||||
inline_mysql_end_sp(LOCKER)
|
||||
#else
|
||||
#define MYSQL_END_SP(LOCKER) \
|
||||
do {} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_SP_INTERFACE
|
||||
#define MYSQL_DROP_SP(OT, SN, SNL, ON, ONL) \
|
||||
inline_mysql_drop_sp(OT, SN, SNL, ON, ONL)
|
||||
#else
|
||||
#define MYSQL_DROP_SP(OT, SN, SNL, ON, ONL) \
|
||||
do {} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_SP_INTERFACE
|
||||
#define MYSQL_GET_SP_SHARE(OT, SN, SNL, ON, ONL) \
|
||||
inline_mysql_get_sp_share(OT, SN, SNL, ON, ONL)
|
||||
#else
|
||||
#define MYSQL_GET_SP_SHARE(OT, SN, SNL, ON, ONL) \
|
||||
NULL
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_SP_INTERFACE
|
||||
static inline struct PSI_sp_locker*
|
||||
inline_mysql_start_sp(PSI_sp_locker_state *state, PSI_sp_share *sp_share)
|
||||
{
|
||||
return PSI_SP_CALL(start_sp)(state, sp_share);
|
||||
}
|
||||
|
||||
static inline void inline_mysql_end_sp(PSI_sp_locker *locker)
|
||||
{
|
||||
if (likely(locker != NULL))
|
||||
PSI_SP_CALL(end_sp)(locker);
|
||||
}
|
||||
|
||||
static inline void
|
||||
inline_mysql_drop_sp(uint sp_type,
|
||||
const char* schema_name, uint shcema_name_length,
|
||||
const char* object_name, uint object_name_length)
|
||||
{
|
||||
PSI_SP_CALL(drop_sp)(sp_type,
|
||||
schema_name, shcema_name_length,
|
||||
object_name, object_name_length);
|
||||
}
|
||||
|
||||
static inline PSI_sp_share*
|
||||
inline_mysql_get_sp_share(uint sp_type,
|
||||
const char* schema_name, uint shcema_name_length,
|
||||
const char* object_name, uint object_name_length)
|
||||
{
|
||||
return PSI_SP_CALL(get_sp_share)(sp_type,
|
||||
schema_name, shcema_name_length,
|
||||
object_name, object_name_length);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,198 +0,0 @@
|
|||
/* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#ifndef MYSQL_STAGE_H
|
||||
#define MYSQL_STAGE_H
|
||||
|
||||
/**
|
||||
@file mysql/psi/mysql_stage.h
|
||||
Instrumentation helpers for stages.
|
||||
*/
|
||||
|
||||
#include "mysql/psi/psi.h"
|
||||
|
||||
#ifndef PSI_STAGE_CALL
|
||||
#define PSI_STAGE_CALL(M) PSI_DYNAMIC_CALL(M)
|
||||
#endif
|
||||
|
||||
/**
|
||||
@defgroup Stage_instrumentation Stage Instrumentation
|
||||
@ingroup Instrumentation_interface
|
||||
@{
|
||||
*/
|
||||
|
||||
/**
|
||||
@def mysql_stage_register(P1, P2, P3)
|
||||
Stage registration.
|
||||
*/
|
||||
#ifdef HAVE_PSI_STAGE_INTERFACE
|
||||
#define mysql_stage_register(P1, P2, P3) \
|
||||
inline_mysql_stage_register(P1, P2, P3)
|
||||
#else
|
||||
#define mysql_stage_register(P1, P2, P3) \
|
||||
do {} while (0)
|
||||
#endif
|
||||
|
||||
/**
|
||||
@def MYSQL_SET_STAGE
|
||||
Set the current stage.
|
||||
Use this API when the file and line
|
||||
is passed from the caller.
|
||||
@param K the stage key
|
||||
@param F the source file name
|
||||
@param L the source file line
|
||||
@return the current stage progress
|
||||
*/
|
||||
#ifdef HAVE_PSI_STAGE_INTERFACE
|
||||
#define MYSQL_SET_STAGE(K, F, L) \
|
||||
inline_mysql_set_stage(K, F, L)
|
||||
#else
|
||||
#define MYSQL_SET_STAGE(K, F, L) \
|
||||
NULL
|
||||
#endif
|
||||
|
||||
/**
|
||||
@def mysql_set_stage
|
||||
Set the current stage.
|
||||
@param K the stage key
|
||||
@return the current stage progress
|
||||
*/
|
||||
#ifdef HAVE_PSI_STAGE_INTERFACE
|
||||
#define mysql_set_stage(K) \
|
||||
inline_mysql_set_stage(K, __FILE__, __LINE__)
|
||||
#else
|
||||
#define mysql_set_stage(K) \
|
||||
NULL
|
||||
#endif
|
||||
|
||||
/**
|
||||
@def mysql_end_stage
|
||||
End the last stage
|
||||
*/
|
||||
#ifdef HAVE_PSI_STAGE_INTERFACE
|
||||
#define mysql_end_stage \
|
||||
inline_mysql_end_stage
|
||||
#else
|
||||
#define mysql_end_stage \
|
||||
do {} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_STAGE_INTERFACE
|
||||
static inline void inline_mysql_stage_register(
|
||||
const char *category, PSI_stage_info **info, int count)
|
||||
{
|
||||
PSI_STAGE_CALL(register_stage)(category, info, count);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_STAGE_INTERFACE
|
||||
static inline PSI_stage_progress*
|
||||
inline_mysql_set_stage(PSI_stage_key key,
|
||||
const char *src_file, int src_line)
|
||||
{
|
||||
return PSI_STAGE_CALL(start_stage)(key, src_file, src_line);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_STAGE_INTERFACE
|
||||
static inline void
|
||||
inline_mysql_end_stage()
|
||||
{
|
||||
PSI_STAGE_CALL(end_stage)();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_STAGE_INTERFACE
|
||||
#define mysql_stage_set_work_completed(P1, P2) \
|
||||
inline_mysql_stage_set_work_completed(P1, P2)
|
||||
|
||||
#define mysql_stage_get_work_completed(P1) \
|
||||
inline_mysql_stage_get_work_completed(P1)
|
||||
#else
|
||||
#define mysql_stage_set_work_completed(P1, P2) \
|
||||
do {} while (0)
|
||||
|
||||
#define mysql_stage_get_work_completed(P1) \
|
||||
do {} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_STAGE_INTERFACE
|
||||
#define mysql_stage_inc_work_completed(P1, P2) \
|
||||
inline_mysql_stage_inc_work_completed(P1, P2)
|
||||
#else
|
||||
#define mysql_stage_inc_work_completed(P1, P2) \
|
||||
do {} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_STAGE_INTERFACE
|
||||
#define mysql_stage_set_work_estimated(P1, P2) \
|
||||
inline_mysql_stage_set_work_estimated(P1, P2)
|
||||
|
||||
#define mysql_stage_get_work_estimated(P1) \
|
||||
inline_mysql_stage_get_work_estimated(P1)
|
||||
#else
|
||||
#define mysql_stage_set_work_estimated(P1, P2) \
|
||||
do {} while (0)
|
||||
|
||||
#define mysql_stage_get_work_estimated(P1) \
|
||||
do {} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_STAGE_INTERFACE
|
||||
static inline void
|
||||
inline_mysql_stage_set_work_completed(PSI_stage_progress *progress,
|
||||
ulonglong val)
|
||||
{
|
||||
if (progress != NULL)
|
||||
progress->m_work_completed= val;
|
||||
}
|
||||
|
||||
static inline ulonglong
|
||||
inline_mysql_stage_get_work_completed(PSI_stage_progress *progress)
|
||||
{
|
||||
return progress->m_work_completed;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_STAGE_INTERFACE
|
||||
static inline void
|
||||
inline_mysql_stage_inc_work_completed(PSI_stage_progress *progress,
|
||||
ulonglong val)
|
||||
{
|
||||
if (progress != NULL)
|
||||
progress->m_work_completed+= val;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_STAGE_INTERFACE
|
||||
static inline void
|
||||
inline_mysql_stage_set_work_estimated(PSI_stage_progress *progress,
|
||||
ulonglong val)
|
||||
{
|
||||
if (progress != NULL)
|
||||
progress->m_work_estimated= val;
|
||||
}
|
||||
|
||||
static inline ulonglong
|
||||
inline_mysql_stage_get_work_estimated(PSI_stage_progress *progress)
|
||||
{
|
||||
return progress->m_work_estimated;
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} (end of group Stage_instrumentation) */
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,235 +0,0 @@
|
|||
/* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#ifndef MYSQL_STATEMENT_H
|
||||
#define MYSQL_STATEMENT_H
|
||||
|
||||
/**
|
||||
@file mysql/psi/mysql_statement.h
|
||||
Instrumentation helpers for statements.
|
||||
*/
|
||||
|
||||
#include "mysql/psi/psi.h"
|
||||
|
||||
class Diagnostics_area;
|
||||
typedef struct charset_info_st CHARSET_INFO;
|
||||
|
||||
#ifndef PSI_STATEMENT_CALL
|
||||
#define PSI_STATEMENT_CALL(M) PSI_DYNAMIC_CALL(M)
|
||||
#endif
|
||||
|
||||
#ifndef PSI_DIGEST_CALL
|
||||
#define PSI_DIGEST_CALL(M) PSI_DYNAMIC_CALL(M)
|
||||
#endif
|
||||
|
||||
/**
|
||||
@defgroup Statement_instrumentation Statement Instrumentation
|
||||
@ingroup Instrumentation_interface
|
||||
@{
|
||||
*/
|
||||
|
||||
/**
|
||||
@def mysql_statement_register(P1, P2, P3)
|
||||
Statement registration.
|
||||
*/
|
||||
#ifdef HAVE_PSI_STATEMENT_INTERFACE
|
||||
#define mysql_statement_register(P1, P2, P3) \
|
||||
inline_mysql_statement_register(P1, P2, P3)
|
||||
#else
|
||||
#define mysql_statement_register(P1, P2, P3) \
|
||||
do {} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_STATEMENT_DIGEST_INTERFACE
|
||||
#define MYSQL_DIGEST_START(LOCKER) \
|
||||
inline_mysql_digest_start(LOCKER)
|
||||
#else
|
||||
#define MYSQL_DIGEST_START(LOCKER) \
|
||||
NULL
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_STATEMENT_DIGEST_INTERFACE
|
||||
#define MYSQL_DIGEST_END(LOCKER, DIGEST) \
|
||||
inline_mysql_digest_end(LOCKER, DIGEST)
|
||||
#else
|
||||
#define MYSQL_DIGEST_END(LOCKER, DIGEST) \
|
||||
do {} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_STATEMENT_INTERFACE
|
||||
#define MYSQL_START_STATEMENT(STATE, K, DB, DB_LEN, CS, SPS) \
|
||||
inline_mysql_start_statement(STATE, K, DB, DB_LEN, CS, SPS, __FILE__, __LINE__)
|
||||
#else
|
||||
#define MYSQL_START_STATEMENT(STATE, K, DB, DB_LEN, CS, SPS) \
|
||||
NULL
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_STATEMENT_INTERFACE
|
||||
#define MYSQL_REFINE_STATEMENT(LOCKER, K) \
|
||||
inline_mysql_refine_statement(LOCKER, K)
|
||||
#else
|
||||
#define MYSQL_REFINE_STATEMENT(LOCKER, K) \
|
||||
NULL
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_STATEMENT_INTERFACE
|
||||
#define MYSQL_SET_STATEMENT_TEXT(LOCKER, P1, P2) \
|
||||
inline_mysql_set_statement_text(LOCKER, P1, P2)
|
||||
#else
|
||||
#define MYSQL_SET_STATEMENT_TEXT(LOCKER, P1, P2) \
|
||||
do {} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_STATEMENT_INTERFACE
|
||||
#define MYSQL_SET_STATEMENT_LOCK_TIME(LOCKER, P1) \
|
||||
inline_mysql_set_statement_lock_time(LOCKER, P1)
|
||||
#else
|
||||
#define MYSQL_SET_STATEMENT_LOCK_TIME(LOCKER, P1) \
|
||||
do {} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_STATEMENT_INTERFACE
|
||||
#define MYSQL_SET_STATEMENT_ROWS_SENT(LOCKER, P1) \
|
||||
inline_mysql_set_statement_rows_sent(LOCKER, P1)
|
||||
#else
|
||||
#define MYSQL_SET_STATEMENT_ROWS_SENT(LOCKER, P1) \
|
||||
do {} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_STATEMENT_INTERFACE
|
||||
#define MYSQL_SET_STATEMENT_ROWS_EXAMINED(LOCKER, P1) \
|
||||
inline_mysql_set_statement_rows_examined(LOCKER, P1)
|
||||
#else
|
||||
#define MYSQL_SET_STATEMENT_ROWS_EXAMINED(LOCKER, P1) \
|
||||
do {} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_STATEMENT_INTERFACE
|
||||
#define MYSQL_END_STATEMENT(LOCKER, DA) \
|
||||
inline_mysql_end_statement(LOCKER, DA)
|
||||
#else
|
||||
#define MYSQL_END_STATEMENT(LOCKER, DA) \
|
||||
do {} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_STATEMENT_INTERFACE
|
||||
static inline void inline_mysql_statement_register(
|
||||
const char *category, PSI_statement_info *info, int count)
|
||||
{
|
||||
PSI_STATEMENT_CALL(register_statement)(category, info, count);
|
||||
}
|
||||
|
||||
#ifdef HAVE_PSI_STATEMENT_DIGEST_INTERFACE
|
||||
static inline struct PSI_digest_locker *
|
||||
inline_mysql_digest_start(PSI_statement_locker *locker)
|
||||
{
|
||||
PSI_digest_locker* digest_locker= NULL;
|
||||
|
||||
if (likely(locker != NULL))
|
||||
digest_locker= PSI_DIGEST_CALL(digest_start)(locker);
|
||||
return digest_locker;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_STATEMENT_DIGEST_INTERFACE
|
||||
static inline void
|
||||
inline_mysql_digest_end(PSI_digest_locker *locker, const sql_digest_storage *digest)
|
||||
{
|
||||
if (likely(locker != NULL))
|
||||
PSI_DIGEST_CALL(digest_end)(locker, digest);
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline struct PSI_statement_locker *
|
||||
inline_mysql_start_statement(PSI_statement_locker_state *state,
|
||||
PSI_statement_key key,
|
||||
const char *db, uint db_len,
|
||||
const CHARSET_INFO *charset,
|
||||
PSI_sp_share *sp_share,
|
||||
const char *src_file, int src_line)
|
||||
{
|
||||
PSI_statement_locker *locker;
|
||||
locker= PSI_STATEMENT_CALL(get_thread_statement_locker)(state, key, charset,
|
||||
sp_share);
|
||||
if (likely(locker != NULL))
|
||||
PSI_STATEMENT_CALL(start_statement)(locker, db, db_len, src_file, src_line);
|
||||
return locker;
|
||||
}
|
||||
|
||||
static inline struct PSI_statement_locker *
|
||||
inline_mysql_refine_statement(PSI_statement_locker *locker,
|
||||
PSI_statement_key key)
|
||||
{
|
||||
if (likely(locker != NULL))
|
||||
{
|
||||
locker= PSI_STATEMENT_CALL(refine_statement)(locker, key);
|
||||
}
|
||||
return locker;
|
||||
}
|
||||
|
||||
static inline void
|
||||
inline_mysql_set_statement_text(PSI_statement_locker *locker,
|
||||
const char *text, uint text_len)
|
||||
{
|
||||
if (likely(locker != NULL))
|
||||
{
|
||||
PSI_STATEMENT_CALL(set_statement_text)(locker, text, text_len);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
inline_mysql_set_statement_lock_time(PSI_statement_locker *locker,
|
||||
ulonglong count)
|
||||
{
|
||||
if (likely(locker != NULL))
|
||||
{
|
||||
PSI_STATEMENT_CALL(set_statement_lock_time)(locker, count);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
inline_mysql_set_statement_rows_sent(PSI_statement_locker *locker,
|
||||
ulonglong count)
|
||||
{
|
||||
if (likely(locker != NULL))
|
||||
{
|
||||
PSI_STATEMENT_CALL(set_statement_rows_sent)(locker, count);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
inline_mysql_set_statement_rows_examined(PSI_statement_locker *locker,
|
||||
ulonglong count)
|
||||
{
|
||||
if (likely(locker != NULL))
|
||||
{
|
||||
PSI_STATEMENT_CALL(set_statement_rows_examined)(locker, count);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
inline_mysql_end_statement(struct PSI_statement_locker *locker,
|
||||
Diagnostics_area *stmt_da)
|
||||
{
|
||||
PSI_STAGE_CALL(end_stage)();
|
||||
if (likely(locker != NULL))
|
||||
PSI_STATEMENT_CALL(end_statement)(locker, stmt_da);
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} (end of group Statement_instrumentation) */
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,142 +0,0 @@
|
|||
/* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
|
||||
|
||||
#ifndef MYSQL_TABLE_H
|
||||
#define MYSQL_TABLE_H
|
||||
|
||||
/**
|
||||
@file mysql/psi/mysql_table.h
|
||||
Instrumentation helpers for table io.
|
||||
*/
|
||||
|
||||
#include "mysql/psi/psi.h"
|
||||
|
||||
#ifndef PSI_TABLE_CALL
|
||||
#define PSI_TABLE_CALL(M) PSI_DYNAMIC_CALL(M)
|
||||
#endif
|
||||
|
||||
/**
|
||||
@defgroup Table_instrumentation Table Instrumentation
|
||||
@ingroup Instrumentation_interface
|
||||
@{
|
||||
*/
|
||||
|
||||
/**
|
||||
@def MYSQL_TABLE_WAIT_VARIABLES
|
||||
Instrumentation helper for table waits.
|
||||
This instrumentation declares local variables.
|
||||
Do not use a ';' after this macro
|
||||
@param LOCKER the locker
|
||||
@param STATE the locker state
|
||||
@sa MYSQL_START_TABLE_IO_WAIT.
|
||||
@sa MYSQL_END_TABLE_IO_WAIT.
|
||||
@sa MYSQL_START_TABLE_LOCK_WAIT.
|
||||
@sa MYSQL_END_TABLE_LOCK_WAIT.
|
||||
*/
|
||||
#ifdef HAVE_PSI_TABLE_INTERFACE
|
||||
#define MYSQL_TABLE_WAIT_VARIABLES(LOCKER, STATE) \
|
||||
struct PSI_table_locker* LOCKER; \
|
||||
PSI_table_locker_state STATE;
|
||||
#else
|
||||
#define MYSQL_TABLE_WAIT_VARIABLES(LOCKER, STATE)
|
||||
#endif
|
||||
|
||||
/**
|
||||
@def MYSQL_START_TABLE_LOCK_WAIT
|
||||
Instrumentation helper for table lock waits.
|
||||
This instrumentation marks the start of a wait event.
|
||||
@param LOCKER the locker
|
||||
@param STATE the locker state
|
||||
@param PSI the instrumented table
|
||||
@param OP the table operation to be performed
|
||||
@param FLAGS per table operation flags.
|
||||
@sa MYSQL_END_TABLE_LOCK_WAIT.
|
||||
*/
|
||||
#ifdef HAVE_PSI_TABLE_INTERFACE
|
||||
#define MYSQL_START_TABLE_LOCK_WAIT(LOCKER, STATE, PSI, OP, FLAGS) \
|
||||
LOCKER= inline_mysql_start_table_lock_wait(STATE, PSI, \
|
||||
OP, FLAGS, __FILE__, __LINE__)
|
||||
#else
|
||||
#define MYSQL_START_TABLE_LOCK_WAIT(LOCKER, STATE, PSI, OP, FLAGS) \
|
||||
do {} while (0)
|
||||
#endif
|
||||
|
||||
/**
|
||||
@def MYSQL_END_TABLE_LOCK_WAIT
|
||||
Instrumentation helper for table lock waits.
|
||||
This instrumentation marks the end of a wait event.
|
||||
@param LOCKER the locker
|
||||
@sa MYSQL_START_TABLE_LOCK_WAIT.
|
||||
*/
|
||||
#ifdef HAVE_PSI_TABLE_INTERFACE
|
||||
#define MYSQL_END_TABLE_LOCK_WAIT(LOCKER) \
|
||||
inline_mysql_end_table_lock_wait(LOCKER)
|
||||
#else
|
||||
#define MYSQL_END_TABLE_LOCK_WAIT(LOCKER) \
|
||||
do {} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_TABLE_INTERFACE
|
||||
#define MYSQL_UNLOCK_TABLE(T) \
|
||||
inline_mysql_unlock_table(T)
|
||||
#else
|
||||
#define MYSQL_UNLOCK_TABLE(T) \
|
||||
do {} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_TABLE_INTERFACE
|
||||
/**
|
||||
Instrumentation calls for MYSQL_START_TABLE_LOCK_WAIT.
|
||||
@sa MYSQL_END_TABLE_LOCK_WAIT.
|
||||
*/
|
||||
static inline struct PSI_table_locker *
|
||||
inline_mysql_start_table_lock_wait(PSI_table_locker_state *state,
|
||||
struct PSI_table *psi,
|
||||
enum PSI_table_lock_operation op,
|
||||
ulong flags, const char *src_file, int src_line)
|
||||
{
|
||||
if (psi != NULL)
|
||||
{
|
||||
struct PSI_table_locker *locker;
|
||||
locker= PSI_TABLE_CALL(start_table_lock_wait)
|
||||
(state, psi, op, flags, src_file, src_line);
|
||||
return locker;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
Instrumentation calls for MYSQL_END_TABLE_LOCK_WAIT.
|
||||
@sa MYSQL_START_TABLE_LOCK_WAIT.
|
||||
*/
|
||||
static inline void
|
||||
inline_mysql_end_table_lock_wait(struct PSI_table_locker *locker)
|
||||
{
|
||||
if (locker != NULL)
|
||||
PSI_TABLE_CALL(end_table_lock_wait)(locker);
|
||||
}
|
||||
|
||||
static inline void
|
||||
inline_mysql_unlock_table(struct PSI_table *table)
|
||||
{
|
||||
if (table != NULL)
|
||||
PSI_TABLE_CALL(unlock_table)(table);
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} (end of group Table_instrumentation) */
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,213 +0,0 @@
|
|||
/* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#ifndef MYSQL_TRANSACTION_H
|
||||
#define MYSQL_TRANSACTION_H
|
||||
|
||||
/**
|
||||
@file mysql/psi/mysql_transaction.h
|
||||
Instrumentation helpers for transactions.
|
||||
*/
|
||||
|
||||
#include "mysql/psi/psi.h"
|
||||
|
||||
#ifndef PSI_TRANSACTION_CALL
|
||||
#define PSI_TRANSACTION_CALL(M) PSI_DYNAMIC_CALL(M)
|
||||
#endif
|
||||
|
||||
/**
|
||||
@defgroup Transaction_instrumentation Transaction Instrumentation
|
||||
@ingroup Instrumentation_interface
|
||||
@{
|
||||
*/
|
||||
|
||||
#ifdef HAVE_PSI_TRANSACTION_INTERFACE
|
||||
#define MYSQL_START_TRANSACTION(STATE, XID, TRXID, ISO, RO, AC) \
|
||||
inline_mysql_start_transaction(STATE, XID, TRXID, ISO, RO, AC, __FILE__, __LINE__)
|
||||
#else
|
||||
#define MYSQL_START_TRANSACTION(STATE, XID, TRXID, ISO, RO, AC) \
|
||||
do {} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_TRANSACTION_INTERFACE
|
||||
#define MYSQL_SET_TRANSACTION_GTID(LOCKER, P1, P2) \
|
||||
inline_mysql_set_transaction_gtid(LOCKER, P1, P2)
|
||||
#else
|
||||
#define MYSQL_SET_TRANSACTION_GTID(LOCKER, P1, P2) \
|
||||
do {} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_TRANSACTION_INTERFACE
|
||||
#define MYSQL_SET_TRANSACTION_XID(LOCKER, P1, P2) \
|
||||
inline_mysql_set_transaction_xid(LOCKER, P1, P2)
|
||||
#else
|
||||
#define MYSQL_SET_TRANSACTION_XID(LOCKER, P1, P2) \
|
||||
do {} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_TRANSACTION_INTERFACE
|
||||
#define MYSQL_SET_TRANSACTION_XA_STATE(LOCKER, P1) \
|
||||
inline_mysql_set_transaction_xa_state(LOCKER, P1)
|
||||
#else
|
||||
#define MYSQL_SET_TRANSACTION_XA_STATE(LOCKER, P1) \
|
||||
do {} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_TRANSACTION_INTERFACE
|
||||
#define MYSQL_SET_TRANSACTION_TRXID(LOCKER, P1) \
|
||||
inline_mysql_set_transaction_trxid(LOCKER, P1)
|
||||
#else
|
||||
#define MYSQL_SET_TRANSACTION_TRXID(LOCKER, P1) \
|
||||
do {} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_TRANSACTION_INTERFACE
|
||||
#define MYSQL_INC_TRANSACTION_SAVEPOINTS(LOCKER, P1) \
|
||||
inline_mysql_inc_transaction_savepoints(LOCKER, P1)
|
||||
#else
|
||||
#define MYSQL_INC_TRANSACTION_SAVEPOINTS(LOCKER, P1) \
|
||||
do {} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_TRANSACTION_INTERFACE
|
||||
#define MYSQL_INC_TRANSACTION_ROLLBACK_TO_SAVEPOINT(LOCKER, P1) \
|
||||
inline_mysql_inc_transaction_rollback_to_savepoint(LOCKER, P1)
|
||||
#else
|
||||
#define MYSQL_INC_TRANSACTION_ROLLBACK_TO_SAVEPOINT(LOCKER, P1) \
|
||||
do {} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_TRANSACTION_INTERFACE
|
||||
#define MYSQL_INC_TRANSACTION_RELEASE_SAVEPOINT(LOCKER, P1) \
|
||||
inline_mysql_inc_transaction_release_savepoint(LOCKER, P1)
|
||||
#else
|
||||
#define MYSQL_INC_TRANSACTION_RELEASE_SAVEPOINT(LOCKER, P1) \
|
||||
do {} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_TRANSACTION_INTERFACE
|
||||
#define MYSQL_ROLLBACK_TRANSACTION(LOCKER) \
|
||||
inline_mysql_rollback_transaction(LOCKER)
|
||||
#else
|
||||
#define MYSQL_ROLLBACK_TRANSACTION(LOCKER) \
|
||||
NULL
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_TRANSACTION_INTERFACE
|
||||
#define MYSQL_COMMIT_TRANSACTION(LOCKER) \
|
||||
inline_mysql_commit_transaction(LOCKER)
|
||||
#else
|
||||
#define MYSQL_COMMIT_TRANSACTION(LOCKER) \
|
||||
NULL
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_TRANSACTION_INTERFACE
|
||||
static inline struct PSI_transaction_locker *
|
||||
inline_mysql_start_transaction(PSI_transaction_locker_state *state,
|
||||
const void *xid,
|
||||
const ulonglong *trxid,
|
||||
int isolation_level,
|
||||
my_bool read_only,
|
||||
my_bool autocommit,
|
||||
const char *src_file, int src_line)
|
||||
{
|
||||
PSI_transaction_locker *locker;
|
||||
locker= PSI_TRANSACTION_CALL(get_thread_transaction_locker)(state,
|
||||
xid, trxid,
|
||||
isolation_level,
|
||||
read_only,
|
||||
autocommit);
|
||||
if (likely(locker != NULL))
|
||||
PSI_TRANSACTION_CALL(start_transaction)(locker, src_file, src_line);
|
||||
return locker;
|
||||
}
|
||||
|
||||
static inline void
|
||||
inline_mysql_set_transaction_gtid(PSI_transaction_locker *locker,
|
||||
const void *sid,
|
||||
const void *gtid_spec)
|
||||
{
|
||||
if (likely(locker != NULL))
|
||||
PSI_TRANSACTION_CALL(set_transaction_gtid)(locker, sid, gtid_spec);
|
||||
}
|
||||
|
||||
static inline void
|
||||
inline_mysql_set_transaction_xid(PSI_transaction_locker *locker,
|
||||
const void *xid,
|
||||
int xa_state)
|
||||
{
|
||||
if (likely(locker != NULL))
|
||||
PSI_TRANSACTION_CALL(set_transaction_xid)(locker, xid, xa_state);
|
||||
}
|
||||
|
||||
static inline void
|
||||
inline_mysql_set_transaction_xa_state(PSI_transaction_locker *locker,
|
||||
int xa_state)
|
||||
{
|
||||
if (likely(locker != NULL))
|
||||
PSI_TRANSACTION_CALL(set_transaction_xa_state)(locker, xa_state);
|
||||
}
|
||||
|
||||
static inline void
|
||||
inline_mysql_set_transaction_trxid(PSI_transaction_locker *locker,
|
||||
const ulonglong *trxid)
|
||||
{
|
||||
if (likely(locker != NULL))
|
||||
PSI_TRANSACTION_CALL(set_transaction_trxid)(locker, trxid);
|
||||
}
|
||||
|
||||
static inline void
|
||||
inline_mysql_inc_transaction_savepoints(PSI_transaction_locker *locker,
|
||||
ulong count)
|
||||
{
|
||||
if (likely(locker != NULL))
|
||||
PSI_TRANSACTION_CALL(inc_transaction_savepoints)(locker, count);
|
||||
}
|
||||
|
||||
static inline void
|
||||
inline_mysql_inc_transaction_rollback_to_savepoint(PSI_transaction_locker *locker,
|
||||
ulong count)
|
||||
{
|
||||
if (likely(locker != NULL))
|
||||
PSI_TRANSACTION_CALL(inc_transaction_rollback_to_savepoint)(locker, count);
|
||||
}
|
||||
|
||||
static inline void
|
||||
inline_mysql_inc_transaction_release_savepoint(PSI_transaction_locker *locker,
|
||||
ulong count)
|
||||
{
|
||||
if (likely(locker != NULL))
|
||||
PSI_TRANSACTION_CALL(inc_transaction_release_savepoint)(locker, count);
|
||||
}
|
||||
|
||||
static inline void
|
||||
inline_mysql_rollback_transaction(struct PSI_transaction_locker *locker)
|
||||
{
|
||||
if (likely(locker != NULL))
|
||||
PSI_TRANSACTION_CALL(end_transaction)(locker, false);
|
||||
}
|
||||
|
||||
static inline void
|
||||
inline_mysql_commit_transaction(struct PSI_transaction_locker *locker)
|
||||
{
|
||||
if (likely(locker != NULL))
|
||||
PSI_TRANSACTION_CALL(end_transaction)(locker, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} (end of group Transaction_instrumentation) */
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,155 +0,0 @@
|
|||
/* Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
|
||||
|
||||
#ifndef MYSQL_PSI_BASE_H
|
||||
#define MYSQL_PSI_BASE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
@file mysql/psi/psi_base.h
|
||||
Performance schema instrumentation interface.
|
||||
|
||||
@defgroup Instrumentation_interface Instrumentation Interface
|
||||
@ingroup Performance_schema
|
||||
@{
|
||||
*/
|
||||
|
||||
#define PSI_INSTRUMENT_ME 0
|
||||
|
||||
#define PSI_NOT_INSTRUMENTED 0
|
||||
|
||||
/**
|
||||
Global flag.
|
||||
This flag indicate that an instrumentation point is a global variable,
|
||||
or a singleton.
|
||||
*/
|
||||
#define PSI_FLAG_GLOBAL (1 << 0)
|
||||
|
||||
/**
|
||||
Mutable flag.
|
||||
This flag indicate that an instrumentation point is a general placeholder,
|
||||
that can mutate into a more specific instrumentation point.
|
||||
*/
|
||||
#define PSI_FLAG_MUTABLE (1 << 1)
|
||||
|
||||
#define PSI_FLAG_THREAD (1 << 2)
|
||||
|
||||
/**
|
||||
Stage progress flag.
|
||||
This flag apply to the stage instruments only.
|
||||
It indicates the instrumentation provides progress data.
|
||||
*/
|
||||
#define PSI_FLAG_STAGE_PROGRESS (1 << 3)
|
||||
|
||||
/**
|
||||
Shared Exclusive flag.
|
||||
Indicates that rwlock support the shared exclusive state.
|
||||
*/
|
||||
#define PSI_RWLOCK_FLAG_SX (1 << 4)
|
||||
|
||||
/**
|
||||
Transferable flag.
|
||||
This flag indicate that an instrumented object can
|
||||
be created by a thread and destroyed by another thread.
|
||||
*/
|
||||
#define PSI_FLAG_TRANSFER (1 << 5)
|
||||
|
||||
/**
|
||||
Volatility flag.
|
||||
This flag indicate that an instrumented object
|
||||
has a volatility (life cycle) comparable
|
||||
to the volatility of a session.
|
||||
*/
|
||||
#define PSI_FLAG_VOLATILITY_SESSION (1 << 6)
|
||||
|
||||
#ifdef HAVE_PSI_INTERFACE
|
||||
|
||||
/**
|
||||
@def PSI_VERSION_1
|
||||
Performance Schema Interface number for version 1.
|
||||
This version is supported.
|
||||
*/
|
||||
#define PSI_VERSION_1 1
|
||||
|
||||
/**
|
||||
@def PSI_VERSION_2
|
||||
Performance Schema Interface number for version 2.
|
||||
This version is not implemented, it's a placeholder.
|
||||
*/
|
||||
#define PSI_VERSION_2 2
|
||||
|
||||
/**
|
||||
@def PSI_CURRENT_VERSION
|
||||
Performance Schema Interface number for the most recent version.
|
||||
The most current version is @c PSI_VERSION_1
|
||||
*/
|
||||
#define PSI_CURRENT_VERSION 1
|
||||
|
||||
/**
|
||||
@def USE_PSI_1
|
||||
Define USE_PSI_1 to use the interface version 1.
|
||||
*/
|
||||
|
||||
/**
|
||||
@def USE_PSI_2
|
||||
Define USE_PSI_2 to use the interface version 2.
|
||||
*/
|
||||
|
||||
/**
|
||||
@def HAVE_PSI_1
|
||||
Define HAVE_PSI_1 if the interface version 1 needs to be compiled in.
|
||||
*/
|
||||
|
||||
/**
|
||||
@def HAVE_PSI_2
|
||||
Define HAVE_PSI_2 if the interface version 2 needs to be compiled in.
|
||||
*/
|
||||
|
||||
#ifndef USE_PSI_2
|
||||
#ifndef USE_PSI_1
|
||||
#define USE_PSI_1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef USE_PSI_1
|
||||
#define HAVE_PSI_1
|
||||
#endif
|
||||
|
||||
#ifdef USE_PSI_2
|
||||
#define HAVE_PSI_2
|
||||
#endif
|
||||
|
||||
/*
|
||||
Allow to override PSI_XXX_CALL at compile time
|
||||
with more efficient implementations, if available.
|
||||
If nothing better is available,
|
||||
make a dynamic call using the PSI_server function pointer.
|
||||
*/
|
||||
|
||||
#define PSI_DYNAMIC_CALL(M) PSI_server->M
|
||||
|
||||
#endif /* HAVE_PSI_INTERFACE */
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MYSQL_PSI_BASE_H */
|
||||
|
||||
|
|
@ -1,155 +0,0 @@
|
|||
/* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
|
||||
|
||||
#ifndef MYSQL_PSI_MEMORY_H
|
||||
#define MYSQL_PSI_MEMORY_H
|
||||
|
||||
#include "psi_base.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
@file mysql/psi/psi_memory.h
|
||||
Performance schema instrumentation interface.
|
||||
|
||||
@defgroup Instrumentation_interface Instrumentation Interface
|
||||
@ingroup Performance_schema
|
||||
@{
|
||||
*/
|
||||
|
||||
#ifdef HAVE_PSI_INTERFACE
|
||||
#ifndef DISABLE_ALL_PSI
|
||||
#ifndef DISABLE_PSI_MEMORY
|
||||
#define HAVE_PSI_MEMORY_INTERFACE
|
||||
#endif /* DISABLE_PSI_MEMORY */
|
||||
#endif /* DISABLE_ALL_PSI */
|
||||
#endif /* HAVE_PSI_INTERFACE */
|
||||
|
||||
struct PSI_thread;
|
||||
|
||||
/**
|
||||
Instrumented memory key.
|
||||
To instrument memory, a memory key must be obtained using @c register_memory.
|
||||
Using a zero key always disable the instrumentation.
|
||||
*/
|
||||
typedef unsigned int PSI_memory_key;
|
||||
|
||||
#ifdef HAVE_PSI_1
|
||||
|
||||
/**
|
||||
@defgroup Group_PSI_v1 Application Binary Interface, version 1
|
||||
@ingroup Instrumentation_interface
|
||||
@{
|
||||
*/
|
||||
|
||||
/**
|
||||
Memory instrument information.
|
||||
@since PSI_VERSION_1
|
||||
This structure is used to register instrumented memory.
|
||||
*/
|
||||
struct PSI_memory_info_v1
|
||||
{
|
||||
/** Pointer to the key assigned to the registered memory. */
|
||||
PSI_memory_key *m_key;
|
||||
/** The name of the memory instrument to register. */
|
||||
const char *m_name;
|
||||
/**
|
||||
The flags of the socket instrument to register.
|
||||
@sa PSI_FLAG_GLOBAL
|
||||
*/
|
||||
int m_flags;
|
||||
};
|
||||
typedef struct PSI_memory_info_v1 PSI_memory_info_v1;
|
||||
|
||||
/**
|
||||
Memory registration API.
|
||||
@param category a category name (typically a plugin name)
|
||||
@param info an array of memory info to register
|
||||
@param count the size of the info array
|
||||
*/
|
||||
typedef void (*register_memory_v1_t)
|
||||
(const char *category, struct PSI_memory_info_v1 *info, int count);
|
||||
|
||||
/**
|
||||
Instrument memory allocation.
|
||||
@param key the memory instrument key
|
||||
@param size the size of memory allocated
|
||||
@param[out] owner the memory owner
|
||||
@return the effective memory instrument key
|
||||
*/
|
||||
typedef PSI_memory_key (*memory_alloc_v1_t)
|
||||
(PSI_memory_key key, size_t size, struct PSI_thread ** owner);
|
||||
|
||||
/**
|
||||
Instrument memory re allocation.
|
||||
@param key the memory instrument key
|
||||
@param old_size the size of memory previously allocated
|
||||
@param new_size the size of memory re allocated
|
||||
@param[in, out] owner the memory owner
|
||||
@return the effective memory instrument key
|
||||
*/
|
||||
typedef PSI_memory_key (*memory_realloc_v1_t)
|
||||
(PSI_memory_key key, size_t old_size, size_t new_size, struct PSI_thread ** owner);
|
||||
|
||||
/**
|
||||
Instrument memory claim.
|
||||
@param key the memory instrument key
|
||||
@param size the size of memory allocated
|
||||
@param[in, out] owner the memory owner
|
||||
@return the effective memory instrument key
|
||||
*/
|
||||
typedef PSI_memory_key (*memory_claim_v1_t)
|
||||
(PSI_memory_key key, size_t size, struct PSI_thread ** owner);
|
||||
|
||||
/**
|
||||
Instrument memory free.
|
||||
@param key the memory instrument key
|
||||
@param size the size of memory allocated
|
||||
@param owner the memory owner
|
||||
*/
|
||||
typedef void (*memory_free_v1_t)
|
||||
(PSI_memory_key key, size_t size, struct PSI_thread * owner);
|
||||
|
||||
/** @} (end of group Group_PSI_v1) */
|
||||
|
||||
#endif /* HAVE_PSI_1 */
|
||||
|
||||
#ifdef HAVE_PSI_2
|
||||
struct PSI_memory_info_v2
|
||||
{
|
||||
int placeholder;
|
||||
};
|
||||
|
||||
#endif /* HAVE_PSI_2 */
|
||||
|
||||
#ifdef USE_PSI_1
|
||||
typedef struct PSI_memory_info_v1 PSI_memory_info;
|
||||
#endif
|
||||
|
||||
#ifdef USE_PSI_2
|
||||
typedef struct PSI_memory_info_v2 PSI_memory_info;
|
||||
#endif
|
||||
|
||||
/** @} (end of group Instrumentation_interface) */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* MYSQL_PSI_MEMORY_H */
|
||||
|
||||
|
|
@ -1,101 +0,0 @@
|
|||
#ifndef MYSQL_SERVICE_MY_SNPRINTF_INCLUDED
|
||||
#define MYSQL_SERVICE_MY_SNPRINTF_INCLUDED
|
||||
/* Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
/**
|
||||
@file
|
||||
my_snprintf service
|
||||
|
||||
Portable and limited vsnprintf() implementation.
|
||||
|
||||
This is a portable, limited vsnprintf() implementation, with some
|
||||
extra features. "Portable" means that it'll produce identical result
|
||||
on all platforms (for example, on Windows and Linux system printf %e
|
||||
formats the exponent differently, on different systems %p either
|
||||
prints leading 0x or not, %s may accept null pointer or crash on
|
||||
it). "Limited" means that it does not support all the C89 features.
|
||||
But it supports few extensions, not in any standard.
|
||||
|
||||
my_vsnprintf(to, n, fmt, ap)
|
||||
|
||||
@param[out] to A buffer to store the result in
|
||||
@param[in] n Store up to n-1 characters, followed by an end 0
|
||||
@param[in] fmt printf-like format string
|
||||
@param[in] ap Arguments
|
||||
|
||||
@return a number of bytes written to a buffer *excluding* terminating '\0'
|
||||
|
||||
@post
|
||||
The syntax of a format string is generally the same:
|
||||
% <flag> <width> <precision> <length modifier> <format>
|
||||
where everithing but the format is optional.
|
||||
|
||||
Three one-character flags are recognized:
|
||||
'0' has the standard zero-padding semantics;
|
||||
'-' is parsed, but silently ignored;
|
||||
'`' (backtick) is only supported for strings (%s) and means that the
|
||||
string will be quoted according to MySQL identifier quoting rules.
|
||||
|
||||
Both <width> and <precision> can be specified as numbers or '*'.
|
||||
If an asterisk is used, an argument of type int is consumed.
|
||||
|
||||
<length modifier> can be 'l', 'll', or 'z'.
|
||||
|
||||
Supported formats are 's' (null pointer is accepted, printed as
|
||||
"(null)"), 'b' (extension, see below), 'c', 'd', 'i', 'u', 'x', 'o',
|
||||
'X', 'p' (works as 0x%x).
|
||||
|
||||
Standard syntax for positional arguments $n is supported.
|
||||
|
||||
Extensions:
|
||||
|
||||
Flag '`' (backtick): see above.
|
||||
|
||||
Format 'b': binary buffer, prints exactly <precision> bytes from the
|
||||
argument, without stopping at '\0'.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef MYSQL_ABI_CHECK
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
extern struct my_snprintf_service_st {
|
||||
size_t (*my_snprintf_type)(char*, size_t, const char*, ...);
|
||||
size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list);
|
||||
} *my_snprintf_service;
|
||||
|
||||
#ifdef MYSQL_DYNAMIC_PLUGIN
|
||||
|
||||
#define my_vsnprintf my_snprintf_service->my_vsnprintf_type
|
||||
#define my_snprintf my_snprintf_service->my_snprintf_type
|
||||
|
||||
#else
|
||||
|
||||
size_t my_snprintf(char* to, size_t n, const char* fmt, ...);
|
||||
size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* #define MYSQL_SERVICE_MY_SNPRINTF_INCLUDED */
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
/* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#ifndef MYSQL_SERVICE_MYSQL_ALLOC_INCLUDED
|
||||
#define MYSQL_SERVICE_MYSQL_ALLOC_INCLUDED
|
||||
|
||||
#ifndef MYSQL_ABI_CHECK
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
/* PSI_memory_key */
|
||||
#include "mysql/psi/psi_memory.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* myf */
|
||||
typedef int myf_t;
|
||||
|
||||
typedef void * (*mysql_malloc_t)(PSI_memory_key key, size_t size, myf_t flags);
|
||||
typedef void * (*mysql_realloc_t)(PSI_memory_key key, void *ptr, size_t size, myf_t flags);
|
||||
typedef void (*mysql_claim_t)(void *ptr);
|
||||
typedef void (*mysql_free_t)(void *ptr);
|
||||
typedef void * (*my_memdup_t)(PSI_memory_key key, const void *from, size_t length, myf_t flags);
|
||||
typedef char * (*my_strdup_t)(PSI_memory_key key, const char *from, myf_t flags);
|
||||
typedef char * (*my_strndup_t)(PSI_memory_key key, const char *from, size_t length, myf_t flags);
|
||||
|
||||
struct mysql_malloc_service_st
|
||||
{
|
||||
mysql_malloc_t mysql_malloc;
|
||||
mysql_realloc_t mysql_realloc;
|
||||
mysql_claim_t mysql_claim;
|
||||
mysql_free_t mysql_free;
|
||||
my_memdup_t my_memdup;
|
||||
my_strdup_t my_strdup;
|
||||
my_strndup_t my_strndup;
|
||||
};
|
||||
|
||||
extern struct mysql_malloc_service_st *mysql_malloc_service;
|
||||
|
||||
#ifdef MYSQL_DYNAMIC_PLUGIN
|
||||
|
||||
#define my_malloc mysql_malloc_service->mysql_malloc
|
||||
#define my_realloc mysql_malloc_service->mysql_realloc
|
||||
#define my_claim mysql_malloc_service->mysql_claim
|
||||
#define my_free mysql_malloc_service->mysql_free
|
||||
#define my_memdup mysql_malloc_service->my_memdup
|
||||
#define my_strdup mysql_malloc_service->my_strdup
|
||||
#define my_strndup mysql_malloc_service->my_strndup
|
||||
|
||||
#else
|
||||
|
||||
extern void * my_malloc(PSI_memory_key key, size_t size, myf_t flags);
|
||||
extern void * my_realloc(PSI_memory_key key, void *ptr, size_t size, myf_t flags);
|
||||
extern void my_claim(void *ptr);
|
||||
extern void my_free(void *ptr);
|
||||
extern void * my_memdup(PSI_memory_key key, const void *from, size_t length, myf_t flags);
|
||||
extern char * my_strdup(PSI_memory_key key, const char *from, myf_t flags);
|
||||
extern char * my_strndup(PSI_memory_key key, const char *from, size_t length, myf_t flags);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
91
src/common/mysql/include/mysql/udf_registration_types.h
Normal file
91
src/common/mysql/include/mysql/udf_registration_types.h
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
/* Copyright (c) 2017, 2026, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
This program is designed to work with certain software (including
|
||||
but not limited to OpenSSL) that is licensed under separate terms,
|
||||
as designated in a particular file or component or in included license
|
||||
documentation. The authors of MySQL hereby grant you an additional
|
||||
permission to link the program and your derivative works with the
|
||||
separately licensed software that they have either included with
|
||||
the program or referenced in the documentation.
|
||||
|
||||
Without limiting anything contained in the foregoing, this file,
|
||||
which is part of C Driver for MySQL (Connector/C), is also subject to the
|
||||
Universal FOSS Exception, version 1.0, a copy of which can be found at
|
||||
http://oss.oracle.com/licenses/universal-foss-exception.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License, version 2.0, for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#ifndef UDF_REGISTRATION_TYPES_H
|
||||
#define UDF_REGISTRATION_TYPES_H
|
||||
|
||||
#ifndef MYSQL_ABI_CHECK
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
Type of the user defined function return slot and arguments
|
||||
*/
|
||||
enum Item_result {
|
||||
INVALID_RESULT = -1, /** not valid for UDFs */
|
||||
STRING_RESULT = 0, /** char * */
|
||||
REAL_RESULT, /** double */
|
||||
INT_RESULT, /** long long */
|
||||
ROW_RESULT, /** not valid for UDFs */
|
||||
DECIMAL_RESULT /** char *, to be converted to/from a decimal */
|
||||
};
|
||||
|
||||
typedef struct UDF_ARGS {
|
||||
unsigned int arg_count; /**< Number of arguments */
|
||||
enum Item_result *arg_type; /**< Pointer to item_results */
|
||||
char **args; /**< Pointer to argument */
|
||||
unsigned long *lengths; /**< Length of string arguments */
|
||||
char *maybe_null; /**< Set to 1 for all maybe_null args */
|
||||
char **attributes; /**< Pointer to attribute name */
|
||||
unsigned long *attribute_lengths; /**< Length of attribute arguments */
|
||||
void *extension;
|
||||
} UDF_ARGS;
|
||||
|
||||
/**
|
||||
Information about the result of a user defined function
|
||||
|
||||
@todo add a notion for determinism of the UDF.
|
||||
|
||||
@sa Item_udf_func::update_used_tables()
|
||||
*/
|
||||
typedef struct UDF_INIT {
|
||||
bool maybe_null; /** 1 if function can return NULL */
|
||||
unsigned int decimals; /** for real functions */
|
||||
unsigned long max_length; /** For string functions */
|
||||
char *ptr; /** free pointer for function data */
|
||||
bool const_item; /** 1 if function always returns the same value */
|
||||
void *extension;
|
||||
} UDF_INIT;
|
||||
|
||||
enum Item_udftype { UDFTYPE_FUNCTION = 1, UDFTYPE_AGGREGATE };
|
||||
|
||||
typedef void (*Udf_func_clear)(UDF_INIT *, unsigned char *, unsigned char *);
|
||||
typedef void (*Udf_func_add)(UDF_INIT *, UDF_ARGS *, unsigned char *,
|
||||
unsigned char *);
|
||||
typedef void (*Udf_func_deinit)(UDF_INIT *);
|
||||
typedef bool (*Udf_func_init)(UDF_INIT *, UDF_ARGS *, char *);
|
||||
typedef void (*Udf_func_any)(void);
|
||||
typedef double (*Udf_func_double)(UDF_INIT *, UDF_ARGS *, unsigned char *,
|
||||
unsigned char *);
|
||||
typedef long long (*Udf_func_longlong)(UDF_INIT *, UDF_ARGS *, unsigned char *,
|
||||
unsigned char *);
|
||||
typedef char *(*Udf_func_string)(UDF_INIT *, UDF_ARGS *, char *,
|
||||
unsigned long *, unsigned char *,
|
||||
unsigned char *);
|
||||
|
||||
#endif /* UDF_REGISTRATION_TYPES_H */
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,41 +0,0 @@
|
|||
/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
/*
|
||||
Definitions private to the server,
|
||||
used in the networking layer to notify specific events.
|
||||
*/
|
||||
|
||||
#ifndef _mysql_com_server_h
|
||||
#define _mysql_com_server_h
|
||||
|
||||
struct st_net_server;
|
||||
|
||||
typedef void (*before_header_callback_fn)
|
||||
(struct st_net *net, void *user_data, size_t count);
|
||||
|
||||
typedef void (*after_header_callback_fn)
|
||||
(struct st_net *net, void *user_data, size_t count, my_bool rc);
|
||||
|
||||
struct st_net_server
|
||||
{
|
||||
before_header_callback_fn m_before_header;
|
||||
after_header_callback_fn m_after_header;
|
||||
void *m_user_data;
|
||||
};
|
||||
|
||||
typedef struct st_net_server NET_SERVER;
|
||||
|
||||
#endif
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
#ifndef MYSQL_EMBED_INCLUDED
|
||||
#define MYSQL_EMBED_INCLUDED
|
||||
|
||||
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
/* Defines that are unique to the embedded version of MySQL */
|
||||
|
||||
#ifdef EMBEDDED_LIBRARY
|
||||
|
||||
/* Things we don't need in the embedded version of MySQL */
|
||||
/* TODO HF add #undef HAVE_VIO if we don't want client in embedded library */
|
||||
|
||||
#undef HAVE_DLOPEN /* No udf functions */
|
||||
|
||||
#endif /* EMBEDDED_LIBRARY */
|
||||
#endif /* MYSQL_EMBED_INCLUDED */
|
||||
|
|
@ -1,22 +1,36 @@
|
|||
/* Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
/* Copyright (c) 2004, 2026, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
This program is designed to work with certain software (including
|
||||
but not limited to OpenSSL) that is licensed under separate terms,
|
||||
as designated in a particular file or component or in included license
|
||||
documentation. The authors of MySQL hereby grant you an additional
|
||||
permission to link the program and your derivative works with the
|
||||
separately licensed software that they have either included with
|
||||
the program or referenced in the documentation.
|
||||
|
||||
Without limiting anything contained in the foregoing, this file,
|
||||
which is part of C Driver for MySQL (Connector/C), is also subject to the
|
||||
Universal FOSS Exception, version 1.0, a copy of which can be found at
|
||||
http://oss.oracle.com/licenses/universal-foss-exception.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU General Public License, version 2.0, for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#ifndef _mysql_time_h_
|
||||
#define _mysql_time_h_
|
||||
|
||||
/*
|
||||
/**
|
||||
@file include/mysql_time.h
|
||||
Time declarations shared between the server and client API:
|
||||
you should not add anything to this header unless it's used
|
||||
(and hence should be visible) in mysql.h.
|
||||
|
|
@ -25,12 +39,33 @@
|
|||
and Time Values" chapter in documentation.
|
||||
*/
|
||||
|
||||
enum enum_mysql_timestamp_type
|
||||
{
|
||||
MYSQL_TIMESTAMP_NONE= -2, MYSQL_TIMESTAMP_ERROR= -1,
|
||||
MYSQL_TIMESTAMP_DATE= 0, MYSQL_TIMESTAMP_DATETIME= 1, MYSQL_TIMESTAMP_TIME= 2
|
||||
};
|
||||
// Do not not pull in the server header "my_inttypes.h" from client code.
|
||||
// IWYU pragma: no_include "my_inttypes.h"
|
||||
|
||||
enum enum_mysql_timestamp_type {
|
||||
MYSQL_TIMESTAMP_NONE = -2,
|
||||
MYSQL_TIMESTAMP_ERROR = -1,
|
||||
|
||||
/// Stores year, month and day components.
|
||||
MYSQL_TIMESTAMP_DATE = 0,
|
||||
|
||||
/**
|
||||
Stores all date and time components.
|
||||
Value is in UTC for `TIMESTAMP` type.
|
||||
Value is in local time zone for `DATETIME` type.
|
||||
*/
|
||||
MYSQL_TIMESTAMP_DATETIME = 1,
|
||||
|
||||
/// Stores hour, minute, second and microsecond.
|
||||
MYSQL_TIMESTAMP_TIME = 2,
|
||||
|
||||
/**
|
||||
A temporary type for `DATETIME` or `TIMESTAMP` types equipped with time
|
||||
zone information. After the time zone information is reconciled, the type is
|
||||
converted to MYSQL_TIMESTAMP_DATETIME.
|
||||
*/
|
||||
MYSQL_TIMESTAMP_DATETIME_TZ = 3
|
||||
};
|
||||
|
||||
/*
|
||||
Structure which is used to represent datetime values inside MySQL.
|
||||
|
|
@ -44,12 +79,13 @@ enum enum_mysql_timestamp_type
|
|||
value (time_type == MYSQL_TIMESTAMP_TIME) days and hour member can hold
|
||||
bigger values.
|
||||
*/
|
||||
typedef struct st_mysql_time
|
||||
{
|
||||
unsigned int year, month, day, hour, minute, second;
|
||||
unsigned long second_part; /**< microseconds */
|
||||
my_bool neg;
|
||||
typedef struct MYSQL_TIME {
|
||||
unsigned int year, month, day, hour, minute, second;
|
||||
unsigned long second_part; /**< microseconds */
|
||||
bool neg;
|
||||
enum enum_mysql_timestamp_type time_type;
|
||||
/// The time zone displacement, specified in seconds.
|
||||
int time_zone_displacement;
|
||||
} MYSQL_TIME;
|
||||
|
||||
#endif /* _mysql_time_h_ */
|
||||
|
|
|
|||
|
|
@ -7,22 +7,23 @@
|
|||
|
||||
#ifndef _mysql_version_h
|
||||
#define _mysql_version_h
|
||||
#ifdef _CUSTOMCONFIG_
|
||||
#include <custom_conf.h>
|
||||
#else
|
||||
|
||||
#define PROTOCOL_VERSION 10
|
||||
#define MYSQL_SERVER_VERSION "5.7.16"
|
||||
#define MYSQL_VERSION_ID 50716
|
||||
#define MYSQL_SERVER_VERSION "8.0.46"
|
||||
#define MYSQL_BASE_VERSION "mysqld-8.0"
|
||||
#define MYSQL_SERVER_SUFFIX_DEF ""
|
||||
#define MYSQL_VERSION_ID 80046
|
||||
#define MYSQL_VERSION_STABILITY "LTS"
|
||||
#define MYSQL_PORT 3306
|
||||
#define MYSQL_ADMIN_PORT 33062
|
||||
#define MYSQL_PORT_DEFAULT 0
|
||||
#define MYSQL_UNIX_ADDR "/tmp/mysql.sock"
|
||||
#define MYSQL_CONFIG_NAME "my"
|
||||
#define MYSQL_COMPILATION_COMMENT "MySQL Connector/C (GPL)"
|
||||
#define LIBMYSQL_VERSION "6.1.11"
|
||||
#define LIBMYSQL_VERSION_ID 60111
|
||||
|
||||
/* mysqld compile time options */
|
||||
#endif /* _CUSTOMCONFIG_ */
|
||||
#define MYSQL_PERSIST_CONFIG_NAME "mysqld-auto"
|
||||
#define MYSQL_COMPILATION_COMMENT "MySQL Community - GPL"
|
||||
#define MYSQL_COMPILATION_COMMENT_SERVER "MySQL Community Server - GPL"
|
||||
#define LIBMYSQL_VERSION "8.0.46"
|
||||
#define LIBMYSQL_VERSION_ID 80046
|
||||
|
||||
#ifndef LICENSE
|
||||
#define LICENSE GPL
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,206 +0,0 @@
|
|||
#ifndef SQL_COMMON_INCLUDED
|
||||
#define SQL_COMMON_INCLUDED
|
||||
|
||||
/* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#define SQL_COMMON_INCLUDED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <mysql.h>
|
||||
#include <hash.h>
|
||||
|
||||
extern const char *unknown_sqlstate;
|
||||
extern const char *cant_connect_sqlstate;
|
||||
extern const char *not_error_sqlstate;
|
||||
|
||||
|
||||
/*
|
||||
Free all memory allocated in MYSQL handle except the
|
||||
current options.
|
||||
*/
|
||||
void mysql_close_free(MYSQL *mysql);
|
||||
|
||||
/*
|
||||
Clear connection options stored in MYSQL handle and
|
||||
free memory used by them.
|
||||
*/
|
||||
void mysql_close_free_options(MYSQL *mysql);
|
||||
|
||||
|
||||
/**
|
||||
The structure is used to hold the state change information
|
||||
received from the server. LIST functions are used for manipulation
|
||||
of the members of the structure.
|
||||
*/
|
||||
typedef struct st_session_track_info_node {
|
||||
/** head_node->data is a LEX_STRING which contains the variable name. */
|
||||
LIST *head_node;
|
||||
LIST *current_node;
|
||||
} STATE_INFO_NODE;
|
||||
|
||||
/**
|
||||
Store the change info received from the server in an array of linked lists
|
||||
with STATE_INFO_NODE elements (one per state type).
|
||||
*/
|
||||
typedef struct st_session_track_info {
|
||||
/** Array of STATE_NODE_INFO elements (one per state type). */
|
||||
struct st_session_track_info_node info_list[SESSION_TRACK_END + 1];
|
||||
} STATE_INFO;
|
||||
|
||||
/*
|
||||
Access to MYSQL::extension member.
|
||||
|
||||
Note: functions mysql_extension_{init,free}() are defined
|
||||
in client.c.
|
||||
*/
|
||||
|
||||
struct st_mysql_trace_info;
|
||||
|
||||
typedef struct st_mysql_extension {
|
||||
struct st_mysql_trace_info *trace_data;
|
||||
struct st_session_track_info state_change;
|
||||
} MYSQL_EXTENSION;
|
||||
|
||||
/* "Constructor/destructor" for MYSQL extension structure. */
|
||||
struct st_mysql_extension* mysql_extension_init(struct st_mysql*);
|
||||
void mysql_extension_free(struct st_mysql_extension*);
|
||||
|
||||
/*
|
||||
Note: Allocated extension structure is freed in mysql_close_free()
|
||||
called by mysql_close().
|
||||
*/
|
||||
#define MYSQL_EXTENSION_PTR(H) \
|
||||
( \
|
||||
(struct st_mysql_extension*) \
|
||||
( (H)->extension ? \
|
||||
(H)->extension : ((H)->extension= mysql_extension_init(H)) \
|
||||
) \
|
||||
)
|
||||
|
||||
|
||||
struct st_mysql_options_extention {
|
||||
char *plugin_dir;
|
||||
char *default_auth;
|
||||
char *ssl_crl; /* PEM CRL file */
|
||||
char *ssl_crlpath; /* PEM directory of CRL-s? */
|
||||
HASH connection_attributes;
|
||||
char *server_public_key_path;
|
||||
size_t connection_attributes_length;
|
||||
my_bool enable_cleartext_plugin;
|
||||
my_bool unused0; /* Former ssl_enforce */
|
||||
char *tls_version; /* TLS version option */
|
||||
long ssl_ctx_flags; /* SSL ctx options flag */
|
||||
unsigned int ssl_mode;
|
||||
};
|
||||
|
||||
typedef struct st_mysql_methods
|
||||
{
|
||||
my_bool (*read_query_result)(MYSQL *mysql);
|
||||
my_bool (*advanced_command)(MYSQL *mysql,
|
||||
enum enum_server_command command,
|
||||
const unsigned char *header,
|
||||
size_t header_length,
|
||||
const unsigned char *arg,
|
||||
size_t arg_length,
|
||||
my_bool skip_check,
|
||||
MYSQL_STMT *stmt);
|
||||
MYSQL_DATA *(*read_rows)(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
|
||||
unsigned int fields);
|
||||
MYSQL_RES * (*use_result)(MYSQL *mysql);
|
||||
void (*fetch_lengths)(unsigned long *to,
|
||||
MYSQL_ROW column, unsigned int field_count);
|
||||
void (*flush_use_result)(MYSQL *mysql, my_bool flush_all_results);
|
||||
int (*read_change_user_result)(MYSQL *mysql);
|
||||
#if !defined(MYSQL_SERVER) || defined(EMBEDDED_LIBRARY)
|
||||
MYSQL_FIELD * (*list_fields)(MYSQL *mysql);
|
||||
my_bool (*read_prepare_result)(MYSQL *mysql, MYSQL_STMT *stmt);
|
||||
int (*stmt_execute)(MYSQL_STMT *stmt);
|
||||
int (*read_binary_rows)(MYSQL_STMT *stmt);
|
||||
int (*unbuffered_fetch)(MYSQL *mysql, char **row);
|
||||
void (*free_embedded_thd)(MYSQL *mysql);
|
||||
const char *(*read_statistics)(MYSQL *mysql);
|
||||
my_bool (*next_result)(MYSQL *mysql);
|
||||
int (*read_rows_from_cursor)(MYSQL_STMT *stmt);
|
||||
void (*free_rows)(MYSQL_DATA *cur);
|
||||
#endif
|
||||
} MYSQL_METHODS;
|
||||
|
||||
#define simple_command(mysql, command, arg, length, skip_check) \
|
||||
((mysql)->methods \
|
||||
? (*(mysql)->methods->advanced_command)(mysql, command, 0, \
|
||||
0, arg, length, skip_check, NULL) \
|
||||
: (set_mysql_error(mysql, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate), 1))
|
||||
#define stmt_command(mysql, command, arg, length, stmt) \
|
||||
((mysql)->methods \
|
||||
? (*(mysql)->methods->advanced_command)(mysql, command, 0, \
|
||||
0, arg, length, 1, stmt) \
|
||||
: (set_mysql_error(mysql, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate), 1))
|
||||
|
||||
extern CHARSET_INFO *default_client_charset_info;
|
||||
MYSQL_FIELD *unpack_fields(MYSQL *mysql, MYSQL_ROWS *data,MEM_ROOT *alloc,
|
||||
uint fields, my_bool default_value,
|
||||
uint server_capabilities);
|
||||
MYSQL_FIELD * cli_read_metadata_ex(MYSQL *mysql, MEM_ROOT *alloc,
|
||||
unsigned long field_count,
|
||||
unsigned int fields);
|
||||
MYSQL_FIELD * cli_read_metadata(MYSQL *mysql, unsigned long field_count,
|
||||
unsigned int fields);
|
||||
void free_rows(MYSQL_DATA *cur);
|
||||
void free_old_query(MYSQL *mysql);
|
||||
void end_server(MYSQL *mysql);
|
||||
my_bool mysql_reconnect(MYSQL *mysql);
|
||||
void mysql_read_default_options(struct st_mysql_options *options,
|
||||
const char *filename,const char *group);
|
||||
my_bool
|
||||
cli_advanced_command(MYSQL *mysql, enum enum_server_command command,
|
||||
const unsigned char *header, size_t header_length,
|
||||
const unsigned char *arg, size_t arg_length,
|
||||
my_bool skip_check, MYSQL_STMT *stmt);
|
||||
unsigned long cli_safe_read(MYSQL *mysql, my_bool *is_data_packet);
|
||||
unsigned long cli_safe_read_with_ok(MYSQL *mysql, my_bool parse_ok,
|
||||
my_bool *is_data_packet);
|
||||
void net_clear_error(NET *net);
|
||||
void set_stmt_errmsg(MYSQL_STMT *stmt, NET *net);
|
||||
void set_stmt_error(MYSQL_STMT *stmt, int errcode, const char *sqlstate,
|
||||
const char *err);
|
||||
void set_mysql_error(MYSQL *mysql, int errcode, const char *sqlstate);
|
||||
void set_mysql_extended_error(MYSQL *mysql, int errcode, const char *sqlstate,
|
||||
const char *format, ...);
|
||||
|
||||
/* client side of the pluggable authentication */
|
||||
struct st_plugin_vio_info;
|
||||
void mpvio_info(Vio *vio, struct st_plugin_vio_info *info);
|
||||
int run_plugin_auth(MYSQL *mysql, char *data, uint data_len,
|
||||
const char *data_plugin, const char *db);
|
||||
int mysql_client_plugin_init();
|
||||
void mysql_client_plugin_deinit();
|
||||
|
||||
struct st_mysql_client_plugin;
|
||||
extern struct st_mysql_client_plugin *mysql_client_builtins[];
|
||||
uchar * send_client_connect_attrs(MYSQL *mysql, uchar *buf);
|
||||
extern my_bool libmysql_cleartext_plugin_enabled;
|
||||
void read_ok_ex(MYSQL *mysql, unsigned long len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#define protocol_41(A) ((A)->server_capabilities & CLIENT_PROTOCOL_41)
|
||||
|
||||
#endif /* SQL_COMMON_INCLUDED */
|
||||
|
|
@ -1,255 +0,0 @@
|
|||
/* Autogenerated file, please don't edit */
|
||||
|
||||
{ ER_DUP_KEY ,"23000", "" },
|
||||
{ ER_OUTOFMEMORY ,"HY001", "S1001" },
|
||||
{ ER_OUT_OF_SORTMEMORY ,"HY001", "S1001" },
|
||||
{ ER_CON_COUNT_ERROR ,"08004", "" },
|
||||
{ ER_BAD_HOST_ERROR ,"08S01", "" },
|
||||
{ ER_HANDSHAKE_ERROR ,"08S01", "" },
|
||||
{ ER_DBACCESS_DENIED_ERROR ,"42000", "" },
|
||||
{ ER_ACCESS_DENIED_ERROR ,"28000", "" },
|
||||
{ ER_NO_DB_ERROR ,"3D000", "" },
|
||||
{ ER_UNKNOWN_COM_ERROR ,"08S01", "" },
|
||||
{ ER_BAD_NULL_ERROR ,"23000", "" },
|
||||
{ ER_BAD_DB_ERROR ,"42000", "" },
|
||||
{ ER_TABLE_EXISTS_ERROR ,"42S01", "" },
|
||||
{ ER_BAD_TABLE_ERROR ,"42S02", "" },
|
||||
{ ER_NON_UNIQ_ERROR ,"23000", "" },
|
||||
{ ER_SERVER_SHUTDOWN ,"08S01", "" },
|
||||
{ ER_BAD_FIELD_ERROR ,"42S22", "S0022" },
|
||||
{ ER_WRONG_FIELD_WITH_GROUP ,"42000", "S1009" },
|
||||
{ ER_WRONG_GROUP_FIELD ,"42000", "S1009" },
|
||||
{ ER_WRONG_SUM_SELECT ,"42000", "S1009" },
|
||||
{ ER_WRONG_VALUE_COUNT ,"21S01", "" },
|
||||
{ ER_TOO_LONG_IDENT ,"42000", "S1009" },
|
||||
{ ER_DUP_FIELDNAME ,"42S21", "S1009" },
|
||||
{ ER_DUP_KEYNAME ,"42000", "S1009" },
|
||||
{ ER_DUP_ENTRY ,"23000", "S1009" },
|
||||
{ ER_WRONG_FIELD_SPEC ,"42000", "S1009" },
|
||||
{ ER_PARSE_ERROR ,"42000", "s1009" },
|
||||
{ ER_EMPTY_QUERY ,"42000", "" },
|
||||
{ ER_NONUNIQ_TABLE ,"42000", "S1009" },
|
||||
{ ER_INVALID_DEFAULT ,"42000", "S1009" },
|
||||
{ ER_MULTIPLE_PRI_KEY ,"42000", "S1009" },
|
||||
{ ER_TOO_MANY_KEYS ,"42000", "S1009" },
|
||||
{ ER_TOO_MANY_KEY_PARTS ,"42000", "S1009" },
|
||||
{ ER_TOO_LONG_KEY ,"42000", "S1009" },
|
||||
{ ER_KEY_COLUMN_DOES_NOT_EXITS ,"42000", "S1009" },
|
||||
{ ER_BLOB_USED_AS_KEY ,"42000", "S1009" },
|
||||
{ ER_TOO_BIG_FIELDLENGTH ,"42000", "S1009" },
|
||||
{ ER_WRONG_AUTO_KEY ,"42000", "S1009" },
|
||||
{ ER_FORCING_CLOSE ,"08S01", "" },
|
||||
{ ER_IPSOCK_ERROR ,"08S01", "" },
|
||||
{ ER_NO_SUCH_INDEX ,"42S12", "S1009" },
|
||||
{ ER_WRONG_FIELD_TERMINATORS ,"42000", "S1009" },
|
||||
{ ER_BLOBS_AND_NO_TERMINATED ,"42000", "S1009" },
|
||||
{ ER_CANT_REMOVE_ALL_FIELDS ,"42000", "" },
|
||||
{ ER_CANT_DROP_FIELD_OR_KEY ,"42000", "" },
|
||||
{ ER_BLOB_CANT_HAVE_DEFAULT ,"42000", "" },
|
||||
{ ER_WRONG_DB_NAME ,"42000", "" },
|
||||
{ ER_WRONG_TABLE_NAME ,"42000", "" },
|
||||
{ ER_TOO_BIG_SELECT ,"42000", "" },
|
||||
{ ER_UNKNOWN_PROCEDURE ,"42000", "" },
|
||||
{ ER_WRONG_PARAMCOUNT_TO_PROCEDURE ,"42000", "" },
|
||||
{ ER_UNKNOWN_TABLE ,"42S02", "" },
|
||||
{ ER_FIELD_SPECIFIED_TWICE ,"42000", "" },
|
||||
{ ER_UNSUPPORTED_EXTENSION ,"42000", "" },
|
||||
{ ER_TABLE_MUST_HAVE_COLUMNS ,"42000", "" },
|
||||
{ ER_UNKNOWN_CHARACTER_SET ,"42000", "" },
|
||||
{ ER_TOO_BIG_ROWSIZE ,"42000", "" },
|
||||
{ ER_WRONG_OUTER_JOIN ,"42000", "" },
|
||||
{ ER_NULL_COLUMN_IN_INDEX ,"42000", "" },
|
||||
{ ER_PASSWORD_ANONYMOUS_USER ,"42000", "" },
|
||||
{ ER_PASSWORD_NOT_ALLOWED ,"42000", "" },
|
||||
{ ER_PASSWORD_NO_MATCH ,"42000", "" },
|
||||
{ ER_WRONG_VALUE_COUNT_ON_ROW ,"21S01", "" },
|
||||
{ ER_INVALID_USE_OF_NULL ,"22004", "" },
|
||||
{ ER_REGEXP_ERROR ,"42000", "" },
|
||||
{ ER_MIX_OF_GROUP_FUNC_AND_FIELDS ,"42000", "" },
|
||||
{ ER_NONEXISTING_GRANT ,"42000", "" },
|
||||
{ ER_TABLEACCESS_DENIED_ERROR ,"42000", "" },
|
||||
{ ER_COLUMNACCESS_DENIED_ERROR ,"42000", "" },
|
||||
{ ER_ILLEGAL_GRANT_FOR_TABLE ,"42000", "" },
|
||||
{ ER_GRANT_WRONG_HOST_OR_USER ,"42000", "" },
|
||||
{ ER_NO_SUCH_TABLE ,"42S02", "" },
|
||||
{ ER_NONEXISTING_TABLE_GRANT ,"42000", "" },
|
||||
{ ER_NOT_ALLOWED_COMMAND ,"42000", "" },
|
||||
{ ER_SYNTAX_ERROR ,"42000", "" },
|
||||
{ ER_ABORTING_CONNECTION ,"08S01", "" },
|
||||
{ ER_NET_PACKET_TOO_LARGE ,"08S01", "" },
|
||||
{ ER_NET_READ_ERROR_FROM_PIPE ,"08S01", "" },
|
||||
{ ER_NET_FCNTL_ERROR ,"08S01", "" },
|
||||
{ ER_NET_PACKETS_OUT_OF_ORDER ,"08S01", "" },
|
||||
{ ER_NET_UNCOMPRESS_ERROR ,"08S01", "" },
|
||||
{ ER_NET_READ_ERROR ,"08S01", "" },
|
||||
{ ER_NET_READ_INTERRUPTED ,"08S01", "" },
|
||||
{ ER_NET_ERROR_ON_WRITE ,"08S01", "" },
|
||||
{ ER_NET_WRITE_INTERRUPTED ,"08S01", "" },
|
||||
{ ER_TOO_LONG_STRING ,"42000", "" },
|
||||
{ ER_TABLE_CANT_HANDLE_BLOB ,"42000", "" },
|
||||
{ ER_TABLE_CANT_HANDLE_AUTO_INCREMENT ,"42000", "" },
|
||||
{ ER_WRONG_COLUMN_NAME ,"42000", "" },
|
||||
{ ER_WRONG_KEY_COLUMN ,"42000", "" },
|
||||
{ ER_DUP_UNIQUE ,"23000", "" },
|
||||
{ ER_BLOB_KEY_WITHOUT_LENGTH ,"42000", "" },
|
||||
{ ER_PRIMARY_CANT_HAVE_NULL ,"42000", "" },
|
||||
{ ER_TOO_MANY_ROWS ,"42000", "" },
|
||||
{ ER_REQUIRES_PRIMARY_KEY ,"42000", "" },
|
||||
{ ER_KEY_DOES_NOT_EXITS ,"42000", "S1009" },
|
||||
{ ER_CHECK_NO_SUCH_TABLE ,"42000", "" },
|
||||
{ ER_CHECK_NOT_IMPLEMENTED ,"42000", "" },
|
||||
{ ER_CANT_DO_THIS_DURING_AN_TRANSACTION ,"25000", "" },
|
||||
{ ER_NEW_ABORTING_CONNECTION ,"08S01", "" },
|
||||
{ ER_MASTER_NET_READ ,"08S01", "" },
|
||||
{ ER_MASTER_NET_WRITE ,"08S01", "" },
|
||||
{ ER_TOO_MANY_USER_CONNECTIONS ,"42000", "" },
|
||||
{ ER_READ_ONLY_TRANSACTION ,"25000", "" },
|
||||
{ ER_NO_PERMISSION_TO_CREATE_USER ,"42000", "" },
|
||||
{ ER_LOCK_DEADLOCK ,"40001", "" },
|
||||
{ ER_NO_REFERENCED_ROW ,"23000", "" },
|
||||
{ ER_ROW_IS_REFERENCED ,"23000", "" },
|
||||
{ ER_CONNECT_TO_MASTER ,"08S01", "" },
|
||||
{ ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT ,"21000", "" },
|
||||
{ ER_USER_LIMIT_REACHED ,"42000", "" },
|
||||
{ ER_SPECIFIC_ACCESS_DENIED_ERROR ,"42000", "" },
|
||||
{ ER_NO_DEFAULT ,"42000", "" },
|
||||
{ ER_WRONG_VALUE_FOR_VAR ,"42000", "" },
|
||||
{ ER_WRONG_TYPE_FOR_VAR ,"42000", "" },
|
||||
{ ER_CANT_USE_OPTION_HERE ,"42000", "" },
|
||||
{ ER_NOT_SUPPORTED_YET ,"42000", "" },
|
||||
{ ER_WRONG_FK_DEF ,"42000", "" },
|
||||
{ ER_OPERAND_COLUMNS ,"21000", "" },
|
||||
{ ER_SUBQUERY_NO_1_ROW ,"21000", "" },
|
||||
{ ER_ILLEGAL_REFERENCE ,"42S22", "" },
|
||||
{ ER_DERIVED_MUST_HAVE_ALIAS ,"42000", "" },
|
||||
{ ER_SELECT_REDUCED ,"01000", "" },
|
||||
{ ER_TABLENAME_NOT_ALLOWED_HERE ,"42000", "" },
|
||||
{ ER_NOT_SUPPORTED_AUTH_MODE ,"08004", "" },
|
||||
{ ER_SPATIAL_CANT_HAVE_NULL ,"42000", "" },
|
||||
{ ER_COLLATION_CHARSET_MISMATCH ,"42000", "" },
|
||||
{ ER_WARN_TOO_FEW_RECORDS ,"01000", "" },
|
||||
{ ER_WARN_TOO_MANY_RECORDS ,"01000", "" },
|
||||
{ ER_WARN_NULL_TO_NOTNULL ,"22004", "" },
|
||||
{ ER_WARN_DATA_OUT_OF_RANGE ,"22003", "" },
|
||||
{ WARN_DATA_TRUNCATED ,"01000", "" },
|
||||
{ ER_WRONG_NAME_FOR_INDEX ,"42000", "" },
|
||||
{ ER_WRONG_NAME_FOR_CATALOG ,"42000", "" },
|
||||
{ ER_UNKNOWN_STORAGE_ENGINE ,"42000", "" },
|
||||
{ ER_TRUNCATED_WRONG_VALUE ,"22007", "" },
|
||||
{ ER_SP_NO_RECURSIVE_CREATE ,"2F003", "" },
|
||||
{ ER_SP_ALREADY_EXISTS ,"42000", "" },
|
||||
{ ER_SP_DOES_NOT_EXIST ,"42000", "" },
|
||||
{ ER_SP_LILABEL_MISMATCH ,"42000", "" },
|
||||
{ ER_SP_LABEL_REDEFINE ,"42000", "" },
|
||||
{ ER_SP_LABEL_MISMATCH ,"42000", "" },
|
||||
{ ER_SP_UNINIT_VAR ,"01000", "" },
|
||||
{ ER_SP_BADSELECT ,"0A000", "" },
|
||||
{ ER_SP_BADRETURN ,"42000", "" },
|
||||
{ ER_SP_BADSTATEMENT ,"0A000", "" },
|
||||
{ ER_UPDATE_LOG_DEPRECATED_IGNORED ,"42000", "" },
|
||||
{ ER_UPDATE_LOG_DEPRECATED_TRANSLATED ,"42000", "" },
|
||||
{ ER_QUERY_INTERRUPTED ,"70100", "" },
|
||||
{ ER_SP_WRONG_NO_OF_ARGS ,"42000", "" },
|
||||
{ ER_SP_COND_MISMATCH ,"42000", "" },
|
||||
{ ER_SP_NORETURN ,"42000", "" },
|
||||
{ ER_SP_NORETURNEND ,"2F005", "" },
|
||||
{ ER_SP_BAD_CURSOR_QUERY ,"42000", "" },
|
||||
{ ER_SP_BAD_CURSOR_SELECT ,"42000", "" },
|
||||
{ ER_SP_CURSOR_MISMATCH ,"42000", "" },
|
||||
{ ER_SP_CURSOR_ALREADY_OPEN ,"24000", "" },
|
||||
{ ER_SP_CURSOR_NOT_OPEN ,"24000", "" },
|
||||
{ ER_SP_UNDECLARED_VAR ,"42000", "" },
|
||||
{ ER_SP_FETCH_NO_DATA ,"02000", "" },
|
||||
{ ER_SP_DUP_PARAM ,"42000", "" },
|
||||
{ ER_SP_DUP_VAR ,"42000", "" },
|
||||
{ ER_SP_DUP_COND ,"42000", "" },
|
||||
{ ER_SP_DUP_CURS ,"42000", "" },
|
||||
{ ER_SP_SUBSELECT_NYI ,"0A000", "" },
|
||||
{ ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG ,"0A000", "" },
|
||||
{ ER_SP_VARCOND_AFTER_CURSHNDLR ,"42000", "" },
|
||||
{ ER_SP_CURSOR_AFTER_HANDLER ,"42000", "" },
|
||||
{ ER_SP_CASE_NOT_FOUND ,"20000", "" },
|
||||
{ ER_DIVISION_BY_ZERO ,"22012", "" },
|
||||
{ ER_ILLEGAL_VALUE_FOR_TYPE ,"22007", "" },
|
||||
{ ER_PROCACCESS_DENIED_ERROR ,"42000", "" },
|
||||
{ ER_XAER_NOTA ,"XAE04", "" },
|
||||
{ ER_XAER_INVAL ,"XAE05", "" },
|
||||
{ ER_XAER_RMFAIL ,"XAE07", "" },
|
||||
{ ER_XAER_OUTSIDE ,"XAE09", "" },
|
||||
{ ER_XAER_RMERR ,"XAE03", "" },
|
||||
{ ER_XA_RBROLLBACK ,"XA100", "" },
|
||||
{ ER_NONEXISTING_PROC_GRANT ,"42000", "" },
|
||||
{ ER_DATA_TOO_LONG ,"22001", "" },
|
||||
{ ER_SP_BAD_SQLSTATE ,"42000", "" },
|
||||
{ ER_CANT_CREATE_USER_WITH_GRANT ,"42000", "" },
|
||||
{ ER_SP_DUP_HANDLER ,"42000", "" },
|
||||
{ ER_SP_NOT_VAR_ARG ,"42000", "" },
|
||||
{ ER_SP_NO_RETSET ,"0A000", "" },
|
||||
{ ER_CANT_CREATE_GEOMETRY_OBJECT ,"22003", "" },
|
||||
{ ER_TOO_BIG_SCALE ,"42000", "S1009" },
|
||||
{ ER_TOO_BIG_PRECISION ,"42000", "S1009" },
|
||||
{ ER_M_BIGGER_THAN_D ,"42000", "S1009" },
|
||||
{ ER_TOO_LONG_BODY ,"42000", "S1009" },
|
||||
{ ER_TOO_BIG_DISPLAYWIDTH ,"42000", "S1009" },
|
||||
{ ER_XAER_DUPID ,"XAE08", "" },
|
||||
{ ER_DATETIME_FUNCTION_OVERFLOW ,"22008", "" },
|
||||
{ ER_ROW_IS_REFERENCED_2 ,"23000", "" },
|
||||
{ ER_NO_REFERENCED_ROW_2 ,"23000", "" },
|
||||
{ ER_SP_BAD_VAR_SHADOW ,"42000", "" },
|
||||
{ ER_SP_WRONG_NAME ,"42000", "" },
|
||||
{ ER_SP_NO_AGGREGATE ,"42000", "" },
|
||||
{ ER_MAX_PREPARED_STMT_COUNT_REACHED ,"42000", "" },
|
||||
{ ER_NON_GROUPING_FIELD_USED ,"42000", "" },
|
||||
{ ER_FOREIGN_DUPLICATE_KEY_OLD_UNUSED ,"23000", "S1009" },
|
||||
{ ER_CANT_CHANGE_TX_CHARACTERISTICS ,"25001", "" },
|
||||
{ ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT ,"42000", "" },
|
||||
{ ER_WRONG_PARAMETERS_TO_NATIVE_FCT ,"42000", "" },
|
||||
{ ER_WRONG_PARAMETERS_TO_STORED_FCT ,"42000", "" },
|
||||
{ ER_DUP_ENTRY_WITH_KEY_NAME ,"23000", "S1009" },
|
||||
{ ER_XA_RBTIMEOUT ,"XA106", "" },
|
||||
{ ER_XA_RBDEADLOCK ,"XA102", "" },
|
||||
{ ER_FUNC_INEXISTENT_NAME_COLLISION ,"42000", "" },
|
||||
{ ER_DUP_SIGNAL_SET ,"42000", "" },
|
||||
{ ER_SIGNAL_WARN ,"01000", "" },
|
||||
{ ER_SIGNAL_NOT_FOUND ,"02000", "" },
|
||||
{ ER_SIGNAL_EXCEPTION ,"HY000", "" },
|
||||
{ ER_RESIGNAL_WITHOUT_ACTIVE_HANDLER ,"0K000", "" },
|
||||
{ ER_SPATIAL_MUST_HAVE_GEOM_COL ,"42000", "" },
|
||||
{ ER_DATA_OUT_OF_RANGE ,"22003", "" },
|
||||
{ ER_ACCESS_DENIED_NO_PASSWORD_ERROR ,"28000", "" },
|
||||
{ ER_TRUNCATE_ILLEGAL_FK ,"42000", "" },
|
||||
{ ER_DA_INVALID_CONDITION_NUMBER ,"35000", "" },
|
||||
{ ER_FOREIGN_DUPLICATE_KEY_WITH_CHILD_INFO,"23000", "S1009" },
|
||||
{ ER_FOREIGN_DUPLICATE_KEY_WITHOUT_CHILD_INFO,"23000", "S1009" },
|
||||
{ ER_CANT_EXECUTE_IN_READ_ONLY_TRANSACTION,"25006", "" },
|
||||
{ ER_ALTER_OPERATION_NOT_SUPPORTED ,"0A000", "" },
|
||||
{ ER_ALTER_OPERATION_NOT_SUPPORTED_REASON ,"0A000", "" },
|
||||
{ ER_DUP_UNKNOWN_IN_INDEX ,"23000", "" },
|
||||
{ ER_ACCESS_DENIED_CHANGE_USER_ERROR ,"28000", "" },
|
||||
{ ER_GET_STACKED_DA_WITHOUT_ACTIVE_HANDLER,"0Z002", "" },
|
||||
{ ER_INVALID_ARGUMENT_FOR_LOGARITHM ,"2201E", "" },
|
||||
{ ER_GIS_INVALID_DATA ,"22023", "" },
|
||||
{ ER_USER_LOCK_WRONG_NAME ,"42000", "" },
|
||||
{ ER_ILLEGAL_USER_VAR ,"42000", "S1009" },
|
||||
{ ER_NET_OK_PACKET_TOO_LARGE ,"08S01", "" },
|
||||
{ ER_WRONG_TABLESPACE_NAME ,"42000", "" },
|
||||
{ ER_LOCKING_SERVICE_WRONG_NAME ,"42000", "" },
|
||||
{ ER_INVALID_JSON_TEXT ,"22032", "" },
|
||||
{ ER_INVALID_JSON_TEXT_IN_PARAM ,"22032", "" },
|
||||
{ ER_INVALID_JSON_PATH ,"42000", "" },
|
||||
{ ER_INVALID_JSON_CHARSET ,"22032", "" },
|
||||
{ ER_INVALID_JSON_CHARSET_IN_FUNCTION ,"22032", "" },
|
||||
{ ER_INVALID_TYPE_FOR_JSON ,"22032", "" },
|
||||
{ ER_INVALID_CAST_TO_JSON ,"22032", "" },
|
||||
{ ER_INVALID_JSON_PATH_CHARSET ,"42000", "" },
|
||||
{ ER_INVALID_JSON_PATH_WILDCARD ,"42000", "" },
|
||||
{ ER_JSON_VALUE_TOO_BIG ,"22032", "" },
|
||||
{ ER_JSON_KEY_TOO_BIG ,"22032", "" },
|
||||
{ ER_JSON_USED_AS_KEY ,"42000", "" },
|
||||
{ ER_JSON_VACUOUS_PATH ,"42000", "" },
|
||||
{ ER_JSON_BAD_ONE_OR_ALL_ARG ,"42000", "" },
|
||||
{ ER_NUMERIC_JSON_VALUE_OUT_OF_RANGE ,"22003", "" },
|
||||
{ ER_INVALID_JSON_VALUE_FOR_CAST ,"22018", "" },
|
||||
{ ER_JSON_DOCUMENT_TOO_DEEP ,"22032", "" },
|
||||
{ ER_JSON_DOCUMENT_NULL_KEY ,"22032", "" },
|
||||
{ ER_INVALID_JSON_PATH_ARRAY_CELL ,"42000", "" },
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
|
||||
|
||||
#ifndef MYSQL_CLIENT
|
||||
#error This header is supposed to be used only in the client
|
||||
#endif
|
||||
|
||||
case OPT_SSL_MODE:
|
||||
opt_ssl_mode= find_type_or_exit(argument, &ssl_mode_typelib,
|
||||
opt->name);
|
||||
ssl_mode_set_explicitly= TRUE;
|
||||
break;
|
||||
case OPT_SSL_SSL:
|
||||
CLIENT_WARN_DEPRECATED("--ssl", "--ssl-mode");
|
||||
if (!opt_use_ssl_arg)
|
||||
opt_ssl_mode= SSL_MODE_DISABLED;
|
||||
else if (opt_ssl_mode < SSL_MODE_REQUIRED)
|
||||
opt_ssl_mode= SSL_MODE_REQUIRED;
|
||||
break;
|
||||
case OPT_SSL_VERIFY_SERVER_CERT:
|
||||
CLIENT_WARN_DEPRECATED("--ssl-verify-server-cert",
|
||||
"--ssl-mode=VERIFY_IDENTITY");
|
||||
if (!opt_ssl_verify_server_cert_arg)
|
||||
{
|
||||
if (opt_ssl_mode >= SSL_MODE_VERIFY_IDENTITY)
|
||||
opt_ssl_mode= SSL_MODE_VERIFY_CA;
|
||||
}
|
||||
else
|
||||
opt_ssl_mode= SSL_MODE_VERIFY_IDENTITY;
|
||||
break;
|
||||
case OPT_SSL_CA:
|
||||
case OPT_SSL_CAPATH:
|
||||
/* Don't change ssl-mode if set explicitly. */
|
||||
if (!ssl_mode_set_explicitly)
|
||||
opt_ssl_mode= SSL_MODE_VERIFY_CA;
|
||||
break;
|
||||
case OPT_SSL_KEY:
|
||||
case OPT_SSL_CERT:
|
||||
case OPT_SSL_CIPHER:
|
||||
case OPT_SSL_CRL:
|
||||
case OPT_SSL_CRLPATH:
|
||||
case OPT_TLS_VERSION:
|
||||
#ifdef HAVE_YASSL
|
||||
/* crl has no effect in yaSSL. */
|
||||
opt_ssl_crl= NULL;
|
||||
opt_ssl_crlpath= NULL;
|
||||
#endif /* HAVE_YASSL */
|
||||
break;
|
||||
#endif /* HAVE_OPENSSL */
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
|
||||
#ifdef MYSQL_CLIENT
|
||||
{"ssl-mode", OPT_SSL_MODE,
|
||||
"SSL connection mode.",
|
||||
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"ssl", OPT_SSL_SSL,
|
||||
"Deprecated. Use --ssl-mode instead.",
|
||||
&opt_use_ssl_arg, &opt_use_ssl_arg, 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},
|
||||
{"ssl-verify-server-cert", OPT_SSL_VERIFY_SERVER_CERT,
|
||||
"Deprecated. Use --ssl-mode=VERIFY_IDENTITY instead.",
|
||||
&opt_ssl_verify_server_cert_arg, &opt_ssl_verify_server_cert_arg,
|
||||
0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
|
||||
#else
|
||||
{"ssl", OPT_SSL_SSL,
|
||||
"If set to ON, this option enforces that SSL is established before client "
|
||||
"attempts to authenticate to the server. To disable client SSL capabilities "
|
||||
"use --ssl=OFF.",
|
||||
&opt_use_ssl, &opt_use_ssl, 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},
|
||||
#endif
|
||||
{"ssl-ca", OPT_SSL_CA,
|
||||
"CA file in PEM format.",
|
||||
&opt_ssl_ca, &opt_ssl_ca, 0, GET_STR, REQUIRED_ARG,
|
||||
0, 0, 0, 0, 0, 0},
|
||||
{"ssl-capath", OPT_SSL_CAPATH,
|
||||
"CA directory.",
|
||||
&opt_ssl_capath, &opt_ssl_capath, 0, GET_STR, REQUIRED_ARG,
|
||||
0, 0, 0, 0, 0, 0},
|
||||
{"ssl-cert", OPT_SSL_CERT, "X509 cert in PEM format.",
|
||||
&opt_ssl_cert, &opt_ssl_cert, 0, GET_STR, REQUIRED_ARG,
|
||||
0, 0, 0, 0, 0, 0},
|
||||
{"ssl-cipher", OPT_SSL_CIPHER, "SSL cipher to use.",
|
||||
&opt_ssl_cipher, &opt_ssl_cipher, 0, GET_STR, REQUIRED_ARG,
|
||||
0, 0, 0, 0, 0, 0},
|
||||
{"ssl-key", OPT_SSL_KEY, "X509 key in PEM format.",
|
||||
&opt_ssl_key, &opt_ssl_key, 0, GET_STR, REQUIRED_ARG,
|
||||
0, 0, 0, 0, 0, 0},
|
||||
{"ssl-crl", OPT_SSL_CRL, "Certificate revocation list.",
|
||||
&opt_ssl_crl, &opt_ssl_crl, 0, GET_STR, REQUIRED_ARG,
|
||||
0, 0, 0, 0, 0, 0},
|
||||
{"ssl-crlpath", OPT_SSL_CRLPATH,
|
||||
"Certificate revocation list path.",
|
||||
&opt_ssl_crlpath, &opt_ssl_crlpath, 0, GET_STR, REQUIRED_ARG,
|
||||
0, 0, 0, 0, 0, 0},
|
||||
{"tls-version", OPT_TLS_VERSION, "TLS version to use, "
|
||||
#ifndef HAVE_YASSL
|
||||
"permitted values are: TLSv1, TLSv1.1, TLSv1.2",
|
||||
#else
|
||||
"permitted values are: TLSv1, TLSv1.1",
|
||||
#endif
|
||||
&opt_tls_version, &opt_tls_version, 0, GET_STR, REQUIRED_ARG,
|
||||
0, 0, 0, 0, 0, 0},
|
||||
#endif /* HAVE_OPENSSL */
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#ifndef SSLOPT_VARS_INCLUDED
|
||||
#define SSLOPT_VARS_INCLUDED
|
||||
|
||||
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
|
||||
|
||||
#ifndef MYSQL_CLIENT
|
||||
#error This header is supposed to be used only in the client
|
||||
#endif
|
||||
|
||||
const char *ssl_mode_names_lib[] =
|
||||
{"DISABLED", "PREFERRED", "REQUIRED", "VERIFY_CA", "VERIFY_IDENTITY",
|
||||
NullS };
|
||||
TYPELIB ssl_mode_typelib = {array_elements(ssl_mode_names_lib) - 1, "",
|
||||
ssl_mode_names_lib, NULL};
|
||||
|
||||
static uint opt_ssl_mode = SSL_MODE_PREFERRED;
|
||||
static char *opt_ssl_ca = 0;
|
||||
static char *opt_ssl_capath = 0;
|
||||
static char *opt_ssl_cert = 0;
|
||||
static char *opt_ssl_cipher = 0;
|
||||
static char *opt_ssl_key = 0;
|
||||
static char *opt_ssl_crl = 0;
|
||||
static char *opt_ssl_crlpath = 0;
|
||||
static char *opt_tls_version = 0;
|
||||
static my_bool ssl_mode_set_explicitly= FALSE;
|
||||
static my_bool opt_use_ssl_arg= TRUE;
|
||||
static my_bool opt_ssl_verify_server_cert_arg= FALSE;
|
||||
|
||||
static void set_client_ssl_options(MYSQL *mysql)
|
||||
{
|
||||
/*
|
||||
Print a warning if explicitly defined combination of --ssl-mode other than
|
||||
VERIFY_CA or VERIFY_IDENTITY with explicit --ssl-ca or --ssl-capath values.
|
||||
*/
|
||||
if (ssl_mode_set_explicitly &&
|
||||
opt_ssl_mode < SSL_MODE_VERIFY_CA &&
|
||||
(opt_ssl_ca || opt_ssl_capath))
|
||||
{
|
||||
printf("WARNING: no verification of server certificate will be done. "
|
||||
"Use --ssl-mode=VERIFY_CA or VERIFY_IDENTITY.\n");
|
||||
}
|
||||
|
||||
/* Set SSL parameters: key, cert, ca, capath, cipher, clr, clrpath. */
|
||||
if (opt_ssl_mode >= SSL_MODE_VERIFY_CA)
|
||||
mysql_ssl_set(mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
|
||||
opt_ssl_capath, opt_ssl_cipher);
|
||||
else
|
||||
mysql_ssl_set(mysql, opt_ssl_key, opt_ssl_cert, NULL,
|
||||
NULL, opt_ssl_cipher);
|
||||
mysql_options(mysql, MYSQL_OPT_SSL_CRL, opt_ssl_crl);
|
||||
mysql_options(mysql, MYSQL_OPT_SSL_CRLPATH, opt_ssl_crlpath);
|
||||
mysql_options(mysql, MYSQL_OPT_TLS_VERSION, opt_tls_version);
|
||||
mysql_options(mysql, MYSQL_OPT_SSL_MODE, &opt_ssl_mode);
|
||||
}
|
||||
|
||||
#define SSL_SET_OPTIONS(mysql) set_client_ssl_options(mysql);
|
||||
#else
|
||||
#define SSL_SET_OPTIONS(mysql) do { } while(0)
|
||||
#endif
|
||||
#endif /* SSLOPT_VARS_INCLUDED */
|
||||
|
|
@ -1,201 +0,0 @@
|
|||
#ifndef THR_COND_INCLUDED
|
||||
#define THR_COND_INCLUDED
|
||||
|
||||
/* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
/**
|
||||
MySQL condition variable implementation.
|
||||
|
||||
There are three "layers":
|
||||
1) native_cond_*()
|
||||
Functions that map directly down to OS primitives.
|
||||
Windows - ConditionVariable
|
||||
Other OSes - pthread
|
||||
2) my_cond_*()
|
||||
Functions that use SAFE_MUTEX (default for debug).
|
||||
Otherwise native_cond_*() is used.
|
||||
3) mysql_cond*()
|
||||
Functions that include Performance Schema instrumentation.
|
||||
See include/mysql/psi/mysql_thread.h
|
||||
*/
|
||||
|
||||
#include "my_thread.h"
|
||||
#include "thr_mutex.h"
|
||||
|
||||
C_MODE_START
|
||||
|
||||
#ifdef _WIN32
|
||||
typedef CONDITION_VARIABLE native_cond_t;
|
||||
#else
|
||||
typedef pthread_cond_t native_cond_t;
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
/**
|
||||
Convert abstime to milliseconds
|
||||
*/
|
||||
|
||||
static DWORD get_milliseconds(const struct timespec *abstime)
|
||||
{
|
||||
#ifndef HAVE_STRUCT_TIMESPEC
|
||||
long long millis;
|
||||
union ft64 now;
|
||||
|
||||
if (abstime == NULL)
|
||||
return INFINITE;
|
||||
|
||||
GetSystemTimeAsFileTime(&now.ft);
|
||||
|
||||
/*
|
||||
Calculate time left to abstime
|
||||
- subtract start time from current time(values are in 100ns units)
|
||||
- convert to millisec by dividing with 10000
|
||||
*/
|
||||
millis= (abstime->tv.i64 - now.i64) / 10000;
|
||||
|
||||
/* Don't allow the timeout to be negative */
|
||||
if (millis < 0)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
Make sure the calculated timeout does not exceed original timeout
|
||||
value which could cause "wait for ever" if system time changes
|
||||
*/
|
||||
if (millis > abstime->max_timeout_msec)
|
||||
millis= abstime->max_timeout_msec;
|
||||
|
||||
if (millis > UINT_MAX)
|
||||
millis= UINT_MAX;
|
||||
|
||||
return (DWORD)millis;
|
||||
#else
|
||||
/*
|
||||
Convert timespec to millis and subtract current time.
|
||||
my_getsystime() returns time in 100 ns units.
|
||||
*/
|
||||
ulonglong future= abstime->tv_sec * 1000 + abstime->tv_nsec / 1000000;
|
||||
ulonglong now= my_getsystime() / 10000;
|
||||
/* Don't allow the timeout to be negative. */
|
||||
if (future < now)
|
||||
return 0;
|
||||
return (DWORD)(future - now);
|
||||
#endif
|
||||
}
|
||||
#endif /* _WIN32 */
|
||||
|
||||
static inline int native_cond_init(native_cond_t *cond)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
InitializeConditionVariable(cond);
|
||||
return 0;
|
||||
#else
|
||||
/* pthread_condattr_t is not used in MySQL */
|
||||
return pthread_cond_init(cond, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int native_cond_destroy(native_cond_t *cond)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return 0; /* no destroy function */
|
||||
#else
|
||||
return pthread_cond_destroy(cond);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int native_cond_timedwait(native_cond_t *cond,
|
||||
native_mutex_t *mutex,
|
||||
const struct timespec *abstime)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
DWORD timeout= get_milliseconds(abstime);
|
||||
if (!SleepConditionVariableCS(cond, mutex, timeout))
|
||||
return ETIMEDOUT;
|
||||
return 0;
|
||||
#else
|
||||
return pthread_cond_timedwait(cond, mutex, abstime);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int native_cond_wait(native_cond_t *cond, native_mutex_t *mutex)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (!SleepConditionVariableCS(cond, mutex, INFINITE))
|
||||
return ETIMEDOUT;
|
||||
return 0;
|
||||
#else
|
||||
return pthread_cond_wait(cond, mutex);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int native_cond_signal(native_cond_t *cond)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
WakeConditionVariable(cond);
|
||||
return 0;
|
||||
#else
|
||||
return pthread_cond_signal(cond);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int native_cond_broadcast(native_cond_t *cond)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
WakeAllConditionVariable(cond);
|
||||
return 0;
|
||||
#else
|
||||
return pthread_cond_broadcast(cond);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef SAFE_MUTEX
|
||||
int safe_cond_wait(native_cond_t *cond, my_mutex_t *mp,
|
||||
const char *file, uint line);
|
||||
int safe_cond_timedwait(native_cond_t *cond, my_mutex_t *mp,
|
||||
const struct timespec *abstime,
|
||||
const char *file, uint line);
|
||||
#endif
|
||||
|
||||
static inline int my_cond_timedwait(native_cond_t *cond, my_mutex_t *mp,
|
||||
const struct timespec *abstime
|
||||
#ifdef SAFE_MUTEX
|
||||
, const char *file, uint line
|
||||
#endif
|
||||
)
|
||||
{
|
||||
#ifdef SAFE_MUTEX
|
||||
return safe_cond_timedwait(cond, mp, abstime, file, line);
|
||||
#else
|
||||
return native_cond_timedwait(cond, mp, abstime);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int my_cond_wait(native_cond_t *cond, my_mutex_t *mp
|
||||
#ifdef SAFE_MUTEX
|
||||
, const char *file, uint line
|
||||
#endif
|
||||
)
|
||||
{
|
||||
#ifdef SAFE_MUTEX
|
||||
return safe_cond_wait(cond, mp, file, line);
|
||||
#else
|
||||
return native_cond_wait(cond, mp);
|
||||
#endif
|
||||
}
|
||||
|
||||
C_MODE_END
|
||||
|
||||
#endif /* THR_COND_INCLUDED */
|
||||
|
|
@ -1,227 +0,0 @@
|
|||
#ifndef THR_MUTEX_INCLUDED
|
||||
#define THR_MUTEX_INCLUDED
|
||||
|
||||
/* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
/**
|
||||
MySQL mutex implementation.
|
||||
|
||||
There are three "layers":
|
||||
1) native_mutex_*()
|
||||
Functions that map directly down to OS primitives.
|
||||
Windows - CriticalSection
|
||||
Other OSes - pthread
|
||||
2) my_mutex_*()
|
||||
Functions that implement SAFE_MUTEX (default for debug),
|
||||
Otherwise native_mutex_*() is used.
|
||||
3) mysql_mutex_*()
|
||||
Functions that include Performance Schema instrumentation.
|
||||
See include/mysql/psi/mysql_thread.h
|
||||
*/
|
||||
|
||||
#include <my_global.h>
|
||||
#include "my_thread.h"
|
||||
|
||||
C_MODE_START
|
||||
|
||||
#ifdef _WIN32
|
||||
typedef CRITICAL_SECTION native_mutex_t;
|
||||
typedef int native_mutexattr_t;
|
||||
#else
|
||||
typedef pthread_mutex_t native_mutex_t;
|
||||
typedef pthread_mutexattr_t native_mutexattr_t;
|
||||
#endif
|
||||
|
||||
/* Define mutex types, see my_thr_init.c */
|
||||
#define MY_MUTEX_INIT_SLOW NULL
|
||||
|
||||
/* Can be set in /usr/include/pthread.h */
|
||||
#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
|
||||
extern native_mutexattr_t my_fast_mutexattr;
|
||||
#define MY_MUTEX_INIT_FAST &my_fast_mutexattr
|
||||
#else
|
||||
#define MY_MUTEX_INIT_FAST NULL
|
||||
#endif
|
||||
|
||||
/* Can be set in /usr/include/pthread.h */
|
||||
#ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
|
||||
extern native_mutexattr_t my_errorcheck_mutexattr;
|
||||
#define MY_MUTEX_INIT_ERRCHK &my_errorcheck_mutexattr
|
||||
#else
|
||||
#define MY_MUTEX_INIT_ERRCHK NULL
|
||||
#endif
|
||||
|
||||
static inline int native_mutex_init(native_mutex_t *mutex,
|
||||
const native_mutexattr_t *attr)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
InitializeCriticalSection(mutex);
|
||||
return 0;
|
||||
#else
|
||||
return pthread_mutex_init(mutex, attr);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int native_mutex_lock(native_mutex_t *mutex)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
EnterCriticalSection(mutex);
|
||||
return 0;
|
||||
#else
|
||||
return pthread_mutex_lock(mutex);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int native_mutex_trylock(native_mutex_t *mutex)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (TryEnterCriticalSection(mutex))
|
||||
{
|
||||
/* Don't allow recursive lock */
|
||||
if (mutex->RecursionCount > 1){
|
||||
LeaveCriticalSection(mutex);
|
||||
return EBUSY;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return EBUSY;
|
||||
#else
|
||||
return pthread_mutex_trylock(mutex);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int native_mutex_unlock(native_mutex_t *mutex)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
LeaveCriticalSection(mutex);
|
||||
return 0;
|
||||
#else
|
||||
return pthread_mutex_unlock(mutex);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int native_mutex_destroy(native_mutex_t *mutex)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
DeleteCriticalSection(mutex);
|
||||
return 0;
|
||||
#else
|
||||
return pthread_mutex_destroy(mutex);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifdef SAFE_MUTEX
|
||||
/* safe_mutex adds checking to mutex for easier debugging */
|
||||
typedef struct st_safe_mutex_t
|
||||
{
|
||||
native_mutex_t global, mutex;
|
||||
const char *file;
|
||||
uint line, count;
|
||||
my_thread_t thread;
|
||||
} my_mutex_t;
|
||||
|
||||
void safe_mutex_global_init();
|
||||
int safe_mutex_init(my_mutex_t *mp, const native_mutexattr_t *attr,
|
||||
const char *file, uint line);
|
||||
int safe_mutex_lock(my_mutex_t *mp, my_bool try_lock, const char *file, uint line);
|
||||
int safe_mutex_unlock(my_mutex_t *mp, const char *file, uint line);
|
||||
int safe_mutex_destroy(my_mutex_t *mp, const char *file, uint line);
|
||||
|
||||
static inline void safe_mutex_assert_owner(const my_mutex_t *mp)
|
||||
{
|
||||
DBUG_ASSERT(mp->count > 0 &&
|
||||
my_thread_equal(my_thread_self(), mp->thread));
|
||||
}
|
||||
|
||||
static inline void safe_mutex_assert_not_owner(const my_mutex_t *mp)
|
||||
{
|
||||
DBUG_ASSERT(!mp->count ||
|
||||
!my_thread_equal(my_thread_self(), mp->thread));
|
||||
}
|
||||
|
||||
#else
|
||||
typedef native_mutex_t my_mutex_t;
|
||||
#endif
|
||||
|
||||
static inline int my_mutex_init(my_mutex_t *mp, const native_mutexattr_t *attr
|
||||
#ifdef SAFE_MUTEX
|
||||
, const char *file, uint line
|
||||
#endif
|
||||
)
|
||||
{
|
||||
#ifdef SAFE_MUTEX
|
||||
return safe_mutex_init(mp, attr, file, line);
|
||||
#else
|
||||
return native_mutex_init(mp, attr);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int my_mutex_lock(my_mutex_t *mp
|
||||
#ifdef SAFE_MUTEX
|
||||
, const char *file, uint line
|
||||
#endif
|
||||
)
|
||||
{
|
||||
#ifdef SAFE_MUTEX
|
||||
return safe_mutex_lock(mp, FALSE, file, line);
|
||||
#else
|
||||
return native_mutex_lock(mp);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int my_mutex_trylock(my_mutex_t *mp
|
||||
#ifdef SAFE_MUTEX
|
||||
, const char *file, uint line
|
||||
#endif
|
||||
)
|
||||
{
|
||||
#ifdef SAFE_MUTEX
|
||||
return safe_mutex_lock(mp, TRUE, file, line);
|
||||
#else
|
||||
return native_mutex_trylock(mp);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int my_mutex_unlock(my_mutex_t *mp
|
||||
#ifdef SAFE_MUTEX
|
||||
, const char *file, uint line
|
||||
#endif
|
||||
)
|
||||
{
|
||||
#ifdef SAFE_MUTEX
|
||||
return safe_mutex_unlock(mp, file, line);
|
||||
#else
|
||||
return native_mutex_unlock(mp);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int my_mutex_destroy(my_mutex_t *mp
|
||||
#ifdef SAFE_MUTEX
|
||||
, const char *file, uint line
|
||||
#endif
|
||||
)
|
||||
{
|
||||
#ifdef SAFE_MUTEX
|
||||
return safe_mutex_destroy(mp, file, line);
|
||||
#else
|
||||
return native_mutex_destroy(mp);
|
||||
#endif
|
||||
}
|
||||
|
||||
C_MODE_END
|
||||
|
||||
#endif /* THR_MUTEX_INCLUDED */
|
||||
|
|
@ -1,214 +0,0 @@
|
|||
#ifndef THR_RWLOCK_INCLUDED
|
||||
#define THR_RWLOCK_INCLUDED
|
||||
|
||||
/* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
/**
|
||||
MySQL rwlock implementation.
|
||||
|
||||
There are two "layers":
|
||||
1) native_rw_*()
|
||||
Functions that map directly down to OS primitives.
|
||||
Windows - SRWLock
|
||||
Other OSes - pthread
|
||||
2) mysql_rw*()
|
||||
Functions that include Performance Schema instrumentation.
|
||||
See include/mysql/psi/mysql_thread.h
|
||||
|
||||
This file also includes rw_pr_*(), which implements a special
|
||||
version of rwlocks that prefer readers. The P_S version of these
|
||||
are mysql_prlock_*() - see include/mysql/psi/mysql_thread.h
|
||||
*/
|
||||
|
||||
#include "my_global.h"
|
||||
#include "my_thread.h"
|
||||
#include "thr_cond.h"
|
||||
|
||||
C_MODE_START
|
||||
|
||||
#ifdef _WIN32
|
||||
typedef struct st_my_rw_lock_t
|
||||
{
|
||||
SRWLOCK srwlock; /* native reader writer lock */
|
||||
BOOL have_exclusive_srwlock; /* used for unlock */
|
||||
} native_rw_lock_t;
|
||||
#else
|
||||
typedef pthread_rwlock_t native_rw_lock_t;
|
||||
#endif
|
||||
|
||||
static inline int native_rw_init(native_rw_lock_t *rwp)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
InitializeSRWLock(&rwp->srwlock);
|
||||
rwp->have_exclusive_srwlock = FALSE;
|
||||
return 0;
|
||||
#else
|
||||
/* pthread_rwlockattr_t is not used in MySQL */
|
||||
return pthread_rwlock_init(rwp, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int native_rw_destroy(native_rw_lock_t *rwp)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return 0; /* no destroy function */
|
||||
#else
|
||||
return pthread_rwlock_destroy(rwp);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int native_rw_rdlock(native_rw_lock_t *rwp)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
AcquireSRWLockShared(&rwp->srwlock);
|
||||
return 0;
|
||||
#else
|
||||
return pthread_rwlock_rdlock(rwp);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int native_rw_tryrdlock(native_rw_lock_t *rwp)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (!TryAcquireSRWLockShared(&rwp->srwlock))
|
||||
return EBUSY;
|
||||
return 0;
|
||||
#else
|
||||
return pthread_rwlock_tryrdlock(rwp);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int native_rw_wrlock(native_rw_lock_t *rwp)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
AcquireSRWLockExclusive(&rwp->srwlock);
|
||||
rwp->have_exclusive_srwlock= TRUE;
|
||||
return 0;
|
||||
#else
|
||||
return pthread_rwlock_wrlock(rwp);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int native_rw_trywrlock(native_rw_lock_t *rwp)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (!TryAcquireSRWLockExclusive(&rwp->srwlock))
|
||||
return EBUSY;
|
||||
rwp->have_exclusive_srwlock= TRUE;
|
||||
return 0;
|
||||
#else
|
||||
return pthread_rwlock_trywrlock(rwp);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int native_rw_unlock(native_rw_lock_t *rwp)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (rwp->have_exclusive_srwlock)
|
||||
{
|
||||
rwp->have_exclusive_srwlock= FALSE;
|
||||
ReleaseSRWLockExclusive(&rwp->srwlock);
|
||||
}
|
||||
else
|
||||
ReleaseSRWLockShared(&rwp->srwlock);
|
||||
return 0;
|
||||
#else
|
||||
return pthread_rwlock_unlock(rwp);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Portable implementation of special type of read-write locks.
|
||||
|
||||
These locks have two properties which are unusual for rwlocks:
|
||||
1) They "prefer readers" in the sense that they do not allow
|
||||
situations in which rwlock is rd-locked and there is a
|
||||
pending rd-lock which is blocked (e.g. due to pending
|
||||
request for wr-lock).
|
||||
This is a stronger guarantee than one which is provided for
|
||||
PTHREAD_RWLOCK_PREFER_READER_NP rwlocks in Linux.
|
||||
MDL subsystem deadlock detector relies on this property for
|
||||
its correctness.
|
||||
2) They are optimized for uncontended wr-lock/unlock case.
|
||||
This is scenario in which they are most oftenly used
|
||||
within MDL subsystem. Optimizing for it gives significant
|
||||
performance improvements in some of tests involving many
|
||||
connections.
|
||||
|
||||
Another important requirement imposed on this type of rwlock
|
||||
by the MDL subsystem is that it should be OK to destroy rwlock
|
||||
object which is in unlocked state even though some threads might
|
||||
have not yet fully left unlock operation for it (of course there
|
||||
is an external guarantee that no thread will try to lock rwlock
|
||||
which is destroyed).
|
||||
Putting it another way the unlock operation should not access
|
||||
rwlock data after changing its state to unlocked.
|
||||
|
||||
TODO/FIXME: We should consider alleviating this requirement as
|
||||
it blocks us from doing certain performance optimizations.
|
||||
*/
|
||||
|
||||
typedef struct st_rw_pr_lock_t {
|
||||
/**
|
||||
Lock which protects the structure.
|
||||
Also held for the duration of wr-lock.
|
||||
*/
|
||||
native_mutex_t lock;
|
||||
/**
|
||||
Condition variable which is used to wake-up
|
||||
writers waiting for readers to go away.
|
||||
*/
|
||||
native_cond_t no_active_readers;
|
||||
/** Number of active readers. */
|
||||
uint active_readers;
|
||||
/** Number of writers waiting for readers to go away. */
|
||||
uint writers_waiting_readers;
|
||||
/** Indicates whether there is an active writer. */
|
||||
my_bool active_writer;
|
||||
#ifdef SAFE_MUTEX
|
||||
/** Thread holding wr-lock (for debug purposes only). */
|
||||
my_thread_t writer_thread;
|
||||
#endif
|
||||
} rw_pr_lock_t;
|
||||
|
||||
extern int rw_pr_init(rw_pr_lock_t *);
|
||||
extern int rw_pr_rdlock(rw_pr_lock_t *);
|
||||
extern int rw_pr_wrlock(rw_pr_lock_t *);
|
||||
extern int rw_pr_unlock(rw_pr_lock_t *);
|
||||
extern int rw_pr_destroy(rw_pr_lock_t *);
|
||||
|
||||
static inline void
|
||||
rw_pr_lock_assert_write_owner(const rw_pr_lock_t *rwlock MY_ATTRIBUTE((unused)))
|
||||
{
|
||||
#ifdef SAFE_MUTEX
|
||||
DBUG_ASSERT(rwlock->active_writer &&
|
||||
my_thread_equal(my_thread_self(), rwlock->writer_thread));
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void
|
||||
rw_pr_lock_assert_not_write_owner(const rw_pr_lock_t *rwlock MY_ATTRIBUTE((unused)))
|
||||
{
|
||||
#ifdef SAFE_MUTEX
|
||||
DBUG_ASSERT(!rwlock->active_writer ||
|
||||
!my_thread_equal(my_thread_self(), rwlock->writer_thread));
|
||||
#endif
|
||||
}
|
||||
|
||||
C_MODE_END
|
||||
|
||||
#endif /* THR_RWLOCK_INCLUDED */
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
|
||||
|
||||
|
||||
#ifndef _typelib_h
|
||||
#define _typelib_h
|
||||
|
||||
#include "my_alloc.h"
|
||||
|
||||
typedef struct st_typelib { /* Different types saved here */
|
||||
unsigned int count; /* How many types */
|
||||
const char *name; /* Name of typelib */
|
||||
const char **type_names;
|
||||
unsigned int *type_lengths;
|
||||
} TYPELIB;
|
||||
|
||||
extern my_ulonglong find_typeset(char *x, TYPELIB *typelib,int *error_position);
|
||||
extern int find_type_or_exit(const char *x, TYPELIB *typelib,
|
||||
const char *option);
|
||||
#define FIND_TYPE_BASIC 0
|
||||
/** makes @c find_type() require the whole name, no prefix */
|
||||
#define FIND_TYPE_NO_PREFIX (1 << 0)
|
||||
/** always implicitely on, so unused, but old code may pass it */
|
||||
#define FIND_TYPE_NO_OVERWRITE (1 << 1)
|
||||
/** makes @c find_type() accept a number */
|
||||
#define FIND_TYPE_ALLOW_NUMBER (1 << 2)
|
||||
/** makes @c find_type() treat ',' as terminator */
|
||||
#define FIND_TYPE_COMMA_TERM (1 << 3)
|
||||
|
||||
extern int find_type(const char *x, const TYPELIB *typelib, unsigned int flags);
|
||||
extern void make_type(char *to,unsigned int nr,TYPELIB *typelib);
|
||||
extern const char *get_type(TYPELIB *typelib,unsigned int nr);
|
||||
extern TYPELIB *copy_typelib(MEM_ROOT *root, TYPELIB *from);
|
||||
|
||||
extern TYPELIB sql_protocol_typelib;
|
||||
|
||||
my_ulonglong find_set_from_flags(const TYPELIB *lib, unsigned int default_name,
|
||||
my_ulonglong cur_set, my_ulonglong default_set,
|
||||
const char *str, unsigned int length,
|
||||
char **err_pos, unsigned int *err_len);
|
||||
|
||||
#endif /* _typelib_h */
|
||||
Binary file not shown.
BIN
src/common/mysql/lib/libmysql.lib
Normal file
BIN
src/common/mysql/lib/libmysql.lib
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -117,7 +117,7 @@ BEGIN
|
|||
CTEXT "___________________________________________________________________________", 4, 0, 32, 320, 8
|
||||
LTEXT "This software makes use of:", 5, 10, 46, 100, 8
|
||||
LTEXT "libev library (v4.33)\nCopyright (C) 2007-2020 Marc Alexander Lehmann", 6, 15, 62, 290, 16
|
||||
LTEXT "MySQL Connector/C (v6.1.11)\nGeneral Public License (GPL) 2000-2017 Oracle", 7, 15, 86, 290, 16
|
||||
LTEXT "MySQL C API (v8.0.46)\nCopyright (C) 2000-2026 Oracle and/or its affiliates", 7, 15, 86, 290, 16
|
||||
LTEXT "SQLite library (v3.53.3)\nGeneral Public License (GPL) 2000-2026", 8, 15, 110, 290, 16
|
||||
LTEXT "Twofish encryption library (v1.0)\nCopyright (C) 1998 Bruce Schneier, Doug Whiting, John Kelsey, Chris Hall, David Wagner", 9, 15, 134, 290, 16
|
||||
LTEXT "zlib data compression library (v1.3.2)\nCopyright (C) 1995-2026 Jean-loup Gailly, Mark Adler", 10, 15, 158, 290, 16
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue