sql: casting FLOAT in [32767, 32767.5) to INT2 fails with "integer out of range" only in the vectorized engine
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 72/100
Direzione di ricerca
Start with floatToInt in pkg/sql/colexec/execgen/cmd/execgen/cast_gen_util.go and compare it with pkg/sql/sem/eval/cast.go. Run the supplied SET vectorize queries around the INT2 and INT4 bounds, then exercise the vectorized cast implementation identified by EXPLAIN (VEC). Done means rounded values that fit the target integer width succeed consistently in both engines, with coverage for the positive and negative boundary cases.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the problem
With vectorize=on, casting a FLOAT in [32767, 32767.5) or (-32768.5, -32768] to INT2 fails with integer out of range, although the rounded value is in range. With vectorize=off the cast returns 32767 / -32768. INT4 behaves the same way near its bounds.
To Reproduce
Single node, cockroach start-single-node --insecure:
CREATE TABLE t (f FLOAT8);
INSERT INTO t VALUES (32767.0), (32767.4), (-32768.4), (2147483647.2);
SET vectorize = off;
SELECT f, f::INT2 FROM t WHERE f < 40000; -- 32767, 32767, -32768
SELECT f, f::INT4 FROM t WHERE f > 40000; -- 2147483647
SET vectorize = on;
SELECT f, f::INT2 FROM t WHERE f < 40000; -- ERROR: integer out of range (22003)
SELECT f, f::INT4 FROM t WHERE f > 40000; -- ERROR: integer out of range (22003)
EXPLAIN (VEC) shows colexecbase.castFloatInt2Op.
Expected behavior
32767 / -32768 / 2147483647 in both engines (PostgreSQL also returns 32767 for 32767.4::float8::int2).
Additional context
- Vectorized:
execgen/cast_gen_util.go:263floatToIntchecksv >= float(MaxInt16)/v <= float(MinInt16)before rounding, so 32767.0 itself is rejected. - Row engine:
sem/eval/cast.go:216checks the INT8 range, rounds withRoundToEven, and then checks the width inAdjustValueToType. - Related but different: #115131 (the row engine returns 32767 for
'32767.6'::float8::int2instead of an error).
Environment:
- CockroachDB v26.2.7 (official Docker image), Linux
Found with AI assistance.
Jira issue: CRDB-70075
- Lingua principale
- Go
- Stelle
- 32.6k
- Fork
- 4.2k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di cockroachdb/cockroach
-
C-bug O-community X-blathers-untriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
cockroachdb/cockroach#176245 · 1 commento ·
-
sql: pg_database.dattablespace is 0 but pg_tablespace.oid is 1663, so they no longer joinForse già presa @1AbdullahButt l’ha presa 14 giorni fa. ApertaC-bug O-community X-blathers-triaged X-move-internal
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
cockroachdb/cockroach#176228 · 1 commento ·
-
PG compat: overflow in integer power calculation triggers incompatible SQLSTATEForse di nuovo libera @darshpatel1052 l’ha presa 18 giorni fa e non c’è nessuna pull request aperta. ApertaC-bug O-community X-blathers-untriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
cockroachdb/cockroach#176223 · 2 commenti ·
-
util/log: bufferedSinkCloser.Close leaks a goroutine after timeoutForse già presa @dajiaohuang l’ha presa 14 giorni fa. ApertaC-bug O-community X-blathers-untriaged
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 84/100
cockroachdb/cockroach#176210 · 1 commento ·
-
C-bug O-community T-sql-queries X-blathers-triaged X-move-internal
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
cockroachdb/cockroach#176150 · 1 commento ·
Tutte le issue di cockroachdb/cockroach
Issue simili
-
☢️ Bug v3
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
area/import-export area/projects concern/ux
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
go-vikunja/vikunja#4455 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Dependabot PRs no longer merge automaticallyForse già presa @dwisiswant0 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
projectdiscovery/urlfinder#160 ·
I maintainer di solito rispondono entro 1 giorno
-
database
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
chnm/legal-modernism#450 ·
I maintainer di solito rispondono entro 1 giorno
-
tech-debt
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno