Skip to content

[Bug]: TEXT rejects 64KB payloads with value-echoing errors #31808

Open

Description

@Ariznawlll

Description

TEXT columns fail at the 64KB boundary with a self-contradictory type error, and error messages echo the entire oversized value into the error string (in my test, a 60-million-character payload got inlined into the error text). Boundary census on main c6683bd2f5 (2026-10-30):

inserted payload (parametrized INSERT into TEXT column) result
4 KB OK
16 KB OK
64 KB (65536 bytes, exactly 1 byte over MySQL's TINYTEXT/TEXT-family 65535 limit) ERROR 1406: "Can't cast column from TEXT type to TEXT type because of one overflow" — a TEXT→TEXT cast "overflow"
1 MB via SET @b then INSERT same 1406
60 MB direct same 1406 + the whole multi-megabyte value is inlined in the error message (client receives a 60MB+ error packet)

MySQL semantics: TEXT holds up to 65535 bytes (65536 = error 1406 "Data too long for column" with truncated display); MEDIUMTEXT 16 MB and LONGTEXT 4 GB exist for bigger payloads.

Two defects in one observation:

  1. Boundary correctness: MO's TEXT rejects ≥64KB payloads — numerically consistent with the 65535 limit — but the error message is nonsense ("cast TEXT to TEXT ... overflow" instead of "data too long"); and MO's own docs/benchmarks commonly treat TEXT as capable of large documents (full-text search workloads), so users hit this on 64KB+ JSON/XML documents or biography-sized text with no MEDIUMTEXT/LONGTEXT escape hatch visible. Verified: MEDIUMTEXT/LONGTEXT are accepted as DDL keywords, but whether they lift the ceiling needs the fix to make explicit (this report claims the TEXT 64KB behavior and message only).
  2. Error-message value inlining: the 1406 message embeds the full offending value. For a 60 MB payload the client receives a 60 MB error string — a memory/CPU amplification vector (a single bad INSERT costing hundreds of MB of error-traffic; trivially abusable as an easy DoS by sending one moderate-size packet).

Impact

  • Document/text workloads (CMS bodies, API response logging, JSON archives) silently assume >64KB text support per MySQL docs and fail with a confusing cast error.
  • The error echo turns one oversized insert into a 60MB+ network + allocation event — a single-statement DoS primitive.

Expected behavior

TEXT ≥64KB → clean 1406 "Data too long for column 't' at row 1" (no value echo — MySQL truncates the echo); MEDIUMTEXT/LONGTEXT raise the limit to their documented capacities.

Reproduction

cur.execute("CREATE TABLE t(id INT PRIMARY KEY, t TEXT)")
cur.execute("INSERT INTO t VALUES (1, %s)", ("y"*65536,))   # 1406 ... cast TEXT to TEXT

main @ c6683bd (2026-10-30), pymysql, threshold bisected at 16384 OK / 65536 fail.

Activity

  1. added
    kind/bug
    on Oct 30, 2026
  2. added this to the MO-202610 milestone on Oct 30, 2026
  3. added theissue type on Oct 30, 2026
  4. Ariznawlll commented on Oct 30, 2026

    @Ariznawlll
    CollaboratorAuthor

    Family extension for this report: BLOB shares the same boundary failure and value-echo behavior (census on main c6683bd2f5, 2026-10-30):

    CREATE TABLE b1(b BLOB);
    INSERT INTO b1 VALUES (%s) with 65536 bytes → ERROR 20101: internal error: Can't cast 'yyyy…' (full value echoed)
    -- 70000 bytes → same

    Same class as TEXT ≥64KB in the report body, but note the error code differs across the family: TEXT gave 1406 ("Can't cast column from TEXT type to TEXT type because of one overflow") on the direct path, while BLOB gives 20101 internal error with the raw value inlined — two different escape paths for the same shape of failure, both user-hostile. The value-echo DoS observation applies to both.

    Also verified while mapping the family, for triage completeness: BINARY(255)/BINARY(256) boundary is correct (256 rejected at DDL), VARBINARY(16383) rejects a 16400-byte insert with the echo-error, and VARBINARY(16384) DDL+insert works — so the caps and guards exist per type; it is specifically the BLOB/TEXT large-object path that collapses.

  5. XuPeng-SH commented on Oct 30, 2026

    @XuPeng-SH
    Contributor

    暂不整体转测:已合入 #31849 只修复 BLOB literal fast-path 的宽度错误/绕过 sql_mode;该 PR 明确未修改本 issue 原始 TEXT 错误措辞。正文要求的无整值回显、清晰 data-too-long 诊断与 MEDIUMTEXT/LONGTEXT 容量合同尚无完整交付证据,仍需开发跟进,保留现负责人。此为范围核对,不把 BLOB 局部修复或作者测试等同于整个 issue 通过;本轮未运行大载荷探针。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugneeds-triage

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions