-
Notifications
You must be signed in to change notification settings - Fork 2.4k
mysql/json: read numbers the way MySQL does #20722
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
Merged
Merged
Changes from 14 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
5a1ed5b
mysql/json: reject numbers a double cannot hold, as MySQL does
arthurschreiber f4aa5ec
mysql/json: cover the exponent spellings called out on the issue
arthurschreiber e68bd7e
mysql/json: bound the exponent as written, not just as converted
arthurschreiber fa351ff
mysql/json: read numbers by JSON's grammar, not Go's
arthurschreiber fe181de
mysql/json: stop reading nan as a number
arthurschreiber b450fe6
mysql/json: decide what a double can hold the way MySQL decides it
arthurschreiber 139a987
mysql/json: keep each significand digit to two roundings
arthurschreiber 16c9c69
mysql/json: count only an exponent that moves the point right
arthurschreiber 0c64ad5
mysql/json: say what readFloat's exponent is, and what it is not
arthurschreiber 879d156
mysql/json: read the power-of-ten table with strconv
arthurschreiber 78c4bfa
mysql/json: say which reader the number check follows
arthurschreiber ed1fe05
mysql/json: record RapidJSON's licence alongside the number check
arthurschreiber 2fe54bb
mysql/json: benchmark the paths the number reader takes
arthurschreiber e3010e5
mysql/json: count the digits that can reach past a double, not the st…
arthurschreiber 97552c6
mysql/json: cover a negative exponent written past what an int holds
arthurschreiber a3fb097
mysql/json: abbreviate the number an error reports on
arthurschreiber 94366cc
mysql/json: abbreviate the document every rejection names
arthurschreiber 97ea69c
mysql/json: benchmark documents that reach the magnitude check
arthurschreiber 0886b6f
mysql/json: pin the tightened grammar on the SQL-marshal path
arthurschreiber File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| Tencent is pleased to support the open source community by making RapidJSON | ||
| available. | ||
|
|
||
| Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. | ||
|
|
||
| Parts of parser.go are derived from RapidJSON 1.1.0, the JSON parser MySQL | ||
| parses documents with, so that Vitess accepts exactly the documents MySQL does: | ||
| mysqlNumberFits follows GenericReader::ParseNumber in | ||
| include/rapidjson/reader.h, scaleByPow10 and movePoint follow | ||
| StrtodNormalPrecision and FastPath in include/rapidjson/internal/strtod.h, and | ||
| the pow10 table holds the same values as Pow10 in | ||
| include/rapidjson/internal/pow10.h. No RapidJSON source is included here; the Go | ||
| code was written to reproduce what those functions decide. | ||
|
|
||
| RapidJSON is licensed under the MIT License: | ||
|
|
||
| The MIT License (MIT) | ||
|
|
||
| Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This call discards the exponent returned by
readFloat, soAppendMarshalSQLandMarshalSQLValuestill accept numbers that the updated parser rejects, such as1e309or1.7976931348623159e308. They emit expressions such asCAST(1e309 as JSON)orJSON_ARRAY(1e309), which MySQL rejects when vreplication executes them; apply the samemayExceedFloat64/mysqlNumberFitsvalidation here so callers fail before constructing an unusable replication statement.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is tracked in #20727 and is not really a reachable issue.