Bug #8750 Text field are truncated
Submitted: 23 Feb 2005 22:07 Modified: 24 Mar 2005 0:19
Reporter: Pier Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:4.0.16 OS:Windows (Windows XP)
Assigned to: Assigned Account CPU Architecture:Any

[23 Feb 2005 22:07] Pier
Description:
Client cannot fetch full content of a "text" field longer than 250 chars. 

How to repeat:
On the Server (Linux with Mysqld 4.0.18) create a table containing 4 columns:
CREATE TABLE log (
  
  col0index int(10) unsigned NOT NULL default '0',
  col1 varchar(44) NOT NULL default '',
  col2 text NOT NULL,
  col3 text NOT NULL
) TYPE=InnoDB;

Update the table with some hundreds of char in col2 and col3.

Client code:

MYSQL * tmp;
MYSQL * mysql;
MYSQL_RES * mysql_result;
MYSQL_ROW mysql_row;
string string_query, tmp_col1, tmp_col2, tmp_col3;

string_query.assign("SELECT col1, col2, col3 from log where col0index='2'");

	if (mysql != NULL)
		return -1;

	mysql = mysql_init(mysql);
	if (mysql == NULL)
		return -1;

	tmp = mysql_real_connect(mysql, cfg.dbmshost, cfg.username, cfg.password, cfg.dbname, cfg.dbmsport, NULL, CLIENT_COMPRESS);

mysql_query(mysql, query);

unsigned long *lengths;
unsigned int num_fields;
unsigned int i;	

mysql_result=mysql_use_result(mysql);

if (mysql_result==NULL)
		return -1;
mysql_row=mysql_fetch_row(mysql_result);
	if (mysql_row!=NULL)
	{ 
   num_fields = mysql_num_fields(mysql_result);
    lengths = mysql_fetch_lengths(mysql_result);
    for(i = 0; i < num_fields; i++)
    {
         printf("Column %u is %lu bytes in length.\n", i, lengths[i]);
    }
//SEE lengths are correct
		tmp_col1.assign(mysql_row[0]);
		tmp_col2.assign(mysql_row[1]);
		tmp_col3.assign(mysql_row[2]);
printf("Col1: %s \nCol2: %s \nCol3: %s \n", tmp_col1.c_str(), tmp_col2.c_str(), tmp_col3.c_str());

//SEE strings longer than 250 are truncated.
[24 Feb 2005 0:11] Hartmut Holzgraefe
C test program

Attachment: mytest.c (text/plain), 1.23 KiB.

[24 Feb 2005 0:19] Hartmut Holzgraefe
Can you please add a complete working example program?
Your's misses headers, the cfg object setup and even within the pasted code
it does not convert string_query to query ...

Anyway, using a plain C version of your code i can't reproduce the problem (on Linux).
As it does not cut data at all i'd suspect either the "string" class you're using or maybe
the printf() function to cut the actual data.

You can verify this by running the C version of the code i uploaded to this bug report
or by changing the length output line in your test code to:

  printf("Column %u is %lu bytes in length (%u).\n", i, lengths[i], strlen(mysql_row[i]);
[25 Mar 2005 0: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".