Re: [PATCHES] ALTER OBJECT SET SCHEMA

2005-08-01 Thread Bernd Helmle
--On Donnerstag, Juli 28, 2005 23:12:37 -0400 Bruce Momjian 
pgman@candle.pha.pa.us wrote:



Here is an updated version of your patch.  Would you supply SGML
documentation updates to match the code changes?  Thanks.


Here's my first shot on this. Let me know if there's somenthing missing or 
broken (note: English is not my native language, i hope there aren't too 
much faults).


--
 Bernd

alter_set_schema_doc.patch
Description: Binary data

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


Re: [PATCHES] ALTER OBJECT SET SCHEMA

2005-08-01 Thread Tom Lane
Bernd Helmle [EMAIL PROTECTED] writes:
 Here is an updated version of your patch.  Would you supply SGML
 documentation updates to match the code changes?  Thanks.

 Here's my first shot on this.

Applied with additional minor editing.

regards, tom lane

---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings


Re: [PATCHES] ALTER OBJECT SET SCHEMA

2005-07-29 Thread Bruce Momjian
Bernd Helmle wrote:
 --On Donnerstag, Juli 28, 2005 23:12:37 -0400 Bruce Momjian 
 pgman@candle.pha.pa.us wrote:
 
  Here is an updated version of your patch.  Would you supply SGML
  documentation updates to match the code changes?  Thanks.
 
 Bruce, is there any requirement to add some regression tests, too?

It would be nice, yes.

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  pgman@candle.pha.pa.us   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073

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

   http://archives.postgresql.org


Re: [PATCHES] ALTER OBJECT SET SCHEMA

2005-07-29 Thread Bernd Helmle
--On Donnerstag, Juli 28, 2005 23:12:37 -0400 Bruce Momjian 
pgman@candle.pha.pa.us wrote:



Here is an updated version of your patch.  Would you supply SGML
documentation updates to match the code changes?  Thanks.


Bruce, is there any requirement to add some regression tests, too?

--
 Bernd

---(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] ALTER OBJECT SET SCHEMA

2005-07-28 Thread Bruce Momjian

Here is an updated version of your patch.  Would you supply SGML
documentation updates to match the code changes?  Thanks.

---

Bernd Helmle wrote:
 Here's my current patch for ALTER OBJECT SET SCHEMA: the attached patch 
 file implements
 schema move for FUNCTION, SEQUENCE, TYPE, DOMAIN and TABLE with all 
 improvements discussed on -hackers recently. Altering OPERATOR, OPERATOR 
 CLASS, AGGREGATE and CONVERSION are currently not implemented (since i ran 
 out of time) :(
 
 Supported syntax is
 
 ALTER TABLE name SET SCHEMA name;
 ALTER SEQUENCE name SET SCHEMA name;
 ALTER FUNCTION name SET SCHEMA name;
 ALTER TYPE name SET SCHEMA name;
 ALTER DOMAIN name SET SCHEMA name;
 
 TIA
 
 -- 
   Bernd

[ Attachment, skipping... ]

 
 ---(end of broadcast)---
 TIP 5: Have you checked our extensive FAQ?
 
http://www.postgresql.org/docs/faq

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  pgman@candle.pha.pa.us   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073
Index: src/backend/catalog/pg_depend.c
===
RCS file: /cvsroot/pgsql/src/backend/catalog/pg_depend.c,v
retrieving revision 1.13
diff -c -c -r1.13 pg_depend.c
*** src/backend/catalog/pg_depend.c 14 Apr 2005 20:03:23 -  1.13
--- src/backend/catalog/pg_depend.c 29 Jul 2005 03:11:17 -
***
*** 211,213 
--- 211,273 
  
return ret;
  }
