[Bug]: max_join_size and sql_big_selects do not enforce SELECT row-examination limits

Aperta
#33,279 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@matrix-meow ci sta già lavorando.

Dal 26/11/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

area/compatibility kind/bug needs-triage

Description

Reproduced on MatrixOne main commit c0cef5c9cce2164fedd201c188bfffe4d2d09a96 (git_version() = c0cef5c) and compared with MySQL 8.0.46.

MatrixOne accepts and reads back max_join_size and sql_big_selects, but does not enforce the SELECT row-examination limit. With max_join_size=1 and sql_big_selects=0, a three-row single-table SELECT, a three-row key JOIN, and a nine-row CROSS JOIN all execute normally. MySQL rejects all three corresponding statements with Error 1104.

This is not limited to JOIN syntax: the basic single-table case also bypasses the guard. A single-table COUNT(*) also executes on MatrixOne; MySQL permits that optimized aggregate too, so the aggregate is documented below as scope information rather than as a compatibility difference.

Minimal reproduction

DROP DATABASE IF EXISTS repro_max_join_size;
CREATE DATABASE repro_max_join_size;
USE repro_max_join_size;

CREATE TABLE t(id INT PRIMARY KEY, v INT);
INSERT INTO t VALUES(1,10),(2,20),(3,30);

SET SESSION sql_big_selects=0;
SET SESSION max_join_size=1;
SELECT @@session.max_join_size, @@session.sql_big_selects;
-- 1, 0

SELECT * FROM t;
-- MatrixOne: returns all three rows
-- MySQL 8.0.46: ERROR 1104 (42000)

SELECT COUNT(*) FROM t;
-- MatrixOne: 3
-- MySQL 8.0.46: 3 (optimized aggregate; not itself a divergence)

SELECT a.id,b.v
FROM t a JOIN t b ON a.id=b.id
ORDER BY a.id;
-- MatrixOne: returns (1,10),(2,20),(3,30)
-- MySQL 8.0.46: ERROR 1104 (42000)

SELECT a.id,b.id
FROM t a CROSS JOIN t b
ORDER BY a.id,b.id;
-- MatrixOne: returns all nine rows
-- MySQL 8.0.46: ERROR 1104 (42000)

SET SESSION sql_big_selects=1;
SELECT a.id,b.v
FROM t a JOIN t b ON a.id=b.id
ORDER BY a.id;
-- control: succeeds

MySQL 8.0.46 produces the following for the single-table statement while the limit is enabled:

ERROR 1104 (42000): The SELECT would examine more than MAX_JOIN_SIZE rows;
check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=#
if the SELECT is okay

Setting sql_big_selects=1 allows the query again, as documented.

Expected behavior

When SQL_BIG_SELECTS=OFF, MatrixOne must reject a SELECT whose estimated row examination exceeds MAX_JOIN_SIZE, using MySQL-compatible Error 1104 semantics. SQL_BIG_SELECTS=ON should bypass this particular limit. These variables must affect admission/planning rather than being writable no-ops.

MySQL documents the interaction here: https://dev.mysql.com/doc/refman/8.0/en/mysql-tips.html#safe-updates

Additional controls

  • A key-JOIN restricted to one result row succeeds.
  • The three-row key JOIN and nine-row CROSS JOIN both succeed immediately after sql_big_selects is set to 1.
  • As a separate session-variable control, sql_select_limit=2 does limit an unqualified three-row SELECT to two rows, and an explicit LIMIT 3 overrides it. Thus the result above is specific to the missing max_join_size enforcement.

Duplicate check

Searched max_join_size, sql_big_selects, ER_TOO_BIG_SELECT, and the Error 1104 text in open and closed issues; no existing report of the missing admission check was found.

Lingua principale
Go
Stelle
1.9k
Fork
312
Merge medio
22h 59m
PR unite (30g)
736

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 matrixorigin/matrixone

Tutte le issue di matrixorigin/matrixone

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.