Commit 9d120741 authored by monty@donna.mysql.com's avatar monty@donna.mysql.com
Browse files

Portability fixes

Changed TRUNCATE table_name -> TRUNCATE TABLE table_name
parent a2c2c9dc
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -18849,7 +18849,7 @@ the @code{LIMIT} value.
@section @code{TRUNCATE} Syntax
@example
TRUNCATE table_name
TRUNCATE TABLE table_name
@end example
Is in 3.23 and the same thing as @code{DELETE FROM table_name}. @xref{DELETE}.
@@ -18860,7 +18860,7 @@ The differences are:
Implemented as a drop and re-create of the table, which makes this
much faster when deleting many rows.
@item
Not transaction-safe; @code{TRUNCATE} will automaticly end the current
Not transaction-safe; @code{TRUNCATE TABLE} will automaticly end the current
transaction as if @code{COMMIT} would have been called.
@item
Doesn't return the number of deleted rows.
@@ -27519,7 +27519,7 @@ This can be done with the following code:
@example
mysql> LOCK TABLES real_table WRITE, insert_table WRITE;
mysql> insert into real_table select * from insert_table;
mysql> TRUNCATE insert_table;
mysql> TRUNCATE TABLE insert_table;
mysql> UNLOCK TABLES;
@end example
@@ -28411,7 +28411,7 @@ it is very important to @code{OPTIMIZE TABLE} sometimes.
@subsection Speed of @code{DELETE} Queries
If you want to delete all rows in the table, you should use
@code{TRUNCATE table_name}. @xref{TRUNCATE}.
@code{TRUNCATE TABLE table_name}. @xref{TRUNCATE}.
The time to delete a record is exactly proportional to the number of
indexes. To delete records more quickly, you can increase the size of
@@ -31651,11 +31651,11 @@ Use the table description file to create new (empty) data and index files:
@example
shell> mysql db_name
mysql> SET AUTOCOMMIT=1;
mysql> TRUNCATE table_name;
mysql> TRUNCATE TABLE table_name;
mysql> quit
@end example
If your SQL version doesn't have @code{TRUNCATE}, use @code{DELETE FROM
If your SQL version doesn't have @code{TRUNCATE TABLE}, use @code{DELETE FROM
table_name} instead.
@item
@@ -40987,6 +40987,10 @@ not yet 100 % confident in this code.
@appendixsubsec Changes in release 3.23.33
@itemize bullet
@item
Changed @code{TRUNCATE table_name} to @code{TRUNCATE TABLE table_name}
to use the same syntax as Oracle.  Until 4.0 we will also allow
@code{TRUNCATE table_name} to not crash old code.
@item
Fixed 'no found rows' bug in @code{MyISAM} tables when a @code{BLOB} was
first part of a multi-part key.
@item
+12 −2
Original line number Diff line number Diff line
@@ -41,6 +41,9 @@

const char *VER="11.12";

/* Don't try to make a nice table if the data is too big */
#define MAX_COLUMN_LENGTH	     1024

gptr sql_alloc(unsigned size);	     // Don't use mysqld alloc for these
void sql_element_free(void *ptr);
#include "sql_string.h"
@@ -1546,7 +1549,8 @@ print_table_data(MYSQL_RES *result)
    (void) tee_fputs("|", PAGER);
    for (uint off=0; (field = mysql_fetch_field(result)) ; off++)
    {
      tee_fprintf(PAGER, " %-*s|",field->max_length,field->name);
      tee_fprintf(PAGER, " %-*s|",min(field->max_length,MAX_COLUMN_LENGTH),
		  field->name);
      num_flag[off]= IS_NUM(field->type);
    }
    (void) tee_fputs("\n", PAGER);
@@ -1559,10 +1563,16 @@ print_table_data(MYSQL_RES *result)
    mysql_field_seek(result,0);
    for (uint off=0 ; off < mysql_num_fields(result); off++)
    {
      const char *str=cur[off] ? cur[off] : "NULL";
      field = mysql_fetch_field(result);
      uint length=field->max_length;
      if (length > MAX_COLUMN_LENGTH)
      {
	tee_fputs(str,PAGER); tee_fputs(" |",PAGER);
      }
      else
      tee_fprintf(PAGER, num_flag[off] ? "%*s |" : " %-*s|",
		  length,cur[off] ? (char*) cur[off] : "NULL");
		  length, str);
    }
    (void) tee_fputs("\n", PAGER);
  }
+8 −0
Original line number Diff line number Diff line
@@ -18,6 +18,10 @@
/* thread safe version of some common functions */

/* for thread safe my_inet_ntoa */
#ifdef	__cplusplus
extern "C" {
#endif /* __cplusplus */

#if !defined(MSDOS) && !defined(__WIN__) && !defined(__BEOS__)
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
@@ -31,3 +35,7 @@
#endif /* !defined(MSDOS) && !defined(__WIN__) */

void my_inet_ntoa(struct in_addr in, char *buf);

#ifdef	__cplusplus
}
#endif
+1 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
# Test of truncate
#
create table t1 (a integer, b integer,c1 CHAR(10));
truncate t1;
truncate table t1;
select count(*) from t1;
insert into t1 values(1,2,"test");
select count(*) from t1;
+1 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@
#  include "ansi_stdlib.h"
#endif /* HAVE_STDLIB_H */

#include <time.h>
#if defined (HAVE_SELECT)
#  if !defined (HAVE_SYS_SELECT_H) || !defined (M_UNIX)
#    include <sys/time.h>
Loading