Commit graph

502 commits

Author SHA1 Message Date
cmiller@calliope.local.cmiller/calliope.local
0733ea7462 Bug#25126: Reference to non-existant column in UPDATE...ORDER BY... crashes server
"update existingtable set anycolumn=nonexisting order by nonexisting" would crash
the server.

Though we would find the reference to a field, that doesn't mean we can then use
it to set some values.  It could be a reference to another field.  If it is NULL, 
don't try to use it to set values in the Item_field and instead return an error.

Over the previous patch, this signals an error at the location of the error, rather
than letting the subsequent deref signal it.
2007-02-09 11:05:36 +01:00
gkodinov/kgeorge@macbook.gmz
77acba320d Bug #22457: Column alias in ORDER BY works, but not if in an expression
The parser is allocating Item_field for references by name in ORDER BY
 expressions. Such expressions however may point not only to Item_field 
 in the select list (or to a table column) but also to an arbitrary Item. 
 This causes Item_field::fix_fields to throw an error about missing 
 column.
 The fix substitutes Item_field for the reference with an Item_ref when 
 not pointing to Item_field.
2006-11-03 18:48:16 +02:00
igor@rurik.mysql.com
55dd569bab Fixed bug #21853: assert failure for a grouping query with
an ALL/ANY quantified subquery in HAVING.
The Item::split_sum_func2 method should not create Item_ref
for objects of any class derived from Item_subselect.
2006-09-25 05:24:07 -07:00
gkodinov@lsmy3.wdf.sap.corp
ca79343359 BUG#18492: mysqld reports ER_ILLEGAL_REFERENCE in --ps-protocol
In the code that converts IN predicates to EXISTS predicates it is changing
the select list elements to constant 1. Example :
SELECT ... FROM ...  WHERE a IN (SELECT c FROM ...)
is transformed to :
SELECT ... FROM ... WHERE EXISTS (SELECT 1 FROM ...  HAVING a = c)
However there can be no FROM clause in the IN subquery and it may not be
a simple select : SELECT ... FROM ... WHERE a IN (SELECT f(..) AS
c UNION SELECT ...) This query is transformed to : SELECT ... FROM ...
WHERE EXISTS (SELECT 1 FROM (SELECT f(..) AS c UNION SELECT ...)
x HAVING a = c) In the above query c in the HAVING clause is made to be
an Item_null_helper (a subclass of Item_ref) pointing to the real
Item_field (which is not referenced anywhere else in the query anymore).
This is done because Item_ref_null_helper collects information whether
there are NULL values in the result.  This is OK for directly executed
statements, because the Item_field pointed by the Item_null_helper is
already fixed when the transformation is done.  But when executed as
a prepared statement all the Item instances are "un-fixed" before the
recompilation of the prepared statement. So when the Item_null_helper
gets fixed it discovers that the Item_field it points to is not fixed
and issues an error.  The remedy is to keep the original select list
references when there are no tables in the FROM clause. So the above
becomes : SELECT ... FROM ...  WHERE EXISTS (SELECT c FROM (SELECT f(..)
AS c UNION SELECT ...) x HAVING a = c) In this way c is referenced
directly in the select list as well as by reference in the HAVING
clause. So it gets correctly fixed even with prepared statements.  And
since the Item_null_helper subclass of Item_ref_null_helper is not used
anywhere else it's taken out.
2006-04-28 11:23:31 +02:00
bar@mysql.com
a6973ceed0 Bug#15949 union + illegal mix of collations (IMPLICIT + COERCIBLE)
union.result, union.test:
  Adding test case.
item.cc:
  Allow safe character set conversion in UNION
  - string constant to column's charset
  - to unicode
  Thus, UNION now works the same with CONCAT (and other string functions)
  in respect of aggregating arguments with different character sets.
2006-03-01 17:58:01 +04:00
jimw@mysql.com
f353bec511 Merge mysql.com:/home/jimw/my/mysql-4.1-14216
into  mysql.com:/home/jimw/my/mysql-4.1-clean
2005-11-29 11:52:58 -08:00
bar@mysql.com
5c1ba75cfd Merge abarkov@bk-internal.mysql.com:/home/bk/mysql-4.1
into  mysql.com:/usr/home/bar/mysql-4.1.b10446
2005-11-29 09:21:57 +04:00
evgen@moonbone.local
a4a3215a44 Fix bug #14482 Wrongly applied optimization in resolve_const_item() caused
crash

