43
43
#define BULK_PACKET_SIZE (5120*1024)
44
44
45
45
/* How many rows to insert before COMMITs (used in bulk insert) */
46
- #define ROWS_BEFORE_COMMIT 1000
46
+ static int ROWS_BEFORE_COMMIT = 1000 ;
47
47
48
48
/* Global variables */
49
49
db_globals_t db_globals CK_CC_CACHELINE ;
@@ -131,7 +131,7 @@ void db_print_help(void)
131
131
log_text (LOG_NOTICE , "General database options:\n" );
132
132
sb_print_options (db_args );
133
133
log_text (LOG_NOTICE , "" );
134
-
134
+
135
135
log_text (LOG_NOTICE , "Compiled-in database drivers:" );
136
136
SB_LIST_FOR_EACH (pos , & drivers )
137
137
{
@@ -841,7 +841,7 @@ int db_parse_arguments(void)
841
841
db_globals .driver = sb_get_value_string ("db-driver" );
842
842
843
843
db_globals .debug = sb_get_value_flag ("db-debug" );
844
-
844
+
845
845
return 0 ;
846
846
}
847
847
@@ -859,7 +859,7 @@ int db_print_value(db_bind_t *var, char *buf, int buflen)
859
859
n = snprintf (buf , buflen , "NULL" );
860
860
return (n < buflen ) ? n : -1 ;
861
861
}
862
-
862
+
863
863
switch (var -> type ) {
864
864
case DB_TYPE_TINYINT :
865
865
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)
955
955
con -> bulk_buffer = (char * )malloc (con -> bulk_buflen );
956
956
if (con -> bulk_buffer == NULL )
957
957
return 1 ;
958
-
958
+
959
+ ROWS_BEFORE_COMMIT = atoi (getenv ("ROWS_BEFORE_COMMIT" )?:"1000" );
960
+
959
961
con -> bulk_commit_max = driver_caps .needs_commit ? ROWS_BEFORE_COMMIT : 0 ;
960
962
con -> bulk_commit_cnt = 0 ;
961
963
strcpy (con -> bulk_buffer , query );
0 commit comments