MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / iscArrayLookupDescImpl

Function iscArrayLookupDescImpl

src/yvalve/array.cpp:193–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

191
192
193void iscArrayLookupDescImpl(Why::YAttachment* attachment,
194 Why::YTransaction* transaction, const SCHAR* relationName, const SCHAR* fieldName, ISC_ARRAY_DESC* desc,
195 MetaString* globalField)
196{
197 LocalStatus status;
198 CheckStatusWrapper statusWrapper(&status);
199
200 copy_exact_name(fieldName, desc->array_desc_field_name, sizeof(desc->array_desc_field_name));
201 copy_exact_name(relationName, desc->array_desc_relation_name, sizeof(desc->array_desc_relation_name));
202
203 desc->array_desc_flags = 0;
204
205 constexpr auto sql = R"""(
206 select f.rdb$field_name,
207 f.rdb$field_type,
208 f.rdb$field_scale,
209 f.rdb$field_length,
210 f.rdb$dimensions
211 from rdb$relation_fields rf
212 join rdb$fields f
213 on f.rdb$field_name = rf.rdb$field_source
214 where rf.rdb$relation_name = ? and
215 rf.rdb$field_name = ?
216 )""";
217
218 FB_MESSAGE(InputMessage, CheckStatusWrapper,
219 (FB_VARCHAR(MAX_SQL_IDENTIFIER_LEN), relationName)
220 (FB_VARCHAR(MAX_SQL_IDENTIFIER_LEN), fieldName)
221 ) inputMessage(&statusWrapper, MasterInterfacePtr());
222 inputMessage.clear();
223
224 FB_MESSAGE(OutputMessage, CheckStatusWrapper,
225 (FB_VARCHAR(MAX_SQL_IDENTIFIER_LEN), fieldName)
226 (FB_INTEGER, fieldType)
227 (FB_INTEGER, fieldScale)
228 (FB_INTEGER, fieldLength)
229 (FB_INTEGER, dimensions)
230 ) outputMessage(&statusWrapper, MasterInterfacePtr());
231
232 inputMessage->relationNameNull = FB_FALSE;
233 inputMessage->relationName.set((const char*) relationName);
234
235 inputMessage->fieldNameNull = FB_FALSE;
236 inputMessage->fieldName.set((const char*) fieldName);
237
238 auto resultSet = makeNoIncRef(attachment->openCursor(&statusWrapper, transaction, 0, sql,
239 SQL_DIALECT_CURRENT, inputMessage.getMetadata(), inputMessage.getData(),
240 outputMessage.getMetadata(), nullptr, 0));
241 status.check();
242
243 if (resultSet->fetchNext(&statusWrapper, outputMessage.getData()) == IStatus::RESULT_OK)
244 {
245 if (globalField)
246 globalField->assign(outputMessage->fieldName.str, outputMessage->fieldName.length);
247
248 desc->array_desc_dtype = outputMessage->fieldTypeNull ? 0 : outputMessage->fieldType;
249 desc->array_desc_scale = outputMessage->fieldScaleNull ? 0 : outputMessage->fieldScale;
250 desc->array_desc_length = outputMessage->fieldLengthNull ? 0 : outputMessage->fieldLength;

Callers 2

iscArrayLookupBoundsImplFunction · 0.85

Calls 15

MasterInterfacePtrClass · 0.85
makeNoIncRefFunction · 0.85
adjust_lengthFunction · 0.85
GdsClass · 0.85
StrClass · 0.85
copy_exact_nameFunction · 0.70
clearMethod · 0.45
setMethod · 0.45
openCursorMethod · 0.45
getMetadataMethod · 0.45
getDataMethod · 0.45
checkMethod · 0.45

Tested by

no test coverage detected