Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ Pinned to [KipData/KiteSQL](https://github.com/KipData/KiteSQL) `main` (`522eb00

| Cargo feature | MySQL behaviour | Upstream hook / issue |
| --- | --- | --- |
| *(default)* | `SqlDialect::parse` with sqlparser MySQL + rewrite, `DataTypeMapper`, `comparison_type`, `boolean_text`, `begin_commits_active_transaction`, `SqlParser::with_set_autocommit`, prefix indexes, fixed-arity scalar functions via `Database::load` | [#404](https://github.com/KipData/KiteSQL/pull/404), [#406](https://github.com/KipData/KiteSQL/pull/406), [#407](https://github.com/KipData/KiteSQL/pull/407), [#409](https://github.com/KipData/KiteSQL/pull/409), [#410](https://github.com/KipData/KiteSQL/pull/410) |
| `hook-functions` | Variadic / `accepts_any_args` functions (`GREATEST`/`LEAST`, open-ended `CONCAT`, …) and richer binder lookup | Implicit-cast function lookup + `ScalarFunctionImpl::{accepts_arity,accepts_any_args,return_type_for}` ([#412](https://github.com/KipData/KiteSQL/issues/412)); FunctionRegistry/packs |
| *(default)* | `SqlDialect::parse` with sqlparser MySQL + rewrite, `DataTypeMapper`, `comparison_type`, `boolean_text`, `begin_commits_active_transaction`, `SqlParser::with_set_autocommit`, prefix indexes, fixed-arity scalar functions via `Database::load`, resolved by implicit cast | [#404](https://github.com/KipData/KiteSQL/pull/404), [#406](https://github.com/KipData/KiteSQL/pull/406), [#407](https://github.com/KipData/KiteSQL/pull/407), [#409](https://github.com/KipData/KiteSQL/pull/409), [#410](https://github.com/KipData/KiteSQL/pull/410), [#418](https://github.com/KipData/KiteSQL/pull/418) |
| `hook-functions` | Variadic / `accepts_any_args` functions (`GREATEST`/`LEAST`, open-ended `CONCAT`, …) and `return_type_for` | `ScalarFunctionImpl::{accepts_arity,accepts_any_args,return_type_for}`; implicit-cast lookup itself landed in [#418](https://github.com/KipData/KiteSQL/pull/418) ([#412](https://github.com/KipData/KiteSQL/issues/412)) |
| `hook-collation` | `utf8mb4_0900_ai_ci` text comparison keys | Dialect collation hooks (`text_collation` / binary-collation detection) |
| `hook-nulls-first` | NULLs first ascending / last descending | Dialect `nulls_first` hook |
| `hook-numeric-typing` | Exact DECIMAL literals, `/` and `AVG` scale rules, arithmetic result types | Dialect `number_literal` / `arithmetic_return_type` / `avg_return_type` hooks |
Expand Down Expand Up @@ -119,7 +119,7 @@ Text comparison follows MySQL 8's default collation: case- and accent-insensitiv

### MySQL Functions

Default build registers fixed-arity implementations through `Database::load` (for example `REPLACE`, `CONCAT` with 1..=8 arguments, `ROUND`, `UUID`, `ISNULL` over common types). Variadic/`accepts_any_args` forms and reliable use on length-bounded column types wait on `hook-functions` / [#412](https://github.com/KipData/KiteSQL/issues/412).
Default build registers fixed-arity implementations through `Database::load` (for example `REPLACE`, `CONCAT` with 1..=8 arguments, `ROUND`, `UUID`, `ISNULL` over common types). Arguments are resolved by implicit cast ([#418](https://github.com/KipData/KiteSQL/pull/418)), so length-bounded `VARCHAR(n)`, `DECIMAL(p,s)`, `VARBINARY(n)`, `TIME(n)` and `TIMESTAMP(n)` columns reach functions declared on the unbounded type, and NULL arguments resolve. Still open: variadic/`accepts_any_args` forms (`GREATEST`/`LEAST`, `CONCAT` over 8 arguments) wait on `hook-functions`, and numeric arguments to `VARCHAR` parameters (for example `CONCAT('a', 1)`, `LENGTH(int_col)`) are not an implicit cast in core.

### NULL Ordering (`hook-nulls-first`)

Expand Down
6 changes: 4 additions & 2 deletions src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ impl MySqlFunctions {
IntegerDivide::new(),
];

// Upstream looks up functions by exact (name, arg_types); register HEX/ROUND
// overloads for the numeric types MySQL accepts.
// Upstream resolves arguments by implicit cast (KipData/KiteSQL#418), preferring the
// closest overload. HEX, ISNULL and ROUND keep one overload per type on purpose: their
// behaviour or result type follows the argument type (for example integers must not go
// through DOUBLE).
for arg_type in ISNULL_ARG_TYPES {
functions.push(Hex::new(arg_type.clone()));
functions.push(IsNull::new(arg_type.clone()));
Expand Down
3 changes: 1 addition & 2 deletions tests/issue_fixes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ fn hex_boolean() -> Result<(), DatabaseError> {

// Issue 4: Truly variadic (11+ arguments work)
#[test]
#[ignore = "needs hook-functions variadic concat"]
#[ignore = "needs hook-functions: variadic CONCAT (#418 resolves fixed arity only)"]
fn concat_variadic() -> Result<(), DatabaseError> {
let dir = TempDir::new().unwrap();
let db = database(&dir)?;
Expand Down Expand Up @@ -157,7 +157,6 @@ fn locate_pos_less_than_1() -> Result<(), DatabaseError> {

// Issue: NULL handling in ROUND
#[test]
#[ignore = "upstream binder rejects NULL literal arg types"]
fn round_null_handling() -> Result<(), DatabaseError> {
let dir = TempDir::new().unwrap();
let db = database(&dir)?;
Expand Down
19 changes: 4 additions & 15 deletions tests/mysql_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ fn replace_semantics() -> Result<(), DatabaseError> {
}

#[test]
#[ignore = "needs hook-functions / exact-type binder workarounds"]
fn replace_on_bounded_columns_in_dml() -> Result<(), DatabaseError> {
let dir = TempDir::new().unwrap();
let mut db = database(&dir)?;
Expand Down Expand Up @@ -182,7 +181,6 @@ fn cms_link_backfill_statement() -> Result<(), DatabaseError> {
}

#[test]
#[ignore = "needs hook-functions / exact-type binder workarounds"]
fn length_function() -> Result<(), DatabaseError> {
let dir = TempDir::new().unwrap();
let db = database(&dir)?;
Expand All @@ -195,7 +193,6 @@ fn length_function() -> Result<(), DatabaseError> {
}

#[test]
#[ignore = "needs hook-functions / exact-type binder workarounds"]
fn length_in_order_by_on_varchar_column() -> Result<(), DatabaseError> {
let dir = TempDir::new().unwrap();
let mut db = database(&dir)?;
Expand All @@ -220,7 +217,6 @@ fn length_in_order_by_on_varchar_column() -> Result<(), DatabaseError> {
}

#[test]
#[ignore = "needs hook-functions / exact-type binder workarounds"]
fn concat_functions() -> Result<(), DatabaseError> {
let dir = TempDir::new().unwrap();
let db = database(&dir)?;
Expand Down Expand Up @@ -249,7 +245,6 @@ fn concat_functions() -> Result<(), DatabaseError> {
}

#[test]
#[ignore = "needs hook-functions / exact-type binder workarounds"]
fn substring_index_function() -> Result<(), DatabaseError> {
let dir = TempDir::new().unwrap();
let db = database(&dir)?;
Expand Down Expand Up @@ -278,7 +273,6 @@ fn substring_index_function() -> Result<(), DatabaseError> {
}

#[test]
#[ignore = "needs hook-functions / exact-type binder workarounds"]
fn locate_instr_position_functions() -> Result<(), DatabaseError> {
let dir = TempDir::new().unwrap();
let db = database(&dir)?;
Expand Down Expand Up @@ -314,7 +308,6 @@ fn locate_instr_position_functions() -> Result<(), DatabaseError> {
}

#[test]
#[ignore = "needs hook-functions / exact-type binder workarounds"]
fn left_right_functions() -> Result<(), DatabaseError> {
let dir = TempDir::new().unwrap();
let db = database(&dir)?;
Expand All @@ -341,7 +334,6 @@ fn lpad_rpad_functions() -> Result<(), DatabaseError> {
}

#[test]
#[ignore = "needs hook-functions / exact-type binder workarounds"]
fn repeat_reverse_functions() -> Result<(), DatabaseError> {
let dir = TempDir::new().unwrap();
let db = database(&dir)?;
Expand All @@ -356,7 +348,6 @@ fn repeat_reverse_functions() -> Result<(), DatabaseError> {
}

#[test]
#[ignore = "needs hook-functions / exact-type binder workarounds"]
fn ltrim_rtrim_functions() -> Result<(), DatabaseError> {
let dir = TempDir::new().unwrap();
let db = database(&dir)?;
Expand Down Expand Up @@ -392,7 +383,7 @@ fn uuid_function() -> Result<(), DatabaseError> {
}

#[test]
#[ignore = "needs hook-functions / exact-type binder workarounds"]
#[ignore = "needs hook-functions: variadic GREATEST/LEAST (#418 resolves fixed arity only)"]
fn greatest_least_functions() -> Result<(), DatabaseError> {
let dir = TempDir::new().unwrap();
let db = database(&dir)?;
Expand Down Expand Up @@ -454,7 +445,7 @@ fn round_function() -> Result<(), DatabaseError> {
}

#[test]
#[ignore = "needs hook-functions / exact-type binder workarounds"]
#[ignore = "needs hook-functions: variadic GREATEST/LEAST (#418 resolves fixed arity only)"]
fn greatest_least_common_type() -> Result<(), DatabaseError> {
use ordered_float::OrderedFloat;
use rust_decimal::Decimal;
Expand Down Expand Up @@ -514,7 +505,7 @@ fn greatest_least_common_type() -> Result<(), DatabaseError> {
}

#[test]
#[ignore = "needs hook-functions / exact-type binder workarounds"]
#[ignore = "needs hook-functions: variadic GREATEST/LEAST (#418 resolves fixed arity only)"]
fn greatest_least_temporal_comparison() -> Result<(), DatabaseError> {
let dir = TempDir::new().unwrap();
let mut db = database(&dir)?;
Expand Down Expand Up @@ -612,7 +603,6 @@ fn wrong_arity_is_an_error_not_a_panic() -> Result<(), DatabaseError> {
}

#[test]
#[ignore = "needs hook-functions / exact-type binder workarounds"]
fn round_return_type_follows_argument() -> Result<(), DatabaseError> {
use ordered_float::OrderedFloat;
use rust_decimal::Decimal;
Expand Down Expand Up @@ -651,7 +641,7 @@ fn round_return_type_follows_argument() -> Result<(), DatabaseError> {
}

#[test]
#[ignore = "needs hook-functions / exact-type binder workarounds"]
#[ignore = "needs hook-numeric-typing on upstream (exact DECIMAL literals)"]
fn round_literal_is_exact() -> Result<(), DatabaseError> {
use ordered_float::OrderedFloat;
use rust_decimal::Decimal;
Expand Down Expand Up @@ -711,7 +701,6 @@ fn locate_empty_needle_and_start_bounds() -> Result<(), DatabaseError> {
}

#[test]
#[ignore = "needs hook-functions / exact-type binder workarounds"]
fn isnull_function() -> Result<(), DatabaseError> {
let dir = TempDir::new().expect("temp dir");
let mut db = database(&dir)?;
Expand Down
12 changes: 5 additions & 7 deletions tests/mysql_new_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ fn locate_character_positions_not_bytes() -> Result<(), DatabaseError> {
}

#[test]
#[ignore = "needs hook-functions / exact-type binder workarounds"]
fn round_with_decimal() -> Result<(), DatabaseError> {
let dir = TempDir::new().unwrap();
let mut db = database(&dir)?;
Expand Down Expand Up @@ -170,7 +169,7 @@ fn hex_with_bigint_column() -> Result<(), DatabaseError> {
}

#[test]
#[ignore = "needs hook-functions / exact-type binder workarounds"]
#[ignore = "needs numeric -> VARCHAR argument casts, not an implicit cast in core (#418 follow-up)"]
fn length_with_int_column() -> Result<(), DatabaseError> {
let dir = TempDir::new().unwrap();
let mut db = database(&dir)?;
Expand All @@ -194,7 +193,7 @@ fn length_with_int_column() -> Result<(), DatabaseError> {
}

#[test]
#[ignore = "needs hook-functions / exact-type binder workarounds"]
#[ignore = "needs numeric -> VARCHAR argument casts, not an implicit cast in core (#418 follow-up)"]
fn concat_with_numeric_arguments() -> Result<(), DatabaseError> {
let dir = TempDir::new().unwrap();
let db = database(&dir)?;
Expand Down Expand Up @@ -223,7 +222,7 @@ fn concat_variadic_1_to_6_args() -> Result<(), DatabaseError> {
}

#[test]
#[ignore = "needs hook-functions / exact-type binder workarounds"]
#[ignore = "needs hook-functions: variadic GREATEST/LEAST (#418 resolves fixed arity only)"]
fn greatest_least_with_integers() -> Result<(), DatabaseError> {
let dir = TempDir::new().unwrap();
let db = database(&dir)?;
Expand All @@ -237,7 +236,7 @@ fn greatest_least_with_integers() -> Result<(), DatabaseError> {
}

#[test]
#[ignore = "needs hook-functions / exact-type binder workarounds"]
#[ignore = "needs hook-functions: variadic GREATEST/LEAST (#418 resolves fixed arity only)"]
fn greatest_least_with_null() -> Result<(), DatabaseError> {
let dir = TempDir::new().unwrap();
let db = database(&dir)?;
Expand All @@ -248,7 +247,7 @@ fn greatest_least_with_null() -> Result<(), DatabaseError> {
}

#[test]
#[ignore = "needs hook-functions / exact-type binder workarounds"]
#[ignore = "needs hook-functions: variadic GREATEST/LEAST (#418 resolves fixed arity only)"]
fn greatest_least_more_than_4_args() -> Result<(), DatabaseError> {
let dir = TempDir::new().unwrap();
let db = database(&dir)?;
Expand Down Expand Up @@ -285,7 +284,6 @@ fn position_in_syntax_matches_mysql() -> Result<(), DatabaseError> {

// String function edge cases from mysql-test func_str/lpad/rpad.test.
#[test]
#[ignore = "needs hook-functions / exact-type binder workarounds"]
fn string_function_edge_cases_match_mysql() -> Result<(), DatabaseError> {
let dir = TempDir::new().unwrap();
let db = database(&dir)?;
Expand Down