~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzleslap.cc

  • Committer: Monty Taylor
  • Date: 2009-01-28 21:42:05 UTC
  • mto: (779.7.3 devel)
  • mto: This revision was merged to the branch mainline in revision 823.
  • Revision ID: mordred@inaugust.com-20090128214205-fszu4qm6cb5jti7x
Fixed 32-64bit bugs in drizzleslap.

Show diffs side-by-side

added added

removed removed

Lines of Context:
115
115
static char **defaults_argv;
116
116
 
117
117
char **primary_keys;
118
 
uint64_t primary_keys_number_of;
 
118
/* This gets passed to malloc, so lets set it to an arch-dependant size */
 
119
size_t primary_keys_number_of;
119
120
 
120
121
static char *host= NULL, *opt_password= NULL, *user= NULL,
121
122
  *user_supplied_query= NULL,
289
290
                         option_string *engine_stmt, stats *sptr);
290
291
static int run_scheduler(stats *sptr, statement **stmts, uint concur,
291
292
                         uint64_t limit);
292
 
pthread_handler_t run_task(void *p);
293
 
pthread_handler_t timer_thread(void *p);
 
293
extern "C" pthread_handler_t run_task(void *p);
 
294
extern "C" pthread_handler_t timer_thread(void *p);
294
295
void statement_cleanup(statement *stmt);
295
296
void option_cleanup(option_string *stmt);
296
297
void concurrency_loop(DRIZZLE *drizzle, uint current, option_string *eptr);
730
731
  my_print_help(my_long_options);
731
732
}
732
733
 
 
734
extern "C"
733
735
static bool
734
736
get_one_option(int optid, const struct my_option *, char *argument)
735
737
{
792
794
  case 'V':
793
795
    print_version();
794
796
    exit(0);
795
 
    break;
796
797
  case '?':
797
798
  case 'I':          /* Info */
798
799
    usage();
1554
1555
        fprintf(stderr,"%s: Could not open create file\n", my_progname);
1555
1556
        exit(1);
1556
1557
      }
1557
 
      tmp_string= (char *)malloc(sbuf.st_size + 1);
 
1558
      if (sbuf.st_size + 1 > SIZE_MAX)
 
1559
      {
 
1560
        fprintf(stderr, "Request for more memory than architecture supports\n");
 
1561
        exit(1);
 
1562
      }
 
1563
      tmp_string= (char *)malloc((size_t)(sbuf.st_size + 1));
1558
1564
      if (tmp_string == NULL)
1559
1565
      {
1560
1566
        fprintf(stderr, "Memory Allocation error in option processing\n");
1561
1567
        exit(1);
1562
1568
      }
1563
 
      memset(tmp_string, 0, sbuf.st_size + 1);
1564
 
      my_read(data_file, (unsigned char*) tmp_string, sbuf.st_size, MYF(0));
 
1569
      memset(tmp_string, 0, (size_t)(sbuf.st_size + 1));
 
1570
      read(data_file, (unsigned char*) tmp_string, (size_t)sbuf.st_size);
1565
1571
      tmp_string[sbuf.st_size]= '\0';
1566
 
      my_close(data_file,MYF(0));
 
1572
      close(data_file);
1567
1573
      parse_delimiter(tmp_string, &create_statements, delimiter[0]);
1568
1574
      free(tmp_string);
1569
1575
    }
1601
1607
        fprintf(stderr,"%s: Could not open query supplied file\n", my_progname);
1602
1608
        exit(1);
1603
1609
      }
1604
 
      tmp_string= (char *)malloc(sbuf.st_size + 1);
 
1610
      if (sbuf.st_size + 1 > SIZE_MAX)
 
1611
      {
 
1612
        fprintf(stderr, "Request for more memory than architecture supports\n");
 
1613
        exit(1);
 
1614
      }
 
1615
      tmp_string= (char *)malloc((size_t)(sbuf.st_size + 1));
1605
1616
      if (tmp_string == NULL)
1606
1617
      {
1607
1618
        fprintf(stderr, "Memory Allocation error in option processing\n");
1608
1619
        exit(1);
1609
1620
      }
1610
 
      memset(tmp_string, 0, sbuf.st_size + 1);
1611
 
      my_read(data_file, (unsigned char*) tmp_string, sbuf.st_size, MYF(0));
 
1621
      memset(tmp_string, 0, (size_t)(sbuf.st_size + 1));
 
1622
      read(data_file, (unsigned char*) tmp_string, (size_t)sbuf.st_size);
1612
1623
      tmp_string[sbuf.st_size]= '\0';
