提交数据库保存dll源代码
This commit is contained in:
parent
a36590c553
commit
3e1653647b
|
@ -0,0 +1,44 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 16
|
||||||
|
VisualStudioVersion = 16.0.32228.343
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HGPdtToolDb", "HGPdtToolDb\HGPdtToolDb.vcxproj", "{7BDFBCC3-6D52-4FDB-B1ED-D820A3D27246}"
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HGPdtToolDbTest", "HGPdtToolDbTest\HGPdtToolDbTest.vcxproj", "{7F83AD40-A311-44E4-977E-583895B4D7E1}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{7BDFBCC3-6D52-4FDB-B1ED-D820A3D27246} = {7BDFBCC3-6D52-4FDB-B1ED-D820A3D27246}
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Debug|x86 = Debug|x86
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
Release|x86 = Release|x86
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{7BDFBCC3-6D52-4FDB-B1ED-D820A3D27246}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{7BDFBCC3-6D52-4FDB-B1ED-D820A3D27246}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{7BDFBCC3-6D52-4FDB-B1ED-D820A3D27246}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{7BDFBCC3-6D52-4FDB-B1ED-D820A3D27246}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{7BDFBCC3-6D52-4FDB-B1ED-D820A3D27246}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{7BDFBCC3-6D52-4FDB-B1ED-D820A3D27246}.Release|x64.Build.0 = Release|x64
|
||||||
|
{7BDFBCC3-6D52-4FDB-B1ED-D820A3D27246}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{7BDFBCC3-6D52-4FDB-B1ED-D820A3D27246}.Release|x86.Build.0 = Release|Win32
|
||||||
|
{7F83AD40-A311-44E4-977E-583895B4D7E1}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{7F83AD40-A311-44E4-977E-583895B4D7E1}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{7F83AD40-A311-44E4-977E-583895B4D7E1}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{7F83AD40-A311-44E4-977E-583895B4D7E1}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{7F83AD40-A311-44E4-977E-583895B4D7E1}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{7F83AD40-A311-44E4-977E-583895B4D7E1}.Release|x64.Build.0 = Release|x64
|
||||||
|
{7F83AD40-A311-44E4-977E-583895B4D7E1}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{7F83AD40-A311-44E4-977E-583895B4D7E1}.Release|x86.Build.0 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {75C8C155-4BF1-4D65-8E34-13B97C6CA6CB}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
|
@ -0,0 +1,171 @@
|
||||||
|
#include "HGPdtToolDb.h"
|
||||||
|
#include "HGPdtToolDbImpl.hpp"
|
||||||
|
#include "base/HGInc.h"
|
||||||
|
|
||||||
|
HGResult HGAPI HGPdtToolDb_CreateUserMgr(const HGChar* host, HGUShort port,
|
||||||
|
const HGChar* user, const HGChar* pwd, HGPdtToolDbUserMgr* userMgr)
|
||||||
|
{
|
||||||
|
if (NULL == userMgr)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
HGPdtToolDbUserMgrImpl* userMgrImpl = new HGPdtToolDbUserMgrImpl;
|
||||||
|
HGResult ret = userMgrImpl->Create(host, port, user, pwd);
|
||||||
|
if (HGBASE_ERR_OK != ret)
|
||||||
|
{
|
||||||
|
delete userMgrImpl;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
*userMgr = (HGPdtToolDbUserMgr)userMgrImpl;
|
||||||
|
return HGBASE_ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HGResult HGAPI HGPdtToolDb_DestroyUserMgr(HGPdtToolDbUserMgr userMgr)
|
||||||
|
{
|
||||||
|
if (NULL == userMgr)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
HGPdtToolDbUserMgrImpl* userMgrImpl = (HGPdtToolDbUserMgrImpl*)userMgr;
|
||||||
|
HGResult ret = userMgrImpl->Destroy();
|
||||||
|
if (HGBASE_ERR_OK != ret)
|
||||||
|
{
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete userMgrImpl;
|
||||||
|
return HGBASE_ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HGResult HGAPI HGPdtToolDb_Export(HGPdtToolDbUserMgr userMgr, const HGChar* xlsPath)
|
||||||
|
{
|
||||||
|
if (NULL == userMgr)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
HGPdtToolDbUserMgrImpl* userMgrImpl = (HGPdtToolDbUserMgrImpl*)userMgr;
|
||||||
|
return userMgrImpl->Export(xlsPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
HGResult HGAPI HGPdtToolDb_GetUserConfig(HGPdtToolDbUserMgr userMgr, const HGChar* key, HGChar* value, HGUInt maxLen)
|
||||||
|
{
|
||||||
|
if (NULL == userMgr)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
HGPdtToolDbUserMgrImpl* userMgrImpl = (HGPdtToolDbUserMgrImpl*)userMgr;
|
||||||
|
return userMgrImpl->GetConfig(key, value, maxLen);
|
||||||
|
}
|
||||||
|
|
||||||
|
HGResult HGAPI HGPdtToolDb_SetUserConfig(HGPdtToolDbUserMgr userMgr, const HGChar* key, const HGChar* value)
|
||||||
|
{
|
||||||
|
if (NULL == userMgr)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
HGPdtToolDbUserMgrImpl* userMgrImpl = (HGPdtToolDbUserMgrImpl*)userMgr;
|
||||||
|
return userMgrImpl->SetConfig(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
HGResult HGAPI HGPdtToolDb_OpenDevice(HGPdtToolDbUserMgr userMgr, const HGChar* sn, HGPdtToolDbDevice* device)
|
||||||
|
{
|
||||||
|
if (NULL == userMgr || NULL == device)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
HGPdtToolDbUserMgrImpl* userMgrImpl = (HGPdtToolDbUserMgrImpl*)userMgr;
|
||||||
|
HGPdtToolDbDeviceImpl* deviceImpl = NULL;
|
||||||
|
HGResult ret = userMgrImpl->OpenDevice(sn, &deviceImpl);
|
||||||
|
if (HGBASE_ERR_OK != ret)
|
||||||
|
{
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
*device = (HGPdtToolDbDevice)deviceImpl;
|
||||||
|
return HGBASE_ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HGResult HGAPI HGPdtToolDb_CloseDevice(HGPdtToolDbDevice device)
|
||||||
|
{
|
||||||
|
if (NULL == device)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
HGPdtToolDbDeviceImpl* deviceImpl = (HGPdtToolDbDeviceImpl*)device;
|
||||||
|
delete deviceImpl;
|
||||||
|
return HGBASE_ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HGResult HGAPI HGPdtToolDb_GetDeviceCurrEntry(HGPdtToolDbDevice device, HGUInt* entryName)
|
||||||
|
{
|
||||||
|
if (NULL == device)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
HGPdtToolDbDeviceImpl* deviceImpl = (HGPdtToolDbDeviceImpl*)device;
|
||||||
|
return deviceImpl->GetCurrEntry(entryName);
|
||||||
|
}
|
||||||
|
|
||||||
|
HGResult HGAPI HGPdtToolDb_SetDeviceCurrEntry(HGPdtToolDbDevice device, HGUInt entryName)
|
||||||
|
{
|
||||||
|
if (NULL == device)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
HGPdtToolDbDeviceImpl* deviceImpl = (HGPdtToolDbDeviceImpl*)device;
|
||||||
|
return deviceImpl->SetCurrEntry(entryName);
|
||||||
|
}
|
||||||
|
|
||||||
|
HGResult HGAPI HGPdtToolDb_GetDeviceEntryStatus(HGPdtToolDbDevice device, HGUInt entryName, HGUInt* entryStatus)
|
||||||
|
{
|
||||||
|
if (NULL == device)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
HGPdtToolDbDeviceImpl* deviceImpl = (HGPdtToolDbDeviceImpl*)device;
|
||||||
|
return deviceImpl->GetEntryStatus(entryName, entryStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
HGResult HGAPI HGPdtToolDb_GetDeviceEntryExcepDesc(HGPdtToolDbDevice device, HGUInt entryName, HGChar* excepDesc, HGUInt maxLen)
|
||||||
|
{
|
||||||
|
if (NULL == device)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
HGPdtToolDbDeviceImpl* deviceImpl = (HGPdtToolDbDeviceImpl*)device;
|
||||||
|
return deviceImpl->GetEntryExcepDesc(entryName, excepDesc, maxLen);
|
||||||
|
}
|
||||||
|
|
||||||
|
HGResult HGAPI HGPdtToolDb_SetDeviceEntryStatus(HGPdtToolDbDevice device, HGUInt entryName, HGUInt entryStatus)
|
||||||
|
{
|
||||||
|
if (NULL == device)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
HGPdtToolDbDeviceImpl* deviceImpl = (HGPdtToolDbDeviceImpl*)device;
|
||||||
|
return deviceImpl->SetEntryStatus(entryName, entryStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
HGResult HGAPI HGPdtToolDb_SetDeviceEntryExcepDesc(HGPdtToolDbDevice device, HGUInt entryName, const HGChar* excepDesc)
|
||||||
|
{
|
||||||
|
if (NULL == device)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
HGPdtToolDbDeviceImpl* deviceImpl = (HGPdtToolDbDeviceImpl*)device;
|
||||||
|
return deviceImpl->SetEntryExcepDesc(entryName, excepDesc);
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
LIBRARY
|
||||||
|
|
||||||
|
EXPORTS
|
||||||
|
|
||||||
|
HGPdtToolDb_CreateUserMgr
|
||||||
|
HGPdtToolDb_DestroyUserMgr
|
||||||
|
HGPdtToolDb_Export
|
||||||
|
HGPdtToolDb_GetUserConfig
|
||||||
|
HGPdtToolDb_SetUserConfig
|
||||||
|
HGPdtToolDb_OpenDevice
|
||||||
|
HGPdtToolDb_CloseDevice
|
||||||
|
HGPdtToolDb_GetDeviceCurrEntry
|
||||||
|
HGPdtToolDb_SetDeviceCurrEntry
|
||||||
|
HGPdtToolDb_GetDeviceEntryStatus
|
||||||
|
HGPdtToolDb_GetDeviceEntryExcepDesc
|
||||||
|
HGPdtToolDb_SetDeviceEntryStatus
|
||||||
|
HGPdtToolDb_SetDeviceEntryExcepDesc
|
|
@ -0,0 +1,133 @@
|
||||||
|
#ifndef __HGPDTTOOLDB_H__
|
||||||
|
#define __HGPDTTOOLDB_H__
|
||||||
|
|
||||||
|
#include "base/HGDef.h"
|
||||||
|
#include "base/HGBaseErr.h"
|
||||||
|
|
||||||
|
/* 拨码开关校验 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYNAME_DIAL_SWITCH 1L
|
||||||
|
/* 检查船型开关功能 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYNAME_ROCKER_SWITCH 2L
|
||||||
|
/* 设备上电并观察开机状态 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYNAME_BOOT_STATUS 3L
|
||||||
|
/* 检查液晶显示 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYNAME_LCD_DISPLAY 4L
|
||||||
|
/* 清理纸道功能确认 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYNAME_CLEAR_PAPER_PATH 5L
|
||||||
|
/* 按键功能检测 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYNAME_KEY_FUNCTION 6L
|
||||||
|
/* 计数模式检测 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYNAME_COUNTING_MODE 7L
|
||||||
|
/* 歪斜检测 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYNAME_SKEW_DETECTION 8L
|
||||||
|
/* 分纸电机检测 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYNAME_SEPARATER_MOTOR 9L
|
||||||
|
/* CIS原图初检 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYNAME_CIS_ORIGINAL_IMAGE 10L
|
||||||
|
/* 主机风扇功能检测 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYNAME_HOST_FAN 11L
|
||||||
|
/* 超声波模块检验 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYNAME_ULTRASONIC_MODULE 12L
|
||||||
|
/* LED灯状态检查 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYNAME_LED_LIGHT 13L
|
||||||
|
/* 复位检查 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYNAME_RESET 14L
|
||||||
|
/* 走纸检查 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYNAME_PAPER_FEED 15L
|
||||||
|
/* 开盖传感器检查 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYNAME_COVER_SENSOR 16L
|
||||||
|
/* 扫描传感器检查 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYNAME_SCANNING_SENSOR 17L
|
||||||
|
|
||||||
|
/* 配置速度模式 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYNAME_CONFIGURE_SPEED_MODE 101L
|
||||||
|
/* 放置校正纸 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYNAME_PLACE_CORRECTION_PAPER 102L
|
||||||
|
/* 自动平场校正 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYNAME_AUTO_FLAT_FIELD 103L
|
||||||
|
/* 重启设备 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYNAME_REBOOT_DEVICE 104L
|
||||||
|
/* 扫描图像质量确认 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYNAME_IMAGE_QUALITY 105L
|
||||||
|
/* 色卡纸成像质量评估 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYNAME_COLORCARD_IMAGEING_QUALITY 106L
|
||||||
|
/* 色卡纸偏色成像质量评估 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYNAME_COLORCARD_BIAS_IMAGEING_QUALITY 107L
|
||||||
|
/* 清晰度质量评估 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYNAME_CLARITY_QUALITY 108L
|
||||||
|
/* 畸变修正 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYNAME_DISTORTION 109L
|
||||||
|
/* 设置休眠 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYNAME_DORMANCY 110L
|
||||||
|
/* 歪斜挡位检测 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYNAME_SKEW_GEAR 111L
|
||||||
|
/* 分纸强度检测 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYNAME_PAPER_SEPARATION_STRENGTH 112L
|
||||||
|
/* 机械走纸倾斜检测 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYNAME_MECH_PAPER_FEEDING_INCLINATION 113L
|
||||||
|
|
||||||
|
/* 单张测试1 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYNAME_SINGLE_PAGE_TEST_1 201L
|
||||||
|
/* 单张测试2 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYNAME_SINGLE_PAGE_TEST_2 202L
|
||||||
|
/* 单张测试3 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYNAME_SINGLE_PAGE_TEST_3 203L
|
||||||
|
/* 压力测试2轮 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYNAME_PRESSUER_TEST 204L
|
||||||
|
/* 清除滚轴计数 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYNAME_CLEAR_ROLLER_COUNT 205L
|
||||||
|
|
||||||
|
/* 未测试 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYSTATUS_NOTTEST 0L
|
||||||
|
/* 不通过 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYSTATUS_NOTPASS 1L
|
||||||
|
/* 不支持 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYSTATUS_NOTSUPP 2L
|
||||||
|
/* 通过 */
|
||||||
|
#define HGPDTTOOLDB_ENTRYSTATUS_PASS 3L
|
||||||
|
|
||||||
|
HG_DECLARE_HANDLE(HGPdtToolDbUserMgr);
|
||||||
|
HG_DECLARE_HANDLE(HGPdtToolDbDevice);
|
||||||
|
|
||||||
|
/* 登录 */
|
||||||
|
HGEXPORT HGResult HGAPI HGPdtToolDb_CreateUserMgr(const HGChar *host, HGUShort port,
|
||||||
|
const HGChar *user, const HGChar *pwd, HGPdtToolDbUserMgr *userMgr);
|
||||||
|
|
||||||
|
/* 登出 */
|
||||||
|
HGEXPORT HGResult HGAPI HGPdtToolDb_DestroyUserMgr(HGPdtToolDbUserMgr userMgr);
|
||||||
|
|
||||||
|
/* 导出所有设备测试信息到XLS文件 */
|
||||||
|
HGEXPORT HGResult HGAPI HGPdtToolDb_Export(HGPdtToolDbUserMgr userMgr, const HGChar *xlsPath);
|
||||||
|
|
||||||
|
/* 获取用户配置 */
|
||||||
|
HGEXPORT HGResult HGAPI HGPdtToolDb_GetUserConfig(HGPdtToolDbUserMgr userMgr, const HGChar* key, HGChar* value, HGUInt maxLen);
|
||||||
|
|
||||||
|
/* 设置用户配置 */
|
||||||
|
HGEXPORT HGResult HGAPI HGPdtToolDb_SetUserConfig(HGPdtToolDbUserMgr userMgr, const HGChar* key, const HGChar* value);
|
||||||
|
|
||||||
|
/* 创建/打开设备,sn标识设备唯一序列号 */
|
||||||
|
HGEXPORT HGResult HGAPI HGPdtToolDb_OpenDevice(HGPdtToolDbUserMgr userMgr, const HGChar* sn, HGPdtToolDbDevice *device);
|
||||||
|
|
||||||
|
/* 关闭设备 */
|
||||||
|
HGEXPORT HGResult HGAPI HGPdtToolDb_CloseDevice(HGPdtToolDbDevice device);
|
||||||
|
|
||||||
|
/* 获取当前的测试项, 0表示还未测试,0xFFFFFFFF表示已经测试完成 */
|
||||||
|
HGEXPORT HGResult HGAPI HGPdtToolDb_GetDeviceCurrEntry(HGPdtToolDbDevice device, HGUInt *entryName);
|
||||||
|
|
||||||
|
/* 设置当前的测试项, 0表示还未测试,0xFFFFFFFF表示已经测试完成 */
|
||||||
|
HGEXPORT HGResult HGAPI HGPdtToolDb_SetDeviceCurrEntry(HGPdtToolDbDevice device, HGUInt entryName);
|
||||||
|
|
||||||
|
/* 获取某个测试项的状态 */
|
||||||
|
HGEXPORT HGResult HGAPI HGPdtToolDb_GetDeviceEntryStatus(HGPdtToolDbDevice device, HGUInt entryName, HGUInt *entryStatus);
|
||||||
|
|
||||||
|
/* 获取某个测试项的异常说明 */
|
||||||
|
HGEXPORT HGResult HGAPI HGPdtToolDb_GetDeviceEntryExcepDesc(HGPdtToolDbDevice device, HGUInt entryName, HGChar *excepDesc, HGUInt maxLen);
|
||||||
|
|
||||||
|
/* 设置某个测试项的状态 */
|
||||||
|
HGEXPORT HGResult HGAPI HGPdtToolDb_SetDeviceEntryStatus(HGPdtToolDbDevice device, HGUInt entryName, HGUInt entryStatus);
|
||||||
|
|
||||||
|
/* 设置某个测试项的异常说明 */
|
||||||
|
HGEXPORT HGResult HGAPI HGPdtToolDb_SetDeviceEntryExcepDesc(HGPdtToolDbDevice device, HGUInt entryName, const HGChar* excepDesc);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* __HGPDTTOOLDB_H__ */
|
|
@ -0,0 +1,184 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="HGPdtToolDb.cpp" />
|
||||||
|
<ClCompile Include="HGPdtToolDbImpl.cpp" />
|
||||||
|
<ClCompile Include="HGString.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="HGPdtToolDb.def" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="HGPdtToolDb.h" />
|
||||||
|
<ClInclude Include="HGPdtToolDbImpl.hpp" />
|
||||||
|
<ClInclude Include="HGString.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<VCProjectVersion>16.0</VCProjectVersion>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<ProjectGuid>{7bdfbcc3-6d52-4fdb-b1ed-d820a3d27246}</ProjectGuid>
|
||||||
|
<RootNamespace>HGPdtToolDb</RootNamespace>
|
||||||
|
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="Shared">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;HGPDTTOOLDB_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||||
|
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableUAC>false</EnableUAC>
|
||||||
|
<ModuleDefinitionFile>HGPdtToolDb.def</ModuleDefinitionFile>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;HGPDTTOOLDB_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||||
|
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableUAC>false</EnableUAC>
|
||||||
|
<ModuleDefinitionFile>HGPdtToolDb.def</ModuleDefinitionFile>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;HGPDTTOOLDB_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||||
|
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
<AdditionalIncludeDirectories>../include;../../../sdk/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableUAC>false</EnableUAC>
|
||||||
|
<AdditionalLibraryDirectories>../lib/x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
|
<AdditionalDependencies>libmysql.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<ModuleDefinitionFile>HGPdtToolDb.def</ModuleDefinitionFile>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;HGPDTTOOLDB_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||||
|
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<AdditionalIncludeDirectories>../include;../../../sdk/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableUAC>false</EnableUAC>
|
||||||
|
<ModuleDefinitionFile>HGPdtToolDb.def</ModuleDefinitionFile>
|
||||||
|
<AdditionalLibraryDirectories>../lib/x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
|
<AdditionalDependencies>libmysql.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
|
@ -0,0 +1,895 @@
|
||||||
|
#include "HGPdtToolDbImpl.hpp"
|
||||||
|
#include "HGPdtToolDb.h"
|
||||||
|
#include "base/HGInc.h"
|
||||||
|
#include "HGString.h"
|
||||||
|
|
||||||
|
const HGChar* INITTIAL_INSPECTION[] =
|
||||||
|
{
|
||||||
|
"dial_switch",
|
||||||
|
"rocker_switch",
|
||||||
|
"boot_status",
|
||||||
|
"lcd_display",
|
||||||
|
"clear_paper_path",
|
||||||
|
"key_function",
|
||||||
|
"counting_mode",
|
||||||
|
"skew_detection",
|
||||||
|
"separater_motor",
|
||||||
|
"cis_original_image",
|
||||||
|
"host_fan",
|
||||||
|
"ultrasonic_module",
|
||||||
|
"led_light",
|
||||||
|
"reset",
|
||||||
|
"paper_feed",
|
||||||
|
"cover_sensor",
|
||||||
|
"scanning_sensor"
|
||||||
|
};
|
||||||
|
|
||||||
|
const HGChar* INITTIAL_INSPECTION_CN[] =
|
||||||
|
{
|
||||||
|
"拨码开关校验",
|
||||||
|
"检查船型开关功能",
|
||||||
|
"设备上电并观察开机状态",
|
||||||
|
"检查液晶显示",
|
||||||
|
"清理纸道功能确认",
|
||||||
|
"按键功能检测",
|
||||||
|
"计数模式检测",
|
||||||
|
"歪斜检测",
|
||||||
|
"分纸电机检测",
|
||||||
|
"CIS原图初检",
|
||||||
|
"主机风扇功能检测",
|
||||||
|
"超声波模块检验",
|
||||||
|
"LED灯状态检查",
|
||||||
|
"复位检查",
|
||||||
|
"走纸检查",
|
||||||
|
"开盖传感器检查",
|
||||||
|
"扫描传感器检查"
|
||||||
|
};
|
||||||
|
|
||||||
|
const HGChar* IMAGE_INSPECTION[] =
|
||||||
|
{
|
||||||
|
"configure_speed_mode",
|
||||||
|
"place_correction_paper",
|
||||||
|
"auto_flat_field",
|
||||||
|
"reboot_device",
|
||||||
|
"image_quality",
|
||||||
|
"colorcard_imaging_quality",
|
||||||
|
"colorcard_bias_imaging_quality",
|
||||||
|
"clarity_quality",
|
||||||
|
"distortion",
|
||||||
|
"dormancy",
|
||||||
|
"skew_gear",
|
||||||
|
"paper_separater_strengch",
|
||||||
|
"mech_paper_feeding_inclination"
|
||||||
|
};
|
||||||
|
|
||||||
|
const HGChar* IMAGE_INSPECTION_CN[] =
|
||||||
|
{
|
||||||
|
"配置速度模式",
|
||||||
|
"放置校正纸",
|
||||||
|
"自动平场校正",
|
||||||
|
"重启设备",
|
||||||
|
"扫描图像质量确认",
|
||||||
|
"色卡纸成像质量评估",
|
||||||
|
"色卡纸偏色成像质量评估",
|
||||||
|
"清晰度质量评估",
|
||||||
|
"畸变修正",
|
||||||
|
"设置休眠",
|
||||||
|
"歪斜挡位检测",
|
||||||
|
"分纸强度检测",
|
||||||
|
"机械走纸倾斜检测"
|
||||||
|
};
|
||||||
|
|
||||||
|
const HGChar* PRESSURE_INSPECTION[] =
|
||||||
|
{
|
||||||
|
"single_page_test_1",
|
||||||
|
"single_page_test_2",
|
||||||
|
"single_page_test_3",
|
||||||
|
"pressure_test",
|
||||||
|
"clear_roller_count"
|
||||||
|
};
|
||||||
|
|
||||||
|
const HGChar* PRESSURE_INSPECTION_CN[] =
|
||||||
|
{
|
||||||
|
"单张测试1",
|
||||||
|
"单张测试2",
|
||||||
|
"单张测试3",
|
||||||
|
"压力测试2轮",
|
||||||
|
"清除滚轴计数"
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
HGPdtToolDbUserMgrImpl::HGPdtToolDbUserMgrImpl()
|
||||||
|
{
|
||||||
|
m_sql = NULL;
|
||||||
|
m_user.clear();
|
||||||
|
m_deviceList.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
HGPdtToolDbUserMgrImpl::~HGPdtToolDbUserMgrImpl()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
HGResult HGPdtToolDbUserMgrImpl::Create(const HGChar* host, HGUShort port, const HGChar* user, const HGChar* pwd)
|
||||||
|
{
|
||||||
|
if (NULL != m_sql)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
MYSQL* sql = mysql_init(NULL);
|
||||||
|
if (NULL == sql)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NULL == mysql_real_connect(sql, host, user, pwd, NULL, port, NULL, 0))
|
||||||
|
{
|
||||||
|
mysql_close(sql);
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ret = mysql_query(sql, "create database if not exists huago_production_tool;");
|
||||||
|
if (0 != ret)
|
||||||
|
{
|
||||||
|
mysql_close(sql);
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = mysql_select_db(sql, "huago_production_tool");
|
||||||
|
if (0 != ret)
|
||||||
|
{
|
||||||
|
mysql_close(sql);
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
#if 0
|
||||||
|
mysql_query(sql, "drop table main_test;");
|
||||||
|
mysql_query(sql, "drop table initial_inspection_test;");
|
||||||
|
mysql_query(sql, "drop table initial_inspection_desc;");
|
||||||
|
mysql_query(sql, "drop table image_inspection_test;");
|
||||||
|
mysql_query(sql, "drop table image_inspection_desc;");
|
||||||
|
mysql_query(sql, "drop table pressure_inspection_test;");
|
||||||
|
mysql_query(sql, "drop table pressure_inspection_desc;");
|
||||||
|
#endif
|
||||||
|
if (0 != CreateUserConfigTable(sql, user) && 0 != CreateMainTestTable(sql)
|
||||||
|
|| 0 != CreateInitInspTestTable(sql) || 0 != CreateInitInspDescTable(sql)
|
||||||
|
|| 0 != CreateImgInspTestTable(sql) || 0 != CreateImgInspDescTable(sql)
|
||||||
|
|| 0 != CreatePreInspTestTable(sql) || 0 != CreatePreInspDescTable(sql))
|
||||||
|
{
|
||||||
|
mysql_close(sql);
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_sql = sql;
|
||||||
|
m_user = user;
|
||||||
|
return HGBASE_ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HGResult HGPdtToolDbUserMgrImpl::Destroy()
|
||||||
|
{
|
||||||
|
if (NULL == m_sql || !m_deviceList.empty())
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
mysql_close(m_sql);
|
||||||
|
m_sql = NULL;
|
||||||
|
m_user.clear();
|
||||||
|
return HGBASE_ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HGResult HGPdtToolDbUserMgrImpl::Export(const HGChar* xlsPath)
|
||||||
|
{
|
||||||
|
if (NULL == m_sql)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NULL == xlsPath || 0 == *xlsPath)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string cmd = "select main_test.sn";
|
||||||
|
cmd += ", main_test.create_time";
|
||||||
|
cmd += ", main_test.create_user";
|
||||||
|
cmd += ", main_test.last_modify_time";
|
||||||
|
cmd += ", main_test.last_modify_user";
|
||||||
|
cmd += ", main_test.current_entry";
|
||||||
|
|
||||||
|
for (int i = 0; i < sizeof(INITTIAL_INSPECTION) / sizeof(const HGChar*); ++i)
|
||||||
|
{
|
||||||
|
cmd += ", initial_inspection_test.";
|
||||||
|
cmd += INITTIAL_INSPECTION[i];
|
||||||
|
cmd += ", initial_inspection_desc.";
|
||||||
|
cmd += INITTIAL_INSPECTION[i];
|
||||||
|
}
|
||||||
|
for (int i = 0; i < sizeof(IMAGE_INSPECTION) / sizeof(const HGChar*); ++i)
|
||||||
|
{
|
||||||
|
cmd += ", image_inspection_test.";
|
||||||
|
cmd += IMAGE_INSPECTION[i];
|
||||||
|
cmd += ", image_inspection_desc.";
|
||||||
|
cmd += IMAGE_INSPECTION[i];
|
||||||
|
}
|
||||||
|
for (int i = 0; i < sizeof(PRESSURE_INSPECTION) / sizeof(const HGChar*); ++i)
|
||||||
|
{
|
||||||
|
cmd += ", pressure_inspection_test.";
|
||||||
|
cmd += PRESSURE_INSPECTION[i];
|
||||||
|
cmd += ", pressure_inspection_desc.";
|
||||||
|
cmd += PRESSURE_INSPECTION[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd += " from main_test";
|
||||||
|
cmd += " inner join initial_inspection_test on main_test.sn = initial_inspection_test.sn";
|
||||||
|
cmd += " inner join initial_inspection_desc on main_test.sn = initial_inspection_desc.sn";
|
||||||
|
cmd += " inner join image_inspection_test on main_test.sn = image_inspection_test.sn";
|
||||||
|
cmd += " inner join image_inspection_desc on main_test.sn = image_inspection_desc.sn";
|
||||||
|
cmd += " inner join pressure_inspection_test on main_test.sn = pressure_inspection_test.sn";
|
||||||
|
cmd += " inner join pressure_inspection_desc on main_test.sn = pressure_inspection_desc.sn";
|
||||||
|
cmd += ";";
|
||||||
|
|
||||||
|
int ret = mysql_query(m_sql, cmd.c_str());
|
||||||
|
if (0 != ret)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
MYSQL_RES* sqlRes = mysql_use_result(m_sql);
|
||||||
|
if (NULL == sqlRes)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
FILE* file = fopen(xlsPath, "wb");
|
||||||
|
if (NULL == file)
|
||||||
|
{
|
||||||
|
mysql_free_result(sqlRes);
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
const HGChar* MAIN_TEST_CN[] = {"序列号", "创建时间", "创建用户", "最后修改时间", "最后修改用户", "当前测试项"};
|
||||||
|
for (int i = 0; i < sizeof(MAIN_TEST_CN) / sizeof(const HGChar*); ++i)
|
||||||
|
{
|
||||||
|
std::string title = (std::string)MAIN_TEST_CN[i] + "\t";
|
||||||
|
fwrite(title.c_str(), 1, title.size(), file);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < sizeof(INITTIAL_INSPECTION_CN) / sizeof(const HGChar*); ++i)
|
||||||
|
{
|
||||||
|
std::string title = (std::string)INITTIAL_INSPECTION_CN[i] + "\t";
|
||||||
|
fwrite(title.c_str(), 1, title.size(), file);
|
||||||
|
std::string descTitle = (std::string)INITTIAL_INSPECTION_CN[i] + "异常说明" + "\t";
|
||||||
|
fwrite(descTitle.c_str(), 1, descTitle.size(), file);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < sizeof(IMAGE_INSPECTION_CN) / sizeof(const HGChar*); ++i)
|
||||||
|
{
|
||||||
|
std::string title = (std::string)IMAGE_INSPECTION_CN[i] + "\t";
|
||||||
|
fwrite(title.c_str(), 1, title.size(), file);
|
||||||
|
std::string descTitle = (std::string)IMAGE_INSPECTION_CN[i] + "异常说明" + "\t";
|
||||||
|
fwrite(descTitle.c_str(), 1, descTitle.size(), file);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < sizeof(PRESSURE_INSPECTION_CN) / sizeof(const HGChar*); ++i)
|
||||||
|
{
|
||||||
|
std::string title = (std::string)PRESSURE_INSPECTION_CN[i] + "\t";
|
||||||
|
fwrite(title.c_str(), 1, title.size(), file);
|
||||||
|
std::string descTitle = (std::string)PRESSURE_INSPECTION_CN[i] + "异常说明" + "\t";
|
||||||
|
fwrite(descTitle.c_str(), 1, descTitle.size(), file);
|
||||||
|
}
|
||||||
|
fwrite("\n", 1, strlen("\n"), file);
|
||||||
|
|
||||||
|
MYSQL_ROW row = NULL;
|
||||||
|
while ((row = mysql_fetch_row(sqlRes)) != NULL)
|
||||||
|
{
|
||||||
|
unsigned int cols = mysql_num_fields(sqlRes);
|
||||||
|
for (unsigned int i = 0; i < cols; ++i)
|
||||||
|
{
|
||||||
|
std::string value;
|
||||||
|
|
||||||
|
if (i < 5)
|
||||||
|
{
|
||||||
|
assert(NULL != row[i]);
|
||||||
|
value = row[i];
|
||||||
|
}
|
||||||
|
else if (i == 5)
|
||||||
|
{
|
||||||
|
assert(NULL != row[i]);
|
||||||
|
value = GetEntryNameCnStr((HGUInt)atoll(row[i]));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (0 == (i - 6) % 2)
|
||||||
|
{
|
||||||
|
assert(NULL != row[i]);
|
||||||
|
const HGChar* ENTRY_STATUS_CN[] = { "未测试", "不通过", "不支持", "通过" };
|
||||||
|
value = ENTRY_STATUS_CN[(HGUInt)atoll(row[i])];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (NULL != row[i])
|
||||||
|
{
|
||||||
|
value = Utf8ToStdString(row[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
value += "\t";
|
||||||
|
fwrite(value.c_str(), 1, value.size(), file);
|
||||||
|
}
|
||||||
|
|
||||||
|
fwrite("\n", 1, strlen("\n"), file);
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(file);
|
||||||
|
mysql_free_result(sqlRes);
|
||||||
|
return HGBASE_ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HGResult HGPdtToolDbUserMgrImpl::GetConfig(const HGChar* key, HGChar* value, HGUInt maxLen)
|
||||||
|
{
|
||||||
|
if (NULL == m_sql)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NULL == key || 0 == *key || NULL == value || 0 == maxLen)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
char sqlCmd[1024] = { 0 };
|
||||||
|
sprintf(sqlCmd, "select config_value from %s_config where config_key = '%s';", m_user.c_str(), key);
|
||||||
|
int ret = mysql_query(m_sql, sqlCmd);
|
||||||
|
if (0 != ret)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
MYSQL_RES* sqlRes = mysql_use_result(m_sql);
|
||||||
|
if (NULL == sqlRes)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
MYSQL_ROW row = mysql_fetch_row(sqlRes);
|
||||||
|
if (NULL == row)
|
||||||
|
{
|
||||||
|
mysql_free_result(sqlRes);
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NULL == row[0])
|
||||||
|
{
|
||||||
|
*value = '\0';
|
||||||
|
mysql_free_result(sqlRes);
|
||||||
|
return HGBASE_ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (maxLen < strlen(row[0]) + 1)
|
||||||
|
{
|
||||||
|
mysql_free_result(sqlRes);
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
strcpy(value, row[0]);
|
||||||
|
mysql_free_result(sqlRes);
|
||||||
|
return HGBASE_ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HGResult HGPdtToolDbUserMgrImpl::SetConfig(const HGChar* key, const HGChar* value)
|
||||||
|
{
|
||||||
|
if (NULL == m_sql)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NULL == key || 0 == *key)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
char sqlCmd[1024] = {0};
|
||||||
|
sprintf(sqlCmd, "insert into %s_config (config_key, config_value) values ('%s', '%s')",
|
||||||
|
m_user.c_str(), key, (NULL != value) ? value : "");
|
||||||
|
int ret = mysql_query(m_sql, sqlCmd);
|
||||||
|
if (0 == ret)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (1062 == mysql_errno(m_sql))
|
||||||
|
{
|
||||||
|
sprintf(sqlCmd, "update %s_config set config_value = '%s' where config_key = '%s'",
|
||||||
|
m_user.c_str(), (NULL != value) ? value : "", key);
|
||||||
|
int ret = mysql_query(m_sql, sqlCmd);
|
||||||
|
return (0 == ret) ? HGBASE_ERR_OK : HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
HGResult HGPdtToolDbUserMgrImpl::OpenDevice(const HGChar* sn, class HGPdtToolDbDeviceImpl** deviceImpl)
|
||||||
|
{
|
||||||
|
if (NULL == m_sql)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NULL == sn || 0 == *sn || NULL == deviceImpl)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 事务开始
|
||||||
|
int ret = mysql_query(m_sql, "begin;");
|
||||||
|
if (0 != ret)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0 != InitMainTestItem(sn) || 0 != InitInspTestItem("initial_inspection_test", sn)
|
||||||
|
|| 0 != InitInspTestItem("initial_inspection_desc", sn) || 0 != InitInspTestItem("image_inspection_test", sn)
|
||||||
|
|| 0 != InitInspTestItem("image_inspection_desc", sn) || 0 != InitInspTestItem("pressure_inspection_test", sn)
|
||||||
|
|| 0 != InitInspTestItem("pressure_inspection_desc", sn))
|
||||||
|
{
|
||||||
|
mysql_query(m_sql, "rollback;");
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 事务结束
|
||||||
|
ret = mysql_query(m_sql, "commit;");
|
||||||
|
assert(0 == ret);
|
||||||
|
|
||||||
|
*deviceImpl = new HGPdtToolDbDeviceImpl(this, sn);
|
||||||
|
m_deviceList.push_back(*deviceImpl);
|
||||||
|
return HGBASE_ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HGPdtToolDbUserMgrImpl::RemoveDevice(class HGPdtToolDbDeviceImpl* deviceImpl)
|
||||||
|
{
|
||||||
|
std::list<class HGPdtToolDbDeviceImpl*>::iterator iter;
|
||||||
|
for (iter = m_deviceList.begin(); iter != m_deviceList.end(); ++iter)
|
||||||
|
{
|
||||||
|
if (deviceImpl == *iter)
|
||||||
|
{
|
||||||
|
m_deviceList.erase(iter);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const HGChar* HGPdtToolDbUserMgrImpl::GetEntryNameCnStr(HGUInt entryName)
|
||||||
|
{
|
||||||
|
if (0 == entryName)
|
||||||
|
return "未开始测试";
|
||||||
|
else if (0xFFFFFFFF == entryName)
|
||||||
|
return "已完成测试";
|
||||||
|
else if (entryName >= HGPDTTOOLDB_ENTRYNAME_DIAL_SWITCH && entryName <= HGPDTTOOLDB_ENTRYNAME_SCANNING_SENSOR)
|
||||||
|
return INITTIAL_INSPECTION_CN[entryName - HGPDTTOOLDB_ENTRYNAME_DIAL_SWITCH];
|
||||||
|
else if (entryName >= HGPDTTOOLDB_ENTRYNAME_CONFIGURE_SPEED_MODE && entryName <= HGPDTTOOLDB_ENTRYNAME_MECH_PAPER_FEEDING_INCLINATION)
|
||||||
|
return IMAGE_INSPECTION_CN[entryName - HGPDTTOOLDB_ENTRYNAME_CONFIGURE_SPEED_MODE];
|
||||||
|
else if (entryName >= HGPDTTOOLDB_ENTRYNAME_SINGLE_PAGE_TEST_1 && entryName <= HGPDTTOOLDB_ENTRYNAME_CLEAR_ROLLER_COUNT)
|
||||||
|
return PRESSURE_INSPECTION_CN[entryName - HGPDTTOOLDB_ENTRYNAME_SINGLE_PAGE_TEST_1];
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int HGPdtToolDbUserMgrImpl::CreateUserConfigTable(MYSQL* sql, const HGChar* user)
|
||||||
|
{
|
||||||
|
assert(NULL != sql);
|
||||||
|
assert(NULL != user && 0 != *user);
|
||||||
|
|
||||||
|
char sqlCmd[1024] = {0};
|
||||||
|
sprintf(sqlCmd, "create table if not exists %s_config (config_key varchar(40) not null primary key, config_value text)", user);
|
||||||
|
return mysql_query(sql, sqlCmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
int HGPdtToolDbUserMgrImpl::CreateMainTestTable(MYSQL* sql)
|
||||||
|
{
|
||||||
|
assert(NULL != sql);
|
||||||
|
|
||||||
|
std::string cmd = "create table if not exists main_test (sn varchar(20) not null primary key";
|
||||||
|
cmd += ", create_time datetime";
|
||||||
|
cmd += ", create_user text not null";
|
||||||
|
cmd += ", last_modify_time datetime";
|
||||||
|
cmd += ", last_modify_user text not null";
|
||||||
|
cmd += ", current_entry int unsigned default 0";
|
||||||
|
cmd += ");";
|
||||||
|
return mysql_query(sql, cmd.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
int HGPdtToolDbUserMgrImpl::CreateInitInspTestTable(MYSQL* sql)
|
||||||
|
{
|
||||||
|
assert(NULL != sql);
|
||||||
|
|
||||||
|
std::string cmd = "create table if not exists initial_inspection_test (sn varchar(20) not null primary key";
|
||||||
|
int size = sizeof(INITTIAL_INSPECTION) / sizeof(const HGChar*);
|
||||||
|
for (int i = 0; i < size; ++i)
|
||||||
|
{
|
||||||
|
cmd += ", ";
|
||||||
|
cmd += INITTIAL_INSPECTION[i];
|
||||||
|
cmd += " tinyint unsigned default 0";
|
||||||
|
}
|
||||||
|
cmd += ");";
|
||||||
|
return mysql_query(sql, cmd.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
int HGPdtToolDbUserMgrImpl::CreateInitInspDescTable(MYSQL* sql)
|
||||||
|
{
|
||||||
|
assert(NULL != sql);
|
||||||
|
|
||||||
|
std::string cmd = "create table if not exists initial_inspection_desc (sn varchar(20) not null primary key";
|
||||||
|
int size = sizeof(INITTIAL_INSPECTION) / sizeof(const HGChar*);
|
||||||
|
for (int i = 0; i < size; ++i)
|
||||||
|
{
|
||||||
|
cmd += ", ";
|
||||||
|
cmd += INITTIAL_INSPECTION[i];
|
||||||
|
cmd += " text";
|
||||||
|
}
|
||||||
|
cmd += ");";
|
||||||
|
return mysql_query(sql, cmd.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
int HGPdtToolDbUserMgrImpl::CreateImgInspTestTable(MYSQL* sql)
|
||||||
|
{
|
||||||
|
assert(NULL != sql);
|
||||||
|
|
||||||
|
std::string cmd = "create table if not exists image_inspection_test (sn varchar(20) not null primary key";
|
||||||
|
int size = sizeof(IMAGE_INSPECTION) / sizeof(const HGChar*);
|
||||||
|
for (int i = 0; i < size; ++i)
|
||||||
|
{
|
||||||
|
cmd += ", ";
|
||||||
|
cmd += IMAGE_INSPECTION[i];
|
||||||
|
cmd += " tinyint unsigned default 0";
|
||||||
|
}
|
||||||
|
cmd += ");";
|
||||||
|
return mysql_query(sql, cmd.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
int HGPdtToolDbUserMgrImpl::CreateImgInspDescTable(MYSQL* sql)
|
||||||
|
{
|
||||||
|
assert(NULL != sql);
|
||||||
|
|
||||||
|
std::string cmd = "create table if not exists image_inspection_desc (sn varchar(20) not null primary key";
|
||||||
|
int size = sizeof(IMAGE_INSPECTION) / sizeof(const HGChar*);
|
||||||
|
for (int i = 0; i < size; ++i)
|
||||||
|
{
|
||||||
|
cmd += ", ";
|
||||||
|
cmd += IMAGE_INSPECTION[i];
|
||||||
|
cmd += " text";
|
||||||
|
}
|
||||||
|
cmd += ");";
|
||||||
|
return mysql_query(sql, cmd.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
int HGPdtToolDbUserMgrImpl::CreatePreInspTestTable(MYSQL* sql)
|
||||||
|
{
|
||||||
|
assert(NULL != sql);
|
||||||
|
|
||||||
|
std::string cmd = "create table if not exists pressure_inspection_test (sn varchar(20) not null primary key";
|
||||||
|
int size = sizeof(PRESSURE_INSPECTION) / sizeof(const HGChar*);
|
||||||
|
for (int i = 0; i < size; ++i)
|
||||||
|
{
|
||||||
|
cmd += ", ";
|
||||||
|
cmd += PRESSURE_INSPECTION[i];
|
||||||
|
cmd += " tinyint unsigned default 0";
|
||||||
|
}
|
||||||
|
cmd += ");";
|
||||||
|
return mysql_query(sql, cmd.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
int HGPdtToolDbUserMgrImpl::CreatePreInspDescTable(MYSQL* sql)
|
||||||
|
{
|
||||||
|
assert(NULL != sql);
|
||||||
|
|
||||||
|
std::string cmd = "create table if not exists pressure_inspection_desc (sn varchar(20) not null primary key";
|
||||||
|
int size = sizeof(PRESSURE_INSPECTION) / sizeof(const HGChar*);
|
||||||
|
for (int i = 0; i < size; ++i)
|
||||||
|
{
|
||||||
|
cmd += ", ";
|
||||||
|
cmd += PRESSURE_INSPECTION[i];
|
||||||
|
cmd += " text";
|
||||||
|
}
|
||||||
|
cmd += ");";
|
||||||
|
return mysql_query(sql, cmd.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
int HGPdtToolDbUserMgrImpl::InitMainTestItem(const HGChar* sn)
|
||||||
|
{
|
||||||
|
assert(NULL != sn && 0 != *sn && NULL != m_sql);
|
||||||
|
|
||||||
|
std::string title = "(sn, create_time, create_user, last_modify_time, last_modify_user)";
|
||||||
|
std::string value = "('" + (std::string)sn + "', now(), '" + m_user + "', now(), '" + m_user + "')";
|
||||||
|
std::string cmd = (std::string)"insert into main_test " + title + " values " + value + ";";
|
||||||
|
int ret = mysql_query(m_sql, cmd.c_str());
|
||||||
|
return (1062 == mysql_errno(m_sql)) ? 0 : ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int HGPdtToolDbUserMgrImpl::InitInspTestItem(const HGChar* tableName, const HGChar* sn)
|
||||||
|
{
|
||||||
|
assert(NULL != tableName && 0 != *tableName);
|
||||||
|
assert(NULL != sn && 0 != *sn && NULL != m_sql);
|
||||||
|
|
||||||
|
char sqlCmd[1024];
|
||||||
|
sprintf(sqlCmd, "insert into %s (sn) values ('%s');", tableName, sn);
|
||||||
|
int ret = mysql_query(m_sql, sqlCmd);
|
||||||
|
return (1062 == mysql_errno(m_sql)) ? 0 : ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
HGPdtToolDbDeviceImpl::HGPdtToolDbDeviceImpl(class HGPdtToolDbUserMgrImpl* userMgr, const HGChar* sn)
|
||||||
|
{
|
||||||
|
m_userMgr = userMgr;
|
||||||
|
m_sn = sn;
|
||||||
|
}
|
||||||
|
|
||||||
|
HGPdtToolDbDeviceImpl::~HGPdtToolDbDeviceImpl()
|
||||||
|
{
|
||||||
|
m_userMgr->RemoveDevice(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
HGResult HGPdtToolDbDeviceImpl::GetCurrEntry(HGUInt* entryName)
|
||||||
|
{
|
||||||
|
if (NULL == entryName)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
char sqlCmd[1024] = { 0 };
|
||||||
|
sprintf(sqlCmd, "select current_entry from main_test where sn = '%s';", m_sn.c_str());
|
||||||
|
int ret = mysql_query(m_userMgr->m_sql, sqlCmd);
|
||||||
|
if (0 != ret)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
MYSQL_RES* sqlRes = mysql_use_result(m_userMgr->m_sql);
|
||||||
|
if (NULL == sqlRes)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
MYSQL_ROW row = mysql_fetch_row(sqlRes);
|
||||||
|
if (NULL == row)
|
||||||
|
{
|
||||||
|
mysql_free_result(sqlRes);
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(NULL != row[0]);
|
||||||
|
*entryName = (HGUInt)atoll(row[0]);
|
||||||
|
mysql_free_result(sqlRes);
|
||||||
|
return HGBASE_ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HGResult HGPdtToolDbDeviceImpl::SetCurrEntry(HGUInt entryName)
|
||||||
|
{
|
||||||
|
if (0 != entryName && 0xFFFFFFFF != entryName)
|
||||||
|
{
|
||||||
|
const HGChar* entryNameStr = GetEntryNameStr(entryName);
|
||||||
|
if (NULL == entryNameStr)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
char sqlCmd[1024] = { 0 };
|
||||||
|
sprintf(sqlCmd, "update main_test set current_entry = %u, last_modify_time = now(), last_modify_user = '%s' where sn = '%s';",
|
||||||
|
entryName, m_userMgr->m_user.c_str(), m_sn.c_str());
|
||||||
|
int ret = mysql_query(m_userMgr->m_sql, sqlCmd);
|
||||||
|
return (0 == ret) ? HGBASE_ERR_OK : HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
HGResult HGPdtToolDbDeviceImpl::GetEntryStatus(HGUInt entryName, HGUInt* entryStatus)
|
||||||
|
{
|
||||||
|
if (NULL == entryStatus)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
const HGChar* entryNameStr = GetEntryNameStr(entryName);
|
||||||
|
const HGChar* tableName = GetTestTableName(entryName);
|
||||||
|
if (NULL == entryNameStr || NULL == tableName)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
char sqlCmd[1024] = { 0 };
|
||||||
|
sprintf(sqlCmd, "select %s from %s where sn = '%s';", entryNameStr, tableName, m_sn.c_str());
|
||||||
|
int ret = mysql_query(m_userMgr->m_sql, sqlCmd);
|
||||||
|
if (0 != ret)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
MYSQL_RES *sqlRes = mysql_use_result(m_userMgr->m_sql);
|
||||||
|
if (NULL == sqlRes)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
MYSQL_ROW row = mysql_fetch_row(sqlRes);
|
||||||
|
if (NULL == row)
|
||||||
|
{
|
||||||
|
mysql_free_result(sqlRes);
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(NULL != row[0]);
|
||||||
|
*entryStatus = (HGUInt)atoll(row[0]);
|
||||||
|
mysql_free_result(sqlRes);
|
||||||
|
return HGBASE_ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HGResult HGPdtToolDbDeviceImpl::SetEntryStatus(HGUInt entryName, HGUInt entryStatus)
|
||||||
|
{
|
||||||
|
if (entryStatus > HGPDTTOOLDB_ENTRYSTATUS_PASS)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
const HGChar* entryNameStr = GetEntryNameStr(entryName);
|
||||||
|
const HGChar* tableName = GetTestTableName(entryName);
|
||||||
|
if (NULL == entryNameStr || NULL == tableName)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
char sqlCmd[1024] = { 0 };
|
||||||
|
|
||||||
|
// 事务开始
|
||||||
|
int ret = mysql_query(m_userMgr->m_sql, "begin;");
|
||||||
|
if (0 != ret)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf(sqlCmd, "update %s set %s = %u where sn = '%s';", tableName, entryNameStr, entryStatus, m_sn.c_str());
|
||||||
|
ret = mysql_query(m_userMgr->m_sql, sqlCmd);
|
||||||
|
if (0 != ret)
|
||||||
|
{
|
||||||
|
mysql_query(m_userMgr->m_sql, "rollback;");
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf(sqlCmd, "update main_test set last_modify_time = now(), last_modify_user = '%s' where sn = '%s';",
|
||||||
|
m_userMgr->m_user.c_str(), m_sn.c_str());
|
||||||
|
ret = mysql_query(m_userMgr->m_sql, sqlCmd);
|
||||||
|
if (0 != ret)
|
||||||
|
{
|
||||||
|
mysql_query(m_userMgr->m_sql, "rollback;");
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 事务结束
|
||||||
|
ret = mysql_query(m_userMgr->m_sql, "commit;");
|
||||||
|
assert(0 == ret);
|
||||||
|
|
||||||
|
return HGBASE_ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HGResult HGPdtToolDbDeviceImpl::GetEntryExcepDesc(HGUInt entryName, HGChar* excepDesc, HGUInt maxLen)
|
||||||
|
{
|
||||||
|
if (NULL == excepDesc || 0 == maxLen)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
const HGChar* entryNameStr = GetEntryNameStr(entryName);
|
||||||
|
const HGChar* tableName = GetDescTableName(entryName);
|
||||||
|
if (NULL == entryNameStr || NULL == tableName)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
char sqlCmd[1024] = { 0 };
|
||||||
|
sprintf(sqlCmd, "select %s from %s where sn = '%s';", entryNameStr, tableName, m_sn.c_str());
|
||||||
|
int ret = mysql_query(m_userMgr->m_sql, sqlCmd);
|
||||||
|
if (0 != ret)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
MYSQL_RES* sqlRes = mysql_use_result(m_userMgr->m_sql);
|
||||||
|
if (NULL == sqlRes)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
MYSQL_ROW row = mysql_fetch_row(sqlRes);
|
||||||
|
if (NULL == row)
|
||||||
|
{
|
||||||
|
mysql_free_result(sqlRes);
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NULL == row[0])
|
||||||
|
{
|
||||||
|
*excepDesc = '\0';
|
||||||
|
mysql_free_result(sqlRes);
|
||||||
|
return HGBASE_ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (maxLen < strlen(row[0]) + 1)
|
||||||
|
{
|
||||||
|
mysql_free_result(sqlRes);
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
strcpy(excepDesc, row[0]);
|
||||||
|
mysql_free_result(sqlRes);
|
||||||
|
return HGBASE_ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HGResult HGPdtToolDbDeviceImpl::SetEntryExcepDesc(HGUInt entryName, const HGChar* excepDesc)
|
||||||
|
{
|
||||||
|
const HGChar* entryNameStr = GetEntryNameStr(entryName);
|
||||||
|
const HGChar* tableName = GetDescTableName(entryName);
|
||||||
|
if (NULL == entryNameStr || NULL == tableName)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
char sqlCmd[1024] = { 0 };
|
||||||
|
|
||||||
|
// 事务开始
|
||||||
|
int ret = mysql_query(m_userMgr->m_sql, "begin;");
|
||||||
|
if (0 != ret)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf(sqlCmd, "update %s set %s = '%s' where sn = '%s';",
|
||||||
|
tableName, entryNameStr, (NULL != excepDesc) ? excepDesc : "", m_sn.c_str());
|
||||||
|
ret = mysql_query(m_userMgr->m_sql, sqlCmd);
|
||||||
|
if (0 != ret)
|
||||||
|
{
|
||||||
|
mysql_query(m_userMgr->m_sql, "rollback;");
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf(sqlCmd, "update main_test set last_modify_time = now(), last_modify_user = '%s' where sn = '%s';",
|
||||||
|
m_userMgr->m_user.c_str(), m_sn.c_str());
|
||||||
|
ret = mysql_query(m_userMgr->m_sql, sqlCmd);
|
||||||
|
if (0 != ret)
|
||||||
|
{
|
||||||
|
mysql_query(m_userMgr->m_sql, "rollback;");
|
||||||
|
return HGBASE_ERR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 事务结束
|
||||||
|
ret = mysql_query(m_userMgr->m_sql, "commit;");
|
||||||
|
assert(0 == ret);
|
||||||
|
|
||||||
|
return HGBASE_ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
const HGChar* HGPdtToolDbDeviceImpl::GetEntryNameStr(HGUInt entryName)
|
||||||
|
{
|
||||||
|
if (entryName >= HGPDTTOOLDB_ENTRYNAME_DIAL_SWITCH && entryName <= HGPDTTOOLDB_ENTRYNAME_SCANNING_SENSOR)
|
||||||
|
return INITTIAL_INSPECTION[entryName - HGPDTTOOLDB_ENTRYNAME_DIAL_SWITCH];
|
||||||
|
else if (entryName >= HGPDTTOOLDB_ENTRYNAME_CONFIGURE_SPEED_MODE && entryName <= HGPDTTOOLDB_ENTRYNAME_MECH_PAPER_FEEDING_INCLINATION)
|
||||||
|
return IMAGE_INSPECTION[entryName - HGPDTTOOLDB_ENTRYNAME_CONFIGURE_SPEED_MODE];
|
||||||
|
else if (entryName >= HGPDTTOOLDB_ENTRYNAME_SINGLE_PAGE_TEST_1 && entryName <= HGPDTTOOLDB_ENTRYNAME_CLEAR_ROLLER_COUNT)
|
||||||
|
return PRESSURE_INSPECTION[entryName - HGPDTTOOLDB_ENTRYNAME_SINGLE_PAGE_TEST_1];
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
const HGChar* HGPdtToolDbDeviceImpl::GetTestTableName(HGUInt entryName)
|
||||||
|
{
|
||||||
|
if (entryName >= HGPDTTOOLDB_ENTRYNAME_DIAL_SWITCH && entryName <= HGPDTTOOLDB_ENTRYNAME_SCANNING_SENSOR)
|
||||||
|
return "initial_inspection_test";
|
||||||
|
else if (entryName >= HGPDTTOOLDB_ENTRYNAME_CONFIGURE_SPEED_MODE && entryName <= HGPDTTOOLDB_ENTRYNAME_MECH_PAPER_FEEDING_INCLINATION)
|
||||||
|
return "image_inspection_test";
|
||||||
|
else if (entryName >= HGPDTTOOLDB_ENTRYNAME_SINGLE_PAGE_TEST_1 && entryName <= HGPDTTOOLDB_ENTRYNAME_CLEAR_ROLLER_COUNT)
|
||||||
|
return "pressure_inspection_test";
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
const HGChar* HGPdtToolDbDeviceImpl::GetDescTableName(HGUInt entryName)
|
||||||
|
{
|
||||||
|
if (entryName >= HGPDTTOOLDB_ENTRYNAME_DIAL_SWITCH && entryName <= HGPDTTOOLDB_ENTRYNAME_SCANNING_SENSOR)
|
||||||
|
return "initial_inspection_desc";
|
||||||
|
else if (entryName >= HGPDTTOOLDB_ENTRYNAME_CONFIGURE_SPEED_MODE && entryName <= HGPDTTOOLDB_ENTRYNAME_MECH_PAPER_FEEDING_INCLINATION)
|
||||||
|
return "image_inspection_desc";
|
||||||
|
else if (entryName >= HGPDTTOOLDB_ENTRYNAME_SINGLE_PAGE_TEST_1 && entryName <= HGPDTTOOLDB_ENTRYNAME_CLEAR_ROLLER_COUNT)
|
||||||
|
return "pressure_inspection_desc";
|
||||||
|
return NULL;
|
||||||
|
}
|
|
@ -0,0 +1,71 @@
|
||||||
|
#ifndef __HGPDTTOOLDBIMPL_H__
|
||||||
|
#define __HGPDTTOOLDBIMPL_H__
|
||||||
|
|
||||||
|
#include "base/HGDef.h"
|
||||||
|
#include "base/HGBaseErr.h"
|
||||||
|
#include "mysql.h"
|
||||||
|
#include <string>
|
||||||
|
#include <list>
|
||||||
|
|
||||||
|
class HGPdtToolDbUserMgrImpl
|
||||||
|
{
|
||||||
|
friend class HGPdtToolDbDeviceImpl;
|
||||||
|
public:
|
||||||
|
HGPdtToolDbUserMgrImpl();
|
||||||
|
~HGPdtToolDbUserMgrImpl();
|
||||||
|
|
||||||
|
HGResult Create(const HGChar* host, HGUShort port, const HGChar* user, const HGChar* pwd);
|
||||||
|
HGResult Destroy();
|
||||||
|
HGResult Export(const HGChar* xlsPath);
|
||||||
|
HGResult GetConfig(const HGChar *key, HGChar *value, HGUInt maxLen);
|
||||||
|
HGResult SetConfig(const HGChar* key, const HGChar *value);
|
||||||
|
HGResult OpenDevice(const HGChar* sn, class HGPdtToolDbDeviceImpl **deviceImpl);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void RemoveDevice(class HGPdtToolDbDeviceImpl* deviceImpl);
|
||||||
|
static const HGChar* GetEntryNameCnStr(HGUInt entryName);
|
||||||
|
|
||||||
|
int CreateUserConfigTable(MYSQL* sql, const HGChar *user);
|
||||||
|
int CreateMainTestTable(MYSQL *sql);
|
||||||
|
int CreateInitInspTestTable(MYSQL* sql);
|
||||||
|
int CreateInitInspDescTable(MYSQL* sql);
|
||||||
|
int CreateImgInspTestTable(MYSQL* sql);
|
||||||
|
int CreateImgInspDescTable(MYSQL* sql);
|
||||||
|
int CreatePreInspTestTable(MYSQL* sql);
|
||||||
|
int CreatePreInspDescTable(MYSQL* sql);
|
||||||
|
|
||||||
|
int InitMainTestItem(const HGChar *sn);
|
||||||
|
int InitInspTestItem(const HGChar* tableName, const HGChar* sn);
|
||||||
|
|
||||||
|
private:
|
||||||
|
MYSQL* m_sql;
|
||||||
|
std::string m_user;
|
||||||
|
std::list<class HGPdtToolDbDeviceImpl*> m_deviceList;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class HGPdtToolDbDeviceImpl
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
HGPdtToolDbDeviceImpl(class HGPdtToolDbUserMgrImpl* userMgr, const HGChar* sn);
|
||||||
|
~HGPdtToolDbDeviceImpl();
|
||||||
|
|
||||||
|
HGResult GetCurrEntry(HGUInt* entryName);
|
||||||
|
HGResult SetCurrEntry(HGUInt entryName);
|
||||||
|
HGResult GetEntryStatus(HGUInt entryName, HGUInt* entryStatus);
|
||||||
|
HGResult SetEntryStatus(HGUInt entryName, HGUInt entryStatus);
|
||||||
|
HGResult GetEntryExcepDesc(HGUInt entryName, HGChar* excepDesc, HGUInt maxLen);
|
||||||
|
HGResult SetEntryExcepDesc(HGUInt entryName, const HGChar* excepDesc);
|
||||||
|
|
||||||
|
private:
|
||||||
|
const HGChar* GetEntryNameStr(HGUInt entryName);
|
||||||
|
const HGChar* GetTestTableName(HGUInt entryName);
|
||||||
|
const HGChar* GetDescTableName(HGUInt entryName);
|
||||||
|
|
||||||
|
private:
|
||||||
|
class HGPdtToolDbUserMgrImpl* m_userMgr;
|
||||||
|
std::string m_sn;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* __HGPDTTOOLDBIMPL_H__ */
|
|
@ -0,0 +1,51 @@
|
||||||
|
#include "HGString.h"
|
||||||
|
#include "base/HGDef.h"
|
||||||
|
#include "base/HGInc.h"
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
#if defined(HG_CMP_MSC)
|
||||||
|
static std::string AnsiToUtf8(const char* text)
|
||||||
|
{
|
||||||
|
int wlen = ::MultiByteToWideChar(CP_ACP, 0, text, -1, NULL, 0);
|
||||||
|
WCHAR* pUnicode = new WCHAR[wlen];
|
||||||
|
::MultiByteToWideChar(CP_ACP, 0, text, -1, pUnicode, wlen);
|
||||||
|
int len = ::WideCharToMultiByte(CP_UTF8, 0, pUnicode, -1, NULL, 0, NULL, NULL);
|
||||||
|
CHAR* pUTF8 = new CHAR[len];
|
||||||
|
::WideCharToMultiByte(CP_UTF8, 0, pUnicode, -1, pUTF8, len, NULL, NULL);
|
||||||
|
delete[] pUnicode;
|
||||||
|
std::string ret = pUTF8;
|
||||||
|
delete[] pUTF8;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
static std::string Utf8ToAnsi(const char* text)
|
||||||
|
{
|
||||||
|
int wlen = ::MultiByteToWideChar(CP_UTF8, 0, text, -1, NULL, 0);
|
||||||
|
WCHAR* pUnicode = new WCHAR[wlen];
|
||||||
|
::MultiByteToWideChar(CP_UTF8, 0, text, -1, pUnicode, wlen);
|
||||||
|
int len = ::WideCharToMultiByte(CP_ACP, 0, pUnicode, -1, NULL, 0, NULL, NULL);
|
||||||
|
CHAR* pAnsi = new CHAR[len];
|
||||||
|
::WideCharToMultiByte(CP_ACP, 0, pUnicode, -1, pAnsi, len, NULL, NULL);
|
||||||
|
delete[] pUnicode;
|
||||||
|
std::string ret = pAnsi;
|
||||||
|
delete[] pAnsi;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
std::string Utf8ToStdString(const std::string& utf8Str)
|
||||||
|
{
|
||||||
|
#if defined(HG_CMP_MSC)
|
||||||
|
return Utf8ToAnsi(utf8Str.c_str());
|
||||||
|
#else
|
||||||
|
return utf8Str;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string StdStringToUtf8(const std::string& stdStr)
|
||||||
|
{
|
||||||
|
#if defined(HG_CMP_MSC)
|
||||||
|
return AnsiToUtf8(stdStr.c_str());
|
||||||
|
#else
|
||||||
|
return stdStr;
|
||||||
|
#endif
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
#ifndef __HGSTRING_H__
|
||||||
|
#define __HGSTRING_H__
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
// 标准字符串:windows下为ansi编码,linux下为utf8编码
|
||||||
|
|
||||||
|
// UTF8转标准字符串
|
||||||
|
std::string Utf8ToStdString(const std::string& utf8Str);
|
||||||
|
|
||||||
|
// 标准字符串转UTF8
|
||||||
|
std::string StdStringToUtf8(const std::string& stdStr);
|
||||||
|
|
||||||
|
#endif /* __HGSTRING_H__ */
|
|
@ -0,0 +1,17 @@
|
||||||
|
#include "base/HGDef.h"
|
||||||
|
#include "base/HGInc.h"
|
||||||
|
#include "../HGPdtToolDb/HGPdtToolDb.h"
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
HGPdtToolDbUserMgr userMgr = NULL;
|
||||||
|
HGPdtToolDb_CreateUserMgr("127.0.0.1", 3306, "huago", "huago", &userMgr);
|
||||||
|
if (NULL != userMgr)
|
||||||
|
{
|
||||||
|
HGPdtToolDb_Export(userMgr, "D:\\1.xls");
|
||||||
|
|
||||||
|
HGPdtToolDb_DestroyUserMgr(userMgr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,150 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<VCProjectVersion>16.0</VCProjectVersion>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<ProjectGuid>{7f83ad40-a311-44e4-977e-583895b4d7e1}</ProjectGuid>
|
||||||
|
<RootNamespace>HGPdtToolDbTest</RootNamespace>
|
||||||
|
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="Shared">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<AdditionalIncludeDirectories>../../../sdk/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>../x64/Debug/HGPdtToolDb.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>../x64/Release/HGPdtToolDb.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="HGPdtToolDbTest.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
|
@ -0,0 +1,145 @@
|
||||||
|
#ifndef ERRMSG_INCLUDED
|
||||||
|
#define ERRMSG_INCLUDED
|
||||||
|
|
||||||
|
/* Copyright (c) 2000, 2022, 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 also distributed 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 included with MySQL.
|
||||||
|
|
||||||
|
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 include/errmsg.h
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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>.
|
||||||
|
|
||||||
|
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_LOCALHOST_CONNECTION 2010
|
||||||
|
#define CR_TCP_CONNECTION 2011
|
||||||
|
#define CR_SERVER_HANDSHAKE_ERR 2012
|
||||||
|
#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_NAMEDPIPESETSTATE_ERROR 2018
|
||||||
|
#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_SSL_CONNECTION_ERROR 2026
|
||||||
|
#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_NO_PARAMETERS_EXISTS 2033
|
||||||
|
#define CR_INVALID_PARAMETER_NO 2034
|
||||||
|
#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_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_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_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_ERROR_LAST /*Copy last error nr:*/ 2073
|
||||||
|
/* 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 */
|
|
@ -0,0 +1,95 @@
|
||||||
|
/* Copyright (c) 2014, 2022, 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 also distributed 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 included with MySQL.
|
||||||
|
|
||||||
|
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 */
|
|
@ -0,0 +1,103 @@
|
||||||
|
/* Copyright (c) 2015, 2022, 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 also distributed 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 included with MySQL.
|
||||||
|
|
||||||
|
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 _mysql_command_h
|
||||||
|
#define _mysql_command_h
|
||||||
|
|
||||||
|
/**
|
||||||
|
@file include/my_command.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
@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, /**< 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, /**< 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, /**< 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, /**< See @ref page_protocol_com_reset_connection */
|
||||||
|
COM_CLONE,
|
||||||
|
COM_SUBSCRIBE_GROUP_REPLICATION_STREAM,
|
||||||
|
/* don't forget to update const char *command_name[] in sql_parse.cc */
|
||||||
|
|
||||||
|
/* Must be last */
|
||||||
|
COM_END /**< Not a real command. Refused. */
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* _mysql_command_h */
|
|
@ -0,0 +1,114 @@
|
||||||
|
/* Copyright (c) 2019, 2022, 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 also distributed 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 included with MySQL.
|
||||||
|
|
||||||
|
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
|
|
@ -0,0 +1,52 @@
|
||||||
|
/* Copyright (c) 2000, 2022, 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 also distributed 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 included with MySQL.
|
||||||
|
|
||||||
|
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 MY_LIST_INCLUDED
|
||||||
|
#define MY_LIST_INCLUDED
|
||||||
|
|
||||||
|
/**
|
||||||
|
@file include/my_list.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct LIST {
|
||||||
|
struct LIST *prev, *next;
|
||||||
|
void *data;
|
||||||
|
} LIST;
|
||||||
|
|
||||||
|
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_reverse(LIST *root);
|
||||||
|
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);
|
||||||
|
|
||||||
|
#define list_rest(a) ((a)->next)
|
||||||
|
|
||||||
|
#endif // MY_LIST_INCLUDED
|
|
@ -0,0 +1,814 @@
|
||||||
|
/* Copyright (c) 2000, 2022, 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 also distributed 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 included with MySQL.
|
||||||
|
|
||||||
|
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 include/mysql.h
|
||||||
|
This file defines the client API to MySQL and also the ABI of the
|
||||||
|
dynamically linked libmysqlclient.
|
||||||
|
|
||||||
|
The ABI should never be changed in a released product of MySQL,
|
||||||
|
thus you need to take great care when changing the file. In case
|
||||||
|
the file is changed so the ABI is broken, you must also update
|
||||||
|
the SHARED_LIB_MAJOR_VERSION in cmake/mysql_version.cmake
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _mysql_h
|
||||||
|
#define _mysql_h
|
||||||
|
|
||||||
|
#ifndef MYSQL_ABI_CHECK
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Legacy definition for the benefit of old code. Use uint64_t in new code.
|
||||||
|
// If you get warnings from printf, use the PRIu64 macro, or, if you need
|
||||||
|
// compatibility with older versions of the client library, cast
|
||||||
|
// before printing.
|
||||||
|
typedef uint64_t my_ulonglong;
|
||||||
|
|
||||||
|
#ifndef my_socket_defined
|
||||||
|
#define my_socket_defined
|
||||||
|
#if defined(_WIN32) && !defined(MYSQL_ABI_CHECK)
|
||||||
|
#include <windows.h>
|
||||||
|
#ifdef WIN32_LEAN_AND_MEAN
|
||||||
|
#include <winsock2.h>
|
||||||
|
#endif
|
||||||
|
#define my_socket SOCKET
|
||||||
|
#else
|
||||||
|
typedef int my_socket;
|
||||||
|
#endif /* _WIN32 && ! MYSQL_ABI_CHECK */
|
||||||
|
#endif /* my_socket_defined */
|
||||||
|
|
||||||
|
// Small extra definition to avoid pulling in my_compiler.h in client code.
|
||||||
|
// IWYU pragma: no_include "my_compiler.h"
|
||||||
|
#ifndef MY_COMPILER_INCLUDED
|
||||||
|
#if !defined(_WIN32) || defined(MYSQL_ABI_CHECK)
|
||||||
|
#define STDCALL
|
||||||
|
#else
|
||||||
|
#define STDCALL __stdcall
|
||||||
|
#endif
|
||||||
|
#endif /* MY_COMPILER_INCLUDED */
|
||||||
|
|
||||||
|
#include "field_types.h"
|
||||||
|
#include "my_list.h"
|
||||||
|
#include "mysql_com.h"
|
||||||
|
|
||||||
|
/* Include declarations of plug-in API */
|
||||||
|
#include "mysql/client_plugin.h" // IWYU pragma: keep
|
||||||
|
|
||||||
|
/*
|
||||||
|
The client should be able to know which version it is compiled against,
|
||||||
|
even if mysql.h doesn't use this information directly.
|
||||||
|
*/
|
||||||
|
#include "mysql_version.h" // IWYU pragma: keep
|
||||||
|
|
||||||
|
// MYSQL_TIME is part of our public API.
|
||||||
|
#include "mysql_time.h" // IWYU pragma: keep
|
||||||
|
|
||||||
|
// The error messages are part of our public API.
|
||||||
|
#include "errmsg.h" // IWYU pragma: keep
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern unsigned int mysql_port;
|
||||||
|
extern char *mysql_unix_port;
|
||||||
|
|
||||||
|
#define CLIENT_NET_RETRY_COUNT 1 /* Retry count */
|
||||||
|
#define CLIENT_NET_READ_TIMEOUT 365 * 24 * 3600 /* Timeout on read */
|
||||||
|
#define CLIENT_NET_WRITE_TIMEOUT 365 * 24 * 3600 /* Timeout on write */
|
||||||
|
|
||||||
|
#define IS_PRI_KEY(n) ((n)&PRI_KEY_FLAG)
|
||||||
|
#define IS_NOT_NULL(n) ((n)&NOT_NULL_FLAG)
|
||||||
|
#define IS_BLOB(n) ((n)&BLOB_FLAG)
|
||||||
|
/**
|
||||||
|
Returns true if the value is a number which does not need quotes for
|
||||||
|
the sql_lex.cc parser to parse correctly.
|
||||||
|
*/
|
||||||
|
#define IS_NUM(t) \
|
||||||
|
(((t) <= MYSQL_TYPE_INT24 && (t) != MYSQL_TYPE_TIMESTAMP) || \
|
||||||
|
(t) == MYSQL_TYPE_YEAR || (t) == MYSQL_TYPE_NEWDECIMAL)
|
||||||
|
#define IS_LONGDATA(t) ((t) >= MYSQL_TYPE_TINY_BLOB && (t) <= MYSQL_TYPE_STRING)
|
||||||
|
|
||||||
|
typedef struct MYSQL_FIELD {
|
||||||
|
char *name; /* Name of column */
|
||||||
|
char *org_name; /* Original column name, if an alias */
|
||||||
|
char *table; /* Table of column if column was a field */
|
||||||
|
char *org_table; /* Org table name, if table was an alias */
|
||||||
|
char *db; /* Database for table */
|
||||||
|
char *catalog; /* Catalog for table */
|
||||||
|
char *def; /* Default value (set by mysql_list_fields) */
|
||||||
|
unsigned long length; /* Width of column (create length) */
|
||||||
|
unsigned long max_length; /* Max width for selected set */
|
||||||
|
unsigned int name_length;
|
||||||
|
unsigned int org_name_length;
|
||||||
|
unsigned int table_length;
|
||||||
|
unsigned int org_table_length;
|
||||||
|
unsigned int db_length;
|
||||||
|
unsigned int catalog_length;
|
||||||
|
unsigned int def_length;
|
||||||
|
unsigned int flags; /* Div flags */
|
||||||
|
unsigned int decimals; /* Number of decimals in field */
|
||||||
|
unsigned int charsetnr; /* Character set */
|
||||||
|
enum enum_field_types type; /* Type of field. See mysql_com.h for types */
|
||||||
|
void *extension;
|
||||||
|
} MYSQL_FIELD;
|
||||||
|
|
||||||
|
typedef char **MYSQL_ROW; /* return data as array of strings */
|
||||||
|
typedef unsigned int MYSQL_FIELD_OFFSET; /* offset to current field */
|
||||||
|
|
||||||
|
#define MYSQL_COUNT_ERROR (~(uint64_t)0)
|
||||||
|
|
||||||
|
/* backward compatibility define - to be removed eventually */
|
||||||
|
#define ER_WARN_DATA_TRUNCATED WARN_DATA_TRUNCATED
|
||||||
|
|
||||||
|
typedef struct MYSQL_ROWS {
|
||||||
|
struct MYSQL_ROWS *next; /* list of rows */
|
||||||
|
MYSQL_ROW data;
|
||||||
|
unsigned long length;
|
||||||
|
} MYSQL_ROWS;
|
||||||
|
|
||||||
|
typedef MYSQL_ROWS *MYSQL_ROW_OFFSET; /* offset to current row */
|
||||||
|
|
||||||
|
struct MEM_ROOT;
|
||||||
|
|
||||||
|
typedef struct MYSQL_DATA {
|
||||||
|
MYSQL_ROWS *data;
|
||||||
|
struct MEM_ROOT *alloc;
|
||||||
|
uint64_t rows;
|
||||||
|
unsigned int fields;
|
||||||
|
} MYSQL_DATA;
|
||||||
|
|
||||||
|
enum mysql_option {
|
||||||
|
MYSQL_OPT_CONNECT_TIMEOUT,
|
||||||
|
MYSQL_OPT_COMPRESS,
|
||||||
|
MYSQL_OPT_NAMED_PIPE,
|
||||||
|
MYSQL_INIT_COMMAND,
|
||||||
|
MYSQL_READ_DEFAULT_FILE,
|
||||||
|
MYSQL_READ_DEFAULT_GROUP,
|
||||||
|
MYSQL_SET_CHARSET_DIR,
|
||||||
|
MYSQL_SET_CHARSET_NAME,
|
||||||
|
MYSQL_OPT_LOCAL_INFILE,
|
||||||
|
MYSQL_OPT_PROTOCOL,
|
||||||
|
MYSQL_SHARED_MEMORY_BASE_NAME,
|
||||||
|
MYSQL_OPT_READ_TIMEOUT,
|
||||||
|
MYSQL_OPT_WRITE_TIMEOUT,
|
||||||
|
MYSQL_OPT_USE_RESULT,
|
||||||
|
MYSQL_REPORT_DATA_TRUNCATION,
|
||||||
|
MYSQL_OPT_RECONNECT,
|
||||||
|
MYSQL_PLUGIN_DIR,
|
||||||
|
MYSQL_DEFAULT_AUTH,
|
||||||
|
MYSQL_OPT_BIND,
|
||||||
|
MYSQL_OPT_SSL_KEY,
|
||||||
|
MYSQL_OPT_SSL_CERT,
|
||||||
|
MYSQL_OPT_SSL_CA,
|
||||||
|
MYSQL_OPT_SSL_CAPATH,
|
||||||
|
MYSQL_OPT_SSL_CIPHER,
|
||||||
|
MYSQL_OPT_SSL_CRL,
|
||||||
|
MYSQL_OPT_SSL_CRLPATH,
|
||||||
|
MYSQL_OPT_CONNECT_ATTR_RESET,
|
||||||
|
MYSQL_OPT_CONNECT_ATTR_ADD,
|
||||||
|
MYSQL_OPT_CONNECT_ATTR_DELETE,
|
||||||
|
MYSQL_SERVER_PUBLIC_KEY,
|
||||||
|
MYSQL_ENABLE_CLEARTEXT_PLUGIN,
|
||||||
|
MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS,
|
||||||
|
MYSQL_OPT_MAX_ALLOWED_PACKET,
|
||||||
|
MYSQL_OPT_NET_BUFFER_LENGTH,
|
||||||
|
MYSQL_OPT_TLS_VERSION,
|
||||||
|
MYSQL_OPT_SSL_MODE,
|
||||||
|
MYSQL_OPT_GET_SERVER_PUBLIC_KEY,
|
||||||
|
MYSQL_OPT_RETRY_COUNT,
|
||||||
|
MYSQL_OPT_OPTIONAL_RESULTSET_METADATA,
|
||||||
|
MYSQL_OPT_SSL_FIPS_MODE,
|
||||||
|
MYSQL_OPT_TLS_CIPHERSUITES,
|
||||||
|
MYSQL_OPT_COMPRESSION_ALGORITHMS,
|
||||||
|
MYSQL_OPT_ZSTD_COMPRESSION_LEVEL,
|
||||||
|
MYSQL_OPT_LOAD_DATA_LOCAL_DIR,
|
||||||
|
MYSQL_OPT_USER_PASSWORD,
|
||||||
|
MYSQL_OPT_SSL_SESSION_DATA
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
@todo remove the "extension", move st_mysql_options completely
|
||||||
|
out of mysql.h
|
||||||
|
*/
|
||||||
|
struct st_mysql_options_extention;
|
||||||
|
|
||||||
|
struct st_mysql_options {
|
||||||
|
unsigned int connect_timeout, read_timeout, write_timeout;
|
||||||
|
unsigned int port, protocol;
|
||||||
|
unsigned long client_flag;
|
||||||
|
char *host, *user, *password, *unix_socket, *db;
|
||||||
|
struct Init_commands_array *init_commands;
|
||||||
|
char *my_cnf_file, *my_cnf_group, *charset_dir, *charset_name;
|
||||||
|
char *ssl_key; /* PEM key file */
|
||||||
|
char *ssl_cert; /* PEM cert file */
|
||||||
|
char *ssl_ca; /* PEM CA file */
|
||||||
|
char *ssl_capath; /* PEM directory of CA-s? */
|
||||||
|
char *ssl_cipher; /* cipher to use */
|
||||||
|
char *shared_memory_base_name;
|
||||||
|
unsigned long max_allowed_packet;
|
||||||
|
bool compress, named_pipe;
|
||||||
|
/**
|
||||||
|
The local address to bind when connecting to remote server.
|
||||||
|
*/
|
||||||
|
char *bind_address;
|
||||||
|
/* 0 - never report, 1 - always report (default) */
|
||||||
|
bool report_data_truncation;
|
||||||
|
|
||||||
|
/* function pointers for local infile support */
|
||||||
|
int (*local_infile_init)(void **, const char *, void *);
|
||||||
|
int (*local_infile_read)(void *, char *, unsigned int);
|
||||||
|
void (*local_infile_end)(void *);
|
||||||
|
int (*local_infile_error)(void *, char *, unsigned int);
|
||||||
|
void *local_infile_userdata;
|
||||||
|
struct st_mysql_options_extention *extension;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum mysql_status {
|
||||||
|
MYSQL_STATUS_READY,
|
||||||
|
MYSQL_STATUS_GET_RESULT,
|
||||||
|
MYSQL_STATUS_USE_RESULT,
|
||||||
|
MYSQL_STATUS_STATEMENT_GET_RESULT
|
||||||
|
};
|
||||||
|
|
||||||
|
enum mysql_protocol_type {
|
||||||
|
MYSQL_PROTOCOL_DEFAULT,
|
||||||
|
MYSQL_PROTOCOL_TCP,
|
||||||
|
MYSQL_PROTOCOL_SOCKET,
|
||||||
|
MYSQL_PROTOCOL_PIPE,
|
||||||
|
MYSQL_PROTOCOL_MEMORY
|
||||||
|
};
|
||||||
|
|
||||||
|
enum mysql_ssl_mode {
|
||||||
|
SSL_MODE_DISABLED = 1,
|
||||||
|
SSL_MODE_PREFERRED,
|
||||||
|
SSL_MODE_REQUIRED,
|
||||||
|
SSL_MODE_VERIFY_CA,
|
||||||
|
SSL_MODE_VERIFY_IDENTITY
|
||||||
|
};
|
||||||
|
|
||||||
|
enum mysql_ssl_fips_mode {
|
||||||
|
SSL_FIPS_MODE_OFF = 0,
|
||||||
|
SSL_FIPS_MODE_ON = 1,
|
||||||
|
SSL_FIPS_MODE_STRICT
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct character_set {
|
||||||
|
unsigned int number; /* character set number */
|
||||||
|
unsigned int state; /* character set state */
|
||||||
|
const char *csname; /* character set name */
|
||||||
|
const char *name; /* collation name */
|
||||||
|
const char *comment; /* comment */
|
||||||
|
const char *dir; /* character set directory */
|
||||||
|
unsigned int mbminlen; /* min. length for multibyte strings */
|
||||||
|
unsigned int mbmaxlen; /* max. length for multibyte strings */
|
||||||
|
} MY_CHARSET_INFO;
|
||||||
|
|
||||||
|
struct MYSQL_METHODS;
|
||||||
|
struct MYSQL_STMT;
|
||||||
|
|
||||||
|
typedef struct MYSQL {
|
||||||
|
NET net; /* Communication parameters */
|
||||||
|
unsigned char *connector_fd; /* ConnectorFd for SSL */
|
||||||
|
char *host, *user, *passwd, *unix_socket, *server_version, *host_info;
|
||||||
|
char *info, *db;
|
||||||
|
struct CHARSET_INFO *charset;
|
||||||
|
MYSQL_FIELD *fields;
|
||||||
|
struct MEM_ROOT *field_alloc;
|
||||||
|
uint64_t affected_rows;
|
||||||
|
uint64_t insert_id; /* id if insert on table with NEXTNR */
|
||||||
|
uint64_t extra_info; /* Not used */
|
||||||
|
unsigned long thread_id; /* Id for connection in server */
|
||||||
|
unsigned long packet_length;
|
||||||
|
unsigned int port;
|
||||||
|
unsigned long client_flag, server_capabilities;
|
||||||
|
unsigned int protocol_version;
|
||||||
|
unsigned int field_count;
|
||||||
|
unsigned int server_status;
|
||||||
|
unsigned int server_language;
|
||||||
|
unsigned int warning_count;
|
||||||
|
struct st_mysql_options options;
|
||||||
|
enum mysql_status status;
|
||||||
|
enum enum_resultset_metadata resultset_metadata;
|
||||||
|
bool free_me; /* If free in mysql_close */
|
||||||
|
bool reconnect; /* set to 1 if automatic reconnect */
|
||||||
|
|
||||||
|
/* session-wide random string */
|
||||||
|
char scramble[SCRAMBLE_LENGTH + 1];
|
||||||
|
|
||||||
|
LIST *stmts; /* list of all statements */
|
||||||
|
const struct MYSQL_METHODS *methods;
|
||||||
|
void *thd;
|
||||||
|
/*
|
||||||
|
Points to boolean flag in MYSQL_RES or MYSQL_STMT. We set this flag
|
||||||
|
from mysql_stmt_close if close had to cancel result set of this object.
|
||||||
|
*/
|
||||||
|
bool *unbuffered_fetch_owner;
|
||||||
|
void *extension;
|
||||||
|
} MYSQL;
|
||||||
|
|
||||||
|
typedef struct MYSQL_RES {
|
||||||
|
uint64_t row_count;
|
||||||
|
MYSQL_FIELD *fields;
|
||||||
|
struct MYSQL_DATA *data;
|
||||||
|
MYSQL_ROWS *data_cursor;
|
||||||
|
unsigned long *lengths; /* column lengths of current row */
|
||||||
|
MYSQL *handle; /* for unbuffered reads */
|
||||||
|
const struct MYSQL_METHODS *methods;
|
||||||
|
MYSQL_ROW row; /* If unbuffered read */
|
||||||
|
MYSQL_ROW current_row; /* buffer to current row */
|
||||||
|
struct MEM_ROOT *field_alloc;
|
||||||
|
unsigned int field_count, current_field;
|
||||||
|
bool eof; /* Used by mysql_fetch_row */
|
||||||
|
/* mysql_stmt_close() had to cancel this result */
|
||||||
|
bool unbuffered_fetch_cancelled;
|
||||||
|
enum enum_resultset_metadata metadata;
|
||||||
|
void *extension;
|
||||||
|
} MYSQL_RES;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Flag to indicate that COM_BINLOG_DUMP_GTID should
|
||||||
|
be used rather than COM_BINLOG_DUMP in the @sa mysql_binlog_open().
|
||||||
|
*/
|
||||||
|
#define MYSQL_RPL_GTID (1 << 16)
|
||||||
|
/**
|
||||||
|
Skip HEARBEAT events in the @sa mysql_binlog_fetch().
|
||||||
|
*/
|
||||||
|
#define MYSQL_RPL_SKIP_HEARTBEAT (1 << 17)
|
||||||
|
|
||||||
|
/**
|
||||||
|
Flag to indicate that the heartbeat_event being generated
|
||||||
|
is using the class Heartbeat_event_v2
|
||||||
|
*/
|
||||||
|
#define USE_HEARTBEAT_EVENT_V2 (1 << 1)
|
||||||
|
|
||||||
|
/**
|
||||||
|
Struct for information about a replication stream.
|
||||||
|
|
||||||
|
@sa mysql_binlog_open()
|
||||||
|
@sa mysql_binlog_fetch()
|
||||||
|
@sa mysql_binlog_close()
|
||||||
|
*/
|
||||||
|
typedef struct MYSQL_RPL {
|
||||||
|
size_t file_name_length; /** Length of the 'file_name' or 0 */
|
||||||
|
const char *file_name; /** Filename of the binary log to read */
|
||||||
|
uint64_t start_position; /** Position in the binary log to */
|
||||||
|
/* start reading from */
|
||||||
|
unsigned int server_id; /** Server ID to use when identifying */
|
||||||
|
/* with the master */
|
||||||
|
unsigned int flags; /** Flags, e.g. MYSQL_RPL_GTID */
|
||||||
|
|
||||||
|
/** Size of gtid set data */
|
||||||
|
size_t gtid_set_encoded_size;
|
||||||
|
/** Callback function which is called */
|
||||||
|
/* from @sa mysql_binlog_open() to */
|
||||||
|
/* fill command packet gtid set */
|
||||||
|
void (*fix_gtid_set)(struct MYSQL_RPL *rpl, unsigned char *packet_gtid_set);
|
||||||
|
void *gtid_set_arg; /** GTID set data or an argument for */
|
||||||
|
/* fix_gtid_set() callback function */
|
||||||
|
|
||||||
|
unsigned long size; /** Size of the packet returned by */
|
||||||
|
/* mysql_binlog_fetch() */
|
||||||
|
const unsigned char *buffer; /** Pointer to returned data */
|
||||||
|
} MYSQL_RPL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Set up and bring down the server; to ensure that applications will
|
||||||
|
work when linked against either the standard client library or the
|
||||||
|
embedded server library, these functions should be called.
|
||||||
|
*/
|
||||||
|
int STDCALL mysql_server_init(int argc, char **argv, char **groups);
|
||||||
|
void STDCALL mysql_server_end(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
mysql_server_init/end need to be called when using libmysqld or
|
||||||
|
libmysqlclient (exactly, mysql_server_init() is called by mysql_init() so
|
||||||
|
you don't need to call it explicitly; but you need to call
|
||||||
|
mysql_server_end() to free memory). The names are a bit misleading
|
||||||
|
(mysql_SERVER* to be used when using libmysqlCLIENT). So we add more general
|
||||||
|
names which suit well whether you're using libmysqld or libmysqlclient. We
|
||||||
|
intend to promote these aliases over the mysql_server* ones.
|
||||||
|
*/
|
||||||
|
#define mysql_library_init mysql_server_init
|
||||||
|
#define mysql_library_end mysql_server_end
|
||||||
|
|
||||||
|
/*
|
||||||
|
Set up and bring down a thread; these function should be called
|
||||||
|
for each thread in an application which opens at least one MySQL
|
||||||
|
connection. All uses of the connection(s) should be between these
|
||||||
|
function calls.
|
||||||
|
*/
|
||||||
|
bool STDCALL mysql_thread_init(void);
|
||||||
|
void STDCALL mysql_thread_end(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Functions to get information from the MYSQL and MYSQL_RES structures
|
||||||
|
Should definitely be used if one uses shared libraries.
|
||||||
|
*/
|
||||||
|
|
||||||
|
uint64_t STDCALL mysql_num_rows(MYSQL_RES *res);
|
||||||
|
unsigned int STDCALL mysql_num_fields(MYSQL_RES *res);
|
||||||
|
bool STDCALL mysql_eof(MYSQL_RES *res);
|
||||||
|
MYSQL_FIELD *STDCALL mysql_fetch_field_direct(MYSQL_RES *res,
|
||||||
|
unsigned int fieldnr);
|
||||||
|
MYSQL_FIELD *STDCALL mysql_fetch_fields(MYSQL_RES *res);
|
||||||
|
MYSQL_ROW_OFFSET STDCALL mysql_row_tell(MYSQL_RES *res);
|
||||||
|
MYSQL_FIELD_OFFSET STDCALL mysql_field_tell(MYSQL_RES *res);
|
||||||
|
enum enum_resultset_metadata STDCALL mysql_result_metadata(MYSQL_RES *result);
|
||||||
|
|
||||||
|
unsigned int STDCALL mysql_field_count(MYSQL *mysql);
|
||||||
|
uint64_t STDCALL mysql_affected_rows(MYSQL *mysql);
|
||||||
|
uint64_t STDCALL mysql_insert_id(MYSQL *mysql);
|
||||||
|
unsigned int STDCALL mysql_errno(MYSQL *mysql);
|
||||||
|
const char *STDCALL mysql_error(MYSQL *mysql);
|
||||||
|
const char *STDCALL mysql_sqlstate(MYSQL *mysql);
|
||||||
|
unsigned int STDCALL mysql_warning_count(MYSQL *mysql);
|
||||||
|
const char *STDCALL mysql_info(MYSQL *mysql);
|
||||||
|
unsigned long STDCALL mysql_thread_id(MYSQL *mysql);
|
||||||
|
const char *STDCALL mysql_character_set_name(MYSQL *mysql);
|
||||||
|
int STDCALL mysql_set_character_set(MYSQL *mysql, const char *csname);
|
||||||
|
|
||||||
|
MYSQL *STDCALL mysql_init(MYSQL *mysql);
|
||||||
|
bool STDCALL mysql_ssl_set(MYSQL *mysql, const char *key, const char *cert,
|
||||||
|
const char *ca, const char *capath,
|
||||||
|
const char *cipher);
|
||||||
|
const char *STDCALL mysql_get_ssl_cipher(MYSQL *mysql);
|
||||||
|
bool STDCALL mysql_get_ssl_session_reused(MYSQL *mysql);
|
||||||
|
void *STDCALL mysql_get_ssl_session_data(MYSQL *mysql, unsigned int n_ticket,
|
||||||
|
unsigned int *out_len);
|
||||||
|
bool STDCALL mysql_free_ssl_session_data(MYSQL *mysql, void *data);
|
||||||
|
bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
|
||||||
|
const char *passwd, const char *db);
|
||||||
|
MYSQL *STDCALL mysql_real_connect(MYSQL *mysql, const char *host,
|
||||||
|
const char *user, const char *passwd,
|
||||||
|
const char *db, unsigned int port,
|
||||||
|
const char *unix_socket,
|
||||||
|
unsigned long clientflag);
|
||||||
|
int STDCALL mysql_select_db(MYSQL *mysql, const char *db);
|
||||||
|
int STDCALL mysql_query(MYSQL *mysql, const char *q);
|
||||||
|
int STDCALL mysql_send_query(MYSQL *mysql, const char *q, unsigned long length);
|
||||||
|
int STDCALL mysql_real_query(MYSQL *mysql, const char *q, unsigned long length);
|
||||||
|
MYSQL_RES *STDCALL mysql_store_result(MYSQL *mysql);
|
||||||
|
MYSQL_RES *STDCALL mysql_use_result(MYSQL *mysql);
|
||||||
|
|
||||||
|
enum net_async_status STDCALL mysql_real_connect_nonblocking(
|
||||||
|
MYSQL *mysql, const char *host, const char *user, const char *passwd,
|
||||||
|
const char *db, unsigned int port, const char *unix_socket,
|
||||||
|
unsigned long clientflag);
|
||||||
|
enum net_async_status STDCALL mysql_send_query_nonblocking(
|
||||||
|
MYSQL *mysql, const char *query, unsigned long length);
|
||||||
|
enum net_async_status STDCALL mysql_real_query_nonblocking(
|
||||||
|
MYSQL *mysql, const char *query, unsigned long length);
|
||||||
|
enum net_async_status STDCALL
|
||||||
|
mysql_store_result_nonblocking(MYSQL *mysql, MYSQL_RES **result);
|
||||||
|
enum net_async_status STDCALL mysql_next_result_nonblocking(MYSQL *mysql);
|
||||||
|
enum net_async_status STDCALL mysql_select_db_nonblocking(MYSQL *mysql,
|
||||||
|
const char *db,
|
||||||
|
bool *error);
|
||||||
|
void STDCALL mysql_get_character_set_info(MYSQL *mysql,
|
||||||
|
MY_CHARSET_INFO *charset);
|
||||||
|
|
||||||
|
int STDCALL mysql_session_track_get_first(MYSQL *mysql,
|
||||||
|
enum enum_session_state_type type,
|
||||||
|
const char **data, size_t *length);
|
||||||
|
int STDCALL mysql_session_track_get_next(MYSQL *mysql,
|
||||||
|
enum enum_session_state_type type,
|
||||||
|
const char **data, size_t *length);
|
||||||
|
/* local infile support */
|
||||||
|
|
||||||
|
#define LOCAL_INFILE_ERROR_LEN 512
|
||||||
|
|
||||||
|
void mysql_set_local_infile_handler(
|
||||||
|
MYSQL *mysql, int (*local_infile_init)(void **, const char *, void *),
|
||||||
|
int (*local_infile_read)(void *, char *, unsigned int),
|
||||||
|
void (*local_infile_end)(void *),
|
||||||
|
int (*local_infile_error)(void *, char *, unsigned int), void *);
|
||||||
|
|
||||||
|
void mysql_set_local_infile_default(MYSQL *mysql);
|
||||||
|
int STDCALL mysql_shutdown(MYSQL *mysql,
|
||||||
|
enum mysql_enum_shutdown_level shutdown_level);
|
||||||
|
int STDCALL mysql_dump_debug_info(MYSQL *mysql);
|
||||||
|
int STDCALL mysql_refresh(MYSQL *mysql, unsigned int refresh_options);
|
||||||
|
int STDCALL mysql_kill(MYSQL *mysql, unsigned long pid);
|
||||||
|
int STDCALL mysql_set_server_option(MYSQL *mysql,
|
||||||
|
enum enum_mysql_set_option option);
|
||||||
|
int STDCALL mysql_ping(MYSQL *mysql);
|
||||||
|
const char *STDCALL mysql_stat(MYSQL *mysql);
|
||||||
|
const char *STDCALL mysql_get_server_info(MYSQL *mysql);
|
||||||
|
const char *STDCALL mysql_get_client_info(void);
|
||||||
|
unsigned long STDCALL mysql_get_client_version(void);
|
||||||
|
const char *STDCALL mysql_get_host_info(MYSQL *mysql);
|
||||||
|
unsigned long STDCALL mysql_get_server_version(MYSQL *mysql);
|
||||||
|
unsigned int STDCALL mysql_get_proto_info(MYSQL *mysql);
|
||||||
|
MYSQL_RES *STDCALL mysql_list_dbs(MYSQL *mysql, const char *wild);
|
||||||
|
MYSQL_RES *STDCALL mysql_list_tables(MYSQL *mysql, const char *wild);
|
||||||
|
MYSQL_RES *STDCALL mysql_list_processes(MYSQL *mysql);
|
||||||
|
int STDCALL mysql_options(MYSQL *mysql, enum mysql_option option,
|
||||||
|
const void *arg);
|
||||||
|
int STDCALL mysql_options4(MYSQL *mysql, enum mysql_option option,
|
||||||
|
const void *arg1, const void *arg2);
|
||||||
|
int STDCALL mysql_get_option(MYSQL *mysql, enum mysql_option option,
|
||||||
|
const void *arg);
|
||||||
|
void STDCALL mysql_free_result(MYSQL_RES *result);
|
||||||
|
enum net_async_status STDCALL mysql_free_result_nonblocking(MYSQL_RES *result);
|
||||||
|
void STDCALL mysql_data_seek(MYSQL_RES *result, uint64_t offset);
|
||||||
|
MYSQL_ROW_OFFSET STDCALL mysql_row_seek(MYSQL_RES *result,
|
||||||
|
MYSQL_ROW_OFFSET offset);
|
||||||
|
MYSQL_FIELD_OFFSET STDCALL mysql_field_seek(MYSQL_RES *result,
|
||||||
|
MYSQL_FIELD_OFFSET offset);
|
||||||
|
MYSQL_ROW STDCALL mysql_fetch_row(MYSQL_RES *result);
|
||||||
|
enum net_async_status STDCALL mysql_fetch_row_nonblocking(MYSQL_RES *res,
|
||||||
|
MYSQL_ROW *row);
|
||||||
|
|
||||||
|
unsigned long *STDCALL mysql_fetch_lengths(MYSQL_RES *result);
|
||||||
|
MYSQL_FIELD *STDCALL mysql_fetch_field(MYSQL_RES *result);
|
||||||
|
MYSQL_RES *STDCALL mysql_list_fields(MYSQL *mysql, const char *table,
|
||||||
|
const char *wild);
|
||||||
|
unsigned long STDCALL mysql_escape_string(char *to, const char *from,
|
||||||
|
unsigned long from_length);
|
||||||
|
unsigned long STDCALL mysql_hex_string(char *to, const char *from,
|
||||||
|
unsigned long from_length);
|
||||||
|
unsigned long STDCALL mysql_real_escape_string(MYSQL *mysql, char *to,
|
||||||
|
const char *from,
|
||||||
|
unsigned long length);
|
||||||
|
unsigned long STDCALL mysql_real_escape_string_quote(MYSQL *mysql, char *to,
|
||||||
|
const char *from,
|
||||||
|
unsigned long length,
|
||||||
|
char quote);
|
||||||
|
void STDCALL mysql_debug(const char *debug);
|
||||||
|
void STDCALL myodbc_remove_escape(MYSQL *mysql, char *name);
|
||||||
|
unsigned int STDCALL mysql_thread_safe(void);
|
||||||
|
bool STDCALL mysql_read_query_result(MYSQL *mysql);
|
||||||
|
int STDCALL mysql_reset_connection(MYSQL *mysql);
|
||||||
|
|
||||||
|
int STDCALL mysql_binlog_open(MYSQL *mysql, MYSQL_RPL *rpl);
|
||||||
|
int STDCALL mysql_binlog_fetch(MYSQL *mysql, MYSQL_RPL *rpl);
|
||||||
|
void STDCALL mysql_binlog_close(MYSQL *mysql, MYSQL_RPL *rpl);
|
||||||
|
|
||||||
|
/*
|
||||||
|
The following definitions are added for the enhanced
|
||||||
|
client-server protocol
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* statement state */
|
||||||
|
enum enum_mysql_stmt_state {
|
||||||
|
MYSQL_STMT_INIT_DONE = 1,
|
||||||
|
MYSQL_STMT_PREPARE_DONE,
|
||||||
|
MYSQL_STMT_EXECUTE_DONE,
|
||||||
|
MYSQL_STMT_FETCH_DONE
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
This structure is used to define bind information, and
|
||||||
|
internally by the client library.
|
||||||
|
Public members with their descriptions are listed below
|
||||||
|
(conventionally `On input' refers to the binds given to
|
||||||
|
mysql_stmt_bind_param, `On output' refers to the binds given
|
||||||
|
to mysql_stmt_bind_result):
|
||||||
|
|
||||||
|
buffer_type - One of the MYSQL_* types, used to describe
|
||||||
|
the host language type of buffer.
|
||||||
|
On output: if column type is different from
|
||||||
|
buffer_type, column value is automatically converted
|
||||||
|
to buffer_type before it is stored in the buffer.
|
||||||
|
buffer - On input: points to the buffer with input data.
|
||||||
|
On output: points to the buffer capable to store
|
||||||
|
output data.
|
||||||
|
The type of memory pointed by buffer must correspond
|
||||||
|
to buffer_type. See the correspondence table in
|
||||||
|
the comment to mysql_stmt_bind_param.
|
||||||
|
|
||||||
|
The two above members are mandatory for any kind of bind.
|
||||||
|
|
||||||
|
buffer_length - the length of the buffer. You don't have to set
|
||||||
|
it for any fixed length buffer: float, double,
|
||||||
|
int, etc. It must be set however for variable-length
|
||||||
|
types, such as BLOBs or STRINGs.
|
||||||
|
|
||||||
|
length - On input: in case when lengths of input values
|
||||||
|
are different for each execute, you can set this to
|
||||||
|
point at a variable containing value length. This
|
||||||
|
way the value length can be different in each execute.
|
||||||
|
If length is not NULL, buffer_length is not used.
|
||||||
|
Note, length can even point at buffer_length if
|
||||||
|
you keep bind structures around while fetching:
|
||||||
|
this way you can change buffer_length before
|
||||||
|
each execution, everything will work ok.
|
||||||
|
On output: if length is set, mysql_stmt_fetch will
|
||||||
|
write column length into it.
|
||||||
|
|
||||||
|
is_null - On input: points to a boolean variable that should
|
||||||
|
be set to TRUE for NULL values.
|
||||||
|
This member is useful only if your data may be
|
||||||
|
NULL in some but not all cases.
|
||||||
|
If your data is never NULL, is_null should be set to 0.
|
||||||
|
If your data is always NULL, set buffer_type
|
||||||
|
to MYSQL_TYPE_NULL, and is_null will not be used.
|
||||||
|
|
||||||
|
is_unsigned - On input: used to signify that values provided for one
|
||||||
|
of numeric types are unsigned.
|
||||||
|
On output describes signedness of the output buffer.
|
||||||
|
If, taking into account is_unsigned flag, column data
|
||||||
|
is out of range of the output buffer, data for this column
|
||||||
|
is regarded truncated. Note that this has no correspondence
|
||||||
|
to the sign of result set column, if you need to find it out
|
||||||
|
use mysql_stmt_result_metadata.
|
||||||
|
error - where to write a truncation error if it is present.
|
||||||
|
possible error value is:
|
||||||
|
0 no truncation
|
||||||
|
1 value is out of range or buffer is too small
|
||||||
|
|
||||||
|
Please note that MYSQL_BIND also has internals members.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct MYSQL_BIND {
|
||||||
|
unsigned long *length; /* output length pointer */
|
||||||
|
bool *is_null; /* Pointer to null indicator */
|
||||||
|
void *buffer; /* buffer to get/put data */
|
||||||
|
/* set this if you want to track data truncations happened during fetch */
|
||||||
|
bool *error;
|
||||||
|
unsigned char *row_ptr; /* for the current data position */
|
||||||
|
void (*store_param_func)(NET *net, struct MYSQL_BIND *param);
|
||||||
|
void (*fetch_result)(struct MYSQL_BIND *, MYSQL_FIELD *, unsigned char **row);
|
||||||
|
void (*skip_result)(struct MYSQL_BIND *, MYSQL_FIELD *, unsigned char **row);
|
||||||
|
/* output buffer length, must be set when fetching str/binary */
|
||||||
|
unsigned long buffer_length;
|
||||||
|
unsigned long offset; /* offset position for char/binary fetch */
|
||||||
|
unsigned long length_value; /* Used if length is 0 */
|
||||||
|
unsigned int param_number; /* For null count and error messages */
|
||||||
|
unsigned int pack_length; /* Internal length for packed data */
|
||||||
|
enum enum_field_types buffer_type; /* buffer type */
|
||||||
|
bool error_value; /* used if error is 0 */
|
||||||
|
bool is_unsigned; /* set if integer type is unsigned */
|
||||||
|
bool long_data_used; /* If used with mysql_send_long_data */
|
||||||
|
bool is_null_value; /* Used if is_null is 0 */
|
||||||
|
void *extension;
|
||||||
|
} MYSQL_BIND;
|
||||||
|
|
||||||
|
struct MYSQL_STMT_EXT;
|
||||||
|
|
||||||
|
/* statement handler */
|
||||||
|
typedef struct MYSQL_STMT {
|
||||||
|
struct MEM_ROOT *mem_root; /* root allocations */
|
||||||
|
LIST list; /* list to keep track of all stmts */
|
||||||
|
MYSQL *mysql; /* connection handle */
|
||||||
|
MYSQL_BIND *params; /* input parameters */
|
||||||
|
MYSQL_BIND *bind; /* output parameters */
|
||||||
|
MYSQL_FIELD *fields; /* result set metadata */
|
||||||
|
MYSQL_DATA result; /* cached result set */
|
||||||
|
MYSQL_ROWS *data_cursor; /* current row in cached result */
|
||||||
|
/*
|
||||||
|
mysql_stmt_fetch() calls this function to fetch one row (it's different
|
||||||
|
for buffered, unbuffered and cursor fetch).
|
||||||
|
*/
|
||||||
|
int (*read_row_func)(struct MYSQL_STMT *stmt, unsigned char **row);
|
||||||
|
/* copy of mysql->affected_rows after statement execution */
|
||||||
|
uint64_t affected_rows;
|
||||||
|
uint64_t insert_id; /* copy of mysql->insert_id */
|
||||||
|
unsigned long stmt_id; /* Id for prepared statement */
|
||||||
|
unsigned long flags; /* i.e. type of cursor to open */
|
||||||
|
unsigned long prefetch_rows; /* number of rows per one COM_FETCH */
|
||||||
|
/*
|
||||||
|
Copied from mysql->server_status after execute/fetch to know
|
||||||
|
server-side cursor status for this statement.
|
||||||
|
*/
|
||||||
|
unsigned int server_status;
|
||||||
|
unsigned int last_errno; /* error code */
|
||||||
|
unsigned int param_count; /* input parameter count */
|
||||||
|
unsigned int field_count; /* number of columns in result set */
|
||||||
|
enum enum_mysql_stmt_state state; /* statement state */
|
||||||
|
char last_error[MYSQL_ERRMSG_SIZE]; /* error message */
|
||||||
|
char sqlstate[SQLSTATE_LENGTH + 1];
|
||||||
|
/* Types of input parameters should be sent to server */
|
||||||
|
bool send_types_to_server;
|
||||||
|
bool bind_param_done; /* input buffers were supplied */
|
||||||
|
unsigned char bind_result_done; /* output buffers were supplied */
|
||||||
|
/* mysql_stmt_close() had to cancel this result */
|
||||||
|
bool unbuffered_fetch_cancelled;
|
||||||
|
/*
|
||||||
|
Is set to true if we need to calculate field->max_length for
|
||||||
|
metadata fields when doing mysql_stmt_store_result.
|
||||||
|
*/
|
||||||
|
bool update_max_length;
|
||||||
|
struct MYSQL_STMT_EXT *extension;
|
||||||
|
} MYSQL_STMT;
|
||||||
|
|
||||||
|
enum enum_stmt_attr_type {
|
||||||
|
/*
|
||||||
|
When doing mysql_stmt_store_result calculate max_length attribute
|
||||||
|
of statement metadata. This is to be consistent with the old API,
|
||||||
|
where this was done automatically.
|
||||||
|
In the new API we do that only by request because it slows down
|
||||||
|
mysql_stmt_store_result sufficiently.
|
||||||
|
*/
|
||||||
|
STMT_ATTR_UPDATE_MAX_LENGTH,
|
||||||
|
/*
|
||||||
|
unsigned long with combination of cursor flags (read only, for update,
|
||||||
|
etc)
|
||||||
|
*/
|
||||||
|
STMT_ATTR_CURSOR_TYPE,
|
||||||
|
/*
|
||||||
|
Amount of rows to retrieve from server per one fetch if using cursors.
|
||||||
|
Accepts unsigned long attribute in the range 1 - ulong_max
|
||||||
|
*/
|
||||||
|
STMT_ATTR_PREFETCH_ROWS
|
||||||
|
};
|
||||||
|
|
||||||
|
bool STDCALL mysql_bind_param(MYSQL *mysql, unsigned n_params,
|
||||||
|
MYSQL_BIND *binds, const char **names);
|
||||||
|
|
||||||
|
MYSQL_STMT *STDCALL mysql_stmt_init(MYSQL *mysql);
|
||||||
|
int STDCALL mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query,
|
||||||
|
unsigned long length);
|
||||||
|
int STDCALL mysql_stmt_execute(MYSQL_STMT *stmt);
|
||||||
|
int STDCALL mysql_stmt_fetch(MYSQL_STMT *stmt);
|
||||||
|
int STDCALL mysql_stmt_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *bind_arg,
|
||||||
|
unsigned int column, unsigned long offset);
|
||||||
|
int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt);
|
||||||
|
unsigned long STDCALL mysql_stmt_param_count(MYSQL_STMT *stmt);
|
||||||
|
bool STDCALL mysql_stmt_attr_set(MYSQL_STMT *stmt,
|
||||||
|
enum enum_stmt_attr_type attr_type,
|
||||||
|
const void *attr);
|
||||||
|
bool STDCALL mysql_stmt_attr_get(MYSQL_STMT *stmt,
|
||||||
|
enum enum_stmt_attr_type attr_type,
|
||||||
|
void *attr);
|
||||||
|
bool STDCALL mysql_stmt_bind_param(MYSQL_STMT *stmt, MYSQL_BIND *bnd);
|
||||||
|
bool STDCALL mysql_stmt_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bnd);
|
||||||
|
bool STDCALL mysql_stmt_close(MYSQL_STMT *stmt);
|
||||||
|
bool STDCALL mysql_stmt_reset(MYSQL_STMT *stmt);
|
||||||
|
bool STDCALL mysql_stmt_free_result(MYSQL_STMT *stmt);
|
||||||
|
bool STDCALL mysql_stmt_send_long_data(MYSQL_STMT *stmt,
|
||||||
|
unsigned int param_number,
|
||||||
|
const char *data, unsigned long length);
|
||||||
|
MYSQL_RES *STDCALL mysql_stmt_result_metadata(MYSQL_STMT *stmt);
|
||||||
|
MYSQL_RES *STDCALL mysql_stmt_param_metadata(MYSQL_STMT *stmt);
|
||||||
|
unsigned int STDCALL mysql_stmt_errno(MYSQL_STMT *stmt);
|
||||||
|
const char *STDCALL mysql_stmt_error(MYSQL_STMT *stmt);
|
||||||
|
const char *STDCALL mysql_stmt_sqlstate(MYSQL_STMT *stmt);
|
||||||
|
MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_seek(MYSQL_STMT *stmt,
|
||||||
|
MYSQL_ROW_OFFSET offset);
|
||||||
|
MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_tell(MYSQL_STMT *stmt);
|
||||||
|
void STDCALL mysql_stmt_data_seek(MYSQL_STMT *stmt, uint64_t offset);
|
||||||
|
uint64_t STDCALL mysql_stmt_num_rows(MYSQL_STMT *stmt);
|
||||||
|
uint64_t STDCALL mysql_stmt_affected_rows(MYSQL_STMT *stmt);
|
||||||
|
uint64_t STDCALL mysql_stmt_insert_id(MYSQL_STMT *stmt);
|
||||||
|
unsigned int STDCALL mysql_stmt_field_count(MYSQL_STMT *stmt);
|
||||||
|
|
||||||
|
bool STDCALL mysql_commit(MYSQL *mysql);
|
||||||
|
bool STDCALL mysql_rollback(MYSQL *mysql);
|
||||||
|
bool STDCALL mysql_autocommit(MYSQL *mysql, bool auto_mode);
|
||||||
|
bool STDCALL mysql_more_results(MYSQL *mysql);
|
||||||
|
int STDCALL mysql_next_result(MYSQL *mysql);
|
||||||
|
int STDCALL mysql_stmt_next_result(MYSQL_STMT *stmt);
|
||||||
|
void STDCALL mysql_close(MYSQL *sock);
|
||||||
|
|
||||||
|
/* Public key reset */
|
||||||
|
void STDCALL mysql_reset_server_public_key(void);
|
||||||
|
|
||||||
|
/* status return codes */
|
||||||
|
#define MYSQL_NO_DATA 100
|
||||||
|
#define MYSQL_DATA_TRUNCATED 101
|
||||||
|
|
||||||
|
#define mysql_reload(mysql) mysql_refresh((mysql), REFRESH_GRANT)
|
||||||
|
|
||||||
|
#define HAVE_MYSQL_REAL_CONNECT
|
||||||
|
|
||||||
|
MYSQL *STDCALL mysql_real_connect_dns_srv(MYSQL *mysql,
|
||||||
|
const char *dns_srv_name,
|
||||||
|
const char *user, const char *passwd,
|
||||||
|
const char *db,
|
||||||
|
unsigned long client_flag);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _mysql_h */
|
|
@ -0,0 +1,237 @@
|
||||||
|
#ifndef MYSQL_CLIENT_PLUGIN_INCLUDED
|
||||||
|
/* Copyright (c) 2010, 2022, 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 also distributed 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 included with MySQL.
|
||||||
|
|
||||||
|
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 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
|
||||||
|
|
||||||
|
#ifndef MYSQL_ABI_CHECK
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
On Windows, exports from DLL need to be declared.
|
||||||
|
Also, plugin needs to be declared as extern "C" because MSVC
|
||||||
|
unlike other compilers, uses C++ mangling for variables not only
|
||||||
|
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 */
|
||||||
|
|
||||||
|
#if defined(MYSQL_DYNAMIC_PLUGIN)
|
||||||
|
#define MYSQL_PLUGIN_EXPORT MY_ATTRIBUTE((visibility("default")))
|
||||||
|
#else
|
||||||
|
#define MYSQL_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_AUTHENTICATION_PLUGIN_INTERFACE_VERSION 0x0200
|
||||||
|
#define MYSQL_CLIENT_TRACE_PLUGIN_INTERFACE_VERSION 0x0200
|
||||||
|
|
||||||
|
#define MYSQL_CLIENT_MAX_PLUGINS 4
|
||||||
|
|
||||||
|
#define MYSQL_CLIENT_PLUGIN_AUTHOR_ORACLE "Oracle Corporation"
|
||||||
|
|
||||||
|
#define mysql_declare_client_plugin(X) \
|
||||||
|
MYSQL_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 *); \
|
||||||
|
int (*get_options)(const char *option, void *);
|
||||||
|
|
||||||
|
struct st_mysql_client_plugin {
|
||||||
|
MYSQL_CLIENT_PLUGIN_HEADER
|
||||||
|
};
|
||||||
|
|
||||||
|
struct MYSQL;
|
||||||
|
|
||||||
|
/******** authentication plugin specific declarations *********/
|
||||||
|
#include "plugin_auth_common.h"
|
||||||
|
|
||||||
|
struct auth_plugin_t {
|
||||||
|
MYSQL_CLIENT_PLUGIN_HEADER
|
||||||
|
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 ************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
loads a plugin and initializes it
|
||||||
|
|
||||||
|
@param mysql MYSQL structure.
|
||||||
|
@param name a name of the plugin to load
|
||||||
|
@param type type of plugin that should be loaded, -1 to disable type check
|
||||||
|
@param argc number of arguments to pass to the plugin initialization
|
||||||
|
function
|
||||||
|
@param ... arguments for the plugin initialization function
|
||||||
|
|
||||||
|
@retval
|
||||||
|
a pointer to the loaded plugin, or NULL in case of a failure
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
|
||||||
|
This is the same as mysql_load_plugin, but take va_list instead of
|
||||||
|
a list of arguments.
|
||||||
|
|
||||||
|
@param mysql MYSQL structure.
|
||||||
|
@param name a name of the plugin to load
|
||||||
|
@param type type of plugin that should be loaded, -1 to disable type check
|
||||||
|
@param argc number of arguments to pass to the plugin initialization
|
||||||
|
function
|
||||||
|
@param args arguments for the plugin initialization function
|
||||||
|
|
||||||
|
@retval
|
||||||
|
a pointer to the loaded plugin, or NULL in case of a failure
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
|
||||||
|
@param mysql MYSQL structure.
|
||||||
|
@param name a name of the plugin to load
|
||||||
|
@param type type of plugin that should be loaded
|
||||||
|
|
||||||
|
@retval
|
||||||
|
a pointer to the plugin, or NULL in case of a failure
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
|
||||||
|
This is useful if an application has the necessary functionality
|
||||||
|
(for example, a special load data handler) statically linked into
|
||||||
|
the application binary. It can use this function to register the plugin
|
||||||
|
directly, avoiding the need to factor it out into a shared object.
|
||||||
|
|
||||||
|
@param mysql MYSQL structure. It is only used for error reporting
|
||||||
|
@param plugin an st_mysql_client_plugin structure to register
|
||||||
|
|
||||||
|
@retval
|
||||||
|
a pointer to the plugin, or NULL in case of a failure
|
||||||
|
*/
|
||||||
|
struct st_mysql_client_plugin *mysql_client_register_plugin(
|
||||||
|
struct MYSQL *mysql, struct st_mysql_client_plugin *plugin);
|
||||||
|
|
||||||
|
/**
|
||||||
|
set plugin options
|
||||||
|
|
||||||
|
Can be used to set extra options and affect behavior for a plugin.
|
||||||
|
This function may be called multiple times to set several options
|
||||||
|
|
||||||
|
@param plugin an st_mysql_client_plugin structure
|
||||||
|
@param option a string which specifies the option to set
|
||||||
|
@param value value for the option.
|
||||||
|
|
||||||
|
@retval 0 on success, 1 in case of failure
|
||||||
|
**/
|
||||||
|
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
|
|
@ -0,0 +1,187 @@
|
||||||
|
#ifndef MYSQL_PLUGIN_AUTH_COMMON_INCLUDED
|
||||||
|
/* Copyright (c) 2010, 2022, 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 also distributed 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 included with MySQL.
|
||||||
|
|
||||||
|
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 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.
|
||||||
|
*/
|
||||||
|
#define MYSQL_PLUGIN_AUTH_COMMON_INCLUDED
|
||||||
|
|
||||||
|
/** the max allowed length for a user name */
|
||||||
|
#define MYSQL_USERNAME_LENGTH 96
|
||||||
|
|
||||||
|
/**
|
||||||
|
return values of the plugin authenticate_user() method.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
Authentication failed, plugin internal error.
|
||||||
|
An error occurred in the authentication plugin itself.
|
||||||
|
These errors are reported in table performance_schema.host_cache,
|
||||||
|
column COUNT_AUTH_PLUGIN_ERRORS.
|
||||||
|
*/
|
||||||
|
#define CR_AUTH_PLUGIN_ERROR 3
|
||||||
|
/**
|
||||||
|
Authentication failed, client server handshake.
|
||||||
|
An error occurred during the client server handshake.
|
||||||
|
These errors are reported in table performance_schema.host_cache,
|
||||||
|
column COUNT_HANDSHAKE_ERRORS.
|
||||||
|
*/
|
||||||
|
#define CR_AUTH_HANDSHAKE 2
|
||||||
|
/**
|
||||||
|
Authentication failed, user credentials.
|
||||||
|
For example, wrong passwords.
|
||||||
|
These errors are reported in table performance_schema.host_cache,
|
||||||
|
column COUNT_AUTHENTICATION_ERRORS.
|
||||||
|
*/
|
||||||
|
#define CR_AUTH_USER_CREDENTIALS 1
|
||||||
|
/**
|
||||||
|
Authentication failed. Additionally, all other CR_xxx values
|
||||||
|
(libmysql error code) can be used too.
|
||||||
|
|
||||||
|
The client plugin may set the error code and the error message directly
|
||||||
|
in the MYSQL structure and return CR_ERROR. If a CR_xxx specific error
|
||||||
|
code was returned, an error message in the MYSQL structure will be
|
||||||
|
overwritten. If CR_ERROR is returned without setting the error in MYSQL,
|
||||||
|
CR_UNKNOWN_ERROR will be user.
|
||||||
|
*/
|
||||||
|
#define CR_ERROR 0
|
||||||
|
/**
|
||||||
|
Authentication (client part) was successful. It does not mean that the
|
||||||
|
authentication as a whole was successful, usually it only means
|
||||||
|
that the client was able to send the user name and the password to the
|
||||||
|
server. If CR_OK is returned, the libmysql reads the next packet expecting
|
||||||
|
it to be one of OK, ERROR, or CHANGE_PLUGIN packets.
|
||||||
|
*/
|
||||||
|
#define CR_OK -1
|
||||||
|
/**
|
||||||
|
Authentication was successful.
|
||||||
|
It means that the client has done its part successfully and also that
|
||||||
|
a plugin has read the last packet (one of OK, ERROR, CHANGE_PLUGIN).
|
||||||
|
In this case, libmysql will not read a packet from the server,
|
||||||
|
but it will use the data at mysql->net.read_pos.
|
||||||
|
|
||||||
|
A plugin may return this value if the number of roundtrips in the
|
||||||
|
authentication protocol is not known in advance, and the client plugin
|
||||||
|
needs to read one packet more to determine if the authentication is finished
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
#define PROXY_FLAG 0
|
||||||
|
|
||||||
|
/*
|
||||||
|
We need HANDLE definition if on Windows. Define WIN32_LEAN_AND_MEAN (if
|
||||||
|
not already done) to minimize amount of imported declarations.
|
||||||
|
*/
|
||||||
|
#if defined(_WIN32) && !defined(MYSQL_ABI_CHECK)
|
||||||
|
#ifndef WIN32_LEAN_AND_MEAN
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
#endif
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
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
|
||||||
|
};
|
||||||
|
|
||||||
|
/* 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 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 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 MYSQL_PLUGIN_VIO *vio, const unsigned char *packet,
|
||||||
|
int packet_len);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Fills in a MYSQL_PLUGIN_VIO_INFO structure, providing the information
|
||||||
|
about the connection.
|
||||||
|
*/
|
||||||
|
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
|
|
@ -0,0 +1,90 @@
|
||||||
|
/* Copyright (c) 2017, 2022, 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 also distributed 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 included with MySQL.
|
||||||
|
|
||||||
|
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
|
@ -0,0 +1,90 @@
|
||||||
|
/* Copyright (c) 2004, 2022, 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 also distributed 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 included with MySQL.
|
||||||
|
|
||||||
|
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 _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.
|
||||||
|
If you're looking for a place to add new time-related declaration,
|
||||||
|
it's most likely my_time.h. See also "C API Handling of Date
|
||||||
|
and Time Values" chapter in documentation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
We assume that values in this structure are normalized, i.e. year <= 9999,
|
||||||
|
month <= 12, day <= 31, hour <= 23, hour <= 59, hour <= 59. Many functions
|
||||||
|
in server such as my_system_gmt_sec() or make_time() family of functions
|
||||||
|
rely on this (actually now usage of make_*() family relies on a bit weaker
|
||||||
|
restriction). Also functions that produce MYSQL_TIME as result ensure this.
|
||||||
|
There is one exception to this rule though if this structure holds time
|
||||||
|
value (time_type == MYSQL_TIMESTAMP_TIME) days and hour member can hold
|
||||||
|
bigger values.
|
||||||
|
*/
|
||||||
|
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_ */
|
|
@ -0,0 +1,31 @@
|
||||||
|
/* Copyright Abandoned 1996,1999 TCX DataKonsult AB & Monty Program KB
|
||||||
|
& Detron HB, 1996, 1999-2004, 2007 MySQL AB.
|
||||||
|
This file is public domain and comes with NO WARRANTY of any kind
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Version numbers for protocol & mysqld */
|
||||||
|
|
||||||
|
#ifndef _mysql_version_h
|
||||||
|
#define _mysql_version_h
|
||||||
|
|
||||||
|
#define PROTOCOL_VERSION 10
|
||||||
|
#define MYSQL_SERVER_VERSION "8.0.31"
|
||||||
|
#define MYSQL_BASE_VERSION "mysqld-8.0"
|
||||||
|
#define MYSQL_SERVER_SUFFIX_DEF ""
|
||||||
|
#define MYSQL_VERSION_ID 80031
|
||||||
|
#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_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.31"
|
||||||
|
#define LIBMYSQL_VERSION_ID 80031
|
||||||
|
|
||||||
|
#ifndef LICENSE
|
||||||
|
#define LICENSE GPL
|
||||||
|
#endif /* LICENSE */
|
||||||
|
|
||||||
|
#endif /* _mysql_version_h */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,99 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 2022, 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 also distributed 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 included with MySQL.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Autogenerated file, please don't edit */
|
||||||
|
|
||||||
|
#include "mysqlx_error.h"
|
||||||
|
|
||||||
|
{"ER_X_BAD_MESSAGE", ER_X_BAD_MESSAGE, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_CAPABILITIES_PREPARE_FAILED", ER_X_CAPABILITIES_PREPARE_FAILED, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_CAPABILITY_NOT_FOUND", ER_X_CAPABILITY_NOT_FOUND, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_INVALID_PROTOCOL_DATA", ER_X_INVALID_PROTOCOL_DATA, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_BAD_CONNECTION_SESSION_ATTRIBUTE_VALUE_LENGTH", ER_X_BAD_CONNECTION_SESSION_ATTRIBUTE_VALUE_LENGTH, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_BAD_CONNECTION_SESSION_ATTRIBUTE_KEY_LENGTH", ER_X_BAD_CONNECTION_SESSION_ATTRIBUTE_KEY_LENGTH, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_BAD_CONNECTION_SESSION_ATTRIBUTE_EMPTY_KEY", ER_X_BAD_CONNECTION_SESSION_ATTRIBUTE_EMPTY_KEY, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_BAD_CONNECTION_SESSION_ATTRIBUTE_LENGTH", ER_X_BAD_CONNECTION_SESSION_ATTRIBUTE_LENGTH, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_BAD_CONNECTION_SESSION_ATTRIBUTE_TYPE", ER_X_BAD_CONNECTION_SESSION_ATTRIBUTE_TYPE, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_CAPABILITY_SET_NOT_ALLOWED", ER_X_CAPABILITY_SET_NOT_ALLOWED, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_SERVICE_ERROR", ER_X_SERVICE_ERROR, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_SESSION", ER_X_SESSION, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_INVALID_ARGUMENT", ER_X_INVALID_ARGUMENT, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_MISSING_ARGUMENT", ER_X_MISSING_ARGUMENT, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_BAD_INSERT_DATA", ER_X_BAD_INSERT_DATA, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_CMD_NUM_ARGUMENTS", ER_X_CMD_NUM_ARGUMENTS, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_CMD_ARGUMENT_TYPE", ER_X_CMD_ARGUMENT_TYPE, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_CMD_ARGUMENT_VALUE", ER_X_CMD_ARGUMENT_VALUE, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_BAD_UPSERT_DATA", ER_X_BAD_UPSERT_DATA, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_DUPLICATED_CAPABILITIES", ER_X_DUPLICATED_CAPABILITIES, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_CMD_ARGUMENT_OBJECT_EMPTY", ER_X_CMD_ARGUMENT_OBJECT_EMPTY, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_CMD_INVALID_ARGUMENT", ER_X_CMD_INVALID_ARGUMENT, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_BAD_UPDATE_DATA", ER_X_BAD_UPDATE_DATA, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_BAD_TYPE_OF_UPDATE", ER_X_BAD_TYPE_OF_UPDATE, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_BAD_COLUMN_TO_UPDATE", ER_X_BAD_COLUMN_TO_UPDATE, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_BAD_MEMBER_TO_UPDATE", ER_X_BAD_MEMBER_TO_UPDATE, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_BAD_STATEMENT_ID", ER_X_BAD_STATEMENT_ID, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_BAD_CURSOR_ID", ER_X_BAD_CURSOR_ID, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_BAD_SCHEMA", ER_X_BAD_SCHEMA, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_BAD_TABLE", ER_X_BAD_TABLE, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_BAD_PROJECTION", ER_X_BAD_PROJECTION, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_DOC_ID_MISSING", ER_X_DOC_ID_MISSING, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_DUPLICATE_ENTRY", ER_X_DUPLICATE_ENTRY, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_DOC_REQUIRED_FIELD_MISSING", ER_X_DOC_REQUIRED_FIELD_MISSING, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_PROJ_BAD_KEY_NAME", ER_X_PROJ_BAD_KEY_NAME, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_BAD_DOC_PATH", ER_X_BAD_DOC_PATH, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_CURSOR_EXISTS", ER_X_CURSOR_EXISTS, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_CURSOR_REACHED_EOF", ER_X_CURSOR_REACHED_EOF, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_PREPARED_STATMENT_CAN_HAVE_ONE_CURSOR", ER_X_PREPARED_STATMENT_CAN_HAVE_ONE_CURSOR, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_PREPARED_EXECUTE_ARGUMENT_NOT_SUPPORTED", ER_X_PREPARED_EXECUTE_ARGUMENT_NOT_SUPPORTED, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_PREPARED_EXECUTE_ARGUMENT_CONSISTENCY", ER_X_PREPARED_EXECUTE_ARGUMENT_CONSISTENCY, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_EXPR_BAD_OPERATOR", ER_X_EXPR_BAD_OPERATOR, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_EXPR_BAD_NUM_ARGS", ER_X_EXPR_BAD_NUM_ARGS, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_EXPR_MISSING_ARG", ER_X_EXPR_MISSING_ARG, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_EXPR_BAD_TYPE_VALUE", ER_X_EXPR_BAD_TYPE_VALUE, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_EXPR_BAD_VALUE", ER_X_EXPR_BAD_VALUE, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_INVALID_COLLECTION", ER_X_INVALID_COLLECTION, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_INVALID_ADMIN_COMMAND", ER_X_INVALID_ADMIN_COMMAND, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_EXPECT_NOT_OPEN", ER_X_EXPECT_NOT_OPEN, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_EXPECT_NO_ERROR_FAILED", ER_X_EXPECT_NO_ERROR_FAILED, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_EXPECT_BAD_CONDITION", ER_X_EXPECT_BAD_CONDITION, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_EXPECT_BAD_CONDITION_VALUE", ER_X_EXPECT_BAD_CONDITION_VALUE, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_INVALID_NAMESPACE", ER_X_INVALID_NAMESPACE, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_BAD_NOTICE", ER_X_BAD_NOTICE, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_CANNOT_DISABLE_NOTICE", ER_X_CANNOT_DISABLE_NOTICE, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_BAD_CONFIGURATION", ER_X_BAD_CONFIGURATION, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_MYSQLX_ACCOUNT_MISSING_PERMISSIONS", ER_X_MYSQLX_ACCOUNT_MISSING_PERMISSIONS, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_EXPECT_FIELD_EXISTS_FAILED", ER_X_EXPECT_FIELD_EXISTS_FAILED, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_BAD_LOCKING", ER_X_BAD_LOCKING, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_FRAME_COMPRESSION_DISABLED", ER_X_FRAME_COMPRESSION_DISABLED, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_DECOMPRESSION_FAILED", ER_X_DECOMPRESSION_FAILED, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_BAD_COMPRESSED_FRAME", ER_X_BAD_COMPRESSED_FRAME, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_CAPABILITY_COMPRESSION_INVALID_ALGORITHM", ER_X_CAPABILITY_COMPRESSION_INVALID_ALGORITHM, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_CAPABILITY_COMPRESSION_INVALID_SERVER_STYLE", ER_X_CAPABILITY_COMPRESSION_INVALID_SERVER_STYLE, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_CAPABILITY_COMPRESSION_INVALID_CLIENT_STYLE", ER_X_CAPABILITY_COMPRESSION_INVALID_CLIENT_STYLE, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_CAPABILITY_COMPRESSION_INVALID_OPTION", ER_X_CAPABILITY_COMPRESSION_INVALID_OPTION, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_CAPABILITY_COMPRESSION_MISSING_REQUIRED_FIELDS", ER_X_CAPABILITY_COMPRESSION_MISSING_REQUIRED_FIELDS, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_DOCUMENT_DOESNT_MATCH_EXPECTED_SCHEMA", ER_X_DOCUMENT_DOESNT_MATCH_EXPECTED_SCHEMA, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_COLLECTION_OPTION_DOESNT_EXISTS", ER_X_COLLECTION_OPTION_DOESNT_EXISTS, "", NULL, NULL, 0 },
|
||||||
|
{"ER_X_INVALID_VALIDATION_SCHEMA", ER_X_INVALID_VALIDATION_SCHEMA, "", NULL, NULL, 0 },
|
||||||
|
|
|
@ -0,0 +1,99 @@
|
||||||
|
/* Copyright (c) 2015, 2022, 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 also distributed 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 included with MySQL.
|
||||||
|
|
||||||
|
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 _MYSQLX_ERROR_H_
|
||||||
|
#define _MYSQLX_ERROR_H_
|
||||||
|
|
||||||
|
#define ER_X_BAD_MESSAGE 5000
|
||||||
|
#define ER_X_CAPABILITIES_PREPARE_FAILED 5001
|
||||||
|
#define ER_X_CAPABILITY_NOT_FOUND 5002
|
||||||
|
#define ER_X_INVALID_PROTOCOL_DATA 5003
|
||||||
|
#define ER_X_BAD_CONNECTION_SESSION_ATTRIBUTE_VALUE_LENGTH 5004
|
||||||
|
#define ER_X_BAD_CONNECTION_SESSION_ATTRIBUTE_KEY_LENGTH 5005
|
||||||
|
#define ER_X_BAD_CONNECTION_SESSION_ATTRIBUTE_EMPTY_KEY 5006
|
||||||
|
#define ER_X_BAD_CONNECTION_SESSION_ATTRIBUTE_LENGTH 5007
|
||||||
|
#define ER_X_BAD_CONNECTION_SESSION_ATTRIBUTE_TYPE 5008
|
||||||
|
#define ER_X_CAPABILITY_SET_NOT_ALLOWED 5009
|
||||||
|
#define ER_X_SERVICE_ERROR 5010
|
||||||
|
#define ER_X_SESSION 5011
|
||||||
|
#define ER_X_INVALID_ARGUMENT 5012
|
||||||
|
#define ER_X_MISSING_ARGUMENT 5013
|
||||||
|
#define ER_X_BAD_INSERT_DATA 5014
|
||||||
|
#define ER_X_CMD_NUM_ARGUMENTS 5015
|
||||||
|
#define ER_X_CMD_ARGUMENT_TYPE 5016
|
||||||
|
#define ER_X_CMD_ARGUMENT_VALUE 5017
|
||||||
|
#define ER_X_BAD_UPSERT_DATA 5018
|
||||||
|
#define ER_X_DUPLICATED_CAPABILITIES 5019
|
||||||
|
#define ER_X_CMD_ARGUMENT_OBJECT_EMPTY 5020
|
||||||
|
#define ER_X_CMD_INVALID_ARGUMENT 5021
|
||||||
|
#define ER_X_BAD_UPDATE_DATA 5050
|
||||||
|
#define ER_X_BAD_TYPE_OF_UPDATE 5051
|
||||||
|
#define ER_X_BAD_COLUMN_TO_UPDATE 5052
|
||||||
|
#define ER_X_BAD_MEMBER_TO_UPDATE 5053
|
||||||
|
#define ER_X_BAD_STATEMENT_ID 5110
|
||||||
|
#define ER_X_BAD_CURSOR_ID 5111
|
||||||
|
#define ER_X_BAD_SCHEMA 5112
|
||||||
|
#define ER_X_BAD_TABLE 5113
|
||||||
|
#define ER_X_BAD_PROJECTION 5114
|
||||||
|
#define ER_X_DOC_ID_MISSING 5115
|
||||||
|
#define ER_X_DUPLICATE_ENTRY 5116
|
||||||
|
#define ER_X_DOC_REQUIRED_FIELD_MISSING 5117
|
||||||
|
#define ER_X_PROJ_BAD_KEY_NAME 5120
|
||||||
|
#define ER_X_BAD_DOC_PATH 5121
|
||||||
|
#define ER_X_CURSOR_EXISTS 5122
|
||||||
|
#define ER_X_CURSOR_REACHED_EOF 5123
|
||||||
|
#define ER_X_PREPARED_STATMENT_CAN_HAVE_ONE_CURSOR 5131
|
||||||
|
#define ER_X_PREPARED_EXECUTE_ARGUMENT_NOT_SUPPORTED 5133
|
||||||
|
#define ER_X_PREPARED_EXECUTE_ARGUMENT_CONSISTENCY 5134
|
||||||
|
#define ER_X_EXPR_BAD_OPERATOR 5150
|
||||||
|
#define ER_X_EXPR_BAD_NUM_ARGS 5151
|
||||||
|
#define ER_X_EXPR_MISSING_ARG 5152
|
||||||
|
#define ER_X_EXPR_BAD_TYPE_VALUE 5153
|
||||||
|
#define ER_X_EXPR_BAD_VALUE 5154
|
||||||
|
#define ER_X_INVALID_COLLECTION 5156
|
||||||
|
#define ER_X_INVALID_ADMIN_COMMAND 5157
|
||||||
|
#define ER_X_EXPECT_NOT_OPEN 5158
|
||||||
|
#define ER_X_EXPECT_NO_ERROR_FAILED 5159
|
||||||
|
#define ER_X_EXPECT_BAD_CONDITION 5160
|
||||||
|
#define ER_X_EXPECT_BAD_CONDITION_VALUE 5161
|
||||||
|
#define ER_X_INVALID_NAMESPACE 5162
|
||||||
|
#define ER_X_BAD_NOTICE 5163
|
||||||
|
#define ER_X_CANNOT_DISABLE_NOTICE 5164
|
||||||
|
#define ER_X_BAD_CONFIGURATION 5165
|
||||||
|
#define ER_X_MYSQLX_ACCOUNT_MISSING_PERMISSIONS 5167
|
||||||
|
#define ER_X_EXPECT_FIELD_EXISTS_FAILED 5168
|
||||||
|
#define ER_X_BAD_LOCKING 5169
|
||||||
|
#define ER_X_FRAME_COMPRESSION_DISABLED 5170
|
||||||
|
#define ER_X_DECOMPRESSION_FAILED 5171
|
||||||
|
#define ER_X_BAD_COMPRESSED_FRAME 5174
|
||||||
|
#define ER_X_CAPABILITY_COMPRESSION_INVALID_ALGORITHM 5175
|
||||||
|
#define ER_X_CAPABILITY_COMPRESSION_INVALID_SERVER_STYLE 5176
|
||||||
|
#define ER_X_CAPABILITY_COMPRESSION_INVALID_CLIENT_STYLE 5177
|
||||||
|
#define ER_X_CAPABILITY_COMPRESSION_INVALID_OPTION 5178
|
||||||
|
#define ER_X_CAPABILITY_COMPRESSION_MISSING_REQUIRED_FIELDS 5179
|
||||||
|
#define ER_X_DOCUMENT_DOESNT_MATCH_EXPECTED_SCHEMA 5180
|
||||||
|
#define ER_X_COLLECTION_OPTION_DOESNT_EXISTS 5181
|
||||||
|
#define ER_X_INVALID_VALIDATION_SCHEMA 5182
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _MYSQLX_ERROR_H_
|
|
@ -0,0 +1,44 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 2022, 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 also distributed 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 included with MySQL.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Version numbers for X Plugin */
|
||||||
|
|
||||||
|
#ifndef _MYSQLX_VERSION_H_
|
||||||
|
#define _MYSQLX_VERSION_H_
|
||||||
|
|
||||||
|
#define MYSQLX_PLUGIN_VERSION_MAJOR 1
|
||||||
|
#define MYSQLX_PLUGIN_VERSION_MINOR 0
|
||||||
|
#define MYSQLX_PLUGIN_VERSION_PATCH 2
|
||||||
|
|
||||||
|
#define MYSQLX_PLUGIN_NAME "mysqlx"
|
||||||
|
#define MYSQLX_STATUS_VARIABLE_PREFIX(NAME) "Mysqlx_" NAME
|
||||||
|
#define MYSQLX_SYSTEM_VARIABLE_PREFIX(NAME) "mysqlx_" NAME
|
||||||
|
|
||||||
|
#define MYSQLX_TCP_PORT 33060U
|
||||||
|
#define MYSQLX_UNIX_ADDR "/tmp/mysqlx.sock"
|
||||||
|
|
||||||
|
#define MYSQLX_PLUGIN_VERSION ( (MYSQLX_PLUGIN_VERSION_MAJOR << 8) | MYSQLX_PLUGIN_VERSION_MINOR )
|
||||||
|
#define MYSQLX_PLUGIN_VERSION_STRING "1.0.2"
|
||||||
|
|
||||||
|
#endif // _MYSQLX_VERSION_H_
|
|
@ -0,0 +1,138 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2004-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||||
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
* in the file LICENSE in the source distribution or at
|
||||||
|
* https://www.openssl.org/source/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define APPLINK_STDIN 1
|
||||||
|
#define APPLINK_STDOUT 2
|
||||||
|
#define APPLINK_STDERR 3
|
||||||
|
#define APPLINK_FPRINTF 4
|
||||||
|
#define APPLINK_FGETS 5
|
||||||
|
#define APPLINK_FREAD 6
|
||||||
|
#define APPLINK_FWRITE 7
|
||||||
|
#define APPLINK_FSETMOD 8
|
||||||
|
#define APPLINK_FEOF 9
|
||||||
|
#define APPLINK_FCLOSE 10 /* should not be used */
|
||||||
|
|
||||||
|
#define APPLINK_FOPEN 11 /* solely for completeness */
|
||||||
|
#define APPLINK_FSEEK 12
|
||||||
|
#define APPLINK_FTELL 13
|
||||||
|
#define APPLINK_FFLUSH 14
|
||||||
|
#define APPLINK_FERROR 15
|
||||||
|
#define APPLINK_CLEARERR 16
|
||||||
|
#define APPLINK_FILENO 17 /* to be used with below */
|
||||||
|
|
||||||
|
#define APPLINK_OPEN 18 /* formally can't be used, as flags can vary */
|
||||||
|
#define APPLINK_READ 19
|
||||||
|
#define APPLINK_WRITE 20
|
||||||
|
#define APPLINK_LSEEK 21
|
||||||
|
#define APPLINK_CLOSE 22
|
||||||
|
#define APPLINK_MAX 22 /* always same as last macro */
|
||||||
|
|
||||||
|
#ifndef APPMACROS_ONLY
|
||||||
|
# include <stdio.h>
|
||||||
|
# include <io.h>
|
||||||
|
# include <fcntl.h>
|
||||||
|
|
||||||
|
static void *app_stdin(void)
|
||||||
|
{
|
||||||
|
return stdin;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *app_stdout(void)
|
||||||
|
{
|
||||||
|
return stdout;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *app_stderr(void)
|
||||||
|
{
|
||||||
|
return stderr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int app_feof(FILE *fp)
|
||||||
|
{
|
||||||
|
return feof(fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int app_ferror(FILE *fp)
|
||||||
|
{
|
||||||
|
return ferror(fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void app_clearerr(FILE *fp)
|
||||||
|
{
|
||||||
|
clearerr(fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int app_fileno(FILE *fp)
|
||||||
|
{
|
||||||
|
return _fileno(fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int app_fsetmod(FILE *fp, char mod)
|
||||||
|
{
|
||||||
|
return _setmode(_fileno(fp), mod == 'b' ? _O_BINARY : _O_TEXT);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
__declspec(dllexport)
|
||||||
|
void **
|
||||||
|
# if defined(__BORLANDC__)
|
||||||
|
/*
|
||||||
|
* __stdcall appears to be the only way to get the name
|
||||||
|
* decoration right with Borland C. Otherwise it works
|
||||||
|
* purely incidentally, as we pass no parameters.
|
||||||
|
*/
|
||||||
|
__stdcall
|
||||||
|
# else
|
||||||
|
__cdecl
|
||||||
|
# endif
|
||||||
|
OPENSSL_Applink(void)
|
||||||
|
{
|
||||||
|
static int once = 1;
|
||||||
|
static void *OPENSSL_ApplinkTable[APPLINK_MAX + 1] =
|
||||||
|
{ (void *)APPLINK_MAX };
|
||||||
|
|
||||||
|
if (once) {
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_STDIN] = app_stdin;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_STDOUT] = app_stdout;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_STDERR] = app_stderr;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_FPRINTF] = fprintf;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_FGETS] = fgets;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_FREAD] = fread;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_FWRITE] = fwrite;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_FSETMOD] = app_fsetmod;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_FEOF] = app_feof;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_FCLOSE] = fclose;
|
||||||
|
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_FOPEN] = fopen;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_FSEEK] = fseek;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_FTELL] = ftell;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_FFLUSH] = fflush;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_FERROR] = app_ferror;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_CLEARERR] = app_clearerr;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_FILENO] = app_fileno;
|
||||||
|
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_OPEN] = _open;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_READ] = _read;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_WRITE] = _write;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_LSEEK] = _lseek;
|
||||||
|
OPENSSL_ApplinkTable[APPLINK_CLOSE] = _close;
|
||||||
|
|
||||||
|
once = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return OPENSSL_ApplinkTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue