Fix for initdb/indexing problems - Mailing list pgsql-hackers

From Bruce Momjian
Subject Fix for initdb/indexing problems
Date
Msg-id 199809022311.TAA17615@candle.pha.pa.us
Whole thread Raw
List pgsql-hackers
OK, I have found the problem.  I looked AGAIN at CatalogIndexInsert(),
because all problems seem to be localized there.  I remembered something
Tom Szybist said yesterday while we were on the phone about Datum only
being one value.

I said they are chained together, which I saw in IndexFormDatum, but
when I looked, I saw that the Datum pointer indexed in IndexFormDatum
was only a single Datum value, not an array of datum values like nulls
is defined.

With single-key system indexes, this was not a problem, but with the new
multi-key system indicies, it is.

I have attached the patch, and it is applied to the tree.  Please let me
know if this fixes the many reported index problems.  It should.


--
Bruce Momjian                          |  830 Blythe Avenue
maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
  +  If your life is a hard drive,     |  (610) 353-9879(w)
  +  Christ can be your backup.        |  (610) 853-3000(h)
Index: src/backend/catalog/indexing.c
===================================================================
RCS file: /usr/local/cvsroot/pgsql/src/backend/catalog/indexing.c,v
retrieving revision 1.29
diff -c -r1.29 indexing.c
*** indexing.c    1998/09/01 16:21:47    1.29
--- indexing.c    1998/09/02 23:00:59
***************
*** 109,120 ****
      HeapTuple    index_tup;
      TupleDesc    heapDescriptor;
      Form_pg_index index_form;
!     Datum        datum;
      int            natts;
      AttrNumber *attnumP;
      FuncIndexInfo finfo,
                 *finfoP;
-     char        nulls[INDEX_MAX_KEYS];
      int            i;

      heapDescriptor = RelationGetDescr(heapRelation);
--- 109,120 ----
      HeapTuple    index_tup;
      TupleDesc    heapDescriptor;
      Form_pg_index index_form;
!     Datum        datum[INDEX_MAX_KEYS];
!     char        nulls[INDEX_MAX_KEYS];
      int            natts;
      AttrNumber *attnumP;
      FuncIndexInfo finfo,
                 *finfoP;
      int            i;

      heapDescriptor = RelationGetDescr(heapRelation);
***************
*** 152,162 ****
                         (AttrNumber *) index_form->indkey,
                         heapTuple,
                         heapDescriptor,
!                        &datum,
                         nulls,
                         finfoP);

!         indexRes = index_insert(idescs[i], &datum, nulls,
                                  &heapTuple->t_ctid, heapRelation);
          if (indexRes)
              pfree(indexRes);
--- 152,162 ----
                         (AttrNumber *) index_form->indkey,
                         heapTuple,
                         heapDescriptor,
!                        datum,
                         nulls,
                         finfoP);

!         indexRes = index_insert(idescs[i], datum, nulls,
                                  &heapTuple->t_ctid, heapRelation);
          if (indexRes)
              pfree(indexRes);

pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] Core dump in regression tests.
Next
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] USE_LOCALE and unsigned char *