Commit 05597586 authored by monty@tik.mysql.fi's avatar monty@tik.mysql.fi
Browse files

Added support for ANSI SQL X'hex-string' format.

Fixed mysqldump to use -- instead of # as comment characters.
Removed support for the 3.20 protocol format
parent 0b8f1595
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -14374,12 +14374,16 @@ like an integer (64-bit precision). In string context these act like a binary
string where each pair of hex digits is converted to a character:
@example
mysql> SELECT x'FF'
       -> 255
mysql> SELECT 0xa+0;
       -> 10
mysql> select 0x5061756c;
       -> Paul
@end example
The x'hexstring' syntax (new in 4.0) is based on ANSI SQL and the 0x
syntax is based on ODBC.
Hexadecimal strings are often used by ODBC to give values for BLOB columns.
@tindex NULL value
@@ -46427,6 +46431,8 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}.
@itemize @bullet
@item
Allow ANSI SQL syntax @code{X'hexadecimal-number'}
@item
Added @code{ALTER TABLE table_name DISABLE KEYS} and
      @code{ALTER TABLE table_name ENABLE KEYS} commands.
@item
+13 −13
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@
**   Tnu Samuel  <tonu@please.do.not.remove.this.spam.ee>
**/

#define DUMP_VERSION "8.14"
#define DUMP_VERSION "8.15"

