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

pgdate: Improve handling of negative years #35602

Merged
merged 1 commit into from
Mar 11, 2019
Merged

pgdate: Improve handling of negative years #35602

merged 1 commit into from
Mar 11, 2019

Conversation

bobvawter
Copy link
Member

The current parsing code doesn't handle negative year values and returns an
unhelpful error message. This change allows negative years to be specified, so
that negative-year datums can at least be round-tripped through the parser.

Supports #28099
Fixes #35255

Release note: None

@bobvawter bobvawter requested review from jordanlewis, knz and a team March 11, 2019 13:37
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

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

LGTM with nits

@@ -1193,3 +1193,32 @@ query T
SELECT date_trunc('month', "date") AS date_trunc_month_created_at FROM "topics";
----
2017-12-01 00:00:00 +0000 UTC


# Test negative years, ensuring that we don't trigger any of the
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe add subtest regression_35255 here

@@ -320,7 +320,7 @@ func (fe *fieldExtract) interpretNumber(chunk numberChunk, textMonth bool) error
case fe.Wants(fieldYear) && fe.Wants(fieldMonth) && fe.Wants(fieldDay):
// Example: All date formats, we're starting from scratch.
switch {
case chunk.magnitude >= 6:
case chunk.magnitude >= 6 && chunk.separator != '-':
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious, why do you exclude the sign here?

Copy link
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

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

LGTM with nits

The current parsing code doesn't handle negative year values and returns an
unhelpful error message. This change allows negative years to be specified, so
that negative-year datums can at least be round-tripped through the parser.

Supports #28099
Fixes #35255

Release note: None
Copy link
Member Author

@bobvawter bobvawter left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @jordanlewis and @knz)


pkg/sql/logictest/testdata/logic_test/datetime, line 1198 at r1 (raw file):

Previously, knz (kena) wrote…

maybe add subtest regression_35255 here

Done.


pkg/util/timeutil/pgdate/field_extract.go, line 323 at r1 (raw file):

Previously, knz (kena) wrote…

Just curious, why do you exclude the sign here?

Updated with a comment explaining that we don't want large-magnitude, negative years to be incorrectly interpreted.

@bobvawter
Copy link
Member Author

bors r+

craig bot pushed a commit that referenced this pull request Mar 11, 2019
35442: roachtest: add nightly multi-AZ tpccbench test r=nvanbenschoten a=nvanbenschoten

This test deviates from similar roachtests in a few useful ways:
- it tests across three AZs in the same region
- it tests a 6-node cluster
- it loads 5k tpcc warehouses
- it runs on only about half of them (testing the impact of cold data)

I've run this a number of times over the past few days and settled upon
2500 warehouses as a good estimate.

Release note: None

35602: pgdate: Improve handling of negative years r=bobvawter a=bobvawter

The current parsing code doesn't handle negative year values and returns an
unhelpful error message. This change allows negative years to be specified, so
that negative-year datums can at least be round-tripped through the parser.

Supports #28099
Fixes #35255

Release note: None

Co-authored-by: Nathan VanBenschoten <nvanbenschoten@gmail.com>
Co-authored-by: Bob Vawter <bob@cockroachlabs.com>
@craig
Copy link
Contributor

craig bot commented Mar 11, 2019

Build succeeded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants