Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

BugReport: Issues with COALESCE function

オープン
#19,478 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
sql
領域
databases

調査の方向性

まず、添付された tidb/tpcd.sql のデータを読み込み、TiDB 8.3.0 に対して両方のクエリを実行して、結果が異なることを確認します。NOT IN と EXCEPT の動作を比較し、そのうえで問題がこのドキュメントリポジトリではなく TiDB にあるのかを判断します。完了とみなすには、診断が確認され、ドキュメントまたは issue が明確に更新されている必要があります。

索引モデルが issue の本文から書いたものです。

説明

BugReport: Issues with COALESCE function

version

8.3.0

Original sql

SELECT DISTINCT l_shipinstruct, l_extendedprice, l_comment
FROM lineitem
WHERE l_shipmode NOT IN (
    SELECT l_commitdate
    FROM lineitem
    WHERE l_commitdate IS NOT NULL
) AND l_shipmode IS NOT NULL ;

return 0 row

Rewritten sql

SELECT DISTINCT l_shipinstruct, l_extendedprice, l_comment
FROM lineitem
WHERE l_shipmode IS NOT NULL
AND l_commitdate IS NOT NULL
EXCEPT
SELECT DISTINCT l_shipinstruct, l_extendedprice, l_comment
FROM lineitem
WHERE l_shipmode IN (
    SELECT l_commitdate
    FROM lineitem
)AND l_shipmode IS NOT NULL
AND l_commitdate IS NOT NULL;

return 5895 row

Analysis

These two queries are logically equivalent, although they are written differently.

The original query uses a NOT IN subquery to filter rows where l_shipmode is not in the set of l_commitdate (where l_commitdate is not NULL) and where l_shipmode is not NULL. Specifically, the query:

  • Uses the subquery SELECT l_commitdate FROM lineitem WHERE l_commitdate IS NOT NULL to get all non-NULL values of l_commitdate.
  • Excludes rows where l_shipmode is in the result set of this subquery, ensuring that l_shipmode is not in any of those l_commitdate values.
  • The condition l_shipmode IS NOT NULL ensures that only rows where l_shipmode is not NULL are returned.

The rewritten query uses an EXCEPT subquery to achieve the same logic:

  • The first part of the query returns all rows where both l_shipmode and l_commitdate are not NULL.
  • The second part (through EXCEPT) returns all rows where l_shipmode is in the set of l_commitdate, and both l_shipmode and l_commitdate are not NULL.
  • The EXCEPT operator excludes the results of the second part, effectively returning all rows where l_shipmode is not in the l_commitdate set and both columns are not NULL.

The two SQL queries are logically equivalent, but they return different results, indicating the presence of a bug.

How to repeat

The exported file for the database is in the attachment. : (https://github.com/LLuopeiqi/newtpcd/blob/main/tidb/tpcd.sql) .

主要言語
Python
スター
616
フォーク
725
平均マージ
1日 6時間
マージ済み PR(30日)
534

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

pingcap/docs のほかの issue

pingcap/docs の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。