Re: [Maria-developers] A mess with sql_alloc() ?

2009-10-09 Thread Kristian Nielsen
Alexi1952  writes:

> Thanks for your comments!
>
>> In any case extern declarations like this should be avoided, much better to
>> only have the declaration in one place in some *.h file.
>
> I agree. Currently, we have:
>
> mysql_priv.h:
>
> #ifndef MYSQL_CLIENT
> ...
> void *sql_alloc(size_t);
> ...
> #endif
>
> thr_malloc.cc:
>
> void *sql_alloc(size_t Size)
> {
>   MEM_ROOT *root= *my_pthread_getspecific_ptr(MEM_ROOT**,THR_MALLOC);
>   return alloc_root(root,Size);
> }
>
> This states that sql_alloc() *should not* be used in MYSQL_CLIENT context
> (hence all these extern declarations). In my opinion, it's more correctly to 
> have:
>
> mysql_priv.h:
>
> void *sql_alloc(size_t);
>
> thr_malloc.cc:
>
> #ifndef MYSQL_CLIENT
> void *sql_alloc(size_t Size)
> {
>   MEM_ROOT *root= *my_pthread_getspecific_ptr(MEM_ROOT**,THR_MALLOC);
>   return alloc_root(root,Size);
> }
> #endif
>
> which states instead that sql_alloc() *can be* used in a client context
> but should be supplied with *another definition*.

Yes, agree.

> Question: May I do these changes in mysql_priv.h and thr_malloc.cc ?
> On the one hand, it is resonable. On the other hand, I am confused a bit
> with "mysql_priv.h" name intended to mean that content of this file belongs
> to mysql internals (though this file is included in mysqlbinlog.cc)

I think this is ok to do (I will check them again when I see the patch for
review).

It is true about mysql_priv.h being more internal, but then mysqlbinlog
already goes deep deep into internals (the replication event stuff).

 - Kristian.

___
Mailing list: https://launchpad.net/~maria-developers
Post to : maria-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~maria-developers
More help   : https://help.launchpad.net/ListHelp


[Maria-developers] bzr commit into MariaDB 5.1, with Maria 1.5:maria branch (knielsen:2775)

2009-10-09 Thread knielsen
#At lp:maria

 2775 kniel...@knielsen-hq.org  2009-10-09
  Fix many test failures in parts test suite with --embedded-server.
  
  Fix some connect options to work with embedded.
  
  Disable in --embedded tests that rely on connecting to mysqld externally 
by
  spawning mysqltest.
  
  Disable in --embedded tests that rely on the mysqltest --list_files 
command,
  which does not seem to work properly in --embedded.
  modified:
mysql-test/suite/parts/t/partition_alter1_1_2_innodb.test
mysql-test/suite/parts/t/partition_alter1_1_2_myisam.test
mysql-test/suite/parts/t/partition_alter1_1_innodb.test
mysql-test/suite/parts/t/partition_alter1_1_myisam.test
mysql-test/suite/parts/t/partition_alter1_2_innodb.test
mysql-test/suite/parts/t/partition_alter1_2_myisam.test
mysql-test/suite/parts/t/partition_alter2_1_innodb.test
mysql-test/suite/parts/t/partition_alter2_1_maria.test
mysql-test/suite/parts/t/partition_alter2_1_myisam.test
mysql-test/suite/parts/t/partition_alter2_2_innodb.test
mysql-test/suite/parts/t/partition_alter2_2_maria.test
mysql-test/suite/parts/t/partition_alter2_2_myisam.test
mysql-test/suite/parts/t/partition_alter3_innodb.test
mysql-test/suite/parts/t/partition_alter3_myisam.test
mysql-test/suite/parts/t/partition_alter4_innodb.test
mysql-test/suite/parts/t/partition_alter4_myisam.test
mysql-test/suite/parts/t/partition_basic_innodb.test
mysql-test/suite/parts/t/partition_basic_myisam.test
mysql-test/suite/parts/t/partition_basic_symlink_myisam.test
mysql-test/suite/parts/t/partition_engine_innodb.test
mysql-test/suite/parts/t/partition_engine_myisam.test
mysql-test/suite/parts/t/partition_special_innodb.test
mysql-test/suite/parts/t/partition_syntax_innodb.test
mysql-test/suite/parts/t/partition_syntax_myisam.test

