Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/mysql/MySQL.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module MySQL {
use Map;
use SysCTypes;
use MySQLNative;

use Regexp;
/*
Enum that describes the data type held by a field in MySQL.
Note: MySQL uses TINYINT(1) internally for the BOOLEAN
Expand Down Expand Up @@ -99,7 +99,7 @@ module MySQL {
var database: string;
var username: string;
var password: string;

var myRegexp = compile("[[:space:]]*");
// let's extract the relevant info from the connection string
for (i, str) in zip(0.., connectionString.split(';')) {
select i {
Expand All @@ -112,10 +112,13 @@ module MySQL {
}

// Throw errors if anything wrong: (TODO: can be improved)
if (host == '' || database == '') {
var host_match = myRegexp.match(host).matched;
var db_match = myRegexp.match(database).matched;
if (host_match || db_match){
throw new ConnectionStringFormatError();
}


this._autocommit = autocommit;
this._prev_autocommit_state = autocommit;
this._cptr_mysqlconn = mysql_init(this._cptr_mysqlconn);
Expand Down