Thread: polite request about syntax

polite request about syntax

From
"Ricardo Malafaia"
Date:
I've send the comment below to the documentation page about CREATE
FUNCTION, but it got (rightfully) rejected, since it doesn't really
add up to the discussion and is more of a request about syntax.  So,
here it goes:

Sorry, but "datetime" vs "timestamp with time zone"?!  And what about
the whole function text between $$'s?  Yes, better than the '' of some
time ago, since we don't have to put string literals in the function
text between '''''s! still...

Why are open-source developers so masochist?  I want to use
PostgreSQL, Linux, Python and others in the firm I work at, but I this
way I can't really sell them the idea of moving on to something which
is harder, clunkier and less supported than Oracle or M$SQL...

Right now we're moving from M$SQL to Oracle and this is why I came
here, to see how things are going.  Well, i guess i'll try again in
five years or so.

Please, take this as constructive criticism, since i'm a proud
open-source supporter... i would gladly use PostgreSQL at work,
clunkier syntax or not, but it's otherwise difficult to sell it to my
Windows-minded coworkers...

best regards


Re: polite request about syntax

From
"Joshua D. Drake"
Date:
> Please, take this as constructive criticism, since i'm a proud
> open-source supporter... i would gladly use PostgreSQL at work,
> clunkier syntax or not, but it's otherwise difficult to sell it to my
> Windows-minded coworkers...

I would love to take this as constructive criticism, but you haven't 
provided any. You don't like $$, o.k. do you have a better solution? 
What is the problem with timestamp?

Joshua D. Drake



> 
> best regards
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
> 


-- 
   === The PostgreSQL Company: Command Prompt, Inc. ===
Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240   Providing the most comprehensive  PostgreSQL
solutionssince 1997             http://www.commandprompt.com/
 




Re: polite request about syntax

From
Tom Lane
Date:
"Ricardo Malafaia" <rmalafaia@gmail.com> writes:
> Sorry, but "datetime" vs "timestamp with time zone"?!  And what about
> the whole function text between $$'s?  Yes, better than the '' of some
> time ago, since we don't have to put string literals in the function
> text between '''''s! still...

"timestamp with time zone" is required by the SQL standard.  If you'd
like to use "datetime" as an alias for it, a quick CREATE DOMAIN will do
that for you.  As for the $$ bit, do you have a constructive suggestion?

> Why are open-source developers so masochist?

You seem to be confusing a database with a point-and-drool GUI.  We have
those too (see pgAdmin for instance, or three or four others), but raw
psql is not designed to make Windows users happy.
        regards, tom lane


Re: polite request about syntax

From
Andrew Dunstan
Date:
Ricardo Malafaia wrote:
> I've send the comment below to the documentation page about CREATE
> FUNCTION, but it got (rightfully) rejected, since it doesn't really
> add up to the discussion and is more of a request about syntax.  So,
> here it goes:
>
> Sorry, but "datetime" vs "timestamp with time zone"?!  

Where is the mention of either of these on the CREATE FUNCTION page? And 
anyway, what is your actual complaint?  You complain about something but 
you expect us to divine what your actual beef is.


