Skip to content

Commit c48345f

Browse files
committed
Add env var ROWS_BEFORE_COMMIT (default = 1000).
1 parent 8250919 commit c48345f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/db_driver.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
#define BULK_PACKET_SIZE (5120*1024)
4444

4545
/* How many rows to insert before COMMITs (used in bulk insert) */
46-
#define ROWS_BEFORE_COMMIT 1000
46+
static int ROWS_BEFORE_COMMIT = 1000;
4747

4848
/* Global variables */
4949
db_globals_t db_globals CK_CC_CACHELINE;
@@ -131,7 +131,7 @@ void db_print_help(void)
131131
log_text(LOG_NOTICE, "General database options:\n");
132132
sb_print_options(db_args);
133133
log_text(LOG_NOTICE, "");
134-
134+
135135
log_text(LOG_NOTICE, "Compiled-in database drivers:");
136136
SB_LIST_FOR_EACH(pos, &drivers)
137137
{
@@ -841,7 +841,7 @@ int db_parse_arguments(void)
841841
db_globals.driver = sb_get_value_string("db-driver");
842842

843843
db_globals.debug = sb_get_value_flag("db-debug");
844-
844+
845845
return 0;
846846
}
847847

@@ -859,7 +859,7 @@ int db_print_value(db_bind_t *var, char *buf, int buflen)
859859
n = snprintf(buf, buflen, "NULL");
860860
return (n < buflen) ? n : -1;
861861
}
862-
862+
863863
switch (var->type) {
864864
case DB_TYPE_TINYINT:
865865
n = snprintf(buf, buflen, "%hhd", *(char *)var->buffer);
@@ -955,7 +955,9 @@ int db_bulk_insert_init(db_conn_t *con, const char *query, size_t query_len)
955955
con->bulk_buffer = (char *)malloc(con->bulk_buflen);
956956
if (con->bulk_buffer == NULL)
957957
return 1;
958-
958+
959+
ROWS_BEFORE_COMMIT = atoi(getenv("ROWS_BEFORE_COMMIT")?:"1000");
960+
959961
con->bulk_commit_max = driver_caps.needs_commit ? ROWS_BEFORE_COMMIT : 0;
960962
con->bulk_commit_cnt = 0;
961963
strcpy(con->bulk_buffer, query);

0 commit comments

Comments
 (0)