
Dear hackers,

Would it hurt anybody if operator == is made a synonym for operator =?
as != is a synonum for <>, it would make sense.

If it does not hurt, should it be implemented by replicating pg_operator
entries, or would a backend modification be ok? Operator != is NOT in
pg_operator, so it must be dealt with in the backend. I would prefer
a backend solution, so that == is also always =.

-- 
Fabien Coelho - coelho@cri.ensmp.fr

Wed, 7 Apr 2004 09:36:29 +0200 (CEST)
Fabien COELHO <coelho@cri.ensmp.fr>
make == as = ?
Fabien COELHO wrote:
> Would it hurt anybody if operator == is made a synonym for operator

Yes, people would be induced to write incorrect code.

> =? as != is a synonum for <>, it would make sense.

That was never such a terribly good idea, IMHO.  It might have gotten 
carried over from PostQUEL.


Wed, 7 Apr 2004 10:20:55 +0200
Peter Eisentraut <peter_e@gmx.net>
Re: make == as = ?
On Wed, 7 Apr 2004, Peter Eisentraut wrote:

> > =? as != is a synonum for <>, it would make sense.
> 
> That was never such a terribly good idea, IMHO.

Agreed. Compilers should give errors and not try to work around bad code.
Had the first generation of browsers done that we would have had a much
nicer web today.

It would be useful with some flag/variable to set that makes pg generate
varnings for non standard constructs. Unfortunatly there are so many
things that are non standard, still using != instead of <> could be a
usable warning.

-- 
/Dennis Bjï¿½rklund


Wed, 7 Apr 2004 10:30:31 +0200 (CEST)
Dennis Bjorklund <db@zigo.dhs.org>
Re: make == as = ?

> > > =? as != is a synonum for <>, it would make sense.
> >
> > That was never such a terribly good idea, IMHO.
>
> Agreed. Compilers should give errors and not try to work around bad code.

Is it bad code? Not for people who come from a C/C++/Java background.
They are used to operators such as == !=  % && || !... Some of these
are available from pg, some are not, so at the time it is incoherent.

Also, I would not like == to mean anything but =, as any other meaning
would be quite error prone to users with a C background.

PostgreSQL is really extensible wrt operators, and I'm not that sure
it is so bad an idea to support "C" flavor operators.

> It would be useful with some flag/variable to set that makes pg generate
> varnings for non standard constructs. Unfortunatly there are so many
> things that are non standard, still using != instead of <> could be a
> usable warning.

You can have two policy. Either you're cool and homogeneous, or either
you're strict. At the time, postgreSQL is rather cool in some place:
!= and <>, ~~ and LIKE... and a little bit inhomogeneous.

-- 
Fabien.

Wed, 7 Apr 2004 11:28:06 +0200 (CEST)
Fabien COELHO <coelho@cri.ensmp.fr>
Re: make == as = ?
On Wed, 7 Apr 2004, Fabien COELHO wrote:

> Is it bad code? Not for people who come from a C/C++/Java background.

It's not the sql operator.

Every week I meet MySql people that want to port their application to
another database and run into problems because they use some mysql
construct instead of the standard sql construct. I fail to see it as a
good thing for pg to add more non standard constructs where that standard
works fine. Extensions for things that are hard/impossible to do with
standard sql is a different thing (but should still be done with care).

If people want it I'd rather have them create the operators themself. 
That's my view.

-- 
/Dennis Bjï¿½rklund


Wed, 7 Apr 2004 11:34:13 +0200 (CEST)
Dennis Bjorklund <db@zigo.dhs.org>
Re: make == as = ?

> > Is it bad code? Not for people who come from a C/C++/Java background.
>
> It's not the sql operator.

Yes.


> Every week I meet MySql people that want to port their application to
> another database and run into problems because they use some mysql
> construct instead of the standard sql construct. I fail to see it as a
> good thing for pg to add more non standard constructs where that
> standard works fine. Extensions for things that are hard/impossible to
> do with standard sql is a different thing (but should still be done with
> care).

If you want to promote postgreSQL, then it should be good that anything
from outside (whether standard or not) can work with postgreSQL, but
anything that work in pg may not work outside;-)