per-file messages:
  mysql-test/suite/parts/t/partition_alter1_1_2_innodb.test
Disable in --embedded tests that rely on connecting to mysqld externally by
spawning mysqltest.
  mysql-test/suite/parts/t/partition_alter1_1_2_myisam.test
Disable in --embedded tests that rely on connecting to mysqld externally by
spawning mysqltest.
  mysql-test/suite/parts/t/partition_alter1_1_innodb.test
Disable in --embedded tests that rely on connecting to mysqld externally by
spawning mysqltest.
  mysql-test/suite/parts/t/partition_alter1_1_myisam.test
Disable in --embedded tests that rely on connecting to mysqld externally by
spawning mysqltest.
  mysql-test/suite/parts/t/partition_alter1_2_innodb.test
Disable in --embedded tests that rely on connecting to mysqld externally by
spawning mysqltest.
  mysql-test/suite/parts/t/partition_alter1_2_myisam.test
Disable in --embedded tests that rely on connecting to mysqld externally by
spawning mysqltest.
  mysql-test/suite/parts/t/partition_alter2_1_innodb.test
Disable in --embedded tests that rely on connecting to mysqld externally by
spawning mysqltest.
  mysql-test/suite/parts/t/partition_alter2_1_maria.test
Disable in --embedded tests that rely on connecting to mysqld externally by
spawning mysqltest.
  mysql-test/suite/parts/t/partition_alter2_1_myisam.test
Disable in --embedded tests that rely on connecting to mysqld externally by
spawning mysqltest.
  mysql-test/suite/parts/t/partition_alter2_2_innodb.test
Disable in --embedded tests that rely on connecting to mysqld externally by
spawning mysqltest.
  mysql-test/suite/parts/t/partition_alter2_2_maria.test
Disable in --embedded tests that rely on connecting to mysqld externally by
spawning mysqltest.
  mysql-test/suite/parts/t/partition_alter2_2_myisam.test
Disable in --embedded tests that rely on connecting to mysqld externally by
spawning mysqltest.
  mysql-test/suite/parts/t/partition_alter3_innodb.test
Disable in --embedded tests that rely on the mysqltest --list_files command,
which does not seem to work properly in --embedded.
  mysql-test/suite/parts/t/partition_alter3_myisam.test
Disable in --embedded tests that rely on the mysqltest --list_files command,
which does not seem to work properly in --embedded.
  mysql-test/suite/parts/t/partition_alter4_innodb.test
Disable in --embedded tests that rely on connecting to mysqld externally by
spawning mysqltest.
  mysql-test/suite/parts/t/partition_alter4_myisam.test
Disable in --embedded tests that rely on connecting to mysqld externally by
spawning mysqltest.
  mysql-test/suite/parts/t/partition_basic_innodb.test
Disable in --embedded tests that rely on connecting to mysqld externally by
spawning mysqltest.
  mysql-test/suite/parts/t/partition_basic_myisam.test
Disable in --embedded tests that rely on connecting to mysqld externally by
spawning mysqltest.
  mysql-test/suit

Re: [Maria-developers] A mess with sql_alloc() ?

2009-10-09 Thread Alexi1952
Thanks for your comments!

> In any case extern declarations like this should be avoided, much better to
> only have the declaration in one place in some *.h file.

I agree. Currently, we have:

mysql_priv.h:

#ifndef MYSQL_CLIENT
...
void *sql_alloc(size_t);
...
#endif

thr_malloc.cc:

void *sql_alloc(size_t Size)
{
  MEM_ROOT *root= *my_pthread_getspecific_ptr(MEM_ROOT**,THR_MALLOC);
  return alloc_root(root,Size);
}

This states that sql_alloc() *should not* be used in MYSQL_CLIENT context
(hence all these extern declarations). In my opinion, it's more correctly to 
have:

mysql_priv.h:

void *sql_alloc(size_t);

thr_malloc.cc:

