mirror of
https://github.com/vlang/v.git
synced 2025-08-03 17:57:59 -04:00
pg: hande C calls, move to .c.v files (#19739)
This commit is contained in:
parent
be89cbf26f
commit
24befa0ba6
@ -73,22 +73,6 @@ pub fn (db DB) drop(table string) ! {
|
|||||||
|
|
||||||
// utils
|
// utils
|
||||||
|
|
||||||
fn pg_stmt_worker(db DB, query string, data orm.QueryData, where orm.QueryData) ![]Row {
|
|
||||||
mut param_types := []u32{}
|
|
||||||
mut param_vals := []&char{}
|
|
||||||
mut param_lens := []int{}
|
|
||||||
mut param_formats := []int{}
|
|
||||||
|
|
||||||
pg_stmt_binder(mut param_types, mut param_vals, mut param_lens, mut param_formats,
|
|
||||||
data)
|
|
||||||
pg_stmt_binder(mut param_types, mut param_vals, mut param_lens, mut param_formats,
|
|
||||||
where)
|
|
||||||
|
|
||||||
res := C.PQexecParams(db.conn, &char(query.str), param_vals.len, param_types.data,
|
|
||||||
param_vals.data, param_lens.data, param_formats.data, 0) // here, the last 0 means require text results, 1 - binary results
|
|
||||||
return db.handle_error_or_result(res, 'orm_stmt_worker')
|
|
||||||
}
|
|
||||||
|
|
||||||
fn pg_stmt_binder(mut types []u32, mut vals []&char, mut lens []int, mut formats []int, d orm.QueryData) {
|
fn pg_stmt_binder(mut types []u32, mut vals []&char, mut lens []int, mut formats []int, d orm.QueryData) {
|
||||||
for data in d.data {
|
for data in d.data {
|
||||||
pg_stmt_match(mut types, mut vals, mut lens, mut formats, data)
|
pg_stmt_match(mut types, mut vals, mut lens, mut formats, data)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
module pg
|
module pg
|
||||||
|
|
||||||
import io
|
import io
|
||||||
|
import orm
|
||||||
|
|
||||||
$if $pkgconfig('libpq') {
|
$if $pkgconfig('libpq') {
|
||||||
#pkgconfig --cflags --libs libpq
|
#pkgconfig --cflags --libs libpq
|
||||||
@ -363,3 +364,19 @@ pub fn (db DB) copy_expert(query string, mut file io.ReaderWriter) !int {
|
|||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn pg_stmt_worker(db DB, query string, data orm.QueryData, where orm.QueryData) ![]Row {
|
||||||
|
mut param_types := []u32{}
|
||||||
|
mut param_vals := []&char{}
|
||||||
|
mut param_lens := []int{}
|
||||||
|
mut param_formats := []int{}
|
||||||
|
|
||||||
|
pg_stmt_binder(mut param_types, mut param_vals, mut param_lens, mut param_formats,
|
||||||
|
data)
|
||||||
|
pg_stmt_binder(mut param_types, mut param_vals, mut param_lens, mut param_formats,
|
||||||
|
where)
|
||||||
|
|
||||||
|
res := C.PQexecParams(db.conn, &char(query.str), param_vals.len, param_types.data,
|
||||||
|
param_vals.data, param_lens.data, param_formats.data, 0) // here, the last 0 means require text results, 1 - binary results
|
||||||
|
return db.handle_error_or_result(res, 'orm_stmt_worker')
|
||||||
|
}
|
@ -214,7 +214,7 @@ fn example_vfsfile_read(file &sqlite.Sqlite3_file, output voidptr, amount int, o
|
|||||||
vfsfile.vfs_state.log << 'read file=${vfsfile.name}'
|
vfsfile.vfs_state.log << 'read file=${vfsfile.name}'
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
C.memset(output, 0, amount)
|
vmemset(output, 0, amount)
|
||||||
}
|
}
|
||||||
|
|
||||||
return sqlite.sqlite_ioerr_short_read
|
return sqlite.sqlite_ioerr_short_read
|
||||||
|
Loading…
x
Reference in New Issue
Block a user