Marco Gergele | 5 May 2013 22:06
Picon

Patch for mysqldump

Hi,

mysqldump can sort by primary key, but only ascending.

mysqldump can not limit the number of rows.

I have added two options: 

--order-by-primary-desc 
                      Sorts descending each table's rows by primary key, or
                      first unique key, if such a key exists.  Useful when
                      dumping a MyISAM table to be loaded into an InnoDB table,
                      but will make the dump itself take considerably longer.

--limit[=name]      (numeric!) Number of rows of each table to dump, 0=all
                     rows

I do need the number for "limit" as a string, so I try to avoid converting it into numbers and back into string.

Greets - Marco Gergele

=== modified file 'client/client_priv.h'
--- client/client_priv.h	2013-02-26 05:35:17 +0000
+++ client/client_priv.h	2013-05-05 17:10:48 +0000
 <at>  <at>  -13,6 +13,9  <at>  <at> 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+
+   Patched for mysqldump-options limit and OPT_ORDER_BY_PRIMARY_DESC.
+
 */

 /* Common defines for all clients */
 <at>  <at>  -88,7 +91,9  <at>  <at> 
   OPT_DEFAULT_AUTH,
   OPT_DEFAULT_PLUGIN,
   OPT_ENABLE_CLEARTEXT_PLUGIN,
-  OPT_MAX_CLIENT_OPTION
+  OPT_MAX_CLIENT_OPTION,
+  OPT_ORDER_BY_PRIMARY_DESC, 
+  OPT_DUMP_LIMIT
 };

 /**

=== modified file 'client/mysqldump.c'
--- client/mysqldump.c	2013-02-26 05:35:17 +0000
+++ client/mysqldump.c	2013-05-05 19:10:06 +0000
 <at>  <at>  -36,6 +36,9  <at>  <at> 
 ** and adapted to mysqldump 05/11/01 by Jani Tolonen
 ** Added --single-transaction option 06/06/2002 by Peter Zaitsev
 ** 10 Jun 2003: SET NAMES and --no-set-names by Alexander Barkov
+
+
+** 05 May 2013: Patched for limit and OPT_ORDER_BY_PRIMARY_DESC by Marco Gergele
 */

 #define DUMP_VERSION "10.13"
 <at>  <at>  -109,7 +112,7  <at>  <at> 
                 opt_autocommit=0,opt_disable_keys=1,opt_xml=0,
                 opt_delete_master_logs=0, tty_password=0,
                 opt_single_transaction=0, opt_comments= 0, opt_compact= 0,
-                opt_hex_blob=0, opt_order_by_primary=0, opt_ignore=0,
+                opt_hex_blob=0, opt_order_by_primary=0, opt_order_by_primary_desc=0, opt_ignore=0,
                 opt_complete_insert= 0, opt_drop_database= 0,
                 opt_replace_into= 0,
                 opt_dump_triggers= 0, opt_routines=0, opt_tz_utc=1,
 <at>  <at>  -127,7 +130,8  <at>  <at> 
              *where=0, *order_by=0,
              *opt_compatible_mode_str= 0,
              *err_ptr= 0,
