Thread: Associative Operators? (Was: Re: [NOVICE] Out of frying pan, into fire)
Seth McQuale pointed out that the follwing does not work: SELECT LASTNAME || ',' || FIRSTNAME [AS] NAME FROM FRIENDS; The solution, was: SELECT ( LASTNAME || ',' ) || FIRSTNAME AS NAME FROM FRIENDS; I looked at pg_operator and didn't see any flag to mark an operator as 'associative'. Perhaps if we added a flag like this, the re-write system could be modified to handle cases like this. Thoughts? Clark Evans
Re: [HACKERS] Associative Operators? (Was: Re: [NOVICE] Out of frying pan, into fire)
From
Bruce Momjian
Date:
> Seth McQuale pointed out that the follwing does not work: > SELECT LASTNAME || ',' || FIRSTNAME [AS] NAME FROM FRIENDS; > > The solution, was: > SELECT ( LASTNAME || ',' ) || FIRSTNAME AS NAME FROM FRIENDS; > > I looked at pg_operator and didn't see any flag to mark > an operator as 'associative'. Perhaps if we added a flag > like this, the re-write system could be modified to handle > cases like this. > > Thoughts? > > Clark Evans > > My guess is that we should auto-left-associate functions like || if no parens are present. It would be a small change to the parser. -- Bruce Momjian | http://www.op.net/~candle maillist@candle.pha.pa.us | (610) 853-3000+ If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania19026
Re: [HACKERS] Associative Operators? (Was: Re: [NOVICE] Out of frying pan, into fire)
From
Clark Evans
Date:
Bruce Momjian wrote: > > My guess is that we should auto-left-associate functions like || if no > parens are present. It would be a small change to the parser. I was trying to describe a more general solution, where the operator is marked if it is associative when it is created. This would allow the same mechanism to be used for user defined types. :) Clark
Re: [HACKERS] Associative Operators? (Was: Re: [NOVICE] Out of frying pan, into fire)
From
"D'Arcy" "J.M." Cain
Date:
Thus spake Bruce Momjian > > I looked at pg_operator and didn't see any flag to mark > > an operator as 'associative'. Perhaps if we added a flag > > like this, the re-write system could be modified to handle > > cases like this. > > My guess is that we should auto-left-associate functions like || if no > parens are present. It would be a small change to the parser. And wouldn't require a dump/reload. -- D'Arcy J.M. Cain <darcy@{druid|vex}.net> | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 424 2871 (DoD#0082) (eNTP) | what's for dinner.
Re: [HACKERS] Associative Operators? (Was: Re: [NOVICE] Out of frying pan, into fire)
From
Clark Evans
Date:
"D'Arcy J.M. Cain" wrote: > And wouldn't require a dump/reload. Why would this require a dump/reload? It would seem to me that this would only be needed if you changed the database storage system? Am I missing something? Clark
Re: [HACKERS] Associative Operators? (Was: Re: [NOVICE] Out of frying pan, into fire)
From
Clark Evans
Date:
"D'Arcy J.M. Cain" wrote: > And wouldn't require a dump/reload. Ooh. If you change pg_operators and add a column. Ok. For the new version, don't they have to do this anyway? Clark
Re: [HACKERS] Associative Operators? (Was: Re: [NOVICE] Out of frying pan, into fire)
From
Bruce Momjian
Date:
This is fixed in 6.5 beta. > Seth McQuale pointed out that the follwing does not work: > SELECT LASTNAME || ',' || FIRSTNAME [AS] NAME FROM FRIENDS; > > The solution, was: > SELECT ( LASTNAME || ',' ) || FIRSTNAME AS NAME FROM FRIENDS; > > I looked at pg_operator and didn't see any flag to mark > an operator as 'associative'. Perhaps if we added a flag > like this, the re-write system could be modified to handle > cases like this. > > Thoughts? > > Clark Evans > > -- Bruce Momjian | http://www.op.net/~candle maillist@candle.pha.pa.us | (610) 853-3000+ If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania19026