Skip to content

Instantly share code, notes, and snippets.

@spetrunia
Created January 27, 2017 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spetrunia/c7665515f9c5e714dd8869701fdabcc0 to your computer and use it in GitHub Desktop.
Save spetrunia/c7665515f9c5e714dd8869701fdabcc0 to your computer and use it in GitHub Desktop.
diff '--exclude=.*' -urpN 10.2-mariarocks-pre/CMakeLists.txt 10.2-mariarocks-noc/CMakeLists.txt
--- 10.2-mariarocks-pre/CMakeLists.txt 2017-01-18 10:11:20.268169303 +0300
+++ 10.2-mariarocks-noc/CMakeLists.txt 2017-01-18 10:08:26.981202365 +0300
@@ -363,6 +363,10 @@ IF(WITH_UNIT_TESTS)
ENDIF()
SET (MYSQLD_STATIC_PLUGIN_LIBS "" CACHE INTERNAL "")
+
+# mariadb_connector_c fetches submodules which is useful for plugins
+INCLUDE(mariadb_connector_c) # this does ADD_SUBDIRECTORY(libmariadb)
+
# Add storage engines and plugins.
CONFIGURE_PLUGINS()
@@ -372,7 +376,6 @@ ADD_SUBDIRECTORY(strings)
ADD_SUBDIRECTORY(vio)
ADD_SUBDIRECTORY(mysys)
ADD_SUBDIRECTORY(mysys_ssl)
-INCLUDE(mariadb_connector_c) # this does ADD_SUBDIRECTORY(libmariadb)
ADD_SUBDIRECTORY(client)
ADD_SUBDIRECTORY(extra)
ADD_SUBDIRECTORY(libservices)
diff '--exclude=.*' -urpN 10.2-mariarocks-pre/include/hash.h 10.2-mariarocks-noc/include/hash.h
--- 10.2-mariarocks-pre/include/hash.h 2017-01-18 10:11:20.268169303 +0300
+++ 10.2-mariarocks-noc/include/hash.h 2017-01-01 13:55:25.176076681 +0300
@@ -74,6 +74,7 @@ my_bool my_hash_init2(HASH *hash, uint g
void my_hash_free(HASH *tree);
void my_hash_reset(HASH *hash);
uchar *my_hash_element(HASH *hash, ulong idx);
+const uchar *my_hash_const_element(const HASH *hash, ulong idx);
uchar *my_hash_search(const HASH *info, const uchar *key, size_t length);
uchar *my_hash_search_using_hash_value(const HASH *info,
my_hash_value_type hash_value,
diff '--exclude=.*' -urpN 10.2-mariarocks-pre/mysql-test/include/restart_mysqld_with_option.inc 10.2-mariarocks-noc/mysql-test/include/restart_mysqld_with_option.inc
--- 10.2-mariarocks-pre/mysql-test/include/restart_mysqld_with_option.inc 1970-01-01 03:00:00.000000000 +0300
+++ 10.2-mariarocks-noc/mysql-test/include/restart_mysqld_with_option.inc 2017-01-01 13:55:25.176076681 +0300
@@ -0,0 +1,31 @@
+
+if ($rpl_inited)
+{
+ if (!$allow_rpl_inited)
+ {
+ --die ERROR IN TEST: This script does not support replication
+ }
+}
+
+# Write file to make mysql-test-run.pl expect the "crash", but don't start
+# it until it's told to
+--let $_server_id= `SELECT @@server_id`
+--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.expect
+--exec echo "wait" > $_expect_file_name
+
+# Send shutdown to the connected server and give
+# it 10 seconds to die before zapping it
+shutdown_server 10;
+
+# Write file to make mysql-test-run.pl start up the server again
+--exec echo "restart:$_mysqld_option" > $_expect_file_name
+
+# Turn on reconnect
+--enable_reconnect
+
+# Call script that will poll the server waiting for it to be back online again
+--source include/wait_until_connected_again.inc
+
+# Turn off reconnect again
+--disable_reconnect
+
diff '--exclude=.*' -urpN 10.2-mariarocks-pre/mysql-test/r/ctype_collate.result 10.2-mariarocks-noc/mysql-test/r/ctype_collate.result
--- 10.2-mariarocks-pre/mysql-test/r/ctype_collate.result 2017-01-18 10:11:20.268169303 +0300
+++ 10.2-mariarocks-noc/mysql-test/r/ctype_collate.result 2017-01-18 10:07:28.509547380 +0300
@@ -719,3 +719,38 @@ DROP FUNCTION getText;
DROP DATABASE test1;
USE test;
SET NAMES latin1;
+#
+# MDEV-11320, MySQL BUG#81810: Inconsistent sort order for blob/text between InnoDB and filesort
+#
+CREATE TABLE t1 (
+b LONGTEXT CHARACTER SET "latin1" COLLATE "latin1_bin",
+KEY b (b(32))
+);
+INSERT INTO t1 (b) VALUES ('a'), (_binary 0x1), (_binary 0x0), ('');
+drop table t1;
+CREATE TABLE t1 (
+b LONGTEXT CHARACTER SET "latin1" COLLATE "latin1_bin",
+PRIMARY KEY b (b(32))
+);
+INSERT INTO t1 (b) VALUES ('a'), (_binary 0x1), (_binary 0x0), ('');
+explain
+select hex(b) from t1 force index (PRIMARY) where b<'zzz';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range PRIMARY PRIMARY 34 NULL 4 Using where
+select hex(b) from t1 force index (PRIMARY) where b<'zzz';
+hex(b)
+00
+01
+
+61
+explain
+select hex(b) from t1 where b<'zzz' order by b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 4 Using where; Using filesort
+select hex(b) from t1 where b<'zzz' order by b;
+hex(b)
+00
+01
+
+61
+drop table t1;
diff '--exclude=.*' -urpN 10.2-mariarocks-pre/mysql-test/r/myisam.result 10.2-mariarocks-noc/mysql-test/r/myisam.result
--- 10.2-mariarocks-pre/mysql-test/r/myisam.result 2017-01-18 10:11:20.272169278 +0300
+++ 10.2-mariarocks-noc/mysql-test/r/myisam.result 2017-01-18 10:07:28.541547192 +0300
@@ -1108,8 +1108,8 @@ length(c1) c1
0
SELECT DISTINCT length(c1), c1 FROM t1 ORDER BY c1;
length(c1) c1
-0
2 A
+0
2 B
DROP TABLE t1;
End of 4.1 tests
diff '--exclude=.*' -urpN 10.2-mariarocks-pre/mysql-test/t/ctype_collate.test 10.2-mariarocks-noc/mysql-test/t/ctype_collate.test
--- 10.2-mariarocks-pre/mysql-test/t/ctype_collate.test 2017-01-18 10:11:20.272169278 +0300
+++ 10.2-mariarocks-noc/mysql-test/t/ctype_collate.test 2017-01-01 13:55:25.192076565 +0300
@@ -308,3 +308,34 @@ DROP FUNCTION getText;
DROP DATABASE test1;
USE test;
SET NAMES latin1;
+
+--echo #
+--echo # MDEV-11320, MySQL BUG#81810: Inconsistent sort order for blob/text between InnoDB and filesort
+--echo #
+
+CREATE TABLE t1 (
+ b LONGTEXT CHARACTER SET "latin1" COLLATE "latin1_bin",
+ KEY b (b(32))
+);
+INSERT INTO t1 (b) VALUES ('a'), (_binary 0x1), (_binary 0x0), ('');
+
+
+drop table t1;
+
+CREATE TABLE t1 (
+ b LONGTEXT CHARACTER SET "latin1" COLLATE "latin1_bin",
+ PRIMARY KEY b (b(32))
+);
+
+INSERT INTO t1 (b) VALUES ('a'), (_binary 0x1), (_binary 0x0), ('');
+
+explain
+select hex(b) from t1 force index (PRIMARY) where b<'zzz';
+select hex(b) from t1 force index (PRIMARY) where b<'zzz';
+
+explain
+select hex(b) from t1 where b<'zzz' order by b;
+select hex(b) from t1 where b<'zzz' order by b;
+
+drop table t1;
+
diff '--exclude=.*' -urpN 10.2-mariarocks-pre/mysys/hash.c 10.2-mariarocks-noc/mysys/hash.c
--- 10.2-mariarocks-pre/mysys/hash.c 2017-01-18 10:11:20.272169278 +0300
+++ 10.2-mariarocks-noc/mysys/hash.c 2017-01-01 13:55:25.192076565 +0300
@@ -721,6 +721,14 @@ uchar *my_hash_element(HASH *hash, ulong
}
+const uchar *my_hash_const_element(const HASH *hash, ulong idx)
+{
+ if (idx < hash->records)
+ return dynamic_element(&hash->array,idx,const HASH_LINK*)->data;
+ return 0;
+}
+
+
/*
Replace old row with new row. This should only be used when key
isn't changed
diff '--exclude=.*' -urpN 10.2-mariarocks-pre/sql/field.cc 10.2-mariarocks-noc/sql/field.cc
--- 10.2-mariarocks-pre/sql/field.cc 2017-01-18 10:11:20.272169278 +0300
+++ 10.2-mariarocks-noc/sql/field.cc 2017-01-27 23:49:47.322856819 +0300
@@ -8254,7 +8254,7 @@ void Field_blob::sort_string(uchar *to,u
uchar *blob;
uint blob_length=get_length();
- if (!blob_length)
+ if (!blob_length && field_charset->pad_char == 0)
bzero(to,length);
else
{
@@ -10585,7 +10585,7 @@ Column_definition::Column_definition(THD
length
*/
-uint32 Field_blob::char_length()
+uint32 Field_blob::char_length() const
{
switch (packlength)
{
diff '--exclude=.*' -urpN 10.2-mariarocks-pre/sql/field.h 10.2-mariarocks-noc/sql/field.h
--- 10.2-mariarocks-pre/sql/field.h 2017-01-18 10:11:20.272169278 +0300
+++ 10.2-mariarocks-noc/sql/field.h 2017-01-18 10:07:28.753545945 +0300
@@ -1355,7 +1355,7 @@ public:
longlong convert_decimal2longlong(const my_decimal *val, bool unsigned_flag,
int *err);
/* The max. number of characters */
- virtual uint32 char_length()
+ virtual uint32 char_length() const
{
return field_length / charset()->mbmaxlen;
}
@@ -3303,7 +3303,7 @@ public:
memcpy(ptr,length,packlength);
memcpy(ptr+packlength, &data,sizeof(char*));
}
- void set_ptr_offset(my_ptrdiff_t ptr_diff, uint32 length, uchar *data)
+ void set_ptr_offset(my_ptrdiff_t ptr_diff, uint32 length, const uchar *data)
{
uchar *ptr_ofs= ADD_TO_PTR(ptr,ptr_diff,uchar*);
store_length(ptr_ofs, packlength, length);
@@ -3346,7 +3346,7 @@ public:
bool has_charset(void) const
{ return charset() == &my_charset_bin ? FALSE : TRUE; }
uint32 max_display_length();
- uint32 char_length();
+ uint32 char_length() const;
uint is_equal(Create_field *new_field);
private:
int do_save_field_metadata(uchar *first_byte);
diff '--exclude=.*' -urpN 10.2-mariarocks-pre/sql/handler.cc 10.2-mariarocks-noc/sql/handler.cc
--- 10.2-mariarocks-pre/sql/handler.cc 2017-01-18 10:11:20.276169255 +0300
+++ 10.2-mariarocks-noc/sql/handler.cc 2017-01-18 10:07:28.753545945 +0300
@@ -2728,6 +2728,14 @@ int handler::ha_index_first(uchar * buf)
return result;
}
+bool handler::is_using_full_key(key_part_map keypart_map,
+ uint actual_key_parts)
+{
+ return (keypart_map == HA_WHOLE_KEY) ||
+ (keypart_map == ((key_part_map(1) << actual_key_parts)
+ - 1));
+}
+
int handler::ha_index_last(uchar * buf)
{
int result;
@@ -5428,7 +5436,7 @@ int handler::compare_key(key_range *rang
This is used by index condition pushdown implementation.
*/
-int handler::compare_key2(key_range *range)
+int handler::compare_key2(key_range *range) const
{
int cmp;
if (!range)
diff '--exclude=.*' -urpN 10.2-mariarocks-pre/sql/handler.h 10.2-mariarocks-noc/sql/handler.h
--- 10.2-mariarocks-pre/sql/handler.h 2017-01-18 10:11:20.276169255 +0300
+++ 10.2-mariarocks-noc/sql/handler.h 2017-01-21 23:00:28.168189748 +0300
@@ -434,7 +434,8 @@ enum legacy_db_type
DB_TYPE_PERFORMANCE_SCHEMA=28,
DB_TYPE_ARIA=42,
DB_TYPE_TOKUDB=43,
- DB_TYPE_FIRST_DYNAMIC=44,
+ DB_TYPE_ROCKSDB=44,
+ DB_TYPE_FIRST_DYNAMIC=45,
DB_TYPE_DEFAULT=127 // Must be last
};
/*
@@ -3177,13 +3178,14 @@ public:
size_t size)
{ return 0; }
+ bool is_using_full_key(key_part_map keypart_map, uint actual_key_parts);
virtual int read_range_first(const key_range *start_key,
const key_range *end_key,
bool eq_range, bool sorted);
virtual int read_range_next();
void set_end_range(const key_range *end_key);
int compare_key(key_range *range);
- int compare_key2(key_range *range);
+ int compare_key2(key_range *range) const;
virtual int ft_init() { return HA_ERR_WRONG_COMMAND; }
void ft_end() { ft_handler=NULL; }
virtual FT_INFO *ft_init_ext(uint flags, uint inx,String *key)
@@ -3933,10 +3935,16 @@ private:
void mark_trx_read_write_internal();
bool check_table_binlog_row_based_internal(bool binlog_row);
- /* Private helpers */
+protected:
+ /*
+ These are intended to be used only by handler::ha_xxxx() functions
+ However, engines that implement read_range_XXX() (like MariaRocks)
+ or embed other engines (like ha_partition) may need to call these also
+ */
inline void increment_statistics(ulong SSV::*offset) const;
inline void decrement_statistics(ulong SSV::*offset) const;
+private:
/*
Low-level primitives for storage engines. These should be
overridden by the storage engine class. To call these methods, use
diff '--exclude=.*' -urpN 10.2-mariarocks-pre/sql/key.cc 10.2-mariarocks-noc/sql/key.cc
--- 10.2-mariarocks-pre/sql/key.cc 2017-01-18 10:11:20.276169255 +0300
+++ 10.2-mariarocks-noc/sql/key.cc 2017-01-01 13:55:25.204076478 +0300
@@ -176,7 +176,7 @@ void key_copy(uchar *to_key, uchar *from
@param key_length specifies length of all keyparts that will be restored
*/
-void key_restore(uchar *to_record, uchar *from_key, KEY *key_info,
+void key_restore(uchar *to_record, const uchar *from_key, KEY *key_info,
uint key_length)
{
uint length;
diff '--exclude=.*' -urpN 10.2-mariarocks-pre/sql/key.h 10.2-mariarocks-noc/sql/key.h
--- 10.2-mariarocks-pre/sql/key.h 2017-01-18 10:11:20.276169255 +0300
+++ 10.2-mariarocks-noc/sql/key.h 2017-01-01 13:55:25.204076478 +0300
@@ -29,7 +29,7 @@ int find_ref_key(KEY *key, uint key_coun
uint *key_length, uint *keypart);
void key_copy(uchar *to_key, uchar *from_record, KEY *key_info, uint key_length,
bool with_zerofill= FALSE);
-void key_restore(uchar *to_record, uchar *from_key, KEY *key_info,
+void key_restore(uchar *to_record, const uchar *from_key, KEY *key_info,
uint key_length);
bool key_cmp_if_same(TABLE *form,const uchar *key,uint index,uint key_length);
void key_unpack(String *to, TABLE *table, KEY *key);
diff '--exclude=.*' -urpN 10.2-mariarocks-pre/sql/sql_parse.cc 10.2-mariarocks-noc/sql/sql_parse.cc
--- 10.2-mariarocks-pre/sql/sql_parse.cc 2017-01-18 10:11:20.276169255 +0300
+++ 10.2-mariarocks-noc/sql/sql_parse.cc 2017-01-18 10:07:28.793545709 +0300
@@ -5477,7 +5477,9 @@ end_with_restore_list:
(longlong) thd->thread_id);
goto error;
}
- my_ok(thd);
+ /* MyRocks: hton->start_consistent_snapshot call may fail with an error */
+ if (!thd->is_error())
+ my_ok(thd);
break;
case SQLCOM_COMMIT:
{
diff '--exclude=.*' -urpN 10.2-mariarocks-pre/sql/sql_select.cc 10.2-mariarocks-noc/sql/sql_select.cc
--- 10.2-mariarocks-pre/sql/sql_select.cc 2017-01-18 10:11:20.280169232 +0300
+++ 10.2-mariarocks-noc/sql/sql_select.cc 2017-01-18 10:07:28.797545685 +0300
@@ -20566,7 +20566,7 @@ static int test_if_order_by_key(JOIN *jo
key_parts= (uint) (key_part - table->key_info[idx].key_part);
if (reverse == -1 &&
- !(table->file->index_flags(idx, user_defined_kp, 1) & HA_READ_PREV))
+ !(table->file->index_flags(idx, user_defined_kp-1, 1) & HA_READ_PREV))
reverse= 0; // Index can't be used
if (have_pk_suffix && reverse == -1)
diff '--exclude=.*' -urpN 10.2-mariarocks-pre/sql/sql_show.cc 10.2-mariarocks-noc/sql/sql_show.cc
--- 10.2-mariarocks-pre/sql/sql_show.cc 2017-01-18 10:11:20.284169207 +0300
+++ 10.2-mariarocks-noc/sql/sql_show.cc 2017-01-18 10:07:28.801545663 +0300
@@ -3386,7 +3386,7 @@ static bool show_status_array(THD *thd,
for (; variables->name; variables++)
{
- bool wild_checked;
+ bool wild_checked= false;
strnmov(prefix_end, variables->name, len);
name_buffer[sizeof(name_buffer)-1]=0; /* Safety */
@@ -3452,8 +3452,8 @@ static bool show_status_array(THD *thd,
else
{
if ((wild_checked ||
- (wild && wild[0] && wild_case_compare(system_charset_info,
- name_buffer, wild))) &&
+ !(wild && wild[0] && wild_case_compare(system_charset_info,
+ name_buffer, wild))) &&
(!cond || cond->val_int()))
{
const char *pos; // We assign a lot of const's
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment