Re: Prepare xlog for optional oid - Mailing list pgsql-patches

From Bruce Momjian
Subject Re: Prepare xlog for optional oid
Date
Msg-id 200207112138.g6BLcvc27054@candle.pha.pa.us
Whole thread Raw
In response to Prepare xlog for optional oid  (Manfred Koizar <mkoi-pg@aon.at>)
Responses Re: Prepare xlog for optional oid  (Manfred Koizar <mkoi-pg@aon.at>)
List pgsql-patches
Your patch has been added to the PostgreSQL unapplied patches list at:

    http://candle.pha.pa.us/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

---------------------------------------------------------------------------


Manfred Koizar wrote:
> Prepare xlog code for optional oid, also some tweaking in
> log_heap_update and heap_xlog_update (1 memcpy instead of 2);
> and - completely unrelated - fix a comment in ExecRemoveJunk()
>
> Servus
>  Manfred
>
> diff -ru ../base/src/backend/access/heap/heapam.c src/backend/access/heap/heapam.c
> --- ../base/src/backend/access/heap/heapam.c    2002-07-04 00:26:37.000000000 +0200
> +++ src/backend/access/heap/heapam.c    2002-07-05 22:22:31.000000000 +0200
> @@ -1179,6 +1179,7 @@
>          rdata[1].next = &(rdata[2]);
>
>          rdata[2].buffer = buffer;
> +        /* PG73FORMAT: write bitmap [+ padding] [+ oid] + data */
>          rdata[2].data = (char *) tup->t_data + offsetof(HeapTupleHeaderData, t_bits);
>          rdata[2].len = tup->t_len - offsetof(HeapTupleHeaderData, t_bits);
>          rdata[2].next = NULL;
> @@ -1988,18 +1989,16 @@
>      xlhdr.hdr.mask = newtup->t_data->t_infomask;
>      if (move)                    /* remember xmin & xmax */
>      {
> -        TransactionId xmax;
> -        TransactionId xmin;
> +        TransactionId xid[2];   /* xmax, xmin */
>
> -        if (newtup->t_data->t_infomask & HEAP_XMAX_INVALID ||
> -            newtup->t_data->t_infomask & HEAP_MARKED_FOR_UPDATE)
> -            xmax = InvalidTransactionId;
> +        if (newtup->t_data->t_infomask & (HEAP_XMAX_INVALID |
> +                                          HEAP_MARKED_FOR_UPDATE))
> +            xid[0] = InvalidTransactionId;
>          else
> -            xmax = HeapTupleHeaderGetXmax(newtup->t_data);
> -        xmin = HeapTupleHeaderGetXmin(newtup->t_data);
> -        memcpy((char *) &xlhdr + hsize, &xmax, sizeof(TransactionId));
> -        memcpy((char *) &xlhdr + hsize + sizeof(TransactionId),
> -               &xmin, sizeof(TransactionId));
> +            xid[0] = HeapTupleHeaderGetXmax(newtup->t_data);
> +        xid[1] = HeapTupleHeaderGetXmin(newtup->t_data);
> +        memcpy((char *) &xlhdr + hsize,
> +               (char *) xid,            2 * sizeof(TransactionId));
>          hsize += 2 * sizeof(TransactionId);
>      }
>      rdata[2].buffer = newbuf;
> @@ -2008,6 +2007,7 @@
>      rdata[2].next = &(rdata[3]);
>
>      rdata[3].buffer = newbuf;
> +    /* PG73FORMAT: write bitmap [+ padding] [+ oid] + data */
>      rdata[3].data = (char *) newtup->t_data + offsetof(HeapTupleHeaderData, t_bits);
>      rdata[3].len = newtup->t_len - offsetof(HeapTupleHeaderData, t_bits);
>      rdata[3].next = NULL;
> @@ -2203,11 +2203,13 @@
>          memcpy((char *) &xlhdr,
>                 (char *) xlrec + SizeOfHeapInsert,
>                 SizeOfHeapHeader);
> +        htup = &tbuf.hdr;
> +        MemSet((char *) htup, 0, sizeof(HeapTupleHeaderData));
> +        /* PG73FORMAT: get bitmap [+ padding] [+ oid] + data */
>          memcpy((char *) &tbuf + offsetof(HeapTupleHeaderData, t_bits),
>                 (char *) xlrec + SizeOfHeapInsert + SizeOfHeapHeader,
>                 newlen);
>          newlen += offsetof(HeapTupleHeaderData, t_bits);
> -        htup = &tbuf.hdr;
>          htup->t_natts = xlhdr.t_natts;
>          htup->t_hoff = xlhdr.t_hoff;
>          htup->t_infomask = HEAP_XMAX_INVALID | xlhdr.mask;
> @@ -2373,29 +2375,30 @@
>          memcpy((char *) &xlhdr,
>                 (char *) xlrec + SizeOfHeapUpdate,
>                 SizeOfHeapHeader);
> +        htup = &tbuf.hdr;
> +        MemSet((char *) htup, 0, sizeof(HeapTupleHeaderData));
> +        /* PG73FORMAT: get bitmap [+ padding] [+ oid] + data */
>          memcpy((char *) &tbuf + offsetof(HeapTupleHeaderData, t_bits),
>                 (char *) xlrec + hsize,
>                 newlen);
>          newlen += offsetof(HeapTupleHeaderData, t_bits);
> -        htup = &tbuf.hdr;
>          htup->t_natts = xlhdr.t_natts;
>          htup->t_hoff = xlhdr.t_hoff;
>          if (reln->rd_rel->relhasoids)
>              HeapTupleHeaderSetOid(htup, xlhdr.t_oid);
>          if (move)
>          {
> -            TransactionId xmax;
> -            TransactionId xmin;
> +            TransactionId xid[2];   /* xmax, xmin */
>
>              hsize = SizeOfHeapUpdate + SizeOfHeapHeader;
> -            memcpy(&xmax, (char *) xlrec + hsize, sizeof(TransactionId));
> -            memcpy(&xmin, (char *) xlrec + hsize + sizeof(TransactionId), sizeof(TransactionId));
> +            memcpy((char *) xid,
> +                   (char *) xlrec + hsize, 2 * sizeof(TransactionId));
>              htup->t_infomask = xlhdr.mask;
>              htup->t_infomask &= ~(HEAP_XMIN_COMMITTED |
>                                    HEAP_XMIN_INVALID | HEAP_MOVED_OFF);
>              htup->t_infomask |= HEAP_MOVED_IN;
> -            HeapTupleHeaderSetXmin(htup, xmin);
> -            HeapTupleHeaderSetXmax(htup, xmax);
> +            HeapTupleHeaderSetXmin(htup, xid[1]);
> +            HeapTupleHeaderSetXmax(htup, xid[0]);
>              HeapTupleHeaderSetXvac(htup, record->xl_xid);
>          }
>          else
> diff -ru ../base/src/backend/executor/execJunk.c src/backend/executor/execJunk.c
> --- ../base/src/backend/executor/execJunk.c    2002-06-21 02:12:15.000000000 +0200
> +++ src/backend/executor/execJunk.c    2002-07-05 19:28:45.000000000 +0200
> @@ -383,8 +383,8 @@
>       * information for the new "clean" tuple.
>       *
>       * Note: we use memory on the stack to optimize things when we are
> -     * dealing with a small number of tuples. for large tuples we just use
> -     * palloc.
> +     * dealing with a small number of attributes. for large tuples we
> +     * just use palloc.
>       */
>      if (cleanLength > 64)
>      {
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>
>
>

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

pgsql-patches by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: several minor cleanups
Next
From: Bruce Momjian
Date:
Subject: Re: Wrap access to Oid II