Skip to content

Commit

Permalink
Fix other string C api call arguments (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
quinnj authored Oct 25, 2022
1 parent 2c15d97 commit 7d9545a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
32 changes: 16 additions & 16 deletions src/api/ccalls.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ end
function mysql_change_user(mysql::Ptr{Cvoid}, user::AbstractString, password::AbstractString, db)
return @c(:mysql_change_user,
Bool,
(Ptr{Cvoid}, Ptr{UInt8}, Ptr{UInt8}, Ptr{UInt8}),
(Ptr{Cvoid}, Cstring, Cstring, Cstring),
mysql, user, password, db)
end

Expand All @@ -56,7 +56,7 @@ end
function mysql_client_find_plugin(mysql::Ptr{Cvoid}, name::AbstractString, type::Int)
return @c(:mysql_client_find_plugin,
Ptr{Cvoid},
(Ptr{Cvoid}, Ptr{UInt8}, Cint),
(Ptr{Cvoid}, Cstring, Cint),
mysql, name, type)
end

Expand Down Expand Up @@ -277,7 +277,7 @@ end
function mysql_hex_string(to, from, length::Integer)
return @c(:mysql_hex_string,
Culong,
(Ptr{UInt8}, Ptr{UInt8}, Culong),
(Cstring, Cstring, Culong),
to, from, length)
end

Expand Down Expand Up @@ -386,46 +386,46 @@ end
function mysql_plugin_options(plugin::Ptr{Cvoid}, option, value)
return @c(:mysql_plugin_options,
Cint,
(Ptr{Cvoid}, Ptr{UInt8}, Ptr{Cvoid}),
(Ptr{Cvoid}, Cstring, Ptr{Cvoid}),
plugin, option, value)
end

function mysql_query(mysql::Ptr{Cvoid}, stmt_str)
return @c(:mysql_query,
Cint,
(Ptr{Cvoid}, Ptr{UInt8}),
(Ptr{Cvoid}, Cstring),
mysql, stmt_str)
end

#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)
function mysql_real_connect(mysql::Ptr{Cvoid}, host, user, passwd, db, port, unix_socket, client_flag)
return @c(:mysql_real_connect,
Ptr{Cvoid},
(Ptr{Cvoid}, Ptr{UInt8}, Ptr{UInt8}, Ptr{UInt8}, Ptr{UInt8}, Cuint, Ptr{UInt8}, Culong),
(Ptr{Cvoid}, Cstring, Cstring, Cstring, Cstring, Cuint, Cstring, Culong),
mysql, host, user, passwd, db, port, unix_socket, client_flag)
end

#unsigned long mysql_real_escape_string(MYSQL *mysql, char *to, const char *from, unsigned long length)
function mysql_real_escape_string(mysql::Ptr{Cvoid}, to, from, len)
return @c(:mysql_real_escape_string,
Culong,
(Ptr{Cvoid}, Ptr{UInt8}, Ptr{UInt8}, Culong),
(Ptr{Cvoid}, Ptr{UInt8}, Cstring, Culong),
mysql, to, from, len)
end

#unsigned long mysql_real_escape_string_quote(MYSQL *mysql, char *to, const char *from, unsigned long length, char quote)
function mysql_real_escape_string_quote(mysql::Ptr{Cvoid}, to, from, len, q)
return @c(:mysql_real_escape_string_quote,
Culong,
(Ptr{Cvoid}, Ptr{UInt8}, Ptr{UInt8}, Culong, Cchar),
(Ptr{Cvoid}, Ptr{UInt8}, Cstring, Culong, Cchar),
mysql, to, from, len, q)
end

#int mysql_real_query(MYSQL *mysql, const char *stmt_str, unsigned long length)
function mysql_real_query(mysql::Ptr{Cvoid}, stmt_str, len)
return @c(:mysql_real_query,
Cint,
(Ptr{Cvoid}, Ptr{UInt8}, Culong),
(Ptr{Cvoid}, Cstring, Culong),
mysql, stmt_str, len)
end

Expand Down Expand Up @@ -480,31 +480,31 @@ end
function mysql_select_db(mysql::Ptr{Cvoid}, db::AbstractString)
return @c(:mysql_select_db,
Cint,
(Ptr{Cvoid}, Ptr{UInt8}),
(Ptr{Cvoid}, Cstring),
mysql, db)
end

#int mysql_session_track_get_first(MYSQL *mysql, enum enum_session_state_type type, const char **data, size_t *length)
function mysql_session_track_get_first(mysql::Ptr{Cvoid}, type, data, len)
return @c(:mysql_session_track_get_first,
Cint,
(Ptr{Cvoid}, Cint, Ptr{Ptr{UInt8}}, Ptr{Csize_t}),
(Ptr{Cvoid}, Cint, Ptr{Cstring}, Ptr{Csize_t}),
mysql, type, data, len)
end

#int mysql_session_track_get_next(MYSQL *mysql, enum enum_session_state_type type, const char **data, size_t *length)
function mysql_session_track_get_next(mysql::Ptr{Cvoid}, type, data, len)
return @c(:mysql_session_track_get_next,
Cint,
(Ptr{Cvoid}, Cint, Ptr{Ptr{UInt8}}, Ptr{Csize_t}),
(Ptr{Cvoid}, Cint, Ptr{Cstring}, Ptr{Csize_t}),
mysql, type, data, len)
end

#int mysql_set_character_set(MYSQL *mysql, const char *csname)
function mysql_set_character_set(mysql::Ptr{Cvoid}, csname::AbstractString)
return @c(:mysql_set_character_set,
Cint,
(Ptr{Cvoid}, Ptr{UInt8}),
(Ptr{Cvoid}, Cstring),
mysql, csname)
end

Expand Down Expand Up @@ -544,7 +544,7 @@ end
function mysql_ssl_set(mysql::Ptr{Cvoid}, key, cert, ca, capath, cipher)
return @c(:mysql_ssl_set,
Bool,
(Ptr{Cvoid}, Ptr{UInt8}, Ptr{UInt8}, Ptr{UInt8}, Ptr{UInt8}, Ptr{UInt8}),
(Ptr{Cvoid}, Cstring, Cstring, Cstring, Cstring, Cstring),
mysql, key, cert, ca, capath, cipher)
end

Expand Down Expand Up @@ -748,7 +748,7 @@ end
function mysql_stmt_prepare(stmt::Ptr{Cvoid}, stmt_str, len)
return @c(:mysql_stmt_prepare,
Cint,
(Ptr{Cvoid}, Ptr{UInt8}, Culong),
(Ptr{Cvoid}, Cstring, Culong),
stmt, stmt_str, len)
end

Expand Down Expand Up @@ -788,7 +788,7 @@ end
function mysql_stmt_send_long_data(stmt::Ptr{Cvoid}, parameter_number, data, length)
return @c(:mysql_stmt_send_long_data,
Bool,
(Ptr{Cvoid}, Cuint, Ptr{UInt8}, Culong),
(Ptr{Cvoid}, Cuint, Cstring, Culong),
stmt, parameter_number, data, length)
end

Expand Down
4 changes: 2 additions & 2 deletions src/execute.jl
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ function DBInterface.execute(conn::Connection, sql::AbstractString, params=(); m
end
nfields = API.numfields(result)
fields = API.fetchfields(result, nfields)
names = [ccall(:jl_symbol_n, Ref{Symbol}, (Ptr{UInt8}, Csize_t), x.name, x.name_length) for x in fields]
names = [ccall(:jl_symbol_n, Ref{Symbol}, (Cstring, Csize_t), x.name, x.name_length) for x in fields]
types = [juliatype(x.field_type, API.notnullable(x), API.isunsigned(x), API.isbinary(x), mysql_date_and_time) for x in fields]
elseif API.fieldcount(conn.mysql) == 0
rows_affected = API.affectedrows(conn.mysql)
Expand Down Expand Up @@ -212,7 +212,7 @@ function Base.iterate(cursor::TextCursors{buffered}, first=true) where {buffered
end
cursor.cursor.nfields = API.numfields(cursor.cursor.result)
fields = API.fetchfields(cursor.cursor.result, cursor.cursor.nfields)
cursor.cursor.names = [ccall(:jl_symbol_n, Ref{Symbol}, (Ptr{UInt8}, Csize_t), x.name, x.name_length) for x in fields]
cursor.cursor.names = [ccall(:jl_symbol_n, Ref{Symbol}, (Cstring, Csize_t), x.name, x.name_length) for x in fields]
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]
else
return nothing
Expand Down
4 changes: 2 additions & 2 deletions src/prepare.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function DBInterface.prepare(conn::Connection, sql::AbstractString; mysql_date_a
result = API.resultmetadata(stmt)
if result.ptr != C_NULL
fields = API.fetchfields(result, nfields)
names = [ccall(:jl_symbol_n, Ref{Symbol}, (Ptr{UInt8}, Csize_t), x.name, x.name_length) for x in fields]
names = [ccall(:jl_symbol_n, Ref{Symbol}, (Cstring, Csize_t), x.name, x.name_length) for x in fields]
types = [juliatype(x.field_type, API.notnullable(x), API.isunsigned(x), API.isbinary(x), mysql_date_and_time) for x in fields]
valuehelpers = [API.BindHelper() for i = 1:nfields]
values = [API.MYSQL_BIND(valuehelpers[i].length, valuehelpers[i].is_null) for i = 1:nfields]
Expand Down Expand Up @@ -180,7 +180,7 @@ function DBInterface.execute(stmt::Statement, params=(); mysql_store_result::Boo
result = API.resultmetadata(stmt.stmt)
if result.ptr != C_NULL
fields = API.fetchfields(result, nfields)
names = [ccall(:jl_symbol_n, Ref{Symbol}, (Ptr{UInt8}, Csize_t), x.name, x.name_length) for x in fields]
names = [ccall(:jl_symbol_n, Ref{Symbol}, (Cstring, Csize_t), x.name, x.name_length) for x in fields]
types = [juliatype(x.field_type, API.notnullable(x), API.isunsigned(x), API.isbinary(x), mysql_date_and_time) for x in fields]
valuehelpers = [API.BindHelper() for i = 1:nfields]
values = [API.MYSQL_BIND(valuehelpers[i].length, valuehelpers[i].is_null) for i = 1:nfields]
Expand Down

0 comments on commit 7d9545a

Please sign in to comment.