Skip to content

Commit 98c8a37

Browse files
committed
fix(pgwire): infer column-backed placeholder parameter types from catalog
Extend $N placeholder type inference beyond catalog-free forms (LIMIT/ OFFSET, casts) to catalog-backed positions such as `WHERE col = $1`, `IN (...)`, `BETWEEN`, and `SET col = $N`, so a bare parameterised query with no prepare_typed and no cast resolves its parameter type instead of describing it as unknown. The resolved type carries the column's declared integer width so an INT column reports int4 rather than collapsing to int8. Split placeholder_types.rs into a directory (catalog_free, column_backed, scope, slots, infer) now that inference spans multiple resolution strategies sharing a scope-tracking context. Also bound the shared placeholder scanner's accepted $N index to the pgwire wire format's Int16 ceiling, so a hostile index that parses as a usize but exceeds what any conforming client could send is left untracked rather than propagated to callers that size a Vec off it.
1 parent 210d634 commit 98c8a37

14 files changed

Lines changed: 1721 additions & 537 deletions

File tree

nodedb-sql/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub use visitor::plan_visitor::args::*;
4040
pub use catalog::{SqlCatalog, SqlCatalogError};
4141
pub use error::{Result, SqlError};
4242
pub use params::ParamValue;
43-
pub use placeholder_types::infer_placeholder_types;
43+
pub use placeholder_types::{InferredParamType, infer_placeholder_types};
4444
pub use types::*;
4545

4646
/// Parse a standalone SQL expression string into an `SqlExpr`.

0 commit comments

Comments
 (0)