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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
b75ca6c6
Commit
b75ca6c6
authored
Mar 02, 2013
by
Andrew McDonnell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First cut at conversion to use varchar (untested)
parent
31dfd3a1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
85 additions
and
14 deletions
+85
-14
storage/oqgraph/graphcore.cc
storage/oqgraph/graphcore.cc
+0
-9
storage/oqgraph/graphcore.h
storage/oqgraph/graphcore.h
+12
-0
storage/oqgraph/ha_oqgraph.cc
storage/oqgraph/ha_oqgraph.cc
+73
-5
No files found.
storage/oqgraph/graphcore.cc
View file @
b75ca6c6
...
...
@@ -674,15 +674,6 @@ namespace open_query
{
optional
<
Vertex
>
orig
,
dest
;
int
op
=
0
,
seq
=
0
;
enum
{
NO_SEARCH
=
0
,
DIJKSTRAS
=
1
,
BREADTH_FIRST
=
2
,
ALGORITHM
=
0x0ffff
,
HAVE_ORIG
=
0x10000
,
HAVE_DEST
=
0x20000
,
};
delete
cursor
;
cursor
=
0
;
row_info
=
empty_row
;
...
...
storage/oqgraph/graphcore.h
View file @
b75ca6c6
...
...
@@ -62,6 +62,18 @@ namespace open_query
inline
~
oqgraph
()
throw
();
public:
// Integer operation flags
enum
{
NO_SEARCH
=
0
,
DIJKSTRAS
=
1
,
BREADTH_FIRST
=
2
,
NUM_SEARCH_OP
=
3
,
ALGORITHM
=
0x0ffff
,
HAVE_ORIG
=
0x10000
,
HAVE_DEST
=
0x20000
,
};
enum
error_code
{
OK
=
0
,
...
...
storage/oqgraph/ha_oqgraph.cc
View file @
b75ca6c6
...
...
@@ -47,6 +47,17 @@
using
namespace
open_query
;
// Table of varchar latch operations.
// In the future this needs to be refactactored to somewhere else
struct
oqgraph_latch_op_table
{
const
char
*
key
;
int
latch
;
};
static
const
oqgraph_latch_op_table
latch_ops_table
[]
=
{
{
"no_search"
,
oqgraph
::
NO_SEARCH
}
,
{
"dijkstras"
,
oqgraph
::
DIJKSTRAS
}
,
{
"breadth_first"
,
oqgraph
::
BREADTH_FIRST
}
,
{
NULL
,
-
1
}
};
struct
oqgraph_table_option_struct
{
char
*
table_name
;
...
...
@@ -176,7 +187,7 @@ static int error_code(int res)
*
* ColName Type Attributes
* ======= ======== =============
* latch
SMALLINT UNSIGNED
NULL
* latch
VARCHAR
NULL
* origid BIGINT UNSIGNED NULL
* destid BIGINT UNSIGNED NULL
* weight DOUBLE NULL
...
...
@@ -184,8 +195,12 @@ static int error_code(int res)
* linkid BIGINT UNSIGNED NULL
* =================================
*
The latch may be a varchar of any length, however if it is too short,
then some of the OQGRAPH graph operations will not be able to be executed.
CREATE TABLE foo (
latch
SMALLINT UNSIGNED
NULL,
latch
VARCHAR(255)
NULL,
origid BIGINT UNSIGNED NULL,
destid BIGINT UNSIGNED NULL,
weight DOUBLE NULL,
...
...
@@ -203,7 +218,7 @@ static int oqgraph_check_table_structure (TABLE *table_arg)
{
int
i
;
struct
{
const
char
*
colname
;
int
coltype
;
}
skel
[]
=
{
{
"latch"
,
MYSQL_TYPE_S
HORT
},
{
"latch"
,
MYSQL_TYPE_S
TRING
},
{
"origid"
,
MYSQL_TYPE_LONGLONG
},
{
"destid"
,
MYSQL_TYPE_LONGLONG
},
{
"weight"
,
MYSQL_TYPE_DOUBLE
},
...
...
@@ -600,6 +615,51 @@ int ha_oqgraph::index_next_same(byte *buf, const byte *key, uint key_len)
return
error_code
(
res
);
}
/**
* This function parse the VARCHAR(n) latch specification into an integer operation specification compatible with
* v1-v3 oqgraph::search().
*
* If the string contains a number, this is directly converted from a decimal integer.
*
* Otherwise, a lookup table is used to convert from a string constant.
*
* It is anticipated that this function (and this file and class oqgraph) will be refactored to do this in a nicer way.
*
* FIXME: For the time being, only handles latin1 character set.
* @return false if parsing fails.
*/
static
bool
parse_latch_string_to_legacy_int
(
const
String
&
value
,
int
&
latch
)
{
// attempt to parse as an integer first.
// to be nice we trim whitespace
LEX_STRING
lex
=
value
.
lex_string
();
trim_whitespace
(
&
my_charset_latin1
,
&
lex
);
if
(
!
strlen
(
lex
.
str
))
{
// treat an empty string same as (LATCH=NULL) in query
latch
=
oqgraph
::
NO_SEARCH
;
return
true
;
}
char
*
eptr
;
unsigned
long
int
v
=
strtoul
(
lex
.
str
,
&
eptr
,
10
);
if
(
!*
eptr
)
{
// we had an unsigned number.
if
(
v
>
0
&&
v
<
oqgraph
::
NUM_SEARCH_OP
)
{
latch
=
v
;
return
true
;
}
// fall through and test as a string (although it is unlikely we might have an operator starting with a number)
}
const
oqgraph_latch_op_table
*
entry
=
latch_ops_table
;
for
(
;
entry
->
key
;
entry
++
)
{
if
(
0
==
strcmp
(
entry
->
key
,
lex
.
str
))
{
latch
=
entry
->
latch
;
return
true
;
}
}
return
false
;
}
int
ha_oqgraph
::
index_read_idx
(
byte
*
buf
,
uint
index
,
const
byte
*
key
,
uint
key_len
,
enum
ha_rkey_function
find_flag
)
{
...
...
@@ -608,8 +668,8 @@ int ha_oqgraph::index_read_idx(byte * buf, uint index, const byte * key,
int
res
;
VertexID
orig_id
,
dest_id
;
int
latch
;
int
*
latchp
;
VertexID
*
orig_idp
=
0
,
*
dest_idp
=
0
;
int
*
latchp
=
0
;
open_query
::
row
row
;
bmove_align
(
buf
,
table
->
s
->
default_values
,
table
->
s
->
reclength
);
...
...
@@ -627,7 +687,15 @@ int ha_oqgraph::index_read_idx(byte * buf, uint index, const byte * key,
if
(
!
field
[
0
]
->
is_null
())
{
latch
=
(
int
)
field
[
0
]
->
val_int
();
//latch= (int) field[0]->val_int();
String
value
;
field
[
0
]
->
val_str
(
&
value
,
&
value
);
if
(
!
parse_latch_string_to_legacy_int
(
value
,
latch
))
{
// Invalid, so warn & fail
push_warning_printf
(
current_thd
,
MYSQL_ERROR
::
WARN_LEVEL_WARN
,
ER_WRONG_ARGUMENTS
,
ER
(
ER_WRONG_ARGUMENTS
),
"OQGRAPH latch"
);
table
->
status
=
STATUS_NOT_FOUND
;
return
error_code
(
oqgraph
::
NO_MORE_DATA
);
}
latchp
=
&
latch
;
}
...
...
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