Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: Fix possibly invalid vector default values #56286

Merged
merged 2 commits into from
Sep 26, 2024

Conversation

breezewish
Copy link
Member

@breezewish breezewish commented Sep 25, 2024

What problem does this PR solve?

Issue Number: ref #54245

Problem Summary:

In non-strict mode, 0-sized vector may be wrongly inserted into a Non-Zero-Sized vector column:

set @session.sql_mode='';
create table x(e vector(3) not null comment 'hnsw(distance=l2)');
insert into x values();

What changed and how does it work?

Forbid such values in any SQL modes.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-tests-checked release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 25, 2024
Comment on lines 129 to 130
tk.MustGetErrMsg("create table t(embedding VECTOR DEFAULT '[1,2,3]')", `VECTOR column 'embedding' can't have a default value`)
tk.MustExec("create table t(embedding VECTOR DEFAULT (VEC_FROM_TEXT('[1,2,3]')))")
Copy link
Contributor

@JaySon-Huang JaySon-Huang Sep 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the error message "can't have a default value" is incorrect.

the default value of VECTOR column 'embedding' should be defined as (VEC_FROM_TEXT(...))?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch.. It is blindly inherited from BLOB/TEXT/JSON column '%-.192s' can't have a default value. We could provide a more friendly description for the VECTOR.

Copy link

codecov bot commented Sep 25, 2024

Codecov Report

Attention: Patch coverage is 71.42857% with 6 lines in your changes missing coverage. Please review.

Project coverage is 76.2653%. Comparing base (a5e07a2) to head (d83bd88).
Report is 43 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #56286        +/-   ##
================================================
+ Coverage   73.4625%   76.2653%   +2.8027%     
================================================
  Files          1605       1639        +34     
  Lines        445096     456881     +11785     
================================================
+ Hits         326979     348442     +21463     
+ Misses        98081      86742     -11339     
- Partials      20036      21697      +1661     
Flag Coverage Δ
integration 52.3773% <4.7619%> (?)
unit 72.5513% <71.4285%> (+0.0084%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 52.9478% <ø> (ø)
parser ∅ <ø> (∅)
br 64.8211% <ø> (+18.8069%) ⬆️

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Sep 25, 2024
@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Sep 25, 2024
Copy link

ti-chi-bot bot commented Sep 25, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-09-25 06:58:30.860975714 +0000 UTC m=+1635580.601399653: ☑️ agreed by hawkingrei.
  • 2024-09-25 07:52:10.398406727 +0000 UTC m=+1638800.138830662: ☑️ agreed by XuHuaiyu.

@breezewish
Copy link
Member Author

/retest-required

Copy link
Contributor

@JaySon-Huang JaySon-Huang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link

ti-chi-bot bot commented Sep 25, 2024

@JaySon-Huang: adding LGTM is restricted to approvers and reviewers in OWNERS files.

In response to this:

lgtm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link

ti-chi-bot bot commented Sep 26, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hawkingrei, JaySon-Huang, wjhuang2016, XuHuaiyu

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added the approved label Sep 26, 2024
@ti-chi-bot ti-chi-bot bot merged commit 5697675 into master Sep 26, 2024
25 checks passed
@ti-chi-bot ti-chi-bot bot deleted the wenxuan/vector-default-value branch September 26, 2024 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants