Re: CLUSTER patch - Mailing list pgsql-patches

From Bruce Momjian
Subject Re: CLUSTER patch
Date
Msg-id 200207150050.g6F0oLQ08853@candle.pha.pa.us
Whole thread Raw
In response to Re: CLUSTER patch  (Alvaro Herrera <alvherre@atentus.com>)
Responses Re: CLUSTER patch
List pgsql-patches
Alvaro Herrera wrote:
> Tom Lane dijo:
>
> > Alvaro Herrera <alvherre@atentus.com> writes:
> > > It does indeed work.  Actually, I tried to do that before, but the fact
> > > that RelationFlushBuffers requires a firstDelBlock made me turn around.
> >
> > firstDelBlock should be 0, not length-of-relation; as given, this code
> > fails to get rid of the buffer entries!
>
> Oh, I failed to understand completely the purpose of firstDelBlock then.
>
> Anyway, there's still a big problem with this patch: the pg_depend
> information gets messed up after CLUSTER, so a clustered table cannot be
> dropped.  I don't know why is this.

I actually backed out Tom's recent change to cluster.c (attached),
applied your patch, then manually applied Tom's patch to cluster.c so I
had a working version of your patch with the new dependencies.  Seemed
to work fine.   I will do the same when I apply you version.

> As I said yesterday, I'm going on vacation tomorrow, and probably will
> not fix this issue.  I can look into it when I'm back, on two weeks.

I will take care of applying your patch and the doc part too.  It will
be all done when you return.  Thanks for your work and have a nice
vacation.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
Index: cluster.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/commands/cluster.c,v
retrieving revision 1.82
retrieving revision 1.83
diff -c -r1.82 -r1.83
*** cluster.c    20 Jun 2002 20:29:26 -0000    1.82
--- cluster.c    12 Jul 2002 18:43:15 -0000    1.83
***************
*** 15,21 ****
   *
   *
   * IDENTIFICATION
!  *      $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.82 2002/06/20 20:29:26 momjian Exp $
   *
   *-------------------------------------------------------------------------
   */
--- 15,21 ----
   *
   *
   * IDENTIFICATION
!  *      $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.83 2002/07/12 18:43:15 tgl Exp $
   *
   *-------------------------------------------------------------------------
   */
***************
*** 24,29 ****
--- 24,30 ----

  #include "access/genam.h"
  #include "access/heapam.h"
+ #include "catalog/dependency.h"
  #include "catalog/heap.h"
  #include "catalog/index.h"
  #include "catalog/pg_index.h"
***************
*** 64,69 ****
--- 65,71 ----
                  OldIndex;
      char        NewHeapName[NAMEDATALEN];
      char        NewIndexName[NAMEDATALEN];
+     ObjectAddress object;

      /*
       * We grab exclusive access to the target rel and index for the
***************
*** 119,127 ****
      CommandCounterIncrement();

      /* Destroy old heap (along with its index) and rename new. */
!     heap_drop_with_catalog(OIDOldHeap, allowSystemTableMods);

!     CommandCounterIncrement();

      renamerel(OIDNewHeap, oldrelation->relname);

--- 121,134 ----
      CommandCounterIncrement();

      /* Destroy old heap (along with its index) and rename new. */
!     object.classId = RelOid_pg_class;
!     object.objectId = OIDOldHeap;
!     object.objectSubId = 0;

!     /* XXX better to use DROP_CASCADE here? */
!     performDeletion(&object, DROP_RESTRICT);
!
!     /* performDeletion does CommandCounterIncrement at end */

      renamerel(OIDNewHeap, oldrelation->relname);

***************
*** 198,203 ****
--- 205,211 ----
                                 OldIndex->rd_rel->relam,
                                 OldIndex->rd_index->indclass,
                                 OldIndex->rd_index->indisprimary,
+                                false, /* XXX losing constraint status */
                                 allowSystemTableMods);

      setRelhasindex(OIDNewHeap, true,

pgsql-patches by date:

Previous
From: Gavin Sherry
Date:
Subject: Re: [HACKERS] Non-standard feature request
Next
From: Tom Lane
Date:
Subject: Re: CLUSTER patch