[Development] SQLite "tuning"

Jordi Pujol pisoengracia at gmail.com
Fri Aug 17 10:12:05 CEST 2012


El dv 17 de 08 de 2012 a les 09:47 +0200, en/na Thiago Macieira va
escriure:
> On sexta-feira, 17 de agosto de 2012 08.30.21, Jordi Pujol wrote:
> > Hi all,
> > 
> > Recently I've had the need to extend sqlite by adding some math
> > functions. I discovered that, by design and due to security reasons,
> > SQLite is compiled in Qt with extensions fully deactivated.
> > 
> > It's a little bit annoying to be forced to recompile the plugin driver
> > if I want to use a very useful feature, so I've made a little patch to
> > allow activation with a new connection option in SQLite :
> > "QSQLITE_ENABLE_LOAD_EXTENSIONS".
> > 
> > Do you think this can be useful for the community ? It's worth to spend
> > any time to integrate this into the repository ? Will it be refused
> > because its potential "security hole" ?
> 
> Is the patch necessary when using a system sqlite?

Not necessary but very useful ( assuming system SQlite is not also
limited, of course ). Adding this connection option you avoid this code
every time you create an sqlite DB :

QVariant v = db.driver()->handle();
if (v.isValid() && qstrcmp(v.typeName(), "sqlite3*")==0) 
{
  sqlite3 *handle = *static_cast<sqlite3 **>(v.data());
  if (handle != 0)
    sqlite3_enable_load_extension(handle,1);
}

And you don't have the need to link with sqlite code ( it's inside qt
library / sqlite plugin ).

Instead of that lines of code, you only have to put this one :

db.setConnectionOptions ( "QSQLITE_ENABLE_LOAD_EXTENSIONS=1" );

Nice, isn't it ?

	Jordi.




More information about the Development mailing list