Hi *,

for reference all of this started when I tried to make

SpecialExpressionTranslator.TranslateConcat()

do its work and use String.Concat on the operands instead of using an
addition after adding a special case for the addition in the
ExpressionDispatcher.Analyzer to make sure PostgreSQL receives "||" and
not just a "+" for string concatenation. It worked but Shamar (that
applied my patch posted on this list some weeks ago) reported other
failing tests.

I traced back the failures to the way the C# compiler creates LINQ
expressions from lambdas. Here is an example (using an abbreviated
notation I hope needs no explanation):

obj.x + 1 // where obj.x is a String

gets converted to:

ADD(MEMBERACCES(obj, x), CONVERT(typeof(Object), 1))

The bad bad bad part is the convert to Object that will allow the
compiler to later (on .Compile()) transform that expression to:

String.Concat((Object)obj.x, (Object)1)

Why bad bad bad? Because some methods in the expression analyzer are
confused by the type (Object) of the convert operation. And are
especially confused by _different_ types on the two operands for
operators that expect the same type (like "+") for which a second
convert operation (to String this time) is NOT generated even if
required.

The current fix (that fixes PostgreSQL problems and the regressions
reported by Shamar) is to analyze the expression and unwrap the inner
Convert and add the correct (usually to String) one.

I still don't have a clean patch for this but I'd like to have comments
from the people that understand how the whole expression analyzer and
dispatcher is supposed to work (especially, I don't understand why some
bugs I am trying to fix don't show under MSQL).

federico

-- 
Federico Di Gregorio                         http://people.initd.org/fog
Debian GNU/Linux Developer                                [email protected]
INIT.D Developer                                           [email protected]
 Everything will be OK at the end. If it's not OK, it's not the end.
                                                              -- Unknown

Attachment: signature.asc
Description: Questa รจ una parte del messaggio firmata digitalmente

Reply via email to