~ubuntu-branches/ubuntu/precise/mysql-5.5/precise-201203300109

« back to all changes in this revision

Viewing changes to sql/sql_cache.cc

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-02-14 23:59:22 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20120214235922-cux5uek1e5l0hje9
Tags: 5.5.20-0ubuntu1
* New upstream release.
* d/mysql-server-5.5.mysql.upstart: Fix stop on to make sure mysql is
  fully stopped before shutdown commences. (LP: #688541) Also simplify
  start on as it is redundant.
* d/control: Depend on upstart version which has apparmor profile load
  script to prevent failure on upgrade from lucid to precise.
  (LP: #907465)
* d/apparmor-profile: need to allow /run since that is the true path
  of /var/run files. (LP: #917542)
* d/control: mysql-server-5.5 has files in it that used to be owned
  by libmysqlclient-dev, so it must break/replace it. (LP: #912487)
* d/rules, d/control: 5.5.20 Fixes segfault on tests with gcc 4.6,
  change compiler back to system default.
* d/rules: Turn off embedded libedit/readline.(Closes: #659566)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1278
1278
    /* Key is query + database + flag */
1279
1279
    if (thd->db_length)
1280
1280
    {
1281
 
      memcpy(thd->query() + thd->query_length() + 1, thd->db, 
1282
 
        thd->db_length);
 
1281
      memcpy(thd->query() + thd->query_length() + 1 + sizeof(size_t), 
 
1282
             thd->db, thd->db_length);
1283
1283
      DBUG_PRINT("qcache", ("database: %s  length: %u",
1284
1284
                            thd->db, (unsigned) thd->db_length)); 
1285
1285
    }
1288
1288
      DBUG_PRINT("qcache", ("No active database"));
1289
1289
    }
1290
1290
    tot_length= thd->query_length() + thd->db_length + 1 +
1291
 
      QUERY_CACHE_FLAGS_SIZE;
 
1291
      sizeof(size_t) + QUERY_CACHE_FLAGS_SIZE;
1292
1292
    /*
1293
1293
      We should only copy structure (don't use it location directly)
1294
1294
      because of alignment issue
1506
1506
      goto err;
1507
1507
    }
1508
1508
  }
 
1509
  {
 
1510
    /*
 
1511
      We have allocated buffer space (in alloc_query) to hold the
 
1512
      SQL statement(s) + the current database name + a flags struct.
 
1513
      If the database name has changed during execution, which might
 
1514
      happen if there are multiple statements, we need to make
 
1515
      sure the new current database has a name with the same length
 
1516
      as the previous one.
 
1517
    */
 
1518
    size_t db_len;
 
1519
    memcpy((char *) &db_len, (sql + query_length + 1), sizeof(size_t));
 
1520
    if (thd->db_length != db_len)
 
1521
    {
 
1522
      /*
 
1523
        We should probably reallocate the buffer in this case,
 
1524
        but for now we just leave it uncached
 
1525
      */
1509
1526
 
 
1527
      DBUG_PRINT("qcache", 
 
1528
                 ("Current database has changed since start of query"));
 
1529
      goto err;
 
1530
    }
 
1531
  }
1510
1532
  /*
1511
1533
    Try to obtain an exclusive lock on the query cache. If the cache is
1512
1534
    disabled or if a full cache flush is in progress, the attempt to
1522
1544
 
1523
1545
  Query_cache_block *query_block;
1524
1546
 
1525
 
  tot_length= query_length + thd->db_length + 1 + QUERY_CACHE_FLAGS_SIZE;
 
1547
  tot_length= query_length + 1 + sizeof(size_t) + 
 
1548
              thd->db_length + QUERY_CACHE_FLAGS_SIZE;
 
1549
 
1526
1550
  if (thd->db_length)
1527
1551
  {
1528
 
    memcpy(sql+query_length+1, thd->db, thd->db_length);
 
1552
    memcpy(sql + query_length + 1 + sizeof(size_t), thd->db, thd->db_length);
1529
1553
    DBUG_PRINT("qcache", ("database: '%s'  length: %u",
1530
1554
                          thd->db, (unsigned)thd->db_length));
1531
1555
  }