1613
 
      my_close(data_file,MYF(0));
 
1624
      close(data_file);
1614
1625
      if (user_supplied_query)
1615
1626
        actual_queries= parse_delimiter(tmp_string, &query_statements[0],
1616
1627
                                        delimiter[0]);
1638
1649
      fprintf(stderr,"%s: Could not open query supplied file\n", my_progname);
1639
1650
      exit(1);
1640
1651
    }
1641
 
    tmp_string= (char *)malloc(sbuf.st_size + 1);
 
1652
    if (sbuf.st_size + 1 > SIZE_MAX)
 
1653
    {
 
1654
      fprintf(stderr, "Request for more memory than architecture supports\n");
 
1655
      exit(1);
 
1656
    }
 
1657
    tmp_string= (char *)malloc((size_t)(sbuf.st_size + 1));
1642
1658
    if (tmp_string == NULL)
1643
1659
    {
1644
1660
      fprintf(stderr, "Memory Allocation error in option processing\n");
1645
1661
      exit(1);
1646
1662
    }
1647
 
    memset(tmp_string, 0, sbuf.st_size + 1);
1648
 
    my_read(data_file, (unsigned char*) tmp_string, sbuf.st_size, MYF(0));
 
1663
    memset(tmp_string, 0, (size_t)(sbuf.st_size + 1));
 
1664
    read(data_file, (unsigned char*) tmp_string, (size_t)sbuf.st_size);
1649
1665
    tmp_string[sbuf.st_size]= '\0';
1650
 
    my_close(data_file,MYF(0));
 
1666
    close(data_file);
1651
1667
    if (user_supplied_pre_statements)
1652
1668
      (void)parse_delimiter(tmp_string, &pre_statements,
1653
1669
                            delimiter[0]);
1675
1691
      fprintf(stderr,"%s: Could not open query supplied file\n", my_progname);
1676
1692
      exit(1);
1677
1693
    }
1678
 
    tmp_string= (char *)malloc(sbuf.st_size + 1);
 
1694
 
 
1695
    if (sbuf.st_size + 1 > SIZE_MAX)
 
1696
    {
 
1697
      fprintf(stderr, "Request for more memory than architecture supports\n");
 
1698
      exit(1);
 
1699
    }
 
1700
    tmp_string= (char *)malloc((size_t)(sbuf.st_size + 1));
1679
1701
    if (tmp_string == NULL)
1680
1702
    {
1681
1703
      fprintf(stderr, "Memory Allocation error in option processing\n");
1682
1704
      exit(1);
1683
1705
    }
1684
 
    memset(tmp_string, 0, sbuf.st_size+1);
1685
 
    my_read(data_file, (unsigned char*) tmp_string, sbuf.st_size, MYF(0));
 
1706
    memset(tmp_string, 0, (size_t)(sbuf.st_size+1));
 
1707
 
 
1708
    read(data_file, (unsigned char*) tmp_string,
 
1709
         (size_t)(sbuf.st_size));
1686
1710
    tmp_string[sbuf.st_size]= '\0';
1687
 
    my_close(data_file,MYF(0));
 
1711
    close(data_file);
1688
1712
    if (user_supplied_post_statements)
1689
1713
      (void)parse_delimiter(tmp_string, &post_statements,
1690
1714
                            delimiter[0]);
1765
1789
    }
1766
1790
 
1767
1791
    result= drizzle_store_result(drizzle);
1768
 
    primary_keys_number_of= drizzle_num_rows(result);
 
1792
    uint64_t num_rows_ret= drizzle_num_rows(result);
 
1793
    if (num_rows_ret > SIZE_MAX)
 
1794
    {
 
1795
      fprintf(stderr, "More primary keys than than architecture supports\n");
 
1796
      exit(1);
 
1797
    }
 
1798
    primary_keys_number_of= (size_t)num_rows_ret;
1769
1799
 
1770
1800
    /* So why check this? Blackhole :) */
1771
1801
    if (primary_keys_number_of)
1780
1810
        fprintf(stderr, "Memory Allocation error in option processing\n");
1781
1811
        exit(1);
1782
1812
      }
1783
 
      memset(primary_keys, 0, sizeof(char *) * primary_keys_number_of);
 
1813
      memset(primary_keys, 0, (size_t)(sizeof(char *) * primary_keys_number_of));
1784
1814
      row= drizzle_fetch_row(result);
1785
1815
      for (counter= 0; counter < primary_keys_number_of;
1786
1816
           counter++, row= drizzle_fetch_row(result))