Skip to content

expr: Convert PadChar to the sqlfunc macro - #39079

Closed
antiguru wants to merge 1 commit into
sqlfunc-convert-int16from
sqlfunc-convert-char
Closed

antiguru wants to merge 1 commit into
sqlfunc-convert-int16from
sqlfunc-convert-char

Conversation

@antiguru

@antiguru antiguru commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Converts PadChar to #[sqlfunc]. It reads its length both when evaluating and when computing the output type, so the function takes &self and an output_type_expr. sqlname = "padchar" keeps the SQL name.

The registry reports only sqlfunc_signature moving, on both records. No declared property changed.

Based on #39062.

🤖 Generated with Claude Code

@antiguru
antiguru requested a review from a team as a code owner September 23, 2026 21:09
@antiguru
antiguru added this pull request to stack #38942 September 24, 2026 08:52
@antiguru
antiguru force-pushed the sqlfunc-convert-char branch from 398ae5c to f90b8d5 Compare September 24, 2026 10:14
@antiguru
antiguru force-pushed the sqlfunc-convert-int16 branch from 14443d5 to a0fc9c4 Compare September 24, 2026 10:14
@antiguru
antiguru requested a review from petrosagg September 24, 2026 11:17
@antiguru
antiguru force-pushed the sqlfunc-convert-char branch from f90b8d5 to 782b054 Compare September 24, 2026 14:29
@antiguru
antiguru force-pushed the sqlfunc-convert-int16 branch from a0fc9c4 to 6a6e9d9 Compare September 24, 2026 14:29
@antiguru
antiguru force-pushed the sqlfunc-convert-char branch from 782b054 to 52aff8b Compare September 25, 2026 16:00
@antiguru
antiguru force-pushed the sqlfunc-convert-int16 branch from 6a6e9d9 to 4ea08d0 Compare September 25, 2026 16:00
@antiguru
antiguru removed the request for review from petrosagg October 13, 2026 15:56
@antiguru
antiguru force-pushed the sqlfunc-convert-int16 branch from 4ea08d0 to e7b8eab Compare October 14, 2026 09:11
@antiguru
antiguru force-pushed the sqlfunc-convert-char branch from 52aff8b to a40619c Compare October 14, 2026 09:11
@antiguru
antiguru requested a review from mgree October 14, 2026 10:22
`PadChar` reads its `length` field in both the call and the output type, so it
takes a `&self` receiver and an `output_type_expr`. The expression collapses to
what the hand-written `output_sql_type` returned: it sets nullability from the
input, and the macro's tail adds only `propagates_nulls && input_type.nullable`,
which the non-nullable `&str` input makes the same term.

`introduces_nulls` derives false from the `Char<String>` output. `could_error`
stays derived, false for a non-`Result` output, matching an impl that never
overrode it.

The `Display` impl wrote a fixed string, so `sqlname` reproduces it. Note that
the SQL name is `padchar` while the function is `pad_char`, so the `func_name!`
entry the macro replaces keeps its own spelling.

The registry reports only `sqlfunc_signature` moving, on both the bounded and
unbounded samples. No declared property changed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@antiguru
antiguru force-pushed the sqlfunc-convert-int16 branch from e7b8eab to 7be7836 Compare October 14, 2026 15:18
@antiguru
antiguru force-pushed the sqlfunc-convert-char branch from a40619c to 72f1ef0 Compare October 14, 2026 15:18
@antiguru
antiguru removed this pull request from stack #38942 October 14, 2026 15:45
@antiguru

Copy link
Copy Markdown
Member Author

Folded into #39062, which now carries all twenty file conversions as separate commits, per review feedback to land them as one PR.

Posted by Claude Code.

@antiguru antiguru closed this Oct 14, 2026
antiguru added a commit that referenced this pull request Oct 14, 2026
…ro (#39062)

Converts the remaining hand-written scalar functions to `#[sqlfunc]`,
one commit per source file or function: the `Cast*ToNumeric` casts
(`int16`, `int32`, `int64`, `uint16`, `uint32`, `uint64`, `float32`,
`float64`, `jsonb`), `PadChar`, `AdjustNumericScale`,
`CastArrayToString`, `CastRangeToString`, and all of `date.rs`,
`time.rs`, `map.rs`, `record.rs`, `list.rs`, `timestamp.rs` and
`string.rs`. Each commit message accounts for every method the deleted
impl overrode.

No declared property changes. The registry reports only the macro
provenance fields moving. Where a hand-written impl declared a property
more conservatively than the body needs, the conversion pins the
declared value: `could_error` on `record_get`, and `introduces_nulls`,
`could_error` and a nullable output on `map_build_from_record_list`.
#39814 corrects both.

Supersedes #39079 to #39097, which held one conversion each.

Based on #39061.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
@antiguru
antiguru deleted the sqlfunc-convert-char branch October 14, 2026 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant