Commit 066d55c0 authored by monty@donna.mysql.com's avatar monty@donna.mysql.com
Browse files

Bug fixes for 3.23.23

parent d564acf1
Loading
Loading
Loading
Loading
+59 −0
Original line number Diff line number Diff line
@@ -143,6 +143,65 @@ same tables.
  and then we read the rows in the sorted order into a row buffer
  (record_buffer) .

@node Coding guidelines
@chapter Coding guidelines

- We are using bitkeeper (www.bitkeeper.com) for source management.
- You should use the MySQL 3.23 or MySQL 4.0 source for all developments.
- If you have any questions about the MySQL source, you can post these
  to developers@mysql.com and we will answer them.
  Note that we will shortly change the name of this list to
  internals@mysql.com, to more accurately reflect what should be
  posted to this list.

- Try to write code in a lot of black boxes that can be reused or at
  least have a clean interface
- Reuse code;  There is already in MySQL a lot of algorithms for list handling,
  queues, dynamic and hashed arrays, sorting...) that can be reused.
- Try to always write optimized code, so that you don't have to
  go back and rewrite it a couple of months later.  It's better to
  spend 3 times as much time designing and writing and optimal function than
  having to do it all over again later on.
- Avoid CPU wasteful code, even where it does not matter, so that
  you will not develop sloppy coding habits.
- If you can write it in fewer lines, do it (as long as the code will not
  be slower or much harder to read)
- do not check the same pointer for NULL more than once.
- Use long function and variable names in English;  This makes your
  code easier to read.
- Think assembly - make it easier for the compiler to optimize your code.
- Comment your code when you do something that someone else may think
  is 'not trivial'.
- Use the my_ functions like my_read/my_write/my_malloc() that you can
  find in the mysys library instead of the direct system calls;  This
  will make your code easier to debug and more portable.
- use libstring functions instead of standard libc string functions
  whenever possible
- Avoid using alloc (its REAL slow);  For memory allocations that only
  needs to live for the lifetime of one thread, on should use
  sql_alloc() instead.
- Before doing big design decision, please first post a summary of
  what you want to do, why you want to do it and how you plan to do
  it.  This way we can easily provide you with feedback and also
  easily discuss is throughly if some other developer thinks there is better
  way to do the same thing!

- Use my_var as opposed to myVar or MyVar ( _ rather than dancing SHIFT
  to spearate words in identifiers)
