~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session.h

  • Committer: Brian Aker
  • Date: 2010-02-22 19:23:48 UTC
  • mfrom: (1273.13.95 build)
  • Revision ID: brian@gaz-20100222192348-bcda6uwqmyt30rbi
Merge Padraig.

Show diffs side-by-side

added added

removed removed

Lines of Context:
406
406
   */
407
407
  uint32_t id;
408
408
  LEX *lex; /**< parse tree descriptor */
409
 
  /**
410
 
    Points to the query associated with this statement. It's const, but
411
 
    we need to declare it char * because all table handlers are written
412
 
    in C and need to point to it.
413
 
 
414
 
    Note that (A) if we set query = NULL, we must at the same time set
415
 
    query_length = 0, and protect the whole operation with the
416
 
    LOCK_thread_count mutex. And (B) we are ONLY allowed to set query to a
417
 
    non-NULL value if its previous value is NULL. We do not need to protect
418
 
    operation (B) with any mutex. To avoid crashes in races, if we do not
419
 
    know that session->query cannot change at the moment, one should print
420
 
    session->query like this:
421
 
      (1) reserve the LOCK_thread_count mutex;
422
 
      (2) check if session->query is NULL;
423
 
      (3) if not NULL, then print at most session->query_length characters from
424
 
      it. We will see the query_length field as either 0, or the right value
425
 
      for it.
426
 
    Assuming that the write and read of an n-bit memory field in an n-bit
427
 
    computer is atomic, we can avoid races in the above way.
428
 
    This printing is needed at least in SHOW PROCESSLIST and SHOW INNODB
429
 
    STATUS.
430
 
  */
431
 
  char *query;
432
 
  uint32_t query_length; /**< current query length */
 
409
  /** query associated with this statement */
 
410
  std::string query;
433
411
 
434
412
  /**
435
413
    Name of the current (default) database.
795
773
  }
796
774
 
797
775
  /** Returns the current query text */
798
 
  inline const char *getQueryString()  const
 
776
  inline const std::string &getQueryString()  const
799
777
  {
800
778
    return query;
801
779
  }
803
781
  /** Returns the length of the current query text */
804
782
  inline size_t getQueryLength() const
805
783
  {
806
 
    if (query != NULL)
807
 
      return strlen(query);
 
784
    if (! query.empty())
 
785
      return query.length();
808
786
    else
809
787
      return 0;
810
788
  }