#ifndef MYSQL_CLIENT
void *sql_alloc(size_t Size)
{
  MEM_ROOT *root= *my_pthread_getspecific_ptr(MEM_ROOT**,THR_MALLOC);
  return alloc_root(root,Size);
}
#endif

which states instead that sql_alloc() *can be* used in a client context
but should be supplied with *another definition*.

Question: May I do these changes in mysql_priv.h and thr_malloc.cc ?
On the one hand, it is resonable. On the other hand, I am confused a bit
with "mysql_priv.h" name intended to mean that content of this file belongs
to mysql internals (though this file is included in mysqlbinlog.cc)

- Alex

09.10.09, 15:15, "Kristian Nielsen" :

> Alexi1952  writes:
> > mysql_priv.h:
> > (1)void *sql_alloc(size_t);
> > So I redefined sql_alloc() in a client context:
> >
> > void *sql_alloc(size_t size) { ... }
> > ...
> > #include "sql_string.h"
> > #include "sql_list.h"
> (Any reason you put the definition before the #include's ? Usually one writes
> things the other way around)
> > sql/sql_string.cc:
> >
> > (2) extern uchar* sql_alloc(unsigned size);
> > (3) extern void sql_alloc(size_t size);
> > - I found no direct usage of sql_alloc() in sql_string.* files;
> > - After commenting (2) & (3) out the rebuild was successfull.
> > If (2) & (3) shouldn't be deleted, then they should be brought
> Seems like you should just delete them.
> In any case extern declarations like this should be avoided, much better to
> only have the declaration in one place in some *.h file.
> > Looks like along with sql_alloc(), we can delete similar declarations
> > (2a) & (3a) of sql_element_free() (and actually all occurences of this 
> > function):
> > mysql_priv.h
> > (1a)void sql_element_free(void *ptr);
> > thr_malloc.cc
> >
> > void sql_element_free(void *ptr __attribute__((unused)))
> > {} /* purecov: deadcode */
> > sql/sql_string.cc
> >
> > (2a)extern void sql_element_free(void *ptr);
> >
> > client/sql_string.cc
> >
> > (3a)extern void sql_element_free(void *ptr);
> >
> > Indeed, besides pointed above we find only the following
> > occurences of sql_element_free():
> >
> > client/mysql.cc
> >
> >  void* sql_alloc(unsigned size);
> >  void sql_element_free(void *ptr);
> >  ...
> >  void *sql_alloc(size_t Size)
> >  {
> >return my_malloc(Size,MYF(MY_WME));
> >  }
> >  void sql_element_free(void *ptr)
> >  {
> >my_free(ptr,MYF(0));
> >  }
> >
> > So sql_element_free() is called nowhere (note also that this function
> > has a do-nothing body).
> Again I think the extern declarations should be deleted.
> Not sure about the sql_element_free(). My guess would be that they were an
> attempt to be able to use sql_list etc. from outside the server without memory
> leaks, but the attempt was never completed. The issue with sql_alloc() is that
> it uses a mem_root that will automatically free all memory at end of a
> statement (for example). Maybe someone wanted to have explicit calls to
> sql_element_free() (which would work in client but do nothing in server), but
> they stopped half-way?
> We might consider deleting them, on the other hand we should maybe better
> leave them to reduce risk of conflicts when merging with MySQL. I have no
> strong opinion on this one.
>  - Kristian.
> ___
> Mailing list: https://launchpad.net/~maria-developers
> Post to : maria-developers@lists.launchpad.net
> Unsubscribe : https://launchpad.net/~maria-developers
> More help   : https://help.launchpad.net/ListHelp

-- 
Почта в порядке находится здесь: http://mail.yandex.ru/promo/new/order

___
Mailing list: https://launchpad.net/~maria-developers
Post to : maria-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~maria-developers
More help   : https://help.launchpad.net/ListHelp


Re: [Maria-developers] A mess with sql_alloc() ?

2009-10-09 Thread Kristian Nielsen
Alexi1952  writes:

> mysql_priv.h:

> (1)void *sql_alloc(size_t);

> So I redefined sql_alloc() in a client context:
>
> void *sql_alloc(size_t size) { ... }
> ...
> #include "sql_string.h"
> #include "sql_list.h"

