Re: merging some features from plpgsql2 project

From: Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com>
To: Marko Tiikkaja <marko(at)joh(dot)to>
Cc: Joel Jacobson <joel(at)trustly(dot)com>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Merlin Moncure <mmoncure(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: merging some features from plpgsql2 project
Date: 2017-01-09 23:47:43
Message-ID: 28720fbc-9804-3a14-bbb0-1a2b24cbbdd7@BlueTreble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 1/9/17 5:30 PM, Marko Tiikkaja wrote:
>
> This is exactly what we did not want to do with this project. The idea
> is to create a language which is really close to PL/PgSQL, but removes
> some of the brain diarrhoea currently present.

As a general comment, ISTM it'd be much better to do as much as we can
in the current language then. It's going to take a LOT to get people to
switch to a different language, so there needs to be a LOT of added value.

> Now, this *is* a problem, and the solution we had (well I, mostly, at
> this point) in mind is to use the underscore prefix for all input
> variables and make OUT parameters invisible to queries inside function
> bodies unless explicitly prefixed with OUT. As far as I can tell this
> eliminates most if not all collisions while staying almost completely
> compatible with arguably well-written PL/PgSQL 1.

That might be workable... it's still rather ugly though.

I don't see prefixing everything with _ as being useful though; people
can already do that if they want to uglify the function's argument names.

I do think there's stuff that could be done along these lines with
namespaces though. Allowing users to rename the namespace that arguments
went into would be a huge step forward. I think having a separate
namespace for all the automatic variables would be a big help too.

Amusingly, that would allow users to set the namespace to '$', which
would (almost) give you $variable.

> - Support for the notion of a variable being unset (which is NOT the
> same thing as NULL).
>
>
> My idea was that the currently unsupported combination of NOT NULL and
> no DEFAULT would mean "has to be assigned to a non-NULL value before it
> can be read from, or an exception is thrown". Solves the most common
> use case and is backwards compatible.

That won't allow you to use a variable in multiple places though... is
there a reason we couldn't support something like IS DEFINED and UNSET?
--
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com
855-TREBLE2 (855-873-2532)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Marko Tiikkaja 2017-01-09 23:53:01 Re: merging some features from plpgsql2 project
Previous Message Michael Paquier 2017-01-09 23:39:04 Re: Make pg_basebackup -x stream the default