提交 1e341e2a 编写于 作者: xengine-qyt's avatar xengine-qyt

delete:nMsgLen field of database

上级 200f1ae5
......@@ -11,7 +11,7 @@
Target Server Version : 80032 (8.0.32-0ubuntu0.22.04.2)
File Encoding : 65001
Date: 24/04/2023 14:58:11
Date: 24/04/2023 15:15:54
*/
SET NAMES utf8mb4;
......@@ -30,8 +30,7 @@ CREATE TABLE `XEngine_CommKey` (
`tszQueueLeftTime` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '过期时间',
`tszQueuePublishTime` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '发布时间',
`tszQueueData` longblob NOT NULL COMMENT '保存数据',
`nDataLen` int NOT NULL COMMENT '数据大小',
`nDataType` tinyint NULL DEFAULT NULL COMMENT '数据类型',
`nDataType` tinyint NOT NULL COMMENT '数据类型',
`tszQueueCreateTime` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '插入时间',
PRIMARY KEY (`ID`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;
......
......@@ -100,12 +100,12 @@ bool CDBModule_MQData::DBModule_MQData_Insert(XENGINE_DBMESSAGEQUEUE* pSt_DBInfo
memset(tszSQLCoder, '\0', sizeof(tszSQLCoder));
DataBase_MySQL_Coder(xhDBSQL, pSt_DBInfo->tszMsgBuffer, tszSQLCoder, &pSt_DBInfo->nMsgLen);
__int64u nRet = _xstprintf(tszSQLStatement, _X("INSERT INTO `%s` (tszUserName,tszQueueName,nQueueSerial,nQueueGetTime,tszQueueLeftTime,tszQueuePublishTime,tszQueueData,nDataLen,nDataType,tszQueueCreateTime) VALUES('%s','%s',%lld,%lld,'%s','%s','"), pSt_DBInfo->tszQueueName, pSt_DBInfo->tszUserName, pSt_DBInfo->tszQueueName, pSt_DBInfo->nQueueSerial, pSt_DBInfo->nQueueGetTime, pSt_DBInfo->tszQueueLeftTime, pSt_DBInfo->tszQueuePublishTime);
__int64u nRet = _xstprintf(tszSQLStatement, _X("INSERT INTO `%s` (tszUserName,tszQueueName,nQueueSerial,nQueueGetTime,tszQueueLeftTime,tszQueuePublishTime,tszQueueData,nDataType,tszQueueCreateTime) VALUES('%s','%s',%lld,%lld,'%s','%s','"), pSt_DBInfo->tszQueueName, pSt_DBInfo->tszUserName, pSt_DBInfo->tszQueueName, pSt_DBInfo->nQueueSerial, pSt_DBInfo->nQueueGetTime, pSt_DBInfo->tszQueueLeftTime, pSt_DBInfo->tszQueuePublishTime);
memcpy(tszSQLStatement + nRet, tszSQLCoder, pSt_DBInfo->nMsgLen);
nRet += pSt_DBInfo->nMsgLen;
memset(tszSQLCoder, '\0', sizeof(tszSQLCoder));
int nLen = _xstprintf(tszSQLCoder, _X("',%d,%d,now())"), pSt_DBInfo->nMsgLen, pSt_DBInfo->byMsgType);
int nLen = _xstprintf(tszSQLCoder, _X("',%d,now())"), pSt_DBInfo->byMsgType);
memcpy(tszSQLStatement + nRet, tszSQLCoder, nLen);
nRet += nLen;
......@@ -195,15 +195,11 @@ bool CDBModule_MQData::DBModule_MQData_Query(XENGINE_DBMESSAGEQUEUE* pSt_DBInfo)
}
if (NULL != pptszResult[8])
{
//pSt_DBInfo->nMsgLen = _ttxoi(pptszResult[8]);
pSt_DBInfo->byMsgType = _ttxoi(pptszResult[8]);
}
if (NULL != pptszResult[9])
{
pSt_DBInfo->byMsgType = _ttxoi(pptszResult[9]);
}
if (NULL != pptszResult[10])
{
_tcsxcpy(pSt_DBInfo->tszQueueCreateTime, pptszResult[10]);
_tcsxcpy(pSt_DBInfo->tszQueueCreateTime, pptszResult[9]);
}
DataBase_MySQL_FreeResult(xhDBSQL, xhTable);
return true;
......@@ -232,18 +228,29 @@ bool CDBModule_MQData::DBModule_MQData_Modify(XENGINE_DBMESSAGEQUEUE* pSt_DBInfo
return false;
}
XCHAR tszSQLStatement[10240];
XCHAR tszSQLCoder[8192];
memset(tszSQLStatement, '\0', sizeof(tszSQLStatement));
memset(tszSQLCoder, '\0', sizeof(tszSQLCoder));
DataBase_MySQL_Coder(xhDBSQL, pSt_DBInfo->tszMsgBuffer, tszSQLCoder, &pSt_DBInfo->nMsgLen);
__int64u nRet = _xstprintf(tszSQLStatement, _X("UPDATE `%s` SET nQueueGetTime = %lld,tszQueueLeftTime = '%s',tszQueuePublishTime = '%s',tszQueueData = '"), pSt_DBInfo->tszQueueName, pSt_DBInfo->nQueueGetTime, pSt_DBInfo->tszQueueLeftTime, pSt_DBInfo->tszQueuePublishTime);
memcpy(tszSQLStatement + nRet, tszSQLCoder, pSt_DBInfo->nMsgLen);
nRet += pSt_DBInfo->nMsgLen;
_xstprintf(tszSQLStatement, _X("UPDATE `%s` SET nQueueGetTime = %lld,tszQueueLeftTime = '%s',tszQueuePublishTime = '%s',tszQueueData = '%s',nDataLen = %d,nDataType = %d WHERE tszUserName = '%s' AND tszQueueName = '%s' AND nQueueSerial = %lld"), pSt_DBInfo->tszQueueName, pSt_DBInfo->nQueueGetTime, pSt_DBInfo->tszQueueLeftTime, pSt_DBInfo->tszQueuePublishTime, pSt_DBInfo->tszMsgBuffer, pSt_DBInfo->nMsgLen, pSt_DBInfo->byMsgType, pSt_DBInfo->tszUserName, pSt_DBInfo->tszQueueName, pSt_DBInfo->nQueueSerial);
memset(tszSQLCoder, '\0', sizeof(tszSQLCoder));
int nLen = _xstprintf(tszSQLCoder, _X("',nDataType = %d WHERE tszUserName = '%s' AND tszQueueName = '%s' AND nQueueSerial = %lld"), pSt_DBInfo->byMsgType, pSt_DBInfo->tszUserName, pSt_DBInfo->tszQueueName, pSt_DBInfo->nQueueSerial);
memcpy(tszSQLStatement + nRet, tszSQLCoder, nLen);
nRet += nLen;
__int64u nRows = 0;
if (!DataBase_MySQL_Execute(xhDBSQL, tszSQLStatement, &nRows))
if (!DataBase_MySQL_Execute(xhDBSQL, tszSQLStatement, &nRet))
{
DBModule_IsErrorOccur = true;
DBModule_dwErrorCode = DataBase_GetLastError();
return false;
}
if (nRows <= 0)
if (nRet <= 0)
{
DBModule_IsErrorOccur = true;
DBModule_dwErrorCode = ERROR_XENGINE_MQCORE_DATABASE_NOTFOUND;
......@@ -315,6 +322,7 @@ bool CDBModule_MQData::DBModule_MQData_List(LPCXSTR lpszQueueName, __int64x nSer
for (__int64u i = 0; i < nllLine; i++)
{
XCHAR** pptszResult = DataBase_MySQL_GetResult(xhDBSQL, xhTable);
XLONG* pInt_Length = DataBase_MySQL_GetLength(xhDBSQL, xhTable);
if (NULL != pptszResult[1])
{
......@@ -342,19 +350,16 @@ bool CDBModule_MQData::DBModule_MQData_List(LPCXSTR lpszQueueName, __int64x nSer
}
if (NULL != pptszResult[7])
{
_tcsxcpy((*pppSt_DBMessage)[i]->tszMsgBuffer, pptszResult[7]);
(*pppSt_DBMessage)[i]->nMsgLen = pInt_Length[7];
memcpy((*pppSt_DBMessage)[i]->tszMsgBuffer, pptszResult[7], (*pppSt_DBMessage)[i]->nMsgLen);
}
if (NULL != pptszResult[8])
{
(*pppSt_DBMessage)[i]->nMsgLen = _ttxoi(pptszResult[8]);
(*pppSt_DBMessage)[i]->byMsgType = _ttxoi(pptszResult[8]);
}
if (NULL != pptszResult[9])
{
(*pppSt_DBMessage)[i]->byMsgType = _ttxoi(pptszResult[9]);
}
if (NULL != pptszResult[10])
{
_tcsxcpy((*pppSt_DBMessage)[i]->tszQueueCreateTime, pptszResult[10]);
_tcsxcpy((*pppSt_DBMessage)[i]->tszQueueCreateTime, pptszResult[9]);
}
}
DataBase_MySQL_FreeResult(xhDBSQL, xhTable);
......@@ -423,6 +428,7 @@ bool CDBModule_MQData::DBModule_MQData_GetSerial(LPCXSTR lpszName, __int64x* pIn
return false;
}
pptszResult = DataBase_MySQL_GetResult(xhDBSQL, xhTable);
XLONG* pInt_Length = DataBase_MySQL_GetLength(xhDBSQL, xhTable);
if (NULL != pptszResult[1])
{
......@@ -450,19 +456,16 @@ bool CDBModule_MQData::DBModule_MQData_GetSerial(LPCXSTR lpszName, __int64x* pIn
}
if (NULL != pptszResult[7])
{
_tcsxcpy(pSt_DBStart->tszMsgBuffer, pptszResult[7]);
pSt_DBStart->nMsgLen = pInt_Length[7];
memcpy(pSt_DBStart->tszMsgBuffer, pptszResult[7], pSt_DBStart->nMsgLen);
}
if (NULL != pptszResult[8])
{
pSt_DBStart->nMsgLen = _ttxoi(pptszResult[8]);
pSt_DBStart->byMsgType = _ttxoi(pptszResult[8]);
}
if (NULL != pptszResult[9])
{
pSt_DBStart->byMsgType = _ttxoi(pptszResult[9]);
}
if (NULL != pptszResult[10])
{
_tcsxcpy(pSt_DBStart->tszQueueCreateTime, pptszResult[10]);
_tcsxcpy(pSt_DBStart->tszQueueCreateTime, pptszResult[9]);
}
DataBase_MySQL_FreeResult(xhDBSQL, xhTable);
}
......@@ -486,6 +489,7 @@ bool CDBModule_MQData::DBModule_MQData_GetSerial(LPCXSTR lpszName, __int64x* pIn
return false;
}
pptszResult = DataBase_MySQL_GetResult(xhDBSQL, xhTable);
XLONG* pInt_Length = DataBase_MySQL_GetLength(xhDBSQL, xhTable);
if (NULL != pptszResult[1])
{
......@@ -513,19 +517,16 @@ bool CDBModule_MQData::DBModule_MQData_GetSerial(LPCXSTR lpszName, __int64x* pIn
}
if (NULL != pptszResult[7])
{
_tcsxcpy(pSt_DBEnd->tszMsgBuffer, pptszResult[7]);
pSt_DBEnd->nMsgLen = pInt_Length[7];
memcpy(pSt_DBEnd->tszMsgBuffer, pptszResult[7], pSt_DBEnd->nMsgLen);
}
if (NULL != pptszResult[8])
{
pSt_DBEnd->nMsgLen = _ttxoi(pptszResult[8]);
pSt_DBEnd->byMsgType = _ttxoi(pptszResult[8]);
}
if (NULL != pptszResult[9])
{
pSt_DBEnd->byMsgType = _ttxoi(pptszResult[9]);
}
if (NULL != pptszResult[10])
{
_tcsxcpy(pSt_DBEnd->tszQueueCreateTime, pptszResult[10]);
_tcsxcpy(pSt_DBEnd->tszQueueCreateTime, pptszResult[9]);
}
DataBase_MySQL_FreeResult(xhDBSQL, xhTable);
}
......@@ -591,7 +592,6 @@ bool CDBModule_MQData::DBModule_MQData_CreateTable(LPCXSTR lpszQueueName)
"`tszQueueLeftTime` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '过期时间',"
"`tszQueuePublishTime` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '发布时间',"
"`tszQueueData` longblob NOT NULL COMMENT '保存数据',"
"`nDataLen` int NOT NULL COMMENT '数据大小',"
"`nDataType` tinyint NOT NULL COMMENT '数据类型',"
"`tszQueueCreateTime` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '插入时间',"
"PRIMARY KEY (`ID`) USING BTREE"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册