(Any reason you put the definition before the #include's ? Usually one writes
things the other way around)

> sql/sql_string.cc:
>
> (2) extern uchar* sql_alloc(unsigned size);

> (3) extern void sql_alloc(size_t size);

> - I found no direct usage of sql_alloc() in sql_string.* files;
> - After commenting (2) & (3) out the rebuild was successfull.
> If (2) & (3) shouldn't be deleted, then they should be brought

Seems like you should just delete them.

In any case extern declarations like this should be avoided, much better to
only have the declaration in one place in some *.h file.

> Looks like along with sql_alloc(), we can delete similar declarations
> (2a) & (3a) of sql_element_free() (and actually all occurences of this 
> function):

> mysql_priv.h

> (1a)void sql_element_free(void *ptr);

> thr_malloc.cc
>
> void sql_element_free(void *ptr __attribute__((unused)))
> {} /* purecov: deadcode */

> sql/sql_string.cc
>
> (2a)extern void sql_element_free(void *ptr);
>
> client/sql_string.cc
>
> (3a)extern void sql_element_free(void *ptr);
>
> Indeed, besides pointed above we find only the following
> occurences of sql_element_free():
>
> client/mysql.cc
>
>  void* sql_alloc(unsigned size);
>  void sql_element_free(void *ptr);
>  ...
>  void *sql_alloc(size_t Size)
>  {
>return my_malloc(Size,MYF(MY_WME));
>  }
>  void sql_element_free(void *ptr)
>  {
>my_free(ptr,MYF(0));
>  }
>
> So sql_element_free() is called nowhere (note also that this function
> has a do-nothing body).

Again I think the extern declarations should be deleted.

Not sure about the sql_element_free(). My guess would be that they were an
attempt to be able to use sql_list etc. from outside the server without memory
leaks, but the attempt was never completed. The issue with sql_alloc() is that
it uses a mem_root that will automatically free all memory at end of a
statement (for example). Maybe someone wanted to have explicit calls to
sql_element_free() (which would work in client but do nothing in server), but
they stopped half-way?

We might consider deleting them, on the other hand we should maybe better
leave them to reduce risk of conflicts when merging with MySQL. I have no
strong opinion on this one.

 - Kristian.

___
Mailing list: https://launchpad.net/~maria-developers
Post to : maria-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~maria-developers
More help   : https://help.launchpad.net/ListHelp


[Maria-developers] bzr commit into MariaDB 5.1, with Maria 1.5:maria branch (knielsen:2774) Bug#39249

2009-10-09 Thread knielsen
#At lp:maria

 2774 kniel...@knielsen-hq.org  2009-10-09 [merge]
  Merge Sanja's fix of BUG#39249 into MariaDB 5.1.38 release clone.
  added:
BUILD/compile-pentium-debug-max-no-qc
  modified:
BUILD/SETUP.sh
sql/mysql_priv.h
storage/maria/ha_maria.cc
storage/maria/ma_state.c
storage/maria/maria_def.h
storage/myisam/ha_myisam.cc
storage/myisam/mi_locking.c
storage/myisam/myisamdef.h

=== modified file 'BUILD/SETUP.sh'
--- a/BUILD/SETUP.sh2009-09-29 19:02:48 +
+++ b/BUILD/SETUP.sh2009-10-06 14:53:46 +
@@ -172,6 +172,7 @@ local_infile_configs="--enable-local-inf
 
 
 max_no_embedded_configs="$SSL_LIBRARY --with-plugins=max"
+max_no_qc_configs="$SSL_LIBRARY --with-plugins=max --without-query-cache"
 max_no_ndb_configs="$SSL_LIBRARY --with-plugins=max-no-ndb 
--with-embedded-server --with-libevent"
 max_configs="$SSL_LIBRARY --with-plugins=max --with-embedded-server 
--with-libevent"
 # Disable NDB in maria max builds

