diff options
| author | Stephen Frost | 2013-07-25 13:41:55 +0000 |
|---|---|---|
| committer | Stephen Frost | 2013-07-25 13:41:55 +0000 |
| commit | 9bd0feeba85fae411e01798d5a5d76b70333e38e (patch) | |
| tree | 2e26bdde3495d8fa776d404ace09aa2055e14614 /src/test/regress | |
| parent | e4c6cccd8cbb96e0f64d81bde2136041492d4312 (diff) | |
Improvements to GetErrorContextStack()
As GetErrorContextStack() borrowed setup and tear-down code from other
places, it was less than clear that it must only be called as a
top-level entry point into the error system and can't be called by an
exception handler (unlike the rest of the error system, which is set up
to be reentrant-safe).
Being called from an exception handler is outside the charter of
GetErrorContextStack(), so add a bit more protection against it,
improve the comments addressing why we have to set up an errordata
stack for this function at all, and add a few more regression tests.
Lack of clarity pointed out by Tom Lane; all bugs are mine.
Diffstat (limited to 'src/test/regress')
| -rw-r--r-- | src/test/regress/expected/plpgsql.out | 62 | ||||
| -rw-r--r-- | src/test/regress/sql/plpgsql.sql | 18 |
2 files changed, 68 insertions, 12 deletions
diff --git a/src/test/regress/expected/plpgsql.out b/src/test/regress/expected/plpgsql.out index 4394a3a1a7a..b022530ae4a 100644 --- a/src/test/regress/expected/plpgsql.out +++ b/src/test/regress/expected/plpgsql.out @@ -4904,27 +4904,55 @@ declare _context text; begin get diagnostics _context = pg_context; raise notice '***%***', _context; + -- lets do it again, just for fun.. + get diagnostics _context = pg_context; + raise notice '***%***', _context; + raise notice 'lets make sure we didnt break anything'; return 2 * $1; end; $$ language plpgsql; create or replace function outer_func(int) returns int as $$ +declare + myresult int; begin - return inner_func($1); + raise notice 'calling down into inner_func()'; + myresult := inner_func($1); + raise notice 'inner_func() done'; + return myresult; end; $$ language plpgsql; create or replace function outer_outer_func(int) returns int as $$ +declare + myresult int; begin - return outer_func($1); + raise notice 'calling down into outer_func()'; + myresult := outer_func($1); + raise notice 'outer_func() done'; + return myresult; end; $$ language plpgsql; select outer_outer_func(10); +NOTICE: calling down into outer_func() +NOTICE: calling down into inner_func() +CONTEXT: PL/pgSQL function outer_outer_func(integer) line 6 at assignment NOTICE: ***PL/pgSQL function inner_func(integer) line 4 at GET DIAGNOSTICS -PL/pgSQL function outer_func(integer) line 3 at RETURN -PL/pgSQL function outer_outer_func(integer) line 3 at RETURN*** -CONTEXT: PL/pgSQL function outer_func(integer) line 3 at RETURN -PL/pgSQL function outer_outer_func(integer) line 3 at RETURN +PL/pgSQL function outer_func(integer) line 6 at assignment +PL/pgSQL function outer_outer_func(integer) line 6 at assignment*** +CONTEXT: PL/pgSQL function outer_func(integer) line 6 at assignment +PL/pgSQL function outer_outer_func(integer) line 6 at assignment +NOTICE: ***PL/pgSQL function inner_func(integer) line 7 at GET DIAGNOSTICS +PL/pgSQL function outer_func(integer) line 6 at assignment +PL/pgSQL function outer_outer_func(integer) line 6 at assignment*** +CONTEXT: PL/pgSQL function outer_func(integer) line 6 at assignment +PL/pgSQL function outer_outer_func(integer) line 6 at assignment +NOTICE: lets make sure we didnt break anything +CONTEXT: PL/pgSQL function outer_func(integer) line 6 at assignment +PL/pgSQL function outer_outer_func(integer) line 6 at assignment +NOTICE: inner_func() done +CONTEXT: PL/pgSQL function outer_outer_func(integer) line 6 at assignment +NOTICE: outer_func() done outer_outer_func ------------------ 20 @@ -4932,11 +4960,25 @@ PL/pgSQL function outer_outer_func(integer) line 3 at RETURN -- repeated call should to work select outer_outer_func(20); +NOTICE: calling down into outer_func() +NOTICE: calling down into inner_func() +CONTEXT: PL/pgSQL function outer_outer_func(integer) line 6 at assignment NOTICE: ***PL/pgSQL function inner_func(integer) line 4 at GET DIAGNOSTICS -PL/pgSQL function outer_func(integer) line 3 at RETURN -PL/pgSQL function outer_outer_func(integer) line 3 at RETURN*** -CONTEXT: PL/pgSQL function outer_func(integer) line 3 at RETURN -PL/pgSQL function outer_outer_func(integer) line 3 at RETURN +PL/pgSQL function outer_func(integer) line 6 at assignment +PL/pgSQL function outer_outer_func(integer) line 6 at assignment*** +CONTEXT: PL/pgSQL function outer_func(integer) line 6 at assignment +PL/pgSQL function outer_outer_func(integer) line 6 at assignment +NOTICE: ***PL/pgSQL function inner_func(integer) line 7 at GET DIAGNOSTICS +PL/pgSQL function outer_func(integer) line 6 at assignment +PL/pgSQL function outer_outer_func(integer) line 6 at assignment*** +CONTEXT: PL/pgSQL function outer_func(integer) line 6 at assignment +PL/pgSQL function outer_outer_func(integer) line 6 at assignment +NOTICE: lets make sure we didnt break anything +CONTEXT: PL/pgSQL function outer_func(integer) line 6 at assignment +PL/pgSQL function outer_outer_func(integer) line 6 at assignment +NOTICE: inner_func() done +CONTEXT: PL/pgSQL function outer_outer_func(integer) line 6 at assignment +NOTICE: outer_func() done outer_outer_func ------------------ 40 diff --git a/src/test/regress/sql/plpgsql.sql b/src/test/regress/sql/plpgsql.sql index b59715267e6..e791efadfdc 100644 --- a/src/test/regress/sql/plpgsql.sql +++ b/src/test/regress/sql/plpgsql.sql @@ -3888,21 +3888,35 @@ declare _context text; begin get diagnostics _context = pg_context; raise notice '***%***', _context; + -- lets do it again, just for fun.. + get diagnostics _context = pg_context; + raise notice '***%***', _context; + raise notice 'lets make sure we didnt break anything'; return 2 * $1; end; $$ language plpgsql; create or replace function outer_func(int) returns int as $$ +declare + myresult int; begin - return inner_func($1); + raise notice 'calling down into inner_func()'; + myresult := inner_func($1); + raise notice 'inner_func() done'; + return myresult; end; $$ language plpgsql; create or replace function outer_outer_func(int) returns int as $$ +declare + myresult int; begin - return outer_func($1); + raise notice 'calling down into outer_func()'; + myresult := outer_func($1); + raise notice 'outer_func() done'; + return myresult; end; $$ language plpgsql; |
