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

Re: position('' in '') returns 1 instead of 0

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: terry(at)greatbridge(dot)com, pgsql-bugs(at)postgresql(dot)org
Subject: Re: position('' in '') returns 1 instead of 0
Date: 2001-04-18 21:26:29
Message-ID: 15181.987629189@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugs
Terry Carlin (terry(at)greatbridge(dot)com) writes:
> While running an ODBC test suite against PostgreSQL 7.1, the test
> software reported that the ODBC command locate("", "") failed.
> It expected the result to be zero and it got a 1.

Evidently your ODBC test suite hasn't read the spec.  See 4.2.2.2 in
either SQL92 or SQL99:

         <position expression> determines the first position, if any, at
         which one string, S1, occurs within another, S2. If S1 is of length
         zero, then it occurs at position 1 for any value of S2. If S1 does
         not occur in S2, then zero is returned.

Whether this is useful or not is perhaps debatable, but it's indisputably
what the standard says to do.

			regards, tom lane

In response to

Responses

pgsql-bugs by date

Next:From: Peter EisentrautDate: 2001-04-18 21:56:57
Subject: Re: position('' in '') returns 1 instead of 0
Previous:From: Thomas LockhartDate: 2001-04-18 21:04:58
Subject: Re: position('' in '') returns 1 instead of 0

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