-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
cli: add support for multiple results to SQL statements #4081
cli: add support for multiple results to SQL statements #4081
Conversation
This PR depends on upstream changes to The interface to retrieve all of the results to a multiple statement query is to execute the query |
879ce4b
to
a74748b
Compare
See lib/pq#425 for |
a74748b
to
99462b4
Compare
9b5da57
to
53507cd
Compare
This is ready for a look. |
53507cd
to
094f7de
Compare
@@ -20,7 +20,8 @@ github.com/cockroachdb/c-lz4 c40aaae2fc50293eb8750b34632bc3efe813e23f | |||
github.com/cockroachdb/c-protobuf 4feb192131ea08dfbd7253a00868ad69cbb61b81 | |||
github.com/cockroachdb/c-rocksdb b7fb7bddcb55be35eacdf67e9e2c931083ce02c4 | |||
github.com/cockroachdb/c-snappy 5c6d0932e0adaffce4bfca7bdf2ac37f79952ccf | |||
github.com/cockroachdb/stress 574c7f17016a4db745b88f6643700995110bdd07 | |||
github.com/cockroachdb/pq 77bd85500f4521560720328957bae47a78a90ed1 | |||
github.com/cockroachdb/stress 574c7f17016a4db745b88f6643700995110bdd07 |
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.
is this whitespace? weird
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.
Appears to be just some sort of weird error in the diff computation. I don't think there are any whitespace differences. And the file was generated via glock save
.
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.
There's a space at the end of the line in the "before" version.
not sure this is worth it, but code LGTM |
I think supporting multiple results is worth the effort. An alternative to the |
What if we introduced a new interface that extends
This might be more palatable upstream than the The needs of our SQL shell are sufficiently different from a normal application that it might make sense for it to use a lower-level API than Or another crazy idea: we could support a special query on the server |
The pgwire protocol doesn't tell you how many result sets there are upfront. I'm not seeing how I would implement the If we don't mind avoiding the |
094f7de
to
199d105
Compare
Thoughts on how to proceed? The approach taken here is very contained, and while not a particularly pretty interface, it isn't fragile either since we limit the number of DB connections from the cli to 1. |
@@ -16,7 +16,7 @@ | |||
|
|||
/* | |||
Package client and its KV API has been deprecated for external usage. Please use | |||
a postgres-compatible SQL driver (e.g. github.com/lib/pq). For more details, see | |||
a postgres-compatible SQL driver (e.g. github.com/cockroachdb/pq). For more details, see |
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.
I think this should continue to recommend lib/pq
instead of our fork; most clients would be better off sticking with the standard version instead of this modified version given its limitations. Use of cockroachdb/pq
should be limited to the cli
package.
What's the impetus for supporting multiple queries in the CLI? We support them on the server side so it will work for (non-go) programmatic clients. I can see that it's a good thing to support in the abstract, but I was unaware until now that this was supported in other CLIs and the cost seems high relative to the benefit. If we can do this with a |
The impetus for supporting multiple queries in the CLI is that we can't easily prohibit the user from entering them and once such a query is executed it is surprising to not get back all of the results. We can't support multiple queries without a change to Maintaining a fork of |
But we also can't prevent people from entering two update statements (which should return two counts of affected rows to satisfy #3993) or a query and an update. The We'll need to either use a lower-level interface that can give us either a result set or a row count without us knowing in advance which to expect (can |
Yes, we'd need to do something additional to handle #3993. It would require some straightforward changes to |
I'd be in favor of moving to direct usage of |
Cc @cuongdo. |
What's the status of this? Reviewed 9 of 14 files at r1, 5 of 5 files at r2. Comments from the review on Reviewable.io |
On hold for now. @cuongdo or I need to pick it up again. Maybe next week. Review status: all files reviewed at latest revision, 2 unresolved discussions, some commit checks failed. Comments from the review on Reviewable.io |
Will take a look next week. On Thu, Feb 18, 2016 at 8:20 AM Peter Mattis notifications@github.com
|
Manually create connections using lib/pq instead of going through the sql package. This ensures we have a single connection to the database and paves the way for exposing more functionality in lib/pq to our sql shell. The downside is the loss of some of the functionality in the standard sql package. See cockroachdb#4081.
Manually create connections using lib/pq instead of going through the sql package. This ensures we have a single connection to the database and paves the way for exposing more functionality in lib/pq to our sql shell. The downside is the loss of some of the functionality in the standard sql package. See cockroachdb#4081.
Manually create connections using lib/pq instead of going through the sql package. This ensures we have a single connection to the database and paves the way for exposing more functionality in lib/pq to our sql shell. The downside is the loss of some of the functionality in the standard sql package. See cockroachdb#4081.
Manually create connections using lib/pq instead of going through the sql package. This ensures we have a single connection to the database and paves the way for exposing more functionality in lib/pq to our sql shell. The downside is the loss of some of the functionality in the standard sql package. See cockroachdb#4081.
183dd81
to
776f5d4
Compare
This is ready for another look. I'm planning to address #3993 in a follow-on PR. |
LGTM Review status: 1 of 14 files reviewed at latest revision, 4 unresolved discussions. cli/sql_util.go, line 35 [r3] (raw file): sql/pgwire_test.go, line 37 [r3] (raw file): Comments from the review on Reviewable.io |
Review status: 1 of 14 files reviewed at latest revision, 3 unresolved discussions. cli/sql_util.go, line 35 [r3] (raw file): sql/pgwire_test.go, line 37 [r3] (raw file): Comments from the review on Reviewable.io |
Review status: 1 of 14 files reviewed at latest revision, 3 unresolved discussions. cli/sql_util.go, line 35 [r3] (raw file): sql/pgwire_test.go, line 37 [r3] (raw file): Should Comments from the review on Reviewable.io |
Review status: 1 of 16 files reviewed at latest revision, 3 unresolved discussions, some commit checks failed. cli/sql_util.go, line 35 [r3] (raw file): sql/pgwire_test.go, line 37 [r3] (raw file): Comments from the review on Reviewable.io |
93799ad
to
da82fc9
Compare
Review status: 1 of 15 files reviewed at latest revision, 3 unresolved discussions. cli/sql_util.go, line 35 [r3] (raw file): client/doc.go, line 19 [r2] (raw file): Comments from the review on Reviewable.io |
ebdb6ac
to
11aa929
Compare
Review status: 1 of 15 files reviewed at latest revision, 4 unresolved discussions. cli/cli_test.go, line 509 [r5] (raw file): Comments from the review on Reviewable.io |
Use the new functionality in lib/pq to select the next set of results when multiple statements were executed. Fixes cockroachdb#4016.
11aa929
to
65e1ba6
Compare
I think this PR has already received sufficient LGTMs, but it underwent a few minor tweaks. I'll be merging in a little bit, but am happy to address any issues in a follow-on PR. |
…results cli: add support for multiple results to SQL statements
Use the new functionality in lib/pq to select the next set of results
when multiple statements were executed.
Switch to using the "postgres" SQL driver in the cli tests.
Remove runPrettyQueryWithFormat. It was only used in tests.