Skip to content

Conversation

@itsumura-h
Copy link
Contributor

@itsumura-h itsumura-h commented Dec 4, 2019

If we have following users table in mysql and "email" column have null data

id name email
1 John null
echo db.getRow(sql"SELECT * FROM users")

expects

@["1", "John", ""]

However we get an error

/nim/lib/impure/db_mysql.nim(310) getRow
SIGSEGV: Illegal storage access. (Attempt to read from nil?)

add(result[i], row[i]) => add(result[i], $row[i])
@itsumura-h itsumura-h marked this pull request as ready for review December 4, 2019 07:52
@itsumura-h itsumura-h changed the title fix db_mysql getRow() fix db_mysql getRow() when column is null error raised Dec 4, 2019
@Araq
Copy link
Member

Araq commented Dec 4, 2019

This is not good for performance, better fix add(s: string; x: cstring) to deal with x == nil. Around line 3413 in system.nim.

@itsumura-h
Copy link
Contributor Author

@Araq
It may works as expected!

@Araq
Copy link
Member

Araq commented Dec 5, 2019

This commit needs the [backport] tag.

@itsumura-h
Copy link
Contributor Author

itsumura-h commented Dec 5, 2019

@Araq
Is it rignt?

d313055

@Araq Araq merged commit 208b018 into nim-lang:devel Dec 5, 2019
narimiran pushed a commit to narimiran/Nim that referenced this pull request Dec 10, 2019
… [backport]

* fix db_mysql getRow()
* added if y == nil [backport]

(cherry picked from commit 208b018)
This was referenced Jun 24, 2020
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.

2 participants