mirror of
https://github.com/mariadb-corporation/mariadb-connector-python.git
synced 2025-08-04 08:04:45 +00:00
Fixed bug in pooling tests:
Paraneters in set_config() method have to be checked against the list of DSN keywords.
This commit is contained in:
@ -276,6 +276,7 @@ typedef struct {
|
|||||||
unsigned long max_len;
|
unsigned long max_len;
|
||||||
} Mariadb_Conversion;
|
} Mariadb_Conversion;
|
||||||
|
|
||||||
|
extern char *dsn_keys[];
|
||||||
|
|
||||||
/* Exceptions */
|
/* Exceptions */
|
||||||
extern PyObject *Mariadb_InterfaceError;
|
extern PyObject *Mariadb_InterfaceError;
|
||||||
|
@ -20,6 +20,20 @@
|
|||||||
#include "mariadb_python.h"
|
#include "mariadb_python.h"
|
||||||
#include "docs/connection.h"
|
#include "docs/connection.h"
|
||||||
|
|
||||||
|
char *dsn_keys[]= {
|
||||||
|
"dsn", "host", "user", "password", "database", "port", "unix_socket",
|
||||||
|
"connect_timeout", "read_timeout", "write_timeout",
|
||||||
|
"local_infile", "compress", "init_command",
|
||||||
|
"default_file", "default_group",
|
||||||
|
"ssl_key", "ssl_ca", "ssl_cert", "ssl_crl",
|
||||||
|
"ssl_cipher", "ssl_capath", "ssl_crlpath",
|
||||||
|
"ssl_verify_cert", "ssl",
|
||||||
|
"client_flags", "pool_name", "pool_size",
|
||||||
|
"pool_reset_connection", "plugin_dir",
|
||||||
|
"username", "db", "password",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
MrdbConnection_dealloc(MrdbConnection *self);
|
MrdbConnection_dealloc(MrdbConnection *self);
|
||||||
|
|
||||||
@ -288,21 +302,6 @@ MrdbConnection_Initialize(MrdbConnection *self,
|
|||||||
unsigned int connect_timeout=0, read_timeout=0, write_timeout=0,
|
unsigned int connect_timeout=0, read_timeout=0, write_timeout=0,
|
||||||
compress= 0, ssl_verify_cert= 0;
|
compress= 0, ssl_verify_cert= 0;
|
||||||
|
|
||||||
char *dsn_keys[]= {
|
|
||||||
"dsn", "host", "user", "password", "database", "port", "unix_socket",
|
|
||||||
"connect_timeout", "read_timeout", "write_timeout",
|
|
||||||
"local_infile", "compress", "init_command",
|
|
||||||
"default_file", "default_group",
|
|
||||||
"ssl_key", "ssl_ca", "ssl_cert", "ssl_crl",
|
|
||||||
"ssl_cipher", "ssl_capath", "ssl_crlpath",
|
|
||||||
"ssl_verify_cert", "ssl",
|
|
||||||
"client_flags", "pool_name", "pool_size",
|
|
||||||
"pool_reset_connection", "plugin_dir",
|
|
||||||
"username", "db", "password",
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, dsnargs,
|
if (!PyArg_ParseTupleAndKeywords(args, dsnargs,
|
||||||
"|sssssisiiibbssssssssssipisibssss:connect",
|
"|sssssisiiibbssssssssssipisibssss:connect",
|
||||||
dsn_keys,
|
dsn_keys,
|
||||||
|
@ -415,10 +415,21 @@ static PyObject
|
|||||||
while(PyDict_Next(kwargs, &pos, &key, &value))
|
while(PyDict_Next(kwargs, &pos, &key, &value))
|
||||||
{
|
{
|
||||||
const char *utf8key= PyUnicode_AsUTF8(key);
|
const char *utf8key= PyUnicode_AsUTF8(key);
|
||||||
if (!strncmp(utf8key, "pool", 4))
|
uint8_t i=0, found=0;
|
||||||
|
|
||||||
|
while (dsn_keys[i])
|
||||||
|
{
|
||||||
|
if (!strcmp(utf8key, dsn_keys[i]))
|
||||||
|
{
|
||||||
|
found= 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if (!found)
|
||||||
{
|
{
|
||||||
mariadb_throw_exception(NULL, Mariadb_PoolError, 0,
|
mariadb_throw_exception(NULL, Mariadb_PoolError, 0,
|
||||||
"Invalid parameter '%s'. Only DSN parameters are supported",
|
"Invalid DSN parameter '%s'",
|
||||||
utf8key);
|
utf8key);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user