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

Function evlPad

src/jrd/SysFunction.cpp:5846–6006  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5844
5845
5846dsc* evlPad(thread_db* tdbb, const SysFunction* function, const NestValueArray& args,
5847 impure_value* impure)
5848{
5849 fb_assert(args.getCount() >= 2);
5850
5851 Request* request = tdbb->getRequest();
5852
5853 const dsc* value1 = EVL_expr(tdbb, request, args[0]);
5854 if (request->req_flags & req_null) // return NULL if value1 is NULL
5855 return NULL;
5856
5857 const dsc* padLenDsc = EVL_expr(tdbb, request, args[1]);
5858 if (request->req_flags & req_null) // return NULL if padLenDsc is NULL
5859 return NULL;
5860
5861 const SLONG padLenArg = MOV_get_long(tdbb, padLenDsc, 0);
5862 if (padLenArg < 0)
5863 {
5864 status_exception::raise(Arg::Gds(isc_expression_eval_err) <<
5865 Arg::Gds(isc_sysf_argnmustbe_nonneg) <<
5866 Arg::Num(2) <<
5867 Arg::Str(function->name));
5868 }
5869
5870 ULONG padLen = static_cast<ULONG>(padLenArg);
5871
5872 const dsc* value2 = NULL;
5873 if (args.getCount() >= 3)
5874 {
5875 value2 = EVL_expr(tdbb, request, args[2]);
5876 if (request->req_flags & req_null) // return NULL if value2 is NULL
5877 return NULL;
5878 }
5879
5880 const USHORT ttype = value1->getTextType();
5881 CharSet* cs = INTL_charset_lookup(tdbb, ttype);
5882
5883 MoveBuffer buffer1;
5884 UCHAR* address1;
5885 ULONG length1 = MOV_make_string2(tdbb, value1, ttype, &address1, buffer1, false);
5886 ULONG charLength1 = cs->length(length1, address1, true);
5887
5888 MoveBuffer buffer2;
5889 const UCHAR* address2;
5890 ULONG length2;
5891
5892 if (value2 == NULL)
5893 {
5894 address2 = cs->getSpace();
5895 length2 = cs->getSpaceLength();
5896 }
5897 else
5898 {
5899 UCHAR* address2Temp = NULL;
5900 length2 = MOV_make_string2(tdbb, value2, ttype, &address2Temp, buffer2, false);
5901 address2 = address2Temp;
5902 }
5903

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_charset_lookupFunction · 0.85
MOV_make_string2Function · 0.85
EVL_make_valueFunction · 0.85
createFunction · 0.85
getTextTypeMethod · 0.80
getSpaceLengthMethod · 0.80

Tested by

no test coverage detected