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

tidb: Fix panic in driverStmt.Query #63

Merged
merged 5 commits into from
Sep 8, 2015
Merged

Conversation

shenli
Copy link
Member

@shenli shenli commented Sep 8, 2015

The prepared statement maybe not query, so the resultset maybe nil.

The prepared statement maybe not query, so the resultset maybe nil.
c.Assert(err, IsNil)
_, err = db.Exec("insert into t values (1), (2), (3)")
c.Assert(err, IsNil)
_, err = db.Query("delete from `t` where `c` = ?", 1)
Copy link
Member

Choose a reason for hiding this comment

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

Query should returns an empty row for delete.

Copy link
Member Author

Choose a reason for hiding this comment

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

PTAL

@shenli
Copy link
Member Author

shenli commented Sep 8, 2015

PTAL

@siddontang
Copy link
Member

should this can fix #57 ?

@@ -379,6 +388,9 @@ func newdriverRows(rs rset.Recordset) *driverRows {
// result is inferred from the length of the slice. If a particular column
// name isn't known, an empty string should be returned for that entry.
func (r *driverRows) Columns() []string {
if r.rs == nil {
return make([]string, 0)
Copy link
Member

Choose a reason for hiding this comment

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

can return nil here?

Copy link
Member

Choose a reason for hiding this comment

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

if return an empty slice, using []string{} is better?

Copy link
Member Author

Choose a reason for hiding this comment

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

I am not sure. I think return empty array is better than nil.

Copy link
Member

Choose a reason for hiding this comment

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

[]string{} +1

Copy link
Member Author

Choose a reason for hiding this comment

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

PTAL

@shenli
Copy link
Member Author

shenli commented Sep 8, 2015

I am not sure. I run go-xorm tidb test with another error. So I can not reach the panic point the same as lunny.
I will find it out later.

@qiuyesuifeng
Copy link
Member

LGTM

shenli added a commit that referenced this pull request Sep 8, 2015
tidb: Fix panic in driverStmt.Query
@shenli shenli merged commit ff96c10 into master Sep 8, 2015
@shenli shenli deleted the shenli/fix-delete-panic branch September 8, 2015 08:14
YuJuncen pushed a commit to YuJuncen/tidb that referenced this pull request Apr 23, 2021
… duration (pingcap#63)

* restore: extend the closeWithRetry() wait duration to 30 seconds

* kv-deliver: properly close the write stream before recyling the client
xhebox pushed a commit to xhebox/tidb that referenced this pull request Sep 28, 2021
xhebox pushed a commit to xhebox/tidb that referenced this pull request Oct 8, 2021
ti-chi-bot pushed a commit that referenced this pull request Oct 9, 2021
* impl Restore of ColunmNameExpr
iosmanthus pushed a commit to iosmanthus/tidb that referenced this pull request Oct 31, 2022
Signed-off-by: disksing <[email protected]>
mittalrishabh pushed a commit to mittalrishabh/tidb that referenced this pull request May 6, 2024
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