Problem with updating system indices.
Problem with updating system indices.
От:
Denis Perchine <dyp@perchine.com>
Дата:
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; ird_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
----------------------------------
Re: Problem with updating system indices.
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Denis Perchine 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
Re: Problem with updating system indices.
От:
Denis Perchine <dyp@perchine.com>
Дата:
> > 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 ----------------------------------