Hello,

Sometime ago I did a patch to have large objects rollbackable.
That patch was against the current (on that moment) CVS.
It worked fine.

Now I tried to port the patch to 7.0.2 and have the following problem:
Somehow index which I made is not updated.
It can be figure out quite simple.
After creating new LO I have:

webmailstation=> explain select * from pg_largeobject where loid=14035719;
NOTICE:  QUERY PLAN:

Seq Scan on pg_largeobject  (cost=0.00..0.00 rows=1 width=20)
EXPLAIN
webmailstation=> select * from pg_largeobject where loid=14035719;
   loid   | pageno | data
----------+--------+------
 14035719 |      0 |
(1 row)
webmailstation=>  set enable_seqscan=off;
SET VARIABLE
webmailstation=> explain select * from pg_largeobject where loid=14035719;
NOTICE:  QUERY PLAN:

Index Scan using pg_largeobject_loid_pn_index on pg_largeobject  (cost=0.00..5.01 rows=1 width=20)

EXPLAIN
webmailstation=>  select * from pg_largeobject where loid=14035719;
 loid | pageno | data
------+--------+------
(0 rows)

As far as you can see index does not contains such value.

The code which creates a LO looks like this:

Oid LargeobjectCreate(Oid loid) {
        Oid             retval;
        Relation                pg_largeobject;
        HeapTuple       ntup = (HeapTuple) palloc(sizeof(HeapTupleData));
        Relation                idescs[Num_pg_index_indices];
        Datum           values[Natts_pg_largeobject];
        char            nulls[Natts_pg_largeobject];
        int             i;

        for (i=0; i<Natts_pg_largeobject; i++) {
                nulls[i] = ' ';
                values[i] = (Datum)NULL;
        }

        i = 0;
        values[i++] = ObjectIdGetDatum(loid);
        values[i++] = Int32GetDatum(0);
        values[i++] = (Datum) _byteain(NULL, 0);

        pg_largeobject = heap_openr(LargeobjectRelationName, RowExclusiveLock);
        ntup = heap_formtuple(pg_largeobject->rd_att, values, nulls);
        retval = heap_insert(pg_largeobject, ntup);

        if (!IsIgnoringSystemIndexes()) {
                CatalogOpenIndices(Num_pg_largeobject_indices, Name_pg_largeobje
                CatalogIndexInsert(idescs, Num_pg_largeobject_indices, pg_largeo
                CatalogCloseIndices(Num_pg_largeobject_indices, idescs);
        }

        heap_close(pg_largeobject, RowExclusiveLock);
        heap_freetuple(ntup);

        CommandCounterIncrement();

        return retval;
}

And all go fine and indices should be updated... What I did wrong???
I traces through this code step by step and all seems fine...

-- 
Sincerely Yours,
Denis Perchine

----------------------------------
E-Mail: dyp@perchine.com
HomePage: http://www.perchine.com/dyp/
FidoNet: 2:5000/120.5
----------------------------------

Sun, 30 Jul 2000 15:18:26 +0700
Denis Perchine <dyp@perchine.com>
Problem with updating system indices.
Denis Perchine <dyp@perchine.com> writes:
>         Relation                idescs[Num_pg_index_indices];
                                             ^^^^^^^^

Dunno whether you have Num_pg_largeobject_indices =
Num_pg_index_indices, but in any case there's a latent
stack clobber here.

>         CommandCounterIncrement();

Are you sure it's a good idea to be incrementing the CC here?
This seems like a pretty low-level routine, so there might be
people further up the stack who do not want this done.

			regards, tom lane

Sun, 30 Jul 2000 10:53:41 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: Problem with updating system indices. 
> >         Relation                idescs[Num_pg_index_indices];
>                                              ^^^^^^^^
> 
> Dunno whether you have Num_pg_largeobject_indices =
> Num_pg_index_indices, but in any case there's a latent
> stack clobber here.

Ough... That's bad to work too much...
 
> >         CommandCounterIncrement();
> 
> Are you sure it's a good idea to be incrementing the CC here?
> This seems like a pretty low-level routine, so there might be
> people further up the stack who do not want this done.

Hmmm... Problem is that if I did not do this I do not see this change
later when I do lo_create/lo_open inside transaction...
What should I use else for this purpose?

-- 
Sincerely Yours,
Denis Perchine

----------------------------------
E-Mail: dyp@perchine.com
HomePage: http://www.perchine.com/dyp/
FidoNet: 2:5000/120.5
----------------------------------

Mon, 31 Jul 2000 11:53:32 +0700
Denis Perchine <dyp@perchine.com>
Re: Problem with updating system indices.