Skip to content

Commit 082e8d2

Browse files
committed
Mark exported functions as not static
This is to better signify that these functions are going to be called from the BEAM.
1 parent 7d0e8aa commit 082e8d2

File tree

1 file changed

+84
-34
lines changed

1 file changed

+84
-34
lines changed

c_src/sqlite3_nif.c

Lines changed: 84 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,10 @@ make_sqlite3_error_tuple(ErlNifEnv* env, int rc, sqlite3* db)
195195
return make_error_tuple(env, make_binary(env, msg, len));
196196
}
197197

198-
static ERL_NIF_TERM
198+
///
199+
/// Opens a new SQLite database
200+
///
201+
ERL_NIF_TERM
199202
exqlite_open(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
200203
{
201204
assert(env);
@@ -251,7 +254,10 @@ exqlite_open(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
251254
return make_ok_tuple(env, result);
252255
}
253256

254-
static ERL_NIF_TERM
257+
///
258+
/// Closes an SQLite database
259+
///
260+
ERL_NIF_TERM
255261
exqlite_close(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
256262
{
257263
assert(env);
@@ -303,9 +309,9 @@ exqlite_close(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
303309
}
304310

305311
///
306-
/// @brief Executes an SQL string.
312+
/// Executes an SQL string.
307313
///
308-
static ERL_NIF_TERM
314+
ERL_NIF_TERM
309315
exqlite_execute(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
310316
{
311317
assert(env);
@@ -336,9 +342,9 @@ exqlite_execute(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
336342
}
337343

338344
///
339-
/// @brief Get the number of changes recently done to the database.
345+
/// Get the number of changes recently done to the database.
340346
///
341-
static ERL_NIF_TERM
347+
ERL_NIF_TERM
342348
exqlite_changes(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
343349
{
344350
assert(env);
@@ -362,9 +368,9 @@ exqlite_changes(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
362368
}
363369

364370
///
365-
/// @brief Prepares an Sqlite3 statement for execution
371+
/// Prepares an Sqlite3 statement for execution
366372
///
367-
static ERL_NIF_TERM
373+
ERL_NIF_TERM
368374
exqlite_prepare(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
369375
{
370376
assert(env);
@@ -425,7 +431,10 @@ raise_badarg(ErlNifEnv* env, ERL_NIF_TERM term)
425431
return enif_raise_exception(env, badarg);
426432
}
427433

428-
static ERL_NIF_TERM
434+
///
435+
/// Reset the prepared statement
436+
///
437+
ERL_NIF_TERM
429438
exqlite_reset(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
430439
{
431440
statement_t* statement;
@@ -437,7 +446,10 @@ exqlite_reset(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
437446
return am_ok;
438447
}
439448

440-
static ERL_NIF_TERM
449+
///
450+
/// Get the bind parameter count
451+
///
452+
ERL_NIF_TERM
441453
exqlite_bind_parameter_count(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
442454
{
443455
statement_t* statement;
@@ -449,7 +461,10 @@ exqlite_bind_parameter_count(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]
449461
return enif_make_int(env, bind_parameter_count);
450462
}
451463

452-
static ERL_NIF_TERM
464+
///
465+
/// Binds a text parameter
466+
///
467+
ERL_NIF_TERM
453468
exqlite_bind_text(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
454469
{
455470
statement_t* statement;
@@ -471,7 +486,10 @@ exqlite_bind_text(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
471486
return enif_make_int(env, rc);
472487
}
473488

474-
static ERL_NIF_TERM
489+
///
490+
/// Binds a blob parameter
491+
///
492+
ERL_NIF_TERM
475493
exqlite_bind_blob(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
476494
{
477495
statement_t* statement;
@@ -493,7 +511,10 @@ exqlite_bind_blob(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
493511
return enif_make_int(env, rc);
494512
}
495513

496-
static ERL_NIF_TERM
514+
///
515+
/// Binds an integer parameter
516+
///
517+
ERL_NIF_TERM
497518
exqlite_bind_integer(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
498519
{
499520
statement_t* statement;
@@ -515,7 +536,10 @@ exqlite_bind_integer(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
515536
return enif_make_int(env, rc);
516537
}
517538

518-
static ERL_NIF_TERM
539+
///
540+
/// Binds a float parameter
541+
///
542+
ERL_NIF_TERM
519543
exqlite_bind_float(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
520544
{
521545
statement_t* statement;
@@ -537,7 +561,10 @@ exqlite_bind_float(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
537561
return enif_make_int(env, rc);
538562
}
539563

540-
static ERL_NIF_TERM
564+
///
565+
/// Binds a null parameter
566+
///
567+
ERL_NIF_TERM
541568
exqlite_bind_null(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
542569
{
543570
statement_t* statement;
@@ -610,7 +637,13 @@ make_row(ErlNifEnv* env, sqlite3_stmt* statement)
610637
return row;
611638
}
612639

613-
static ERL_NIF_TERM
640+
///
641+
/// Steps the sqlite prepared statement multiple times.
642+
///
643+
/// This is to reduce the back and forth between the BEAM and sqlite in
644+
/// fetching data. Without using this, throughput can suffer.
645+
///
646+
ERL_NIF_TERM
614647
exqlite_multi_step(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
615648
{
616649
assert(env);
@@ -671,7 +704,12 @@ exqlite_multi_step(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
671704
return enif_make_tuple2(env, am_rows, rows);
672705
}
673706

674-
static ERL_NIF_TERM
707+
///
708+
/// Invokes one step on the SQLite prepared statement's results. If multiple
709+
/// steps are being taken, throughput may suffer, but this does allow for
710+
/// better interleaved calls to a NIF and letting the VM do more bookkeeping
711+
///
712+
ERL_NIF_TERM
675713
exqlite_step(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
676714
{
677715
assert(env);
@@ -710,7 +748,10 @@ exqlite_step(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
710748
}
711749
}
712750

713-
static ERL_NIF_TERM
751+
///
752+
/// Get the columns requested in a prepared statement
753+
///
754+
ERL_NIF_TERM
714755
exqlite_columns(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
715756
{
716757
assert(env);
@@ -761,7 +802,10 @@ exqlite_columns(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
761802
return make_ok_tuple(env, result);
762803
}
763804

764-
static ERL_NIF_TERM
805+
///
806+
/// Get the last inserted row id.
807+
///
808+
ERL_NIF_TERM
765809
exqlite_last_insert_rowid(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
766810
{
767811
assert(env);
@@ -780,7 +824,10 @@ exqlite_last_insert_rowid(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
780824
return make_ok_tuple(env, enif_make_int64(env, last_rowid));
781825
}
782826

783-
static ERL_NIF_TERM
827+
///
828+
/// Get the current transaction status
829+
///
830+
ERL_NIF_TERM
784831
exqlite_transaction_status(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
785832
{
786833
assert(env);
@@ -808,7 +855,7 @@ exqlite_transaction_status(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
808855
autocommit == 0 ? am_transaction : am_idle);
809856
}
810857

811-
static ERL_NIF_TERM
858+
ERL_NIF_TERM
812859
exqlite_serialize(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
813860
{
814861
assert(env);
@@ -843,7 +890,7 @@ exqlite_serialize(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
843890
return make_ok_tuple(env, serialized);
844891
}
845892

846-
static ERL_NIF_TERM
893+
ERL_NIF_TERM
847894
exqlite_deserialize(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
848895
{
849896
assert(env);
@@ -888,7 +935,11 @@ exqlite_deserialize(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
888935
return am_ok;
889936
}
890937

891-
static ERL_NIF_TERM
938+
///
939+
/// Releases a prepared statement's consumed memory and allows the system to
940+
/// reclaim it.
941+
///
942+
ERL_NIF_TERM
892943
exqlite_release(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
893944
{
894945
assert(env);
@@ -1046,7 +1097,7 @@ on_unload(ErlNifEnv* caller_env, void* priv_data)
10461097
// Enable extension loading
10471098
//
10481099

1049-
static ERL_NIF_TERM
1100+
ERL_NIF_TERM
10501101
exqlite_enable_load_extension(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
10511102
{
10521103
assert(env);
@@ -1073,10 +1124,9 @@ exqlite_enable_load_extension(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[
10731124
return am_ok;
10741125
}
10751126

1076-
//
1077-
// Data Change Notifications
1078-
//
1079-
1127+
///
1128+
/// Data Change Notifications
1129+
///
10801130
void
10811131
update_callback(void* arg, int sqlite_operation_type, char const* sqlite_database, char const* sqlite_table, sqlite3_int64 sqlite_rowid)
10821132
{
@@ -1114,7 +1164,7 @@ update_callback(void* arg, int sqlite_operation_type, char const* sqlite_databas
11141164
enif_free_env(msg_env);
11151165
}
11161166

1117-
static ERL_NIF_TERM
1167+
ERL_NIF_TERM
11181168
exqlite_set_update_hook(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
11191169
{
11201170
assert(env);
@@ -1166,7 +1216,7 @@ log_callback(void* arg, int iErrCode, const char* zMsg)
11661216
enif_free_env(msg_env);
11671217
}
11681218

1169-
static ERL_NIF_TERM
1219+
ERL_NIF_TERM
11701220
exqlite_set_log_hook(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
11711221
{
11721222
assert(env);
@@ -1196,9 +1246,9 @@ exqlite_set_log_hook(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
11961246
}
11971247

11981248
///
1199-
/// @brief Interrupt a long-running query.
1249+
/// Interrupt a long-running query.
12001250
///
1201-
static ERL_NIF_TERM
1251+
ERL_NIF_TERM
12021252
exqlite_interrupt(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
12031253
{
12041254
assert(env);
@@ -1223,7 +1273,7 @@ exqlite_interrupt(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
12231273
return am_ok;
12241274
}
12251275

1226-
static ERL_NIF_TERM
1276+
ERL_NIF_TERM
12271277
exqlite_errmsg(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
12281278
{
12291279
connection_t* conn;
@@ -1244,7 +1294,7 @@ exqlite_errmsg(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
12441294
return make_binary(env, msg, strlen(msg));
12451295
}
12461296

1247-
static ERL_NIF_TERM
1297+
ERL_NIF_TERM
12481298
exqlite_errstr(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
12491299
{
12501300
int rc;

0 commit comments

Comments
 (0)