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

Function evlPosition

src/jrd/SysFunction.cpp:6021–6144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6019
6020
6021dsc* evlPosition(thread_db* tdbb, const SysFunction* function, const NestValueArray& args,
6022 impure_value* impure)
6023{
6024 fb_assert(args.getCount() >= 2);
6025
6026 Request* request = tdbb->getRequest();
6027
6028 const dsc* value1 = EVL_expr(tdbb, request, args[0]);
6029 if (request->req_flags & req_null) // return NULL if value1 is NULL
6030 return NULL;
6031
6032 const dsc* value2 = EVL_expr(tdbb, request, args[1]);
6033 if (request->req_flags & req_null) // return NULL if value2 is NULL
6034 return NULL;
6035
6036 SLONG start = 1;
6037
6038 if (args.getCount() >= 3)
6039 {
6040 const dsc* value3 = EVL_expr(tdbb, request, args[2]);
6041 if (request->req_flags & req_null) // return NULL if value3 is NULL
6042 return NULL;
6043
6044 start = MOV_get_long(tdbb, value3, 0);
6045 if (start <= 0)
6046 {
6047 status_exception::raise(Arg::Gds(isc_expression_eval_err) <<
6048 Arg::Gds(isc_sysf_argnmustbe_positive) <<
6049 Arg::Num(3) <<
6050 Arg::Str(function->name));
6051 }
6052 }
6053
6054 // make descriptor for return value
6055 impure->vlu_desc.makeLong(0, &impure->vlu_misc.vlu_long);
6056
6057 // we'll use the collation from the second string
6058 const USHORT ttype = value2->getTextType();
6059 TextType* tt = INTL_texttype_lookup(tdbb, ttype);
6060 CharSet* cs = tt->getCharSet();
6061 const UCHAR canonicalWidth = tt->getCanonicalWidth();
6062
6063 MoveBuffer value1Buffer;
6064 UCHAR* value1Address;
6065 ULONG value1Length;
6066
6067 if (value1->isBlob())
6068 {
6069 // value1 is a blob
6070 blb* blob = blb::open(tdbb, tdbb->getRequest()->req_transaction,
6071 reinterpret_cast<bid*>(value1->dsc_address));
6072
6073 value1Address = value1Buffer.getBuffer(blob->blb_length);
6074 value1Length = blob->BLB_get_data(tdbb, value1Address, blob->blb_length, true);
6075 }
6076 else
6077 value1Length = MOV_make_string2(tdbb, value1, ttype, &value1Address, value1Buffer);
6078

Callers

nothing calls this directly

Calls 15

EVL_exprFunction · 0.85
MOV_get_longFunction · 0.85
raiseFunction · 0.85
GdsClass · 0.85
NumClass · 0.85
StrClass · 0.85
INTL_texttype_lookupFunction · 0.85
MOV_make_string2Function · 0.85
makeLongMethod · 0.80
getTextTypeMethod · 0.80
getCanonicalWidthMethod · 0.80
isBlobMethod · 0.80

Tested by

no test coverage detected