Bug in error message with UNION and derived table with MySQL-4.1 ?

Bug in error message with UNION and derived table with MySQL-4.1 ?

am 17.12.2002 20:12:48 von Jocelyn Fournier

Hi,

I'm wondering if the following is a bug or not :

How-to-repeat :

mysql> SELECT 1 as a FROM (SELECT 1 UNION SELECT a) b;
ERROR 1245: Reference 'a' not supported (forward reference in item list)

mysql> SELECT 1 as a FROM (SELECT a UNION SELECT 1) b;
ERROR 1054: Unknown column 'a' in 'field list'

This should be the same error message for both SELECT ?

Regards,
Jocelyn

------------------------------------------------------------ ---------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)

To request this thread, e-mail bugs-thread13317@lists.mysql.com
To unsubscribe, e-mail

Re: Bug in error message with UNION and derived table with MySQL-4.1 ?

am 17.12.2002 21:28:55 von Sinisa Milivojevic

Jocelyn Fournier writes:
> Hi,
>
> I'm wondering if the following is a bug or not :
>
> How-to-repeat :
>
> mysql> SELECT 1 as a FROM (SELECT 1 UNION SELECT a) b;
> ERROR 1245: Reference 'a' not supported (forward reference in item list)
>
> mysql> SELECT 1 as a FROM (SELECT a UNION SELECT 1) b;
> ERROR 1054: Unknown column 'a' in 'field list'
>
> This should be the same error message for both SELECT ?
>
> Regards,
> Jocelyn


Thank you for your bug report which helped us fix another bug in
derived tables with UNION's.

This is a patch:

===== sql/item.cc 1.63 vs edited =====
*** /tmp/item.cc-1.63-4419 Tue Dec 17 21:04:32 2002
--- edited/sql/item.cc Tue Dec 17 22:23:20 2002
***************
*** 573,579 ****
Item **refer= (Item **)not_found_item;
// Prevent using outer fields in subselects, that is not supported now
SELECT_LEX *cursel=(SELECT_LEX *) thd->lex.current_select;
! if (cursel->linkage != DERIVED_TABLE_TYPE)
for (SELECT_LEX *sl=cursel->outer_select();
sl;
sl= sl->outer_select())
--- 573,579 ----
Item **refer= (Item **)not_found_item;
// Prevent using outer fields in subselects, that is not supported now
SELECT_LEX *cursel=(SELECT_LEX *) thd->lex.current_select;
! if (cursel->master_unit()->first_select()->linkage != DERIVED_TABLE_TYPE)
for (SELECT_LEX *sl=cursel->outer_select();
sl;
sl= sl->outer_select())


--
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Mr. Sinisa Milivojevic
/ /|_/ / // /\ \/ /_/ / /__ MySQL AB, Fulltime Developer
/_/ /_/\_, /___/\___\_\___/ Larnaca, Cyprus
<___/ www.mysql.com

Join MySQL Users Conference and Expo:
http://www.mysql.com/events/uc2003/


------------------------------------------------------------ ---------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)

To request this thread, e-mail bugs-thread13318@lists.mysql.com
To unsubscribe, e-mail

Re: Bug in error message with UNION and derived table with MySQL-4.1 ?

am 17.12.2002 21:47:24 von Jocelyn Fournier

Hi,

I hit another similar bug with the following ;) :

mysql> SELECT 1 as a FROM (SELECT (SELECT a) UNION SELECT 1) b;
ERROR 1054: Unknown column 'a' in 'field list'

mysql> SELECT 1 as a FROM (SELECT 1 UNION SELECT (SELECT a)) b;
ERROR 1245: Reference 'a' not supported (forward reference in item list)

Regards,
Jocelyn

----- Original Message -----
From: "Sinisa Milivojevic"
To:
Cc:
Sent: Tuesday, December 17, 2002 8:28 PM
Subject: Re: Bug in error message with UNION and derived table with
MySQL-4.1 ?


> Jocelyn Fournier writes:
> > Hi,
> >
> > I'm wondering if the following is a bug or not :
> >
> > How-to-repeat :
> >
> > mysql> SELECT 1 as a FROM (SELECT 1 UNION SELECT a) b;
> > ERROR 1245: Reference 'a' not supported (forward reference in item list)
> >
> > mysql> SELECT 1 as a FROM (SELECT a UNION SELECT 1) b;
> > ERROR 1054: Unknown column 'a' in 'field list'
> >
> > This should be the same error message for both SELECT ?
> >
> > Regards,
> > Jocelyn
>
>
> Thank you for your bug report which helped us fix another bug in
> derived tables with UNION's.
>
> This is a patch:
>
> ===== sql/item.cc 1.63 vs edited =====
> *** /tmp/item.cc-1.63-4419 Tue Dec 17 21:04:32 2002
> --- edited/sql/item.cc Tue Dec 17 22:23:20 2002
> ***************
> *** 573,579 ****
> Item **refer= (Item **)not_found_item;
> // Prevent using outer fields in subselects, that is not supported
now
> SELECT_LEX *cursel=(SELECT_LEX *) thd->lex.current_select;
> ! if (cursel->linkage != DERIVED_TABLE_TYPE)
> for (SELECT_LEX *sl=cursel->outer_select();
> sl;
> sl= sl->outer_select())
> --- 573,579 ----
> Item **refer= (Item **)not_found_item;
> // Prevent using outer fields in subselects, that is not supported
now
> SELECT_LEX *cursel=(SELECT_LEX *) thd->lex.current_select;
> ! if (cursel->master_unit()->first_select()->linkage !=
DERIVED_TABLE_TYPE)
> for (SELECT_LEX *sl=cursel->outer_select();
> sl;
> sl= sl->outer_select())
>
>
> --
> __ ___ ___ ____ __
> / |/ /_ __/ __/ __ \/ / Mr. Sinisa Milivojevic
> / /|_/ / // /\ \/ /_/ / /__ MySQL AB, Fulltime Developer
> /_/ /_/\_, /___/\___\_\___/ Larnaca, Cyprus
> <___/ www.mysql.com
>
> Join MySQL Users Conference and Expo:
> http://www.mysql.com/events/uc2003/
>
>
> ------------------------------------------------------------ ---------
> Before posting, please check:
> http://www.mysql.com/manual.php (the manual)
> http://lists.mysql.com/ (the list archive)
>
> To request this thread, e-mail bugs-thread13318@lists.mysql.com
> To unsubscribe, e-mail
>
>
>
>