=== added file 'BUILD/compile-pentium-debug-max-no-qc'
--- a/BUILD/compile-pentium-debug-max-no-qc 1970-01-01 00:00:00 +
+++ b/BUILD/compile-pentium-debug-max-no-qc 2009-10-07 10:02:43 +
@@ -0,0 +1,10 @@
+#! /bin/sh
+# Builds server without query cache support
+
+path=`dirname $0`
+. "$path/SETUP.sh"
+
+extra_flags="$pentium_cflags $debug_cflags"
+extra_configs="$pentium_configs $debug_configs $max_no_qc_configs"
+
+. "$path/FINISH.sh"

=== modified file 'sql/mysql_priv.h'
--- a/sql/mysql_priv.h  2009-09-15 10:46:35 +
+++ b/sql/mysql_priv.h  2009-10-06 14:53:46 +
@@ -947,7 +947,6 @@ struct Query_cache_query_flags
 
 #define query_cache_abort(A)
 #define query_cache_end_of_result(A)
-#define query_cache_invalidate_by_MyISAM_filename_ref NULL
 #define query_cache_maybe_disabled(T) 1
 #define query_cache_is_cacheable_query(L) 0
 #endif /*HAVE_QUERY_CACHE*/

=== modified file 'storage/maria/ha_maria.cc'
--- a/storage/maria/ha_maria.cc 2009-09-07 20:50:10 +
+++ b/storage/maria/ha_maria.cc 2009-10-06 14:53:46 +
@@ -28,6 +28,7 @@
 #include 
 #include "ha_maria.h"
 #include "trnman_public.h"
+#include "trnman.h"
 
 C_MODE_START
 #include "maria_def.h"
@@ -918,6 +919,8 @@ int ha_maria::open(const char *name, int
   if (!(file= maria_open(name, mode, test_if_locked | HA_OPEN_FROM_SQL_LAYER)))
 return (my_errno ? my_errno : -1);
 
+  file->s->chst_invalidator= query_cache_invalidate_by_MyISAM_filename_ref;
+
   if (test_if_locked & (HA_OPEN_IGNORE_IF_LOCKED | HA_OPEN_TMP_TABLE))
 VOID(maria_extra(file, HA_EXTRA_NO_WAIT_LOCK, 0));
 
@@ -3238,6 +3241,9 @@ my_bool ha_maria::register_query_cache_t
   */
   *engine_data= 0;
 
+  if (file->s->now_transactional && file->s->have_versioning)
+return (file->trn->trid >= file->s->state.last_change_trn);
+
   /*
 If a concurrent INSERT has happened just before the currently processed
 SELECT statement, the total size of the table is unknown.

=== modified file 'storage/maria/ma_state.c'
--- a/storage/maria/ma_state.c  2008-12-27 02:05:16 +
+++ b/storage/maria/ma_state.c  2009-10-06 06:57:22 +
@@ -318,6 +318,13 @@ void _ma_update_status(void* param)
 DBUG_ASSERT(!info->s->base.born_transactional);
 share->state.state= *info->state;
 info->state= &share->state.state;
+#ifdef HAVE_QUERY_CACHE
+DBUG_PRINT("info", ("invalidator... '%s' (status update)",
+info->s->data_file_name.str));
+DBUG_ASSERT(info->s->chst_invalidator != NULL);
+(*info->s->chst_invalidator)((const char *)info->s->data_file_name.str);
+#endif
+
   }
   info->append_insert_at_end= 0;
 }
@@ -469,6 +476,8 @@ my_bool _ma_trnman_end_trans_hook(TRN *t
  tables->state_start.checksum);
   history->trid= trn->commit_trid;
 
+  share->state.last_change_trn= trn->commit_trid;
+
   if (history->next)
   {
 /* Remove not visible states */

=== modified file 'storage/maria/maria_def.h'
--- a/storage/maria/maria_def.h 2009-02-19 09:01:25 +
+++ b/storage/maria/maria_def.h 2009-10-06 06:57:22 +
@@ -83,6 +83,7 @@ typedef struct st_maria_state_info
   pgcache_page_no_t first_bitmap_with_space;
   ulonglong auto_increment;
   TrID create_trid; /* Minum trid for file */
+  TrID last_change_trn; /* selfdescriptive */
   ulong update_count;  /* Updated for each write lock */
   ulong status;
   double *rec_per_key_part;
@@ -337,7 +338,10 @@ typedef struct st_maria_share
   /* Mapings to read/write the data file */
   size_t (*file_read)(MARIA_HA *, uchar *, size_t, my_off_t, myf);
   size_t (*file_write)(MARIA_HA *, const uchar *, size_t, my_off_t, myf);
-  invalidator_by_filename invalidator; /* query cache invalidator */
+  /* query cache invalidator for merged tables */
+  invalidator_by_filename invalidator;
+  /* query cache invalidator for changing state */
+  invalidator_by_file

[Maria-developers] bzr commit into MariaDB 5.1, with Maria 1.5:maria branch (knielsen:2773)

2009-10-09 Thread knielsen
#At lp:maria

 2773 kniel...@knielsen-hq.org  2009-10-09
  Implement mysqltest --enable_prepare_warnings to properly fix some test 
failures.
  
  The --enable_prepare_warnings allows to not discard warnings from 
autorepair
  of crashed table in --ps-protocol mode.
  
  Use this to properly fix the parts.partition_recover_myisam and
  maria.maria-recover tests.
  
  Add a test case for the new feature. This also adds missing test coverage
  for the case where the same warning is thrown in both prepare and execute
  phase.
  added:
mysql-test/r/mysqltest_ps.result
mysql-test/t/mysqltest_ps.test
  modified:
client/mysqltest.cc
mysql-test/suite/maria/t/maria-recover.test
mysql-test/suite/parts/t/partition_recover_myisam.test

per-file messages:
  client/mysqltest.cc
Implement new commands --enable-prepare_warnings and 
--disable_prepare_warnings.
  mysql-test/r/mysqltest_ps.result
Add test case for new --enable_prepare_warning mysqltest command.
  mysql-test/suite/maria/t/maria-recover.test
Better fix of test case using new --enable_prepare_warnings command.
  mysql-test/suite/parts/t/partition_recover_myisam.test
Fix test failure in --ps-protocol mode.
  mysql-test/t/mysqltest_ps.test
Add test case for new --enable_prepare_warning mysqltest command.
=== modified file 'client/mysqltest.cc'
--- a/client/mysqltest.cc   2009-09-07 20:50:10 +
+++ b/client/mysqltest.cc   2009-10-09 08:09:24 +
@@ -100,6 +100,7 @@ static my_bool display_result_vertically
   display_metadata= FALSE, display_result_sorted= FALSE;
 static my_bool disable_query_log= 0, disable_result_log= 0;
 static my_bool disable_warnings= 0;
+static my_bool prepare_warnings_enabled= 0;
 static my_bool disable_info= 1;
 static my_bool abort_on_error= 1;
 static my_bool server_initialized= 0;
@@ -289,7 +290,7 @@ enum enum_commands {
   Q_SEND_QUIT, Q_CHANGE_USER, Q_MKDIR, Q_RMDIR,
   Q_LIST_FILES, Q_LIST_FILES_WRITE_FILE, Q_LIST_FILES_APPEND_FILE,
   Q_SEND_SHUTDOWN, Q_SHUTDOWN_SERVER,
-  Q_MOVE_FILE,
+  Q_MOVE_FILE, Q_ENABLE_PREPARE_WARNINGS, Q_DISABLE_PREPARE_WARNINGS,
 
   Q_UNKNOWN,  /* Unknown command.   */
   Q_COMMENT,  /* Comments, ignored. */
@@ -387,6 +388,8 @@ const char *command_names[]=
   "send_shutdown",
   "shutdown_server",
   "move_file",
+  "enable_prepare_warnings",
+  "disable_prepare_warnings",
 
   0
 };
@@ -6929,8 +6932,17 @@ void run_query_stmt(MYSQL *mysql, struct
 
   mysql_free_result(res); /* Free normal result set with meta data */
 
-  /* Clear prepare warnings */
-  dynstr_set(&ds_prepare_warnings, NULL);
+  /*
+Normally, if there is a result set, we do not show warnings from the
+prepare phase. This is because some warnings are generated both during
+prepare and execute; this would generate different warning output
+between normal and ps-protocol test runs.
+
+The --enable_prepare_warnings command can be used to change this so
+that warnings from both the prepare and execute phase are shown.
+  */
+  if (!disable_warnings && !prepare_warnings_enabled)
+dynstr_set(&ds_prepare_warnings, NULL);
 }
 else
 {
@@ -7754,6 +7766,8 @@ int main(int argc, char **argv)
   case Q_DISABLE_RESULT_LOG: disable_result_log=1; break;
   case Q_ENABLE_WARNINGS:disable_warnings=0; break;
   case Q_DISABLE_WARNINGS:   disable_warnings=1; break;
+  case Q_ENABLE_PREPARE_WARNINGS:  prepare_warnings_enabled=1; break;
+  case Q_DISABLE_PREPARE_WARNINGS: prepare_warnings_enabled=0; break;
   case Q_ENABLE_INFO:disable_info=0; break;
   case Q_DISABLE_INFO:   disable_info=1; break;
   case Q_ENABLE_METADATA:display_metadata=1; break;

=== added file 'mysql-test/r/mysqltest_ps.result'
--- a/mysql-test/r/mysqltest_ps.result  1970-01-01 00:00:00 +
+++ b/mysql-test/r/mysqltest_ps.result  2009-10-09 08:09:24 +
@@ -0,0 +1,40 @@
+select 1 + "2 a";
+1 + "2 a"
+3
+Warnings:
+Warning1292Truncated incorrect DOUBLE value: '2 a'
+create table t (a int primary key, b blob default '');
+Warnings:
+Warning1101BLOB/TEXT column 'b' can't have a default value
+select a, (2*a) AS a from t group by a;
+a  a
+Warnings:
+Warning1052Column 'a' in group statement is ambiguous
+drop table t;
+select 1 + "2 a";
+1 + "2 a"
+3
+Warnings:
+Warning1292Truncated incorrect DOUBLE value: '2 a'
+create table t (a int primary key, b blob default '');
+Warnings:
+Warning1101BLOB/TEXT column 'b' can't have a default value
+select a, (2*a) AS a from t group by a;
+a  a
+Warnings:
+Warning1052Column 'a' in group statement is ambiguous
+Warning1052Column 'a' in group statement is ambiguous
+drop table t;
+select 1 + "2 a";
+1 + "2 a"
+3
+Warnings:
+Warning1292

[Maria-developers] bzr commit into MariaDB 5.1, with Maria 1.5:maria branch (knielsen:2770)

2009-10-09 Thread knielsen
#At lp:maria

 2770 kniel...@knielsen-hq.org  2009-10-09
  Implement mysqltest --enable_prepare_warnings to properly fix some test 
failures.
  
  The --enable_prepare_warnings allows to not discard warnings from 
autorepair
  of crashed table in --ps-protocol mode.
  
  Use this to properly fix the parts.partition_recover_myisam and
  maria.maria-recover tests.
  
  Add a test case for the new feature. This also adds missing test coverage
  for the case where the same warning is thrown in both prepare and execute
  phase.
  added:
mysql-test/r/mysqltest_ps.result
mysql-test/t/mysqltest_ps.test
  modified:
client/mysqltest.cc
mysql-test/suite/maria/t/maria-recover.test
mysql-test/suite/parts/t/partition_recover_myisam.test

per-file messages:
  client/mysqltest.cc
Implement new commands --enable-prepare_warnings and 
--disable_prepare_warnings.
  mysql-test/r/mysqltest_ps.result
Add test case for new --enable_prepare_warning mysqltest command.
  mysql-test/suite/maria/t/maria-recover.test
Better fix of test case using new --enable_prepare_warnings command.
  mysql-test/suite/parts/t/partition_recover_myisam.test
Fix test failure in --ps-protocol mode.
  mysql-test/t/mysqltest_ps.test
Add test case for new --enable_prepare_warning mysqltest command.
=== modified file 'client/mysqltest.cc'
--- a/client/mysqltest.cc   2009-09-07 20:50:10 +
+++ b/client/mysqltest.cc   2009-10-09 07:52:38 +
@@ -100,6 +100,7 @@ static my_bool display_result_vertically
   display_metadata= FALSE, display_result_sorted= FALSE;
 static my_bool disable_query_log= 0, disable_result_log= 0;
 static my_bool disable_warnings= 0;
+static my_bool prepare_warnings_enabled= 0;
 static my_bool disable_info= 1;
 static my_bool abort_on_error= 1;
 static my_bool server_initialized= 0;
@@ -289,7 +290,7 @@ enum enum_commands {
   Q_SEND_QUIT, Q_CHANGE_USER, Q_MKDIR, Q_RMDIR,
   Q_LIST_FILES, Q_LIST_FILES_WRITE_FILE, Q_LIST_FILES_APPEND_FILE,
   Q_SEND_SHUTDOWN, Q_SHUTDOWN_SERVER,
-  Q_MOVE_FILE,
+  Q_MOVE_FILE, Q_ENABLE_PREPARE_WARNINGS, Q_DISABLE_PREPARE_WARNINGS,
 
   Q_UNKNOWN,  /* Unknown command.   */
   Q_COMMENT,  /* Comments, ignored. */
@@ -387,6 +388,8 @@ const char *command_names[]=
   "send_shutdown",
   "shutdown_server",
   "move_file",
+  "enable_prepare_warnings",
+  "disable_prepare_warnings",
 
   0
 };
@@ -6929,8 +6932,17 @@ void run_query_stmt(MYSQL *mysql, struct
 
   mysql_free_result(res); /* Free normal result set with meta data */
 
-  /* Clear prepare warnings */
-  dynstr_set(&ds_prepare_warnings, NULL);
+  /*
+Normally, if there is a result set, we do not show warnings from the
+prepare phase. This is because some warnings are generated both during
+prepare and execute; this would generate different warning output
+between normal and ps-protocol test runs.
+
+The --enable_prepare_warnings command can be used to change this so
+that warnings from both the prepare and execute phase are shown.
+  */
+  if (!disable_warnings && !prepare_warnings_enabled)
+dynstr_set(&ds_prepare_warnings, NULL);
 }
 else
 {
@@ -7754,6 +7766,8 @@ int main(int argc, char **argv)
   case Q_DISABLE_RESULT_LOG: disable_result_log=1; break;
   case Q_ENABLE_WARNINGS:disable_warnings=0; break;
   case Q_DISABLE_WARNINGS:   disable_warnings=1; break;
+  case Q_ENABLE_PREPARE_WARNINGS:  prepare_warnings_enabled=1; break;
+  case Q_DISABLE_PREPARE_WARNINGS: prepare_warnings_enabled=0; break;
   case Q_ENABLE_INFO:disable_info=0; break;
   case Q_DISABLE_INFO:   disable_info=1; break;
   case Q_ENABLE_METADATA:display_metadata=1; break;

=== added file 'mysql-test/r/mysqltest_ps.result'
--- a/mysql-test/r/mysqltest_ps.result  1970-01-01 00:00:00 +
+++ b/mysql-test/r/mysqltest_ps.result  2009-10-09 07:52:38 +
@@ -0,0 +1,40 @@
+select 1 + "2 a";
+1 + "2 a"
+3
+Warnings:
+Warning1292Truncated incorrect DOUBLE value: '2 a'
+create table t (a int primary key, b blob default '');
+Warnings:
+Warning1101BLOB/TEXT column 'b' can't have a default value
+select a, (2*a) AS a from t group by a;
+a  a
+Warnings:
+Warning1052Column 'a' in group statement is ambiguous
+drop table t;
+select 1 + "2 a";
+1 + "2 a"
+3
+Warnings:
+Warning1292Truncated incorrect DOUBLE value: '2 a'
+create table t (a int primary key, b blob default '');
+Warnings:
+Warning1101BLOB/TEXT column 'b' can't have a default value
+select a, (2*a) AS a from t group by a;
+a  a
+Warnings:
+Warning1052Column 'a' in group statement is ambiguous
+Warning1052Column 'a' in group statement is ambiguous
+drop table t;
+select 1 + "2 a";
+1 + "2 a"
+3
+Warnings:
+Warning1292