Re: PL/pgSQL 1.2

Поиск
Список
Период
Сортировка
Искать
От
Hannu Krosing
Тема
Re: PL/pgSQL 1.2
Дата
Msg-id
540785E1.6070007@2ndQuadrant.com
Ответ на
Re: PL/pgSQL 2 (Marko Tiikkaja)
Список
Дерево обсуждения
PL/pgSQL 2 Joel Jacobson <joel@trustly.com>
Re: PL/pgSQL 2 Kevin Grittner <kgrittn@ymail.com>
Re: PL/pgSQL 2 Joel Jacobson <joel@trustly.com>
Re: PL/pgSQL 2 Kevin Grittner <kgrittn@ymail.com>
Re: PL/pgSQL 2 Marko Tiikkaja <marko@joh.to>
Re: PL/pgSQL 2 Kevin Grittner <kgrittn@ymail.com>
Re: PL/pgSQL 2 Marko Tiikkaja <marko@joh.to>
Re: PL/pgSQL 2 Joel Jacobson <joel@trustly.com>
Re: PL/pgSQL 2 Kevin Grittner <kgrittn@ymail.com>
Re: PL/pgSQL 2 Joel Jacobson <joel@trustly.com>
Re: PL/pgSQL 2 Álvaro Hernández Tortosa <aht@nosys.es>
Re: PL/pgSQL 2 Jan Wieck <jan@wi3ck.info>
Re: PL/pgSQL 2 Heikki Linnakangas <hlinnakangas@vmware.com>
Re: PL/pgSQL 2 Marko Tiikkaja <marko@joh.to>
Re: PL/pgSQL 2 Heikki Linnakangas <hlinnakangas@vmware.com>
Re: PL/pgSQL 2 Joel Jacobson <joel@trustly.com>
Re: PL/pgSQL 2 Andrew Dunstan <andrew@dunslane.net>
Re: PL/pgSQL 2 Heikki Linnakangas <hlinnakangas@vmware.com>
Re: PL/pgSQL 2 Marko Tiikkaja <marko@joh.to>
Re: PL/pgSQL 2 Kevin Grittner <kgrittn@ymail.com>
Re: PL/pgSQL 2 Marko Tiikkaja <marko@joh.to>
Re: PL/pgSQL 2 Kevin Grittner <kgrittn@ymail.com>
Re: PL/pgSQL 2 Marko Tiikkaja <marko@joh.to>
Re: PL/pgSQL 2 Jan Wieck <jan@wi3ck.info>
Re: PL/pgSQL 2 Marko Tiikkaja <marko@joh.to>
Re: PL/pgSQL 2 Jan Wieck <jan@wi3ck.info>
Re: PL/pgSQL 2 Marko Tiikkaja <marko@joh.to>
Re: PL/pgSQL 2 Jan Wieck <jan@wi3ck.info>
Re: PL/pgSQL 2 David G Johnston <david.g.johnston@gmail.com>
Re: PL/pgSQL 2 Jan Wieck <jan@wi3ck.info>
Re: PL/pgSQL 2 Joel Jacobson <joel@trustly.com>
Re: PL/pgSQL 2 Pavel Stehule <pavel.stehule@gmail.com>
Re: PL/pgSQL 2 Andres Freund <andres@2ndquadrant.com>
Re: PL/pgSQL 2 Hannu Krosing <hannu@2ndQuadrant.com>
Re: PL/pgSQL 2 Marko Tiikkaja <marko@joh.to>
Re: PL/pgSQL 2 Andres Freund <andres@2ndquadrant.com>
Re: PL/pgSQL 2 Marko Tiikkaja <marko@joh.to>
Re: PL/pgSQL 2 Andres Freund <andres@2ndquadrant.com>
Re: PL/pgSQL 2 Hannu Krosing <hannu@2ndQuadrant.com>
Re: PL/pgSQL 2 Joel Jacobson <joel@trustly.com>
Re: PL/pgSQL 2 Pavel Stehule <pavel.stehule@gmail.com>
Re: PL/pgSQL 2 Steven Lembark <lembark@wrkhors.com>
Re: PL/pgSQL 2 Hannu Krosing <hannu@2ndQuadrant.com>
Re: PL/pgSQL 2 Joel Jacobson <joel@trustly.com>
Re: PL/pgSQL 2 Craig Ringer <craig@2ndquadrant.com>
Re: PL/pgSQL 2 Steven Lembark <lembark@wrkhors.com>
Re: PL/pgSQL 2 Joel Jacobson <joel@trustly.com>
Re: PL/pgSQL 2 Craig Ringer <craig@2ndquadrant.com>
Re: PL/pgSQL 2 Hannu Krosing <hannu@2ndQuadrant.com>
Re: PL/pgSQL 2 Pavel Stehule <pavel.stehule@gmail.com>
Re: PL/pgSQL 2 Craig Ringer <craig@2ndquadrant.com>
Re: PL/pgSQL 2 Joel Jacobson <joel@trustly.com>
Re: PL/pgSQL 2 Pavel Stehule <pavel.stehule@gmail.com>
Re: PL/pgSQL 2 Craig Ringer <craig@2ndquadrant.com>
Re: PL/pgSQL 2 Andres Freund <andres@2ndquadrant.com>
Re: PL/pgSQL 2 Craig Ringer <craig@2ndquadrant.com>
Re: PL/pgSQL 2 Andres Freund <andres@2ndquadrant.com>
Re: PL/pgSQL 2 Craig Ringer <craig@2ndquadrant.com>
Re: PL/pgSQL 2 Joel Jacobson <joel@trustly.com>
Re: PL/pgSQL 2 David G Johnston <david.g.johnston@gmail.com>
Re: PL/pgSQL 2 Heikki Linnakangas <hlinnakangas@vmware.com>
Re: PL/pgSQL 2 Craig Ringer <craig@2ndquadrant.com>
Re: PL/pgSQL 2 Joel Jacobson <joel@trustly.com>
Re: PL/pgSQL 2 Craig Ringer <craig@2ndquadrant.com>
Re: PL/pgSQL 2 Mark Kirkwood <mark.kirkwood@catalyst.net.nz>
Re: PL/pgSQL 2 Joel Jacobson <joel@trustly.com>
Re: PL/pgSQL 2 Heikki Linnakangas <hlinnakangas@vmware.com>
Re: PL/pgSQL 2 Joel Jacobson <joel@trustly.com>
Re: PL/pgSQL 2 Jan Wieck <jan@wi3ck.info>
Re: PL/pgSQL 2 Pavel Stehule <pavel.stehule@gmail.com>
Re: PL/pgSQL 2 Pavel Stehule <pavel.stehule@gmail.com>
Re: PL/pgSQL 2 Pavel Stehule <pavel.stehule@gmail.com>
Re: PL/pgSQL 2 Craig Ringer <craig@2ndquadrant.com>
Re: PL/pgSQL 2 Pavel Stehule <pavel.stehule@gmail.com>
Re: PL/pgSQL 2 Jan Wieck <jan@wi3ck.info>
Re: PL/pgSQL 2 Shaun Thomas <sthomas@optionshouse.com>
Re: PL/pgSQL 2 Joel Jacobson <joel@trustly.com>
Re: PL/pgSQL 2 Joel Jacobson <joel@trustly.com>
Re: PL/pgSQL 2 Pavel Stehule <pavel.stehule@gmail.com>
Re: PL/pgSQL 2 Marko Tiikkaja <marko@joh.to>
Re: PL/pgSQL 2 Pavel Stehule <pavel.stehule@gmail.com>
Re: PL/pgSQL 2 Joel Jacobson <joel@trustly.com>
Re: PL/pgSQL 2 Heikki Linnakangas <hlinnakangas@vmware.com>
Re: PL/pgSQL 2 Marko Tiikkaja <marko@joh.to>
Re: PL/pgSQL 2 Andres Freund <andres@2ndquadrant.com>
Re: PL/pgSQL 2 Joel Jacobson <joel@trustly.com>
Re: PL/pgSQL 2 Heikki Linnakangas <hlinnakangas@vmware.com>
Re: PL/pgSQL 2 Joel Jacobson <joel@trustly.com>
Re: PL/pgSQL 2 Heikki Linnakangas <hlinnakangas@vmware.com>
Re: PL/pgSQL 2 Marko Tiikkaja <marko@joh.to>
Re: PL/pgSQL 2 Tom Lane <tgl@sss.pgh.pa.us>
Re: PL/pgSQL 2 Andres Freund <andres@2ndquadrant.com>
Re: PL/pgSQL 2 Bruce Momjian <bruce@momjian.us>
Re: PL/pgSQL 2 Joel Jacobson <joel@trustly.com>
Re: PL/pgSQL 2 Bruce Momjian <bruce@momjian.us>
Re: PL/pgSQL 2 Joel Jacobson <joel@trustly.com>
Re: PL/pgSQL 2 Bruce Momjian <bruce@momjian.us>
Re: PL/pgSQL 2 Andres Freund <andres@2ndquadrant.com>
Re: PL/pgSQL 2 Jan Wieck <jan@wi3ck.info>
Re: PL/pgSQL 2 Joel Jacobson <joel@trustly.com>
Re: PL/pgSQL 2 Joel Jacobson <joel@trustly.com>
Re: PL/pgSQL 2 Marko Tiikkaja <marko@joh.to>
Re: PL/pgSQL 2 Pavel Stehule <pavel.stehule@gmail.com>
Re: PL/pgSQL 2 Jan Wieck <jan@wi3ck.info>
Re: PL/pgSQL 2 Pavel Stehule <pavel.stehule@gmail.com>
Re: PL/pgSQL 2 Joel Jacobson <joel@trustly.com>
Re: PL/pgSQL 2 Pavel Stehule <pavel.stehule@gmail.com>
Re: PL/pgSQL 2 Joel Jacobson <joel@trustly.com>
Re: PL/pgSQL 2 Álvaro Hernández Tortosa <aht@nosys.es>
Re: PL/pgSQL 2 Tom Lane <tgl@sss.pgh.pa.us>
Re: PL/pgSQL 2 Álvaro Hernández Tortosa <aht@nosys.es>
Re: PL/pgSQL 2 Pavel Stehule <pavel.stehule@gmail.com>
Re: PL/pgSQL 2 Álvaro Hernández Tortosa <aht@nosys.es>
Re: PL/pgSQL 2 Marko Tiikkaja <marko@joh.to>
Re: PL/pgSQL 2 Álvaro Hernández Tortosa <aht@nosys.es>
Re: PL/pgSQL 2 Joel Jacobson <joel@trustly.com>
Re: PL/pgSQL 2 Álvaro Hernández Tortosa <aht@nosys.es>
Re: PL/pgSQL 2 David G Johnston <david.g.johnston@gmail.com>
Re: PL/pgSQL 2 Álvaro Hernández Tortosa <aht@nosys.es>
Re: PL/pgSQL 2 Craig Ringer <craig@2ndquadrant.com>
Re: PL/pgSQL 2 Tom Lane <tgl@sss.pgh.pa.us>
Re: PL/pgSQL 2 Bruce Momjian <bruce@momjian.us>
Re: PL/pgSQL 2 "Joshua D. Drake" <jd@commandprompt.com>
Re: PL/pgSQL 2 David Johnston <david.g.johnston@gmail.com>
Re: PL/pgSQL 2 Álvaro Hernández Tortosa <aht@nosys.es>
Re: PL/pgSQL 2 "Joshua D. Drake" <jd@commandprompt.com>
Re: PL/pgSQL 2 Álvaro Hernández Tortosa <aht@nosys.es>
Re: PL/pgSQL 2 "Joshua D. Drake" <jd@commandprompt.com>
Re: PL/pgSQL 2 Jan Wieck <jan@wi3ck.info>
Re: PL/pgSQL 2 Andrew Dunstan <andrew@dunslane.net>
Re: PL/pgSQL 2 Jan Wieck <jan@wi3ck.info>
Re: PL/pgSQL 2 Szymon Guz <mabewlun@gmail.com>
Re: PL/pgSQL 2 Christopher Browne <cbbrowne@gmail.com>
Re: PL/pgSQL 2 Bruce Momjian <bruce@momjian.us>
Re: PL/pgSQL 2 Joel Jacobson <joel@trustly.com>
Re: PL/pgSQL 2 "Joshua D. Drake" <jd@commandprompt.com>
Re: PL/pgSQL 2 Joel Jacobson <joel@trustly.com>
Re: PL/pgSQL 2 Álvaro Hernández Tortosa <aht@nosys.es>
Re: PL/pgSQL 2 "Joshua D. Drake" <jd@commandprompt.com>
Re: PL/pgSQL 2 Álvaro Hernández Tortosa <aht@nosys.es>
Re: PL/pgSQL 2 Robert Haas <robertmhaas@gmail.com>
Re: PL/pgSQL 2 David G Johnston <david.g.johnston@gmail.com>
Re: PL/pgSQL 2 Pavel Stehule <pavel.stehule@gmail.com>
Re: PL/pgSQL 2 Stephen Frost <sfrost@snowman.net>
Re: PL/pgSQL 2 "Joshua D. Drake" <jd@commandprompt.com>
Re: PL/pgSQL 2 Craig Ringer <craig@2ndquadrant.com>
Re: PL/pgSQL 2 Álvaro Hernández Tortosa <aht@nosys.es>
Re: PL/pgSQL 2 Craig Ringer <craig@2ndquadrant.com>
Re: PL/pgSQL 2 Marko Tiikkaja <marko@joh.to>
Re: PL/pgSQL 2 Pavel Stehule <pavel.stehule@gmail.com>
Re: Allowing implicit 'text' -> xml|json|jsonb (was: PL/pgSQL 2) Craig Ringer <craig@2ndquadrant.com>
Re: Allowing implicit 'text' -> xml|json|jsonb Marko Tiikkaja <marko@joh.to>
Re: Allowing implicit 'text' -> xml|json|jsonb Craig Ringer <craig@2ndquadrant.com>
Re: Allowing implicit 'text' -> xml|json|jsonb Tom Lane <tgl@sss.pgh.pa.us>
Re: Allowing implicit 'text' -> xml|json|jsonb Craig Ringer <craig@2ndquadrant.com>
Re: Allowing implicit 'text' -> xml|json|jsonb Marko Tiikkaja <marko@joh.to>
Re: Allowing implicit 'text' -> xml|json|jsonb (was: PL/pgSQL 2) Merlin Moncure <mmoncure@gmail.com>
Re: PL/pgSQL 2 Álvaro Hernández Tortosa <aht@nosys.es>
Re: PL/pgSQL 2 Craig Ringer <craig@2ndquadrant.com>
Re: PL/pgSQL 2 Álvaro Hernández Tortosa <aht@nosys.es>
Re: PL/pgSQL 2 Marko Tiikkaja <marko@joh.to>
Re: PL/pgSQL 2 Álvaro Hernández Tortosa <aht@nosys.es>
Re: PL/pgSQL 2 Pavel Stehule <pavel.stehule@gmail.com>
Re: PL/pgSQL 2 Álvaro Hernández Tortosa <aht@nosys.es>
Re: PL/pgSQL 2 Hannu Krosing <hannu@2ndQuadrant.com>
Re: PL/pgSQL 2 Álvaro Hernández Tortosa <aht@nosys.es>
Re: PL/pgSQL 2 Joel Jacobson <joel@trustly.com>
Re: PL/pgSQL 2 Hannu Krosing <hannu@2ndQuadrant.com>
Re: PL/pgSQL 2 Álvaro Hernández Tortosa <aht@nosys.es>
Re: PL/pgSQL 2 Pavel Stehule <pavel.stehule@gmail.com>
Re: PL/pgSQL 2 Marko Tiikkaja <marko@joh.to>
Re: PL/pgSQL 2 Pavel Stehule <pavel.stehule@gmail.com>
Re: PL/pgSQL 2 Joel Jacobson <joel@trustly.com>
Re: PL/pgSQL 2 Andres Freund <andres@2ndquadrant.com>
Re: PL/pgSQL 2 Tom Lane <tgl@sss.pgh.pa.us>
Re: PL/pgSQL 2 Neil Tiffin <neilt@neiltiffin.com>
Re: PL/pgSQL 2 Andrew Dunstan <andrew@dunslane.net>
Re: PL/pgSQL 2 Jan Wieck <jan@wi3ck.info>
Re: PL/pgSQL 2 David G Johnston <david.g.johnston@gmail.com>
Re: PL/pgSQL 2 Craig Ringer <craig@2ndquadrant.com>
Re: PL/pgSQL 2 David Johnston <david.g.johnston@gmail.com>
Re: PL/pgSQL 2 Craig Ringer <craig@2ndquadrant.com>
Re: PL/pgSQL 2 Craig Ringer <craig@2ndquadrant.com>
Re: PL/pgSQL 2 Ian Barwick <ian@2ndquadrant.com>
Re: PL/pgSQL 2 Álvaro Hernández Tortosa <aht@nosys.es>
Re: PL/pgSQL 2 Mark Kirkwood <mark.kirkwood@catalyst.net.nz>
Re: PL/pgSQL 2 Álvaro Hernández Tortosa <aht@nosys.es>
Re: PL/pgSQL 2 Andrew Dunstan <andrew@dunslane.net>
Re: PL/pgSQL 2 Ryan Pedela <rpedela@datalanche.com>
Re: PL/pgSQL 2 Andrew Dunstan <andrew@dunslane.net>
Re: PL/pgSQL 2 Pavel Stehule <pavel.stehule@gmail.com>
Re: PL/pgSQL 2 Andrew Dunstan <andrew@dunslane.net>
Re: PL/pgSQL 2 Pavel Stehule <pavel.stehule@gmail.com>
Re: PL/pgSQL 2 Pavel Stehule <pavel.stehule@gmail.com>
Re: PL/pgSQL 2 Álvaro Hernández Tortosa <aht@nosys.es>
Re: PL/pgSQL 2 Pavel Stehule <pavel.stehule@gmail.com>
Re: PL/pgSQL 2 Álvaro Hernández Tortosa <aht@nosys.es>
Re: PL/pgSQL 2 Neil Tiffin <neilt@neiltiffin.com>
Re: PL/pgSQL 2 Craig Ringer <craig@2ndquadrant.com>
Re: PL/pgSQL 2 Joel Jacobson <joel@trustly.com>
Re: PL/pgSQL 2 Tom Lane <tgl@sss.pgh.pa.us>
Re: PL/pgSQL 2 Joel Jacobson <joel@trustly.com>
Re: PL/pgSQL 2 Pavel Stehule <pavel.stehule@gmail.com>
Re: PL/pgSQL 2 Joel Jacobson <joel@trustly.com>
Re: PL/pgSQL 2 Andres Freund <andres@2ndquadrant.com>
Re: PL/pgSQL 2 Joel Jacobson <joel@trustly.com>
Re: PL/pgSQL 2 Steven Lembark <lembark@wrkhors.com>
Re: PL/pgSQL 2 Merlin Moncure <mmoncure@gmail.com>
Re: PL/pgSQL 2 Merlin Moncure <mmoncure@gmail.com>
Re: PL/pgSQL 2 Joel Jacobson <joel@trustly.com>
On 09/03/2014 05:09 PM, Marko Tiikkaja wrote:
> On 9/3/14 5:05 PM, Bruce Momjian wrote:
>> On Wed, Sep  3, 2014 at 07:54:09AM +0200, Pavel Stehule wrote:
>>> I am not against to improve a PL/pgSQL. And I repeat, what can be
>>> done and can
>>> be done early:
>>>
>>> a) ASSERT clause -- with some other modification to allow better
>>> static analyze
>>> of DML statements, and enforces checks in runtime.
>>>
>>> b) #option or PRAGMA clause with GUC with function scope that
>>> enforce check on
>>> processed rows after any DML statement
>>>
>>> c) maybe introduction automatic variable ROW_COUNT as shortcut for GET
>>> DIAGNOSTICS rc = ROW_COUNT
>>
>> All these ideas are being captured somewhere, right?  Where?
>
> I'm working on a wiki page with all these ideas.  Some of them break
> backwards compatibility somewhat blatantly, some of them could be
> added into PL/PgSQL if we're okay with reserving a keyword for the
> feature. All of them we think are necessary.

Ok, here are my 0.5 cents worth of proposals for some features discussed
in this thread

They should be backwards compatible, but perhaps they are not very
ADA/SQL-kosher  ;)

They also could be implemented as macros first with possible
optimisations in the future


1. Conditions for number of rows returned by SELECT or touched by UPDATE
or DELETE
---------------------------------------------------------------------------------------------------------

Enforcing number of rows returned/affected could be done using the
following syntax which is concise and clear (and should be in no way
backwards incompatible)

SELECT[1]   - select exactly one row, anything else raises error
SELECT[0:1]   - select zero or one rows, anything else raises error
SELECT[1:] - select one or more rows

plain SELECT is equivalent to SELECT[0:]

same syntax could be used for enforcing sane affected row counts
for INSERT and DELETE


A more SQL-ish way of doing the same could probably be called COMMAND
CONSTRAINTS
and look something like this

SELECT
...
CHECK (ROWCOUNT BETWEEN 0 AND 1);



2. Substitute for EXECUTE with string manipulation
----------------------------------------------------------------

using backticks `` for value/command substitution in SQL as an alternative
to EXECUTE string

Again it should be backwards compatible as , as currently `` are not
allowed inside pl/pgsql functions

Sample 1:

ALTER USER `current_user` PASSWORD newpassword;

would be expanded to

EXECUTE 'ALTER USER ' || current_user ||               ' PASSWORD = $1' USING newpassword;

Sample2:

SELECT * FROM `tablename` WHERE "`idcolumn`" = idvalue;

this could be expanded to

EXECUTE 'SELECT * FROM ' || tablename ||               ' WHERE quote_ident(idcolumn) = $1' USING idvalue;

Notice that the use of "" around `` forced use of quote_ident()


3. A way to tell pl/pggsql not to cache plans fro normal queries
-----------------------------------------------------------------------------------

This could be done using a #pragma or special /* NOPLANCACHE */
comment as suggested by Pavel

Or we could expand the [] descriptor from 1. to allow more options

OR we could do it in SQL-ish way using like this:

SELECT
...
USING FRESH PLAN;


Best Regards

-- 
Hannu Krosing
PostgreSQL Consultant
Performance, Scalability and High Availability
2ndQuadrant Nordic OÜ



В списке pgsql-hackers по дате отправления
От: Robert Haas
Дата:
От: Robert Haas
Дата:
FAQ