~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzle.cc

  • Committer: Monty Taylor
  • Date: 2008-10-23 23:53:49 UTC
  • mto: This revision was merged to the branch mainline in revision 557.
  • Revision ID: monty@inaugust.com-20081023235349-317wgwqwgccuacmq
SplitĀ outĀ nested_join.h.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
 *
34
34
 **/
35
35
 
36
 
#include "config.h"
 
36
#include <config.h>
37
37
 
38
38
#include <string>
39
39
 
40
40
#include "client_priv.h"
41
41
#include <mystrings/m_ctype.h>
42
42
#include <stdarg.h>
43
 
#ifndef __GNU_LIBRARY__
44
 
#define __GNU_LIBRARY__          // Skip warnings in getopt.h
45
 
#endif
46
43
#include <readline/history.h>
47
44
#include "my_readline.h"
48
45
#include <signal.h>
53
50
#include <locale.h>
54
51
#endif
55
52
 
56
 
#include <libdrizzle/gettext.h>
 
53
#include <drizzled/gettext.h>
57
54
 
58
55
const char *VER= "14.14";
59
56
 
63
60
/* Buffer to hold 'version' and 'version_comment' */
64
61
#define MAX_SERVER_VERSION_LENGTH     128
65
62
 
66
 
/* Array of options to pass to libdrizzled */
67
 
#define MAX_SERVER_ARGS               64
68
 
 
69
63
void* sql_alloc(unsigned size);       // Don't use drizzled alloc for these
70
64
void sql_element_free(void *ptr);
71
65
 
610
604
  { "QUARTER", 0, 0, 0, ""},
611
605
  { "QUERY", 0, 0, 0, ""},
612
606
  { "QUICK", 0, 0, 0, ""},
613
 
  { "RAID0", 0, 0, 0, ""},
614
 
  { "RAID_CHUNKS", 0, 0, 0, ""},
615
 
  { "RAID_CHUNKSIZE", 0, 0, 0, ""},
616
 
  { "RAID_TYPE", 0, 0, 0, ""},
617
607
  { "READ", 0, 0, 0, ""},
618
608
  { "READS", 0, 0, 0, ""},
619
609
  { "REAL", 0, 0, 0, ""},
2505
2495
{
2506
2496
  DRIZZLE_ROW cur;
2507
2497
  const char *server_cmd= buffer->c_str();
2508
 
  char cmd_buf[100];
 
2498
  string cmd_buf;
2509
2499
  DRIZZLE_RES *result;
2510
2500
  int error;
2511
2501
 
 
2502
  cmd_buf.reserve(100);
2512
2503
  if (help_arg[0] != '\'')
2513
2504
  {
2514
2505
    char *end_arg= strchr(help_arg, '\0');
2518
2509
        end_arg--;
2519
2510
      *++end_arg= '\0';
2520
2511
    }
2521
 
    (void) strxnmov(cmd_buf, sizeof(cmd_buf), "help '", help_arg, "'", NULL);
2522
 
    server_cmd= cmd_buf;
 
2512
    cmd_buf.append("help '");
 
2513
    cmd_buf.append(help_arg);
 
2514
    cmd_buf.append("'");
 
2515
  
 
2516
    server_cmd= cmd_buf.c_str();
2523
2517
  }
2524
2518
 
2525
2519
  if (!connected && reconnect())
2867
2861
    case DRIZZLE_TYPE_TIME:        return "TIME";
2868
2862
    case DRIZZLE_TYPE_TIMESTAMP:   return "TIMESTAMP";
2869
2863
    case DRIZZLE_TYPE_TINY:        return "TINY";
 
2864
    case DRIZZLE_TYPE_VIRTUAL:     return "VIRTUAL";
2870
2865
    default:                     return "?-unknown-?";
2871
2866
  }
2872
2867
}
3507
3502
  end[0]=0;
3508
3503
  unpack_filename(source_name,source_name);
3509
3504
  /* open file name */
3510
 
  if (!(sql_file = my_fopen(source_name, O_RDONLY | O_BINARY,MYF(0))))
 
3505
  if (!(sql_file = my_fopen(source_name, O_RDONLY,MYF(0))))
3511
3506
  {
3512
3507
    char buff[FN_REFLEN+60];
3513
3508
    sprintf(buff,"Failed to open file '%s', error: %d", source_name,errno);
3868
3863
static const char *
3869
3864
server_version_string(DRIZZLE *con)
3870
3865
{
3871
 
  static char buf[MAX_SERVER_VERSION_LENGTH] = "";
 
3866
  static string buf("");
 
3867
  static bool server_version_string_reserved= false;
3872
3868
 
 
3869
  if (!server_version_string_reserved)
 
3870
  {
 
3871
    buf.reserve(MAX_SERVER_VERSION_LENGTH);
 
3872
    server_version_string_reserved= true;
 
3873
  }
3873
3874
  /* Only one thread calls this, so no synchronization is needed */
3874
3875
  if (buf[0] == '\0')
3875
3876
  {
3876
 
    char *bufp = buf;
3877
3877
    DRIZZLE_RES *result;
3878
3878
 
3879
 
    bufp= my_stpncpy(buf, drizzle_get_server_info(con), sizeof buf);
 
3879
    buf.append(drizzle_get_server_info(con));
3880
3880
 
3881
3881
    /* "limit 1" is protection against SQL_SELECT_LIMIT=0 */
3882
3882
    if (!drizzle_query(con, "select @@version_comment limit 1") &&
3885
3885
      DRIZZLE_ROW cur = drizzle_fetch_row(result);
3886
3886
      if (cur && cur[0])
3887
3887
      {
3888
 
        bufp = strxnmov(bufp, sizeof buf - (bufp - buf), " ", cur[0], NULL);
 
3888
        buf.append(" ");
 
3889
        buf.append(cur[0]);
3889
3890
      }
3890
3891
      drizzle_free_result(result);
3891
3892
    }
3892
 
 
3893
 
    /* str*nmov doesn't guarantee NUL-termination */
3894
 
    if (bufp == buf + sizeof buf)
3895
 
      buf[sizeof buf - 1] = '\0';
3896
3893
  }
3897
3894
 
3898
 
  return buf;
 
3895
  return buf.c_str();
3899
3896
}
3900
3897
 
3901
3898
static int