This pseudo portability strategy is used by Oracle, IBM, M$ or mysql...
That makes you're clients stay with you longer;-) So usually it is a
success...

semi joke: I was not aware that there is such a thing as an SQL standard.
I have the O'Reilly book about SQL, which declines *every* command for
SQL Server, Oracle, MySQL, PostgreSQL...


> If people want it I'd rather have them create the operators themself.

Sure, it is possible to do it so. But if it is in the default
installation, it would help me;-)

 From my point of view, my students come from a java first course, so they
have to learn again some new syntax and new operators. Small stuff, but
it can help to say "same as java" and go on to new concepts.

Also, if I add some new operators in pg_operator, say && for AND, I'm not
sure the optimiser will know that is a AND and take that into account.


> That's my view.

Yep.

-- 
Fabien Coelho - coelho@cri.ensmp.fr

Wed, 7 Apr 2004 11:56:16 +0200 (CEST)
Fabien COELHO <coelho@cri.ensmp.fr>
Re: make == as = ?
On Wed, 7 Apr 2004, Fabien COELHO wrote:

> From my point of view, my students come from a java first course, so they
> have to learn again some new syntax and new operators. Small stuff, but
> it can help to say "same as java" and go on to new concepts.

Don't you want them to learn SQL?

-- 
/Dennis Bjï¿½rklund


Wed, 7 Apr 2004 11:58:31 +0200 (CEST)
Dennis Bjorklund <db@zigo.dhs.org>
Re: make == as = ?

> > From my point of view, my students come from a java first course, so they
> > have to learn again some new syntax and new operators. Small stuff, but
> > it can help to say "same as java" and go on to new concepts.
>
> Don't you want them to learn SQL?

I want to teach them the concepts: relations, views, relationnal algebra,
aggregation and so on, and how to build a resonnable schema from a
real-world problem.

I do not consider whether the comparison is == or = as a key issue.

Moreover, there are many SQL flavors around, so whatever the detailed
syntax I learn them, it won't be the one they will have to face if the
database they use is different. So why bother?

That's just my view.

-- 
Fabien Coelho - coelho@cri.ensmp.fr

Wed, 7 Apr 2004 12:05:21 +0200 (CEST)
Fabien COELHO <coelho@cri.ensmp.fr>
Re: make == as = ?
Fabien COELHO wrote:

>>>From my point of view, my students come from a java first course, so they
>>>have to learn again some new syntax and new operators. Small stuff, but
>>>it can help to say "same as java" and go on to new concepts.
>>>      
>>>
>>Don't you want them to learn SQL?
>>    
>>
>
>I want to teach them the concepts: relations, views, relationnal algebra,
>aggregation and so on, and how to build a resonnable schema from a
>real-world problem.
>
>I do not consider whether the comparison is == or = as a key issue.
>
>Moreover, there are many SQL flavors around, so whatever the detailed
>syntax I learn them, it won't be the one they will have to face if the
>database they use is different. So why bother?
>
>That's just my view.
>
>  
>

My sister is a teacher - she has a bumper sticker that reads 
"Monolinguism is curable".

There is a special display in my imaginary hall of fame of bad design 
decisions for the use of = and == in C and its blind adoption by C++, 
Java, Perl, etc, along with the associated use of "expr ;" as a statement.

That's my view ;-)

cheers

andrew

Wed, 07 Apr 2004 09:53:51 -0400
Andrew Dunstan <andrew@dunslane.net>
Re: make == as = ?
Fabien COELHO wrote:

> If you want to promote postgreSQL, then it should be good that anything
> from outside (whether standard or not) can work with postgreSQL, but
> anything that work in pg may not work outside;-)

I couldn't disagree more. What you are asking for is to do whatever (you 
think) gets the crowds cheering. That is exactly what MySQL attempts by 
stuffing one half baked feature after another into their db product and 
calling it "integration". What we try instead is to create a stable, 
reliable and predictable database server.

> Also, if I add some new operators in pg_operator, say && for AND, I'm not
> sure the optimiser will know that is a AND and take that into account.

