| 143 | |
| 144 | |
| 145 | void iscArrayLookupBoundsImpl(Why::YAttachment* attachment, |
| 146 | Why::YTransaction* transaction, const SCHAR* relationName, const SCHAR* fieldName, ISC_ARRAY_DESC* desc) |
| 147 | { |
| 148 | LocalStatus status; |
| 149 | CheckStatusWrapper statusWrapper(&status); |
| 150 | |
| 151 | MetaString globalField; |
| 152 | iscArrayLookupDescImpl(attachment, transaction, relationName, fieldName, desc, &globalField); |
| 153 | |
| 154 | ISC_ARRAY_BOUND* tail = desc->array_desc_bounds; |
| 155 | |
| 156 | constexpr auto sql = R"""( |
| 157 | select fd.rdb$lower_bound, |
| 158 | fd.rdb$upper_bound |
| 159 | from rdb$field_dimensions fd |
| 160 | where fd.rdb$field_name = ? |
| 161 | order by fd.rdb$dimension |
| 162 | )"""; |
| 163 | |
| 164 | FB_MESSAGE(InputMessage, CheckStatusWrapper, |
| 165 | (FB_VARCHAR(MAX_SQL_IDENTIFIER_LEN), fieldName) |
| 166 | ) inputMessage(&statusWrapper, MasterInterfacePtr()); |
| 167 | inputMessage.clear(); |
| 168 | |
| 169 | FB_MESSAGE(OutputMessage, CheckStatusWrapper, |
| 170 | (FB_INTEGER, lowerBound) |
| 171 | (FB_INTEGER, upperBound) |
| 172 | ) outputMessage(&statusWrapper, MasterInterfacePtr()); |
| 173 | |
| 174 | inputMessage->fieldNameNull = FB_FALSE; |
| 175 | inputMessage->fieldName.set(globalField.c_str()); |
| 176 | |
| 177 | auto resultSet = makeNoIncRef(attachment->openCursor(&statusWrapper, transaction, 0, sql, |
| 178 | SQL_DIALECT_CURRENT, inputMessage.getMetadata(), inputMessage.getData(), |
| 179 | outputMessage.getMetadata(), nullptr, 0)); |
| 180 | status.check(); |
| 181 | |
| 182 | while (resultSet->fetchNext(&statusWrapper, outputMessage.getData()) == IStatus::RESULT_OK) |
| 183 | { |
| 184 | tail->array_bound_lower = outputMessage->lowerBoundNull ? 0 : outputMessage->lowerBound; |
| 185 | tail->array_bound_upper = outputMessage->upperBoundNull ? 0 : outputMessage->upperBound; |
| 186 | ++tail; |
| 187 | } |
| 188 | |
| 189 | status.check(); |
| 190 | } |
| 191 | |
| 192 | |
| 193 | void iscArrayLookupDescImpl(Why::YAttachment* attachment, |
no test coverage detected