Describe the bug
query and real_query return a !Result type correctly: an error if there is a database error or a Result object when there are no errors.
The Result object can contain no data, when the statement return no result sets, or an empty set:
mysql.Result{
result: &nil
}
There currently is no way of checking whether the returned object is null or not. Attempting to use methods on the result, such as Result.rows() causes a runtime memory access error.
Expected Behavior
Some options:
- A function such as
Result.is_null() should be available
- A boolean field
Result.is_null should exist
- Existing functions should return empty objects: for example
Result.rows() should return an empty []Row.
Current Behavior
mysql.Result.rows() can cause memory access errors
Reproduction Steps
use real_query to select something, provide a where clause that will not match anything. Then use rows() on the result.
res := mysql.real_query('SELECT column FROM table WHERE id = 69')
runtime_memory_access_error := res.rows()
Possible Solution
No response
Additional Information/Context
No response
V version
Current V version: V 0.4.0 3211a65, timestamp: 2023-08-09 15:05:17 +0300
Environment details (OS name and version, etc.)
V full version: V 0.4.0 ee4150f.3211a65
OS: linux, Linux version 5.14.0-284.25.1.el9_2.x86_64 (mockbuild@pp-el9-x86) (gcc (GCC) 11.3.1 20221121 (Red Hat 11.3.1-4), GNU ld version 2.35.2-37.el9) #1 SMP PREEMPT_DYNAMIC Wed Aug 2 09:19:04 UTC 2023
Processor: 4 cpus, 64bit, little endian, Intel(R) Core(TM) i3-5005U CPU @ 2.00GHz
getwd: /home/coachonko/Documents/projects/vlang/peony
vexe: /home/coachonko/.local/lib64/v/v
vexe mtime: 2023-08-09 19:18:34
vroot: OK, value: /home/coachonko/.local/lib64/v
VMODULES: OK, value: /home/coachonko/.vmodules
VTMP: OK, value: /tmp/v_1000
Git version: git version 2.39.3
Git vroot status: weekly.2023.30-103-g3211a653
.git/config present: true
CC version: cc (GCC) 11.3.1 20221121 (Red Hat 11.3.1-4)
thirdparty/tcc status: thirdparty-linux-amd64 12f392c3
Describe the bug
query and real_query return a
!Resulttype correctly: an error if there is a database error or aResultobject when there are no errors.The
Resultobject can contain no data, when the statement return no result sets, or an empty set:There currently is no way of checking whether the returned object is null or not. Attempting to use methods on the result, such as
Result.rows()causes a runtime memory access error.Expected Behavior
Some options:
Result.is_null()should be availableResult.is_nullshould existResult.rows()should return an empty[]Row.Current Behavior
mysql.Result.rows() can cause memory access errors
Reproduction Steps
use real_query to select something, provide a where clause that will not match anything. Then use rows() on the result.
Possible Solution
No response
Additional Information/Context
No response
V version
Current V version: V 0.4.0 3211a65, timestamp: 2023-08-09 15:05:17 +0300Environment details (OS name and version, etc.)