Re: MySQL search query is not executing in Postgres DB
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Greg Stark <stark@mit.edu>, Bruce Momjian <bruce@momjian.us>, Andrew Dunstan <andrew@dunslane.net>, Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>, premanand <kottiprem@gmail.com>, pgsql-hackers@postgresql.org
Date: 2012-08-29T15:40:36Z
Lists: pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes: > The upshot here appears to be that we're kind of schizophrenic about > what we want. With things like text || anyelement, anyelement || > text, and concat(variadic "any") we are basically asserting that we > want to treat anything that we don't recognize as a string. But then > we have other functions (like max and length) where we don't want that > behavior. I suppose that more than anything this is based on a > perception that || won't be ambiguous (though whether that perception > is entirely correct is debatable, given the array-related meanings of > that operator) but there might be more than one possible sense for > length() or max(). Is there any principled way of distinguishing > these cases, or even a rule for what we ought to do by hand in future > cases of this type, or is it totally arbitrary? I would not claim that the situation around || is principled in any fashion. Rather, || was identified as being a key pain point for the removal of implicit-casts-to-text during 8.3 development, and we agreed we would reduce the pain by adding operators that effectively reintroduced the implicit casts *for that one operator only*. I felt that was still a big step forward compared to implicit casts everywhere. But if we'd been doing this in a green field, I doubt that you'd see text || anyelement or anyelement || text in there. I would vote against introducing more such things in future, on the grounds that there would be no backwards-compatibility argument for it. As for the concat() function, IMO it's an ugly kluge. But again, it's not introducing any global behavior that might have side-effects on the resolution of other function or operator names. >> regression=# select lpad(42,8); >> ERROR: failed to find conversion function from integer to text >> I'm not sure why that's happening, either, but evidently some >> additional coercion laxity would required. > This, however, is a trivial problem; make_fn_arguments just didn't get > the memo that it might now need to look for assignment casts. See > attached. Meh. I'm a bit worried about whether that might have unexpected consequences, too. regards, tom lane