Commit graph

8 commits

Author SHA1 Message Date
Staale Smedseng
220d9b8c4a This is a backport of the two patches for Bug #28299:
To-number conversion warnings work differenly with CHAR 
and VARCHAR sp variables.

The original revision-IDs are:
  staale.smedseng@sun.com-20081124095339-2qdvzkp0rn1ljs30
  staale.smedseng@sun.com-20081125104611-rtxic5d12e83ag2o
                                                
The patch provides ER_TRUNCATED_WRONG_VALUE warning messages
for conversion of VARCHAR to numberic values, in line with
messages provided for CHAR conversions. Conversions are
checked for success, and the message is emitted in case
failure.
                                                
The tests are amended to accept the added warning messages,
and explicit conversion of ON/OFF values is added for
statements checking system variables. In test
rpl.rpl_switch_stm_row_mixed checking for warnings is
temporarily disabled for one statement, as this generates
warning messages for strings that vary between executions.


sql/field.cc:
  The pushing of the truncation warning is now done in a
  separate static function, and used in various places.
2009-10-09 15:34:07 +02:00
unknown
ad4da53510 Merge adventure.(none):/home/thek/Development/cpp/bug26277/my51-bug26277
into  adventure.(none):/home/thek/Development/cpp/mysql-5.1-runtime


mysql-test/t/sp-vars.test:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/item_func.h:
  Auto merged
mysql-test/r/sp-vars.result:
  manual merge
2007-05-18 14:29:24 +02:00
unknown
755ae21b82 Bug#26277 User variable returns one type in SELECT @v and other for CREATE as SELECT @v
- Adding variable m_cached_result_type to keep the variable type consistent
  during the execution of a statement.
- Before each result set is returned to the client the description of each
  column is sent as meta data.
  Previously the result type for a column could change if the hash variable
  entry changed between statements. This caused the result set of the query
  to alternate column types in certain cases which is not supported by MySQL
  client-server protocol. Example:
  Previously this sequence:
    SET @a:=1;
    SELECT @a:="text", @a;
  would return "text", "text";
 
  After the change the SELECT returns "text", 0
  The reson for this is that previously the result set from 'SELECT @a;'
  would always be of the type STRING, whereas now the type of the variable
  is taken from the last SET statement. However, 'SELECT @a:="text"' will
  return type of STRING since the right side of the assignment is used.


mysql-test/r/ps_2myisam.result:
  Changed test result because SQL type of a user variable now
  more accurately represents its Item type: since Item type of a variable
  can be either STRING, INT, DECIMAL or DOUBLE, SQL type of the
  result set metadata now can be either MYSQL_TYPE_VARCHAR,
  MYSQL_TYPE_LONGLONG, MYSQL_TYPE_NEWDECIMAL or MYSQL_TYPE_DOUBLE.
  
  Previously it was always MYSQL_TYPE_VARCHAR.
  
  In particular, integer variables now have changed from
  MYSQL_TYPE_VARCHAR to MYSQL_TYPE_LONGLONG.
mysql-test/r/ps_3innodb.result:
  Changed test result because SQL type of a user variable now
  more accurately represents its Item type: since Item type of a variable
  can be either STRING, INT, DECIMAL or DOUBLE, SQL type of the
  result set metadata now can be either MYSQL_TYPE_VARCHAR,
  MYSQL_TYPE_LONGLONG, MYSQL_TYPE_NEWDECIMAL or MYSQL_TYPE_DOUBLE.
  
  Previously it was always MYSQL_TYPE_VARCHAR.
  
  In particular, integer variables now have changed from
  MYSQL_TYPE_VARCHAR to MYSQL_TYPE_LONGLONG.
mysql-test/r/ps_4heap.result:
  Changed test result because SQL type of a user variable now
  more accurately represents its Item type: since Item type of a variable
  can be either STRING, INT, DECIMAL or DOUBLE, SQL type of the
  result set metadata now can be either MYSQL_TYPE_VARCHAR,
  MYSQL_TYPE_LONGLONG, MYSQL_TYPE_NEWDECIMAL or MYSQL_TYPE_DOUBLE.
  
  Previously it was always MYSQL_TYPE_VARCHAR.
  
  In particular, integer variables now have changed from
  MYSQL_TYPE_VARCHAR to MYSQL_TYPE_LONGLONG.
mysql-test/r/ps_5merge.result:
  Changed test result because SQL type of a user variable now
  more accurately represents its Item type: since Item type of a variable
  can be either STRING, INT, DECIMAL or DOUBLE, SQL type of the
  result set metadata now can be either MYSQL_TYPE_VARCHAR,
  MYSQL_TYPE_LONGLONG, MYSQL_TYPE_NEWDECIMAL or MYSQL_TYPE_DOUBLE.
  
  Previously it was always MYSQL_TYPE_VARCHAR.
  
  In particular, integer variables now have changed from
  MYSQL_TYPE_VARCHAR to MYSQL_TYPE_LONGLONG.
mysql-test/r/ps_7ndb.result:
  Changed test result because SQL type of a user variable now
  more accurately represents its Item type: since Item type of a variable
  can be either STRING, INT, DECIMAL or DOUBLE, SQL type of the
  result set metadata now can be either MYSQL_TYPE_VARCHAR,
  MYSQL_TYPE_LONGLONG, MYSQL_TYPE_NEWDECIMAL or MYSQL_TYPE_DOUBLE.
  
  Previously it was always MYSQL_TYPE_VARCHAR.
  
  In particular, integer variables now have changed from
  MYSQL_TYPE_VARCHAR to MYSQL_TYPE_LONGLONG.
mysql-test/r/sp-vars.result:
  Added test case. Previously variables could change their variable type during 
  the execution of a statement.
  Which variable type to use in the statement is specified in
  any previous statement.
mysql-test/r/type_date.result:
  This test case result is changed because it is no longer allowed for user
  variables to change their variable type during the execution of a statement.
  The determination of which variable type to use in the statement is specified in
  any previous statement.
mysql-test/r/user_var.result:
  This test case result is changed because it is no longer allowed for user
  variables to change their variable type during the execution of a statement.
  The determination of which variable type to use in the statement is specified in
  any previous statement.
mysql-test/t/sp-vars.test:
  Added test case. Previously variables could change their variable type during 
  the execution of a statement.
  Which variable type to use in the statement is specified in
  any previous statement.
mysql-test/t/type_date.test:
  This test case result is changed because it is no longer allowed for user
  variables to change their variable type during the execution of a statement.
  The determination of which variable type to use in the statement is specified in
  any previous statement.
sql/item_func.cc:
  Adding variable m_cached_result_type to keep the variable type consistent
  during the execution of a statement.
  Previously the result type could change if the hash variable entry changed
  between statements. This caused the result set of the query to alternate
  column types in certain cases.
sql/item_func.h:
  Adding variable m_cached_result_type to keep the variable type consistent
  during the execution of a statement.
  Previously the result type could change if the hash variable entry changed
  between statements. This caused the result set of the query to alternate
  column types in certain cases.
2007-05-18 12:44:03 +02:00
unknown
d9ce3033f5 Bug#27415 Text Variables in stored procedures
- Problem was reported as a SP variable using itself as 
   right value inside SUBSTR caused corruption of data. 
 - This bug could not be verified in either 5.0bk or 5.1bk
 - Added test case to prevent future regressions.


mysql-test/r/sp-vars.result:
  Added test case for a reported regression which couldn't be
  verified.
mysql-test/t/sp-vars.test:
  Added test case for a reported regression which couldn't be
  verified.
2007-05-16 14:25:38 +02:00
unknown
372fc7e443 Bug#12976 (stored procedures local variables of type bit)
Before this change, a local variables in stored procedures / stored functions
or triggers, when declared with a type of bit(N), would not evaluate their
value properly.

The problem was that the data was incorrectly typed as a string,
causing for example bit b'1', implemented as a byte 0x01, to be interpreted
as a string starting with the character 0x01. This later would cause
implicit conversions to integers or booleans to fail.

The root cause of this problem was an incorrect translation between field
types, like bit(N), and internal types used when representing values in Item
objects.

Also, before this change, the function HEX() would sometime print extra "0"
characters when invoked with bit(N) values.

With this fix, the type translation (sp_map_result_type, sp_map_item_type)
has been changed so that bit(N) fields are represented with integer values.

A consequence is that, for the function HEX(), when called with a stored
procedure local variable of type bit(N) as argument, HEX() is provided with an
integer instead of a string, and therefore does not print "0" padding.

A test case for Bug 12976 was present in the test suite, and has been updated.


mysql-test/r/sp-vars.result:
  Local stored procedure variables of type bit(N) are integer values.
mysql-test/t/sp-vars.test:
  Local stored procedure variables of type bit(N) are integer values.
sql/sp_head.cc:
  Local stored procedure variables of type bit(N) are integer values.
2007-02-06 16:01:22 -07:00
unknown
5bd58f3e00 Bug#20028 (Function with select return no data)
This patch reverts a change introduced by Bug 6951, which incorrectly
set thd->abort_on_warning for stored procedures.

As per internal discussions about the SQL_MODE=TRADITIONAL,
the correct behavior is to *not* abort on warnings even inside an INSERT/UPDATE
trigger.

Tests for Stored Procedures, Stored Functions, Triggers involving SQL_MODE
have been included or revised, to reflect the intended behavior.

(reposting approved patch, to work around source control issues, no review needed)


mysql-test/include/sp-vars.inc:
  Tests for SQL_MODE='TRADITIONAL'
mysql-test/r/sp-vars.result:
  Tests for SQL_MODE='TRADITIONAL'
mysql-test/r/sp.result:
  Tests for SQL_MODE='TRADITIONAL'
mysql-test/r/trigger.result:
  Tests for SQL_MODE='TRADITIONAL'
mysql-test/t/sp-vars.test:
  Tests for SQL_MODE='TRADITIONAL'
mysql-test/t/sp.test:
  Tests for SQL_MODE='TRADITIONAL'
mysql-test/t/trigger.test:
  Tests for SQL_MODE='TRADITIONAL'
sql/sp_head.cc:
  For SQL_MODE='TRADITIONAL',
  thd->abort_on_warning should be set only when assigning a *column*
2006-10-19 11:39:51 -07:00
unknown
fc085d77ad Bug#17226: Variable set in cursor on first iteration is assigned
second iterations value

During assignment to the BLOB variable in routine body the value
wasn't copied.


mysql-test/r/sp-vars.result:
  Add result for bug#17226.
mysql-test/t/sp-vars.test:
  Add test case for bug#17226.
sql/field_conv.cc:
  Honor copy_blobs flag.
2006-06-30 18:14:22 +04:00
unknown
06e9966396 Fix commit error: sp-vars.test should belong to mysql-test/t directory.
mysql-test/t/sp-vars.test:
  Rename: mysql-test/sp-vars.test -> mysql-test/t/sp-vars.test
2005-12-07 22:06:30 +03:00
Renamed from mysql-test/sp-vars.test (Browse further)