Re: [PATCHES] Patch for search_path --- apply to 7.4 branch?

2004-01-20 Thread ohp
Hi Tom,

I'd love to see it in a 7.4.2... With maybe the patch for SMP...

Regards
On Mon, 19 Jan 2004, Tom Lane wrote:

 Date: Mon, 19 Jan 2004 14:15:08 -0500
 From: Tom Lane [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Subject: [PATCHES] Patch for search_path --- apply to 7.4 branch?

 Attached is the patch I just applied to CVS HEAD to fix the search_path
 problem that Olivier Prenant recently identified (can't set a search
 path for another database if it mentions schemas not present in the
 current database).  I am looking for comments on whether to back-patch
 this into REL7_4_STABLE.  It is a rather large patch to fix what might
 be considered a non-critical problem, so I'm a bit hesitant about back
 patching.  Any opinions?

   regards, tom lane



-- 
Olivier PRENANT Tel: +33-5-61-50-97-00 (Work)
6, Chemin d'Harraud Turrou   +33-5-61-50-97-01 (Fax)
31190 AUTERIVE   +33-6-07-63-80-64 (GSM)
FRANCE  Email: [EMAIL PROTECTED]
--
Make your life a dream, make your dream a reality. (St Exupery)

---(end of broadcast)---
TIP 8: explain analyze is your friend


[PATCHES] Patch for search_path --- apply to 7.4 branch?

2004-01-19 Thread Tom Lane
Attached is the patch I just applied to CVS HEAD to fix the search_path
problem that Olivier Prenant recently identified (can't set a search
path for another database if it mentions schemas not present in the
current database).  I am looking for comments on whether to back-patch
this into REL7_4_STABLE.  It is a rather large patch to fix what might
be considered a non-critical problem, so I'm a bit hesitant about back
patching.  Any opinions?

regards, tom lane

*** src/backend/access/transam/xlog.c.orig  Tue Jan  6 17:22:37 2004
--- src/backend/access/transam/xlog.c   Mon Jan 19 13:21:29 2004
***
*** 3523,3529 
   * GUC support
   */
  const char *
! assign_xlog_sync_method(const char *method, bool doit, bool interactive)
  {
int new_sync_method;
int new_sync_bit;
--- 3523,3529 
   * GUC support
   */
  const char *
! assign_xlog_sync_method(const char *method, bool doit, GucSource source)
  {
int new_sync_method;
int new_sync_bit;
*** src/backend/catalog/namespace.c.origTue Dec 30 17:03:39 2003
--- src/backend/catalog/namespace.c Mon Jan 19 13:36:24 2004
***
*** 39,44 
--- 39,45 
  #include utils/acl.h
  #include utils/builtins.h
  #include utils/catcache.h
+ #include utils/guc.h
  #include utils/inval.h
  #include utils/lsyscache.h
  #include utils/memutils.h
***
*** 1773,1779 
  
  /* assign_hook: validate new search_path, do extra actions as needed */
  const char *
! assign_search_path(const char *newval, bool doit, bool interactive)
  {
char   *rawname;
List   *namelist;
--- 1774,1780 
  
  /* assign_hook: validate new search_path, do extra actions as needed */
  const char *
! assign_search_path(const char *newval, bool doit, GucSource source)
  {
char   *rawname;
List   *namelist;
***
*** 1795,1807 
 * If we aren't inside a transaction, we cannot do database access so
 * cannot verify the individual names.  Must accept the list on faith.
 */
!   if (interactive  IsTransactionState())
{
/*
 * Verify that all the names are either valid namespace names or
 * $user.  We do not require $user to correspond to a valid
 * namespace.  We do not check for USAGE rights, either; should
 * we?
 */
foreach(l, namelist)
{
--- 1796,1814 
 * If we aren't inside a transaction, we cannot do database access so
 * cannot verify the individual names.  Must accept the list on faith.
 */
!   if (source = PGC_S_INTERACTIVE  IsTransactionState())
{
/*
 * Verify that all the names are either valid namespace names or
 * $user.  We do not require $user to correspond to a valid
 * namespace.  We do not check for USAGE rights, either; should
 * we?
+*
+* When source == PGC_S_TEST, we are checking the argument of an
+* ALTER DATABASE SET or ALTER USER SET command.  It could be that
+* the intended use of the search path is for some other database,
+* so we should not error out if it mentions schemas not present
+* in the current database.  We reduce the message to NOTICE instead.
 */
foreach(l, namelist)
{
***
*** 1812,1818 
if (!SearchSysCacheExists(NAMESPACENAME,
  
CStringGetDatum(curname),
  0, 0, 0))
!   ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_SCHEMA),
   errmsg(schema \%s\ does not exist, 
curname)));
}
--- 1819,1825 
if (!SearchSysCacheExists(NAMESPACENAME,
  
CStringGetDatum(curname),
  0, 0, 0))
!   ereport((source == PGC_S_TEST) ? NOTICE : ERROR,
(errcode(ERRCODE_UNDEFINED_SCHEMA),
   errmsg(schema \%s\ does not exist, 
curname)));
}
*** src/backend/commands/variable.c.origSun Dec 21 17:53:44 2003
--- src/backend/commands/variable.c Mon Jan 19 13:30:06 2004
***
*** 48,54 
   * assign_datestyle: GUC assign_hook for datestyle
   */
  const char *
! assign_datestyle(const char *value, bool