Bug #49333 Unknown column 'test.TEMPTABLE.column1' in 'field list'
Submitted: 2 Dec 2009 10:04 Modified: 2 Dec 2009 10:54
Reporter: Devart Team Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Stored Routines Severity:S3 (Non-critical)
Version:5.1.34 OS:Any
Assigned to: CPU Architecture:Any

[2 Dec 2009 10:04] Devart Team
Description:
When I call this SP twice, I get an error - Unknown column 'test.TEMPTABLE.column1' in 'field list'.  

CREATE PROCEDURE test.proc1(p1 INT)
BEGIN

  DROP TABLE IF EXISTS test.TEMPTABLE;

  IF p1 = 0 THEN
    CREATE TEMPORARY TABLE test.TEMPTABLE(
      id INT(11),
      column1 INT,
      column2 INT,
      column3 INT
    );
  ELSE
    CREATE TEMPORARY TABLE test.TEMPTABLE(
      id INT(11),
      column2 INT,
      column3 INT
    );
  END IF;

  SELECT 
    *
  FROM
    test.TEMPTABLE;

  DROP TABLE IF EXISTS test.TEMPTABLE;

END

I guess that 'SELECT * FROM test.TEMPTABLE' is the reason.

How to repeat:
CALL test.proc1(0);
CALL test.proc1(1);
[2 Dec 2009 10:54] Sveta Smirnova
Please do not submit the same bug more than once. An existing bug report already describes this very problem. Even if you feel that your issue is somewhat different, the resolution is likely
to be the same. Because of this, we hope you add your comments to the original bug instead.

Thank you for your interest in MySQL.

Duplicate of bug #12257