| 4835 | |
| 4836 | |
| 4837 | bool ResultSet::fetch(CheckStatusWrapper* status, void* buffer, P_FETCH operation, int position) |
| 4838 | { |
| 4839 | /************************************** |
| 4840 | * |
| 4841 | * d s q l _ f e t c h |
| 4842 | * |
| 4843 | ************************************** |
| 4844 | * |
| 4845 | * Functional description |
| 4846 | * Fetch next record from a dynamic SQL cursor. |
| 4847 | * |
| 4848 | **************************************/ |
| 4849 | |
| 4850 | reset(status); |
| 4851 | |
| 4852 | // Check and validate handles, etc. |
| 4853 | |
| 4854 | if (delayedFormat || !stmt) |
| 4855 | { |
| 4856 | (Arg::Gds(isc_dsql_cursor_err) << Arg::Gds(isc_bad_req_handle)).raise(); |
| 4857 | } |
| 4858 | |
| 4859 | Rsr* const statement = stmt->getStatement(); |
| 4860 | CHECK_HANDLE(statement, isc_bad_req_handle); |
| 4861 | |
| 4862 | Rdb* const rdb = statement->rsr_rdb; |
| 4863 | CHECK_HANDLE(rdb, isc_bad_db_handle); |
| 4864 | |
| 4865 | rem_port* const port = rdb->rdb_port; |
| 4866 | |
| 4867 | // Scrolling is not available in older protocols |
| 4868 | if (operation != fetch_next && port->port_protocol < PROTOCOL_FETCH_SCROLL) |
| 4869 | unsupported(); |
| 4870 | |
| 4871 | // Whether we're fetching relatively to the current position |
| 4872 | const bool relative = |
| 4873 | (operation == fetch_next || operation == fetch_prior || operation == fetch_relative); |
| 4874 | |
| 4875 | BlrFromMessage outBlr(outputFormat, stmt->getDialect(), port->port_protocol); |
| 4876 | unsigned int blr_length = outBlr.getLength(); |
| 4877 | const UCHAR* blr = outBlr.getBytes(); |
| 4878 | const unsigned int msg_length = outBlr.getMsgLength(); |
| 4879 | UCHAR* msg = static_cast<UCHAR*>(buffer); |
| 4880 | |
| 4881 | // Validate data length |
| 4882 | |
| 4883 | CHECK_LENGTH(port, blr_length); |
| 4884 | CHECK_LENGTH(port, msg_length); |
| 4885 | |
| 4886 | RefMutexGuard portGuard(*port->port_sync, FB_FUNCTION); |
| 4887 | |
| 4888 | if (!statement->rsr_flags.test(Rsr::FETCHED)) |
| 4889 | { |
| 4890 | // On first fetch, clear the end-of-stream flag & reset the message buffers |
| 4891 | |
| 4892 | statement->raiseException(); |
| 4893 | |
| 4894 | statement->rsr_flags.clear(Rsr::STREAM_END | Rsr::PAST_END | Rsr::STREAM_ERR); |
nothing calls this directly
no test coverage detected