Re: BUG #4044: Incorrect RegExp substring Output

From: "Rui Martins" <Rui(dot)Martins(at)PDMFC(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4044: Incorrect RegExp substring Output
Date: 2008-03-19 15:43:38
Message-ID: 3028.B1UHWUVdEF8=.1205941418.squirrel@www.pdmfc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi Tom

What I meant is:

SELECT '' ~ '^(something)?$'

This will match, i.e. the empty string will match with the expression,
and substring would return and empty string.

or in other words:
it returns true

SELECT SUBSTRING( '', '^(something)?$' )

This will also match, has a global expression, and the return is, has
expected, an EMPTY string !

Now, If all the above is correct (which I believe it is), than:

SELECT 'TEST' ~ '^TEST(something)?$'

Will also return TRUE, which it correctly does.

So, what would you expect to be the result, from the following query ?

SELECT SUBSTRING( 'TEST', '^TEST(something)?$' )

The current returned value is 'TEST' which is wrong!
This we knew already, from my bug Report.

But by analogy, with the previous queries, and to maintain overall
coherence the expected correct result should be and EMPTY string too!

But If I understood you correctly, you said that it will return a result
of NULL, which I think is incorrect.

Did I make my self clearer know ?

Thanks again for feedback.

See ya
Rui Martins

> "Rui Martins" <Rui(dot)Martins(at)PDMFC(dot)com> writes:
>> Here the context of the word "match" may be misleading us, in this
>> conversation.
>> I say this, because in my report, the second substring expression, the
>> one
>> for RoomSize:
>
>> SUBSTRING( BedNo, '^[[:digit:]]+([a-zA-Z]*)(:[[:digit:]]+)?$' ) AS
>> RoomSize,
>
>> Actually returns an EMPTY String, and not a NULL, for the first 2 test
>> cases, which I believe is the correct answer.
>
> What's your point? A zero-length substring is a legal match to that
> subexpression ... unlike the third one.
>
> regards, tom lane
>

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2008-03-19 18:56:14 Re: BUG #4044: Incorrect RegExp substring Output
Previous Message Tom Lane 2008-03-19 14:53:22 Re: Problem identifying constraints which should not be inherited