AND is not an operator, it is a keyword in the first place. And the 
optimiser can use a multi-column index containing a user defined data 
type here, so it is well aware of the things you add, if you do it right.


Jan

-- 
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#================================================== JanWieck@Yahoo.com #


Wed, 07 Apr 2004 10:19:46 -0400
Jan Wieck <JanWieck@Yahoo.com>
Re: make == as = ?
On Wed, 7 Apr 2004, Fabien COELHO wrote:

>
> > > From my point of view, my students come from a java first course, so they
> > > have to learn again some new syntax and new operators. Small stuff, but
> > > it can help to say "same as java" and go on to new concepts.
> >
> > Don't you want them to learn SQL?
>
> I want to teach them the concepts: relations, views, relationnal algebra,
> aggregation and so on, and how to build a resonnable schema from a
> real-world problem.

Which are all good things.  But even if you wanted to make java-like
flavored SQL for such a purpose, I don't see how that ties into changing
the default behavior of postgres flavored SQL.

> I do not consider whether the comparison is == or = as a key issue.

It could be if your students think they know SQL and want to get a job
doing it.  I know that if I were to ask questions and had someone
consistenly misuse == for = and such it would certainly raise doubts, just
like many answers for a C question about a = a++ + ++a.

> Moreover, there are many SQL flavors around, so whatever the detailed
> syntax I learn them, it won't be the one they will have to face if the
> database they use is different. So why bother?

Because hopefully by the time your students are out they know how to
generalize their knowledge and be able to use what they've learned as the
base point to learn the various flavors.

Wed, 7 Apr 2004 08:13:44 -0700 (PDT)
Stephan Szabo <sszabo@megazone.bigpanda.com>
Re: make == as = ?

> There is a special display in my imaginary hall of fame of bad design
> decisions for the use of = and == in C and its blind adoption by C++,
> Java, Perl, etc, along with the associated use of "expr ;" as a statement.
>
> That's my view ;-)

Well, I agree with yout view about the C language design.

But now is too late;-)

My point is more practical: my students know one syntax, I don't have a
lot of hours for the course, most of them won't be software developers but
rather software users, so if I can do more interesting things it is not
bad.

-- 
Fabien Coelho - coelho@cri.ensmp.fr

Wed, 7 Apr 2004 17:34:42 +0200 (CEST)
Fabien COELHO <coelho@cri.ensmp.fr>
Re: make == as = ?
Dennis Bjorklund wrote:
> It would be useful with some flag/variable to set that makes pg
> generate varnings for non standard constructs. Unfortunatly there are
> so many things that are non standard, still using != instead of <>
> could be a usable warning.

This is a valid project; in fact it's required for SQL conformance.  
Search the archives for "SQL flagger" to learn about some of the 
previous discussions.  Of course a lot of people will be disappointed 
to see that the SQL flagger will complain about nearly every statement 
they issue.


Wed, 7 Apr 2004 19:23:18 +0200
Peter Eisentraut <peter_e@gmx.net>
Re: make == as = ?
El Mié 07 Abr 2004 06:28, Fabien COELHO escribió:
> > > > =? as != is a synonum for <>, it would make sense.
> > >
> > > That was never such a terribly good idea, IMHO.
> >
> > Agreed. Compilers should give errors and not try to work around bad code.
>
> Is it bad code? Not for people who come from a C/C++/Java background.
> They are used to operators such as == !=  % && || !... Some of these
> are available from pg, some are not, so at the time it is incoherent.

I have such a background, and still don't use != to ask for inequality. The 
correct thing to use is <>, because thats what the SQL standards say.

-- 
 17:28:01 up 29 days, 21:55,  2 users,  load average: 0.34, 0.31, 0.29
-----------------------------------------------------------------
Martín Marqués        | select 'mmarques' || '@' || 'unl.edu.ar'
Centro de Telematica  |  DBA, Programador, Administrador
             Universidad Nacional
                  del Litoral
-----------------------------------------------------------------


Wed, 7 Apr 2004 17:29:42 -0300
Martin Marques <martin@bugs.unl.edu.ar>
Re: make == as = ?

Dear Jan,

