extension to SQL to access TIDs from indices

From: Jan Vicherek <honza(at)ied(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Hannu Krosing <hannu(at)trust(dot)ee>, vadim(at)sable(dot)krasnoyarsk(dot)su, The Hermit Hacker <scrappy(at)hub(dot)org>
Subject: extension to SQL to access TIDs from indices
Date: 1998-01-25 06:00:59
Message-ID: Pine.LNX.3.96.980125003854.497j-100000@ann.ied.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


hi,

I'm tempted to implement an extension to the current postgres' SQL
language that would allow me to do something like :

CREATE INDEX MyIndex ON MyTable (IndexField);
BEGIN;
SELECT LAST(Tid) AS MyFirstTid FROM MyIndex WHERE IndexField = 'what_user_requests';
SELECT * from MyTable where Tid = MyFirstTid;
END;
... disconnect ...
... reconnect ...
BEGIN;
SELECT NEXT(Tid) AS MyNextTid FROM MyIndex WHERE Tid = MyFirstTid;
SELECT * from MyTable where Tid = MyNextTid;
END;
... disconnect ...
... etc ...

The "LAST(Tid)" could also be "FIRST(Tid)". The FIRST/LAST keywords are
there so it knows which index pointer (TID) to pick when the index isn't
unique and the 'what_user_requests' value happens to be in the index more
than once.

The NEXT could also be PREVIOUS.

Now I understand that the first and second SELECT would have to be in
one transaction, so that other users cannot invalidate on me (delete /
update) the record that the TID points to.

Also after I reconnect, it is not guaranteed that MyFirstTid is still a
valid Tid. If it is not valid, then the first SELECT should return 0 rows
as result. If it is still valid, it should return exacly one row with the
next TID in the index.

I would appreciate opinions on any of the following :

o. is this a reasonable approach to solve my "browsing" problem ?

o. what would be involved in implementing this ?

o. given the current design, how many lines (estimate) of code would
have to be written to do this,

o. given the current design, how many functions (estimate) would have to
be rewritten

Is there anybody out there who would be willing to do this with me over
the next couple of days ? (My "selling" of postgres to my customer is
completely lost yet.)

Or is there anybody who could at least feed me with pointers when I get
stuck ? (I.e. you would give me the direction(s), I would do the work.)

Thanx,

Jan

-- Gospel of Jesus is the saving power of God for all who believe --
Jan Vicherek ## To some, nothing is impossible. ## www.ied.com/~honza
>>> Free Software Union President ... www.fslu.org <<<
Interactive Electronic Design Inc. -#- PGP: finger honza(at)ied(dot)com

Browse pgsql-hackers by date

  From Date Subject
Next Message The Hermit Hacker 1998-01-25 07:12:09 A small type extension example for the contrib directory (fwd)
Previous Message Jan Vicherek 1998-01-25 05:38:01 Re: Browsing the tables / why pgsql does not perform well (with temp fix)