Re: [PATCHES] schema-qualified SET CONSTRAINTS

2006-04-26 Thread Bruce Momjian

Patch applied.  Thanks.  I also updated our SGML documentation:

The current schema search path is used to find the first matching name
if no schema name is specified.

---


Kris Jurka wrote:
> 
> The attached patch allows SET CONSTRAINTS to take a schema qualified 
> constraint name (myschema.t1_fk_t2) and when given a bare constraint name 
> it uses the search_path to determine the matching constraint instead of 
> the previous behavior of disabling all identically named constraints.
> 
> Kris Jurka

Content-Description: 

[ Attachment, skipping... ]

-- 
  Bruce Momjian   http://candle.pha.pa.us
  EnterpriseDBhttp://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

---(end of broadcast)---
TIP 4: Have you searched our list archives?

   http://archives.postgresql.org


Re: [PATCHES] schema-qualified SET CONSTRAINTS

2006-04-17 Thread Bruce Momjian

Based on discussion, it seems the idea of using search path seems
accepted.

Your patch has been added to the PostgreSQL unapplied patches list at:

http://momjian.postgresql.org/cgi-bin/pgpatches

It will be applied as soon as one of the PostgreSQL committers reviews
and approves it.

---


Kris Jurka wrote:
> 
> The attached patch allows SET CONSTRAINTS to take a schema qualified 
> constraint name (myschema.t1_fk_t2) and when given a bare constraint name 
> it uses the search_path to determine the matching constraint instead of 
> the previous behavior of disabling all identically named constraints.
> 
> Kris Jurka

Content-Description: 

[ Attachment, skipping... ]

-- 
  Bruce Momjian   http://candle.pha.pa.us
  EnterpriseDBhttp://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly


Re: [PATCHES] schema-qualified SET CONSTRAINTS

2006-04-10 Thread Tom Lane
Kris Jurka <[EMAIL PROTECTED]> writes:
> The attached patch allows SET CONSTRAINTS to take a schema qualified 
> constraint name (myschema.t1_fk_t2) and when given a bare constraint name 
> it uses the search_path to determine the matching constraint instead of 
> the previous behavior of disabling all identically named constraints.

This patch seems egregiously non backwards compatible :-(.  A behavior
that would be backwards compatible is to retain the previous behavior
given an un-qualified name, while if given a schema-qualified name,
modify all matching constraints within that schema.  That doesn't seem
very self-consistent though.  A compromise that might succeed in making
*everybody* unhappy would be for the unqualified-name case to only
affect constraints that are visible in the current search path (but
affect all of them, not only one as in this patch).

Given the fundamental point that we don't insist on uniqueness of
constraint names within schemas, I'm not sure that the spec gives us
any useful guidance on what SET CONSTRAINTS should affect.

Anyway, I'm not sure what to do, but I am sure it requires some
discussion not just a patch.

regards, tom lane

---(end of broadcast)---
TIP 2: Don't 'kill -9' the postmaster


[PATCHES] schema-qualified SET CONSTRAINTS

2006-04-10 Thread Kris Jurka


The attached patch allows SET CONSTRAINTS to take a schema qualified 
constraint name (myschema.t1_fk_t2) and when given a bare constraint name 
it uses the search_path to determine the matching constraint instead of 
the previous behavior of disabling all identically named constraints.


Kris Jurka? src/backend/parser/.deps
? src/backend/commands/.deps
? src/backend/commands/.trigger.c.swp
Index: src/backend/parser/gram.y
===
RCS file: /projects/cvsroot/pgsql/src/backend/parser/gram.y,v
retrieving revision 2.537
diff -c -r2.537 gram.y
*** src/backend/parser/gram.y   23 Mar 2006 00:19:29 -  2.537
--- src/backend/parser/gram.y   11 Apr 2006 00:01:54 -
***
*** 1282,1288 
  
  constraints_set_list:
ALL 
{ $$ = NIL; }
!   | name_list 
{ $$ = $1; }
;
  
  constraints_set_mode:
--- 1282,1288 
  
  constraints_set_list:
ALL 
{ $$ = NIL; }
!   | qualified_name_list   
{ $$ = $1; }
;
  
  constraints_set_mode:
Index: src/include/nodes/parsenodes.h
===
RCS file: /projects/cvsroot/pgsql/src/include/nodes/parsenodes.h,v
retrieving revision 1.306
diff -c -r1.306 parsenodes.h
*** src/include/nodes/parsenodes.h  23 Mar 2006 00:19:30 -  1.306
--- src/include/nodes/parsenodes.h  11 Apr 2006 00:01:54 -
***
*** 1803,1809 
  typedef struct ConstraintsSetStmt
  {
NodeTag type;
!   List   *constraints;/* List of names as Value strings */
booldeferred;
  } ConstraintsSetStmt;
  
--- 1803,1809 
  typedef struct ConstraintsSetStmt
  {
NodeTag type;
!   List   *constraints;/* List of names as RangeVars */
booldeferred;
  } ConstraintsSetStmt;
  
Index: doc/src/sgml/ref/set_constraints.sgml
===
RCS file: /projects/cvsroot/pgsql/doc/src/sgml/ref/set_constraints.sgml,v
retrieving revision 1.12
diff -c -r1.12 set_constraints.sgml
*** doc/src/sgml/ref/set_constraints.sgml   10 Sep 2004 18:39:53 -  
1.12
--- doc/src/sgml/ref/set_constraints.sgml   11 Apr 2006 00:01:54 -
***
*** 93,105 
 foreign-key constraints.

  
-   
-The SQL standard says that constraint names appearing in SET
-CONSTRAINTS can be schema-qualified.  This is not yet
-supported by PostgreSQL: the names must
-be unqualified, and all constraints matching the command will be
-affected no matter which schema they are in.
-   
   
  
  
--- 93,98 
Index: src/backend/commands/trigger.c
===
RCS file: /projects/cvsroot/pgsql/src/backend/commands/trigger.c,v
retrieving revision 1.200
diff -c -r1.200 trigger.c
*** src/backend/commands/trigger.c  5 Mar 2006 15:58:25 -   1.200
--- src/backend/commands/trigger.c  11 Apr 2006 00:01:54 -
***
*** 24,29 
--- 24,30 
  #include "catalog/pg_proc.h"
  #include "catalog/pg_trigger.h"
  #include "catalog/pg_type.h"
+ #include "commands/dbcommands.h"
  #include "commands/defrem.h"
  #include "commands/trigger.h"
  #include "executor/executor.h"
***
*** 37,42 
--- 38,44 
  #include "utils/inval.h"
  #include "utils/lsyscache.h"
  #include "utils/memutils.h"
+ #include "utils/relcache.h"
  #include "utils/syscache.h"
  
  
***
*** 2922,2986 
  
foreach(l, stmt->constraints)
{
!   char   *cname = strVal(lfirst(l));
ScanKeyData skey;
SysScanDesc tgscan;
HeapTuple   htup;
boolfound;
  
!   /*
!* Check that only named constraints are set explicitly
!*/
!   if (strlen(cname) == 0)
!   ereport(ERROR,
!   (errcode(ERRCODE_INVALID_NAME),
!   errmsg("unnamed constraints cannot be 
set explicitly")));
  
!   /*
!* Setup to scan pg_trigger by tgconstrname ...
 */
!   ScanKeyInit(&skey,
!   Anum_pg_trigger_tgconstrname,
!   BTEqualStrategyNumber, F_NAMEEQ,
!