55 class Field newfield(type, length, indextype, name);
57 fields.push_back(newfield);
94 fprintf(
logfile,
"anomaly: %i %s %i\n", type, __FILE__, __LINE__);
103 vector<fieldValue_s> &fieldValRef = *fieldVal;
105 if (fieldValRef.size() !=
fields.size())
107 fprintf(
logfile,
"%s %i anomaly fieldValRef.size() %lu fields.size() %lu\n", __FILE__, __LINE__, (
unsigned long)fieldValRef.size(),
108 (
unsigned long)
fields.size());
119 bool hasvarchar=
false;
121 for (
size_t n=0; n<fieldValRef.size(); n++)
123 rsize +=
sizeof(bool);
129 rsize +=
sizeof(int64_t);
133 rsize +=
sizeof(uint64_t);
137 rsize +=
sizeof(bool);
141 rsize +=
sizeof(
long double);
145 rsize +=
sizeof(char);
149 rsize +=
fields[n].length;
153 rsize +=
sizeof(int64_t);
154 rsize += fieldValRef[n].str.length();
159 fprintf(
logfile,
"anomaly: %i %s %i\n",
fields[n].type, __FILE__,
165 if (hasvarchar==
true)
170 res->assign(rsize, 0);
175 for (
size_t n=0; n<
fields.size(); n++)
177 if (fieldValRef[n].isnull==
false)
179 res->operator [](pos++)=0;
183 res->operator[](pos++)=1;
190 memcpy(&res->operator [](pos), &fieldValRef[n].value.integer,
191 sizeof(fieldValRef[n].value.integer));
192 pos +=
sizeof(fieldValRef[n].value.integer);
196 memcpy(&res->operator [](pos), &fieldValRef[n].value.uinteger,
197 sizeof(fieldValRef[n].value.uinteger));
198 pos +=
sizeof(fieldValRef[n].value.uinteger);
202 memcpy(&res->operator [](pos), &fieldValRef[n].value.boolean,
203 sizeof(fieldValRef[n].value.boolean));
204 pos +=
sizeof(fieldValRef[n].value.boolean);
208 memcpy(&res->operator [](pos), &fieldValRef[n].value.floating,
209 sizeof(fieldValRef[n].value.floating));
210 pos +=
sizeof(fieldValRef[n].value.floating);
214 memcpy(&res->operator [](pos), &fieldValRef[n].value.character,
215 sizeof(fieldValRef[n].value.character));
216 pos +=
sizeof(fieldValRef[n].value.character);
222 if (fieldValRef[n].str.length() < (size_t)
fields[n].
length)
224 fieldValRef[n].str.append(
fields[n].length-
225 fieldValRef[n].str.length(),
' ');
228 fieldValRef[n].str.copy(&res->operator [](pos),
fields[n].length, 0);
234 int64_t varcharlength = fieldValRef[n].str.length();
235 memcpy(&res->operator [](pos),
236 &varcharlength,
sizeof(varcharlength));
237 pos +=
sizeof(varcharlength);
238 memcpy(&res->operator [](pos), fieldValRef[n].str.c_str(),
240 pos += varcharlength;
245 fprintf(
logfile,
"anomaly: %i %s %i\n",
fields[n].type, __FILE__,
254 int64_t subtransactionid, int64_t pendingcmdid,
255 vector<returnRow_s> *returnRows,
256 vector<int64_t> *lockPendingRowids,
257 int64_t tacmdentrypoint)
261 lockPendingRowids->clear();
266 for (
size_t n=0; n < rowids.size(); n++)
268 int64_t rid = rowids[n];
272 currentRowPtr =
rows[rid];
282 r.
row = currentRowPtr->
row;
283 returnRows->push_back(r);
296 r.
row = currentRowPtr->
row;
297 returnRows->push_back(r);
300 new boost::unordered_set<int64_t>;
301 printf(
"%s %i ROWID %li READLOCKHOLDERS->insert %li\n",
302 __FILE__, __LINE__, rid, subtransactionid);
309 printf(
"%s %i ROWID %li READLOCKHOLDERS->insert %li\n",
310 __FILE__, __LINE__, rid, subtransactionid);
314 r.
row = currentRowPtr->
row;
315 returnRows->push_back(r);
329 lockPendingRowids->push_back(rid);
334 fprintf(
logfile,
"anomaly: %i %s %i\n",
352 r.
row = currentRowPtr->
row;
353 returnRows->push_back(r);
367 lockPendingRowids->push_back(rid);
381 lockPendingRowids->push_back(rid);
386 fprintf(
logfile,
"anomaly: %i %s %i\n",
394 fprintf(
logfile,
"anomaly: %i %s %i\n", locktype, __FILE__,
403 if (!
rows.count(rowid))
413 fprintf(
logfile,
"anomaly %i %li %s %i\n", currentRowRef.
flags,
429 int64_t forward_rowid, int64_t forward_engineid)
431 int64_t status =
deleterow(rowid, subtransactionid);
442 forwarder.
rowid = forward_rowid;
443 forwarder.
engineid = forward_engineid;
449 int64_t subtransactionid, int64_t pendingcmdid,
450 vector<returnRow_s> *returnRows, int64_t tacmdentrypoint)
452 vector<returnRow_s> &returnRowsRef = *returnRows;
453 size_t numrowids = rowids->size();
454 returnRowsRef.reserve(numrowids);
462 for (
size_t n=0; n<numrowids; n++)
464 rowid = rowids->at(n);
465 workrow.
rowid = rowid;
467 if (!
rows.count(rowid))
480 if (
rows[rowid]->readlockHolders->count(subtransactionid))
488 if (
rows[rowid]->writelockHolder==subtransactionid)
496 printf(
"%s %i anomaly %i\n", __FILE__, __LINE__,
501 workrow.
row =
rows[rowid]->row;
505 returnRowsRef.push_back(workrow);
512 for (
size_t n=0; n<numrowids; n++)
514 rowid = rowids->at(n);
515 workrow.
rowid = rowid;
517 if (!
rows.count(rowid))
528 rows[rowid]->readlockHolders =
529 new boost::unordered_set<int64_t>;
530 rows[rowid]->readlockHolders->insert(subtransactionid);
531 workrow.
row =
rows[rowid]->row;
536 if (
rows[rowid]->readlockHolders->count(subtransactionid))
542 rows[rowid]->readlockHolders->insert(subtransactionid);
543 workrow.
row =
rows[rowid]->row;
551 if (
rows[rowid]->writelockHolder==subtransactionid)
569 fprintf(
logfile,
"anomaly: %i %s %i\n",
574 returnRowsRef.push_back(workrow);
581 for (
size_t n=0; n<numrowids; n++)
583 rowid = rowids->at(n);
584 workrow.
rowid = rowid;
586 if (!
rows.count(rowid))
597 rows[rowid]->writelockHolder = subtransactionid;
598 workrow.
row =
rows[rowid]->row;
615 if (subtransactionid ==
rows[rowid]->writelockHolder)
617 workrow.
row =
rows[rowid]->row;
636 fprintf(
logfile,
"anomaly: %i %s %i\n",
641 returnRowsRef.push_back(workrow);
647 fprintf(
logfile,
"anomaly: %i %s %i\n", locktype, __FILE__, __LINE__);
664 printf(
"%s %i anomaly subtransactionid %li\n", __FILE__,
665 __LINE__, subtransactionid);
684 printf(
"%s %i anomaly flags %i subtransactionid %li writelockHolder %li rowid %li cmd %i flags %i\n", __FILE__, __LINE__, (
int)currentRowRef.
flags,
686 (
int)currentRowRef.
flags);
697 delete ¤tRowRef;
711 printf(
"%s %i anomaly: readlockHolders\n", __FILE__, __LINE__);
712 boost::unordered_set<int64_t>::const_iterator it;
717 printf(
"%s %i readlockHolder %li\n", __FILE__, __LINE__, *it);
730 shadowRowRef.
flags=0;
740 delete ¤tRowRef;
741 rows[rowid]=&shadowRowRef;
747 printf(
"%s %i anomaly\n", __FILE__, __LINE__);
748 currentRowRef.
flags=0;
776 if (!
rows.count(rowid))
786 fprintf(
logfile,
"anomaly: %s %i\n", __FILE__, __LINE__);
792 delete ¤tRowRef;
811 printf(
"%s %i anomaly rowid %li\n", __FILE__, __LINE__, rowid);
830 currentRowRef.
flags = 0;
853 fprintf(
logfile,
"anomaly: %s %i\n", __FILE__, __LINE__);
859 fprintf(
logfile,
"anomaly: %s %i\n", __FILE__, __LINE__);
878 if (!
rows.count(rowid))
888 fprintf(
logfile,
"anomaly: %s %i\n", __FILE__, __LINE__);
898 currentRowRef.
flags = 0;
907 fprintf(
logfile,
"anomaly %i %s %i\n", cmd, __FILE__, __LINE__);
913 vector<fieldValue_s> &resultFieldsRef = *resultFields;
914 string &rowstringRef = *rowstring;
917 size_t numfields =
fields.size();
919 size_t rowsize = rowstringRef.size();
921 for (
size_t n=0; n < numfields; n++)
923 if (pos >= rowsize-1)
928 if (rowstringRef[pos++] == 0)
930 resultFieldsRef[n].isnull =
false;
934 resultFieldsRef[n].isnull =
true;
941 memcpy(&resultFieldsRef[n].value.integer, &rowstringRef[pos],
942 sizeof(resultFieldsRef[n].value.integer));
943 pos +=
sizeof(resultFieldsRef[n].value.integer);
947 memcpy(&resultFieldsRef[n].value.uinteger, &rowstringRef[pos],
948 sizeof(resultFieldsRef[n].value.uinteger));
949 pos +=
sizeof(resultFieldsRef[n].value.uinteger);
953 memcpy(&resultFieldsRef[n].value.boolean, &rowstringRef[pos],
954 sizeof(resultFieldsRef[n].value.boolean));
955 pos +=
sizeof(resultFieldsRef[n].value.boolean);
959 memcpy(&resultFieldsRef[n].value.floating, &rowstringRef[pos],
960 sizeof(resultFieldsRef[n].value.floating));
961 pos +=
sizeof(resultFieldsRef[n].value.floating);
965 memcpy(&resultFieldsRef[n].value.character, &rowstringRef[pos],
966 sizeof(resultFieldsRef[n].value.character));
967 pos +=
sizeof(resultFieldsRef[n].value.character);
972 resultFieldsRef[n].str.assign(rowstringRef, pos,
fields[n].
length);
974 if (resultFieldsRef[n].str.size() <
fields[n].length)
977 printf(
"%s %i rowstring.size() %lu field %lu resultFieldsRef[n].str.size() %lu fields[n].length %lu\n", __FILE__, __LINE__,
978 (
unsigned long)rowstring->size(), (
unsigned long)n,
979 resultFieldsRef[n].str.size(),
fields[n].length);
980 resultFieldsRef[n].str.append(
fields[n].length -
981 resultFieldsRef[n].str.size(), 0);
989 int64_t varcharlength;
990 memcpy(&varcharlength, &rowstringRef[pos],
sizeof(varcharlength));
991 pos +=
sizeof(varcharlength);
992 resultFieldsRef[n].str.assign(rowstringRef, pos, varcharlength);
993 pos += varcharlength;
998 fprintf(
logfile,
"anomaly: %i %s %i\n",
fields[n].type, __FILE__,
1022 rows[newrowid] = nrow;
1028 if (!
rows.count(rowid))
1038 fprintf(
logfile,
"anomaly %i %li %s %i\n", currentRowRef.
flags,
1048 int64_t subtransactionid, int64_t pendingcmdid, int64_t tacmdentrypoint)