| 1 | #include "duckdb/parser/expression/collate_expression.hpp" |
|---|---|
| 2 | #include "duckdb/planner/expression/bound_parameter_expression.hpp" |
| 3 | #include "duckdb/planner/expression_binder.hpp" |
| 4 | |
| 5 | namespace duckdb { |
| 6 | |
| 7 | BindResult ExpressionBinder::BindExpression(CollateExpression &expr, idx_t depth) { |
| 8 | // first try to bind the child of the cast expression |
| 9 | string error = Bind(expr&: expr.child, depth); |
| 10 | if (!error.empty()) { |
| 11 | return BindResult(error); |
| 12 | } |
| 13 | auto &child = BoundExpression::GetExpression(expr&: *expr.child); |
| 14 | if (child->HasParameter()) { |
| 15 | throw ParameterNotResolvedException(); |
| 16 | } |
| 17 | if (child->return_type.id() != LogicalTypeId::VARCHAR) { |
| 18 | throw BinderException("collations are only supported for type varchar"); |
| 19 | } |
| 20 | // Validate the collation, but don't use it |
| 21 | PushCollation(context, source: child->Copy(), collation: expr.collation, equality_only: false); |
| 22 | child->return_type = LogicalType::VARCHAR_COLLATION(collation: expr.collation); |
| 23 | return BindResult(std::move(child)); |
| 24 | } |
| 25 | |
| 26 | } // namespace duckdb |
| 27 |