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
7c51cce0
Commit
7c51cce0
authored
Jan 13, 2005
by
patg@patrick-galbraiths-computer.local
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
progress in fixing multi-key, two-byte prefix keys.
parent
5dd710a9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
140 additions
and
13 deletions
+140
-13
sql/ha_federated.cc
sql/ha_federated.cc
+139
-13
sql/ha_federated.h
sql/ha_federated.h
+1
-0
No files found.
sql/ha_federated.cc
View file @
7c51cce0
...
@@ -586,6 +586,103 @@ uint ha_federated::convert_row_to_internal_format(byte *record, MYSQL_ROW row)
...
@@ -586,6 +586,103 @@ uint ha_federated::convert_row_to_internal_format(byte *record, MYSQL_ROW row)
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
}
}
bool
ha_federated
::
create_where_from_key
(
String
*
to
,
KEY
*
key_info
,
const
byte
*
key
,
uint
key_length
)
{
uint
second_loop
=
0
;
KEY_PART_INFO
*
key_part
;
DBUG_ENTER
(
"ha_federated::create_where_from_key"
);
for
(
key_part
=
key_info
->
key_part
;
(
int
)
key_length
>
0
;
key_part
++
)
{
Field
*
field
=
key_part
->
field
;
uint
length
=
key_part
->
length
;
if
(
second_loop
++
&&
to
->
append
(
" AND "
,
5
))
DBUG_RETURN
(
1
);
if
(
to
->
append
(
'`'
)
||
to
->
append
(
field
->
field_name
)
||
to
->
append
(
"` "
,
2
))
DBUG_RETURN
(
1
);
// Out of memory
if
(
key_part
->
null_bit
)
{
if
(
*
key
++
)
{
if
(
to
->
append
(
"IS NULL"
,
7
))
DBUG_RETURN
(
1
);
key_length
-=
key_part
->
store_length
;
key
+=
key_part
->
store_length
-
1
;
continue
;
}
key_length
--
;
}
if
(
to
->
append
(
'='
))
DBUG_RETURN
(
1
);
if
(
key_part
->
type
==
HA_KEYTYPE_BIT
)
{
/* This is can be threated as a hex string */
Field_bit
*
field
=
(
Field_bit
*
)
(
key_part
->
field
);
char
buff
[
64
+
2
],
*
ptr
;
byte
*
end
=
key
+
length
;
buff
[
0
]
=
'0'
;
buff
[
1
]
=
'x'
;
for
(
ptr
=
buff
+
2
;
key
<
end
;
key
++
)
{
uint
tmp
=
(
uint
)
(
uchar
)
*
key
;
*
ptr
++=
_dig_vec_upper
[
tmp
>>
4
];
*
ptr
++=
_dig_vec_upper
[
tmp
&
15
];
}
if
(
to
->
append
(
buff
,
(
uint
)
(
ptr
-
buff
)))
DBUG_RETURN
(
1
);
key_length
-=
length
;
continue
;
}
if
(
key_part
->
key_part_flag
&
HA_BLOB_PART
)
{
uint
blob_length
=
uint2korr
(
key
);
key
+=
HA_KEY_BLOB_LENGTH
;
key_length
-=
HA_KEY_BLOB_LENGTH
;
if
(
append_escaped
(
to
,
key
,
blob_length
))
DBUG_RETURN
(
1
);
length
=
key_part
->
length
;
}
else
if
(
key_part
->
key_part_flag
&
HA_VAR_LENGTH_PART
)
{
key_length
-=
HA_KEY_BLOB_LENGTH
;
length
=
key_part
->
length
;
key
+=
HA_KEY_BLOB_LENGTH
;
if
(
append_escaped
(
to
,
key
,
length
))
DBUG_RETURN
(
1
);
}
else
{
//bool need_quotes= field->needs_quotes();
bool
needs_quotes
=
type_quote
(
field
->
type
());
char
buff
[
MAX_FIELD_WIDTH
];
String
str
(
buff
,
sizeof
(
buff
),
field
->
charset
()),
*
res
;
if
(
needs_quotes
&&
to
->
append
(
'='
))
DBUG_RETURN
(
1
);
res
=
field
->
val_str
(
&
str
,
(
char
*
)(
key
));
if
(
field
->
result_type
()
==
STRING_RESULT
)
{
if
(
append_escaped
(
to
,
res
->
ptr
(),
res
->
length
()))
DBUG_RETURN
(
1
);
}
else
if
(
to
->
append
(
res
->
ptr
(),
res
->
length
()))
DBUG_RETURN
(
1
);
if
(
needs_quotes
&&
to
->
append
(
'='
))
DBUG_RETURN
(
1
);
}
key
+=
length
;
key_length
-=
length
;
}
}
/*
/*
SYNOPSIS
SYNOPSIS
quote_data()
quote_data()
...
@@ -612,13 +709,13 @@ void ha_federated::quote_data(String *unquoted_string, Field *field )
...
@@ -612,13 +709,13 @@ void ha_federated::quote_data(String *unquoted_string, Field *field )
int
quote_flag
;
int
quote_flag
;
DBUG_ENTER
(
"ha_federated::quote_data"
);
DBUG_ENTER
(
"ha_federated::quote_data"
);
DBUG_PRINT
(
"ha_federated::quote_data"
,
(
"unescaped %s"
,
unquoted_string
->
c_ptr_quick
()));
// this is the same call that mysql_real_escape_string() calls
// this is the same call that mysql_real_escape_string() calls
escape_string_for_mysql
(
&
my_charset_bin
,
(
char
*
)
escaped_string
,
escape_string_for_mysql
(
&
my_charset_bin
,
(
char
*
)
escaped_string
,
unquoted_string
->
c_ptr_quick
(),
unquoted_string
->
length
());
unquoted_string
->
c_ptr_quick
(),
unquoted_string
->
length
());
DBUG_PRINT
(
"ha_federated::quote_data"
,
DBUG_PRINT
(
"ha_federated::quote_data"
,(
"escaped %s"
,
escaped_string
));
(
"escape_string_for_mysql unescaped %s escaped %s"
,
unquoted_string
->
c_ptr_quick
(),
escaped_string
));
if
(
field
->
is_null
())
if
(
field
->
is_null
())
{
{
...
@@ -630,6 +727,9 @@ void ha_federated::quote_data(String *unquoted_string, Field *field )
...
@@ -630,6 +727,9 @@ void ha_federated::quote_data(String *unquoted_string, Field *field )
quote_flag
=
type_quote
(
field
->
type
());
quote_flag
=
type_quote
(
field
->
type
());
DBUG_PRINT
(
"ha_federated::quote_data"
,
(
"quote flag %d type %d"
,
quote_flag
,
field
->
type
()));
if
(
quote_flag
==
0
)
if
(
quote_flag
==
0
)
{
{
DBUG_PRINT
(
"ha_federated::quote_data"
,
DBUG_PRINT
(
"ha_federated::quote_data"
,
...
@@ -1069,7 +1169,8 @@ int ha_federated::write_row(byte * buf)
...
@@ -1069,7 +1169,8 @@ int ha_federated::write_row(byte * buf)
values_string
.
append
(
','
);
values_string
.
append
(
','
);
DBUG_PRINT
(
"ha_federated::write_row"
,
DBUG_PRINT
(
"ha_federated::write_row"
,
(
"insert_string %s values_string %s insert_field_value_string %s"
,
(
"insert_string %s values_string %s insert_field_value_string %s"
,
insert_string
.
c_ptr_quick
(),
values_string
.
c_ptr_quick
(),
insert_field_value_string
.
c_ptr_quick
()));
insert_string
.
c_ptr_quick
(),
values_string
.
c_ptr_quick
(),
insert_field_value_string
.
c_ptr_quick
()));
}
}
}
}
...
@@ -1365,30 +1466,55 @@ int ha_federated::index_read_idx(byte * buf, uint index, const byte * key,
...
@@ -1365,30 +1466,55 @@ int ha_federated::index_read_idx(byte * buf, uint index, const byte * key,
__attribute__
((
unused
)))
__attribute__
((
unused
)))
{
{
char
index_value
[
IO_SIZE
];
char
index_value
[
IO_SIZE
];
char
key_value
[
IO_SIZE
];
char
test_value
[
IO_SIZE
];
String
index_string
(
index_value
,
sizeof
(
index_value
),
&
my_charset_bin
);
String
index_string
(
index_value
,
sizeof
(
index_value
),
&
my_charset_bin
);
String
test_string
(
test_value
,
sizeof
(
test_value
),
&
my_charset_bin
);
index_string
.
length
(
0
);
index_string
.
length
(
0
);
test_string
.
length
(
0
);
uint
keylen
;
char
sql_query_buffer
[
IO_SIZE
];
char
sql_query_buffer
[
IO_SIZE
];
String
tmp_string
;
String
sql_query
(
sql_query_buffer
,
sizeof
(
sql_query_buffer
),
&
my_charset_bin
);
String
sql_query
(
sql_query_buffer
,
sizeof
(
sql_query_buffer
),
&
my_charset_bin
);
sql_query
.
length
(
0
);
sql_query
.
length
(
0
);
DBUG_ENTER
(
"ha_federated::index_read_idx"
);
DBUG_ENTER
(
"ha_federated::index_read_idx"
);
statistic_increment
(
table
->
in_use
->
status_var
.
ha_read_key_count
,
&
LOCK_status
);
statistic_increment
(
table
->
in_use
->
status_var
.
ha_read_key_count
,
&
LOCK_status
);
index_string
.
length
(
0
);
sql_query
.
length
(
0
);
sql_query
.
append
(
share
->
select_query
);
sql_query
.
append
(
share
->
select_query
);
sql_query
.
append
(
" WHERE "
);
sql_query
.
append
(
" WHERE "
);
sql_query
.
append
(
table
->
key_info
[
index
].
key_part
->
field
->
field_name
);
sql_query
.
append
(
table
->
key_info
[
index
].
key_part
->
field
->
field_name
);
sql_query
.
append
(
" = "
);
sql_query
.
append
(
" = "
);
table
->
key_info
[
index
].
key_part
->
field
->
val_str
(
&
index_string
,
(
char
*
)(
key
));
if
(
table
->
key_info
[
index
].
key_part
->
field
->
type
()
==
MYSQL_TYPE_VARCHAR
)
{
//keylen= uint2korr(key);
keylen
=
key
[
0
];
create_where_from_key
(
&
tmp_string
,
&
table
->
key_info
[
index
],
key
,
keylen
);
memcpy
(
key_value
,
key
+
HA_KEY_BLOB_LENGTH
,
keylen
);
key_value
[
keylen
]
=
0
;
DBUG_PRINT
(
"ha_federated::index_read_idx"
,
(
"key_value %s len %d"
,
key_value
,
keylen
));
index_string
.
append
(
key_value
);
}
else
{
//table->key_info[index].key_part->field->val_str(&index_string, (char
//*)(key));
index_string
.
append
((
char
*
)(
key
));
}
DBUG_PRINT
(
"ha_federated::index_read_idx"
,
(
"current key %d key value %s index_string value %s length %d"
,
index
,
(
char
*
)(
key
),
index_string
.
c_ptr_quick
(),
index_string
.
length
()));
//table->key_info[index].key_part->field->val_str(&index_string);
quote_data
(
&
index_string
,
table
->
key_info
[
index
].
key_part
->
field
);
quote_data
(
&
index_string
,
table
->
key_info
[
index
].
key_part
->
field
);
sql_query
.
append
(
index_string
);
sql_query
.
append
(
index_string
);
DBUG_PRINT
(
"ha_federated::index_read_idx"
,
DBUG_PRINT
(
"ha_federated::index_read_idx"
,
(
"sql_query %s"
,
sql_query
.
c_ptr_quick
()));
(
"current position %d sql_query %s"
,
current_position
,
sql_query
.
c_ptr_quick
()));
if
(
mysql_real_query
(
mysql
,
sql_query
.
c_ptr_quick
(),
sql_query
.
length
()))
if
(
mysql_real_query
(
mysql
,
sql_query
.
c_ptr_quick
(),
sql_query
.
length
()))
{
{
...
@@ -1539,7 +1665,7 @@ int ha_federated::rnd_pos(byte * buf, byte *pos)
...
@@ -1539,7 +1665,7 @@ int ha_federated::rnd_pos(byte * buf, byte *pos)
{
{
DBUG_ENTER
(
"ha_federated::rnd_pos"
);
DBUG_ENTER
(
"ha_federated::rnd_pos"
);
statistic_increment
(
table
->
in_use
->
status_var
.
ha_read_rnd_count
,
&
LOCK_status
);
statistic_increment
(
table
->
in_use
->
status_var
.
ha_read_rnd_count
,
&
LOCK_status
);
memcpy
(
current_position
,
pos
,
sizeof
(
MYSQL_ROW_OFFSET
));
// pos is not aligned
memcpy
_fixed
(
&
current_position
,
pos
,
sizeof
(
MYSQL_ROW_OFFSET
));
// pos is not aligned
result
->
current_row
=
0
;
result
->
current_row
=
0
;
result
->
data_cursor
=
current_position
;
result
->
data_cursor
=
current_position
;
DBUG_RETURN
(
rnd_next
(
buf
));
DBUG_RETURN
(
rnd_next
(
buf
));
...
...
sql/ha_federated.h
View file @
7c51cce0
...
@@ -75,6 +75,7 @@ private:
...
@@ -75,6 +75,7 @@ private:
uint
convert_row_to_internal_format
(
byte
*
buf
,
MYSQL_ROW
row
);
uint
convert_row_to_internal_format
(
byte
*
buf
,
MYSQL_ROW
row
);
uint
type_quote
(
int
type
);
uint
type_quote
(
int
type
);
void
quote_data
(
String
*
string1
,
Field
*
field
);
void
quote_data
(
String
*
string1
,
Field
*
field
);
bool
ha_federated
::
create_where_from_key
(
String
*
to
,
KEY
*
key_info
,
const
byte
*
key
,
uint
key_length
);
public:
public:
ha_federated
(
TABLE
*
table
)
:
handler
(
table
),
ha_federated
(
TABLE
*
table
)
:
handler
(
table
),
...
...
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