Commit 65888585 authored by unknown's avatar unknown

Merge zippy.(none):/home/cmiller/work/mysql/merge/tmp_merge

into  zippy.(none):/home/cmiller/work/mysql/merge/mysql-5.1-new


client/mysql.cc:
  Auto merged
mysql-test/t/mysql.test:
  Auto merged
parents 3e21b9d0 10633fd8
...@@ -185,7 +185,7 @@ void tee_fprintf(FILE *file, const char *fmt, ...); ...@@ -185,7 +185,7 @@ void tee_fprintf(FILE *file, const char *fmt, ...);
void tee_fputs(const char *s, FILE *file); void tee_fputs(const char *s, FILE *file);
void tee_puts(const char *s, FILE *file); void tee_puts(const char *s, FILE *file);
void tee_putc(int c, FILE *file); void tee_putc(int c, FILE *file);
static void tee_print_sized_data(const char *data, unsigned int length, unsigned int width); static void tee_print_sized_data(const char *, unsigned int, unsigned int, bool);
/* The names of functions that actually do the manipulation. */ /* The names of functions that actually do the manipulation. */
static int get_options(int argc,char **argv); static int get_options(int argc,char **argv);
static int com_quit(String *str,char*), static int com_quit(String *str,char*),
...@@ -2311,35 +2311,52 @@ print_table_data(MYSQL_RES *result) ...@@ -2311,35 +2311,52 @@ print_table_data(MYSQL_RES *result)
while ((cur= mysql_fetch_row(result))) while ((cur= mysql_fetch_row(result)))
{ {
ulong *lengths= mysql_fetch_lengths(result); ulong *lengths= mysql_fetch_lengths(result);
(void) tee_fputs("|", PAGER); (void) tee_fputs("| ", PAGER);
mysql_field_seek(result, 0); mysql_field_seek(result, 0);
for (uint off= 0; off < mysql_num_fields(result); off++) for (uint off= 0; off < mysql_num_fields(result); off++)
{ {
const char *str= cur[off] ? cur[off] : "NULL"; const char *buffer;
uint currlength; uint data_length;
uint maxlength; uint field_max_length;
uint numcells; bool right_justified;
uint visible_length;
field= mysql_fetch_field(result); uint extra_padding;
maxlength= field->max_length;
currlength= (uint) lengths[off]; if (lengths[off] == 0)
numcells= charset_info->cset->numcells(charset_info, {
str, str + currlength); buffer= "NULL";
if (maxlength > MAX_COLUMN_LENGTH) data_length= 4;
}
else
{ {
tee_print_sized_data(str, currlength, maxlength); buffer= cur[off];
tee_fputs(" |", PAGER); data_length= (uint) lengths[off];
} }
field= mysql_fetch_field(result);
field_max_length= field->max_length;
/*
How many text cells on the screen will this string span? If it contains
multibyte characters, then the number of characters we occupy on screen
will be fewer than the number of bytes we occupy in memory.
We need to find how much screen real-estate we will occupy to know how
many extra padding-characters we should send with the printing function.
*/
visible_length= charset_info->cset->numcells(charset_info, buffer, buffer + data_length);
extra_padding= data_length - visible_length;
if (field_max_length > MAX_COLUMN_LENGTH)
tee_print_sized_data(buffer, data_length, MAX_COLUMN_LENGTH+extra_padding, FALSE);
else else
{ {
if (num_flag[off] != 0) if (num_flag[off] != 0) /* if it is numeric, we right-justify it */
tee_fprintf(PAGER, " %-*s|", maxlength + currlength - numcells, str); tee_print_sized_data(buffer, data_length, field_max_length+extra_padding, TRUE);
else else
{ tee_print_sized_data(buffer, data_length, field_max_length+extra_padding, FALSE);
tee_print_sized_data(str, currlength, maxlength);
tee_fputs(" |", PAGER);
}
} }
tee_fputs(" | ", PAGER);
} }
(void) tee_fputs("\n", PAGER); (void) tee_fputs("\n", PAGER);
} }
...@@ -2349,10 +2366,9 @@ print_table_data(MYSQL_RES *result) ...@@ -2349,10 +2366,9 @@ print_table_data(MYSQL_RES *result)
static void static void
tee_print_sized_data(const char *data, unsigned int length, unsigned int width) tee_print_sized_data(const char *data, unsigned int data_length, unsigned int total_bytes_to_send, bool right_justified)
{ {
/* /*
It is not a number, so print each character justified to the left.
For '\0's print ASCII spaces instead, as '\0' is eaten by (at For '\0's print ASCII spaces instead, as '\0' is eaten by (at
least my) console driver, and that messes up the pretty table least my) console driver, and that messes up the pretty table
grid. (The \0 is also the reason we can't use fprintf() .) grid. (The \0 is also the reason we can't use fprintf() .)
...@@ -2360,9 +2376,14 @@ tee_print_sized_data(const char *data, unsigned int length, unsigned int width) ...@@ -2360,9 +2376,14 @@ tee_print_sized_data(const char *data, unsigned int length, unsigned int width)
unsigned int i; unsigned int i;
const char *p; const char *p;
tee_putc(' ', PAGER); total_bytes_to_send -= 1;
/* Off by one, perhaps mistakenly accounting for a terminating NUL. */
if (right_justified)
for (i= 0; i < (total_bytes_to_send - data_length); i++)
tee_putc((int)' ', PAGER);
for (i= 0, p= data; i < length; i+= 1, p+= 1) for (i= 0, p= data; i < data_length; i+= 1, p+= 1)
{ {
if (*p == '\0') if (*p == '\0')
tee_putc((int)' ', PAGER); tee_putc((int)' ', PAGER);
...@@ -2370,9 +2391,9 @@ tee_print_sized_data(const char *data, unsigned int length, unsigned int width) ...@@ -2370,9 +2391,9 @@ tee_print_sized_data(const char *data, unsigned int length, unsigned int width)
tee_putc((int)*p, PAGER); tee_putc((int)*p, PAGER);
} }
i+= 1; if (! right_justified)
for ( ; i < width; i+= 1) for (i= 0; i < (total_bytes_to_send - data_length); i++)
tee_putc((int)' ', PAGER); tee_putc((int)' ', PAGER);
} }
...@@ -3360,7 +3381,7 @@ put_info(const char *str,INFO_TYPE info_type, uint error, const char *sqlstate) ...@@ -3360,7 +3381,7 @@ put_info(const char *str,INFO_TYPE info_type, uint error, const char *sqlstate)
if (info_type == INFO_ERROR) if (info_type == INFO_ERROR)
{ {
if (!opt_nobeep) if (!opt_nobeep)
putchar('\007'); /* This should make a bell */ putchar('\a'); /* This should make a bell */
vidattr(A_STANDOUT); vidattr(A_STANDOUT);
if (error) if (error)
{ {
......
...@@ -72,7 +72,16 @@ c_cp932 ...@@ -72,7 +72,16 @@ c_cp932
+----------------------+------------+--------+ +----------------------+------------+--------+
| concat('>',col1,'<') | col2 | col3 | | concat('>',col1,'<') | col2 | col3 |
+----------------------+------------+--------+ +----------------------+------------+--------+
| >a < | b | 123421 | | >a < | b | 123421 |
| >a < | 0123456789 | 4 | | >a < | 0123456789 | 4 |
| >abcd< | | 4 | | >abcd< | NULL | 4 |
+----------------------+------------+--------+ +----------------------+------------+--------+
+------+------+---------------------------+
| i | j | k |
+------+------+---------------------------+
| 1 | NULL | NULL |
| NULL | NULL | <-----------------------> |
| NULL | NULL | <----- |
| NULL | NULL | Τη γλώσσα |
| NULL | NULL | ᛖᚴ ᚷᛖᛏ |
+------+------+---------------------------+
...@@ -61,3 +61,9 @@ drop table t1; ...@@ -61,3 +61,9 @@ drop table t1;
# Bug#16859 -- NULLs in columns must not truncate data as if a C-language "string". # Bug#16859 -- NULLs in columns must not truncate data as if a C-language "string".
# #
--exec $MYSQL -t test -e "create table t1 (col1 binary(4), col2 varchar(10), col3 int); insert into t1 values ('a', 'b', 123421),('a ', '0123456789', 4), ('abcd', '', 4); select concat('>',col1,'<'), col2, col3 from t1; drop table t1;" 2>&1 --exec $MYSQL -t test -e "create table t1 (col1 binary(4), col2 varchar(10), col3 int); insert into t1 values ('a', 'b', 123421),('a ', '0123456789', 4), ('abcd', '', 4); select concat('>',col1,'<'), col2, col3 from t1; drop table t1;" 2>&1
#
# Bug#18265 -- mysql client: No longer right-justifies numeric columns
#
--exec $MYSQL -t --default-character-set utf8 test -e "create table t1 (i int, j int, k char(25) charset utf8); insert into t1 (i) values (1); insert into t1 (k) values ('<----------------------->'); insert into t1 (k) values ('<-----'); insert into t1 (k) values ('Τη γλώσσα'); insert into t1 (k) values ('ᛖᚴ ᚷᛖᛏ'); select * from t1; DROP TABLE t1;"
...@@ -384,11 +384,10 @@ MY_DIR *my_dir(const char *path, myf MyFlags) ...@@ -384,11 +384,10 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
DBUG_PRINT("my",("path: '%s' stat: %d MyFlags: %d",path,MyFlags)); DBUG_PRINT("my",("path: '%s' stat: %d MyFlags: %d",path,MyFlags));
/* Put LIB-CHAR as last path-character if not there */ /* Put LIB-CHAR as last path-character if not there */
tmp_file=tmp_path; tmp_file=tmp_path;
if (!*path) if (!*path)
*tmp_file++ ='.'; /* From current dir */ *tmp_file++ ='.'; /* From current dir */
tmp_file= strmov(tmp_file,path); tmp_file= strnmov(tmp_file, path, FN_REFLEN-5);
if (tmp_file[-1] == FN_DEVCHAR) if (tmp_file[-1] == FN_DEVCHAR)
*tmp_file++= '.'; /* From current dev-dir */ *tmp_file++= '.'; /* From current dev-dir */
if (tmp_file[-1] != FN_LIBCHAR) if (tmp_file[-1] != FN_LIBCHAR)
...@@ -424,7 +423,7 @@ MY_DIR *my_dir(const char *path, myf MyFlags) ...@@ -424,7 +423,7 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
if ((handle=_findfirst(tmp_path,&find)) == -1L) if ((handle=_findfirst(tmp_path,&find)) == -1L)
#endif #endif
{ {
DBUG_PRINT("info", ("find_first returned error")); DBUG_PRINT("info", ("findfirst returned error, errno: %d", errno));
if (errno != EINVAL) if (errno != EINVAL)
goto error; goto error;
/* /*
...@@ -433,72 +432,76 @@ MY_DIR *my_dir(const char *path, myf MyFlags) ...@@ -433,72 +432,76 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
continue and return zero files in dir continue and return zero files in dir
*/ */
} }
else
do
{ {
do
{
#ifdef __BORLANDC__ #ifdef __BORLANDC__
attrib= find.ff_attrib; attrib= find.ff_attrib;
#else #else
attrib= find.attrib; attrib= find.attrib;
/* /*
Do not show hidden and system files which Windows sometimes create. Do not show hidden and system files which Windows sometimes create.
Note. Because Borland's findfirst() is called with the third Note. Because Borland's findfirst() is called with the third
argument = 0 hidden/system files are excluded from the search. argument = 0 hidden/system files are excluded from the search.
*/ */
if (attrib & (_A_HIDDEN | _A_SYSTEM)) if (attrib & (_A_HIDDEN | _A_SYSTEM))
continue; continue;
#endif #endif
#ifdef __BORLANDC__ #ifdef __BORLANDC__
if (!(finfo.name= strdup_root(names_storage, find.ff_name))) if (!(finfo.name= strdup_root(names_storage, find.ff_name)))
goto error; goto error;
#else #else
if (!(finfo.name= strdup_root(names_storage, find.name))) if (!(finfo.name= strdup_root(names_storage, find.name)))
goto error;
#endif
if (MyFlags & MY_WANT_STAT)
{
if (!(finfo.mystat= (MY_STAT*)alloc_root(names_storage,
sizeof(MY_STAT))))
goto error; goto error;
#endif
bzero(finfo.mystat, sizeof(MY_STAT)); if (MyFlags & MY_WANT_STAT)
{
if (!(finfo.mystat= (MY_STAT*)alloc_root(names_storage,
sizeof(MY_STAT))))
goto error;
bzero(finfo.mystat, sizeof(MY_STAT));
#ifdef __BORLANDC__ #ifdef __BORLANDC__
finfo.mystat->st_size=find.ff_fsize; finfo.mystat->st_size=find.ff_fsize;
#else #else
finfo.mystat->st_size=find.size; finfo.mystat->st_size=find.size;
#endif #endif
mode=MY_S_IREAD; mode= MY_S_IREAD;
if (!(attrib & _A_RDONLY)) if (!(attrib & _A_RDONLY))
mode|=MY_S_IWRITE; mode|= MY_S_IWRITE;
if (attrib & _A_SUBDIR) if (attrib & _A_SUBDIR)
mode|=MY_S_IFDIR; mode|= MY_S_IFDIR;
finfo.mystat->st_mode=mode; finfo.mystat->st_mode= mode;
#ifdef __BORLANDC__ #ifdef __BORLANDC__
finfo.mystat->st_mtime=((uint32) find.ff_ftime); finfo.mystat->st_mtime= ((uint32) find.ff_ftime);
#else #else
finfo.mystat->st_mtime=((uint32) find.time_write); finfo.mystat->st_mtime= ((uint32) find.time_write);
#endif #endif
} }
else else
finfo.mystat= NULL; finfo.mystat= NULL;
if (push_dynamic(dir_entries_storage, (gptr)&finfo)) if (push_dynamic(dir_entries_storage, (gptr)&finfo))
goto error; goto error;
}
#ifdef __BORLANDC__ #ifdef __BORLANDC__
} while (findnext(&find) == 0); while (findnext(&find) == 0);
#else #else
} while (_findnext(handle,&find) == 0); while (_findnext(handle,&find) == 0);
_findclose(handle); _findclose(handle);
#endif #endif
}
result->dir_entry= (FILEINFO *)dir_entries_storage->buffer; result->dir_entry= (FILEINFO *)dir_entries_storage->buffer;
result->number_off_files= dir_entries_storage->elements; result->number_off_files= dir_entries_storage->elements;
if (!(MyFlags & MY_DONT_SORT)) if (!(MyFlags & MY_DONT_SORT))
qsort((void *) result->dir_entry, result->number_off_files, qsort((void *) result->dir_entry, result->number_off_files,
sizeof(FILEINFO), (qsort_cmp) comp_names); sizeof(FILEINFO), (qsort_cmp) comp_names);
DBUG_PRINT(exit, ("found %d files", result->number_off_files));
DBUG_RETURN(result); DBUG_RETURN(result);
error: error:
my_errno=errno; my_errno=errno;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment