~mathiaz/ubuntu/lucid/mysql-dfsg-5.1/zap-bug-552053

« back to all changes in this revision

Viewing changes to tests/mysql_client_test.c

  • Committer: Bazaar Package Importer
  • Author(s): Mathias Gug
  • Date: 2009-06-25 12:55:45 UTC
  • mfrom: (1.1.2 upstream) (0.1.3 experimental)
  • Revision ID: james.westby@ubuntu.com-20090625125545-m8ogs96zzsri74xe
Tags: 5.1.34-1ubuntu1
* Merge from debian experimental (and 5.0 from main), remaining changes:
  - debian/mysql-server-5.1.config:
    + ask for MySQL root password at priority high instead of medium so
      that the password prompt is seen on a default install. (LP: #319843)
    + don't ask for root password when upgrading from a 5.0 install.
  - debian/control:
    + Make libmysqlclient16-dev a transitional package depending on
      libmysqlclient-dev.
    + Make libmysqlclient-dev conflict with libmysqlclient15-dev.
    + Don't build mysql-server, mysql-client, mysql-common and
      libmysqlclient15-dev binary packages since they're still provided
      by mysql-dfsg-5.0.
    + Make mysql-{client,server}-5.1 packages conflict and
      replace mysql-{client,server}-5.0, but not provide
      mysql-{client,server}.
    + Depend on a specific version of mysql-common rather than the src
      version of mysql-dfsg-5.1 since mysql-common is currently part of
      mysql-dfsg-5.0.
    + Lower mailx from a Recommends to a Suggests to avoid pulling in
      a full MTA on all installs of mysql-server. (LP: #259477)
  - debian/rules:
    + added -fno-strict-aliasing to CFLAGS to get around mysql testsuite
      build failures.
    + install mysql-test and sql-bench to /usr/share/mysql/ rather than
      /usr/.
  - debian/additions/debian-start.inc.sh: support ANSI mode (LP: #310211)
  - Add AppArmor profile:
    - debian/apparmor-profile: apparmor profile.
    - debian/rules, debian/mysql-server-5.0.files: install apparmor profile.
    - debian/mysql-server-5.0.dirs: add etc/apparmor.d/force-complain
    - debian/mysql-server-5.0.postrm: remove symlink in force-complain/ on
      purge.
    - debian/mysql-server-5.1.README.Debian: add apparmor documentation.
    - debian/additions/my.cnf: Add warning about apparmor. (LP: #201799)
    - debian/mysql-server-5.1.postinst: reload apparmor profiles.
  - debian/additions/my.cnf: remove language option. Error message files are
    located in a different directory in MySQL 5.0. Setting the language
    option to use /usr/share/mysql/english breaks 5.0. Both 5.0 and 5.1
    use a default value that works. (LP: #316974)
  - debian/mysql-server-5.1.mysql.init:
    + Clearly indicate that we do not support running multiple instances
      of mysqld by duplicating the init script.
      (closes: #314785, #324834, #435165, #444216)
    + Properly parameterize all existing references to the mysql config
      file (/etc/mysql/my.cnf).
  - debian/mysql-server-5.0.postinst: Clear out the second password
    when setting up mysql. (LP: #344816)
  - mysql-server-core-5.1 package for files needed by Akonadi:
    + debian/control: create mysql-server-core-5.1 package.
    + debian/mysql-server-core-5.1.files, debian/mysql-server-5.1.files:
      move core mysqld files to mysql-server-core-5.1 package.
  - Don't package sql-bench and mysql-test file.
* Dropped changes:
  - debian/patches/92_ssl_test_cert.dpatch: certificate expiration in
    test suite (LP: #323755). Included upstream.
* Dropped from 5.0:
  - apparmor profile:
    - debian/control: Recommends apparmor >= 2.1+1075-0ubuntu6. All version
      of apparmor-profile (>hardy) are higher than this version.
    - debian/mysql-server-5.0.preinst: create symlink for force-complain/
      on pre-feisty upgrades, upgrades where apparmor-profiles profile is
      unchanged (ie non-enforcing) and upgrades where the profile
      doesn't exist. Support for pre-hardy upgrades is no longer needed.
* debian/mysql-server-5.1.postinst: fix debian-sys-maint user creation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
262
262
mysql_simple_prepare(MYSQL *mysql_arg, const char *query)
263
263
{
264
264
  MYSQL_STMT *stmt= mysql_stmt_init(mysql_arg);
265
 
  if (stmt && mysql_stmt_prepare(stmt, query, strlen(query)))
 
265
  if (stmt && mysql_stmt_prepare(stmt, query, (uint) strlen(query)))
266
266
  {
267
267
    mysql_stmt_close(stmt);
268
268
    return 0;
723
723
{
724
724
  MYSQL_FIELD *field;
725
725
  CHARSET_INFO *cs;
 
726
  ulonglong expected_field_length;
726
727
 
727
728
  if (!(field= mysql_fetch_field_direct(result, no)))
728
729
  {
731
732
  }
732
733
  cs= get_charset(field->charsetnr, 0);
733
734
  DIE_UNLESS(cs);
 
735
  if ((expected_field_length= length * cs->mbmaxlen) > UINT_MAX32)
 
736
    expected_field_length= UINT_MAX32;
734
737
  if (!opt_silent)
735
738
  {
736
739
    fprintf(stdout, "\n field[%d]:", no);
745
748
      fprintf(stdout, "\n    org_table:`%s`\t(expected: `%s`)",
746
749
              field->org_table, org_table);
747
750
    fprintf(stdout, "\n    database :`%s`\t(expected: `%s`)", field->db, db);
748
 
    fprintf(stdout, "\n    length   :`%lu`\t(expected: `%lu`)",
749
 
            field->length, length * cs->mbmaxlen);
 
751
    fprintf(stdout, "\n    length   :`%lu`\t(expected: `%llu`)",
 
752
            field->length, expected_field_length);
750
753
    fprintf(stdout, "\n    maxlength:`%ld`", field->max_length);
751
754
    fprintf(stdout, "\n    charsetnr:`%d`", field->charsetnr);
752
755
    fprintf(stdout, "\n    default  :`%s`\t(expected: `%s`)",
782
785
    as utf8. Field length is calculated as number of characters * maximum
783
786
    number of bytes a character can occupy.
784
787
  */
785
 
  if (length && field->length != length * cs->mbmaxlen)
 
788
  if (length && (field->length != expected_field_length))
786
789
  {
787
 
    fprintf(stderr, "Expected field length: %d,  got length: %d\n",
788
 
            (int) (length * cs->mbmaxlen), (int) field->length);
789
 
    DIE_UNLESS(field->length == length * cs->mbmaxlen);
 
790
    fprintf(stderr, "Expected field length: %llu,  got length: %lu\n",
 
791
            expected_field_length, field->length);
 
792
    DIE_UNLESS(field->length == expected_field_length);
790
793
  }
791
794
  if (def)
792
795
    DIE_UNLESS(strcmp(field->def, def) == 0);
17712
17715
 
17713
17716
  DBUG_VOID_RETURN;
17714
17717
}
 
17718
 
 
17719
 
 
17720
/**
 
17721
  Bug#36326: nested transaction and select
 
17722
*/
 
17723
 
 
17724
#ifdef HAVE_QUERY_CACHE
 
17725
 
 
17726
static void test_bug36326()
 
17727
{
 
17728
  int rc;
 
17729
 
 
17730
  DBUG_ENTER("test_bug36326");
 
17731
  myheader("test_bug36326");
 
17732
 
 
17733
  rc= mysql_autocommit(mysql, TRUE);
 
17734
  myquery(rc);
 
17735
  rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
 
17736
  myquery(rc);
 
17737
  rc= mysql_query(mysql, "CREATE  TABLE t1 (a INTEGER)");
 
17738
  myquery(rc);
 
17739
  rc= mysql_query(mysql, "INSERT INTO t1 VALUES (1)");
 
17740
  myquery(rc);
 
17741
  rc= mysql_query(mysql, "SET GLOBAL query_cache_type = 1");
 
17742
  myquery(rc);
 
17743
  rc= mysql_query(mysql, "SET GLOBAL query_cache_size = 1048576");
 
17744
  myquery(rc);
 
17745
  DIE_UNLESS(!(mysql->server_status & SERVER_STATUS_IN_TRANS));
 
17746
  DIE_UNLESS(mysql->server_status & SERVER_STATUS_AUTOCOMMIT);
 
17747
  rc= mysql_query(mysql, "BEGIN");
 
17748
  myquery(rc);
 
17749
  DIE_UNLESS(mysql->server_status & SERVER_STATUS_IN_TRANS);
 
17750
  rc= mysql_query(mysql, "SELECT * FROM t1");
 
17751
  myquery(rc);
 
17752
  rc= my_process_result(mysql);
 
17753
  DIE_UNLESS(rc == 1);
 
17754
  rc= mysql_rollback(mysql);
 
17755
  myquery(rc);
 
17756
  rc= mysql_query(mysql, "ROLLBACK");
 
17757
  myquery(rc);
 
17758
  DIE_UNLESS(!(mysql->server_status & SERVER_STATUS_IN_TRANS));
 
17759
  rc= mysql_query(mysql, "SELECT * FROM t1");
 
17760
  myquery(rc);
 
17761
  DIE_UNLESS(!(mysql->server_status & SERVER_STATUS_IN_TRANS));
 
17762
  rc= my_process_result(mysql);
 
17763
  DIE_UNLESS(rc == 1);
 
17764
  rc= mysql_query(mysql, "DROP TABLE t1");
 
17765
  myquery(rc);
 
17766
  rc= mysql_query(mysql, "SET GLOBAL query_cache_size = 0");
 
17767
  myquery(rc);
 
17768
 
 
17769
  DBUG_VOID_RETURN;
 
17770
}
 
17771
 
 
17772
#endif
 
17773
 
 
17774
/**
 
17775
  Bug#41078: With CURSOR_TYPE_READ_ONLY mysql_stmt_fetch() returns short
 
17776
             string value.
 
17777
*/
 
17778
 
 
17779
static void test_bug41078(void)
 
17780
{
 
17781
  uint         rc;
 
17782
  MYSQL_STMT   *stmt= 0;
 
17783
  MYSQL_BIND   param, result;
 
17784
  ulong        cursor_type= CURSOR_TYPE_READ_ONLY;
 
17785
  ulong        len;
 
17786
  char         str[64];
 
17787
  const char   param_str[]= "abcdefghijklmn";
 
17788
  my_bool      is_null, error;
 
17789
 
 
17790
  DBUG_ENTER("test_bug41078");
 
17791
 
 
17792
  rc= mysql_query(mysql, "SET NAMES UTF8");
 
17793
  myquery(rc);
 
17794
 
 
17795
  stmt= mysql_simple_prepare(mysql, "SELECT ?");
 
17796
  check_stmt(stmt);
 
17797
  verify_param_count(stmt, 1);
 
17798
 
 
17799
  rc= mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, &cursor_type);
 
17800
  check_execute(stmt, rc);
 
17801
  
 
17802
  bzero(&param, sizeof(param));
 
17803
  param.buffer_type= MYSQL_TYPE_STRING;
 
17804
  param.buffer= (void *) param_str;
 
17805
  len= sizeof(param_str) - 1;
 
17806
  param.length= &len;
 
17807
 
 
17808
  rc= mysql_stmt_bind_param(stmt, &param);
 
17809
  check_execute(stmt, rc);
 
17810
 
 
17811
  rc= mysql_stmt_execute(stmt);
 
17812
  check_execute(stmt, rc);
 
17813
 
 
17814
  bzero(&result, sizeof(result));
 
17815
  result.buffer_type= MYSQL_TYPE_STRING;
 
17816
  result.buffer= str;
 
17817
  result.buffer_length= sizeof(str);
 
17818
  result.is_null= &is_null;
 
17819
  result.length= &len;
 
17820
  result.error=  &error;
 
17821
  
 
17822
  rc= mysql_stmt_bind_result(stmt, &result);
 
17823
  check_execute(stmt, rc);
 
17824
 
 
17825
  rc= mysql_stmt_store_result(stmt);
 
17826
  check_execute(stmt, rc);
 
17827
 
 
17828
  rc= mysql_stmt_fetch(stmt);
 
17829
  check_execute(stmt, rc);
 
17830
 
 
17831
  DIE_UNLESS(len == sizeof(param_str) - 1 && !strcmp(str, param_str));
 
17832
 
 
17833
  mysql_stmt_close(stmt);
 
17834
 
 
17835
  DBUG_VOID_RETURN;
 
17836
}
 
17837
 
17715
17838
/*
17716
17839
  Read and parse arguments and MySQL options from my.cnf
17717
17840
*/
18025
18148
#ifdef HAVE_SPATIAL
18026
18149
  { "test_bug37956", test_bug37956 },
18027
18150
#endif
 
18151
#ifdef HAVE_QUERY_CACHE
 
18152
  { "test_bug36326", test_bug36326 },
 
18153
#endif
 
18154
  { "test_bug41078", test_bug41078 },
18028
18155
  { 0, 0 }
18029
18156
};
18030
18157