Generate a sort clause.
| 617 | |
| 618 | // Generate a sort clause. |
| 619 | void GEN_sort(DsqlCompilerScratch* dsqlScratch, UCHAR blrVerb, ValueListNode* list) |
| 620 | { |
| 621 | dsqlScratch->appendUChar(blrVerb); |
| 622 | dsqlScratch->appendUChar(list ? list->items.getCount() : 0); |
| 623 | |
| 624 | if (list) |
| 625 | { |
| 626 | NestConst<ValueExprNode>* ptr = list->items.begin(); |
| 627 | |
| 628 | for (const NestConst<ValueExprNode>* const end = list->items.end(); ptr != end; ++ptr) |
| 629 | { |
| 630 | OrderNode* orderNode = nodeAs<OrderNode>(*ptr); |
| 631 | |
| 632 | switch (orderNode->nullsPlacement) |
| 633 | { |
| 634 | case OrderNode::NULLS_FIRST: |
| 635 | dsqlScratch->appendUChar(blr_nullsfirst); |
| 636 | break; |
| 637 | case OrderNode::NULLS_LAST: |
| 638 | dsqlScratch->appendUChar(blr_nullslast); |
| 639 | break; |
| 640 | } |
| 641 | |
| 642 | dsqlScratch->appendUChar((orderNode->descending ? blr_descending : blr_ascending)); |
| 643 | GEN_expr(dsqlScratch, orderNode->value); |
| 644 | } |
| 645 | } |
| 646 | } |
| 647 | |
| 648 | |
| 649 | // Write a context number into the BLR buffer. Check for possible overflow. |