Re: json/jsonb/hstore operator precedence

Поиск
Список
Период
Сортировка
От Andrew Dunstan
Тема Re: json/jsonb/hstore operator precedence
Дата
Msg-id 533B38AE.80008@dunslane.net
обсуждение исходный текст
Ответ на Re: json/jsonb/hstore operator precedence  (Jim Nasby <jim@nasby.net>)
Список pgsql-hackers
On 04/01/2014 05:42 PM, Jim Nasby wrote:
> On 4/1/14, 3:07 PM, Andrew Dunstan wrote:
>>> What are cases where things would break if we changed the precedence 
>>> of -> and ->>? ISTM that's what we really should do if there's some 
>>> way to manage the backwards compatibility...
>>
>>
>> There is no provision for setting the precedence of any operators. 
>> The precedence is set in the grammar, and these all have the same 
>> precedence. What you're suggesting would a cure far worse than the 
>> disease, I strongly suspect. You just need to learn to live with this.
>>
>> What really bugs me about the example is that <> has a different 
>> precedence from =, which seems more than odd. The example works just 
>> fine if you use = instead of <>. But I guess it's been that way for a 
>> very long time and there's not much to be done about it.
>
> I'm confused... first you say there's no precedence and then you're 
> saying that there is? Which is it?

No I didn't say there was no precedence. Please reread what I said. I 
said there was no provision for setting the precedence. There is 
precedence of course, but it's hardcoded.

>
> ISTM that most languages set the priority of de-referencing operators 
> to be quite high, so I don't see how that would be a disaster?

The way the grammar works ALL the composite operators have the same 
precedence. It has no notion that -> is a dereference operator. You're 
suggesting something without actually looking at the code. Look at 
gram.y and scan.l and you might understand.

>
> Of course, changing the precedence of = and <> certainly would be a 
> disaster; I'm not suggesting that.

There is arguably nothing wrong with the precedence of -> and ->>. The 
reason for the problem Greg reported is that <> probably has its 
precedence set too low. And no, we can't change it.

cheers

andrew






В списке pgsql-hackers по дате отправления:

Предыдущее
От: Jim Nasby
Дата:
Сообщение: Re: json/jsonb/hstore operator precedence
Следующее
От: Merlin Moncure
Дата:
Сообщение: Re: using arrays within structure in ECPG