> > If you want to promote postgreSQL, then it should be good that anything
> > from outside (whether standard or not) can work with postgreSQL, but
> > anything that work in pg may not work outside;-)
>
> I couldn't disagree more. What you are asking for is to do whatever (you
> think) gets the crowds cheering. That is exactly what MySQL attempts by
> stuffing one half baked feature after another into their db product and
> calling it "integration". What we try instead is to create a stable,
> reliable and predictable database server.

Well, I can have different opinions, depending on the standpoint;-)

(1) as a sql developer, I may want to have a tool that helps me write
    portable and standard code. Well, if I know there is a standard.
    Otherwise, I just want to code, and the more feature the better.

(2) as a product developer, I may want to serve all my customers, whether
    they are of the "standard" type or not.

(3) as a product marketer, I may want that my product as distinguishable
    features so that I can "sell" it because it does more that the
    standard.

    I've been involved in a Fortran research compiler, and I assure you
    that you must support extensions (sun cray...)
    if you want to take real industrial codes.

So on the point that the standard must be supported, I perfectly agree.

On the point that anything else should be dropped out: let's do it!
I'll send a patch to remove all those non portable features in postgresql
that make users write non portable code... But I'm not sure it will be
accepted;-)

Moreover, having == as a synonym for = is not necessarily in contradiction
with a stable, reliable and predictable server.

> AND is not an operator, ...

The docs says "logical operator". Maybe you mean "is not a pg_operator".

-- 
Fabien Coelho - coelho@cri.ensmp.fr

Sat, 10 Apr 2004 11:35:42 +0200 (CEST)
Fabien COELHO <coelho@cri.ensmp.fr>
Re: make == as = ?
Fabien COELHO said:
>
>
> So on the point that the standard must be supported, I perfectly agree.
>
> On the point that anything else should be dropped out: let's do it!
> I'll send a patch to remove all those non portable features in
> postgresql that make users write non portable code... But I'm not sure
> it will be accepted;-)
>
> Moreover, having == as a synonym for = is not necessarily in
> contradiction with a stable, reliable and predictable server.


Nobody is suggesting that we should not support legacy features that are
non-standard, nor even that we should not occasionally, and for very good
reasons, introduce new non-standard features (e.g. dollar quoting).

But making == a synonym for = is just syntactic sugar, of no obvious
practical benefit that I can see. I think its alleged utility in teaching
C/Java/perl programmers is overstated - if they think of == as equality
will they also think of = as assignment? And the fact that C (stupidly)
uses = for assignment is the whole reason for the existence of == in the
first place, and many languages (e.g. see the algol family) do not suffer
from this defect.

The last reason I advance against this is that operator space is scarce,
and if we do use == somewhere it should be to some better purpose than
this.

cheers

andrew





Sat, 10 Apr 2004 07:05:10 -0400 (EDT)
"Andrew Dunstan" <andrew@dunslane.net>
Re: make == as = ?

> But making == a synonym for = is just syntactic sugar,

Sure.

> of no obvious practical benefit that I can see.

I can see a small practical benefit, as I could skip the expression part
of my course just by telling them "same as java". No big deal, I agree.

> I think its alleged utility in teaching C/Java/perl programmers is
> overstated - if they think of == as equality will they also think of =
> as assignment?

Maybe. The good news is that = is already used for assignment in SQL
(UPDATE foo SET bla=zzz), so it is already C-compatible;-) ;-)

> And the fact that C (stupidly) uses = for assignment is the whole reason
> for the existence of == in the first place, and many languages (e.g. see
> the algol family) do not suffer from this defect.

I'm not claiming that C choices were good.

> The last reason I advance against this is that operator space is scarce,

??? [!=<>+-*/%&~@]+ does not look scarce to me. Postgres has the largest
operator space I ever seen!

> and if we do use == somewhere it should be to some better purpose than
> this.

I'm not sure it would be good to have "==" meaning anything but "=", as a
lot of people are "used" to C/C++/java/perl.

Anyway, << bonnes Paques >>,

-- 
Fabien Coelho - coelho@cri.ensmp.fr

Sat, 10 Apr 2004 14:33:24 +0200 (CEST)
Fabien COELHO <coelho@cri.ensmp.fr>
Re: make == as = ?