SQL: sqllogictest query returns NULL instead of an error
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
Direzione di ricerca
Start by comparing the behavior of NULLIF and division by zero in the SQL evaluation path, using the simplified SELECT NULLIF ( - CAST ( NULL AS REAL ), 1/0) repro. The issue points to changes around commits cbb4109 and 43a111b, associated with #6633 and #6666; trace those changes and add a regression test. Done means the query returns an error rather than null.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
super returns null here:
$ super -version &&
super -c "SELECT DISTINCT + 31 + + NULLIF ( - CAST ( NULL AS REAL ), - + 93 + - 22 / CASE COUNT ( * ) WHEN - NULLIF ( + 11, - 22 * 52 + 20 / + COALESCE ( - COALESCE ( 0, - 31 / 65 ), - 8 ) ) THEN - COUNT ( * ) ELSE NULL END ) AS col1;"
Version: v0.3.0-419-gb57febcd1
{col1:null}
Whereas Postgres surfaces a "division by zero" error:
$ psql postgres -c "SELECT DISTINCT + 31 + + NULLIF ( - CAST ( NULL AS REAL ), - + 93 + - 22 / CASE COUNT ( * ) WHEN - NULLIF ( + 11, - 22 * 52 + 20 / + COALESCE ( - COALESCE ( 0, - 31 / 65 ), - 8 ) ) THEN - COUNT ( * ) ELSE NULL END ) AS col1;"
ERROR: division by zero
Details
Repro is with super commit b57febc.
This is the same sqllogictest query studied in #6533. That issue's purpose was to point out how Postgres happens to fail quickly here by sniffing out the constant division by zero, whereas we surfaced an error("divide by zero") that was wrapped inside of other errors. At the time both systems were surfacing errors, so I'd not frame #6533 as a bug. However, as the repro above shows, since that time conditions have changed such that super is now returning a null value instead of any kind of error, so this seems more like a bug.
To walk the history from the original repro in #6533, the error("divide by zero") went away at commit cbb4109, which is associated with the removal of typed nulls via the merge of #6633.
$ super -version &&
super -c "SELECT DISTINCT + 31 + + NULLIF ( - CAST ( NULL AS REAL ), - + 93 + - 22 / CASE COUNT ( * ) WHEN - NULLIF ( + 11, - 22 * 52 + 20 / + COALESCE ( - COALESCE ( 0, - 31 / 65 ), - 8 ) ) THEN - COUNT ( * ) ELSE NULL END ) AS col1;"
Version: v0.1.0-23-gcbb41094c
{col1:error({message:"type incompatible with unary '-' operator",on:error({message:"cannot cast to float32",on:null})})}
Then the result became straight null starting at commit 43a111b, which is associated with the merge of #6666.
$ super -version &&
super -c "SELECT DISTINCT + 31 + + NULLIF ( - CAST ( NULL AS REAL ), - + 93 + - 22 / CASE COUNT ( * ) WHEN - NULLIF ( + 11, - 22 * 52 + 20 / + COALESCE ( - COALESCE ( 0, - 31 / 65 ), - 8 ) ) THEN - COUNT ( * ) ELSE NULL END ) AS col1;"
Version: v0.1.0-51-g43a111b6b
{col1:null}
It looks like similar symptoms can be shown by changes in the results of this simplified query at the same spots:
$ super -version && super -c "SELECT NULLIF ( - CAST ( NULL AS REAL ), 1/0)"
Version: v0.1.0-22-g1bced4402
{NULLIF:error("divide by zero")}
$ super -version && super -c "SELECT NULLIF ( - CAST ( NULL AS REAL ), 1/0)"
Version: v0.1.0-23-gcbb41094c
{NULLIF:error({message:"type incompatible with unary '-' operator",on:error({message:"cannot cast to float32",on:null})})}
$ super -version && super -c "SELECT NULLIF ( - CAST ( NULL AS REAL ), 1/0)"
Version: v0.1.0-51-g43a111b6b
{NULLIF:null}
- Lingua principale
- Go
- Stelle
- 1.6k
- Fork
- 84
- Merge medio
- 10h
- PR unite (30g)
- 125
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 superdb/super
-
"super db detach" is documented but not availableForse già presa @mccanne l’ha presa oggi. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
zeek reader: time/interval values with more than 9 fractional digits silently become 0; out-of-range values wrapForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertacommunity
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
superdb/super#7492 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
sql-coverage
Difficoltà 4/5 3-5 giorni Idoneità per principianti 57/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 47/100
superdb/super#7503 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 Più di una settimana Idoneità per principianti 18/100
superdb/super#7484 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di superdb/super
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
Rafaeldelinares/gentle-mesh#125 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
Gentleman-Programming/gentle-ai#5643 ·
I maintainer di solito rispondono entro 1 giorno
-
security
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
FootprintAI/Containarium#2869 ·
I maintainer di solito rispondono entro 1 giorno
-
kind/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
kubevirt/kubevirt#19559 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
bug raised-by:verifier
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
medici-finance/assay#3817 ·
I maintainer di solito rispondono entro 1 giorno