[TYPO3-core] RFC #14818: Performance: Use mysql find_in_set-function in t3lib_db->listQuery()

Xavier Perseguers typo3 at perseguers.ch
Sat Jul 17 10:11:39 CEST 2010


Hi Ernesto,

> could you explain a bit this DBAL diff?
>
> http://forge.typo3.org/projects/extension-dbal/repository/revisions/35742/diff

Actually this post is more related to FYI #14985 but both of them are 
related to each other, you're right.

> The whole "switch (TRUE)" case with nested if ($functionMapping) and
> purposedly missing breaks is a bit confusing if not misleading.

You're right. It has the same structure as many other places but in fact 
it could probably be rewritten with standard "if" and become more clear.

> Since I don't understand it well, I cannot propose a patch to solve it,
> but maybe you understand my trouble in understanding it and find a
> solution for that part of the code? I would be thankful! :)

Will have a look at that!

> And maybe also explain the $functionMapping argument that is available
> in several functions?

I'm not sure if I should explain this stuff here, actually it is part of 
the fact that DBAL is not very... well... quick :-) $functionMapping 
tells the parser whether MySQL functions should be mapped onto their 
corresponding function for another DBMS. For instance whether LOCATE 
should be rewritten as CHARINDEX or INSTR for another DBMS or whether it 
should (for the time being) be left as this ($functionMapping = FALSE). 
And that's the part I could love a bit more but...

In DBAL it does this _when mapping is needed_ (Oracle for instance):

In exec_SELECTquery

$this->map_remapSELECTQueryParts($select_fields, ...)

which in turn parses all parts ($select, $from, $where, ...), remap 
field names and recreate as _string_ the different parts as if the 
developer had already written the query with remapped names. Then as 
usual in SELECTquery:

$select_fields = $this->quoteFieldNames($select_fields);
$from_table = $this->quoteFromTables($from_table);
$where_clause = $this->quoteWhereClause($where_clause);
$groupBy = $this->quoteGroupBy($groupBy);
$orderBy = $this->quoteOrderBy($orderBy);

And within quote* it parses the parts, quote the identifiers and 
recompose the query string.

Meaning that if we need mapping for table/field names and we already 
replace the functions such as LOCATE or FIND_IN_SET with their 
equivalent the first time we parse the string, the SQL parser won't be 
able to parse the query the second time unless we add support for 
non-MySQL SQL in Core's SQL... This is why there is this 
$functionMapping flag...

Hope the idea is a bit more clear...

Xavier


More information about the TYPO3-team-core mailing list