Skip to content

Commit

Permalink
fixed: fix mysql compatability when creating triggers with BEGIN and …
Browse files Browse the repository at this point in the history
…END keywords. see xbmc#10301.

git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@34276 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
  • Loading branch information
firnsy committed Sep 28, 2010
1 parent f90b5f5 commit e78a94c
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions xbmc/lib/sqLite/mysqldataset.cpp
Expand Up @@ -1214,11 +1214,24 @@ int MysqlDataset::exec(const string &sql) {
exec_res.clear();

// enforce the "auto_increment" keyword to be appended to "integer primary key"
const char* toFind = "integer primary key";
size_t loc = qry.find(toFind);
if (loc != string::npos)
size_t loc;
if ( (loc=qry.find("integer primary key")) != string::npos)
{
qry = qry.insert(loc + strlen(toFind), " auto_increment ");
qry = qry.insert(loc + 19, " auto_increment ");
}

// sqlite3 requires the BEGIN and END pragmas when creating triggers. mysql does not.
if ( qry.find("CREATE TRIGGER") != string::npos )
{
if ( (loc=qry.find("BEGIN ")) != string::npos )
{
qry.replace(loc, 6, "");
}

if ( (loc=qry.find(" END")) != string::npos )
{
qry.replace(loc, 4, "");
}
}

CLog::Log(LOGDEBUG,"Mysql execute: %s", qry.c_str());
Expand Down

0 comments on commit e78a94c

Please sign in to comment.