[SERVER-5728] Regular Expression Query Limitations Created: 30/Apr/12  Updated: 11/Jul/16  Resolved: 01/Sep/12

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 2.0.1, 2.1.1
Fix Version/s: 2.3.0

Type: Bug Priority: Major - P3
Reporter: Cory Spencer Assignee: Randolph Tan
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Linux, Mac OS X


Operating System: ALL
Participants:

 Description   

Querying MongoDB with a regular expression exceeding 32764 characters in length silently fails without returning any results or raising any errors.

An example of this behaviour is as follows.

Create a document in the mongo shell:

  > String.prototype.repeat = function(n) { return new Array(n + 1).join(this) }
  function (n) {
      return (new Array(n + 1)).join(this);
  }
  > db.example.insert({ field : "x".repeat(50000) })

Querying for the document with a 32764 character regular expression will return a result as expected:

  > db.example.find({ field : { $regex : "x".repeat(32764) }})
  > { "_id" : ObjectId("4f9e1678d3eff3503675d2be"), "field" : "..." }

Querying for a document with a 32765 character regular expression fails with no errors nor results:

  > db.example.find({ field : { $regex : "x".repeat(32765) }})
  >

As per Eliot on the mongodb-user list:

"That looks like the default pcre max size.
Can you open a ticket @ jira.mongodb.org to see if its possible to
increase the size?"



 Comments   
Comment by auto [ 01/Sep/12 ]

Author:

{u'date': u'2012-09-01T16:15:37-07:00', u'email': u'randolph@10gen.com', u'name': u'Randolph Tan'}

Message: Fixed buildbot test failure caused by SERVER-5728
Branch: master
https://github.com/mongodb/mongo/commit/e42801cf9d3e8524146b23b5395c40b3137df794

Comment by auto [ 01/Sep/12 ]

Author:

{u'date': u'2012-05-07T13:32:39-07:00', u'email': u'randolph@10gen.com', u'name': u'Randolph Tan'}

Message: SERVER-5728 Regular Expression Query Limitations

Added assert when user tries to create a reqex query with size
greater than the max pattern size pcre can handle correctly with
the current configuration.
Branch: master
https://github.com/mongodb/mongo/commit/bed40ed0f9df2dc815df23d5437f1d8ffed5931f

Generated at Thu Feb 08 03:09:43 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.