> And what about
> the whole function text between $$'s?  Yes, better than the '' of some
> time ago, since we don't have to put string literals in the function
> text between '''''s! still...


still what? Same deal. You expect us to read your brainwaves to discover 
what is bugging you.

>
> Why are open-source developers so masochist?  I want to use
> PostgreSQL, Linux, Python and others in the firm I work at, but I this
> way I can't really sell them the idea of moving on to something which
> is harder, clunkier and less supported than Oracle or M$SQL...
>
> Right now we're moving from M$SQL to Oracle and this is why I came
> here, to see how things are going.  Well, i guess i'll try again in
> five years or so.
>
> Please, take this as constructive criticism, since i'm a proud
> open-source supporter... i would gladly use PostgreSQL at work,
> clunkier syntax or not, but it's otherwise difficult to sell it to my
> Windows-minded coworkers...
>
>

If you're a proud open source supporter, then contribute. Whining about 
things you don't like is not the same as support.

Talk is cheap.

cheers

andrew



Re: polite request about syntax

From
"Ricardo Malafaia"
Date:
well, ain't that surprising to see so many open-source developers
living in denial and sugestions to RTFM rather than actually coping
wth the problem?  are you to be taken seriously?

As a C programmer, I'm in the same league as most of you guys, so
while i can really contribute code and my talk is cheap, it's the best
i can do:  bug you with feature requests.

So:

On 9/15/06, Andrew Dunstan <andrew@dunslane.net> wrote:
> Where is the mention of either of these on the CREATE FUNCTION page?

http://www.postgresql.org/docs/8.1/interactive/sql-createfunction.html

> And anyway, what is your actual complaint?

my complaint is that, like i said, "timestamp with time zone" is no
good substitute for a simple "datetime".  Here, someone suggested a
CREATE DOMAIN to create an alias for it.  Why isn't it provided there
out-of-the-box by default?  So you have the SQL standard timestamp and
the industry standard datetime.

and, while $$ is a whole lot better than '', why do we really need
these?  Why not a normal, simple, begin end block or {}?  People in
the industry don't like hacks and the open-source world is full of it,
though it's getting better.

I think this is all valid criticism, but you wanna play deaf, that's
up to you guys.  cheers

and Tom, i don't really want a GUI:  psql's use of GNU readline
autocompletion is far better than M$'s stupid Query Analizer standard
editor and matching it up with vim gets better yet.


Re: polite request about syntax

From
Martijn van Oosterhout
Date:
On Fri, Sep 15, 2006 at 12:35:03PM -0300, Ricardo Malafaia wrote:
> On 9/15/06, Andrew Dunstan <andrew@dunslane.net> wrote:
> >Where is the mention of either of these on the CREATE FUNCTION page?
>
> http://www.postgresql.org/docs/8.1/interactive/sql-createfunction.html

Err, in the example? So you're not complaining about any text as such
and there's nothing actually wrong on that page. OK.

You're complaint is that we follow the standard and MSSQL doesn't and
should follow them instead. Eh?

There are more databases than MS-SQL, we can't implement everybodies
version of "timestamp". And in any case, why are they not the same?

> and, while $$ is a whole lot better than '', why do we really need
> these?  Why not a normal, simple, begin end block or {}?  People in
> the industry don't like hacks and the open-source world is full of it,
> though it's getting better.

Because Postgresql has a lot more languages. Putting a begin/end around
perl code or {} around python code would just look wrong. $$ is
unobstrusive and looks ok no matter what the language.

Not to mention that it's actually parseable without know the language.
Remember, we have to know where the code block begins and ends before
we know what language it is, the LANGUAGE specifier comes after.

> I think this is all valid criticism, but you wanna play deaf, that's
> up to you guys.  cheers

Deaf? You're the first person who has mentioned either of these issues.
So I'm sorry if we don't run to implement them right away.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Re: polite request about syntax

From
"Dave Page"
Date:

> -----Original Message-----
> From: pgsql-hackers-owner@postgresql.org
> [mailto:pgsql-hackers-owner@postgresql.org] On Behalf Of
> Ricardo Malafaia
> Sent: 15 September 2006 16:35
> To: Andrew Dunstan
> Cc: pgsql-hackers@postgresql.org
> Subject: Re: [HACKERS] polite request about syntax
>
> my complaint is that, like i said, "timestamp with time zone" is no
> good substitute for a simple "datetime".  Here, someone suggested a
> CREATE DOMAIN to create an alias for it.  Why isn't it provided there
> out-of-the-box by default?  So you have the SQL standard timestamp and
> the industry standard datetime.

Because adding everybody's idea of industry-standard typenames, function
name, operators etc will lead to bloated system catalogs and insanity
for people trying to understand what differences between objects there
may or may not be.

We follow the SQL standards. If you need to provide compatibility types
and functions to migrate from another product, then unlike many others
we provide the capability for you to add them yourself.
> and, while $$ is a whole lot better than '', why do we really need
> these?  Why not a normal, simple, begin end block or {}?  People in
> the industry don't like hacks and the open-source world is full of it,
> though it's getting better.

Because the parser may have no knowledge of the syntax of the language
being used which may legitimately use begin-end or { } for some other
purpose (possibly not in matched pairs). Dollar quoting gives you the
flexibility to avoid any potential clash. If we only had one procedural
language then I'm sure we could do away with dollar quoting, but there
are a dozen or more out there and they're all different.

Regards, Dave.


Re: polite request about syntax

From
Andrew Dunstan
Date:
The only person in denial is you. Here's a hard lesson about open 
source: bitching gets you nothing.

YOU are not going to be taken seriously while all you do is complain. 
And if you must complain, make sure the politeness is in the words, not 
just the subject.

The only place timestamp is mentioned on that page is in the user 
contributed part of the docs - the official docs do not contain it (one 
of the reasons I hate so called interactive docs - we are held 
responsible for stuff that is not in our official docs as if it were). 
In any case, as Tom pointed out, making an alias for it is child's play.

If you think it would be easy to come up with a way of having function 
bodies that are not strings, then we will be pleased to listen to your 
constructive and detailed plan for getting there. But first I'd like to 
know how you intend to do that and at the same time allow for loadable 
PLs of which we might know nothing at the time Postgres is built. 
(Personally I think there's a case to be made for special casing SQL and 
PLPgsql function bodies so they don't have to be strings, but I'm not 
sure how many people would agree with that).

have fun with oracle.

cheers

andrew


Ricardo Malafaia wrote:
> well, ain't that surprising to see so many open-source developers
> living in denial and sugestions to RTFM rather than actually coping
> wth the problem?  are you to be taken seriously?
>
> As a C programmer, I'm in the same league as most of you guys, so
> while i can really contribute code and my talk is cheap, it's the best
> i can do:  bug you with feature requests.
>
> So:
>
> On 9/15/06, Andrew Dunstan <andrew@dunslane.net> wrote:
>> Where is the mention of either of these on the CREATE FUNCTION page?
>
> http://www.postgresql.org/docs/8.1/interactive/sql-createfunction.html
>
>> And anyway, what is your actual complaint?
>
> my complaint is that, like i said, "timestamp with time zone" is no
> good substitute for a simple "datetime".  Here, someone suggested a
> CREATE DOMAIN to create an alias for it.  Why isn't it provided there
> out-of-the-box by default?  So you have the SQL standard timestamp and
> the industry standard datetime.
>
> and, while $$ is a whole lot better than '', why do we really need
> these?  Why not a normal, simple, begin end block or {}?  People in
> the industry don't like hacks and the open-source world is full of it,
> though it's getting better.
>
> I think this is all valid criticism, but you wanna play deaf, that's
> up to you guys.  cheers
>
> and Tom, i don't really want a GUI:  psql's use of GNU readline
> autocompletion is far better than M$'s stupid Query Analizer standard
> editor and matching it up with vim gets better yet.
>



Re: polite request about syntax

From
Tom Lane
Date:
"Ricardo Malafaia" <rmalafaia@gmail.com> writes:
> my complaint is that, like i said, "timestamp with time zone" is no
> good substitute for a simple "datetime".  Here, someone suggested a
> CREATE DOMAIN to create an alias for it.  Why isn't it provided there
> out-of-the-box by default?  So you have the SQL standard timestamp and
> the industry standard datetime.

In which part of the industry is "datetime" industry standard?  Last
I heard, the SQL spec was the industry standard.

> and, while $$ is a whole lot better than '', why do we really need
> these?  Why not a normal, simple, begin end block or {}?

Doesn't work real well for arbitrary PL languages: you are effectively
assuming that the main SQL parser can lex every language anyone might
want to write a PL with.  I think I need stray no further than plperl
to provide a counterexample: should the SQL parser be expected to
realize that qq/end/ does not represent a matching "end"?

> and Tom, i don't really want a GUI:

No, but it sounds like your co-workers do.
        regards, tom lane


Fwd: polite request about syntax

From
"Ricardo Malafaia"
Date:
---------- Forwarded message ----------
From: Ricardo Malafaia <rmalafaia@gmail.com>
Date: Sep 15, 2006 1:28 PM
Subject: Re: [HACKERS] polite request about syntax
To: Tom Lane <tgl@sss.pgh.pa.us>


ok, guys. i guess i was a bit unfair.  Timestamp is used everywhere
indeed, Oracle, Firebird you name it.  Only MySQL followed M$ and
added a confusing datetime and date to the mix.  I hope, though, that
the "timestamp with timezone" isn't really necessary.

And the $$ is indeed needed for allowing languages with different
syntaxes.  agreed.  However, Tom, i could counter example your plperl
example:

> realize that qq/end/ does not represent a matching "end"?

What happens then when it sees something like a double variable
interpolation as in $$foobar? ;)

Sorry for the rudeness, but i truly like PostgreSQL and was playing
devil's advocate.  and no, i'm not likely to have fun with Oracle...
:P

cheers


-- 
http://slashdot.org


Re: Fwd: polite request about syntax

From
Douglas McNaught
Date:
"Ricardo Malafaia" <rmalafaia@gmail.com> writes:

> What happens then when it sees something like a double variable
> interpolation as in $$foobar? ;)

Then you use $FOO$ (or something else that doesn't appear in your
code) as the delimiter--you're not limited to just $$.

-Doug


Re: Fwd: polite request about syntax

From
"Ricardo Malafaia"
Date:
On 9/15/06, Douglas McNaught <doug@mcnaught.org> wrote:
> > What happens then when it sees something like a double variable
> > interpolation as in $$foobar? ;)
>
> Then you use $FOO$ (or something else that doesn't appear in your
> code) as the delimiter--you're not limited to just $$.

clever.  still, i don't believe such variety of syntax and even
multitude of language support would do well with most Windows shops.
but that's not really your fault...


Re: Fwd: polite request about syntax

From
Andrew Dunstan
Date:
Ricardo Malafaia wrote:
>
> And the $$ is indeed needed for allowing languages with different
> syntaxes.  agreed.  However, Tom, i could counter example your plperl
> example:
>
>> realize that qq/end/ does not represent a matching "end"?
>
> What happens then when it sees something like a double variable
> interpolation as in $$foobar? ;)
>


The delimiter does not have to be $$. It can be 
$any_unquoted_identifier_without_a_dollar_sign$.

the lexer says:

/* $foo$ style quotes ("dollar quoting")* The quoted string starts with $foo$ where "foo" is an optional string* in the
formof an identifier, except that it may not contain "$",* and extends to the first occurrence of an identical string.
*There is *no* processing of the quoted text.**/
 
dolq_start      [A-Za-z\200-\377_]
dolq_cont       [A-Za-z\200-\377_0-9]
dolqdelim       \$({dolq_start}{dolq_cont}*)?\$


So for a plperl function you just use something like $func$ at each end.

cheers

andrew




Re: Fwd: polite request about syntax

From
Alvaro Herrera
Date:
Ricardo Malafaia wrote:
> On 9/15/06, Douglas McNaught <doug@mcnaught.org> wrote:
> >> What happens then when it sees something like a double variable
> >> interpolation as in $$foobar? ;)
> >
> >Then you use $FOO$ (or something else that doesn't appear in your
> >code) as the delimiter--you're not limited to just $$.
> 
> clever.  still, i don't believe such variety of syntax and even
> multitude of language support would do well with most Windows shops.
> but that's not really your fault...

Well, there's always MS Access ...

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


Re: polite request about syntax

From
Jeremy Drake
Date:
On Fri, 15 Sep 2006, Dave Page wrote:
> > -----Original Message-----
> > From: pgsql-hackers-owner@postgresql.org
> > [mailto:pgsql-hackers-owner@postgresql.org] On Behalf Of
> > Ricardo Malafaia
> > Sent: 15 September 2006 16:35
> > To: Andrew Dunstan
> > Cc: pgsql-hackers@postgresql.org
> > Subject: Re: [HACKERS] polite request about syntax
> >
> > my complaint is that, like i said, "timestamp with time zone" is no
> > good substitute for a simple "datetime".  Here, someone suggested a
> > CREATE DOMAIN to create an alias for it.  Why isn't it provided there
> > out-of-the-box by default?  So you have the SQL standard timestamp and
> > the industry standard datetime.
>
> Because adding everybody's idea of industry-standard typenames, function
> name, operators etc will lead to bloated system catalogs and insanity
> for people trying to understand what differences between objects there
> may or may not be.
>
> We follow the SQL standards. If you need to provide compatibility types
> and functions to migrate from another product, then unlike many others
> we provide the capability for you to add them yourself.

I hate to comment on what is shaping up to be a bit of a tinderbox of a
thread, but I can't help myself.

When I was first dealing with postgres, I found it extremely annoying that
I had to type out "double precision" rather than just "double" since every
sane programming language (as well as Java) uses double.  I eventually
figured out that it was because double precision is the standard name, but
I don't like to type and although I know I could use float8, I am used to
typing double.

I have found the same thing with the type "timestamp without time zone".
The verbosity of type names seems rather extreme.  But it is just not
important enough to warrant me creating a domain or anything to do
anything about it, it just slightly irks me every time I have to type
them.

I have probably now written more on this than it deserves :)

-- 
Fertility is hereditary.  If your parents didn't have any children,
neither will you.


Re: polite request about syntax

From
Jim Nasby
Date:
On Sep 15, 2006, at 11:32 PM, Jeremy Drake wrote:
> When I was first dealing with postgres, I found it extremely  
> annoying that
> I had to type out "double precision" rather than just "double"  
> since every
> sane programming language (as well as Java) uses double.  I eventually
> figured out that it was because double precision is the standard  
> name, but
> I don't like to type and although I know I could use float8, I am  
> used to
> typing double.
>
> I have found the same thing with the type "timestamp without time  
> zone".
> The verbosity of type names seems rather extreme.  But it is just not
> important enough to warrant me creating a domain or anything to do
> anything about it, it just slightly irks me every time I have to type
> them.

Luckily, it's pretty easy to create a 'double' type on your own,  
either as a DOMAIN or as it's own type. Same with datetime, etc.  
(BTW, timestamptz works great as a replacement for "timestamp with  
time zone").

Going one step further, you could also create a compatibility package  
and put it on pgFoundry. In fact, I believe one already exists for  
MySQL. I'm sure users would love to see ones for other popular  
databases.

As for $$ quoting, I do think it would be nice if the docs adopted  
the standard of

CREATE FUNCTION my_function ... $my_function$
...
$my_function$

While more verbose than $$, it does a lot to help code readability.
--
Jim Nasby                                            jim@nasby.net
EnterpriseDB      http://enterprisedb.com      512.569.9461 (cell)




Re: polite request about syntax

From
Alvaro Herrera
Date:
Jeremy Drake wrote:

> I have found the same thing with the type "timestamp without time zone".
> The verbosity of type names seems rather extreme.

Then use simply "timestamptz" (with TZ) or "timestamp" (without).

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


Re: polite request about syntax

From
Jeremy Drake
Date:
On Tue, 19 Sep 2006, Alvaro Herrera wrote:

> Jeremy Drake wrote:
>
> > I have found the same thing with the type "timestamp without time zone".
> > The verbosity of type names seems rather extreme.
>
> Then use simply "timestamptz" (with TZ) or "timestamp" (without).

Didn't know about these, learn something new every day I guess.  I know
that double did not work due to the countless times I forget the
"precision" :)

-- 
Armadillo:To provide weapons to a Spanish pickle


Re: polite request about syntax

From
"Andrew Dunstan"
Date:
Jeremy Drake wrote:
> On Tue, 19 Sep 2006, Alvaro Herrera wrote:
>
>> Jeremy Drake wrote:
>>
>> > I have found the same thing with the type "timestamp without time
>> zone".
>> > The verbosity of type names seems rather extreme.
>>
>> Then use simply "timestamptz" (with TZ) or "timestamp" (without).
>
> Didn't know about these, learn something new every day I guess.  I know
> that double did not work due to the countless times I forget the
> "precision" :)

then use float8.

for a list of all the builtin aliases see
http://www.postgresql.org/docs/current/static/datatype.html

cheers

andrew