@@ -48,6 +48,10 @@ PERFORMANCE OF THIS SOFTWARE.
4848#define HAVE_MYSQL_SERVER_PUBLIC_KEY
4949#endif
5050
51+ #if !defined(MARIADB_VERSION_ID ) && MYSQL_VERSION_ID >= 80021
52+ #define HAVE_MYSQL_OPT_LOCAL_INFILE_DIR
53+ #endif
54+
5155#define PY_SSIZE_T_CLEAN 1
5256#include "Python.h"
5357
@@ -436,7 +440,7 @@ _mysql_ConnectionObject_Initialize(
436440 "client_flag" , "ssl" , "ssl_mode" ,
437441 "local_infile" ,
438442 "read_timeout" , "write_timeout" , "charset" ,
439- "auth_plugin" , "server_public_key_path" ,
443+ "auth_plugin" , "server_public_key_path" , "local_infile_dir" ,
440444 NULL } ;
441445 int connect_timeout = 0 ;
442446 int read_timeout = 0 ;
@@ -448,14 +452,15 @@ _mysql_ConnectionObject_Initialize(
448452 * read_default_group = NULL ,
449453 * charset = NULL ,
450454 * auth_plugin = NULL ,
451- * server_public_key_path = NULL ;
455+ * server_public_key_path = NULL ,
456+ * local_infile_dir = NULL ;
452457
453458 self -> converter = NULL ;
454459 self -> open = false;
455460 self -> reconnect = false;
456461
457462 if (!PyArg_ParseTupleAndKeywords (args , kwargs ,
458- "|ssssisOiiisssiOsiiisss :connect" ,
463+ "|ssssisOiiisssiOsiiissss :connect" ,
459464 kwlist ,
460465 & host , & user , & passwd , & db ,
461466 & port , & unix_socket , & conv ,
@@ -469,7 +474,8 @@ _mysql_ConnectionObject_Initialize(
469474 & write_timeout ,
470475 & charset ,
471476 & auth_plugin ,
472- & server_public_key_path
477+ & server_public_key_path ,
478+ & local_infile_dir
473479 ))
474480 return -1 ;
475481
@@ -479,6 +485,13 @@ _mysql_ConnectionObject_Initialize(
479485 return -1 ;
480486 }
481487#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
482495 // For compatibility with PyPy, we need to keep strong reference
483496 // to unicode objects until we use UTF8.
484497#define _stringsuck (d ,t ,s ) {t=PyMapping_GetItemString(s,#d);\
@@ -599,6 +612,12 @@ _mysql_ConnectionObject_Initialize(
599612 }
600613#endif
601614
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+
602621 Py_BEGIN_ALLOW_THREADS
603622 conn = mysql_real_connect (& (self -> connection ), host , user , passwd , db ,
604623 port , unix_socket , client_flag );
0 commit comments