Skip to content

fix: Bind hms values of 256 hours or more without wrapping around - #616

Merged
krlmlr merged 1 commit into
claude/bind-microsecondsfrom
claude/bind-time-hours
Nov 29, 2026
Merged

krlmlr merged 1 commit into
claude/bind-microsecondsfrom
claude/bind-time-hours

Conversation

@krlmlr

@krlmlr krlmlr commented Nov 29, 2026

Copy link
Copy Markdown
Member

Closes #609. Stacked on #610.

Before this change, a bound hms of 256 hours or more was stored modulo 256 hours in TIME columns: 256:00:00 became 00:00:00, and 300:00:00 became 44:00:00. All hours went into the hour field of MYSQL_TIME, but the binary protocol sends a TIME value as days plus an hour byte.

Change

  • For TIME, whole days now go into day, and the rest goes through set_time_buffer(). neg comes from the full value, so -24:00:00 keeps its sign.
  • DATETIME is unchanged.
  • Values beyond TIME's range (±838:59:59) are clamped by the server, without a warning and also under STRICT_TRANS_TABLES. Before, they wrapped around. The clamping is left to the server.

Tests

tests/testthat/test-bind-microseconds.R gains a block for 255, 256, 300 and 838:59:59.999999 hours and their negatives. It fails without the fix when linked to libmysqlclient 8.0. With the fix, it passes against MariaDB 10.11 with both libmysqlclient 8.0 and MariaDB Connector/C 3.3.17. The whole suite had 0 failures and the one test-timezone.R error ("US/Alaska" unknown to CCTZ in this container), which also happens on main. MySQL servers were not tested: there is no server in this container, and CI's MySQL entries currently run MariaDB (#592).

Session: https://claude.ai/code/session_01Hr1rd5PUWgaCJzotWt9NhJ


Generated by Claude Code

@krlmlr
krlmlr added this pull request to stack #617 November 29, 2026 12:13

krlmlr commented Nov 29, 2026

Copy link
Copy Markdown
Member Author

Accepted limitations

The clean review found nothing above Low.


Generated by Claude Code

@krlmlr
krlmlr marked this pull request as ready for review November 29, 2026 12:14
@krlmlr
krlmlr merged commit 13d9a53 into main Nov 29, 2026
9 checks passed
@krlmlr
krlmlr deleted the claude/bind-time-hours branch November 29, 2026 13:56
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.

Bound hms values of 256 hours or more wrap around in TIME columns

2 participants