- class names start with a capital 
- structure types are typedefed to all caps identifier
- #defines are capitalized
- matching { are in the same column
 - functions return 0 on success , non-zero on error, so you can do
  if(a() || b() || c()) { error("something went wrong");}
- goto is ok if not abused
- avoid default variable initalizations, use LINT_INIT() if the
  compiler complains after making sure that there is really no way
  the variable can be used uninitialized
- Do not instantiate a class if you do not have to
- Use pointers rather than array indexing when operating on strings


@node Index
@unnumbered Index

+276 −148

File changed.

Preview size limit exceeded, changes collapsed.

+18 −8
Original line number Diff line number Diff line
@@ -114,7 +114,7 @@ static bool info_flag=0,ignore_errors=0,wait_flag=0,quick=0,
	    no_rehash=0,skip_updates=0,safe_updates=0,one_database=0,
	    opt_compress=0,
	    vertical=0,skip_line_numbers=0,skip_column_names=0,opt_html=0,
	    no_named_cmds=0;
            no_named_cmds=1; // we want this to be the default
static uint verbose=0,opt_silent=0,opt_mysql_port=0;
static my_string opt_mysql_unix_port=0;
static int connect_flag=CLIENT_INTERACTIVE;
@@ -160,7 +160,7 @@ typedef struct {

static COMMANDS commands[] = {
  { "help",   'h', com_help,   0, "Display this text" },
  { "?",      'h', com_help,   0, "Synonym for `help'" },
  { "?",      '?', com_help,   0, "Synonym for `help'" },
  { "clear",  'c', com_clear,  0, "Clear command"},
  { "connect",'r', com_connect,1,
    "Reconnect to the server. Optional arguments are db and host" },
@@ -300,7 +300,7 @@ int main(int argc,char *argv[])
    }
  }
#endif
  sprintf(buff, "Type '%s' for help.\n", no_named_cmds ? "\\h" : "help");
  sprintf(buff, "Type 'help;' or '\\h' for help.\n");
  put_info(buff,INFO_INFO);
  status.exit_status=read_lines(1);		// read lines and execute them
  mysql_end(0);
@@ -352,6 +352,7 @@ static struct option long_options[] =
  {"database",	    required_argument,     0, 'D'},
  {"debug-info",    no_argument,	   0, 'T'},
  {"default-character-set", required_argument,  0, OPT_DEFAULT_CHARSET},
  {"enable-named-commands", no_argument,   0, 'G'},
  {"execute",	    required_argument,	   0, 'e'},
  {"force",	    no_argument,	   0, 'f'},
  {"help",	    no_argument,	   0, '?'},
@@ -401,7 +402,7 @@ CHANGEABLE_VAR changeable_vars[] = {

static void usage(int version)
{
  printf("%s  Ver 10.8 Distrib %s, for %s (%s)\n",
  printf("%s  Ver 10.10 Distrib %s, for %s (%s)\n",
	 my_progname, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE);
  if (version)
    return;
@@ -426,11 +427,17 @@ static void usage(int version)
  -D, --database=..	Database to use.\n\
  --default-character-set=...\n\
                        Set the default character set.\n\
  -G, --enable-named-commands\n\
                        Named commands are enabled. Opposite to -g.\n\
  -e, --execute=...     Execute command and quit. (Output like with --batch)\n\
  -E, --vertical        Print the output of a query (rows) vertically.\n\
  -f, --force           Continue even if we get an sql error.\n\
  -g, --no-named-commands\n\
			Named commands are disabled. Use \\* form only.\n\
			Named commands are disabled. Use \\* form only, or\n\
                        use named commands only in the beginning of a line\n\
                        ending with a semicolon (;)\n\
                        Since version 10.9 the client now starts with this\n\
                        option ENABLED by default! Disable with '-G'\n\
  -i, --ignore-space	Ignore space after function names.\n\
  -h, --host=...	Connect to host.\n\
  -H, --html		Produce HTML output.\n\
@@ -486,7 +493,7 @@ static int get_options(int argc, char **argv)
  bool tty_password=0;

  set_all_changeable_vars(changeable_vars);
  while ((c=getopt_long(argc,argv,"?ABCD:LfgHinNoqrstTUvVwWEe:h:O:P:S:u:#::p::",
  while ((c=getopt_long(argc,argv,"?ABCD:LfgGHinNoqrstTUvVwWEe:h:O:P:S:u:#::p::",
			long_options, &option_index)) != EOF)
  {
    switch(c) {
@@ -565,6 +572,7 @@ static int get_options(int argc, char **argv)
    case 'E': vertical=1; break;
    case 'w': wait_flag=1; break;
    case 'A': no_rehash=1; break;
    case 'G': no_named_cmds=0; break;
    case 'g': no_named_cmds=1; break;
    case 'H': opt_html=1; break;
    case 'i': connect_flag|= CLIENT_IGNORE_SPACE; break;
@@ -1171,11 +1179,13 @@ com_help (String *buffer __attribute__((unused)),
  reg1 int i;

  put_info("\nMySQL commands:",INFO_INFO);
  if (no_named_cmds)
    put_info("Note that all text commands must be first on line and end with ';'",INFO_INFO);
  for (i = 0; commands[i].name; i++)
  {
    if (commands[i].func)
      printf("%s\t(\\%c)\t%s\n", commands[i].name,commands[i].cmd_char,
	     commands[i].doc);
      printf("%s\t(\\%c)\t%s\n", commands[i].name,
	     commands[i].cmd_char, commands[i].doc);
  }
  if (connected)
    printf("\nConnection id: %ld  (Can be used with mysqladmin kill)\n\n",
+1 −2
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@
**			   *			   *
**			   *************************
*/
#define IMPORT_VERSION "2.3"
#define IMPORT_VERSION "2.4"

#include <global.h>
#include <my_sys.h>
@@ -514,7 +514,6 @@ int main(int argc, char **argv)
	exitcode = error;
  db_disconnect(current_host, sock);
  my_free(password,MYF(MY_ALLOW_ZERO_PTR));
  my_free(current_user,MYF(MY_ALLOW_ZERO_PTR));
  free_defaults(argv_to_free);
  my_end(0);
  return(exitcode);
+2 −0
Original line number Diff line number Diff line
@@ -250,6 +250,8 @@ inline double ulonglong2double(ulonglong value)
#define HAVE_RINT               /* defined in this file */
#define NO_FCNTL_NONBLOCK       /* No FCNTL */
#define HAVE_ALLOCA
#define HAVE_STRPBRK
#define HAVE_STRSTR
#define HAVE_COMPRESS

#ifdef NOT_USED
Loading