Hi all,
authorBruce Momjian <bruce@momjian.us>
Fri, 28 Aug 1998 03:36:31 +0000 (03:36 +0000)
committerBruce Momjian <bruce@momjian.us>
Fri, 28 Aug 1998 03:36:31 +0000 (03:36 +0000)
    I  don't know if this is really related to the initdb problem
    discussion (haven't followed it enough). But seems so because
    it  fixes  a  damn  problem  during  index tuple insertion on
    CREATE TABLE into pg_attribute_relid_attnum_index.

    Anyway - this bug was really hard to find. During startup the
    relcache  reads  in  some  prepared  information  about index
    strategies from a file and then  reinitializes  the  function
    pointers  inside  the  scanKey data.  But for sake it assumed
    single attribute index tuples (hasn't that changed recently).
    Thus not all the strategies scanKey entries where initialized
    properly,  resulting  in  invalid  addresses  for  the  btree
    comparision functions.

    With  the  patch  at  the  end  the  regression  tests passed
    excellent except for the sanity_check that crashed at  vacuum
    and the misc test where the select unique1 from onek2 outputs
    the two rows in different order.

Jan

src/backend/catalog/index.c
src/backend/commands/vacuum.c
src/backend/utils/cache/relcache.c
src/bin/psql/psqlHelp.h

index 2b1005fcf3174699fa5b2800d000eee129167ca8..031d2d4321053d34d014e2776aa05d7ad7381e05 100644 (file)
@@ -1267,7 +1267,6 @@ FormIndexDatum(int numberOfAttributes,
                           FuncIndexInfoPtr fInfo)
 {
        AttrNumber      i;
-       int                     offset;
        bool            isNull;
 
        /* ----------------
@@ -1277,19 +1276,16 @@ FormIndexDatum(int numberOfAttributes,
         * ----------------
         */
 
-       for (i = 1; i <= numberOfAttributes; i++)
+       for (i = 0; i < numberOfAttributes; i++)
        {
-               offset = AttrNumberGetAttrOffset(i);
-
-               datum[offset] =
-                       PointerGetDatum(GetIndexValue(heapTuple,
-                                                                                 heapDescriptor,
-                                                                                 offset,
-                                                                                 attributeNumber,
-                                                                                 fInfo,
-                                                                                 &isNull));
-
-               nullv[offset] = (isNull) ? 'n' : ' ';
+               datum[i] =      PointerGetDatum(GetIndexValue(heapTuple,
+                                                                         heapDescriptor,
+                                                                         i,
+                                                                         attributeNumber,
+                                                                         fInfo,
+                                                                         &isNull));
+
+               nullv[i] = (isNull) ? 'n' : ' ';
        }
 }
 
index 91e9589c6333c7f7fd5ed1b71a4bfa0934fe8b45..4762e73222856955722a13b301e43bc0ecdccd8a 100644 (file)
@@ -1143,16 +1143,14 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
                        {
                                for (i = 0, idcur = Idesc; i < nindices; i++, idcur++)
                                {
-                                       FormIndexDatum(
-                                                                  idcur->natts,
-                                                          (AttrNumber *) &(idcur->tform->indkey[0]),
+                                       FormIndexDatum(idcur->natts,
+                                                                  (AttrNumber *) &(idcur->tform->indkey[0]),
                                                                   newtup,
                                                                   tupdesc,
                                                                   idatum,
                                                                   inulls,
                                                                   idcur->finfoP);
-                                       iresult = index_insert(
-                                                                                  Irel[i],
+                                       iresult = index_insert(Irel[i],
                                                                                   idatum,
                                                                                   inulls,
                                                                                   &(newtup->t_ctid),
index 92d2aafa0550bd37548f8333015f582c953a6c9b..b704122ccbe44cc7f5deb5cb8f9c30b1feb42f88 100644 (file)
@@ -1982,10 +1982,11 @@ init_irels(void)
 #define SMD(i) strat[0].strategyMapData[i].entry[0]
 
                /* have to reinit the function pointers in the strategy maps */
-               for (i = 0; i < am->amstrategies; i++)
+               for (i = 0; i < am->amstrategies * relform->relnatts; i++) {
                        fmgr_info(SMD(i).sk_procedure,
                                          &(SMD(i).sk_func));
-               SMD(i).sk_nargs = SMD(i).sk_func.fn_nargs;
+                       SMD(i).sk_nargs = SMD(i).sk_func.fn_nargs;
+               }
 
 
                /*
index 34df0a6296f7f5f3d1eb8525d464d4a32f15d000..4f334e9f4a49e915bf50a973556b3ebe10d6b979 100644 (file)
@@ -353,7 +353,7 @@ set R_PLANS TO 'ON'| 'OFF'"},
                "update tuples",
        "\
 \tUPDATE class_name SET attr1 = expr1, ...attrN = exprN\n\
-\t [FROM from_clause]\n\
+\t[FROM from_clause]\n\
 \t[WHERE qual];"},
        {"vacuum",
                "vacuum the database, i.e. cleans out deleted records, updates statistics",