[Owncloud] oracle support

Jörn Friedrich Dreyer jfd at owncloud.com
Mon Jul 23 18:12:07 UTC 2012


The problem: Oracle up-cases identifiers in queries that have not been 
quoted:

SELECT user FROM oc_fscache

becomes

SELECT USER FROM OC_FSCACHE;

This causes problems as some of our queries use quotes and some don't, 
resulting in strange errors where oracle dies on comparing strings with 
integers ... yeah, welcome to debugging hell.

I already tried removing back ticks in OC_DB::processQuery() and setting 
'quote_identifier' = false for MDB2.  The idea was to use oracles 
automatic uppercase conversion. MDB2 would not quote table names and 
columns and oracle would create them up-cased. PDO statements would be 
stripped of quotes and no further modifications would have been 
necessary. Unfortunately, Oracle disallows the use of some registered 
words like 'USER', 'SIZE', 'UID', and maybe others we use as column names.

The only other viable option I now see is forcing the use of back ticks 
and lowercase for table AND column names. Not only when creating the 
database with MDB2 (which is already the case) but in all queries. 
Lowercase versions of user, uid and size do not collide with Oracle 
reserved words. OC_DB::processQuery() can then change the quotation if 
needed before executing a query with PDO. So, the general way things 
work would not change. However, I would need to fix at least 248 matches 
of ' *PREFIX*' and even more occurances of unescaped column names. In 
the future we might add a code smell for unescaped SQL identifiers in 
our CI server (hint hint ... this is a very good use case for CI by the 
way).

I admit that adding backticks seems superflous and to my personal taste 
even hinders readability, but I don't see another sane solution to 
support oracle.

Maybe someone of you does?

so long

Jörn

-- 
Jörn Friedrich Dreyer (jfd at owncloud.com)
Software Developer
ownCloud GmbH

Your Data, Your Cloud, Your Way!

ownCloud GmbH, GF: Markus Rex, Holger Dyroff
Schloßäckerstrasse 26a, 90443 Nürnberg, HRB 28050 (AG Nürnberg)




More information about the Owncloud mailing list