DeveelDB
20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
|
This is a static class that performs the operations to do a pattern search on a given column of a table. More...
Static Public Member Functions | |
static bool | IsWildCard (char ch) |
Returns true if the given character is a wild card (unknown). More... | |
static bool | FullPatternMatch (string pattern, string str, char escapeChar) |
Matches a pattern against a string and returns true if it matches or false otherwise. More... | |
static bool | PatternMatch (string pattern, string expression, char escapeChar) |
This is the pattern match recurrsive method. More... | |
Private Attributes | |
const char | ZeroOrMoreChars = '%' |
const char | OneChar = '_' |
This is a static class that performs the operations to do a pattern search on a given column of a table.
The pattern syntax is very simple and follows that of the SQL standard.
It works as follows: The '' character represents any sequence of characters. The '_' character represents some character.
Therefore, the pattern search Anto%
will find all rows that start with the string Anto
and end with any sequence of characters. The pattern A% Proven%
will find all names starting with A and containing Proven somewhere in the end. The pattern _at will find all three letter words ending with at.
Note A ab%
type search is faster than a bc
type search. If the start of the search pattern is unknown then the entire contents of the column need to be accessed.
Definition at line 45 of file PatternSearch.cs.
|
inlinestatic |
Matches a pattern against a string and returns true if it matches or false otherwise.
This matches patterns that do not necessarily start with a wild card unlike the PatternMatch method.
Definition at line 67 of file PatternSearch.cs.
|
inlinestatic |
Returns true if the given character is a wild card (unknown).
ch |
Definition at line 55 of file PatternSearch.cs.
|
inlinestatic |
This is the pattern match recurrsive method.
It recurses on each wildcard expression in the pattern which makes for slightly better efficiency than a character recurse algorithm. However, patterns such as __a
will result in many recursive calls.
Note That __
will be less efficient than __%
and will produce the same result.
Note It requires that a wild card character is the first character in the expression.
Issue Pattern optimiser, we should optimize wild cards of type __
to __%
, or ____%
to ____%
. Optimised forms are identical in result and more efficient. This optimization could be performed by the client during parsing of the LIKE statement.
Hacking Issue Badly formed wild cards may result in hogging of server side resources.
Definition at line 129 of file PatternSearch.cs.
|
private |
Definition at line 48 of file PatternSearch.cs.
|
private |
Definition at line 47 of file PatternSearch.cs.