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,
!