Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
5135d05a
Commit
5135d05a
authored
Feb 21, 2005
by
pekka@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ndb - fix TUP filtering of LIKE / NOT_LIKE
parent
beb8d6aa
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
25 deletions
+30
-25
ndb/include/util/NdbSqlUtil.hpp
ndb/include/util/NdbSqlUtil.hpp
+3
-3
ndb/src/common/util/NdbSqlUtil.cpp
ndb/src/common/util/NdbSqlUtil.cpp
+10
-6
ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp
ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp
+17
-16
No files found.
ndb/include/util/NdbSqlUtil.hpp
View file @
5135d05a
...
...
@@ -45,9 +45,9 @@ 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.
* Prototype for "like" comparison. Defined for
string types. Second
*
argument must have same type-specific format. Returns 0 on match,
*
+1 on no match, and -1
on bad data.
*
* Uses default special chars ( \ % _ ).
*
...
...
ndb/src/common/util/NdbSqlUtil.cpp
View file @
5135d05a
...
...
@@ -795,14 +795,18 @@ NdbSqlUtil::cmpTimestamp(const void* info, const void* p1, unsigned n1, const vo
// like
static
const
int
ndb_wild_prefix
=
'\\'
;
static
const
int
ndb_wild_one
=
'_'
;
static
const
int
ndb_wild_many
=
'%'
;
int
NdbSqlUtil
::
likeChar
(
const
void
*
info
,
const
void
*
p1
,
unsigned
n1
,
const
void
*
p2
,
unsigned
n2
)
{
const
char
*
v1
=
(
const
char
*
)
p1
;
const
char
*
v2
=
(
const
char
*
)
p2
;
CHARSET_INFO
*
cs
=
(
CHARSET_INFO
*
)(
info
);
int
k
=
(
cs
->
coll
->
wildcmp
)(
cs
,
v1
,
v1
+
n1
,
v2
,
v2
+
n2
,
wild_prefix
,
wild_one
,
wild_many
);
return
k
;
int
k
=
(
cs
->
coll
->
wildcmp
)(
cs
,
v1
,
v1
+
n1
,
v2
,
v2
+
n2
,
ndb_wild_prefix
,
ndb_wild_one
,
ndb_
wild_many
);
return
k
==
0
?
0
:
+
1
;
}
int
...
...
@@ -825,8 +829,8 @@ NdbSqlUtil::likeVarchar(const void* info, const void* p1, unsigned n1, const voi
const
char
*
w1
=
(
const
char
*
)
v1
+
lb
;
const
char
*
w2
=
(
const
char
*
)
v2
+
lb
;
CHARSET_INFO
*
cs
=
(
CHARSET_INFO
*
)(
info
);
int
k
=
(
cs
->
coll
->
wildcmp
)(
cs
,
w1
,
w1
+
m1
,
w2
,
w2
+
m2
,
wild_prefix
,
wild_one
,
wild_many
);
return
k
;
int
k
=
(
cs
->
coll
->
wildcmp
)(
cs
,
w1
,
w1
+
m1
,
w2
,
w2
+
m2
,
ndb_wild_prefix
,
ndb_wild_one
,
ndb_
wild_many
);
return
k
==
0
?
0
:
+
1
;
}
}
return
-
1
;
...
...
@@ -852,8 +856,8 @@ NdbSqlUtil::likeLongvarchar(const void* info, const void* p1, unsigned n1, const
const
char
*
w1
=
(
const
char
*
)
v1
+
lb
;
const
char
*
w2
=
(
const
char
*
)
v2
+
lb
;
CHARSET_INFO
*
cs
=
(
CHARSET_INFO
*
)(
info
);
int
k
=
(
cs
->
coll
->
wildcmp
)(
cs
,
w1
,
w1
+
m1
,
w2
,
w2
+
m2
,
wild_prefix
,
wild_one
,
wild_many
);
return
k
;
int
k
=
(
cs
->
coll
->
wildcmp
)(
cs
,
w1
,
w1
+
m1
,
w2
,
w2
+
m2
,
ndb_wild_prefix
,
ndb_wild_one
,
ndb_
wild_many
);
return
k
==
0
?
0
:
+
1
;
}
}
return
-
1
;
...
...
ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp
View file @
5135d05a
...
...
@@ -1861,56 +1861,57 @@ int Dbtup::interpreterNextLab(Signal* signal,
bool
r1_null
=
ah
.
isNULL
();
bool
r2_null
=
argLen
==
0
;
int
res
;
int
res
1
;
if
(
cond
!=
Interpreter
::
LIKE
&&
cond
!=
Interpreter
::
NOT_LIKE
)
{
if
(
r1_null
||
r2_null
)
{
// NULL==NULL and NULL<not-NULL
res
=
r1_null
&&
r2_null
?
0
:
r1_null
?
-
1
:
1
;
res
1
=
r1_null
&&
r2_null
?
0
:
r1_null
?
-
1
:
1
;
}
else
{
res
=
(
*
sqlType
.
m_cmp
)(
cs
,
s1
,
attrLen
,
s2
,
argLen
,
true
);
res
1
=
(
*
sqlType
.
m_cmp
)(
cs
,
s1
,
attrLen
,
s2
,
argLen
,
true
);
}
}
else
{
if
(
r1_null
||
r2_null
)
{
// NULL like NULL is true (has no practical use)
res
=
r1_null
&&
r2_null
?
0
:
-
1
;
res
1
=
r1_null
&&
r2_null
?
0
:
-
1
;
}
else
{
res
=
(
*
sqlType
.
m_like
)(
cs
,
s1
,
attrLen
,
s2
,
argLen
);
res
1
=
(
*
sqlType
.
m_like
)(
cs
,
s1
,
attrLen
,
s2
,
argLen
);
}
}
int
res
=
0
;
switch
((
Interpreter
::
BinaryCondition
)
cond
)
{
case
Interpreter
:
:
EQ
:
res
=
(
res
==
0
);
res
=
(
res
1
==
0
);
break
;
case
Interpreter
:
:
NE
:
res
=
(
res
!=
0
);
res
=
(
res
1
!=
0
);
break
;
// note the condition is backwards
case
Interpreter
:
:
LT
:
res
=
(
res
>
0
);
res
=
(
res
1
>
0
);
break
;
case
Interpreter
:
:
LE
:
res
=
(
res
>=
0
);
res
=
(
res
1
>=
0
);
break
;
case
Interpreter
:
:
GT
:
res
=
(
res
<
0
);
res
=
(
res
1
<
0
);
break
;
case
Interpreter
:
:
GE
:
res
=
(
res
<=
0
);
res
=
(
res
1
<=
0
);
break
;
case
Interpreter
:
:
LIKE
:
res
=
(
res
>
0
);
res
=
(
res
1
==
0
);
break
;
case
Interpreter
:
:
NOT_LIKE
:
res
=
(
res
==
0
);
res
=
(
res
1
==
1
);
break
;
// XXX handle invalid value
}
#ifdef TRACE_INTERPRETER
ndbout_c
(
"cond=%u
diff=%d vc=%d nopad=%d attr(%d) = >%.*s<(%d) str=>%.*s<(%d) -> res =
%d"
,
cond
,
diff
,
vchr
,
nopad
,
attrId
>>
16
,
attrLen
,
s1
,
attrLen
,
argLen
,
s2
,
argLen
,
res
);
ndbout_c
(
"cond=%u
attr(%d)='%.*s'(%d) str='%.*s'(%d) res1=%d res=
%d"
,
cond
,
attrId
>>
16
,
attrLen
,
s1
,
attrLen
,
argLen
,
s2
,
argLen
,
res1
,
res
);
#endif
if
(
res
)
TprogramCounter
=
brancher
(
theInstruction
,
TprogramCounter
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment