|
2015-10-21
| ||
| 17:01 | • Closed ticket [1080042fff]: \Y can be quantified as (\Y) plus 5 other change... artifact: 5a3487520b user: dgp | |
| 16:27 | • Ticket [1080042fff]: 3 changes artifact: 44a578c336 user: tgl | |
| 14:20 | • Pending ticket [1080042fff]. artifact: 6d63a4b086 user: dgp | |
| 14:10 | [1080042][8f245009b0] Big bundle of regexp engine fixes and improvements contributed from Tom Lane o... check-in: 497b93405b user: dgp tags: trunk | |
| 13:50 | [1080042][8f245009b0] Big bundle of regexp engine fixes and improvements contributed from Tom Lane o... check-in: 01bd72a637 user: dgp tags: core-8-5-branch | |
| 13:11 | • Ticket [1080042fff] \Y can be quantified as (\Y) status still Open with 3 ot... artifact: 033745a511 user: dgp | |
|
2015-10-20
| ||
| 23:24 | • Ticket [1080042fff]: 3 changes artifact: cc50d7fc9b user: tgl | |
| 20:23 | • Ticket [1080042fff]: 3 changes artifact: 3e2352fff5 user: dgp | |
|
2015-10-15
| ||
| 05:32 | • Ticket [1080042fff]: 7 changes artifact: aec51a7212 user: tgl | |
|
2004-12-06
| ||
| 16:02 | • New ticket [1080042fff]. artifact: 81b40f23c5 user: kaitzschu | |
\Y can be quantified as (\Y)
Closed / Fixed1080042fffffffffffffffffffffffffffffffffCreated 22 years agoUpdated 11 years ago
Descriptionplain2004-12-06 16:02:12
Donal K. Fellows advised me to report this as a bug. Summary says it all. Try following (by Arjen Markus)
regexp {(\Y)+} foo
and see it happening.
tglplain2015-10-15 05:32:13
I've written a fix for this problem. It's included along with a batch of other regex fixes in this submission to the Postgres project: http://www.postgresql.org/message-id/[email protected] I plan to submit a Tcl-adapted version of this code once it's committed to Postgres, but if anyone would like to help review it right now, please step up.
dgpplain2015-10-20 20:23:41
I've now adapted all the patches I found at that link, yet this bug still remains. Is the bug fix really somewhere else?
tglplain2015-10-20 23:24:21
Um ... do we have different ideas of what the bug is?
In 8.6.4 I see
% regexp {(\Y)+} foo
couldn't compile regular expression pattern: nfa has too many states
Building from commit 8dd308bfed2d855e902aa815eadabbe560d39e2d (tip of tgl-pg-re), I see
% regexp {(\Y)+} foo
1
which seems like the correct behavior to me.
I did a quick manual comparison of regc_nfa.c from your tree to ours, and I don't see anything that you seem to have missed, except for the stack-depth-checking changes not being there.
dgpplain2015-10-21 13:11:54
Ok, what's confusing me is this:
% regexp {(\Y)+} foo
1
% regexp {\Y+} foo
couldn't compile regular expression pattern: quantifier operand invalid
I don't understand why adding the parens converts an RE from
something invalid into something valid.
I do confirm the changes your report though.
dgpplain2015-10-21 14:20:09
Fix accepted. Leaving Pending in case anyone can comment and clear up my confusion.
tglplain2015-10-21 16:27:25
> I don't understand why adding the parens converts an RE from > something invalid into something valid. This is pretty key actually: I suspect Henry Spencer may never have considered this sort of situation, because he explicitly disallows quantification of bare constraints in the re_syntax.n man page. It says in so many words "A constraint may not be followed by a quantifier.", and this is also implicit in the careful distinctions it draws between atoms (which match some amount of text) and constraints (which don't). However, any legal RE can be enclosed in parentheses, making it an atom, which allows it to be quantified. I think his rule against quantifying bare constraints is sensible: a constraint either matches or doesn't, there is no point in applying it more than once. So another way we might possibly have addressed this is to disallow quantification of subexpressions that don't contain at least one non-constraint. But I'm not quite convinced that that wouldn't break some useful cases, and it probably wouldn't be trivial to implement either.
dgpplain2015-10-21 17:01:58
Thanks for the info. And thanks for all the improvements too.
Log in (anonymous is fine) to add a comment.