#include <global.h>
#include <my_sys.h>
@@ -274,12 +274,12 @@ puts("\

static void write_heder(FILE *sql_file, char *db_name)
{
  fprintf(sql_file, "# MySQL dump %s\n#\n", DUMP_VERSION);
  fprintf(sql_file, "# Host: %s    Database: %s\n",
  fprintf(sql_file, "-- MySQL dump %s\n#\n", DUMP_VERSION);
  fprintf(sql_file, "-- Host: %s    Database: %s\n",
	  current_host ? current_host : "localhost", db_name ? db_name : "");
  fputs("#--------------------------------------------------------\n",
  fputs("---------------------------------------------------------\n",
  sql_file);
  fprintf(sql_file, "# Server version\t%s\n",
  fprintf(sql_file, "-- Server version\t%s\n",
	  mysql_get_server_info(&mysql_connection));
  return;
} /* write_heder */
@@ -515,7 +515,7 @@ static int dbConnect(char *host, char *user,char *passwd)
  DBUG_ENTER("dbConnect");
  if (verbose)
  {
    fprintf(stderr, "# Connecting to %s...\n", host ? host : "localhost");
    fprintf(stderr, "-- Connecting to %s...\n", host ? host : "localhost");
  }
  mysql_init(&mysql_connection);
  if (opt_compress)
@@ -542,7 +542,7 @@ static int dbConnect(char *host, char *user,char *passwd)
static void dbDisconnect(char *host)
{
  if (verbose)
    fprintf(stderr, "# Disconnecting from %s...\n", host ? host : "localhost");
    fprintf(stderr, "-- Disconnecting from %s...\n", host ? host : "localhost");
  mysql_close(sock);
} /* dbDisconnect */

@@ -608,7 +608,7 @@ static uint getTableStructure(char *table, char* db)
  delayed= opt_delayed ? " DELAYED " : "";

  if (verbose)
    fprintf(stderr, "# Retrieving table structure for table %s...\n", table);
    fprintf(stderr, "-- Retrieving table structure for table %s...\n", table);

  sprintf(insert_pat,"SET OPTION SQL_QUOTE_SHOW_CREATE=%d", opt_quoted);
  table_name=quote_name(table,table_buff);
@@ -837,7 +837,7 @@ static uint getTableStructure(char *table, char* db)
	  {					/* If old MySQL version */
	    if (verbose)
	      fprintf(stderr,
		      "# Warning: Couldn't get status information for table '%s' (%s)\n",
		      "-- Warning: Couldn't get status information for table '%s' (%s)\n",
		      table,mysql_error(sock));
	  }
        }
@@ -934,7 +934,7 @@ static void dumpTable(uint numFields, char *table)
  ulong		rownr, row_break, total_length, init_length;

  if (verbose)
    fprintf(stderr, "# Sending SELECT query...\n");
    fprintf(stderr, "-- Sending SELECT query...\n");
  if (path)
  {
    char filename[FN_REFLEN], tmp_path[FN_REFLEN];
@@ -977,10 +977,10 @@ static void dumpTable(uint numFields, char *table)
    sprintf(query, "SELECT * FROM %s", quote_name(table,table_buff));
    if (where)
    {
      fprintf(result_file,"# WHERE:  %s\n",where);
      fprintf(result_file,"-- WHERE:  %s\n",where);
      strxmov(strend(query), " WHERE ",where,NullS);
    }
    fputs("#\n\n", result_file);
    fputs("\n\n", result_file);

    if (mysql_query(sock, query))
    {
@@ -997,7 +997,7 @@ static void dumpTable(uint numFields, char *table)
      return;
    }
    if (verbose)
      fprintf(stderr, "# Retrieving rows...\n");
      fprintf(stderr, "-- Retrieving rows...\n");
    if (mysql_num_fields(res) != numFields)
    {
      fprintf(stderr,"%s: Error in field count for table: '%s' !  Aborting.\n",
+8 −13
Original line number Diff line number Diff line
@@ -322,17 +322,9 @@ net_safe_read(MYSQL *mysql)
    if (len > 3)
    {
      char *pos=(char*) net->read_pos+1;
      if (mysql->protocol_version > 9)
      {						/* New client protocol */
      net->last_errno=uint2korr(pos);
      pos+=2;
      len-=2;
      }
      else
      {
	net->last_errno=CR_UNKNOWN_ERROR;
	len--;
      }
      (void) strmake(net->last_error,(char*) pos,
		     min(len,sizeof(net->last_error)-1));
    }
@@ -1404,6 +1396,7 @@ mysql_ssl_clear(MYSQL *mysql)
** If host == 0 then use localhost
**************************************************************************/

#ifdef USE_OLD_FUNCTIONS
MYSQL * STDCALL
mysql_connect(MYSQL *mysql,const char *host,
	      const char *user, const char *passwd)
@@ -1420,6 +1413,7 @@ mysql_connect(MYSQL *mysql,const char *host,
    DBUG_RETURN(res);
  }
}
#endif


/*
@@ -1651,8 +1645,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
  DBUG_DUMP("packet",(char*) net->read_pos,10);
  DBUG_PRINT("info",("mysql protocol version %d, server=%d",
		     PROTOCOL_VERSION, mysql->protocol_version));
  if (mysql->protocol_version != PROTOCOL_VERSION &&
      mysql->protocol_version != PROTOCOL_VERSION-1)
  if (mysql->protocol_version != PROTOCOL_VERSION)
  {
    net->last_errno= CR_VERSION_ERROR;
    sprintf(net->last_error, ER(CR_VERSION_ERROR), mysql->protocol_version,
@@ -2547,6 +2540,7 @@ mysql_list_processes(MYSQL *mysql)
}


#ifdef USE_OLD_FUNCTIONS
int  STDCALL
mysql_create_db(MYSQL *mysql, const char *db)
{
@@ -2563,6 +2557,7 @@ mysql_drop_db(MYSQL *mysql, const char *db)
  DBUG_PRINT("enter",("db: %s",db));
  DBUG_RETURN(simple_command(mysql,COM_DROP_DB,db,(uint) strlen(db),0));
}
#endif


int STDCALL
+0 −2
Original line number Diff line number Diff line
@@ -258,8 +258,6 @@ static void usage(void)
  -k, --keys-used=#   Tell MyISAM to update only some specific keys. # is a\n\
	              bit mask of which keys to use. This can be used to\n\
		      get faster inserts!\n\
  -l, --no-symlinks   Do not follow symbolic links. Normally\n\
		      myisamchk repairs the table a symlink points at.\n\
  -r, --recover       Can fix almost anything except unique keys that aren't\n\
                      unique.\n\
  -n, --sort-recover  Force recovering with sorting even if the temporary\n\
+4 −0
Original line number Diff line number Diff line
@@ -2,5 +2,9 @@
A	65	9223372036854775807	-1
0x31+1	concat(0x31)+1	-0xf
50	2	-15
x'31'	X'ffff'+0
1	65535
table	type	possible_keys	key	key_len	ref	rows	Extra
t1	const	UNIQ	UNIQ	8	const	1	
x	xx
1	2
Loading