cockroachdb / cockroach

CockroachDB — the cloud native, distributed SQL database designed for high availability, effortless scale, and control over data placement.
https://www.cockroachlabs.com
Other
29.99k stars 3.79k forks source link

Explain Analyze broken for DataGrip #107898

Closed j82w closed 1 year ago

j82w commented 1 year ago

With the current master build if you try to run any EXPLAIN ANALYZE statement in DataGrip always fails with [42601] ERROR: EXPLAIN ANALYZE can only be used as a top-level statement. It seems to be caused by the following change: https://github.com/cockroachdb/cockroach/pull/103259.

  1. The error message should return the full query text that was being executed. This way users can see that DataGrip is executing it as a prepared statement, and that is the cause of the failure. The current error message is confusing because the user just executes the EXPLAIN ANALYZE so it is the top-level statement.
  2. This will likely cause customer issues as they will expect this to just work.

slack thread: https://cockroachlabs.slack.com/archives/C0168LW5THS/p1690822395401319

Jira issue: CRDB-30249

mgartner commented 1 year ago

Are you sure that #103259 caused this issue? Are you sure EXPLAIN ANALYZE was working in DataGrip before that PR? According to #98731, executing a prepared EXPLAIN ANALYZE was not working prior to #103259.

michae2 commented 1 year ago

@j82w we believe we were able to PREPARE EXPLAIN ANALYZE before, but not execute it after preparing, so we don't think this worked even before #103259.

j82w commented 1 year ago

@michae2 and @mgartner I'm not sure which commit caused the issue. I know in v22.1 and v23.1.6 explain analyze select * from system.statement_statistics; works in DataGrip. Building and executing the same query on master today fails with [42601] ERROR: EXPLAIN ANALYZE can only be used as a top-level statement

j82w commented 1 year ago

@michae2 and @mgartner I confirmed it's from commit feb9c43eff5cdd16b5e4a50a1ecac3fffaf5a436 which is from PR https://github.com/cockroachdb/cockroach/pull/103259. If I build master it fails, but if I do git revert feb9c43eff5cdd16b5e4a50a1ecac3fffaf5a436 it succeeds.

michae2 commented 1 year ago

Thanks for confirming @j82w. It sounds like our assumption was wrong. We will investigate.

j82w commented 1 year ago

Let me know if you want to pair and/or anything else to help with the investigation.