Skip to content

Commit 251905a

Browse files
committed
Renamed MYSQLPTR to MYSQL, moved constants from types.jl to consts.jl
1 parent 9c9c667 commit 251905a

File tree

4 files changed

+167
-159
lines changed

4 files changed

+167
-159
lines changed

src/MySQL.jl

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module MySQL
22
using DBI
33

44
include("config.jl")
5+
include("consts.jl")
56
include("types.jl")
67
include("api.jl")
78
include("handy.jl")

src/api.jl

+39-39
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Initializes the MYSQL object. Must be called before mysql_real_connect.
33
Memory allocated by mysql_init can be freed with mysql_close.
44
"""
5-
function mysql_init(mysqlptr::MYSQLPTR)
5+
function mysql_init(mysqlptr::MYSQL)
66
return ccall((:mysql_init, mysql_lib),
77
Ptr{Void},
88
(Ptr{Cuchar}, ),
@@ -13,7 +13,7 @@ end
1313
Used to connect to database server. Returns a MYSQL handle on success and
1414
C_NULL on failure.
1515
"""
16-
function mysql_real_connect(mysqlptr::MYSQLPTR,
16+
function mysql_real_connect(mysqlptr::MYSQL,
1717
host::String,
1818
user::String,
1919
passwd::String,
@@ -55,7 +55,7 @@ Used to set options. Must be called after mysql_init and before
5555
mysql_real_connect. Can be called multiple times to set options.
5656
Returns non zero on error.
5757
"""
58-
function mysql_options(mysqlptr::MYSQLPTR,
58+
function mysql_options(mysqlptr::MYSQL,
5959
option_type::Cuint,
6060
option::Ptr{None})
6161
return ccall((:mysql_options, mysql_lib),
@@ -71,7 +71,7 @@ end
7171
"""
7272
Close an opened MySQL connection.
7373
"""
74-
function mysql_close(mysqlptr::MYSQLPTR)
74+
function mysql_close(mysqlptr::MYSQL)
7575
return ccall((:mysql_close, mysql_lib),
7676
Void,
7777
(Ptr{Cuchar}, ),
@@ -81,7 +81,7 @@ end
8181
"""
8282
Returns the error number of the last API call.
8383
"""
84-
function mysql_errno(mysqlptr::MYSQLPTR)
84+
function mysql_errno(mysqlptr::MYSQL)
8585
return ccall((:mysql_errno, mysql_lib),
8686
Cuint,
8787
(Ptr{Cuchar}, ),
@@ -92,7 +92,7 @@ end
9292
Returns a string of the last error message of the most recent function call.
9393
If no error occured and empty string is returned.
9494
"""
95-
function mysql_error(mysqlptr::MYSQLPTR)
95+
function mysql_error(mysqlptr::MYSQL)
9696
return ccall((:mysql_error, mysql_lib),
9797
Ptr{Cuchar},
9898
(Ptr{Cuchar}, ),
@@ -123,7 +123,7 @@ end
123123
Returns the value generated by auto increment column by the previous
124124
insert / update statement.
125125
"""
126-
function mysql_insert_id(mysqlptr::MYSQLPTR)
126+
function mysql_insert_id(mysqlptr::MYSQL)
127127
return ccall((:mysql_insert_id, mysql_lib),
128128
Culong,
129129
(Ptr{Cuchar}, ),
@@ -133,7 +133,7 @@ end
133133
"""
134134
Creates the sql string where the special chars are escaped
135135
"""
136-
function mysql_real_escape_string(mysqlptr::MYSQLPTR,
136+
function mysql_real_escape_string(mysqlptr::MYSQL,
137137
to::Vector{Uint8},
138138
from::String,
139139
length::Culong)
@@ -219,7 +219,7 @@ end
219219
"""
220220
Executes the query and returns the status of the same.
221221
"""
222-
function mysql_query(mysqlptr::MYSQLPTR, sql::String)
222+
function mysql_query(mysqlptr::MYSQL, sql::String)
223223
return ccall((:mysql_query, mysql_lib),
224224
Int8,
225225
(Ptr{Cuchar}, Ptr{Cuchar}),
@@ -298,25 +298,25 @@ function mysql_affected_rows(results::Ptr{Cuchar})
298298
results)
299299
end
300300

301-
function mysql_autocommit(mysqlptr::MYSQLPTR, mode::Int8)
301+
function mysql_autocommit(mysqlptr::MYSQL, mode::Int8)
302302
return ccall((:mysql_autocommit, mysql_lib),
303303
Cchar, (Ptr{Void}, Cchar),
304304
mysqlptr, mode)
305305
end
306306

307-
function mysql_change_user(mysqlptr::MYSQLPTR, user::String, passwd::String,
307+
function mysql_change_user(mysqlptr::MYSQL, user::String, passwd::String,
308308
db::String = "")
309309
return ccall((:mysql_change_user, mysql_lib),
310310
Cchar, (Ptr{Void}, Cstring, Cstring, Cstring),
311311
mysqlptr, user, passwd, (db == "" ? C_NULL : db))
312312
end
313313

314-
function mysql_character_set_name(mysqlptr::MYSQLPTR)
314+
function mysql_character_set_name(mysqlptr::MYSQL)
315315
return ccall((:mysql_character_set_name, mysql_lib),
316316
Cstring, (Ptr{Void},), mysqlptr)
317317
end
318318

319-
function mysql_commit(mysqlptr::MYSQLPTR)
319+
function mysql_commit(mysqlptr::MYSQL)
320320
return ccall((:mysql_commit, mysql_lib), Cchar, (Ptr{Void},), mysqlptr)
321321
end
322322

@@ -326,7 +326,7 @@ function mysql_data_seek(result::MYSQL_RES, offset::Uint64)
326326
result, offset-1)
327327
end
328328

329-
function mysql_dump_debug_info(mysqlptr::MYSQLPTR)
329+
function mysql_dump_debug_info(mysqlptr::MYSQL)
330330
return ccall((:mysql_dump_debug_info, mysql_lib),
331331
Cint, (Ptr{Void},), mysqlptr)
332332
end
@@ -335,7 +335,7 @@ function mysql_fetch_lengths(result::MYSQL_RES)
335335
return ccall((:mysql_fetch_lengths, mysql_lib), Ptr{Cuint}, (Ptr{Void},), result)
336336
end
337337

338-
function mysql_field_count(mysqlptr::MYSQLPTR)
338+
function mysql_field_count(mysqlptr::MYSQL)
339339
return ccall((:mysql_field_count, mysql_lib), Cuint, (Ptr{Void},), mysqlptr)
340340
end
341341

@@ -348,7 +348,7 @@ function mysql_field_tell(result::MYSQL_RES)
348348
return ccall((:mysql_field_tell, mysql_lib), Cuint, (Ptr{Void},), result)
349349
end
350350

351-
function mysql_get_character_set_info(mysqlptr::MYSQLPTR)
351+
function mysql_get_character_set_info(mysqlptr::MYSQL)
352352
info = _MY_CHARSET_INFO_[_MY_CHARSET_INFO_()]
353353
ccall((:mysql_get_character_set_info, mysql_lib), Void, (Ptr{Void}, Ref{_MY_CHARSET_INFO_}),
354354
mysqlptr, info)
@@ -363,31 +363,31 @@ function mysql_get_client_version()
363363
return ccall((:mysql_get_client_version, mysql_lib), Culong, ())
364364
end
365365

366-
function mysql_get_host_info(mysqlptr::MYSQLPTR)
366+
function mysql_get_host_info(mysqlptr::MYSQL)
367367
return ccall((:mysql_get_host_info, mysql_lib), Ptr{Uint8}, (Ptr{Void},), mysqlptr)
368368
end
369369

370-
function mysql_get_proto_info(mysqlptr::MYSQLPTR)
370+
function mysql_get_proto_info(mysqlptr::MYSQL)
371371
return ccall((:mysql_get_proto_info, mysql_lib), Cuint, (Ptr{Void},), mysqlptr)
372372
end
373373

374-
function mysql_get_server_info(mysqlptr::MYSQLPTR)
374+
function mysql_get_server_info(mysqlptr::MYSQL)
375375
return ccall((:mysql_get_server_info, mysql_lib), Ptr{Uint8}, (Ptr{Void},), mysqlptr)
376376
end
377377

378-
function mysql_get_server_version(mysqlptr::MYSQLPTR)
378+
function mysql_get_server_version(mysqlptr::MYSQL)
379379
return ccall((:mysql_get_server_version, mysql_lib), Culong, (Ptr{Void},), mysqlptr)
380380
end
381381

382-
function mysql_get_ssl_cipher(mysqlptr::MYSQLPTR)
382+
function mysql_get_ssl_cipher(mysqlptr::MYSQL)
383383
return ccall((:mysql_get_ssl_cipher, mysql_lib), Ptr{Uint8}, (Ptr{Void},), mysqlptr)
384384
end
385385

386-
function mysql_info(mysqlptr::MYSQLPTR)
386+
function mysql_info(mysqlptr::MYSQL)
387387
return ccall((:mysql_info, mysql_lib), Ptr{Uint8}, (Ptr{Void},), mysqlptr)
388388
end
389389

390-
function mysql_kill(mysqlptr::MYSQLPTR, pid::Uint)
390+
function mysql_kill(mysqlptr::MYSQL, pid::Uint)
391391
return ccall((:mysql_kill, mysql_lib), Cint, (PTr{Uint8}, Culong),
392392
mysqlptr, pid)
393393
end
@@ -408,35 +408,35 @@ function mysql_server_init()
408408
0, C_NULL, C_NULL)
409409
end
410410

411-
function mysql_more_results(mysqlptr::MYSQLPTR)
411+
function mysql_more_results(mysqlptr::MYSQL)
412412
retval = ccall((:mysql_more_results, mysql_lib), Cchar, (Ptr{Void},), mysqlptr)
413413
return retval == 1
414414
end
415415

416-
function mysql_next_result(mysqlptr::MYSQLPTR)
416+
function mysql_next_result(mysqlptr::MYSQL)
417417
return ccall((:mysql_next_result, mysql_lib), Cint, (Ptr{Void},),
418418
mysqlptr)
419419
end
420420

421-
function mysql_ping(mysqlptr::MYSQLPTR)
421+
function mysql_ping(mysqlptr::MYSQL)
422422
return ccall((:mysql_ping, mysql_lib), Cint, (Ptr{Void},), mysqlptr)
423423
end
424424

425-
function mysql_real_query(mysqlptr::MYSQLPTR, query::Vector{Uint8})
425+
function mysql_real_query(mysqlptr::MYSQL, query::Vector{Uint8})
426426
return ccall((:mysql_real_query, mysql_lib), Cint, (Ptr{Void}, Ptr{Uint8}, Culong),
427427
mysqlptr, query, length(query))
428428
end
429429

430-
function mysql_real_query(mysqlptr::MYSQLPTR, query::Ptr{Cuchar})
430+
function mysql_real_query(mysqlptr::MYSQL, query::Ptr{Cuchar})
431431
return mysql_real_query(mysqlptr, query)
432432
end
433433

434-
function mysql_refresh(mysqlptr::MYSQLPTR, options::Uint32)
434+
function mysql_refresh(mysqlptr::MYSQL, options::Uint32)
435435
return ccall((:mysql_refresh, mysql_lib), Cchar,
436436
(Ptr{Void}, Cuint), mysqlptr, options)
437437
end
438438

439-
function mysql_rollback(mysqlptr::MYSQLPTR)
439+
function mysql_rollback(mysqlptr::MYSQL)
440440
return ccall((:mysql_rollback, mysql_lib), Cchar, (Ptr{Void},), mysqlptr)
441441
end
442442

@@ -449,39 +449,39 @@ function mysql_row_tell(result::MYSQL_RES)
449449
result)
450450
end
451451

452-
function mysql_select_db(mysqlptr::MYSQLPTR, db::String)
452+
function mysql_select_db(mysqlptr::MYSQL, db::String)
453453
return ccall((:mysql_select_db, mysql_lib),
454454
Cint, (Ptr{Void}, Ptr{Void}), mysqlptr, db)
455455
end
456456

457-
function mysql_set_character_set(mysqlptr::MYSQLPTR, csname::String)
457+
function mysql_set_character_set(mysqlptr::MYSQL, csname::String)
458458
return ccall((:mysql_set_character_set, mysql_lib), Cint, (Ptr{Void}, Ptr{Void}), mysqlptr, csname)
459459
end
460460

461-
function mysql_set_server_option(mysqlptr::MYSQLPTR, option::Uint32)
461+
function mysql_set_server_option(mysqlptr::MYSQL, option::Uint32)
462462
return ccall((:mysql_set_server_option, mysql_lib), Cint, (Ptr{Void}, Cint), mysqlptr, option)
463463
end
464464

465-
function mysql_sqlstate(mysqlptr::MYSQLPTR)
465+
function mysql_sqlstate(mysqlptr::MYSQL)
466466
return ccall((:mysql_sqlstate, mysql_lib), Ptr{Uint8}, (Ptr{Void},), mysqlptr)
467467
end
468468

469-
function mysql_ssl_set(mysqlptr::MYSQLPTR, key::Ptr{Uint8}=C_NULL, cert::Ptr{Uint8}=C_NULL, ca::Ptr{Uint8}=C_NULL,
469+
function mysql_ssl_set(mysqlptr::MYSQL, key::Ptr{Uint8}=C_NULL, cert::Ptr{Uint8}=C_NULL, ca::Ptr{Uint8}=C_NULL,
470470
capath::Ptr{Uint8}=C_NULL, cipher::Ptr{Uint8}=C_NULL)
471471
return ccall((:mysql_ssl_set, mysql_lib),
472472
Cchar, (Ptr{Void}, Ptr{Uint8}, Ptr{Uint8}, Ptr{Uint8}, Ptr{Uint8}, Ptr{Uint8}),
473473
mysqlptr, key, cert, ca, capath, cipher)
474474
end
475475

476-
function mysql_stat(mysqlptr::MYSQLPTR)
476+
function mysql_stat(mysqlptr::MYSQL)
477477
return ccall((:mysql_stat, mysql_lib), Ptr{Uint8}, (Ptr{Void},), mysqlptr)
478478
end
479479

480480
function mysql_thread_end()
481481
return ccall((:mysql_thread_end, mysql_lib), Void, ())
482482
end
483483

484-
function mysql_thread_id(mysqlptr::MYSQLPTR)
484+
function mysql_thread_id(mysqlptr::MYSQL)
485485
return ccall((:mysql_thread_id, mysql_lib), Culong, (Ptr{Void},), mysqlptr)
486486
end
487487

@@ -493,12 +493,12 @@ function mysql_thread_safe()
493493
return ccall((:mysql_thread_safe, mysql_lib), Cint, ())
494494
end
495495

496-
function mysql_use_result(mysqlptr::MYSQLPTR)
496+
function mysql_use_result(mysqlptr::MYSQL)
497497
return ccall((:mysql_use_result, mysql_lib), Ptr{Void}, (Ptr{Void},),
498498
mysqlptr)
499499
end
500500

501-
function mysql_warning_count(mysqlptr::MYSQLPTR)
501+
function mysql_warning_count(mysqlptr::MYSQL)
502502
return ccall((:mysql_warning_count, mysql_lib), Cuint, (Ptr{Void},),
503503
mysqlptr)
504504
end

0 commit comments

Comments
 (0)