Repository navigation
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review of exact head 159121e8370fd9ae11c022a650d8729dd41d04f1 against the implementation contract and MySQL 8.0.42's own source/tests. The parser/token work has useful differential coverage, but three reachable blockers remain:
-
[P1 semantic persistence] The function is registered as deterministic/foldable although its result depends on runtime variables. Every overload leaves both
volatileandrealTimeRelatedfalse, whileStatementDigestTextreads sessionsql_modeand globalmax_digest_length. MatrixOne can therefore constant-fold a literal call and, more seriously,checkExprForVolatileFuncpermits it in generated columns. A stored generated value can then depend on mutable session/global state, contrary to MatrixOne's generated-column invariant and MySQL's explicit rejection ofstatement_digest_textin generated columns. Give the overload the correct non-foldable/runtime-related properties and cover generated-column rejection plus PREPARE/EXECUTE across a settings change. -
[P1 compatibility] Binary inputs are accepted even though MySQL rejects the binary character set.
statementDigestTextFunctionexplicitly registersBINARY,VARBINARY, andBLOB, and the unit test requires them to succeed. MySQL 8.0.42's implementation callsis_supported_parser_charsetand its officialfunc_digest_errors.incexpects an undisclosed parse/function error for binary/geometry input; current MySQL additionally checkscs == my_charset_binexplicitly. Valid UTF-8 bytes in a blob currently return a digest in MO instead of the required error. Enforce the charset contract and test both valid-looking and arbitrary binary payloads. -
[P1 error confidentiality/compatibility]
Vector.IsConst()is not MySQL's “literal” test. MySQL usesItem::basic_const_item(): only a literal may expose parser details; any expression, even one that folds to a constant vector, must useER_UNDISCLOSED_PARSE_ERROR_IN_DIGEST_FN. This implementation will disclose for folded constant expressions becausediscloseParseErroris based on vector shape. The official suite specifically expectsstatement_digest_text(statement_digest_text('SELECT 1, 2, 3'))to fail undisclosed. Preserve literal-vs-expression metadata from binding/planning instead of inferring it at vector execution, and add constant-expression/nested-function/subquery regressions.
Primary references:
- MySQL 8.0.42
sql/item_strfunc.cc,Parse_error_anonymizerandItem_func_statement_digest_text - MySQL 8.0.42
mysql-test/include/func_digest_errors.inc - MySQL generated-column negative test for
statement_digest_text
The 187-case output differential does not exercise these type, planner-property, and expression-origin contracts, so green normalization cases do not close them.
aptend
left a comment
There was a problem hiding this comment.
Deep review of exact head 159121e8370fd9ae11c022a650d8729dd41d04f1, including the full diff, planner integration, parser behavior, and an independent differential run against MySQL 8.0.42. The existing focused unit and race tests pass, but targeted counterexamples expose four blocking compatibility/correctness gaps: generated-column/constant-fold semantics, error-detail disclosure after folding, missing canonical token aliases, and ANSI_QUOTES user-variable handling. I reproduced the generated-column acceptance with a temporary planner test and reproduced the output cases against MySQL 8.0.42; the temporary test and database container were removed afterward.
| } | ||
| overloads := make([]overload, 0, len(stringTypes)) | ||
| for i, typ := range stringTypes { | ||
| overloads = append(overloads, overload{ |
There was a problem hiding this comment.
[P1] Register this function as non-deterministic/runtime-dependent. StatementDigestText reads session sql_mode and max_digest_length, but these overloads currently report both CannotFold() == false and IsRealTimeRelated() == false. On this exact head, a temporary planner regression for CREATE TABLE t (s TEXT, g TEXT GENERATED ALWAYS AS (statement_digest_text(s)) STORED) failed because buildGeneratedExpr returned no error; MySQL 8.0.42 rejects the same expression with ER 3763. MatrixOne materializes generated columns, so changing sql_mode or the digest-length setting can persist different g values for identical s, and a literal call can also be frozen at PREPARE time. Set the appropriate function properties and cover generated-column rejection plus PREPARE/EXECUTE across a setting change.
| } | ||
| sqlMode := statementDigestSQLMode(proc) | ||
| maxDigestLength := statementDigestMaxLength(proc) | ||
| discloseParseError := parameters[0].IsConst() && |
There was a problem hiding this comment.
[P1] Vector.IsConst() describes the post-optimization vector shape, not whether the SQL argument was a literal. For example, MySQL 8.0.42 returns the generic ER 3677 for STATEMENT_DIGEST_TEXT(CONCAT('SELECT ', '?')), because an expression is not allowed to disclose parser details. MatrixOne's constant-fold rule first replaces CONCAT(...) with a constant vector; when digest evaluation fails, this condition then selects ER 3676 and exposes the underlying parser message. Preserve literal-vs-expression origin metadata through planning/execution and add folded-expression and nested-function regressions.
| return "FIELDS" | ||
| case DISTINCT: | ||
| return "DISTINCTROW" | ||
| case CURRENT_TIMESTAMP, LOCALTIME, LOCALTIMESTAMP: |
There was a problem hiding this comment.
[P1] The canonical alias table is incomplete, so valid statements produce a digest text different from MySQL. For SELECT CURRENT_DATE, CURRENT_TIME, SESSION_USER(), USER(), STD(a), VARIANCE(a) FROM t, MySQL 8.0.42 emits CURDATE, CURTIME, SYSTEM_USER, SYSTEM_USER, STDDEV_POP, and VAR_POP; this implementation leaves the original names (and treats several as quoted identifiers). Since STATEMENT_DIGEST() hashes this normalized text, semantically equivalent spellings split into different digest groups and MatrixOne cannot match MySQL monitoring output. Add the MySQL canonical mappings and differential cases for these aliases.
| } | ||
| if typ == '@' && scanner.Pos < len(sql) { | ||
| quote := sql[scanner.Pos] | ||
| quotedUserVar := strings.TrimSpace(rawSource) == "@" && (quote == '\'' || quote == '"') |
There was a problem hiding this comment.
[P1] This treats a double quote after @ as a string delimiter even when ANSI_QUOTES makes it an identifier delimiter. With sql_mode=ANSI_QUOTES, STATEMENT_DIGEST_TEXT('SELECT @"odd name", "col" FROM t') replaces the user variable with @? here, while MySQL 8.0.42 preserves it as a quoted identifier (@ followed by odd name in backticks). Distinct quoted user variables are therefore collapsed into the same digest and the advertised MySQL-compatible text is wrong. Make this branch mode-aware and add the ANSI_QUOTES counterexample.
|
请求一位独立 maintainer/reviewer 审阅设计文档 v6 与当前 head |
XuPeng-SH
left a comment
There was a problem hiding this comment.
GPT-6 medium deep review at exact head 4bb0db4.\n\nP1 — Required independent design approval remains missing. docs/design/statement_digest_text.md:533 identifies revision v9 as proposed and leaves the independent reviewer and reviewed commit pending; the companion RFC also leaves approval pending. This feature adds public SQL functions, diagnostic-disclosure rules, statement-setting transport, and a MORPC capability boundary, so the mandatory design-first gate blocks implementation approval.\n\nPlease record independent approval of the exact design revision, reviewed commit, and approval link. Existing implementation approvals do not approve the consolidated v9 design.\n\nExact-head CI reports successful Ubuntu UT, shared build, SCA, coverage, and multi-CN BVT jobs; upgrade checks are skipped. This review is design-gated and did not proceed to full implementation closure.
What type of PR is this?
Which issue(s) this PR fixes:
issue #23025
What this PR does / why we need it:
Summary
Previously reported validation
The inherited summary does not identify its tested commit. Retain it as historical evidence, rather than a PASS for the current remote head
1a9ade8f4d114f7982dd8cd11efd1a2c36e89e92. Canonical regression files aretest/distributed/cases/function/func_statement_digest_text.sqland.result; current-head execution and review closure remain to be established.Known environment limitations are documented in the task report: native make build requires unavailable cmake; lint target/tools and Java-based mo-tester are unavailable.
QA Decision
QA required: yes — public digest normalization and diagnostic disclosure depend on SQL mode, argument provenance and execution-setting transport. Verify the MySQL oracle matrix, charset/binary input, delimiters, truncation, prepared reuse and distributed settings on the delivered revision. The inherited summary above has no tested-SHA binding and cannot establish current-head acceptance.