------------------------------------------------------------ ---------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)

To request this thread, e-mail bugs-thread13319@lists.mysql.com
To unsubscribe, e-mail

Re: Bug in error message with UNION and derived table with MySQL-4.1 ?

am 17.12.2002 23:00:57 von Sanja Byelkin

Hi!

On Tue, Dec 17, 2002 at 08:47:24PM -0000, Jocelyn Fournier wrote:
> Hi,
>
> I hit another similar bug with the following ;) :
>
> mysql> SELECT 1 as a FROM (SELECT (SELECT a) UNION SELECT 1) b;
> ERROR 1054: Unknown column 'a' in 'field list'
>
> mysql> SELECT 1 as a FROM (SELECT 1 UNION SELECT (SELECT a)) b;
> ERROR 1245: Reference 'a' not supported (forward reference in item list)

Thank you for bugreport!
following patch should solve all such problems

diff -Nrc a/sql/item.cc b/sql/item.cc
*** a/sql/item.cc Wed Dec 18 00:00:17 2002
--- b/sql/item.cc Wed Dec 18 00:00:17 2002
***************
*** 573,579 ****
Item **refer= (Item **)not_found_item;
// Prevent using outer fields in subselects, that is not supported now
SELECT_LEX *cursel=(SELECT_LEX *) thd->lex.current_select;
! if (cursel->linkage != DERIVED_TABLE_TYPE)
for (SELECT_LEX *sl=cursel->outer_select();
sl;
sl= sl->outer_select())
--- 573,580 ----
Item **refer= (Item **)not_found_item;
// Prevent using outer fields in subselects, that is not supported now
SELECT_LEX *cursel=(SELECT_LEX *) thd->lex.current_select;
! if (cursel->master_unit()->first_select()->linkage !=
! DERIVED_TABLE_TYPE)
for (SELECT_LEX *sl=cursel->outer_select();
sl;
sl= sl->outer_select())
***************
*** 586,592 ****
REPORT_EXCEPT_NOT_FOUND)) !=
(Item **)not_found_item)
break;
! if (sl->linkage == DERIVED_TABLE_TYPE)
break; // do not look over derived table
}
if (!tmp)
--- 587,594 ----
REPORT_EXCEPT_NOT_FOUND)) !=
(Item **)not_found_item)
break;
! if (sl->master_unit()->first_select()->linkage ==
! DERIVED_TABLE_TYPE)
break; // do not look over derived table
}
if (!tmp)
***************
*** 1024,1030 ****
if ((ref= find_item_in_list(this,
*(thd->lex.current_select->get_item_list()),
((sl &&
! thd->lex.current_select->linkage !=
DERIVED_TABLE_TYPE) ?
REPORT_EXCEPT_NOT_FOUND :
REPORT_ALL_ERRORS))) ==
--- 1026,1033 ----
if ((ref= find_item_in_list(this,
*(thd->lex.current_select->get_item_list()),
((sl &&
! thd->lex.current_select->master_unit()->
! first_select()->linkage !=
DERIVED_TABLE_TYPE) ?
REPORT_EXCEPT_NOT_FOUND :
REPORT_ALL_ERRORS))) ==
***************
*** 1050,1056 ****
if ((tmp= find_field_in_tables(thd, this,
sl->get_table_list(),
0)) != not_found_field);
! if (sl->linkage == DERIVED_TABLE_TYPE)
break; // do not look over derived table
}

--- 1053,1060 ----
if ((tmp= find_field_in_tables(thd, this,
sl->get_table_list(),
0)) != not_found_field);
! if (sl->master_unit()->first_select()->linkage ==
! DERIVED_TABLE_TYPE)
break; // do not look over derived table
}



--
For technical support contracts, visit https://order.mysql.com/
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Mr. Oleksandr Byelkin
/ /|_/ / // /\ \/ /_/ / /__ MySQL AB, Full-Time Developer
/_/ /_/\_, /___/\___\_\___/ Lugansk, Ukraine
<___/ www.mysql.com

------------------------------------------------------------ ---------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)

To request this thread, e-mail bugs-thread13320@lists.mysql.com
To unsubscribe, e-mail