resolve_const_item() substitutes item which will evaluate to constant with
equvalent constant item, basing on the item's result type. In this case
subselect was resolved as constant, and resolve_const_item() was substituting
it's result's Item_caches to Item_null. Later Item_cache's function was called
for Item_null object, which caused server crash.

resolve_const_item() now substitutes constants for items with 
result_type == ROW_RESULT only for Item_rows.
2005-11-24 19:16:51 +03:00
bar@mysql.com
2f72e05903 Bug#10446 Illegal mix of collations:
item_strfunc.h, item_strfunc.cc, item.cc:
  Try to convert a const item into destination 
  character set. If conversion happens without
  data loss, then cache the converted value
  and return it during val_str().
  Otherwise, if conversion loses data, return
  Illeral mix of collations error, as it happened
  previously.
ctype_recoding.result, ctype_recoding.test:
  Fixing tests accordingly.
2005-11-21 17:26:31 +04:00
jimw@mysql.com
e55f906130 Fix bug in handling of decimal fields in UNION statements that could
cause a crash or write to an incorrect memory location. (Bug #14216)
2005-10-28 18:12:57 -07:00
evgen@moonbone.local
8cb0dff904 Fix bug#13392 Wrong VALUES() behaviour in INSERT SELECT with ON DUPLICATE
VALUES() can only refer to table insert going to. 
But Item_insert_value::fix_fields() were passing to it's arg full table list,
This results in finding second column which shouldn't be found, and
failing with error about ambiguous field.

Item_insert_value::fix_fields() now passes only first table of full table
list.
2005-10-25 20:04:12 +04:00
serg@serg.mylan
721873f7cd compilation failure fixed 2005-10-21 14:56:59 +02:00
evgen@moonbone.local
fb0074a6ad Manual merged 2005-10-13 01:14:58 +04:00
evgen@moonbone.local
551961b207 select.test, sql_select.cc, sql_lex.cc, item.cc:
Bug #7672 after merge fix
2005-10-13 00:58:59 +04:00
evgen@moonbone.local
c16410d3a1 Manual merge, fix for bug #7672 2005-10-12 03:32:14 +04:00
hf@deer.(none)
83c103ed81 Merge bk@192.168.21.1:/usr/home/bk/mysql-4.1
into deer.(none):/home/hf/work/mysql-4.1.13372
2005-10-10 21:09:34 +05:00
evgen@moonbone.local
6bfc2d4b89 Fix bug#7672 Unknown column error in order clause
When fixing Item_func_plus in ORDER BY clause field c is searched in all
opened tables, but because c is an alias it wasn't found there.

This patch adds a flag to select_lex which allows Item_field::fix_fields() 
to look up in select's item_list to find aliased fields.
2005-10-09 23:05:44 +04:00
monty@mysql.com
82855517a1 Review of new code since last pull
- Use %lx instead of %p as %p is not portable
- Don't replace ROW item with Item_null
2005-10-07 03:12:15 +03:00
evgen@moonbone.local
4f4711bd49 Fix bug#13356 resolve_const_item() wasn't able to handle Item_row items.
resolve_const_item() assumed to be not called for Item_row items. For
ensuring that DBUG_ASSERT(0) was set there.

This patch adds section for Item_row items. If it can it recursively calls
resolve_const_item() for each item the Item_row contains. If any of the
contained items is null then whole Item_row substitued by Item_null. Otherwise
it just returns.
2005-09-28 00:58:12 +04:00
hf@deer.(none)
9b88d25247 additional fix to the bug #13372 (decimal union) 2005-09-27 15:31:38 +05:00
hf@deer.(none)
7f3e2dc48d Fix for bug #13372 (decimal union) 2005-09-27 15:11:39 +05:00
gluh@eagle.intranet.mysql.r18.ru
99bc9607e1 Bug#12817 SHOW STATUS now blob fields
This fix is cancellation of ChangeSet
   1.2329 05/07/12 08:35:30 reggie@linux.site +8 -0
   Bug 7142  Show Fields from fails using Borland's dbExpress interface
   The reason is we can't fix bug#7142 without
   breaking of existing applications/APIs that worked fine with earlier 4.1
   bug 7142 is fixed in 5.0
2005-09-09 13:22:16 +05:00
evgen@moonbone.local
6ed7255448 manual merge of bug fix#12537 2005-08-30 23:29:47 +04:00
evgen@moonbone.local
d76f9471cb Fix bug #12537 UNION produces longtext instead of varchar
Item::tmp_table_field_from_field_type() and create_tmp_field_from_item()
was converting string field to blob depending on byte-wise length instead of
character length, which results in converting valid varchar string with
length == 86 to longtext.

Made that functions above take into account max width of character when
converting string fields to blobs.
2005-08-30 16:19:53 +04:00
bar@mysql.com
96e0cb8cbf ctype_utf8.result, ctype_utf8.test, item.cc:
Bug#12371 executing prepared statement fails (illegal mix of collations)
  After review fixes.
2005-08-29 16:49:01 +05:00
bar@mysql.com
be470c38c6 Merge abarkov@bk-internal.mysql.com:/home/bk/mysql-4.1
into  mysql.com:/usr/home/bar/mysql-4.1.b12371
2005-08-29 15:44:49 +05:00
elliot@mysql.com
d9efe655ed Bug#11338 Fixes from review (identical functionality). 2005-08-19 14:49:34 -04:00
elliot@mysql.com
197782605f BUG#11338 (logging of prepared statement w/ blob type)
In cp932, '\' character can be the second byte in a 
multi-byte character stream. This makes it difficult to use
mysql_escape_string. Added flag to indicate which languages allow
'\' as second byte of multibyte sequence so that when putting a prepared
statement into the binlog we can decide at runtime whether hex encoding
is really needed.
2005-08-17 04:26:32 -04:00
bar@mysql.com
2c8fc886b9 item.cc:
After review fix
2005-08-08 16:20:46 +05:00
bar@mysql.com
8d5bfbfa1e Bug#12371 executing prepared statement fails (illegal mix of collations)
item.cc:
item.h:
  Adding Item_param::safe_charset_converter,
  not to return collation mix error if
  parameter can be converted into operation
  character set.

ctype_utf8.result:
  adding test case
ctype_utf8.test:
  adding test case
2005-08-06 16:58:36 +05:00
bar@mysql.com
1b40adcb06 grant.result, grant.test:
fixing tests accordingly
item.cc:
  Bug #10892 user variables not auto cast for comparisons
  When mixing strings with different character sets,
  and coercibility is the same, we allow conversion
  if one character set is superset for other character set.
2005-08-04 15:25:03 +05:00
bar@mysql.com
0c2035b7bd func_gconcat.result, func_gconcat.test:
Adding test
item_sum.cc:
  Adding a call for collation/charset aggregation,
      to collect attributes from the arguments. The actual bug fix.
item_func.h, item_func.cc, item.h, item.cc:
  - Removing collation aggrgation functions from Item_func class
      in item.cc, and adding it as non-class functions in item.cc
      to be able to reuse this code for group_concat.
      - Adding replacement for these functions into Item_func class
      as wrappers for moved functions, to minizize patch size,
2005-07-26 12:52:02 +05:00
reggie@linux.site
8f605428cb Merge rburnett@bk-internal.mysql.com:/home/bk/mysql-4.1
into  linux.site:/home/reggie/bk/bug7142
2005-07-18 08:03:59 -06:00
bar@mysql.com
1b612b0006 Merge abarkov@bk-internal.mysql.com:/home/bk/mysql-4.1
into  mysql.com:/usr/home/bar/mysql-4.1.num-conv
2005-07-14 10:46:15 +05:00
konstantin@mysql.com
1755df7649 A fix and a test case for Bug#9379 (collation of a parameter marker is
binary).
2005-07-13 23:43:46 +04:00
konstantin@mysql.com
bef558b7ee - a fix for Bug#11458 "Prepared statement with subselects return random
data": remove the fix for another bug (8807) that
added OUTER_REF_TABLE_BIT to all subqueries that used a placeholder
to prevent their evaluation at prepare. As this bit hanged in 
Item_subselect::used_tables_cache for ever, a constant subquery with
a placeholder was never evaluated as such, which caused wrong 
choice of the execution plan for the statement.
- to fix Bug#8807 backport a better fix from 5.0
- post-review fixes.
2005-07-13 17:38:55 +04:00
bar@mysql.com
5150fdcc04 ctype_utf8.result:
adding test case
sql_table.cc:
  sql_table.cc:
  - do not create a new item when charsets are the same
  - return ER_INVALID_DEFAULT if default value cannot
    be converted into the column character set.
