~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzle.cc

Merge from Monty's tree

Show diffs side-by-side

added added

removed removed

Lines of Context:
2495
2495
{
2496
2496
  DRIZZLE_ROW cur;
2497
2497
  const char *server_cmd= buffer->c_str();
2498
 
  char cmd_buf[100];
 
2498
  string cmd_buf;
2499
2499
  DRIZZLE_RES *result;
2500
2500
  int error;
2501
2501
 
 
2502
  cmd_buf.reserve(100);
2502
2503
  if (help_arg[0] != '\'')
2503
2504
  {
2504
2505
    char *end_arg= strchr(help_arg, '\0');
2508
2509
        end_arg--;
2509
2510
      *++end_arg= '\0';
2510
2511
    }
2511
 
    (void) strxnmov(cmd_buf, sizeof(cmd_buf), "help '", help_arg, "'", NULL);
2512
 
    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();
2513
2517
  }
2514
2518
 
2515
2519
  if (!connected && reconnect())
3859
3863
static const char *
3860
3864
server_version_string(DRIZZLE *con)
3861
3865
{
3862
 
  static char buf[MAX_SERVER_VERSION_LENGTH] = "";
 
3866
  static string buf("");
 
3867
  static bool server_version_string_reserved= false;
3863
3868
 
 
3869
  if (!server_version_string_reserved)
 
3870
  {
 
3871
    buf.reserve(MAX_SERVER_VERSION_LENGTH);
 
3872
    server_version_string_reserved= true;
 
3873
  }
3864
3874
  /* Only one thread calls this, so no synchronization is needed */
3865
3875
  if (buf[0] == '\0')
3866
3876
  {
3867
 
    char *bufp = buf;
3868
3877
    DRIZZLE_RES *result;
3869
3878
 
3870
 
    bufp= my_stpncpy(buf, drizzle_get_server_info(con), sizeof buf);
 
3879
    buf.append(drizzle_get_server_info(con));
3871
3880
 
3872
3881
    /* "limit 1" is protection against SQL_SELECT_LIMIT=0 */
3873
3882
    if (!drizzle_query(con, "select @@version_comment limit 1") &&
3876
3885
      DRIZZLE_ROW cur = drizzle_fetch_row(result);
3877
3886
      if (cur && cur[0])
3878
3887
      {
3879
 
        bufp = strxnmov(bufp, sizeof buf - (bufp - buf), " ", cur[0], NULL);
 
3888
        buf.append(" ");
 
3889
        buf.append(cur[0]);
3880
3890
      }
3881
3891
      drizzle_free_result(result);
3882
3892
    }
3883
 
 
3884
 
    /* str*nmov doesn't guarantee NUL-termination */
3885
 
    if (bufp == buf + sizeof buf)
3886
 
      buf[sizeof buf - 1] = '\0';
3887
3893
  }
3888
3894
 
3889
 
  return buf;
 
3895
  return buf.c_str();
3890
3896
}
3891
3897
 
3892
3898
static int