List:General Discussion« Previous MessageNext Message »
From:Michael Widenius Date:February 18 2000 1:13pm
Subject:[Fwd: NULLs get scrambled in an INSERT-SELECT]
View as plain text  
Hi!

>>>>> "Jan" == Jan Dvorak <jan.dvorak@stripped> writes:

Jan> I'm not sure if this bug report hasn't slipped
Jan> the Developers' attention.
Jan> I think it's pretty urgent,
Jan> as a part of standard SQL functionality broke.

Jan> Jan Dvorak


Jan> -------- Original Message --------
Jan> From: jan.dvorak@stripped
Jan> Subject: NULLs get scrambled in an INSERT-SELECT
Jan> To: mysql@stripped

>> Description:
Jan> An INSERT-SELECT appears to change NULLs to 0's.

Jan> When the SELECT part is run by itself,
Jan> it produces the correct result,
Jan> with NULLs at the right places.

Jan> When I try to INSERT the result into a table,
Jan> the NULLs are changed to 0's,
Jan> even though the relevant target table column
Jan> does allow NULLs.

Jan> Same problem with CREATE TABLE ... SELECT.

<cut>

Here is a fix for this:

*** /my/monty/master/mysql-3.23.11-alpha/sql/item.cc	Tue Jan  4 23:54:26 2000
--- ./item.cc	Fri Feb 18 15:00:24 2000
***************
*** 327,333 ****
  
  void Item_field::save_org_in_field(Field *to)
  {
!   if (field->is_real_null())
    {
      null_value=1;
      set_field_to_null(to);
--- 327,333 ----
  
  void Item_field::save_org_in_field(Field *to)
  {
!   if (field->is_null())
    {
      null_value=1;
      set_field_to_null(to);
***************
*** 342,348 ****
  
  bool Item_field::save_in_field(Field *to)
  {
!   if (result_field->is_real_null())
    {
      null_value=1;
      return set_field_to_null(to);
--- 342,348 ----
  
  bool Item_field::save_in_field(Field *to)
  {
!   if (result_field->is_null())
    {
      null_value=1;
      return set_field_to_null(to);


Regards,
Monty


Thread
[Fwd: NULLs get scrambled in an INSERT-SELECT]Michael Widenius18 Feb