~ubuntu-branches/ubuntu/karmic/mysql-dfsg-5.1/karmic

« back to all changes in this revision

Viewing changes to sql/sql_class.cc

  • Committer: Bazaar Package Importer
  • Author(s): Mathias Gug
  • Date: 2009-02-10 16:42:05 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090210164205-ej41ocvm4z1s14nq
Tags: 5.1.31-1ubuntu1
* Merge from debian experimental, 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)
  - debian/control: 
    + Don't build mysql-server, mysql-client, mysql-common and 
      libmysqlclient15-dev binary packages since they're still provided 
      by mysql-dfsg-5.0.
    + Rename libmysqlclient-dev package to libmysqlclient16-dev (LP: #316280).
      Make it conflict with libmysqlclient15-dev.
    + 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.
  - debian/rules: added -fno-strict-aliasing to CFLAGS to get
    around mysql testsuite build failures.
* debian/patches/92_ssl_test_cert.dpatch: certificate expiration in 
  test suite (LP: #323755).
* Dropped changes:
  - all of the changes made to support both 5.0 and 5.1 installed at the
    same time have been dropped now that amarok doesn't depend on
    mysql-server-5.1 anymore.

Show diffs side-by-side

added added

removed removed

Lines of Context:
306
306
  thd->row_count++;
307
307
}
308
308
 
309
 
/*
 
309
 
 
310
/**
310
311
  Dumps a text description of a thread, its security context
311
312
  (user, host) and the current query.
312
313
 
313
 
  SYNOPSIS
314
 
    thd_security_context()
315
 
    thd                 current thread context
316
 
    buffer              pointer to preferred result buffer
317
 
    length              length of buffer
318
 
    max_query_len       how many chars of query to copy (0 for all)
 
314
  @param thd thread context
 
315
  @param buffer pointer to preferred result buffer
 
316
  @param length length of buffer
 
317
  @param max_query_len how many chars of query to copy (0 for all)
319
318
 
320
 
  RETURN VALUES
321
 
    pointer to string
 
319
  @req LOCK_thread_count
 
320
  
 
321
  @note LOCK_thread_count mutex is not necessary when the function is invoked on
 
322
   the currently running thread (current_thd) or if the caller in some other
 
323
   way guarantees that access to thd->query is serialized.
 
324
 
 
325
  @return Pointer to string
322
326
*/
 
327
 
323
328
extern "C"
324
329
char *thd_security_context(THD *thd, char *buffer, unsigned int length,
325
330
                           unsigned int max_query_len)
328
333
  const Security_context *sctx= &thd->main_security_ctx;
329
334
  char header[64];
330
335
  int len;
 
336
  /*
 
337
    The pointers thd->query and thd->proc_info might change since they are
 
338
    being modified concurrently. This is acceptable for proc_info since its
 
339
    values doesn't have to very accurate and the memory it points to is static,
 
340
    but we need to attempt a snapshot on the pointer values to avoid using NULL
 
341
    values. The pointer to thd->query however, doesn't point to static memory
 
342
    and has to be protected by LOCK_thread_count or risk pointing to
 
343
    uninitialized memory.
 
344
  */
 
345
  const char *proc_info= thd->proc_info;
331
346
 
332
347
  len= my_snprintf(header, sizeof(header),
333
348
                   "MySQL thread id %lu, query id %lu",
353
368
    str.append(sctx->user);
354
369
  }
355
370
 
356
 
  if (thd->proc_info)
 
371
  if (proc_info)
357
372
  {
358
373
    str.append(' ');
359
 
    str.append(thd->proc_info);
 
374
    str.append(proc_info);
360
375
  }
361
376
 
362
377
  if (thd->query)
370
385
  }
371
386
  if (str.c_ptr_safe() == buffer)
372
387
    return buffer;
373
 
  return thd->strmake(str.ptr(), str.length());
 
388
 
 
389
  /*
 
390
    We have to copy the new string to the destination buffer because the string
 
391
    was reallocated to a larger buffer to be able to fit.
 
392
  */
 
393
  DBUG_ASSERT(buffer != NULL);
 
394
  length= min(str.length(), length-1);
 
395
  memcpy(buffer, str.c_ptr_quick(), length);
 
396
  /* Make sure that the new string is null terminated */
 
397
  buffer[length]= '\0';
 
398
  return buffer;
374
399
}
375
400
 
376
401
/**