Skip to content

Commit

Permalink
improve error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
fuyufjh committed May 21, 2024
1 parent ebcdd90 commit b370df0
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/frontend/src/binder/expr/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1016,19 +1016,15 @@ impl Binder {
if inputs[0].return_type() != DataType::Varchar {
// Support `quote_literal(any)` by converting it to `quote_literal(any::text)`
// Ref. https://github.com/postgres/postgres/blob/REL_16_1/src/include/catalog/pg_proc.dat#L4641
FunctionCall::cast_mut(&mut inputs[0], DataType::Varchar, CastContext::Explicit).map_err(|e| {
ErrorCode::BindError(format!("{} in `quote_literal`", e.as_report()))
})?;
FunctionCall::cast_mut(&mut inputs[0], DataType::Varchar, CastContext::Explicit)?;
}
Ok(FunctionCall::new_unchecked(ExprType::QuoteLiteral, inputs, DataType::Varchar).into())
}))),
("quote_nullable", guard_by_len(1, raw(|_binder, mut inputs| {
if inputs[0].return_type() != DataType::Varchar {
// Support `quote_nullable(any)` by converting it to `quote_nullable(any::text)`
// Ref. https://github.com/postgres/postgres/blob/REL_16_1/src/include/catalog/pg_proc.dat#L4650
FunctionCall::cast_mut(&mut inputs[0], DataType::Varchar, CastContext::Explicit).map_err(|e| {
ErrorCode::BindError(format!("{} in `quote_nullable`", e.as_report()))
})?;
FunctionCall::cast_mut(&mut inputs[0], DataType::Varchar, CastContext::Explicit)?;
}
Ok(FunctionCall::new_unchecked(ExprType::QuoteNullable, inputs, DataType::Varchar).into())
}))),
Expand Down

0 comments on commit b370df0

Please sign in to comment.