Re: proposal: plpgsql - Assert statement
От
Marko Tiikkaja
Тема
Re: proposal: plpgsql - Assert statement
Дата
Msg-id
54096BA4.5030600@joh.to
Ответ на
proposal: plpgsql - Assert statement (Pavel Stehule)
Список
Дерево обсуждения
proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal: plpgsql - Assert statement Marko Tiikkaja <marko@joh.to>
Re: proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal: plpgsql - Assert statement Marko Tiikkaja <marko@joh.to>
Re: proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal: plpgsql - Assert statement Marko Tiikkaja <marko@joh.to>
Re: proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal: plpgsql - Assert statement Marko Tiikkaja <marko@joh.to>
Re: proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal: plpgsql - Assert statement Craig Ringer <craig@2ndquadrant.com>
Re: proposal: plpgsql - Assert statement Marko Tiikkaja <marko@joh.to>
Re: proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal: plpgsql - Assert statement Jan Wieck <jan@wi3ck.info>
Re: proposal: plpgsql - Assert statement Alvaro Herrera <alvherre@2ndquadrant.com>
Re: proposal: plpgsql - Assert statement Peter Eisentraut <peter_e@gmx.net>
Re: proposal: plpgsql - Assert statement Peter Eisentraut <peter_e@gmx.net>
Re: proposal: plpgsql - Assert statement Marko Tiikkaja <marko@joh.to>
Re: proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal: plpgsql - Assert statement Peter Eisentraut <peter_e@gmx.net>
Re: proposal: plpgsql - Assert statement Jan Wieck <jan@wi3ck.info>
Re: proposal: plpgsql - Assert statement Jim Nasby <jim@nasby.net>
Re: proposal: plpgsql - Assert statement Ali Akbar <the.apaan@gmail.com>
Re: proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal: plpgsql - Assert statement Jan Wieck <jan@wi3ck.info>
Re: proposal: plpgsql - Assert statement Petr Jelinek <petr@2ndquadrant.com>
Re: proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal: plpgsql - Assert statement Marko Tiikkaja <marko@joh.to>
Re: proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal: plpgsql - Assert statement Marko Tiikkaja <marko@joh.to>
Re: proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal: plpgsql - Assert statement Robert Haas <robertmhaas@gmail.com>
Re: proposal: plpgsql - Assert statement Craig Ringer <craig@2ndquadrant.com>
Re: proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal: plpgsql - Assert statement Petr Jelinek <petr@2ndquadrant.com>
Re: proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal: plpgsql - Assert statement Petr Jelinek <petr@2ndquadrant.com>
Re: proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal: plpgsql - Assert statement Simon Riggs <simon@2ndQuadrant.com>
Re: proposal: plpgsql - Assert statement Jim Nasby <Jim.Nasby@BlueTreble.com>
Re: proposal: plpgsql - Assert statement Simon Riggs <simon@2ndQuadrant.com>
Re: proposal: plpgsql - Assert statement Andrew Dunstan <andrew@dunslane.net>
Re: proposal: plpgsql - Assert statement Jim Nasby <Jim.Nasby@BlueTreble.com>
Re: proposal: plpgsql - Assert statement Andrew Dunstan <andrew@dunslane.net>
Re: proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal: plpgsql - Assert statement Petr Jelinek <petr@2ndquadrant.com>
Re: proposal: plpgsql - Assert statement Simon Riggs <simon@2ndQuadrant.com>
Re: proposal: plpgsql - Assert statement Andrew Dunstan <andrew@dunslane.net>
Re: proposal: plpgsql - Assert statement Tom Lane <tgl@sss.pgh.pa.us>
Re: proposal: plpgsql - Assert statement Robert Haas <robertmhaas@gmail.com>
Re: proposal: plpgsql - Assert statement Tom Lane <tgl@sss.pgh.pa.us>
Re: proposal: plpgsql - Assert statement Robert Haas <robertmhaas@gmail.com>
Re: proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal: plpgsql - Assert statement Marko Tiikkaja <marko@joh.to>
Re: proposal: plpgsql - Assert statement Tom Lane <tgl@sss.pgh.pa.us>
Re: proposal: plpgsql - Assert statement Tom Lane <tgl@sss.pgh.pa.us>
Re: proposal: plpgsql - Assert statement Robert Haas <robertmhaas@gmail.com>
Re: proposal: plpgsql - Assert statement Tom Lane <tgl@sss.pgh.pa.us>
Re: proposal: plpgsql - Assert statement Robert Haas <robertmhaas@gmail.com>
Re: proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal: plpgsql - Assert statement Marko Tiikkaja <marko@joh.to>
Re: proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal: plpgsql - Assert statement Alvaro Herrera <alvherre@2ndquadrant.com>
Re: proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal: plpgsql - Assert statement Jim Nasby <Jim.Nasby@BlueTreble.com>
Re: proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal: plpgsql - Assert statement Jim Nasby <Jim.Nasby@BlueTreble.com>
Re: proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal: plpgsql - Assert statement Jim Nasby <Jim.Nasby@BlueTreble.com>
Re: proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal: plpgsql - Assert statement Tom Lane <tgl@sss.pgh.pa.us>
Re: proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal: plpgsql - Assert statement Jim Nasby <Jim.Nasby@BlueTreble.com>
Re: proposal: plpgsql - Assert statement Tom Lane <tgl@sss.pgh.pa.us>
Re: proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal: plpgsql - Assert statement Jim Nasby <decibel@decibel.org>
Re: proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal: plpgsql - Assert statement Tom Lane <tgl@sss.pgh.pa.us>
Re: proposal: plpgsql - Assert statement Simon Riggs <simon@2ndQuadrant.com>
Re: proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal: plpgsql - Assert statement Mike Blackwell <mike.blackwell@rrd.com>
Re: proposal: plpgsql - Assert statement Andrew Dunstan <andrew@dunslane.net>
Re: proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal: plpgsql - Assert statement Simon Riggs <simon@2ndQuadrant.com>
Re: proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal: plpgsql - Assert statement Pavel Stehule <pavel.stehule@gmail.com>
On 2014-09-05 08:16, Pavel Stehule wrote: > Assert is usually implemented as custom functions and used via PERFORM > statement now > > -- usual current solution > PERFORM Assert(some expression) > > I would to implement Assert as plpgsql internal statement due bigger > possibilities to design syntax and internal implementation now and in > future. More - as plpgsql statement should be compatible with any current > code - because there should not be collision between SQL and PLpgSQL space. > So this design doesn't break any current code. It does require making ASSERT an unreserved keyword, no? That would break code where someone used "assert" as a variable name, for example. > I propose following syntax with following ecosystem: > > ASSERT [ NOTICE, WARNING, >>EXCEPTION<< ] > [ string expression or literal - explicit message ] > [ USING clause - same as RAISE stmt (possible in future ) ] > ( ROW_COUNT ( = | <> ) ( 1 | 0 ) | > ( QUERY some query should not be empty ) | > ( CHECK some expression should be true ) > ( IS NOT NULL expression should not be null ) > UPDATE tab SET c = 1 WHERE pk = somevar; > ASSERT ROW_COUNT = 1; -- knows what is previous DML or Dynamic DML > ASSERT CHECK a < 100; > ASSERT IS NOT NULL pk; > ASSERT QUERY SELECT id FROM tab WHERE x = 1; > ASSERT CHECK 2 = (SELECT count(*) FROM tab WHERE x = 1); I don't see the need for specialized syntax. If the syntax was just ASSERT (), these could be written as: ASSERT (row_count = 1); -- assuming we provide a special variable instead of having to do GET DIAGNOSTICS ASSERT (a < 100); -- or perhaps ASSERT((a < 100) IS TRUE); depending on how NULLs are handled ASSERT (pk IS NOT NULL); ASSERT (EXISTS(SELECT id FROM tab WHERE x = 1)); ASSERT (2 = (SELECT count(*) FROM tab WHERE x = 1)); the idea being that it gets turned into SELECT ; and then evaluated. > ASSERT WARNING "data are there" QUERY SELECT ... I think this could still be parsed correctly, though I'm not 100% sure on that: ASSERT WARNING (EXISTS(SELECT ..)), 'data are there'; For extra points the error detail could work similarly to print_strict_params. e.g. ASSERT(row_count = 1); would display the value of row_count in the DETAIL line, since row_count was a parameter to the expression. .marko
В списке pgsql-hackers по дате отправления