Closed Bug 474274 Opened 16 years ago Closed 16 years ago

Request to implement regex loadable extension for SQLite

Categories

(Toolkit :: Storage, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 391750

People

(Reporter: noah.hart, Unassigned)

Details

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5 (.NET CLR 3.5.30729) Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5 (.NET CLR 3.5.30729) As expected, executing the preparing the following SQL statement 'SELECT "TEXT" REGEX "T*";' gives an error, since there is no REGEX function natively included in SQLite. However, SQLite does allow loadable extensions via SELECT load_extension('filename'); Would be nice to have an Unicode aware regex available. Reproducible: Always
You could actually just define a user function "regexp" using a js component and run it through the js regexp object to make this work, no need for a loadable extension at all. Presumably it is also possible to just bundle such an extension with your add-on and load it that way.
In a trivial case, running the results rows through a js regexp object would work, but in a more complex case, such as SELECT * FROM TABLE_1 WHERE FIELD_1 IN (SELECT MATCH_1 FROM TABLE_2 WHERE TEST_1 REGEX "T*") it would involve recreating the SQLite logic in the calling procedure. It would be better for the work to be done in the SQL database engine itself.
From the sqlite docs: "The REGEXP operator is a special syntax for the regexp() user function". So it should be very easy to implement a mozIStorageFunction for regexp to achieve what you want.
It also wouldn't be terribly difficult for us to implement it internally in storage like we provide some Unicode-compliant string functions. We already have a bug for this though.
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.