Bug #36791 Error trying to get Column Names
Submitted: 19 May 2008 1:10 Modified: 19 Jun 2008 16:45
Reporter: Jose Sturniolo Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: DML Severity:S2 (Serious)
Version:5.1.23 OS:Windows
Assigned to: CPU Architecture:Any
Tags: columns names, group_concat

[19 May 2008 1:10] Jose Sturniolo
Description:

I'm trying to get column names from a dynamic table. 
I need to build a CSV file, but the columns are build dynamicaly.

I have the following sentence that is called inside a Store Procedure:
(1)	SELECT SQL_NO_CACHE group_concat(QUOTE(column_name) SEPARATOR ',')  FROM `information_schema`.`COLUMNS` C
	WHERE table_schema = 'cbf' AND table_name = 'cvsFmt' 
	GROUP BY table_schema,table_name;

At the first run, the output is:
  'NomSocio','NroSocio','CONSAL?AUG 07','FATFA?AUG 07','FMLF?SEP 07',.... (and others)
 
 After this, I call the store procedure with other parameters, that create a different 'cvsFmt' table, this time, the third column 'CONSAL?SEP 07'
 however, if is I execute the sentence (1) I get the first result (CONSAL?AUG 07) 
 But if I execute: 
(2) describe cbf.cvsfmt
 I get:
 "NomSocio"	"varchar(102)"	"YES"	""	\N	""
"NroSocio"	"smallint(5) unsigned"	"NO"	""	\N	""
"CONSAL?SEP 07"	"decimal(30,2)"	"YES"	""	\N	""
"FATFA?SEP 07"	"decimal(30,2)"	"YES"	""	\N	""
"FMLF?OCT 07"	"decimal(30,2)"	"YES"	""	\N	""
"JERSAL?OCT 07"	"decimal(30,2)"	"YES"	""	\N	""
"MUT25?OCT 07"	"decimal(30,2)"	"YES"	""	\N	""
......

it seems as a cache is storing the sentence (1), I think that it is a bug, because the sentence 1 and 2 are equivalent, but are working different.

How to repeat:
1- create a table with a given schema
2- Execute sentence (1)
3- Drop the table and create again the same table, but with a different column names
4- Execute sentences (1) and (2) and you see the different output from each

Suggested fix:
I think that is necessary to provide a clear way to Get the COLUMN NAMES of a Table or a SELECT_SENTENCE that work with TEMPORARY and REAL TABLES.
[19 May 2008 15:07] Peter Laursen
looks like (one more) dublicate of:
http://bugs.mysql.com/bug.php?id=32868
[19 May 2008 16:45] Sveta Smirnova
Thank you for the report.

I can not repeat described behavior with current development sources. Please try with current version 5.1.24 and you still have same problem provide your configuration file and indicate if you issue this query from stored procedure.
[19 Jun 2008 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".