39 sockfd(sockfdarg), pgcmdtype(
'\0'), size(0), outcmd(
'\0'),
userid(-1),
40 schemaPtr(NULL), session_isautocommit(true), isintransactionblock(false)
99 printf(
"%s %i anomaly events %u\n", __FILE__, __LINE__,
104 short retval =
initcmd(newdata);
123 printf(
"%s %i anomaly retval %i\n", __FILE__, __LINE__, retval);
136 if (
get(&sslreq)==
false)
142 if (sslreq != 80877103)
162 if (
get(&protvers)==
false)
168 if (protvers != 196608)
178 if (
get(paramstr)==
false)
186 if (
get(valstr)==
false)
233 if (
get(password)==
false)
245 new class MessageUserSchema(TOPIC_OPERATION);
254 taPtr->mboxes.toUserSchemaMgr(taPtr->myIdentity.address, *msg);
277 printf(
"%s %i don't know how to handle cmdtype %c\n", __FILE__,
319 putErrorResponse(
"ERROR",
"25P02",
"current transaction is aborted, commands ignored until end of transaction block");
331 printf(
"%s %i don't know how to handle cmdtype %c\n", __FILE__,
338 printf(
"%s %i anomaly state %i\n", __FILE__, __LINE__,
state);
349 ssize_t readed = recv(
sockfd, in, 8192, 0);
353 buf.append(in, readed);
355 else if (readed == -1)
357 if (errno==EAGAIN || errno==EWOULDBLOCK)
408 fprintf(
logfile,
"%s %i fd %i > %i\n", __FILE__, __LINE__, socketfd,
411 taRef.
Pgs.erase(socketfd);
422 inbuf.append(newdata);
431 inbuf.append(newdata);
438 memcpy(&
size, &newdata[0],
sizeof(
size));
440 inbuf = newdata.substr(
sizeof(
size), string::npos);
445 memcpy(&
size, &newdata[1],
sizeof(
size));
447 inbuf = newdata.substr(
sizeof(
size)+1, string::npos);
452 inbuf.append(newdata);
465 fprintf(
logfile,
"%s %i sockfd %i pgcmdtype %c inbuf.size() %lu sizeof(size) %lu size %u state %i '%s'\n", __FILE__, __LINE__,
sockfd,
pgcmdtype,
476 if (
pos +
sizeof(int16_t) >
inbuf.size())
482 memcpy(val, &
inbuf[
pos],
sizeof(int16_t));
483 *val = be16toh(*val);
484 pos +=
sizeof(int16_t);
491 if (
pos +
sizeof(int32_t) >
inbuf.size())
497 memcpy(val, &
inbuf[
pos],
sizeof(int32_t));
498 *val = be32toh(*val);
499 pos +=
sizeof(int32_t);
506 if (
pos +
sizeof(int64_t) >
inbuf.size())
512 memcpy(val, &
inbuf[
pos],
sizeof(int64_t));
513 *val = be64toh(*val);
514 pos +=
sizeof(int64_t);
519 bool Pg::get(vector<int16_t> &val,
size_t nelem)
521 if (
pos +
sizeof(int16_t)*nelem >
inbuf.size())
527 for (
size_t n=0; n < nelem; n++)
530 memcpy(&elem, &
inbuf[
pos],
sizeof(int16_t));
531 elem = be16toh(elem);
533 pos +=
sizeof(int16_t);
539 bool Pg::get(vector<int32_t> &val,
size_t nelem)
541 if (
pos +
sizeof(int32_t)*nelem >
inbuf.size())
547 for (
size_t n=0; n < nelem; n++)
550 memcpy(&elem, &
inbuf[
pos],
sizeof(int32_t));
551 elem = be32toh(elem);
553 pos +=
sizeof(int32_t);
559 bool Pg::get(vector<int64_t> &val,
size_t nelem)
561 if (
pos +
sizeof(int64_t)*nelem >
inbuf.size())
567 for (
size_t n=0; n < nelem; n++)
570 memcpy(&elem, &
inbuf[
pos],
sizeof(int64_t));
571 elem = be64toh(elem);
573 pos +=
sizeof(int64_t);
582 if (
pos +
sizeof(
char) >
inbuf.size())
597 if (
pos +
sizeof(
char)*nelem >
inbuf.size())
604 pos +=
sizeof(char)*nelem;
612 size_t endpos =
inbuf.find(
'\0',
pos);
614 if (endpos == string::npos)
627 size_t curpos =
outmsg.size();
628 outmsg.resize(curpos +
sizeof(int16_t));
630 memcpy(&
outmsg[curpos], &val,
sizeof(int16_t));
635 size_t curpos =
outmsg.size();
636 outmsg.resize(curpos +
sizeof(int32_t));
638 memcpy(&
outmsg[curpos], &val,
sizeof(int32_t));
643 size_t curpos =
outmsg.size();
644 outmsg.resize(curpos +
sizeof(int64_t));
646 memcpy(&
outmsg[curpos], &val,
sizeof(int64_t));
651 size_t curpos =
outmsg.size();
652 size_t nelem = val.size();
653 outmsg.resize(curpos +
sizeof(int16_t)*nelem);
655 for (
size_t n=0; n < nelem; n++)
657 int16_t elem = htobe16(val[n]);
658 memcpy(&
outmsg[curpos], &elem,
sizeof(int16_t));
659 curpos +=
sizeof(int16_t);
665 size_t curpos =
outmsg.size();
666 size_t nelem = val.size();
667 outmsg.resize(curpos +
sizeof(int32_t)*nelem);
669 for (
size_t n=0; n < nelem; n++)
671 int32_t elem = htobe32(val[n]);
672 memcpy(&
outmsg[curpos], &elem,
sizeof(int32_t));
673 curpos +=
sizeof(int32_t);
679 size_t curpos =
outmsg.size();
680 size_t nelem = val.size();
681 outmsg.resize(curpos +
sizeof(int64_t)*nelem);
683 for (
size_t n=0; n < nelem; n++)
685 int64_t elem = htobe64(val[n]);
686 memcpy(&
outmsg[curpos], &elem,
sizeof(int64_t));
687 curpos +=
sizeof(int64_t);
694 size_t curpos =
outmsg.size();
695 outmsg.resize(curpos +
sizeof(
char));
702 outmsg.append(val, nelem);
720 uint32_t osize = htobe32((uint32_t)
outmsg.size() +
sizeof(osize));
721 string prependstr(
sizeof(osize) +
sizeof(
outcmd),
'\0');
723 memcpy(&prependstr[1], &osize,
sizeof(osize));
724 outmsg.insert(0, prependstr);
756 size_t outbuflen =
outbuf.size();
758 while (curpos < outbuflen)
761 (outbuflen-curpos) >= 8192 ? 8192 :
762 outbuflen-curpos, 0);
766 if (errno==EAGAIN || errno==EWOULDBLOCK)
768 string backgroundstr =
outbuf.substr(curpos, string::npos);
769 outbuf.swap(backgroundstr);
770 struct epoll_event epevent;
771 epevent.events = EPOLLOUT | EPOLLHUP | EPOLLET;
799 struct epoll_event epevent;
800 epevent.events = EPOLLIN | EPOLLHUP | EPOLLET;
812 printf(
"%s %i anomaly WTF\n", __FILE__, __LINE__);
895 fprintf(
logfile,
"%s %i deleting this %p\n", __FILE__, __LINE__,
916 std::stringstream tag;
973 std::stringstream tag;
1003 std::stringstream tag;
1043 putNoticeResponse(
"WARNING",
"25001",
"there is already a transaction in progress");
1102 std::stringstream tag;
1129 printf(
"%s %i anomaly cmdtype %i statementStatus %li\n", __FILE__,
1260 for (int16_t n=0; n < numfields; n++)
1274 put((int32_t)INT8OID);
1304 printf(
"%s %i anomaly %i\n", __FILE__, __LINE__,
1318 boost::unordered_map< uuRecord_s, vector<fieldValue_s> >::const_iterator it;
1327 const vector<fieldValue_s> &
fieldValues = it->second;
1329 for (int16_t n=0; n < numfields; n++)
1331 if (fieldValues[n].isnull==
true)
1342 int32_t len=sprintf(val,
"%li", fieldValues[n].value.integer);
1351 int32_t len=sprintf(val,
"%lu", fieldValues[n].value.uinteger);
1360 if (fieldValues[n].value.boolean==
true)
1373 std::stringstream val;
1374 val << (double)fieldValues[n].value.floating;
1376 if ((
double)fieldValues[n].value.floating /
1377 (int64_t)fieldValues[n].value.floating == 1)
1382 int32_t len=val.str().size();
1384 put((
char *)val.str().c_str(), len);
1390 put(fieldValues[n].value.character);
1395 int32_t len = fieldValues[n].str.size();
1397 put((
char *)fieldValues[n].str.c_str(), len);
1403 int32_t len = fieldValues[n].str.size();
1405 put((
char *)fieldValues[n].str.c_str(), len);
1410 printf(
"%s %i anomaly %i\n", __FILE__, __LINE__,
1432 fprintf(
logfile,
"%s %i deleting this %p\n", __FILE__, __LINE__,
1460 fprintf(
logfile,
"%s %i deleting this %p\n", __FILE__, __LINE__,
1490 fprintf(
logfile,
"%s %i deleting this %p\n", __FILE__, __LINE__,
1511 fprintf(
logfile,
"%s %i deleting this %p\n", __FILE__, __LINE__,
1601 "generic InfiniSQL error");
1613 printf(
"%s %i anomaly %li\n", __FILE__, __LINE__, status);
1615 "syntax_error_or_access_rule_violation");