Skip site navigation (1) Skip section navigation (2)

TidScan needs handling of a corner cases

From: "Gurjeet Singh" <singh(dot)gurjeet(at)gmail(dot)com>
To: "PGSQL Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: TidScan needs handling of a corner cases
Date: 2008-04-30 17:54:21
Message-ID: 65937bea0804301054p16727110ga99ab2ca001f1c52@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackers
Hi All,

    I noticed that the TidScan fails to identify when the requested block is
not in the relation. Consider this (pg_class has 6 blocks):

postgres=# explain analyze select ctid, * from pg_class where ctid in (
'(6,1)' );
ERROR:  could not read block 6 of relation 1663/11511/1259: read only 0 of
8192 bytes

    Also, it is known that 0 is not a valid row-offset in the block, but the
tid input function accepts this value (it rejects -ve values). For the same
setup:

postgres=#  explain analyze select ctid, * from pg_class where ctid in (
'(6,0)' );
                                             QUERY
PLAN
----------------------------------------------------------------------------------------------------
 Tid Scan on pg_class  (cost=0.00..4.01 rows=1 width=211) (actual
time=0.009..0.009 rows=0 loops=1)
   TID Cond: (ctid = '(6,0)'::tid)
 Total runtime: 0.130 ms
(3 rows)

    Can we safely fix these? First one by ignoring the request if
requested_block >= RelationGetNumberOfBlocks(), and second one by accepting
only non-zero positive values in the tid input function.

Best regards

-- 
gurjeet[(dot)singh](at)EnterpriseDB(dot)com
singh(dot)gurjeet(at){ gmail | hotmail | indiatimes | yahoo }.com

EnterpriseDB http://www.enterprisedb.com

Mail sent from my BlackLaptop device

Responses

pgsql-hackers by date

Next:From: Bryce NesbittDate: 2008-04-30 19:28:05
Subject: Re: Proposed patch - psql wraps at window width
Previous:From: Aidan Van DykDate: 2008-04-30 17:50:25
Subject: Re: Protection from SQL injection

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group