@@ -48,6 +48,10 @@ PERFORMANCE OF THIS SOFTWARE.
48
48
#define HAVE_MYSQL_SERVER_PUBLIC_KEY
49
49
#endif
50
50
51
+ #if !defined(MARIADB_VERSION_ID ) && MYSQL_VERSION_ID >= 80021
52
+ #define HAVE_MYSQL_OPT_LOCAL_INFILE_DIR
53
+ #endif
54
+
51
55
#define PY_SSIZE_T_CLEAN 1
52
56
#include "Python.h"
53
57
@@ -436,7 +440,7 @@ _mysql_ConnectionObject_Initialize(
436
440
"client_flag" , "ssl" , "ssl_mode" ,
437
441
"local_infile" ,
438
442
"read_timeout" , "write_timeout" , "charset" ,
439
- "auth_plugin" , "server_public_key_path" ,
443
+ "auth_plugin" , "server_public_key_path" , "local_infile_dir" ,
440
444
NULL } ;
441
445
int connect_timeout = 0 ;
442
446
int read_timeout = 0 ;
@@ -448,14 +452,15 @@ _mysql_ConnectionObject_Initialize(
448
452
* read_default_group = NULL ,
449
453
* charset = NULL ,
450
454
* auth_plugin = NULL ,
451
- * server_public_key_path = NULL ;
455
+ * server_public_key_path = NULL ,
456
+ * local_infile_dir = NULL ;
452
457
453
458
self -> converter = NULL ;
454
459
self -> open = false;
455
460
self -> reconnect = false;
456
461
457
462
if (!PyArg_ParseTupleAndKeywords (args , kwargs ,
458
- "|ssssisOiiisssiOsiiisss :connect" ,
463
+ "|ssssisOiiisssiOsiiissss :connect" ,
459
464
kwlist ,
460
465
& host , & user , & passwd , & db ,
461
466
& port , & unix_socket , & conv ,
@@ -469,7 +474,8 @@ _mysql_ConnectionObject_Initialize(
469
474
& write_timeout ,
470
475
& charset ,
471
476
& auth_plugin ,
472
- & server_public_key_path
477
+ & server_public_key_path ,
478
+ & local_infile_dir
473
479
))
474
480
return -1 ;
475
481
@@ -479,6 +485,13 @@ _mysql_ConnectionObject_Initialize(
479
485
return -1 ;
480
486
}
481
487
#endif
488
+
489
+ #ifndef HAVE_MYSQL_OPT_LOCAL_INFILE_DIR
490
+ if (local_infile_dir ) {
491
+ PyErr_SetString (_mysql_NotSupportedError , "local_infile_dir is not supported" );
492
+ return -1 ;
493
+ }
494
+ #endif
482
495
// For compatibility with PyPy, we need to keep strong reference
483
496
// to unicode objects until we use UTF8.
484
497
#define _stringsuck (d ,t ,s ) {t=PyMapping_GetItemString(s,#d);\
@@ -599,6 +612,12 @@ _mysql_ConnectionObject_Initialize(
599
612
}
600
613
#endif
601
614
615
+ #ifdef HAVE_MYSQL_OPT_LOCAL_INFILE_DIR
616
+ if (local_infile_dir ) {
617
+ mysql_options (& (self -> connection ), MYSQL_OPT_LOAD_DATA_LOCAL_DIR , local_infile_dir );
618
+ }
619
+ #endif
620
+
602
621
Py_BEGIN_ALLOW_THREADS
603
622
conn = mysql_real_connect (& (self -> connection ), host , user , passwd , db ,
604
623
port , unix_socket , client_flag );
0 commit comments