+ 
+ bool
+ changeDependencyFor(Oid classId, Oid objectId, Oid oldrefobjectId,
+   Oid newrefobjectId)
+ {
+   ScanKeyData key[2];
+   SysScanDesc scan;
+   HeapTuple   tup;
+   RelationdepRel;
+   boolresult = false; /* nothing changed */
+ 
+   Assert(OidIsValid(classId)  OidIsValid(objectId) 
+  OidIsValid(oldrefobjectId)  OidIsValid(newrefobjectId));
+ 
+   depRel = heap_open(DependRelationId, RowExclusiveLock);
+ 
+   ScanKeyInit(key[0], Anum_pg_depend_classid, BTEqualStrategyNumber, 
F_OIDEQ,
+   ObjectIdGetDatum(classId));
+   ScanKeyInit(key[1], Anum_pg_depend_objid, BTEqualStrategyNumber, 
F_OIDEQ,
+   ObjectIdGetDatum(objectId));
+ 
+   scan = systable_beginscan(depRel, DependDependerIndexId, true,
+ SnapshotNow, 2, key);
+ 
+   while (HeapTupleIsValid((tup = systable_getnext(scan
+   {
+   Form_pg_depend depend_class = (Form_pg_depend) GETSTRUCT(tup);
+   
+   if (depend_class-refobjid == oldrefobjectId)
+   {
+   ObjectAddress objAddr;
+   
+   objAddr.classId = classId;
+   objAddr.objectId = oldrefobjectId;
+   objAddr.objectSubId = 0;
+   
+   if (isObjectPinned(objAddr, depRel))
+   elog(ERROR, attempt to change dependency on a 
system object!);
+   
+   tup = heap_copytuple(tup);
+   depend_class = (Form_pg_depend) GETSTRUCT(tup);
+   
+   depend_class-refobjid = newrefobjectId;
+   simple_heap_update(depRel, tup-t_self, tup);
+   CatalogUpdateIndexes(depRel, tup);
+   
+   /*
+* Assume that the specified object/classId couldn't 
reference the
+* changed object twice, so exit the loop immediately.
+*/
+   result = true;
+   break;
+   }
+   }
+ 
+   systable_endscan(scan);
+   heap_close(depRel, RowExclusiveLock);
+ 
+   return result;
+ }
Index: src/backend/commands/alter.c
===
RCS file: /cvsroot/pgsql/src/backend/commands/alter.c,v
retrieving revision 1.13
diff -c -c -r1.13 alter.c
*** src/backend/commands/alter.c28 Jun 2005 05:08:53 -  1.13
--- src/backend/commands/alter.c29 Jul 2005 03:11:17 -
***
*** 38,43 
--- 38,75 
  
  
  /*
+  * Executes an ALTER OBJECT / SET SCHEMA statement
+  */
+ void
+ ExecRenameObjSchemaStmt(RenameObjSchemaStmt *stmt)
+ {
+   Oid relid;
+ 
+   switch (stmt-renameType)
+   {
+   case OBJECT_TYPE:
+   case OBJECT_DOMAIN:
+   AlterDomainNamespace(stmt-object, stmt-newname);
+   break;
+   
+   case OBJECT_FUNCTION:
+   AlterFunctionNamespace(stmt-object, stmt-objarg, 

[PATCHES] ALTER OBJECT SET SCHEMA

2005-07-03 Thread Bernd Helmle
Here's my current patch for ALTER OBJECT SET SCHEMA: the attached patch 
file implements
schema move for FUNCTION, SEQUENCE, TYPE, DOMAIN and TABLE with all 
improvements discussed on -hackers recently. Altering OPERATOR, OPERATOR 
CLASS, AGGREGATE and CONVERSION are currently not implemented (since i ran 
out of time) :(


Supported syntax is

ALTER TABLE name SET SCHEMA name;
ALTER SEQUENCE name SET SCHEMA name;
ALTER FUNCTION name SET SCHEMA name;
ALTER TYPE name SET SCHEMA name;
ALTER DOMAIN name SET SCHEMA name;

TIA

--
 Bernd

pgsql_alter.patch.bz2
Description: Binary data

---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq