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

Function evlCharToUuid

src/jrd/SysFunction.cpp:2596–2684  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2594
2595
2596dsc* evlCharToUuid(thread_db* tdbb, const SysFunction* function, const NestValueArray& args,
2597 impure_value* impure)
2598{
2599 fb_assert(args.getCount() == 1);
2600
2601 Request* request = tdbb->getRequest();
2602
2603 const dsc* value = EVL_expr(tdbb, request, args[0]);
2604 if (request->req_flags & req_null) // return NULL if value is NULL
2605 return NULL;
2606
2607 if (!value->isText())
2608 {
2609 status_exception::raise(Arg::Gds(isc_expression_eval_err) <<
2610 Arg::Gds(isc_sysf_argviolates_uuidtype) << Arg::Str(function->name));
2611 }
2612
2613 UCHAR* data_temp;
2614 USHORT len = MOV_get_string(tdbb, value, &data_temp, NULL, 0);
2615 const UCHAR* data;
2616
2617 if (len > GUID_BODY_SIZE)
2618 {
2619 // Verify if only spaces exists after the expected length. See CORE-5062.
2620 data = data_temp + GUID_BODY_SIZE;
2621
2622 while (len > GUID_BODY_SIZE)
2623 {
2624 if (*data++ != ASCII_SPACE)
2625 break;
2626
2627 --len;
2628 }
2629 }
2630
2631 data = data_temp;
2632
2633 // validate the UUID
2634 if (len != GUID_BODY_SIZE) // 36
2635 {
2636 status_exception::raise(Arg::Gds(isc_expression_eval_err) <<
2637 Arg::Gds(isc_sysf_argviolates_uuidlen) <<
2638 Arg::Num(GUID_BODY_SIZE) <<
2639 Arg::Str(function->name));
2640 }
2641
2642 for (int i = 0; i < GUID_BODY_SIZE; ++i)
2643 {
2644 if (i == 8 || i == 13 || i == 18 || i == 23)
2645 {
2646 if (data[i] != '-')
2647 {
2648 status_exception::raise(Arg::Gds(isc_expression_eval_err) <<
2649 Arg::Gds(isc_sysf_argviolates_uuidfmt) <<
2650 Arg::Str(showInvalidChar(data[i])) <<
2651 Arg::Num(i + 1) <<
2652 Arg::Str(function->name));
2653 }

Callers

nothing calls this directly

Calls 12

EVL_exprFunction · 0.85
raiseFunction · 0.85
GdsClass · 0.85
StrClass · 0.85
MOV_get_stringFunction · 0.85
NumClass · 0.85
showInvalidCharFunction · 0.85
EVL_make_valueFunction · 0.85
isTextMethod · 0.80
makeTextMethod · 0.80
getCountMethod · 0.45
getRequestMethod · 0.45

Tested by

no test coverage detected