@@ -100,12 +100,12 @@ bool CDBModule_MQData::DBModule_MQData_Insert(XENGINE_DBMESSAGEQUEUE* pSt_DBInfo
100100 memset (tszSQLCoder, ' \0 ' , sizeof (tszSQLCoder));
101101
102102 DataBase_MySQL_Coder (xhDBSQL, pSt_DBInfo->tszMsgBuffer , tszSQLCoder, &pSt_DBInfo->nMsgLen );
103- __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 );
103+ __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 );
104104 memcpy (tszSQLStatement + nRet, tszSQLCoder, pSt_DBInfo->nMsgLen );
105105 nRet += pSt_DBInfo->nMsgLen ;
106106
107107 memset (tszSQLCoder, ' \0 ' , sizeof (tszSQLCoder));
108- int nLen = _xstprintf (tszSQLCoder, _X (" ',%d,%d, now())" ), pSt_DBInfo-> nMsgLen , pSt_DBInfo->byMsgType );
108+ int nLen = _xstprintf (tszSQLCoder, _X (" ',%d,now())" ), pSt_DBInfo->byMsgType );
109109 memcpy (tszSQLStatement + nRet, tszSQLCoder, nLen);
110110 nRet += nLen;
111111
@@ -195,15 +195,11 @@ bool CDBModule_MQData::DBModule_MQData_Query(XENGINE_DBMESSAGEQUEUE* pSt_DBInfo)
195195 }
196196 if (NULL != pptszResult[8 ])
197197 {
198- // pSt_DBInfo->nMsgLen = _ttxoi(pptszResult[8]);
198+ pSt_DBInfo->byMsgType = _ttxoi (pptszResult[8 ]);
199199 }
200200 if (NULL != pptszResult[9 ])
201201 {
202- pSt_DBInfo->byMsgType = _ttxoi (pptszResult[9 ]);
203- }
204- if (NULL != pptszResult[10 ])
205- {
206- _tcsxcpy (pSt_DBInfo->tszQueueCreateTime , pptszResult[10 ]);
202+ _tcsxcpy (pSt_DBInfo->tszQueueCreateTime , pptszResult[9 ]);
207203 }
208204 DataBase_MySQL_FreeResult (xhDBSQL, xhTable);
209205 return true ;
@@ -232,18 +228,29 @@ bool CDBModule_MQData::DBModule_MQData_Modify(XENGINE_DBMESSAGEQUEUE* pSt_DBInfo
232228 return false ;
233229 }
234230 XCHAR tszSQLStatement[10240 ];
231+ XCHAR tszSQLCoder[8192 ];
232+
235233 memset (tszSQLStatement, ' \0 ' , sizeof (tszSQLStatement));
234+ memset (tszSQLCoder, ' \0 ' , sizeof (tszSQLCoder));
235+
236+ DataBase_MySQL_Coder (xhDBSQL, pSt_DBInfo->tszMsgBuffer , tszSQLCoder, &pSt_DBInfo->nMsgLen );
237+ __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 );
238+
239+ memcpy (tszSQLStatement + nRet, tszSQLCoder, pSt_DBInfo->nMsgLen );
240+ nRet += pSt_DBInfo->nMsgLen ;
236241
237- _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 );
242+ memset (tszSQLCoder, ' \0 ' , sizeof (tszSQLCoder));
243+ 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 );
244+ memcpy (tszSQLStatement + nRet, tszSQLCoder, nLen);
245+ nRet += nLen;
238246
239- __int64u nRows = 0 ;
240- if (!DataBase_MySQL_Execute (xhDBSQL, tszSQLStatement, &nRows))
247+ if (!DataBase_MySQL_Execute (xhDBSQL, tszSQLStatement, &nRet))
241248 {
242249 DBModule_IsErrorOccur = true ;
243250 DBModule_dwErrorCode = DataBase_GetLastError ();
244251 return false ;
245252 }
246- if (nRows <= 0 )
253+ if (nRet <= 0 )
247254 {
248255 DBModule_IsErrorOccur = true ;
249256 DBModule_dwErrorCode = ERROR_XENGINE_MQCORE_DATABASE_NOTFOUND;
@@ -315,6 +322,7 @@ bool CDBModule_MQData::DBModule_MQData_List(LPCXSTR lpszQueueName, __int64x nSer
315322 for (__int64u i = 0 ; i < nllLine; i++)
316323 {
317324 XCHAR** pptszResult = DataBase_MySQL_GetResult (xhDBSQL, xhTable);
325+ XLONG* pInt_Length = DataBase_MySQL_GetLength (xhDBSQL, xhTable);
318326
319327 if (NULL != pptszResult[1 ])
320328 {
@@ -342,19 +350,16 @@ bool CDBModule_MQData::DBModule_MQData_List(LPCXSTR lpszQueueName, __int64x nSer
342350 }
343351 if (NULL != pptszResult[7 ])
344352 {
345- _tcsxcpy ((*pppSt_DBMessage)[i]->tszMsgBuffer , pptszResult[7 ]);
353+ (*pppSt_DBMessage)[i]->nMsgLen = pInt_Length[7 ];
354+ memcpy ((*pppSt_DBMessage)[i]->tszMsgBuffer , pptszResult[7 ], (*pppSt_DBMessage)[i]->nMsgLen );
346355 }
347356 if (NULL != pptszResult[8 ])
348357 {
349- (*pppSt_DBMessage)[i]->nMsgLen = _ttxoi (pptszResult[8 ]);
358+ (*pppSt_DBMessage)[i]->byMsgType = _ttxoi (pptszResult[8 ]);
350359 }
351360 if (NULL != pptszResult[9 ])
352361 {
353- (*pppSt_DBMessage)[i]->byMsgType = _ttxoi (pptszResult[9 ]);
354- }
355- if (NULL != pptszResult[10 ])
356- {
357- _tcsxcpy ((*pppSt_DBMessage)[i]->tszQueueCreateTime , pptszResult[10 ]);
362+ _tcsxcpy ((*pppSt_DBMessage)[i]->tszQueueCreateTime , pptszResult[9 ]);
358363 }
359364 }
360365 DataBase_MySQL_FreeResult (xhDBSQL, xhTable);
@@ -423,6 +428,7 @@ bool CDBModule_MQData::DBModule_MQData_GetSerial(LPCXSTR lpszName, __int64x* pIn
423428 return false ;
424429 }
425430 pptszResult = DataBase_MySQL_GetResult (xhDBSQL, xhTable);
431+ XLONG* pInt_Length = DataBase_MySQL_GetLength (xhDBSQL, xhTable);
426432
427433 if (NULL != pptszResult[1 ])
428434 {
@@ -450,19 +456,16 @@ bool CDBModule_MQData::DBModule_MQData_GetSerial(LPCXSTR lpszName, __int64x* pIn
450456 }
451457 if (NULL != pptszResult[7 ])
452458 {
453- _tcsxcpy (pSt_DBStart->tszMsgBuffer , pptszResult[7 ]);
459+ pSt_DBStart->nMsgLen = pInt_Length[7 ];
460+ memcpy (pSt_DBStart->tszMsgBuffer , pptszResult[7 ], pSt_DBStart->nMsgLen );
454461 }
455462 if (NULL != pptszResult[8 ])
456463 {
457- pSt_DBStart->nMsgLen = _ttxoi (pptszResult[8 ]);
464+ pSt_DBStart->byMsgType = _ttxoi (pptszResult[8 ]);
458465 }
459466 if (NULL != pptszResult[9 ])
460467 {
461- pSt_DBStart->byMsgType = _ttxoi (pptszResult[9 ]);
462- }
463- if (NULL != pptszResult[10 ])
464- {
465- _tcsxcpy (pSt_DBStart->tszQueueCreateTime , pptszResult[10 ]);
468+ _tcsxcpy (pSt_DBStart->tszQueueCreateTime , pptszResult[9 ]);
466469 }
467470 DataBase_MySQL_FreeResult (xhDBSQL, xhTable);
468471 }
@@ -486,6 +489,7 @@ bool CDBModule_MQData::DBModule_MQData_GetSerial(LPCXSTR lpszName, __int64x* pIn
486489 return false ;
487490 }
488491 pptszResult = DataBase_MySQL_GetResult (xhDBSQL, xhTable);
492+ XLONG* pInt_Length = DataBase_MySQL_GetLength (xhDBSQL, xhTable);
489493
490494 if (NULL != pptszResult[1 ])
491495 {
@@ -513,19 +517,16 @@ bool CDBModule_MQData::DBModule_MQData_GetSerial(LPCXSTR lpszName, __int64x* pIn
513517 }
514518 if (NULL != pptszResult[7 ])
515519 {
516- _tcsxcpy (pSt_DBEnd->tszMsgBuffer , pptszResult[7 ]);
520+ pSt_DBEnd->nMsgLen = pInt_Length[7 ];
521+ memcpy (pSt_DBEnd->tszMsgBuffer , pptszResult[7 ], pSt_DBEnd->nMsgLen );
517522 }
518523 if (NULL != pptszResult[8 ])
519524 {
520- pSt_DBEnd->nMsgLen = _ttxoi (pptszResult[8 ]);
525+ pSt_DBEnd->byMsgType = _ttxoi (pptszResult[8 ]);
521526 }
522527 if (NULL != pptszResult[9 ])
523528 {
524- pSt_DBEnd->byMsgType = _ttxoi (pptszResult[9 ]);
525- }
526- if (NULL != pptszResult[10 ])
527- {
528- _tcsxcpy (pSt_DBEnd->tszQueueCreateTime , pptszResult[10 ]);
529+ _tcsxcpy (pSt_DBEnd->tszQueueCreateTime , pptszResult[9 ]);
529530 }
530531 DataBase_MySQL_FreeResult (xhDBSQL, xhTable);
531532 }
@@ -591,7 +592,6 @@ bool CDBModule_MQData::DBModule_MQData_CreateTable(LPCXSTR lpszQueueName)
591592 " `tszQueueLeftTime` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '过期时间',"
592593 " `tszQueuePublishTime` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '发布时间',"
593594 " `tszQueueData` longblob NOT NULL COMMENT '保存数据',"
594- " `nDataLen` int NOT NULL COMMENT '数据大小',"
595595 " `nDataType` tinyint NOT NULL COMMENT '数据类型',"
596596 " `tszQueueCreateTime` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '插入时间',"
597597 " PRIMARY KEY (`ID`) USING BTREE"
0 commit comments