~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzle.cc

  • Committer: Monty Taylor
  • Author(s): Andrew Hutchings
  • Date: 2011-02-21 14:56:10 UTC
  • mto: This revision was merged to the branch mainline in revision 2190.
  • Revision ID: andrew@linuxjedi.co.uk-20110221145610-rasgqsugv890e3d4
Fix BOOLEAN type for batch mode

Show diffs side-by-side

added added

removed removed

Lines of Context:
3542
3542
  drizzle_return_t ret;
3543
3543
  drizzle_column_st *field;
3544
3544
  size_t *lengths;
3545
 
 
3546
 
  if (opt_silent < 2 && column_names)
 
3545
  std::vector<bool> boolean_flag;
 
3546
 
 
3547
  boolean_flag.resize(drizzle_result_column_count(result));
 
3548
 
 
3549
  int first=0;
 
3550
  for (uint32_t off= 0; (field = drizzle_column_next(result)); off++)
3547
3551
  {
3548
 
    int first=0;
3549
 
    while ((field = drizzle_column_next(result)))
 
3552
    if (opt_silent < 2 && column_names)
3550
3553
    {
3551
3554
      if (first++)
3552
3555
        (void) tee_fputs("\t", PAGER);
3553
3556
      (void) tee_fputs(drizzle_column_name(field), PAGER);
3554
3557
    }
 
3558
    if ((server_type == ServerDetect::SERVER_DRIZZLE_FOUND) and
 
3559
      (drizzle_column_type(field) == DRIZZLE_COLUMN_TYPE_TINY))
 
3560
    {
 
3561
      boolean_flag[off]= true;
 
3562
    }
 
3563
    else
 
3564
    {
 
3565
      boolean_flag[off]= false;
 
3566
    }
 
3567
  }
 
3568
  if (opt_silent < 2 && column_names)
 
3569
  {
3555
3570
    (void) tee_fputs("\n", PAGER);
3556
3571
  }
3557
3572
  while (1)
3572
3587
      break;
3573
3588
 
3574
3589
    lengths= drizzle_row_field_sizes(result);
3575
 
    safe_put_field(cur[0],lengths[0]);
3576
 
    for (uint32_t off=1 ; off < drizzle_result_column_count(result); off++)
 
3590
    drizzle_column_seek(result, 0);
 
3591
    for (uint32_t off=0 ; off < drizzle_result_column_count(result); off++)
3577
3592
    {
3578
 
      (void) tee_fputs("\t", PAGER);
3579
 
      safe_put_field(cur[off], lengths[off]);
 
3593
      if (off != 0)
 
3594
        (void) tee_fputs("\t", PAGER);
 
3595
      if (boolean_flag[off])
 
3596
      {
 
3597
        if (strncmp(cur[off],"1", 1) == 0)
 
3598
          safe_put_field("TRUE", 4);
 
3599
        else
 
3600
          safe_put_field("FALSE", 5);
 
3601
      }
 
3602
      else
 
3603
      {
 
3604
        safe_put_field(cur[off], lengths[off]);
 
3605
      }
3580
3606
    }
3581
3607
    (void) tee_fputs("\n", PAGER);
3582
3608
    if (quick)