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: Internal Error when using invalid range condition #95604

Closed
SteveLeungYL opened this issue Jan 20, 2023 · 1 comment · Fixed by #96113
Closed

sql: Internal Error when using invalid range condition #95604

SteveLeungYL opened this issue Jan 20, 2023 · 1 comment · Fixed by #96113
Assignees
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-community Originated from the community T-sql-queries SQL Queries Team

Comments

@SteveLeungYL
Copy link

SteveLeungYL commented Jan 20, 2023

Describe the problem

The latest version of the CockroachDB (b861696) shows Internal Error when executing the following query:

 SELECT NULL FROM ROWS FROM (SUM(*)) AS OF SYSTEM TIME ('' BETWEEN '' AND '');

To Reproduce

Here is the detail steps to reproduce the bug.

  1. In operating system Ubuntu 20.04, download the CockroachDB source code from the github source.
  2. Use the latest version of the CockroachDB code (tested version: b861696)
  3. Directly make install in the root repository folder.
  4. Run ./cockroach demo, and then paste the PoC query to the cockroach cli environment.
  5. Observe the Internal Error and log the stack information.

Expected behavior

The SELECT statement's result should be a semantic error.

Additional data / screenshots

Here is the outputted stack trace:

[email protected]:26257/movr> SELECT NULL FROM ROWS FROM (SUM(*)) AS OF SYSTEM TIME ('' BETWEEN '' AND '');
ERROR: internal error: unhandled type *tree.RangeCond
SQLSTATE: XX000
DETAIL: stack trace:
github.com/cockroachdb/cockroach/pkg/sql/sem/eval/expr.go:611: EvalRangeCond()
github.com/cockroachdb/cockroach/pkg/sql/sem/tree/eval_expr_generated.go:341: Eval()
github.com/cockroachdb/cockroach/pkg/sql/sem/eval/expr.go:26: Expr()
github.com/cockroachdb/cockroach/pkg/sql/sem/asof/as_of.go:196: Eval()
github.com/cockroachdb/cockroach/pkg/sql/exec_util.go:1898: EvalAsOfTimestamp()
github.com/cockroachdb/cockroach/pkg/sql/exec_util.go:1952: isAsOf()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:806: handleAOST()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:658: execStmtInOpenState()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:130: func1()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:2527: execWithProfiling()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:129: execStmt()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1959: func1()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1964: execCmd()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1882: run()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:836: ServeConn()
github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go:731: func1()
runtime/asm_arm64.s:1165: goexit()

HINT: You have encountered an unexpected error.

Environment:

  • CockroachDB version: v23.1.0-alpha
  • Server OS: Ubuntu 20.04 LTS
  • Client app: CockroachDB demo command. (./cockroach demo)
  • Detailed CockroachDB version output:
cockroach version details:
Build Tag:        v23.1.0-alpha.1-1132-gb861696207
Build Time:       2023/01/20 18:12:24
Distribution:     CCL
Platform:         linux arm64 (aarch64-linux-gnu)
Go Version:       go1.19
C Compiler:       gcc 9.4.0
Build Commit ID:  b861696207d6640f187add625ac6e4bb7b9575d4
Build Type:       development

Additional context

The bug can be reproduced by CockroachDB release version: CockroachDB v23.1 Testing Releases , v22.2.2 and v22.1. We haven't tested versions before v22.1.

Jira issue: CRDB-23610

@SteveLeungYL SteveLeungYL added the C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. label Jan 20, 2023
@blathers-crl
Copy link

blathers-crl bot commented Jan 20, 2023

Hello, I am Blathers. I am here to help you get the issue triaged.

Hoot - a bug! Though bugs are the bane of my existence, rest assured the wretched thing will get the best of care here.

I was unable to automatically find someone to ping.

If we have not gotten back to your issue within a few business days, you can try the following:

  • Join our community slack channel and ask on #cockroachdb.
  • Try find someone from here if you know they worked closely on the area and CC them.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@blathers-crl blathers-crl bot added O-community Originated from the community X-blathers-untriaged blathers was unable to find an owner labels Jan 20, 2023
@yuzefovich yuzefovich removed the X-blathers-untriaged blathers was unable to find an owner label Jan 20, 2023
@blathers-crl blathers-crl bot added the T-sql-queries SQL Queries Team label Jan 20, 2023
@msirek msirek self-assigned this Jan 27, 2023
msirek pushed a commit to msirek/cockroach that referenced this issue Jan 27, 2023
Fixes cockroachdb#95604

This adds missing normalization of AS OF SYSTEM TIME expressions.
Without normalization, some expressions such as range conditions
may result in an internal error.

Release note (bug fix): This patch fixes internal errors which may
occur on some AS OF SYSTEM TIME expressions.
craig bot pushed a commit that referenced this issue Jan 27, 2023
96105: sql: add logic test for function dropped by DROP OWNED BY r=chengxiong-ruan a=chengxiong-ruan

With DROP FUNCTION supported in declarative schema changer, DROP OWNED BY can now drop functions.

Epic: None

Release note: None

96113: asof: fix internal error on AOST expression requiring normalization r=ajwerner a=msirek

Fixes #95604

This adds missing normalization of AS OF SYSTEM TIME expressions. Without normalization, some expressions such as range conditions may result in an internal error.

Release note (bug fix): This patch fixes internal errors which may occur on some AS OF SYSTEM TIME expressions.

96121: workflow: Cluster UI autopublishing configuration fixes r=nathanstilwell a=nathanstilwell

Using action `actions/setup-node@v3` we need to provide specific configuration for the internally generated `.npmrc`. This commit sets `registry-url` and `always-auth` to be explicit and changes the environment variable `NPM_TOKEN` to `NODE_AUTH_TOKEN` since this is what the action uses internally to set the auth token. I'm also switching back to using `npm` to publish as the setup-node action uses Yarn2 internally which can not read npm configuration and must have its own `.yarnrc.yml` generated.

A couple more improvements were made (since I was here),
- Add explicit output when a package should be published
- Check for the existence of a git tag before creating one (to prevent duplicates)
- Adds `--ignore-scripts` option to publish command to prevent duplicate builds.

Test publish - [Publish Cluster UI Pre-release #73](https://github.com/cockroachdb/cockroach/actions/runs/4027917363) (published [23.1.0-publishtest.0](https://www.npmjs.com/package/`@cockroachlabs/cluster-ui/v/23.1.0-publishtest.0)` and created [tag](https://github.com/cockroachdb/cockroach/releases/tag/%40cockroachlabs%2Fcluster-ui%4023.1.0-publishtest.0)) 

Epic: none

Release note: None

Co-authored-by: Chengxiong Ruan <[email protected]>
Co-authored-by: Mark Sirek <[email protected]>
Co-authored-by: Nathan Stilwell <[email protected]>
@craig craig bot closed this as completed in 0d64780 Jan 27, 2023
@mgartner mgartner moved this to Done in SQL Queries Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-community Originated from the community T-sql-queries SQL Queries Team
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants