From 783780f1c92e6c8b3ebbb1f40ca34cc14336f81b Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 27 Mar 2006 12:02:23 +0300 Subject: [PATCH 1/3] Safer fix for Bug #18435 "5.0.19 libmysqlclient not ABI-compatible with 5.0.18" This fixes the problem if someone is using struct MYSQL as part of another structure together with a shared library include/mysql.h: Safer fix for Bug #18435 sql-common/client.c: Safer fix for Bug #18435 --- include/mysql.h | 2 ++ sql-common/client.c | 6 ------ 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/include/mysql.h b/include/mysql.h index 303cb2af4f5..925a4525378 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -287,8 +287,10 @@ typedef struct st_mysql from mysql_stmt_close if close had to cancel result set of this object. */ my_bool *unbuffered_fetch_owner; +#if defined(EMBEDDED_LIBRARY) || defined(EMBEDDED_LIBRARY_COMPATIBLE) || MYSQL_VERSION_ID >= 50100 /* needed for embedded server - no net buffer to store the 'info' */ char *info_buffer; +#endif } MYSQL; typedef struct st_mysql_res { diff --git a/sql-common/client.c b/sql-common/client.c index 4c7ef3fcd03..cd50960164b 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -1428,13 +1428,7 @@ mysql_init(MYSQL *mysql) mysql->free_me=1; } else - { -#if defined(EMBEDDED_LIBRARY) || MYSQL_VERSION_ID >= 50100 bzero((char*) (mysql), sizeof(*(mysql))); -#else - bzero((char*) (mysql), offsetof(MYSQL, info_buffer)); -#endif - } mysql->options.connect_timeout= CONNECT_TIMEOUT; mysql->last_used_con= mysql->next_slave= mysql->master = mysql; mysql->charset=default_charset_info; From 53aadad668116627005a3b2e52d241056c891060 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 27 Mar 2006 19:25:25 +0200 Subject: [PATCH 2/3] mysql_config.sh: We are not to control what malloc package others are to use, remove -lmtmalloc from --libs(_r), bug#18322 scripts/mysql_config.sh: We are not to control what malloc package others are to use, remove -lmtmalloc from --libs(_r), bug#18322 --- scripts/mysql_config.sh | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/scripts/mysql_config.sh b/scripts/mysql_config.sh index 5b35c0190a5..caf8708c6a0 100644 --- a/scripts/mysql_config.sh +++ b/scripts/mysql_config.sh @@ -91,18 +91,15 @@ socket='@MYSQL_UNIX_ADDR@' port='@MYSQL_TCP_PORT@' ldflags='@LDFLAGS@' -# Create options - -libs="$ldflags -L$pkglibdir -lmysqlclient @ZLIB_DEPS@ @NON_THREADED_LIBS@" +# Create options +# We intentionally add a space to the beginning of lib strings, simplifies replace later +libs=" $ldflags -L$pkglibdir -lmysqlclient @ZLIB_DEPS@ @NON_THREADED_LIBS@" libs="$libs @openssl_libs@ @STATIC_NSS_FLAGS@" -libs=`echo "$libs" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'` +libs_r=" $ldflags -L$pkglibdir -lmysqlclient_r @ZLIB_DEPS@ @LIBS@ @openssl_libs@" +embedded_libs=" $ldflags -L$pkglibdir -lmysqld @ZLIB_DEPS@ @LIBS@ @WRAPLIBS@ @innodb_system_libs@" -libs_r="$ldflags -L$pkglibdir -lmysqlclient_r @ZLIB_DEPS@ @LIBS@ @openssl_libs@" -libs_r=`echo "$libs_r" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'` cflags="-I$pkgincludedir @CFLAGS@ " #note: end space! include="-I$pkgincludedir" -embedded_libs="$ldflags -L$pkglibdir -lmysqld @ZLIB_DEPS@ @LIBS@ @WRAPLIBS@ @innodb_system_libs@" -embedded_libs=`echo "$embedded_libs" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'` # Remove some options that a client doesn't have to care about # FIXME until we have a --cxxflags, we need to remove -Xa @@ -118,6 +115,20 @@ do done cflags=`echo "$cflags"|sed -e 's/ *\$//'` +# Same for --libs(_r) +for remove in lmtmalloc +do + # We know the strings starts with a space + libs=`echo "$libs"|sed -e "s/ -$remove */ /g"` + libs_r=`echo "$libs_r"|sed -e "s/ -$remove */ /g"` + embedded_libs=`echo "$embedded_libs"|sed -e "s/ -$remove */ /g"` +done + +# Strip trailing and ending space if any, and '+' (FIXME why?) +libs=`echo "$libs" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'` +libs_r=`echo "$libs_r" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'` +embedded_libs=`echo "$embedded_libs" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'` + usage () { cat < Date: Mon, 27 Mar 2006 18:28:55 -0800 Subject: [PATCH 3/3] Fixed bug #18386. An invalid assertion in Item_direct_view_ref::eq caused an assertion abort in the debug version. mysql-test/r/view.result: Added a test case for bug #18386. mysql-test/t/view.test: Added a test case for bug #18386. sql/item.cc: Fixed bug #18386. An invalid assertion in Item_direct_view_ref::eq caused an assertion abort in the debug version. Changed the assertion. --- mysql-test/r/view.result | 9 +++++++++ mysql-test/t/view.test | 14 ++++++++++++++ sql/item.cc | 11 ++++------- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 7678c70bda2..5a5f60e9409 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -2553,3 +2553,12 @@ a b 3 3 drop view v2, v1; drop table t1; +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (1), (2); +CREATE VIEW v1 AS SELECT SQRT(a) my_sqrt FROM t1; +SELECT my_sqrt FROM v1 ORDER BY my_sqrt; +my_sqrt +1 +1.4142135623731 +DROP VIEW v1; +DROP TABLE t1; diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index e17e2b98527..e53988ad3d9 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -2399,3 +2399,17 @@ update v2 set b=3 where a=2; select * from v2; drop view v2, v1; drop table t1; + +# +# Bug #18386: select from view over a table with ORDER BY view_col clause +# given view_col is not an image of any column from the base table + +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (1), (2); + +CREATE VIEW v1 AS SELECT SQRT(a) my_sqrt FROM t1; + +SELECT my_sqrt FROM v1 ORDER BY my_sqrt; + +DROP VIEW v1; +DROP TABLE t1; diff --git a/sql/item.cc b/sql/item.cc index c48bf19a88b..8ffe7a6b2fd 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -5076,11 +5076,8 @@ bool Item_direct_view_ref::fix_fields(THD *thd, Item **reference) DESCRIPTION A view column reference is considered equal to another column reference if the second one is a view column and if both column - references point to the same field. For views 'same field' means - the same Item_field object in the view translation table, where - the view translation table contains all result columns of the - view. This definition ensures that view columns are resolved - in the same manner as table columns. + references resolve to the same item. It is assumed that both + items are of the same type. RETURN TRUE Referenced item is equal to given item @@ -5096,8 +5093,8 @@ bool Item_direct_view_ref::eq(const Item *item, bool binary_cmp) const if (item_ref->ref_type() == VIEW_REF) { Item *item_ref_ref= *(item_ref->ref); - DBUG_ASSERT((*ref)->real_item()->type() == FIELD_ITEM && - (item_ref_ref->real_item()->type() == FIELD_ITEM)); + DBUG_ASSERT((*ref)->real_item()->type() == + item_ref_ref->real_item()->type()); return ((*ref)->real_item() == item_ref_ref->real_item()); } }