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

sql: weird error message for negative date #35255

Closed
jordanlewis opened this issue Feb 28, 2019 · 1 comment
Closed

sql: weird error message for negative date #35255

jordanlewis opened this issue Feb 28, 2019 · 1 comment
Assignees
Labels
C-cleanup Tech debt, refactors, loose ends, etc. Solution not expected to significantly change behavior. O-sqlsmith

Comments

@jordanlewis
Copy link
Member

root@127.0.0.1:54927/defaultdb> select '-56325279622-12-26'::date;
pq: unexpected separator '45' for field Hour as type date

This is admittedly nonsensical, but the error message could use some work. I don't understand where the 45 comes from, for instance.

Here's what Postgres says:

jordan=# select '-56325279622-12-26'::date;
ERROR:  time zone displacement out of range: "-56325279622-12-26"

Here's the stack trace of where the error came from in case it's useful:

github.com/cockroachdb/cockroach/pkg/util/timeutil/pgdate.badFieldPrefixError(0x4, 0xc00000002d, 0x400529d, 0x74ad420)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/util/timeutil/pgdate/parsing.go:150 +0x39
github.com/cockroachdb/cockroach/pkg/util/timeutil/pgdate.(*fieldExtract).SetChunk(0xc001656c60, 0x4, 0xc00000002d, 0x1a, 0x2, 0x3b0000c001970000, 0x5)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/util/timeutil/pgdate/field_extract.go:729 +0x93
github.com/cockroachdb/cockroach/pkg/util/timeutil/pgdate.(*fieldExtract).interpretNumber(0xc001656c60, 0x2d, 0x1a, 0x2, 0x0, 0x0, 0x0)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/util/timeutil/pgdate/field_extract.go:552 +0xcdc
github.com/cockroachdb/cockroach/pkg/util/timeutil/pgdate.(*fieldExtract).interpretNumber(0xc001656c60, 0x2d, 0x1a, 0x2, 0x0, 0x0, 0x0)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/util/timeutil/pgdate/field_extract.go:519 +0xf4d
github.com/cockroachdb/cockroach/pkg/util/timeutil/pgdate.(*fieldExtract).Extract(0xc001656c60, 0xc00016ac00, 0x12, 0x5c772f2c, 0xc001864048)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/util/timeutil/pgdate/field_extract.go:235 +0x390
github.com/cockroachdb/cockroach/pkg/util/timeutil/pgdate.ParseDate(0x33d1a000, 0xed409262c, 0x0, 0x0, 0xc00016ac00, 0x12, 0x6, 0xc00006b488, 0xc00006b400, 0x7447b1818982b3f2, ...)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/util/timeutil/pgdate/parsing.go:100 +0x111
github.com/cockroachdb/cockroach/pkg/sql/sem/tree.ParseDDate(0x743c960, 0xc001592470, 0xc00016ac00, 0x12, 0x4b26aeb, 0xc0018641c0, 0x0)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/sem/tree/datum.go:1692 +0x7b
github.com/cockroachdb/cockroach/pkg/sql/sem/tree.parseStringAs(0x747e9c0, 0x92cf140, 0xc00016ac00, 0x12, 0x743c960, 0xc001592470, 0x0, 0x6, 0xc00006b488, 0xc00006b400)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/sem/tree/parse_string.go:76 +0x7c8
github.com/cockroachdb/cockroach/pkg/sql/sem/tree.(*StrVal).ResolveAsType(0xc00171c040, 0xc001592470, 0x747e9c0, 0x92cf140, 0xc001864360, 0xc00171c040, 0xc001864310, 0x4b10c3f)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/sem/tree/constant.go:499 +0x393
github.com/cockroachdb/cockroach/pkg/sql/sem/tree.typeCheckConstant(0x7483fa0, 0xc00171c040, 0xc001592470, 0x747e9c0, 0x92cf140, 0x1, 0xf, 0x6, 0x928ef00)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/sem/tree/constant.go:69 +0x312
github.com/cockroachdb/cockroach/pkg/sql/sem/tree.(*StrVal).TypeCheck(0xc00171c040, 0xc001592470, 0x747e9c0, 0x92cf140, 0xc00171c001, 0xc00171c001, 0xc00171c080, 0x6b081a0)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/sem/tree/type_check.go:1186 +0x59
github.com/cockroachdb/cockroach/pkg/sql/sem/tree.(*CastExpr).TypeCheck(0xc00171c080, 0xc001592470, 0x747e840, 0x92cf140, 0x0, 0x0, 0xc00171c080, 0xc00003a000)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/sem/tree/type_check.go:438 +0x174
github.com/cockroachdb/cockroach/pkg/sql/sem/tree.TypeCheck(0x7465ba0, 0xc00171c080, 0xc001592470, 0x747e840, 0x92cf140, 0xc0018644d0, 0x400d0cd, 0x69d5fc0, 0x6b081a0)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/sem/tree/type_check.go:260 +0xaa
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*scope).resolveType(0xc00160b0f0, 0x7465ba0, 0xc00171c080, 0x747e840, 0x92cf140, 0x0, 0xc00197e970)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/scope.go:291 +0x86
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).analyzeSelectList(0xc0015a4d20, 0xc0003b80a0, 0x1, 0x1, 0x0, 0x0, 0x0, 0xc00160b0f0, 0xc00160b1e0)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/project.go:146 +0x520
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).analyzeProjectionList(0xc0015a4d20, 0xc0003b80a0, 0x1, 0x1, 0x0, 0x0, 0x0, 0xc00160b0f0, 0xc00160b1e0)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/project.go:80 +0x18a
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).buildSelectClause(0xc0015a4d20, 0xc0017c9680, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc00160b000, 0x203000)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/select.go:635 +0x197
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).buildSelect(0xc0015a4d20, 0xc00171c0c0, 0x0, 0x0, 0x0, 0xc00160b000, 0x0)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/select.go:581 +0x201
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).buildStmt(0xc0015a4d20, 0x74671e0, 0xc00171c0c0, 0xc00160b000, 0x4)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/builder.go:211 +0x10e
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).Build(0xc0015a4d20, 0x0, 0x0)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/builder.go:156 +0x111
github.com/cockroachdb/cockroach/pkg/sql.(*optPlanningCtx).buildExecMemo(0xc0007e5500, 0x74616e0, 0xc00169b470, 0xc00171c0c0, 0x74616e0, 0xc00169b470, 0x4060d00)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/plan_opt.go:399 +0x188
github.com/cockroachdb/cockroach/pkg/sql.(*planner).makeOptimizerPlan(0xc001592460, 0x74616e0, 0xc00169b470, 0x6ccc2bb, 0x19, 0xc541917ca6f0f, 0x33d10f78)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/plan_opt.go:147 +0xc8
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).makeExecPlan(0xc001592000, 0x74616e0, 0xc00169b470, 0xc001592460, 0x6, 0x400edbf)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:939 +0x11b
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).dispatchToExecutionEngine(0xc001592000, 0x74616e0, 0xc00169b470, 0xc001592460, 0xea1a200, 0xc001656bb0, 0x0, 0x0)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:834 +0x148
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execStmtInOpenState(0xc001592000, 0x74616e0, 0xc00169b470, 0x74671e0, 0xc00171c0c0, 0xc00160c0c3, 0x21, 0x0, 0x0, 0x0, ...)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:447 +0xd8c
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execStmt(0xc001592000, 0x74616e0, 0xc00169b470, 0x74671e0, 0xc00171c0c0, 0xc00160c0c3, 0x21, 0x0, 0x0, 0x0, ...)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:103 +0x610
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).run(0xc001592000, 0x7461620, 0xc000901e80, 0xc000246c38, 0x5400, 0x15000, 0xc000246cd0, 0xc0005123a0, 0x0, 0x0)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1183 +0x21e5
github.com/cockroachdb/cockroach/pkg/sql.(*Server).ServeConn(0xc0006ff860, 0x7461620, 0xc000901e80, 0xc001592000, 0x5400, 0x15000, 0xc000246cd0, 0xc0005123a0, 0x0, 0x0)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:429 +0xce
github.com/cockroachdb/cockroach/pkg/sql/pgwire.(*conn).serveImpl.func4(0xc0006ff860, 0xc001506000, 0xc0003c1f84, 0xc0005123a0, 0x7461620, 0xc000901e80, 0xc001592000, 0x5400, 0x15000, 0xc000246cd0, ...)
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go:331 +0xcf
created by github.com/cockroachdb/cockroach/pkg/sql/pgwire.(*conn).serveImpl
        /Users/jordan/repo/src/github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go:314 +0x1040

@bobvawter would you mind taking a quick look at this since I know you worked a bunch of date parsing? I think it would be nice if we could follow Postgres's rule for generating that "out of range" error, but if that's a lot of work maybe it doesn't really matter.

@jordanlewis jordanlewis added C-cleanup Tech debt, refactors, loose ends, etc. Solution not expected to significantly change behavior. O-sqlsmith labels Feb 28, 2019
craig bot pushed a commit that referenced this issue 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 craig bot closed this as completed in #35602 Mar 11, 2019
@jordanlewis
Copy link
Member Author

Thanks @bobvawter!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Tech debt, refactors, loose ends, etc. Solution not expected to significantly change behavior. O-sqlsmith
Projects
None yet
Development

No branches or pull requests

2 participants