Thread: Associative Operators? (Was: Re: [NOVICE] Out of frying pan, into fire)

Associative Operators? (Was: Re: [NOVICE] Out of frying pan, into fire)

From
Clark Evans
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


> 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
 


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.


"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


"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


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