item.cc:
  - Allow conversion not only to Unicode,
    but also to and from "binary".
  - Adding safe_charset_converter() for Item_num
    and Item_varbinary, returning a fixed const Item.
2005-07-13 13:00:17 +05:00
sergefp@mysql.com
55e70fd1f6 Fix for BUG#11821: Make Item_type_holder be able to work with MIN(field),
MAX(field).
2005-07-12 16:30:45 +00:00
reggie@linux.site
8a68788c39 Bug #7142 Show Fields from fails using Borland's dbExpress interface
The problem here is that columns that have an especially long type 
such as an enum type with many options would be longer than 40 chars
but the type column returned from show columns always was defined
as varchar(40).

This is fixed in 5.0 using info schema.
2005-07-12 08:35:30 -06:00
monty@mishka.local
83f90e060e Better bug fix for:
#9728  'Decreased functionality in "on duplicate key update
#8147  'a column proclaimed ambigous in INSERT ... SELECT .. ON DUPLICATE'

This ensures fields are uniquely qualified and also that one can't update other tables in the ON DUPLICATE KEY UPDATE part
2005-06-27 16:46:41 +03:00
evgen@moonbone.local
2235ea9593 Fix bug #9728 decreased functionality in "on duplicate key update"
Remove changes made by bug fix #8147. They strips list of insert_table_list to
only insert table, which results in error reported in bug #9728.
Added flag to Item to resolve ambigous fields reported in bug #8147.
2005-06-22 07:18:42 +04:00
serg@serg.mylan
6a5349028c a compiler must see '#pragma implementation' *before*
'#pragma interface' (that comes with the #include'd header file)
2005-06-05 19:38:52 +02:00
monty@mysql.com
29fd1f2fd9 Move USE_PRAGMA_IMPLEMENTATION to proper place
Ensure that 'null_value' is not accessed before val() is called in FIELD() functions
Fixed initialization of key maps. This fixes some problems with keys when you have more than 64 keys
Fixed that ROLLUP don't always create a temporary table. This fix ensures that func_gconcat.test results are now predictable
2005-06-03 23:46:03 +03:00
kent@mysql.com
bd48eed988 tztime.cc:
Set #pragma implementation" earlier
Many files:
  Need to include <my_global.h> before #ifdef USE_PRAGMA_IMPLEMENTATION
2005-06-02 02:43:32 +02:00
msvensson@neptunus.(none)
dbcf3b3a2e Merge bk-internal.mysql.com:/home/bk/mysql-4.1
into neptunus.(none):/home/msvensson/mysql/mysql-4.1
2005-05-26 20:02:21 +02:00
bell@sanja.is.com.ua
b186d8b4f9 merge 2005-05-26 18:33:57 +03:00
bell@sanja.is.com.ua
db2ce1edf6 fixed problem with long string results of expressions in UNIONS (BUG#10025) 2005-05-26 17:30:12 +03:00
msvensson@neptunus.(none)
975ca22872 Merge bk-internal.mysql.com:/home/bk/mysql-4.1
into neptunus.(none):/home/msvensson/mysql/mysql-4.1
2005-05-26 12:10:05 +02:00
msvensson@neptunus.(none)
83d430353e Add ifdefs to control when "#pragma implementation" should be used
Added some more ifdefs for "#pragma interface"
2005-05-26 12:09:14 +02:00
jani@ua141d10.elisa.omakaista.fi
5254d52cb6 Added a test case for Bug#8009. 2005-05-24 17:50:17 +03:00