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

Function evlFirstLastDay

src/jrd/SysFunction.cpp:4319–4452  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4317
4318
4319dsc* evlFirstLastDay(thread_db* tdbb, const SysFunction* function, const NestValueArray& args,
4320 impure_value* impure)
4321{
4322 fb_assert(args.getCount() >= 2);
4323
4324 Request* request = tdbb->getRequest();
4325
4326 const dsc* partDsc = EVL_expr(tdbb, request, args[0]);
4327 if (request->req_flags & req_null) // return NULL if partDsc is NULL
4328 return NULL;
4329
4330 const dsc* valueDsc = EVL_expr(tdbb, request, args[1]);
4331 if (request->req_flags & req_null) // return NULL if valueDsc is NULL
4332 return NULL;
4333
4334 TimeStamp timestamp;
4335 tm times = {0};
4336 int fractions = 0;
4337
4338 switch (valueDsc->dsc_dtype)
4339 {
4340 case dtype_sql_date:
4341 timestamp.value().timestamp_date = *(GDS_DATE*) valueDsc->dsc_address;
4342 timestamp.value().timestamp_time = 0;
4343 timestamp.decode(&times, &fractions);
4344 break;
4345
4346 case dtype_timestamp:
4347 timestamp.value() = *(GDS_TIMESTAMP*) valueDsc->dsc_address;
4348 timestamp.decode(&times, &fractions);
4349 break;
4350
4351 case dtype_timestamp_tz:
4352 TimeZoneUtil::decodeTimeStamp(*(ISC_TIMESTAMP_TZ*) valueDsc->dsc_address, false, TimeZoneUtil::NO_OFFSET,
4353 &times, &fractions);
4354 break;
4355
4356 default:
4357 status_exception::raise(
4358 Arg::Gds(isc_expression_eval_err) <<
4359 Arg::Gds(isc_sysf_invalid_date_timestamp) <<
4360 Arg::Str(function->name));
4361 break;
4362 }
4363
4364 const SLONG part = MOV_get_long(tdbb, partDsc, 0);
4365
4366 switch (part)
4367 {
4368 case blr_extract_year:
4369 times.tm_mon = 0;
4370 // fall through
4371
4372 case blr_extract_month:
4373 times.tm_mday = 1;
4374 break;
4375
4376 case blr_extract_quarter:

Callers

nothing calls this directly

Calls 11

EVL_exprFunction · 0.85
raiseFunction · 0.85
GdsClass · 0.85
StrClass · 0.85
MOV_get_longFunction · 0.85
EVL_make_valueFunction · 0.85
getCountMethod · 0.45
getRequestMethod · 0.45
valueMethod · 0.45
decodeMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected