Re: Like vs '=' bug with indexing

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Hannu Krosing <hannu(at)tm(dot)ee>
Cc: m w <mttf2000(at)yahoo(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Like vs '=' bug with indexing
Date: 2001-02-04 18:45:27
Message-ID: 6654.981312327@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hannu Krosing <hannu(at)tm(dot)ee> writes:
> Is there no simple (i.e. cheap) way to disallow \0 alltogether for
> these types then ?
> perhaps just strip them out in textin() (or is it text_in()) ?

They *are* stripped out in textin(), by virtue of the fact that
textin expects to see a null-terminated input string.

>> It wouldn't surprise me too much if there are inconsistent
>> behaviors between indexscans and seqscans for such invalid data.

> should'nt they both use the _same_ strcoll() and friends ?

Irrelevant; the issue is that the various comparison operators may
produce inconsistent results given invalid input. For instance
texteq() short-circuits to a FALSE result if the lengths of the
inputs are different, which means that 'ab\0' = 'ab' will produce
false, even though a strcoll-based comparison will claim they are
equal. I don't think that means that texteq() is wrong to check the
lengths first.

> Should we not examine "the _possible_ outputs of every C-coded function
> to make sure it produces a valid value of the datatype" ;)

Go for it.

Possibly chr() should reject chr(0) ...

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2001-02-04 18:59:12 Re: Like vs '=' bug with indexing
Previous Message Bruce Momjian 2001-02-04 17:41:05 Re: TODO list: Allow Java server-side programming