CONCAT produces extra trailing bytes for a BLOB argument in a UTF-16le database

Aperta
#1,483 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
java, sql, sqlite

Direzione di ricerca

Start by reproducing the SQL script against a newly created database, setting UTF-16le encoding before creating tables; compare the HEX results for the direct cast and CONCAT. The issue names no source files or tests, so trace CONCAT's handling of BLOB arguments and BLOB-to-text conversion in the SQLite code bundled with sqlite-jdbc. Done means the single-argument CONCAT result matches the expected text without trailing bytes, with the UTF-16le case verified.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

triage

I observed unexpected trailing bytes when passing a BLOB argument to CONCAT() in a UTF-16le database.

Reproduction

Run this script against a newly created, empty database. The encoding must be set before creating any tables.

PRAGMA encoding = 'UTF-16le';

CREATE TABLE t(x);
INSERT INTO t VALUES(960613696.0);

PRAGMA encoding;

SELECT
    HEX(CAST(CAST(x AS BLOB) AS TEXT)) AS direct_text,
    HEX(CONCAT(CAST(x AS BLOB))) AS concatenated
FROM t;

SELECT sqlite_version(), sqlite_source_id();
Actual result
direct_text:
3900360030003600310033003600390036002E003000

concatenated:
3900360030003600310033003600390036002E00300000000300000000000000000000000000000000000000

The CONCAT result contains the expected prefix followed by additional bytes.

Expected result

I would expect CONCAT() with this single non-NULL argument to produce the same text content as the explicit conversion to TEXT, without additional trailing bytes.

Version tested
SQLite 3.51.1
2025-11-28 17:28:25
281fc0e9afc38674b9b0991943b9e9d1e64c6cbdb133d35f6f5c87ff6af38a88

I also tested a development Fiddle build:

SQLite 3.54.0
2026-10-05 14:22:13
4bfc6e53a95d710b7f40fa9c80d8cdd1df50d69ed8614e9800f7e6a1ca5a3c29

However, that test produced UTF-8 output, so it did not reproduce the same encoding conditions. I have not yet verified whether the issue persists in the development build with a UTF-16le database.

Is this a known or already-fixed issue involving CONCAT(), BLOB-to-text conversion, and UTF-16 database encoding?

Lingua principale
Java
Stelle
3.3k
Fork
676
Merge medio
1g 15h
PR unite (30g)
18

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di xerial/sqlite-jdbc

Tutte le issue di xerial/sqlite-jdbc

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.