Re: PL/pgSQL 1.2

Поиск
Список
Период
Сортировка
От Oskari Saarenmaa
Тема Re: PL/pgSQL 1.2
Дата
Msg-id 540B4588.1060505@ohmu.fi
обсуждение исходный текст
Ответ на Re: PL/pgSQL 1.2  (Jan Wieck <jan@wi3ck.info>)
Ответы Re: PL/pgSQL 1.2  (Marko Tiikkaja <marko@joh.to>)
Список pgsql-hackers
06.09.2014 19:12, Jan Wieck kirjoitti:
> On 09/06/2014 04:21 AM, Marko Tiikkaja wrote:
>> We wrap these things into (sometimes) simple-looking function so that
>> none of the application developers ever run any SQL.  We define an
>> interface between the application and the database, and that interface
>> is implemented using PL/PgSQL functions.  Sure, sometimes one function
>> will just fire off a single UPDATE .. RETURNING, or a SELECT, but that
>> doesn't matter.  The trick is to be consistent everywhere.
>
> There is precisely your root problem. Instead of educating your
> application developers on how to properly use a relational database
> system, you try to make it foolproof.

There are also other reasons to wrap everything in functions, for 
example sharding using pl/proxy which by the way always throws an error 
if a SELECT didn't match exactly one row and the function wasn't 
declared returning 'SETOF' (although it currently doesn't set any 
sqlstate for these errors making it a bit difficult to properly catch them.)

Anyway, I think the discussed feature to make select, update and delete 
throw an error if they returned or modified <> 1 row would be more 
useful as an extension of the basic sql statements instead of a plpgsql 
(2) only feature to make it possible to use it from other languages and 
outside functions.

/ Oskari



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Marko Tiikkaja
Дата:
Сообщение: Re: proposal: plpgsql - Assert statement
Следующее
От: Marko Tiikkaja
Дата:
Сообщение: Re: PL/pgSQL 1.2