-             *log_error_file= NULL;
+             *log_error_file= NULL,
+             *opt_dump_limit=0;
 static char **defaults_argv= 0;
 static char compatible_mode_normal_str[255];
 /* Server supports character_set_results session variable? */
 <at>  <at>  -423,6 +427,9  <at>  <at> 
   {"order-by-primary", OPT_ORDER_BY_PRIMARY,
    "Sorts each table's rows by primary key, or first unique key, if such a key exists.  Useful when dumping a
MyISAM table to be loaded into an InnoDB table, but will make the dump itself take considerably longer.",
    &opt_order_by_primary, &opt_order_by_primary, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+  {"order-by-primary-desc", OPT_ORDER_BY_PRIMARY_DESC,
+   "Sorts descending each table's rows by primary key, or first unique key, if such a key exists.  Useful when
dumping a MyISAM table to be loaded into an InnoDB table, but will make the dump itself take considerably longer.",
+   &opt_order_by_primary_desc, &opt_order_by_primary_desc, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"password", 'p',
    "Password to use when connecting to server. If password is not given it's solicited on the tty.",
    0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
 <at>  <at>  -521,6 +528,11  <at>  <at> 
    "Default authentication client-side plugin to use.",
    &opt_default_auth, &opt_default_auth, 0,
    GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+  {"limit", OPT_DUMP_LIMIT, 
+   "(numeric!) Number of rows of each table to dump, 0=all rows",
+    &opt_dump_limit, &opt_dump_limit, 0,
+    GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
+
   {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
 };

 <at>  <at>  -2489,7 +2501,7  <at>  <at> 
   result_table=     quote_name(table, table_buff, 1);
   opt_quoted_table= quote_name(table, table_buff2, 0);

-  if (opt_order_by_primary)
+  if (opt_order_by_primary || opt_order_by_primary_desc)
     order_by= primary_key_fields(result_table);

   if (!opt_xml && !mysql_query_with_error_report(mysql, 0, query_buff))
 <at>  <at>  -3457,6 +3469,14  <at>  <at> 
     {
       dynstr_append_checked(&query_string, " ORDER BY ");
       dynstr_append_checked(&query_string, order_by);
+      if(opt_order_by_primary_desc){
+          dynstr_append_checked(&query_string, " DESC ");
+      }
+    }
+
+    if(opt_dump_limit){
+        dynstr_append_checked(&query_string, " LIMIT ");
+        dynstr_append_checked(&query_string, opt_dump_limit);
     }

     if (mysql_real_query(mysql, query_string.str, query_string.length))
 <at>  <at>  -3484,10 +3504,22  <at>  <at> 
     }
     if (order_by)
     {
-      print_comment(md_result_file, 0, "-- ORDER BY:  %s\n", order_by);

       dynstr_append_checked(&query_string, " ORDER BY ");
       dynstr_append_checked(&query_string, order_by);
+
+      if(opt_order_by_primary_desc){
+          print_comment(md_result_file, 0, "-- ORDER BY:  %s DESC \n", order_by);
+          dynstr_append_checked(&query_string, " DESC ");
+      }
+      else{
+          print_comment(md_result_file, 0, "-- ORDER BY:  %s\n", order_by);
+      }
+    }
+
+    if(opt_dump_limit){
+        dynstr_append_checked(&query_string, " LIMIT ");
+        dynstr_append_checked(&query_string, opt_dump_limit);
     }

     if (!opt_xml && !opt_compact)


--

-- 
MySQL Internals Mailing List
For list archives: http://lists.mysql.com/internals
To unsubscribe:    http://lists.mysql.com/internals
Zardosht Kasheff | 5 May 2013 17:53
Picon

outputting varchars to a file to be read by load data infile

Hello all,

I have an interesting problem. I am in the process of trying to
manually recover data from a corrupted dictionary. The table has
DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci, and there are four
columns:
  `a` varchar(100) CHARACTER SET utf8 NOT NULL,
  `b` varchar(10) COLLATE latin1_general_ci DEFAULT NULL,
  `c` varchar(20) COLLATE latin1_general_ci DEFAULT NULL,
  `d` varchar(20) COLLATE latin1_general_ci NOT NULL DEFAULT '',

The data in the corrupted dictionary is identical to what we would
find in table->record[0] as accessed by storage engine's handler. It
contains the length of each string and the bytes.

What I want to do is make a little program that will read this data
from the corrupted dictionary, and write it to a file in such a format
such that I can use "load data infile" to interpret it correctly and
reload the data.

If I just copy the bytes directly to the file, will load data infile
be able to interpret the data? Is there anything else that needs to be
done (such as put in a \0 or something?)

Thanks
-Zardosht

--

-- 
MySQL Internals Mailing List
For list archives: http://lists.mysql.com/internals
To unsubscribe:    http://lists.mysql.com/internals

AugustQ | 23 Apr 2013 15:14
Picon

adding an index of my own type/code

Hi,

I'm using the source-code of MySQL-version 5.5.8

I want to implement my own type of an index and play with it. How can I
do this?

It's easy to add a storage engine. For creating the index on a table I
use a statement like:
    create index PRIMA3 
    on ABDAOK(Id, PZN, ArtikelBez) 
    type  AQTREE;

I go a syntax-error: ERROR 1064 (42000)

What do I have to do to implement my own index-code? 
Is there a newer version that supports this better?

Thanks
AugustQ

--

-- 
MySQL Internals Mailing List
For list archives: http://lists.mysql.com/internals
To unsubscribe:    http://lists.mysql.com/internals

frederic nivor | 10 Mar 2013 08:15
Picon

after cross compile, mysql table hidden while operation on it still work

Hi,
I'm trying to cross compile mysql server. Most of it work, but when I access the database via root <at> localhost
account (show databases;), I've got :
Database
information_schema
Applications
Developer
Library
System
bin
cores
etc
private
sbin
usr
var

Which seems to be my / directory.
When I try :
use mysql;
of course, the mysql database is unknown for him, but when I try :
select * from mysql.user;
I've got the right result.
So I thought the root user didn't have the right privileges, but when I check :
show grants for 'root' <at> 'localhost';
I've got :
GRANT ALL PRIVILEGES ON *.* TO 'root' <at> 'localhost' WITH GRANT OPTION
GRANT PROXY ON '' <at> '' TO 'root' <at> 'localhost' WITH GRANT OPTION
Then I thought my datadir variable was not well configured, but when I try :
show variables;
I've got :
datadir /var/mobile/mysql/Library/data/
which is the right path, where mysql and performance_schema folder databases are stored.
Any idea ?
B.R.
--

-- 
MySQL Internals Mailing List
For list archives: http://lists.mysql.com/internals
To unsubscribe:    http://lists.mysql.com/internals

Kuts Alexey | 4 Mar 2013 22:59
Picon
Favicon

inconsistency in source-code/comments in mf_keycache

Hi,

I am just learning the inner working of myisam key cache
and found some inconsistency in mf_keycache.c

here is this place and my suggested patch:
--- mysys/mf_keycache.c	2011-09-07 10:08:09 +0000
+++ mysys/mf_keycache.c	2013-03-06 07:53:02 +0000
 <at>  <at>  -3404,7 +3404,7  <at>  <at> 
     return;

   /* Error blocks are not put into the LRU ring. */
-  if (!(block->status & BLOCK_ERROR))
+  if (block->status & BLOCK_ERROR)
   {
     /* Here the block must be in the LRU ring. Unlink it again. */
     DBUG_ASSERT(block->next_used && block->prev_used &&

I don't know, is there really a bug, that erroneous blocks are remained in LRU-ring.

Regards,
Alexey

--

-- 
MySQL Internals Mailing List
For list archives: http://lists.mysql.com/internals
To unsubscribe:    http://lists.mysql.com/internals

Zardosht Kasheff | 28 Feb 2013 03:08
Picon

effects of load data local on RSS

Hello all,

We have noticed something peculiar to our storage engine, but could
not reproduce with InnoDB. We notice when a user runs load data local
infile, that a lot of memory that we cannot account for gets used by
the system, sometimes leading the system to crash from being low on
memory. However, when running load data infile ignore, we see no such
issues.

As far as I can tell, the settings for the handler are the same for
load data local infile and load data infile ignore. Both load many
rows within the context of a single statement, and both set the flag
HA_EXTRA_IGNORE_DUP_KEY in handler::extra. Otherwise, as far as the
handler is concerned, these two look identical. Yet one utilizes much
more RSS than the other, and we do not see this behavior with InnoDB.

Does anyone have any thoughts on what may be happening?

Thanks
-Zardosht

--

-- 
MySQL Internals Mailing List
For list archives: http://lists.mysql.com/internals
To unsubscribe:    http://lists.mysql.com/internals

Zardosht Kasheff | 26 Feb 2013 22:47
Picon

properly detecting cases where handler can silently overwrite rows

Hello all,

For a bunch of statements, "replace into", "replace into ... select",
"load data... replace", we sometimes do not follow the protocol of
return an error if we see a duplicate key so that a subsequent update
can overwrite the row. Instead, we have handler::write_row silently
overwrite the data and report success.

The trouble we have is properly detecting when we are indeed allowed
to silently overwrite the row. What we have been doing is checking
(thd->lex->duplicates == DUP_REPLACE).

We recently found what seems like a corner case where this does not
work. During replication on a slave, if slave_exec_mode is set to
IDEMPOTENT, then thd->lex->duplicates is set to DUP_REPLACE, but the
operation is not just a silent overwrite. The operation works like an
insert on duplicate key update, where the updated row is dependent on
the existing row and the inserted row.

My questions:
 - why is DUP_REPLACE being set in this case in replication?
 - What is the proper way to determine when we can safely silently
overwrite an existing row. We already check for having a binary log in
row format and for triggers. It seems checking thd->lex->DUP_REPLACE
is not sufficient.

Thanks
-Zardosht

--

-- 
MySQL Internals Mailing List
For list archives: http://lists.mysql.com/internals
To unsubscribe:    http://lists.mysql.com/internals

Sergei Golubchik | 25 Feb 2013 12:58
Favicon

Re: [Maria-developers] Fwd: some question on bundled libedit in mysql

Hi, AL13N!

On Feb 25, AL13N wrote:
> >
> > In MariaDB we prefer to link with readline. We never link with bundled
> > libedit at all. Either with system readline, if it's usable, or with
> > system libedit, or with bundled readline.
> 
> iinm, MariaDB is GPLv2 and libreadline (version 6) is GPLv3, so they don't
> mix. but bundled libreadline (version 5) is GPLv2 and that one is
> possible.

That's why I said "with system readline, if it's usable".
We only link with system readline if it's V5 or earlier.

Regards,
Sergei

--

-- 
MySQL Internals Mailing List
For list archives: http://lists.mysql.com/internals
To unsubscribe:    http://lists.mysql.com/internals

xiaobing jiang | 25 Feb 2013 10:55
Picon

Fwd: some question on bundled libedit in mysql

hi all:
    No reply from jonathan.perkin, so post to the maillist.

can some one explain to me?

Thanks!

---------- Forwarded message ----------
From: xiaobing jiang <s7v7nislands <at> gmail.com>
Date: Fri, Feb 22, 2013 at 3:52 PM
Subject: some question on bundled libedit in mysql
To: jonathan.perkin <at> oracle.com

hi jonathan:
  after read the README in source, I have some question about libedit.
  in recently, we find a bug. when using bundled libedit, we can't
input the chinese using GBK. after debug, I find this code may be
cause the bug.

protected int
terminal__putc(EditLine *el, Int c)
{
    char buf[MB_LEN_MAX +1];
    ssize_t i;
    mbstate_t state;

    memset(&state, 0, sizeof(mbstate_t));
    if (c == (Int)MB_FILL_CHAR)
        return 0;
    i = ct_encode_char(buf, (size_t)MB_CUR_MAX, c, &state);  // this
should be:   ct_encode_char(buf, (size_t)MB_LEN_MAX, c, &state);
    if (i <= 0)
        return (int)i;
    buf[i] = '\0';
    return fputs(buf, el->el_outfile);
}

after change the code, I can fix the bug. and I find upstream also
using MB_LEN_MAX.

http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libedit/terminal.c

protected int
terminal__putc(EditLine *el, Int c)
{
        char buf[MB_LEN_MAX +1];
        ssize_t i;
        if (c == (Int)MB_FILL_CHAR)
                return 0;
        i = ct_encode_char(buf, (size_t)MB_LEN_MAX, c);
        if (i <= 0)
                return (int)i;
        buf[i] = '\0';
        return fputs(buf, el->el_outfile);
}

so the merge from upstream may be wrong.

And this bug may be the same
http://bugs.mysql.com/bug.php?id=23097

and why mysql5.6 remove the bundled readline? I think readline is used
more than libedit.
and when using system readline, why perfer libedit to readline ? look
at cmake/readline.cmake. FIND_SYSTEM_LIBEDIT(edit) ->
FIND_SYSTEM_LIBEDIT(readline)

thanks!
xiaobing jiang

--

-- 
MySQL Internals Mailing List
For list archives: http://lists.mysql.com/internals
To unsubscribe:    http://lists.mysql.com/internals

Zardosht Kasheff | 21 Feb 2013 05:20
Picon

Are handlerton->commit calls serialized in MySQL 5.6?

Hello all,

In http://lists.mysql.com/internals/38715, I learned quite a bit about
MySQL 5.6 replication, but also saw something interesting that I would
like to learn more about.

As covered in that thread, handlerton->commit calls made with
thd->durability_properties set to HA_IGNORE_DURABILITY means the
enginecan ignore the durability requirements of commits.

However, I also saw that such calls are serialized under some global
mutex. Is this accurate? Is this mutex a MySQL mutex or an InnoDB
mutex? If so, how is concurrency affected? Is this any different than
how MySQL 5.5 behaves?

Thanks
-Zardosht

--

-- 
MySQL Internals Mailing List
For list archives: http://lists.mysql.com/internals
To unsubscribe:    http://lists.mysql.com/internals

AugustQ | 15 Feb 2013 15:20
Picon

API version for STORAGE ENGINE plugin is too different

Hello to everyone.

I got this error-message yesterday and I don't know what's wrong here on
my machine. So let me describe the situation:

I'm using MySql 5.5.8, sources.

on a command-line I cd to the source-directory and enter: make clean

After this I do a: make install

when this finished without any error I cd to this
directory: /usr/local/mysql
and start the server:  bin/mysqld_safe --user=mysql &
then I connect to it: bin/mysql
now I enter: mysql> INSTALL PLUGIN dbf SONAME 'ha_dbf.so';
and the response is this:
ERROR 1126 (HY000): Can't open shared library 'ha_dbf.so' (errno: 0 API
version for STORAGE ENGINE plugin is too different)

OK, it was a fresh compile so everything should be fine. Here are some
details:
in /usr/local/mysql/bin:
-rwxr-xr-x 1 root root  55764444 Feb 15 11:08 mysqld

in /usr/local/mysql/lib/plugin:
-rw-r--r-- 1 root root  283275 Feb 15 11:01 ha_dbf.so

it looks like everything is indeed freshly compiled so the API should be
OK, otherwise I expect an error-message during compile or linking.

What's going on here? What ma I doing wrong?

Thanks 
AugustQ

PS: ha_dbf is a class I created by myself. Everything else seems to
work.

--

-- 
MySQL Internals Mailing List
For list archives: http://lists.mysql.com/internals
To unsubscribe:    http://lists.mysql.com/internals


Gmane