summaryrefslogtreecommitdiff
path: root/ndb/include
diff options
context:
space:
mode:
authorunknown <pekka@mysql.com>2005-02-17 17:12:36 +0100
committerunknown <pekka@mysql.com>2005-02-17 17:12:36 +0100
commitac2e5124d8d52150567c71f53102f5b03b341246 (patch)
tree408f685af70b7332f9cea922be934bbef521d278 /ndb/include
parent134c099c5f604148ab581388e916a698ed0c7964 (diff)
downloadmariadb-git-ac2e5124d8d52150567c71f53102f5b03b341246.tar.gz
ndb - TUP scan filter support for LIKE/NOT_LIKE
ndb/include/ndbapi/NdbScanFilter.hpp: TUP scan filter support for LIKE/NOT_LIKE ndb/include/util/NdbSqlUtil.hpp: TUP scan filter support for LIKE/NOT_LIKE ndb/src/common/util/NdbSqlUtil.cpp: TUP scan filter support for LIKE/NOT_LIKE ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp: TUP scan filter support for LIKE/NOT_LIKE ndb/src/ndbapi/NdbScanFilter.cpp: TUP scan filter support for LIKE/NOT_LIKE
Diffstat (limited to 'ndb/include')
-rw-r--r--ndb/include/ndbapi/NdbScanFilter.hpp4
-rw-r--r--ndb/include/util/NdbSqlUtil.hpp36
2 files changed, 23 insertions, 17 deletions
diff --git a/ndb/include/ndbapi/NdbScanFilter.hpp b/ndb/include/ndbapi/NdbScanFilter.hpp
index 7c575169dc1..b5457bab99b 100644
--- a/ndb/include/ndbapi/NdbScanFilter.hpp
+++ b/ndb/include/ndbapi/NdbScanFilter.hpp
@@ -53,7 +53,9 @@ public:
COND_GE = 2, ///< upper bound
COND_GT = 3, ///< upper bound, strict
COND_EQ = 4, ///< equality
- COND_NE = 5 ///< not equal
+ COND_NE = 5, ///< not equal
+ COND_LIKE = 6, ///< like
+ COND_NOT_LIKE = 7 ///< not like
};
/**
diff --git a/ndb/include/util/NdbSqlUtil.hpp b/ndb/include/util/NdbSqlUtil.hpp
index 41e4dadfd60..ebcfc562ec4 100644
--- a/ndb/include/util/NdbSqlUtil.hpp
+++ b/ndb/include/util/NdbSqlUtil.hpp
@@ -26,20 +26,6 @@ typedef struct charset_info_st CHARSET_INFO;
class NdbSqlUtil {
public:
/**
- * Compare strings, optionally with padded semantics. Returns
- * negative (less), zero (equal), or positive (greater).
- */
- static int char_compare(const char* s1, unsigned n1,
- const char* s2, unsigned n2, bool padded);
-
- /**
- * Like operator, optionally with padded semantics. Returns true or
- * false.
- */
- static bool char_like(const char* s1, unsigned n1,
- const char* s2, unsigned n2, bool padded);
-
- /**
* Compare attribute values. Returns -1, 0, +1 for less, equal,
* greater, respectively. Parameters are pointers to values and their
* lengths in bytes. The lengths can differ.
@@ -48,7 +34,7 @@ public:
* the partial value is not enough to determine the result, CmpUnknown
* will be returned. A shorter second value is not necessarily
* partial. Partial values are allowed only for types where prefix
- * comparison is possible (basically, binary types).
+ * comparison is possible (basically, binary strings).
*
* First parameter is a pointer to type specific extra info. Char
* types receive CHARSET_INFO in it.
@@ -58,6 +44,18 @@ public:
*/
typedef int Cmp(const void* info, const void* p1, unsigned n1, const void* p2, unsigned n2, bool full);
+ /**
+ * Prototype for "like" comparison. Defined for the 3 char string
+ * types. Second argument must have same type-specific format.
+ * Returns >0 on match, 0 on no match, <0 on bad data.
+ *
+ * Uses default special chars ( \ % _ ).
+ *
+ * TODO convert special chars to the cs so that ucs2 etc works
+ * TODO allow user-defined escape ( \ )
+ */
+ typedef int Like(const void* info, const void* p1, unsigned n1, const void* p2, unsigned n2);
+
enum CmpResult {
CmpLess = -1,
CmpEqual = 0,
@@ -101,6 +99,7 @@ public:
};
Enum m_typeId; // redundant
Cmp* m_cmp; // comparison method
+ Like* m_like; // "like" comparison method
};
/**
@@ -110,7 +109,8 @@ public:
/**
* Get the normalized type used in hashing and key comparisons.
- * Maps all string types to Binary.
+ * Maps all string types to Binary. This includes Var* strings
+ * because strxfrm result is padded to fixed (maximum) length.
*/
static const Type& getTypeBinary(Uint32 typeId);
@@ -176,6 +176,10 @@ private:
static Cmp cmpOlddecimalunsigned;
static Cmp cmpDecimal;
static Cmp cmpDecimalunsigned;
+ //
+ static Like likeChar;
+ static Like likeVarchar;
+ static Like likeLongvarchar;
};
#endif