Skip to content

Commit 7d9545a

Browse files
authored
Fix other string C api call arguments (#205)
1 parent 2c15d97 commit 7d9545a

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

src/api/ccalls.jl

+16-16
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ end
4040
function mysql_change_user(mysql::Ptr{Cvoid}, user::AbstractString, password::AbstractString, db)
4141
return @c(:mysql_change_user,
4242
Bool,
43-
(Ptr{Cvoid}, Ptr{UInt8}, Ptr{UInt8}, Ptr{UInt8}),
43+
(Ptr{Cvoid}, Cstring, Cstring, Cstring),
4444
mysql, user, password, db)
4545
end
4646

@@ -56,7 +56,7 @@ end
5656
function mysql_client_find_plugin(mysql::Ptr{Cvoid}, name::AbstractString, type::Int)
5757
return @c(:mysql_client_find_plugin,
5858
Ptr{Cvoid},
59-
(Ptr{Cvoid}, Ptr{UInt8}, Cint),
59+
(Ptr{Cvoid}, Cstring, Cint),
6060
mysql, name, type)
6161
end
6262

@@ -277,7 +277,7 @@ end
277277
function mysql_hex_string(to, from, length::Integer)
278278
return @c(:mysql_hex_string,
279279
Culong,
280-
(Ptr{UInt8}, Ptr{UInt8}, Culong),
280+
(Cstring, Cstring, Culong),
281281
to, from, length)
282282
end
283283

@@ -386,46 +386,46 @@ end
386386
function mysql_plugin_options(plugin::Ptr{Cvoid}, option, value)
387387
return @c(:mysql_plugin_options,
388388
Cint,
389-
(Ptr{Cvoid}, Ptr{UInt8}, Ptr{Cvoid}),
389+
(Ptr{Cvoid}, Cstring, Ptr{Cvoid}),
390390
plugin, option, value)
391391
end
392392

393393
function mysql_query(mysql::Ptr{Cvoid}, stmt_str)
394394
return @c(:mysql_query,
395395
Cint,
396-
(Ptr{Cvoid}, Ptr{UInt8}),
396+
(Ptr{Cvoid}, Cstring),
397397
mysql, stmt_str)
398398
end
399399

400400
#MYSQL *mysql_real_connect(MYSQL *mysql, const char *host, const char *user, const char *passwd, const char *db, unsigned int port, const char *unix_socket, unsigned long client_flag)
401401
function mysql_real_connect(mysql::Ptr{Cvoid}, host, user, passwd, db, port, unix_socket, client_flag)
402402
return @c(:mysql_real_connect,
403403
Ptr{Cvoid},
404-
(Ptr{Cvoid}, Ptr{UInt8}, Ptr{UInt8}, Ptr{UInt8}, Ptr{UInt8}, Cuint, Ptr{UInt8}, Culong),
404+
(Ptr{Cvoid}, Cstring, Cstring, Cstring, Cstring, Cuint, Cstring, Culong),
405405
mysql, host, user, passwd, db, port, unix_socket, client_flag)
406406
end
407407

408408
#unsigned long mysql_real_escape_string(MYSQL *mysql, char *to, const char *from, unsigned long length)
409409
function mysql_real_escape_string(mysql::Ptr{Cvoid}, to, from, len)
410410
return @c(:mysql_real_escape_string,
411411
Culong,
412-
(Ptr{Cvoid}, Ptr{UInt8}, Ptr{UInt8}, Culong),
412+
(Ptr{Cvoid}, Ptr{UInt8}, Cstring, Culong),
413413
mysql, to, from, len)
414414
end
415415

416416
#unsigned long mysql_real_escape_string_quote(MYSQL *mysql, char *to, const char *from, unsigned long length, char quote)
417417
function mysql_real_escape_string_quote(mysql::Ptr{Cvoid}, to, from, len, q)
418418
return @c(:mysql_real_escape_string_quote,
419419
Culong,
420-
(Ptr{Cvoid}, Ptr{UInt8}, Ptr{UInt8}, Culong, Cchar),
420+
(Ptr{Cvoid}, Ptr{UInt8}, Cstring, Culong, Cchar),
421421
mysql, to, from, len, q)
422422
end
423423

424424
#int mysql_real_query(MYSQL *mysql, const char *stmt_str, unsigned long length)
425425
function mysql_real_query(mysql::Ptr{Cvoid}, stmt_str, len)
426426
return @c(:mysql_real_query,
427427
Cint,
428-
(Ptr{Cvoid}, Ptr{UInt8}, Culong),
428+
(Ptr{Cvoid}, Cstring, Culong),
429429
mysql, stmt_str, len)
430430
end
431431

@@ -480,31 +480,31 @@ end
480480
function mysql_select_db(mysql::Ptr{Cvoid}, db::AbstractString)
481481
return @c(:mysql_select_db,
482482
Cint,
483-
(Ptr{Cvoid}, Ptr{UInt8}),
483+
(Ptr{Cvoid}, Cstring),
484484
mysql, db)
485485
end
486486

487487
#int mysql_session_track_get_first(MYSQL *mysql, enum enum_session_state_type type, const char **data, size_t *length)
488488
function mysql_session_track_get_first(mysql::Ptr{Cvoid}, type, data, len)
489489
return @c(:mysql_session_track_get_first,
490490
Cint,
491-
(Ptr{Cvoid}, Cint, Ptr{Ptr{UInt8}}, Ptr{Csize_t}),
491+
(Ptr{Cvoid}, Cint, Ptr{Cstring}, Ptr{Csize_t}),
492492
mysql, type, data, len)
493493
end
494494

495495
#int mysql_session_track_get_next(MYSQL *mysql, enum enum_session_state_type type, const char **data, size_t *length)
496496
function mysql_session_track_get_next(mysql::Ptr{Cvoid}, type, data, len)
497497
return @c(:mysql_session_track_get_next,
498498
Cint,
499-
(Ptr{Cvoid}, Cint, Ptr{Ptr{UInt8}}, Ptr{Csize_t}),
499+
(Ptr{Cvoid}, Cint, Ptr{Cstring}, Ptr{Csize_t}),
500500
mysql, type, data, len)
501501
end
502502

503503
#int mysql_set_character_set(MYSQL *mysql, const char *csname)
504504
function mysql_set_character_set(mysql::Ptr{Cvoid}, csname::AbstractString)
505505
return @c(:mysql_set_character_set,
506506
Cint,
507-
(Ptr{Cvoid}, Ptr{UInt8}),
507+
(Ptr{Cvoid}, Cstring),
508508
mysql, csname)
509509
end
510510

@@ -544,7 +544,7 @@ end
544544
function mysql_ssl_set(mysql::Ptr{Cvoid}, key, cert, ca, capath, cipher)
545545
return @c(:mysql_ssl_set,
546546
Bool,
547-
(Ptr{Cvoid}, Ptr{UInt8}, Ptr{UInt8}, Ptr{UInt8}, Ptr{UInt8}, Ptr{UInt8}),
547+
(Ptr{Cvoid}, Cstring, Cstring, Cstring, Cstring, Cstring),
548548
mysql, key, cert, ca, capath, cipher)
549549
end
550550

@@ -748,7 +748,7 @@ end
748748
function mysql_stmt_prepare(stmt::Ptr{Cvoid}, stmt_str, len)
749749
return @c(:mysql_stmt_prepare,
750750
Cint,
751-
(Ptr{Cvoid}, Ptr{UInt8}, Culong),
751+
(Ptr{Cvoid}, Cstring, Culong),
752752
stmt, stmt_str, len)
753753
end
754754

@@ -788,7 +788,7 @@ end
788788
function mysql_stmt_send_long_data(stmt::Ptr{Cvoid}, parameter_number, data, length)
789789
return @c(:mysql_stmt_send_long_data,
790790
Bool,
791-
(Ptr{Cvoid}, Cuint, Ptr{UInt8}, Culong),
791+
(Ptr{Cvoid}, Cuint, Cstring, Culong),
792792
stmt, parameter_number, data, length)
793793
end
794794

src/execute.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ function DBInterface.execute(conn::Connection, sql::AbstractString, params=(); m
180180
end
181181
nfields = API.numfields(result)
182182
fields = API.fetchfields(result, nfields)
183-
names = [ccall(:jl_symbol_n, Ref{Symbol}, (Ptr{UInt8}, Csize_t), x.name, x.name_length) for x in fields]
183+
names = [ccall(:jl_symbol_n, Ref{Symbol}, (Cstring, Csize_t), x.name, x.name_length) for x in fields]
184184
types = [juliatype(x.field_type, API.notnullable(x), API.isunsigned(x), API.isbinary(x), mysql_date_and_time) for x in fields]
185185
elseif API.fieldcount(conn.mysql) == 0
186186
rows_affected = API.affectedrows(conn.mysql)
@@ -212,7 +212,7 @@ function Base.iterate(cursor::TextCursors{buffered}, first=true) where {buffered
212212
end
213213
cursor.cursor.nfields = API.numfields(cursor.cursor.result)
214214
fields = API.fetchfields(cursor.cursor.result, cursor.cursor.nfields)
215-
cursor.cursor.names = [ccall(:jl_symbol_n, Ref{Symbol}, (Ptr{UInt8}, Csize_t), x.name, x.name_length) for x in fields]
215+
cursor.cursor.names = [ccall(:jl_symbol_n, Ref{Symbol}, (Cstring, Csize_t), x.name, x.name_length) for x in fields]
216216
cursor.cursor.types = [juliatype(x.field_type, API.notnullable(x), API.isunsigned(x), API.isbinary(x), cursor.cursor.mysql_date_and_time) for x in fields]
217217
else
218218
return nothing

src/prepare.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function DBInterface.prepare(conn::Connection, sql::AbstractString; mysql_date_a
5353
result = API.resultmetadata(stmt)
5454
if result.ptr != C_NULL
5555
fields = API.fetchfields(result, nfields)
56-
names = [ccall(:jl_symbol_n, Ref{Symbol}, (Ptr{UInt8}, Csize_t), x.name, x.name_length) for x in fields]
56+
names = [ccall(:jl_symbol_n, Ref{Symbol}, (Cstring, Csize_t), x.name, x.name_length) for x in fields]
5757
types = [juliatype(x.field_type, API.notnullable(x), API.isunsigned(x), API.isbinary(x), mysql_date_and_time) for x in fields]
5858
valuehelpers = [API.BindHelper() for i = 1:nfields]
5959
values = [API.MYSQL_BIND(valuehelpers[i].length, valuehelpers[i].is_null) for i = 1:nfields]
@@ -180,7 +180,7 @@ function DBInterface.execute(stmt::Statement, params=(); mysql_store_result::Boo
180180
result = API.resultmetadata(stmt.stmt)
181181
if result.ptr != C_NULL
182182
fields = API.fetchfields(result, nfields)
183-
names = [ccall(:jl_symbol_n, Ref{Symbol}, (Ptr{UInt8}, Csize_t), x.name, x.name_length) for x in fields]
183+
names = [ccall(:jl_symbol_n, Ref{Symbol}, (Cstring, Csize_t), x.name, x.name_length) for x in fields]
184184
types = [juliatype(x.field_type, API.notnullable(x), API.isunsigned(x), API.isbinary(x), mysql_date_and_time) for x in fields]
185185
valuehelpers = [API.BindHelper() for i = 1:nfields]
186186
values = [API.MYSQL_BIND(valuehelpers[i].length, valuehelpers[i].is_null) for i = 1:nfields]

0 commit comments

Comments
 (0)