~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session.h

Merge with my query rewrite tree to change the query member in Session to std::string

Show diffs side-by-side

added added

removed removed

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