Hi

I am sending a next variant of filtering context patch.

postgres=# do $$ begin raise notice 'kuku'; end $$;
NOTICE:  kuku
DO
Time: 2.441 ms
postgres=# do $$ begin raise exception 'kuku'; end $$;
ERROR:  kuku
CONTEXT:  PL/pgSQL function inline_code_block line 1 at RAISE
Time: 0.648 ms
postgres=# \set SHOW_CONTEXT always
postgres=# do $$ begin raise notice 'kuku'; end $$;
NOTICE:  kuku
CONTEXT:  PL/pgSQL function inline_code_block line 1 at RAISE
DO
Time: 0.702 ms

It is a variant, when I try to filter CONTEXT in libpq. There is little bit
less granularity on libpq side than server side, but still it is enough -
always, error, none.

This patch is without documentation, but basic regress tests works.

Regards

Pavel



2015-07-25 10:01 GMT+02:00 Pavel Stehule <pavel.steh...@gmail.com>:

>
>
> 2015-07-21 16:58 GMT+02:00 Merlin Moncure <mmonc...@gmail.com>:
>
>> On Tue, Jul 21, 2015 at 2:53 AM, Heikki Linnakangas <hlinn...@iki.fi>
>> wrote:
>> > On 07/21/2015 10:38 AM, Pavel Stehule wrote:
>> >>
>> >> where we are with this patch? Can I do some for it?
>> >
>> >
>> > I still feel this approach is misguided, and we should be tweaking psql
>> > and/or libpq instead. I don't feel strongly though, and if some other
>> > committer wants to pick this up in its current form, I won't object. So
>> this
>> > patch has reached an impasse, and if no-one else wants to pick this up,
>> I'm
>> > going to mark this as "Returned with Feedback" and move on.
>>
>> That's unfortunate.  Maybe I'm missing something:
>>
>> What does a client side implementation offer that a server side
>> implementation does not offer?
>>
>
> I have not any problem to change the filtering to client side. Primary
> question is fix of PLpgSQL RAISE statement issue - The context field
> filtering is a necessary follow-up and trivial in both cases.
>
> In this case, it is acceptable for all?
>
> Regards
>
> Pavel
>
>
>>
>> merlin
>>
>
>
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
new file mode 100644
index 6181a61..7168809
*** a/src/bin/psql/command.c
--- b/src/bin/psql/command.c
*************** SyncVariables(void)
*** 2029,2034 ****
--- 2029,2035 ----
  
  	/* send stuff to it, too */
  	PQsetErrorVerbosity(pset.db, pset.verbosity);
+ 	PQsetErrorContextVisibility(pset.db, pset.show_context);
  }
  
  /*
diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c
new file mode 100644
index d3e3114..0bc97de
*** a/src/bin/psql/help.c
--- b/src/bin/psql/help.c
*************** helpVariables(unsigned short int pager)
*** 307,313 ****
  {
  	FILE	   *output;
  
! 	output = PageOutput(85, pager ? &(pset.popt.topt) : NULL);
  
  	fprintf(output, _("List of specially treated variables.\n"));
  
--- 307,313 ----
  {
  	FILE	   *output;
  
! 	output = PageOutput(86, pager ? &(pset.popt.topt) : NULL);
  
  	fprintf(output, _("List of specially treated variables.\n"));
  
*************** helpVariables(unsigned short int pager)
*** 339,344 ****
--- 339,345 ----
  	fprintf(output, _("  PROMPT2            specify the prompt used when a statement continues from a previous line\n"));
  	fprintf(output, _("  PROMPT3            specify the prompt used during COPY ... FROM STDIN\n"));
  	fprintf(output, _("  QUIET              run quietly (same as -q option)\n"));
+ 	fprintf(output, _("  SHOW_CONTEXT       when a error context will be displayed [always, error, none]\n"));
  	fprintf(output, _("  SINGLELINE         end of line terminates SQL command mode (same as -S option)\n"));
  	fprintf(output, _("  SINGLESTEP         single-step mode (same as -s option)\n"));
  	fprintf(output, _("  USER               the currently connected database user\n"));
diff --git a/src/bin/psql/settings.h b/src/bin/psql/settings.h
new file mode 100644
index d34dc28..5b49059
*** a/src/bin/psql/settings.h
--- b/src/bin/psql/settings.h
*************** typedef struct _psqlSettings
*** 129,134 ****
--- 129,135 ----
  	const char *prompt2;
  	const char *prompt3;
  	PGVerbosity verbosity;		/* current error verbosity level */
+ 	bool		show_context;
  } PsqlSettings;
  
  extern PsqlSettings pset;
diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c
new file mode 100644
index 28ba75a..534c914
*** a/src/bin/psql/startup.c
--- b/src/bin/psql/startup.c
*************** main(int argc, char *argv[])
*** 157,162 ****
--- 157,163 ----
  	SetVariable(pset.vars, "PROMPT1", DEFAULT_PROMPT1);
  	SetVariable(pset.vars, "PROMPT2", DEFAULT_PROMPT2);
  	SetVariable(pset.vars, "PROMPT3", DEFAULT_PROMPT3);
+ 	SetVariable(pset.vars, "SHOW_CONTEXT", "error");;
  
  	parse_psql_options(argc, argv, &options);
  
*************** verbosity_hook(const char *newval)
*** 868,873 ****
--- 869,895 ----
  		PQsetErrorVerbosity(pset.db, pset.verbosity);
  }
  
+ static void
+ show_context_hook(const char *newval)
+ {
+ 	if (newval == NULL)
+ 		pset.show_context = PQSHOW_CONTEXT_ERROR;
+ 	else if (pg_strcasecmp(newval, "always") == 0)
+ 		pset.show_context = PQSHOW_CONTEXT_ALL;
+ 	else if (pg_strcasecmp(newval, "error") == 0)
+ 		pset.show_context = PQSHOW_CONTEXT_ERROR;
+ 	else if (pg_strcasecmp(newval, "none") == 0)
+ 		pset.show_context = PQSHOW_CONTEXT_NONE;
+ 	else
+ 	{
+ 		psql_error("unrecognized value \"%s\" for \"%s\"; assuming \"%s\"\n",
+ 				   newval, "SHOW_CONTEXT", "error");
+ 		pset.show_context = PQSHOW_CONTEXT_ERROR;
+ 	}
+ 
+ 	if (pset.db)
+ 		PQsetErrorContextVisibility(pset.db, pset.show_context);
+ }
  
  static void
  EstablishVariableSpace(void)
*************** EstablishVariableSpace(void)
*** 889,892 ****
--- 911,915 ----
  	SetVariableAssignHook(pset.vars, "PROMPT2", prompt2_hook);
  	SetVariableAssignHook(pset.vars, "PROMPT3", prompt3_hook);
  	SetVariableAssignHook(pset.vars, "VERBOSITY", verbosity_hook);
+ 	SetVariableAssignHook(pset.vars, "SHOW_CONTEXT", show_context_hook);
  }
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
new file mode 100644
index 9596af6..681e561
*** a/src/bin/psql/tab-complete.c
--- b/src/bin/psql/tab-complete.c
*************** psql_completion(const char *text, int st
*** 3934,3939 ****
--- 3934,3946 ----
  			COMPLETE_WITH_LIST_CS(boolean_value_list);
  		else if (strcmp(prev_wd, "SINGLESTEP") == 0)
  			COMPLETE_WITH_LIST_CS(boolean_value_list);
+ 		else if (strcmp(prev_wd, "SHOW_CONTEXT") == 0)
+ 		{
+ 			static const char *const my_list[] =
+ 			{"always", "error", "none", NULL};
+ 
+ 			COMPLETE_WITH_LIST_CS(my_list);
+ 		}
  		else if (strcmp(prev_wd, "VERBOSITY") == 0)
  		{
  			static const char *const my_list[] =
diff --git a/src/interfaces/libpq/exports.txt b/src/interfaces/libpq/exports.txt
new file mode 100644
index 4a21bf1..0bbcae5
*** a/src/interfaces/libpq/exports.txt
--- b/src/interfaces/libpq/exports.txt
*************** PQsslInUse                166
*** 169,171 ****
--- 169,172 ----
  PQsslStruct               167
  PQsslAttributes           168
  PQsslAttribute            169
+ PQsetErrorContextVisibility 170
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
new file mode 100644
index a45f4cb..81d6eb4
*** a/src/interfaces/libpq/fe-connect.c
--- b/src/interfaces/libpq/fe-connect.c
*************** PQsetErrorVerbosity(PGconn *conn, PGVerb
*** 5553,5558 ****
--- 5553,5570 ----
  	return old;
  }
  
+ PGContextVisibility
+ PQsetErrorContextVisibility(PGconn *conn, PGContextVisibility show_context)
+ {
+ 	bool	old;
+ 
+ 	if (!conn)
+ 		return PQSHOW_CONTEXT_ERROR;;
+ 	old = conn->show_context;
+ 	conn->show_context = show_context;
+ 	return old;
+ }
+ 
  void
  PQtrace(PGconn *conn, FILE *debug_port)
  {
diff --git a/src/interfaces/libpq/fe-protocol3.c b/src/interfaces/libpq/fe-protocol3.c
new file mode 100644
index dbc0d89..38fa9ad
*** a/src/interfaces/libpq/fe-protocol3.c
--- b/src/interfaces/libpq/fe-protocol3.c
*************** pqGetErrorNotice3(PGconn *conn, bool isE
*** 935,941 ****
  		if (val)
  			appendPQExpBuffer(&workBuf, libpq_gettext("QUERY:  %s\n"), val);
  		val = PQresultErrorField(res, PG_DIAG_CONTEXT);
! 		if (val)
  			appendPQExpBuffer(&workBuf, libpq_gettext("CONTEXT:  %s\n"), val);
  	}
  	if (conn->verbosity == PQERRORS_VERBOSE)
--- 935,942 ----
  		if (val)
  			appendPQExpBuffer(&workBuf, libpq_gettext("QUERY:  %s\n"), val);
  		val = PQresultErrorField(res, PG_DIAG_CONTEXT);
! 		if (val && (conn->show_context == PQSHOW_CONTEXT_ALL
! 				 || (conn->show_context == PQSHOW_CONTEXT_ERROR && isError)))
  			appendPQExpBuffer(&workBuf, libpq_gettext("CONTEXT:  %s\n"), val);
  	}
  	if (conn->verbosity == PQERRORS_VERBOSE)
diff --git a/src/interfaces/libpq/libpq-fe.h b/src/interfaces/libpq/libpq-fe.h
new file mode 100644
index a73eae2..030ad59
*** a/src/interfaces/libpq/libpq-fe.h
--- b/src/interfaces/libpq/libpq-fe.h
*************** typedef enum
*** 110,115 ****
--- 110,122 ----
  	PQERRORS_VERBOSE			/* all the facts, ma'am */
  } PGVerbosity;
  
+ typedef enum
+ {
+ 	PQSHOW_CONTEXT_ALL,		/* errors, warnings, notices */
+ 	PQSHOW_CONTEXT_ERROR,		/* errors only, default */
+ 	PQSHOW_CONTEXT_NONE		/* hide error context */
+ } PGContextVisibility;
+ 
  /*
   * PGPing - The ordering of this enum should not be altered because the
   * values are exposed externally via pg_isready.
*************** extern void PQinitOpenSSL(int do_ssl, in
*** 337,342 ****
--- 344,353 ----
  /* Set verbosity for PQerrorMessage and PQresultErrorMessage */
  extern PGVerbosity PQsetErrorVerbosity(PGconn *conn, PGVerbosity verbosity);
  
+ /* Hide a context of error message */
+ extern PGContextVisibility PQsetErrorContextVisibility(PGconn *conn,
+ 						    PGContextVisibility show_context);
+ 
  /* Enable/disable tracing */
  extern void PQtrace(PGconn *conn, FILE *debug_port);
  extern void PQuntrace(PGconn *conn);
diff --git a/src/interfaces/libpq/libpq-int.h b/src/interfaces/libpq/libpq-int.h
new file mode 100644
index 2175957..0c5e4b5
*** a/src/interfaces/libpq/libpq-int.h
--- b/src/interfaces/libpq/libpq-int.h
*************** struct pg_conn
*** 395,400 ****
--- 395,401 ----
  	bool		std_strings;	/* standard_conforming_strings */
  	PGVerbosity verbosity;		/* error/notice message verbosity */
  	PGlobjfuncs *lobjfuncs;		/* private state for large-object access fns */
+ 	PGContextVisibility	show_context;	/* controll a error context visibility */
  
  	/* Buffer for data received from backend and not yet processed */
  	char	   *inBuffer;		/* currently allocated buffer */
diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c
new file mode 100644
index b7f6360..60e5d8d
*** a/src/pl/plpgsql/src/pl_exec.c
--- b/src/pl/plpgsql/src/pl_exec.c
***************
*** 42,49 ****
  #include "utils/typcache.h"
  
  
- static const char *const raise_skip_msg = "RAISE";
- 
  typedef struct
  {
  	int			nargs;			/* number of arguments */
--- 42,47 ----
*************** plpgsql_exec_error_callback(void *arg)
*** 957,966 ****
  {
  	PLpgSQL_execstate *estate = (PLpgSQL_execstate *) arg;
  
- 	/* if we are doing RAISE, don't report its location */
- 	if (estate->err_text == raise_skip_msg)
- 		return;
- 
  	if (estate->err_text != NULL)
  	{
  		/*
--- 955,960 ----
*************** exec_stmt_raise(PLpgSQL_execstate *estat
*** 3176,3183 ****
  	/*
  	 * Throw the error (may or may not come back)
  	 */
- 	estate->err_text = raise_skip_msg;	/* suppress traceback of raise */
- 
  	ereport(stmt->elog_level,
  			(err_code ? errcode(err_code) : 0,
  			 errmsg_internal("%s", err_message),
--- 3170,3175 ----
diff --git a/src/test/regress/expected/copy2.out b/src/test/regress/expected/copy2.out
new file mode 100644
index 5e31737..72ada21
*** a/src/test/regress/expected/copy2.out
--- b/src/test/regress/expected/copy2.out
*************** Check constraints:
*** 447,458 ****
  
  copy check_con_tbl from stdin;
  NOTICE:  input = {"f1":1}
- CONTEXT:  COPY check_con_tbl, line 1: "1"
  NOTICE:  input = {"f1":null}
- CONTEXT:  COPY check_con_tbl, line 2: "\N"
  copy check_con_tbl from stdin;
  NOTICE:  input = {"f1":0}
- CONTEXT:  COPY check_con_tbl, line 1: "0"
  ERROR:  new row for relation "check_con_tbl" violates check constraint "check_con_tbl_check"
  DETAIL:  Failing row contains (0).
  CONTEXT:  COPY check_con_tbl, line 1: "0"
--- 447,455 ----
diff --git a/src/test/regress/expected/event_trigger.out b/src/test/regress/expected/event_trigger.out
new file mode 100644
index e70c315..05ac0ad
*** a/src/test/regress/expected/event_trigger.out
--- b/src/test/regress/expected/event_trigger.out
*************** drop cascades to table schema_one.table_
*** 234,248 ****
  drop cascades to table schema_one."table two"
  drop cascades to table schema_one.table_three
  NOTICE:  table "schema_two_table_two" does not exist, skipping
- CONTEXT:  SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_two_table_two"
- PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement
  NOTICE:  table "audit_tbls_schema_two_table_three" does not exist, skipping
- CONTEXT:  SQL statement "DROP TABLE IF EXISTS audit_tbls.audit_tbls_schema_two_table_three"
- PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement
- SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_two_table_three"
- PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement
  ERROR:  object audit_tbls.schema_two_table_three of type table cannot be dropped
! CONTEXT:  SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_two_table_three"
  PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement
  DELETE FROM undroppable_objs WHERE object_identity = 'audit_tbls.schema_two_table_three';
  DROP SCHEMA schema_one, schema_two CASCADE;
--- 234,243 ----
  drop cascades to table schema_one."table two"
  drop cascades to table schema_one.table_three
  NOTICE:  table "schema_two_table_two" does not exist, skipping
  NOTICE:  table "audit_tbls_schema_two_table_three" does not exist, skipping
  ERROR:  object audit_tbls.schema_two_table_three of type table cannot be dropped
! CONTEXT:  PL/pgSQL function undroppable() line 14 at RAISE
! SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_two_table_three"
  PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement
  DELETE FROM undroppable_objs WHERE object_identity = 'audit_tbls.schema_two_table_three';
  DROP SCHEMA schema_one, schema_two CASCADE;
*************** drop cascades to table schema_one.table_
*** 255,277 ****
  drop cascades to table schema_one."table two"
  drop cascades to table schema_one.table_three
  NOTICE:  table "schema_two_table_two" does not exist, skipping
- CONTEXT:  SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_two_table_two"
- PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement
  NOTICE:  table "audit_tbls_schema_two_table_three" does not exist, skipping
- CONTEXT:  SQL statement "DROP TABLE IF EXISTS audit_tbls.audit_tbls_schema_two_table_three"
- PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement
- SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_two_table_three"
- PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement
  NOTICE:  table "schema_one_table_one" does not exist, skipping
- CONTEXT:  SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_one_table_one"
- PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement
  NOTICE:  table "schema_one_table two" does not exist, skipping
- CONTEXT:  SQL statement "DROP TABLE IF EXISTS audit_tbls."schema_one_table two""
- PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement
  NOTICE:  table "schema_one_table_three" does not exist, skipping
- CONTEXT:  SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_one_table_three"
- PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement
  ERROR:  object schema_one.table_three of type table cannot be dropped
  DELETE FROM undroppable_objs WHERE object_identity = 'schema_one.table_three';
  DROP SCHEMA schema_one, schema_two CASCADE;
  NOTICE:  drop cascades to 7 other objects
--- 250,261 ----
  drop cascades to table schema_one."table two"
  drop cascades to table schema_one.table_three
  NOTICE:  table "schema_two_table_two" does not exist, skipping
  NOTICE:  table "audit_tbls_schema_two_table_three" does not exist, skipping
  NOTICE:  table "schema_one_table_one" does not exist, skipping
  NOTICE:  table "schema_one_table two" does not exist, skipping
  NOTICE:  table "schema_one_table_three" does not exist, skipping
  ERROR:  object schema_one.table_three of type table cannot be dropped
+ CONTEXT:  PL/pgSQL function undroppable() line 14 at RAISE
  DELETE FROM undroppable_objs WHERE object_identity = 'schema_one.table_three';
  DROP SCHEMA schema_one, schema_two CASCADE;
  NOTICE:  drop cascades to 7 other objects
*************** drop cascades to table schema_one.table_
*** 283,304 ****
  drop cascades to table schema_one."table two"
  drop cascades to table schema_one.table_three
  NOTICE:  table "schema_two_table_two" does not exist, skipping
- CONTEXT:  SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_two_table_two"
- PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement
  NOTICE:  table "audit_tbls_schema_two_table_three" does not exist, skipping
- CONTEXT:  SQL statement "DROP TABLE IF EXISTS audit_tbls.audit_tbls_schema_two_table_three"
- PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement
- SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_two_table_three"
- PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement
  NOTICE:  table "schema_one_table_one" does not exist, skipping
- CONTEXT:  SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_one_table_one"
- PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement
  NOTICE:  table "schema_one_table two" does not exist, skipping
- CONTEXT:  SQL statement "DROP TABLE IF EXISTS audit_tbls."schema_one_table two""
- PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement
  NOTICE:  table "schema_one_table_three" does not exist, skipping
- CONTEXT:  SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_one_table_three"
- PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement
  SELECT * FROM dropped_objects WHERE schema IS NULL OR schema <> 'pg_toast';
       type     |   schema   |               object                
  --------------+------------+-------------------------------------
--- 267,276 ----
*************** SELECT * FROM dropped_objects WHERE sche
*** 329,336 ****
  
  DROP OWNED BY regression_bob;
  NOTICE:  schema "audit_tbls" does not exist, skipping
- CONTEXT:  SQL statement "DROP TABLE IF EXISTS audit_tbls.audit_tbls_schema_one_table_two"
- PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement
  SELECT * FROM dropped_objects WHERE type = 'schema';
    type  | schema |   object   
  --------+--------+------------
--- 301,306 ----
*************** insert into rewriteme
*** 402,409 ****
--- 372,381 ----
       select x * 1.001 from generate_series(1, 500) as t(x);
  alter table rewriteme alter column foo type numeric;
  ERROR:  I'm sorry Sir, No Rewrite Allowed.
+ CONTEXT:  PL/pgSQL function test_evtrig_no_rewrite() line 3 at RAISE
  alter table rewriteme add column baz int default 0;
  ERROR:  I'm sorry Sir, No Rewrite Allowed.
+ CONTEXT:  PL/pgSQL function test_evtrig_no_rewrite() line 3 at RAISE
  -- test with more than one reason to rewrite a single table
  CREATE OR REPLACE FUNCTION test_evtrig_no_rewrite() RETURNS event_trigger
  LANGUAGE plpgsql AS $$
diff --git a/src/test/regress/expected/plancache.out b/src/test/regress/expected/plancache.out
new file mode 100644
index 864f70f..3f3db33
*** a/src/test/regress/expected/plancache.out
--- b/src/test/regress/expected/plancache.out
*************** begin
*** 234,241 ****
  end$$ language plpgsql;
  select cachebug();
  NOTICE:  table "temptable" does not exist, skipping
- CONTEXT:  SQL statement "drop table if exists temptable cascade"
- PL/pgSQL function cachebug() line 4 at SQL statement
  NOTICE:  1
  NOTICE:  2
  NOTICE:  3
--- 234,239 ----
*************** NOTICE:  3
*** 246,253 ****
  
  select cachebug();
  NOTICE:  drop cascades to view vv
- CONTEXT:  SQL statement "drop table if exists temptable cascade"
- PL/pgSQL function cachebug() line 4 at SQL statement
  NOTICE:  1
  NOTICE:  2
  NOTICE:  3
--- 244,249 ----
diff --git a/src/test/regress/expected/plpgsql.out b/src/test/regress/expected/plpgsql.out
new file mode 100644
index 31182db..97105e5
*** a/src/test/regress/expected/plpgsql.out
--- b/src/test/regress/expected/plpgsql.out
*************** ERROR:  duplicate key value violates uni
*** 1518,1544 ****
  DETAIL:  Key (name)=(PF1_1) already exists.
  update PSlot set backlink = 'WS.not.there' where slotname = 'PS.base.a1';
  ERROR:  WS.not.there         does not exist
! CONTEXT:  PL/pgSQL function tg_backlink_a() line 17 at assignment
  update PSlot set backlink = 'XX.illegal' where slotname = 'PS.base.a1';
  ERROR:  illegal backlink beginning with XX
! CONTEXT:  PL/pgSQL function tg_backlink_a() line 17 at assignment
  update PSlot set slotlink = 'PS.not.there' where slotname = 'PS.base.a1';
  ERROR:  PS.not.there         does not exist
! CONTEXT:  PL/pgSQL function tg_slotlink_a() line 17 at assignment
  update PSlot set slotlink = 'XX.illegal' where slotname = 'PS.base.a1';
  ERROR:  illegal slotlink beginning with XX
! CONTEXT:  PL/pgSQL function tg_slotlink_a() line 17 at assignment
  insert into HSlot values ('HS', 'base.hub1', 1, '');
  ERROR:  duplicate key value violates unique constraint "hslot_name"
  DETAIL:  Key (slotname)=(HS.base.hub1.1      ) already exists.
  insert into HSlot values ('HS', 'base.hub1', 20, '');
  ERROR:  no manual manipulation of HSlot
  delete from HSlot;
  ERROR:  no manual manipulation of HSlot
  insert into IFace values ('IF', 'notthere', 'eth0', '');
  ERROR:  system "notthere" does not exist
  insert into IFace values ('IF', 'orion', 'ethernet_interface_name_too_long', '');
  ERROR:  IFace slotname "IF.orion.ethernet_interface_name_too_long" too long (20 char max)
  --
  -- The following tests are unrelated to the scenario outlined above;
  -- they merely exercise specific parts of PL/pgSQL
--- 1518,1552 ----
  DETAIL:  Key (name)=(PF1_1) already exists.
  update PSlot set backlink = 'WS.not.there' where slotname = 'PS.base.a1';
  ERROR:  WS.not.there         does not exist
! CONTEXT:  PL/pgSQL function tg_backlink_set(character,character) line 30 at RAISE
! PL/pgSQL function tg_backlink_a() line 17 at assignment
  update PSlot set backlink = 'XX.illegal' where slotname = 'PS.base.a1';
  ERROR:  illegal backlink beginning with XX
! CONTEXT:  PL/pgSQL function tg_backlink_set(character,character) line 47 at RAISE
! PL/pgSQL function tg_backlink_a() line 17 at assignment
  update PSlot set slotlink = 'PS.not.there' where slotname = 'PS.base.a1';
  ERROR:  PS.not.there         does not exist
! CONTEXT:  PL/pgSQL function tg_slotlink_set(character,character) line 30 at RAISE
! PL/pgSQL function tg_slotlink_a() line 17 at assignment
  update PSlot set slotlink = 'XX.illegal' where slotname = 'PS.base.a1';
  ERROR:  illegal slotlink beginning with XX
! CONTEXT:  PL/pgSQL function tg_slotlink_set(character,character) line 77 at RAISE
! PL/pgSQL function tg_slotlink_a() line 17 at assignment
  insert into HSlot values ('HS', 'base.hub1', 1, '');
  ERROR:  duplicate key value violates unique constraint "hslot_name"
  DETAIL:  Key (slotname)=(HS.base.hub1.1      ) already exists.
  insert into HSlot values ('HS', 'base.hub1', 20, '');
  ERROR:  no manual manipulation of HSlot
+ CONTEXT:  PL/pgSQL function tg_hslot_biu() line 12 at RAISE
  delete from HSlot;
  ERROR:  no manual manipulation of HSlot
+ CONTEXT:  PL/pgSQL function tg_hslot_bd() line 12 at RAISE
  insert into IFace values ('IF', 'notthere', 'eth0', '');
  ERROR:  system "notthere" does not exist
+ CONTEXT:  PL/pgSQL function tg_iface_biu() line 8 at RAISE
  insert into IFace values ('IF', 'orion', 'ethernet_interface_name_too_long', '');
  ERROR:  IFace slotname "IF.orion.ethernet_interface_name_too_long" too long (20 char max)
+ CONTEXT:  PL/pgSQL function tg_iface_biu() line 14 at RAISE
  --
  -- The following tests are unrelated to the scenario outlined above;
  -- they merely exercise specific parts of PL/pgSQL
*************** NOTICE:  should see this
*** 1963,1968 ****
--- 1971,1977 ----
  NOTICE:  should see this only if -100 <> 0
  NOTICE:  should see this only if -100 fits in smallint
  ERROR:  -100 is less than zero
+ CONTEXT:  PL/pgSQL function trap_zero_divide(integer) line 12 at RAISE
  create function trap_matching_test(int) returns int as $$
  declare x int;
  	sx smallint;
*************** begin
*** 2066,2079 ****
  end$$ language plpgsql;
  select test_variable_storage();
  NOTICE:  should see this
- CONTEXT:  SQL statement "SELECT trap_zero_divide(-100)"
- PL/pgSQL function test_variable_storage() line 8 at PERFORM
  NOTICE:  should see this only if -100 <> 0
- CONTEXT:  SQL statement "SELECT trap_zero_divide(-100)"
- PL/pgSQL function test_variable_storage() line 8 at PERFORM
  NOTICE:  should see this only if -100 fits in smallint
- CONTEXT:  SQL statement "SELECT trap_zero_divide(-100)"
- PL/pgSQL function test_variable_storage() line 8 at PERFORM
   test_variable_storage 
  -----------------------
   123456789012
--- 2075,2082 ----
*************** DETAIL:  some detail info
*** 4052,4057 ****
--- 4055,4061 ----
  HINT:  some hint
  ERROR:  1 2 3
  DETAIL:  some detail info
+ CONTEXT:  PL/pgSQL function raise_test() line 5 at RAISE
  -- Since we can't actually see the thrown SQLSTATE in default psql output,
  -- test it like this; this also tests re-RAISE
  create or replace function raise_test() returns void as $$
*************** select raise_test();
*** 4068,4073 ****
--- 4072,4078 ----
  NOTICE:  SQLSTATE: 22012 SQLERRM: check me
  ERROR:  check me
  DETAIL:  some detail info
+ CONTEXT:  PL/pgSQL function raise_test() line 3 at RAISE
  create or replace function raise_test() returns void as $$
  begin
    raise 'check me'
*************** select raise_test();
*** 4082,4087 ****
--- 4087,4093 ----
  NOTICE:  SQLSTATE: 1234F SQLERRM: check me
  ERROR:  check me
  DETAIL:  some detail info
+ CONTEXT:  PL/pgSQL function raise_test() line 3 at RAISE
  -- SQLSTATE specification in WHEN
  create or replace function raise_test() returns void as $$
  begin
*************** select raise_test();
*** 4097,4102 ****
--- 4103,4109 ----
  NOTICE:  SQLSTATE: 1234F SQLERRM: check me
  ERROR:  check me
  DETAIL:  some detail info
+ CONTEXT:  PL/pgSQL function raise_test() line 3 at RAISE
  create or replace function raise_test() returns void as $$
  begin
    raise division_by_zero using detail = 'some detail info';
*************** select raise_test();
*** 4110,4115 ****
--- 4117,4123 ----
  NOTICE:  SQLSTATE: 22012 SQLERRM: division_by_zero
  ERROR:  division_by_zero
  DETAIL:  some detail info
+ CONTEXT:  PL/pgSQL function raise_test() line 3 at RAISE
  create or replace function raise_test() returns void as $$
  begin
    raise division_by_zero;
*************** end;
*** 4117,4122 ****
--- 4125,4131 ----
  $$ language plpgsql;
  select raise_test();
  ERROR:  division_by_zero
+ CONTEXT:  PL/pgSQL function raise_test() line 3 at RAISE
  create or replace function raise_test() returns void as $$
  begin
    raise sqlstate '1234F';
*************** end;
*** 4124,4129 ****
--- 4133,4139 ----
  $$ language plpgsql;
  select raise_test();
  ERROR:  1234F
+ CONTEXT:  PL/pgSQL function raise_test() line 3 at RAISE
  create or replace function raise_test() returns void as $$
  begin
    raise division_by_zero using message = 'custom' || ' message';
*************** end;
*** 4131,4136 ****
--- 4141,4147 ----
  $$ language plpgsql;
  select raise_test();
  ERROR:  custom message
+ CONTEXT:  PL/pgSQL function raise_test() line 3 at RAISE
  create or replace function raise_test() returns void as $$
  begin
    raise using message = 'custom' || ' message', errcode = '22012';
*************** end;
*** 4138,4143 ****
--- 4149,4155 ----
  $$ language plpgsql;
  select raise_test();
  ERROR:  custom message
+ CONTEXT:  PL/pgSQL function raise_test() line 3 at RAISE
  -- conflict on message
  create or replace function raise_test() returns void as $$
  begin
*************** $$ language plpgsql;
*** 4254,4259 ****
--- 4266,4272 ----
  select raise_test();
  NOTICE:  22012
  ERROR:  substitute message
+ CONTEXT:  PL/pgSQL function raise_test() line 7 at RAISE
  drop function raise_test();
  -- test passing column_name, constraint_name, datatype_name, table_name
  -- and schema_name error fields
*************** LINE 1: SELECT 'foo\\bar\041baz'
*** 4806,4812 ****
                 ^
  HINT:  Use the escape string syntax for backslashes, e.g., E'\\'.
  QUERY:  SELECT 'foo\\bar\041baz'
- CONTEXT:  PL/pgSQL function strtest() line 4 at RETURN
     strtest   
  -------------
   foo\bar!baz
--- 4819,4824 ----
*************** $$ language plpgsql;
*** 5322,5343 ****
  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 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 
  ------------------
--- 5334,5347 ----
*************** NOTICE:  outer_func() done
*** 5348,5369 ****
  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 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 
  ------------------
--- 5352,5365 ----
*************** $$ language plpgsql;
*** 5420,5441 ****
  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 10 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:  ***PL/pgSQL function inner_func(integer) line 15 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 
  ------------------
--- 5416,5429 ----
*************** NOTICE:  outer_func() done
*** 5446,5467 ****
  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 10 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:  ***PL/pgSQL function inner_func(integer) line 15 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 
  ------------------
--- 5434,5447 ----
diff --git a/src/test/regress/expected/privileges.out b/src/test/regress/expected/privileges.out
new file mode 100644
index c0cd9fa..88bdc2c
*** a/src/test/regress/expected/privileges.out
--- b/src/test/regress/expected/privileges.out
*************** GRANT regressgroup2 TO regressuser5; --
*** 1023,1029 ****
  ERROR:  must have admin option on role "regressgroup2"
  SELECT dogrant_ok();			-- ok: SECURITY DEFINER conveys ADMIN
  NOTICE:  role "regressuser5" is already a member of role "regressgroup2"
- CONTEXT:  SQL function "dogrant_ok" statement 1
   dogrant_ok 
  ------------
   
--- 1023,1028 ----
diff --git a/src/test/regress/expected/rangefuncs.out b/src/test/regress/expected/rangefuncs.out
new file mode 100644
index 6dabe50..00ef421
*** a/src/test/regress/expected/rangefuncs.out
--- b/src/test/regress/expected/rangefuncs.out
*************** create trigger tnoticetrigger after inse
*** 1704,1712 ****
  execute procedure noticetrigger();
  select insert_tt2('foolme','barme') limit 1;
  NOTICE:  noticetrigger 11 foolme
- CONTEXT:  SQL function "insert_tt2" statement 1
  NOTICE:  noticetrigger 12 barme
- CONTEXT:  SQL function "insert_tt2" statement 1
   insert_tt2 
  ------------
           11
--- 1704,1710 ----
*************** create rule insert_tt_rule as on insert
*** 1735,1743 ****
    insert into tt_log values(new.*);
  select insert_tt2('foollog','barlog') limit 1;
  NOTICE:  noticetrigger 13 foollog
- CONTEXT:  SQL function "insert_tt2" statement 1
  NOTICE:  noticetrigger 14 barlog
- CONTEXT:  SQL function "insert_tt2" statement 1
   insert_tt2 
  ------------
           13
--- 1733,1739 ----
diff --git a/src/test/regress/expected/triggers.out b/src/test/regress/expected/triggers.out
new file mode 100644
index 3b32e8f..cd43e46
*** a/src/test/regress/expected/triggers.out
--- b/src/test/regress/expected/triggers.out
*************** NOTICE:  main_view BEFORE INSERT STATEME
*** 958,968 ****
  NOTICE:  main_view INSTEAD OF INSERT ROW (instead_of_ins)
  NOTICE:  NEW: (20,30)
  NOTICE:  trigger_func(before_ins_stmt) called: action = INSERT, when = BEFORE, level = STATEMENT
- CONTEXT:  SQL statement "INSERT INTO main_table VALUES (NEW.a, NEW.b)"
- PL/pgSQL function view_trigger() line 17 at SQL statement
  NOTICE:  trigger_func(after_ins_stmt) called: action = INSERT, when = AFTER, level = STATEMENT
- CONTEXT:  SQL statement "INSERT INTO main_table VALUES (NEW.a, NEW.b)"
- PL/pgSQL function view_trigger() line 17 at SQL statement
  NOTICE:  main_view AFTER INSERT STATEMENT (after_view_ins_stmt)
  INSERT 0 1
  INSERT INTO main_view VALUES (21, 31) RETURNING a, b;
--- 958,964 ----
*************** NOTICE:  main_view BEFORE INSERT STATEME
*** 970,980 ****
  NOTICE:  main_view INSTEAD OF INSERT ROW (instead_of_ins)
  NOTICE:  NEW: (21,31)
  NOTICE:  trigger_func(before_ins_stmt) called: action = INSERT, when = BEFORE, level = STATEMENT
- CONTEXT:  SQL statement "INSERT INTO main_table VALUES (NEW.a, NEW.b)"
- PL/pgSQL function view_trigger() line 17 at SQL statement
  NOTICE:  trigger_func(after_ins_stmt) called: action = INSERT, when = AFTER, level = STATEMENT
- CONTEXT:  SQL statement "INSERT INTO main_table VALUES (NEW.a, NEW.b)"
- PL/pgSQL function view_trigger() line 17 at SQL statement
  NOTICE:  main_view AFTER INSERT STATEMENT (after_view_ins_stmt)
   a  | b  
  ----+----
--- 966,972 ----
*************** NOTICE:  main_view BEFORE UPDATE STATEME
*** 988,1004 ****
  NOTICE:  main_view INSTEAD OF UPDATE ROW (instead_of_upd)
  NOTICE:  OLD: (20,30), NEW: (20,31)
  NOTICE:  trigger_func(before_upd_a_stmt) called: action = UPDATE, when = BEFORE, level = STATEMENT
- CONTEXT:  SQL statement "UPDATE main_table SET a = NEW.a, b = NEW.b WHERE a = OLD.a AND b = OLD.b"
- PL/pgSQL function view_trigger() line 23 at SQL statement
  NOTICE:  trigger_func(before_upd_a_row) called: action = UPDATE, when = BEFORE, level = ROW
- CONTEXT:  SQL statement "UPDATE main_table SET a = NEW.a, b = NEW.b WHERE a = OLD.a AND b = OLD.b"
- PL/pgSQL function view_trigger() line 23 at SQL statement
  NOTICE:  trigger_func(after_upd_b_stmt) called: action = UPDATE, when = AFTER, level = STATEMENT
- CONTEXT:  SQL statement "UPDATE main_table SET a = NEW.a, b = NEW.b WHERE a = OLD.a AND b = OLD.b"
- PL/pgSQL function view_trigger() line 23 at SQL statement
  NOTICE:  trigger_func(after_upd_stmt) called: action = UPDATE, when = AFTER, level = STATEMENT
- CONTEXT:  SQL statement "UPDATE main_table SET a = NEW.a, b = NEW.b WHERE a = OLD.a AND b = OLD.b"
- PL/pgSQL function view_trigger() line 23 at SQL statement
  NOTICE:  main_view AFTER UPDATE STATEMENT (after_view_upd_stmt)
  UPDATE 0
  UPDATE main_view SET b = 32 WHERE a = 21 AND b = 31 RETURNING a, b;
--- 980,988 ----
*************** NOTICE:  main_view BEFORE UPDATE STATEME
*** 1006,1022 ****
  NOTICE:  main_view INSTEAD OF UPDATE ROW (instead_of_upd)
  NOTICE:  OLD: (21,31), NEW: (21,32)
  NOTICE:  trigger_func(before_upd_a_stmt) called: action = UPDATE, when = BEFORE, level = STATEMENT
- CONTEXT:  SQL statement "UPDATE main_table SET a = NEW.a, b = NEW.b WHERE a = OLD.a AND b = OLD.b"
- PL/pgSQL function view_trigger() line 23 at SQL statement
  NOTICE:  trigger_func(before_upd_a_row) called: action = UPDATE, when = BEFORE, level = ROW
- CONTEXT:  SQL statement "UPDATE main_table SET a = NEW.a, b = NEW.b WHERE a = OLD.a AND b = OLD.b"
- PL/pgSQL function view_trigger() line 23 at SQL statement
  NOTICE:  trigger_func(after_upd_b_stmt) called: action = UPDATE, when = AFTER, level = STATEMENT
- CONTEXT:  SQL statement "UPDATE main_table SET a = NEW.a, b = NEW.b WHERE a = OLD.a AND b = OLD.b"
- PL/pgSQL function view_trigger() line 23 at SQL statement
  NOTICE:  trigger_func(after_upd_stmt) called: action = UPDATE, when = AFTER, level = STATEMENT
- CONTEXT:  SQL statement "UPDATE main_table SET a = NEW.a, b = NEW.b WHERE a = OLD.a AND b = OLD.b"
- PL/pgSQL function view_trigger() line 23 at SQL statement
  NOTICE:  main_view AFTER UPDATE STATEMENT (after_view_upd_stmt)
   a | b 
  ---+---
--- 990,998 ----
*************** NOTICE:  main_view BEFORE UPDATE STATEME
*** 1031,1050 ****
  NOTICE:  main_view INSTEAD OF UPDATE ROW (instead_of_upd)
  NOTICE:  OLD: (20,30), NEW: (20,31)
  NOTICE:  trigger_func(before_upd_a_stmt) called: action = UPDATE, when = BEFORE, level = STATEMENT
- CONTEXT:  SQL statement "UPDATE main_table SET a = NEW.a, b = NEW.b WHERE a = OLD.a AND b = OLD.b"
- PL/pgSQL function view_trigger() line 23 at SQL statement
  NOTICE:  trigger_func(after_upd_a_b_row) called: action = UPDATE, when = AFTER, level = ROW
- CONTEXT:  SQL statement "UPDATE main_table SET a = NEW.a, b = NEW.b WHERE a = OLD.a AND b = OLD.b"
- PL/pgSQL function view_trigger() line 23 at SQL statement
  NOTICE:  trigger_func(after_upd_b_row) called: action = UPDATE, when = AFTER, level = ROW
- CONTEXT:  SQL statement "UPDATE main_table SET a = NEW.a, b = NEW.b WHERE a = OLD.a AND b = OLD.b"
- PL/pgSQL function view_trigger() line 23 at SQL statement
  NOTICE:  trigger_func(after_upd_b_stmt) called: action = UPDATE, when = AFTER, level = STATEMENT
- CONTEXT:  SQL statement "UPDATE main_table SET a = NEW.a, b = NEW.b WHERE a = OLD.a AND b = OLD.b"
- PL/pgSQL function view_trigger() line 23 at SQL statement
  NOTICE:  trigger_func(after_upd_stmt) called: action = UPDATE, when = AFTER, level = STATEMENT
- CONTEXT:  SQL statement "UPDATE main_table SET a = NEW.a, b = NEW.b WHERE a = OLD.a AND b = OLD.b"
- PL/pgSQL function view_trigger() line 23 at SQL statement
  NOTICE:  main_view AFTER UPDATE STATEMENT (after_view_upd_stmt)
  UPDATE 1
  UPDATE main_view SET b = 32 WHERE a = 21 AND b = 31 RETURNING a, b;
--- 1007,1016 ----
*************** NOTICE:  main_view BEFORE UPDATE STATEME
*** 1052,1071 ****
  NOTICE:  main_view INSTEAD OF UPDATE ROW (instead_of_upd)
  NOTICE:  OLD: (21,31), NEW: (21,32)
  NOTICE:  trigger_func(before_upd_a_stmt) called: action = UPDATE, when = BEFORE, level = STATEMENT
- CONTEXT:  SQL statement "UPDATE main_table SET a = NEW.a, b = NEW.b WHERE a = OLD.a AND b = OLD.b"
- PL/pgSQL function view_trigger() line 23 at SQL statement
  NOTICE:  trigger_func(after_upd_a_b_row) called: action = UPDATE, when = AFTER, level = ROW
- CONTEXT:  SQL statement "UPDATE main_table SET a = NEW.a, b = NEW.b WHERE a = OLD.a AND b = OLD.b"
- PL/pgSQL function view_trigger() line 23 at SQL statement
  NOTICE:  trigger_func(after_upd_b_row) called: action = UPDATE, when = AFTER, level = ROW
- CONTEXT:  SQL statement "UPDATE main_table SET a = NEW.a, b = NEW.b WHERE a = OLD.a AND b = OLD.b"
- PL/pgSQL function view_trigger() line 23 at SQL statement
  NOTICE:  trigger_func(after_upd_b_stmt) called: action = UPDATE, when = AFTER, level = STATEMENT
- CONTEXT:  SQL statement "UPDATE main_table SET a = NEW.a, b = NEW.b WHERE a = OLD.a AND b = OLD.b"
- PL/pgSQL function view_trigger() line 23 at SQL statement
  NOTICE:  trigger_func(after_upd_stmt) called: action = UPDATE, when = AFTER, level = STATEMENT
- CONTEXT:  SQL statement "UPDATE main_table SET a = NEW.a, b = NEW.b WHERE a = OLD.a AND b = OLD.b"
- PL/pgSQL function view_trigger() line 23 at SQL statement
  NOTICE:  main_view AFTER UPDATE STATEMENT (after_view_upd_stmt)
   a  | b  
  ----+----
--- 1018,1027 ----
*************** INSERT 0 1
*** 1277,1282 ****
--- 1233,1239 ----
  -- UPDATE .. RETURNING
  UPDATE city_view SET country_name = 'Japon' WHERE city_name = 'Tokyo'; -- error
  ERROR:  No such country: "Japon"
+ CONTEXT:  PL/pgSQL function city_update() line 9 at RAISE
  UPDATE city_view SET country_name = 'Japan' WHERE city_name = 'Takyo'; -- no match
  UPDATE 0
  UPDATE city_view SET country_name = 'Japan' WHERE city_name = 'Tokyo' RETURNING *; -- OK
*************** select pg_trigger_depth();
*** 1489,1514 ****
  insert into depth_a values (1);
  NOTICE:  depth_a_tr: depth = 1
  NOTICE:  depth_b_tr: depth = 2
- CONTEXT:  SQL statement "insert into depth_b values (new.id)"
- PL/pgSQL function depth_a_tf() line 4 at SQL statement
  NOTICE:  depth_c_tr: depth = 3
- CONTEXT:  SQL statement "insert into depth_c values (1)"
- PL/pgSQL function depth_b_tf() line 5 at EXECUTE statement
- SQL statement "insert into depth_b values (new.id)"
- PL/pgSQL function depth_a_tf() line 4 at SQL statement
  NOTICE:  SQLSTATE = U9999: depth = 2
- CONTEXT:  SQL statement "insert into depth_b values (new.id)"
- PL/pgSQL function depth_a_tf() line 4 at SQL statement
  NOTICE:  depth_b_tr: depth = 2
- CONTEXT:  SQL statement "insert into depth_b values (new.id)"
- PL/pgSQL function depth_a_tf() line 4 at SQL statement
  NOTICE:  depth_c_tr: depth = 3
- CONTEXT:  SQL statement "insert into depth_c values (1)"
- PL/pgSQL function depth_b_tf() line 12 at EXECUTE statement
- SQL statement "insert into depth_b values (new.id)"
- PL/pgSQL function depth_a_tf() line 4 at SQL statement
  ERROR:  U9999
! CONTEXT:  SQL statement "insert into depth_c values (1)"
  PL/pgSQL function depth_b_tf() line 12 at EXECUTE statement
  SQL statement "insert into depth_b values (new.id)"
  PL/pgSQL function depth_a_tf() line 4 at SQL statement
--- 1446,1458 ----
  insert into depth_a values (1);
  NOTICE:  depth_a_tr: depth = 1
  NOTICE:  depth_b_tr: depth = 2
  NOTICE:  depth_c_tr: depth = 3
  NOTICE:  SQLSTATE = U9999: depth = 2
  NOTICE:  depth_b_tr: depth = 2
  NOTICE:  depth_c_tr: depth = 3
  ERROR:  U9999
! CONTEXT:  PL/pgSQL function depth_c_tf() line 5 at RAISE
! SQL statement "insert into depth_c values (1)"
  PL/pgSQL function depth_b_tf() line 12 at EXECUTE statement
  SQL statement "insert into depth_b values (new.id)"
  PL/pgSQL function depth_a_tf() line 4 at SQL statement
*************** select pg_trigger_depth();
*** 1521,1541 ****
  insert into depth_a values (2);
  NOTICE:  depth_a_tr: depth = 1
  NOTICE:  depth_b_tr: depth = 2
- CONTEXT:  SQL statement "insert into depth_b values (new.id)"
- PL/pgSQL function depth_a_tf() line 4 at SQL statement
  NOTICE:  depth_c_tr: depth = 3
- CONTEXT:  SQL statement "insert into depth_c values (2)"
- PL/pgSQL function depth_b_tf() line 5 at EXECUTE statement
- SQL statement "insert into depth_b values (new.id)"
- PL/pgSQL function depth_a_tf() line 4 at SQL statement
  NOTICE:  depth_c_tr: depth = 3
- CONTEXT:  SQL statement "insert into depth_c values (2)"
- PL/pgSQL function depth_b_tf() line 5 at EXECUTE statement
- SQL statement "insert into depth_b values (new.id)"
- PL/pgSQL function depth_a_tf() line 4 at SQL statement
  NOTICE:  depth_b_tr: depth = 2
- CONTEXT:  SQL statement "insert into depth_b values (new.id)"
- PL/pgSQL function depth_a_tf() line 4 at SQL statement
  NOTICE:  depth_a_tr: depth = 1
  select pg_trigger_depth();
   pg_trigger_depth 
--- 1465,1473 ----
diff --git a/src/test/regress/expected/xml.out b/src/test/regress/expected/xml.out
new file mode 100644
index 9b2d264..5691e47
*** a/src/test/regress/expected/xml.out
--- b/src/test/regress/expected/xml.out
*************** SELECT xpath('/*', '<relativens xmlns=''
*** 934,940 ****
  WARNING:  line 1: xmlns: URI relative is not absolute
  <relativens xmlns='relative'/>
                              ^
- CONTEXT:  SQL function "xpath" statement 1
                  xpath                 
  --------------------------------------
   {"<relativens xmlns=\"relative\"/>"}
--- 934,939 ----
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to