| 509 | } |
| 510 | |
| 511 | void AvgAggNode::make(DsqlCompilerScratch* dsqlScratch, dsc* desc) |
| 512 | { |
| 513 | DsqlDescMaker::fromNode(dsqlScratch, desc, arg, true); |
| 514 | |
| 515 | if (desc->isNull()) |
| 516 | return; |
| 517 | |
| 518 | if (DTYPE_IS_DECFLOAT(desc->dsc_dtype)) |
| 519 | return; |
| 520 | |
| 521 | if (dialect1) |
| 522 | { |
| 523 | if (!DTYPE_IS_NUMERIC(desc->dsc_dtype) && !DTYPE_IS_TEXT(desc->dsc_dtype)) |
| 524 | { |
| 525 | ERRD_post(Arg::Gds(isc_expression_eval_err) << |
| 526 | Arg::Gds(isc_dsql_agg_wrongarg) << Arg::Str("AVG")); |
| 527 | } |
| 528 | else if (DTYPE_IS_TEXT(desc->dsc_dtype)) |
| 529 | { |
| 530 | desc->dsc_dtype = dtype_double; |
| 531 | desc->dsc_length = sizeof(double); |
| 532 | } |
| 533 | } |
| 534 | else |
| 535 | { |
| 536 | if (!DTYPE_IS_NUMERIC(desc->dsc_dtype)) |
| 537 | { |
| 538 | ERRD_post(Arg::Gds(isc_expression_eval_err) << |
| 539 | Arg::Gds(isc_dsql_agg2_wrongarg) << Arg::Str("AVG")); |
| 540 | } |
| 541 | else if (desc->dsc_dtype == dtype_int128) |
| 542 | { |
| 543 | desc->dsc_dtype = dtype_int128; |
| 544 | desc->dsc_length = sizeof(Int128); |
| 545 | } |
| 546 | else if (DTYPE_IS_EXACT(desc->dsc_dtype)) |
| 547 | { |
| 548 | desc->dsc_dtype = dtype_int64; |
| 549 | desc->dsc_length = sizeof(SINT64); |
| 550 | } |
| 551 | else |
| 552 | { |
| 553 | desc->dsc_dtype = dtype_double; |
| 554 | desc->dsc_length = sizeof(double); |
| 555 | } |
| 556 | } |
| 557 | } |
| 558 | |
| 559 | void AvgAggNode::getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc) |
| 560 | { |
no test coverage detected