| 399 | } |
| 400 | |
| 401 | Request* Statement::findRequest(thread_db* tdbb, bool unique) |
| 402 | { |
| 403 | SET_TDBB(tdbb); |
| 404 | Attachment* const attachment = tdbb->getAttachment(); |
| 405 | |
| 406 | const Statement* const thisPointer = this; // avoid warning |
| 407 | if (!thisPointer) |
| 408 | BUGCHECK(167); /* msg 167 invalid SEND request */ |
| 409 | |
| 410 | // Search clones for one request in use by this attachment. |
| 411 | // If not found, return first inactive request. |
| 412 | |
| 413 | Request* clone = NULL; |
| 414 | USHORT count = 0; |
| 415 | const USHORT clones = requests.getCount(); |
| 416 | USHORT n; |
| 417 | |
| 418 | for (n = 0; n < clones; ++n) |
| 419 | { |
| 420 | Request* next = getRequest(tdbb, n); |
| 421 | |
| 422 | if (next->req_attachment == attachment) |
| 423 | { |
| 424 | if (!(next->req_flags & req_in_use)) |
| 425 | { |
| 426 | clone = next; |
| 427 | break; |
| 428 | } |
| 429 | |
| 430 | if (unique) |
| 431 | return NULL; |
| 432 | |
| 433 | ++count; |
| 434 | } |
| 435 | else if (!(next->req_flags & req_in_use) && !clone) |
| 436 | clone = next; |
| 437 | } |
| 438 | |
| 439 | if (count > MAX_CLONES) |
| 440 | ERR_post(Arg::Gds(isc_req_max_clones_exceeded)); |
| 441 | |
| 442 | if (!clone) |
| 443 | clone = getRequest(tdbb, n); |
| 444 | |
| 445 | clone->setAttachment(attachment); |
| 446 | clone->req_stats.reset(); |
| 447 | clone->req_base_stats.reset(); |
| 448 | clone->req_flags |= req_in_use; |
| 449 | |
| 450 | return clone; |
| 451 | } |
| 452 | |
| 453 | Request* Statement::getRequest(thread_db* tdbb, USHORT level) |
| 454 | { |
no test coverage detected