Re: plpgsql defensive mode - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: plpgsql defensive mode
Date
Msg-id CAFj8pRB1o819tzEJnCj2Yv=po7dThsvh0pzLn9m=K=sMiSe76Q@mail.gmail.com
Whole thread Raw
In response to Re: plpgsql defensive mode  (Marko Tiikkaja <marko@joh.to>)
Responses Re: plpgsql defensive mode
List pgsql-hackers



2014-09-06 16:31 GMT+02:00 Marko Tiikkaja <marko@joh.to>:
On 2014-09-06 7:51 AM, Pavel Stehule wrote:
In this mode .. all DML statements should to return EXACTLY ONE row with
exception CURSORs and FOR LOOP cycle where more rows is expected. But in
this case we can raise a exception NODATA if there is no row.

In this mode late IO casting will be disabled. We can disallow implicit
casting too.

We can talk what plpgsql warnings in this mode will be critical.

This mode can be enabled for function by option

#option defensive

or for all plpgsql functions by GUC

SET plpgsql.defensive = on

In this moment I don't see a necessity to change or enhance syntax.

How do you run queries which affect more than one row in this mode? Because that's crucial as well.  We want something we can run 100% of our code on, but with a slightly more convenient syntax than PL/PgSQL provides right when coding defensively in the cases where exactly one row should be affected.

you use a normal function. I don't expect, so it can be too often in your case.

Pavel
 


.marko

pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: proposal: plpgsql - Assert statement
Next
From: Marko Tiikkaja
Date:
Subject: Re: plpgsql defensive mode