Thread: system table scan

system table scan

From
"Ehab Galal"
Date:
Hi,
I created an additional system table that i need in my system. The table 
contains attributes (username, att1, att2, ...)
I need to scan the table for a certain username while retrieving the tupled 
ordered by att1.

If i understand correctly, i may use systable_beginscan() and 
systable_getnext() to scan a system table while specifying a key (e.g., 
username='user1'). But i know nothing about specifying the order of the 
scan.

Should i implement my own table scan functions then? Or there is any 
mechanism that i may reuse?

Thanks a lot,
Ehab

_________________________________________________________________
All-in-one security and maintenance for your PC.� Get a free 90-day trial! 

http://clk.atdmt.com/MSN/go/msnnkwlo0050000002msn/direct/01/?href=http://clk.atdmt.com/MSN/go/msnnkwlo0050000001msn/direct/01/?href=http://www.windowsonecare.com/?sc_cid=msn_hotmail



Re: system table scan

From
Tom Lane
Date:
"Ehab Galal" <ehabgalal123@hotmail.com> writes:
> If i understand correctly, i may use systable_beginscan() and 
> systable_getnext() to scan a system table while specifying a key (e.g., 
> username='user1'). But i know nothing about specifying the order of the 
> scan.

The systable_xxx functions allow implementation by either indexscan or
seqscan, therefore they guarantee *nothing* about retrieval order.

If your code does not need to be executed during bootstrap or crash
recovery, you could depend on an indexscan instead.  See
toast_fetch_datum() for an example.
        regards, tom lane