#include <SqlNetworkHandler.h>
Collaboration diagram for SqlNetworkHandler:
Public Member Functions | |
int | process (PacketHeader &header, char *buffer) |
int | processPrepare (PacketHeader &header, char *buffer) |
int | processCommit (PacketHeader &header, char *buffer) |
int | processFree (PacketHeader &header, char *buffer) |
Static Public Attributes | |
static List | stmtList |
static AbsSqlConnection * | conn |
static SqlApiImplType | type |
Definition at line 26 of file SqlNetworkHandler.h.
int SqlNetworkHandler::process | ( | PacketHeader & | header, | |
char * | buffer | |||
) |
Definition at line 34 of file SqlNetworkHandler.cxx.
References NW_PKT_COMMIT, NW_PKT_PREPARE, PacketHeader::packetType, processCommit(), and processPrepare().
Referenced by UDPServer::handleClient().
00035 { 00036 switch(header.packetType) 00037 { 00038 case NW_PKT_PREPARE: 00039 return processPrepare(header, buffer); 00040 break; 00041 case NW_PKT_COMMIT: 00042 return processCommit(header, buffer); 00043 break; 00044 } 00045 }
Here is the call graph for this function:
Here is the caller graph for this function:
int SqlNetworkHandler::processCommit | ( | PacketHeader & | header, | |
char * | buffer | |||
) |
Definition at line 47 of file SqlNetworkHandler.cxx.
References DM_Network, ErrSysFatal, PacketCommit::getExecPacketList(), OK, PacketHeader::packetLength, printDebug, printError, BasePacket::setBuffer(), BasePacket::setBufferSize(), stmtList, and PacketCommit::unmarshall().
Referenced by process().
00048 { 00049 printDebug(DM_Network, "Processing COMMIT"); 00050 PacketCommit *pkt = new PacketCommit(); 00051 pkt->setBuffer(buffer); 00052 pkt->setBufferSize(header.packetLength); 00053 pkt->unmarshall(); 00054 List pktList; 00055 pkt->getExecPacketList(stmtList, pktList); 00056 DbRetVal rv = applyExecPackets(stmtList, pktList); 00057 int response = 1; 00058 if (rv != OK) 00059 { 00060 printError(ErrSysFatal, "Unable to apply the exec packets\n"); 00061 response =0; 00062 } 00063 return response; 00064 00065 }
Here is the call graph for this function:
Here is the caller graph for this function:
int SqlNetworkHandler::processFree | ( | PacketHeader & | header, | |
char * | buffer | |||
) |
Definition at line 66 of file SqlNetworkHandler.cxx.
References PacketHeader::packetLength, BasePacket::setBuffer(), BasePacket::setBufferSize(), and PacketFree::unmarshall().
00067 { 00068 PacketFree *pkt = new PacketFree(); 00069 pkt->setBuffer(buffer); 00070 pkt->setBufferSize(header.packetLength); 00071 pkt->unmarshall(); 00072 //printf("FREE %d \n", pkt->stmtID); 00073 int response =1; 00074 //This wont work for two statement executed in same transaction using same SqlStatement object using free. 00075 //so do not delete now and put a flag 'readyfordelete' in NetworkStmt object and delete it during execute 00076 /* 00077 ListIterator iter = stmtList.getIterator(); 00078 NetworkStmt *stmt, *removeStmt = NULL; 00079 while (iter.hasElement()) 00080 { 00081 stmt = (NetworkStmt*)iter.nextElement(); 00082 if (stmt->srcNetworkID == header.srcNetworkID 00083 && stmt->stmtID == pkt->stmtID) 00084 { 00085 removeStmt = stmt; 00086 break; 00087 } 00088 } 00089 if (removeStmt) stmtList.remove(removeStmt); 00090 else printf("Statement id %d not found in list \n", pkt->stmtID); 00091 */ 00092 return response; 00093 }
Here is the call graph for this function:
int SqlNetworkHandler::processPrepare | ( | PacketHeader & | header, | |
char * | buffer | |||
) |
Definition at line 94 of file SqlNetworkHandler.cxx.
References AllDataType::alloc(), List::append(), conn, SqlFactory::createStatement(), DM_Network, ErrSysInit, PacketPrepare::length, BindSqlField::length, PacketPrepare::noParams, OK, PacketHeader::packetLength, NetworkStmt::paramList, AbsSqlStatement::prepare(), printDebug, printError, BasePacket::setBuffer(), BasePacket::setBufferSize(), AbsSqlStatement::setConnection(), PacketHeader::srcNetworkID, NetworkStmt::srcNetworkID, NetworkStmt::stmt, NetworkStmt::stmtID, PacketPrepare::stmtID, stmtList, PacketPrepare::stmtString, PacketPrepare::type, BindSqlField::type, type, PacketPrepare::unmarshall(), and BindSqlField::value.
Referenced by process().
00095 { 00096 PacketPrepare *pkt = new PacketPrepare(); 00097 pkt->setBuffer(buffer); 00098 pkt->setBufferSize(header.packetLength); 00099 pkt->unmarshall(); 00100 printDebug(DM_Network, "PREPARE %d %s\n", pkt->stmtID, pkt->stmtString); 00101 //for (int i =0 ; i < pkt->noParams; i++) 00102 //printf("PREPARE type %d length %d \n", pkt->type[i], pkt->length[i]); 00103 int response =1; 00104 //TODO::add it to the SqlStatement list 00105 AbsSqlStatement *sqlstmt = SqlFactory::createStatement(type); 00106 sqlstmt->setConnection(conn); 00107 NetworkStmt *nwStmt = new NetworkStmt(); 00108 printDebug(DM_Network, "Statement string %s\n", pkt->stmtString); 00109 nwStmt->srcNetworkID = header.srcNetworkID; 00110 nwStmt->stmtID = pkt->stmtID; 00111 nwStmt->stmt = sqlstmt; 00112 DbRetVal rv = sqlstmt->prepare(pkt->stmtString); 00113 if (rv != OK) 00114 { 00115 printError(ErrSysInit, "statement prepare failed\n"); 00116 response = 0; 00117 return response; 00118 } 00119 BindSqlField *bindField = NULL; 00120 //populate paramList 00121 for (int i = 0; i < pkt->noParams; i++) 00122 { 00123 bindField = new BindSqlField(); 00124 bindField->type = (DataType) pkt->type[i]; 00125 bindField->length = pkt->length[i]; 00126 bindField->value = AllDataType::alloc(bindField->type, 00127 bindField->length); 00128 nwStmt->paramList.append(bindField); 00129 } 00130 stmtList.append(nwStmt); 00131 return response; 00132 00133 }
Here is the call graph for this function:
Here is the caller graph for this function:
AbsSqlConnection * SqlNetworkHandler::conn [static] |
List SqlNetworkHandler::stmtList [static] |
Definition at line 34 of file SqlNetworkHandler.h.
Referenced by processCommit(), and processPrepare().
SqlApiImplType SqlNetworkHandler::type [static] |