~stewart/drizzle/bug588251-startScan-unused-result

« back to all changes in this revision

Viewing changes to drizzled/session.h

  • Committer: Brian Aker
  • Date: 2010-12-31 06:44:35 UTC
  • mfrom: (2040.4.3 timestamp)
  • Revision ID: brian@tangent.org-20101231064435-g0h53tjfisjty2fy
Partial update to the time code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
659
659
  uint32_t file_id;     /**< File ID for LOAD DATA INFILE */
660
660
  /* @note the following three members should likely move to Client */
661
661
  uint32_t max_client_packet_length; /**< Maximum number of bytes a client can send in a single packet */
 
662
 
 
663
private:
 
664
  boost::posix_time::ptime _epoch;
 
665
  boost::posix_time::ptime _start_timer;
 
666
  boost::posix_time::ptime _end_timer;
 
667
 
 
668
public:
 
669
 
662
670
  time_t start_time;
663
671
  time_t user_time;
664
 
  uint64_t thr_create_utime; /**< track down slow pthread_create */
665
672
  uint64_t start_utime;
666
673
  uint64_t utime_after_lock;
667
674
 
684
691
  */
685
692
  query_id_t query_id;
686
693
  query_id_t warn_query_id;
 
694
 
687
695
public:
688
696
  void **getEngineData(const plugin::MonitoredInTransaction *monitored);
689
697
  ResourceContext *getResourceContext(const plugin::MonitoredInTransaction *monitored,
1240
1248
  const char* enter_cond(boost::condition_variable_any &cond, boost::mutex &mutex, const char* msg);
1241
1249
  void exit_cond(const char* old_msg);
1242
1250
 
1243
 
  inline time_t query_start() { return start_time; }
1244
 
  inline void set_time()
1245
 
  {
1246
 
    boost::posix_time::ptime mytime(boost::posix_time::microsec_clock::local_time());
1247
 
    boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));
1248
 
    start_utime= utime_after_lock= (mytime-epoch).total_microseconds();
 
1251
  time_t query_start()
 
1252
  {
 
1253
    return start_time;
 
1254
  }
 
1255
 
 
1256
  void set_time()
 
1257
  {
 
1258
    _end_timer= _start_timer= boost::posix_time::microsec_clock::universal_time();
 
1259
    start_utime= utime_after_lock= (_start_timer - _epoch).total_microseconds();
1249
1260
 
1250
1261
    if (user_time)
1251
1262
    {
1253
1264
      connect_microseconds= start_utime;
1254
1265
    }
1255
1266
    else 
1256
 
      start_time= (mytime-epoch).total_seconds();
 
1267
    {
 
1268
      start_time= (_start_timer - _epoch).total_seconds();
 
1269
    }
1257
1270
  }
1258
 
  inline void   set_current_time()    { start_time= time(NULL); }
1259
 
  inline void   set_time(time_t t)
 
1271
 
 
1272
  void set_time(time_t t)
1260
1273
  {
1261
1274
    start_time= user_time= t;
1262
 
    boost::posix_time::ptime mytime(boost::posix_time::microsec_clock::local_time());
1263
 
    boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));
1264
 
    uint64_t t_mark= (mytime-epoch).total_microseconds();
 
1275
    boost::posix_time::ptime mytime(boost::posix_time::microsec_clock::universal_time());
 
1276
    uint64_t t_mark= (mytime - _epoch).total_microseconds();
1265
1277
 
1266
1278
    start_utime= utime_after_lock= t_mark;
1267
1279
  }
1268
 
  void set_time_after_lock()  { 
1269
 
     boost::posix_time::ptime mytime(boost::posix_time::microsec_clock::local_time());
1270
 
     boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));
1271
 
     utime_after_lock= (mytime-epoch).total_microseconds();
1272
 
  }
 
1280
 
 
1281
  void set_time_after_lock()
 
1282
  { 
 
1283
    boost::posix_time::ptime mytime(boost::posix_time::microsec_clock::universal_time());
 
1284
    utime_after_lock= (mytime - _epoch).total_microseconds();
 
1285
  }
 
1286
 
 
1287
  void set_end_timer()
 
1288
  {
 
1289
    _end_timer= boost::posix_time::microsec_clock::universal_time();
 
1290
    status_var.execution_time_nsec+=(_end_timer - _start_timer).total_microseconds();
 
1291
  }
 
1292
 
1273
1293
  /**
1274
1294
   * Returns the current micro-timestamp
1275
1295
   */
1276
 
  inline uint64_t getCurrentTimestamp()  
 
1296
  uint64_t getCurrentTimestamp(bool actual= true)  
1277
1297
  { 
1278
 
    boost::posix_time::ptime mytime(boost::posix_time::microsec_clock::local_time());
1279
 
    boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));
1280
 
    uint64_t t_mark= (mytime-epoch).total_microseconds();
 
1298
    uint64_t t_mark;
 
1299
 
 
1300
    if (actual)
 
1301
    {
 
1302
      boost::posix_time::ptime mytime(boost::posix_time::microsec_clock::universal_time());
 
1303
      t_mark= (mytime - _epoch).total_microseconds();
 
1304
    }
 
1305
    else
 
1306
    {
 
1307
      t_mark= (_end_timer - _epoch).total_microseconds();
 
1308
    }
1281
1309
 
1282
1310
    return t_mark; 
1283
1311
  }
1284
 
  inline uint64_t found_rows(void)
 
1312
 
 
1313
  uint64_t found_rows(void)
1285
1314
  {
1286
1315
    return limit_found_rows;
1287
1316
  }
 
1317
 
1288
1318
  /** Returns whether the session is currently inside a transaction */
1289
 
  inline bool inTransaction()
 
1319
  bool inTransaction()
1290
1320
  {
1291
1321
    return server_status & SERVER_STATUS_IN_TRANS;
1292
1322
  }
 
1323
 
1293
1324
  LEX_STRING *make_lex_string(LEX_STRING *lex_str,
1294
1325
                              const char* str, uint32_t length,
1295
1326
                              bool allocate_lex_string);
 
1327
 
1296
1328
  LEX_STRING *make_lex_string(LEX_STRING *lex_str,
1297
1329
                              const std::string &str,
1298
1330
                              bool allocate_lex_string);
1299
1331
 
1300
1332
  int send_explain_fields(select_result *result);
 
1333
 
1301
1334
  /**
1302
1335
    Clear the current error, if any.
1303
1336
    We do not clear is_fatal_error or is_fatal_sub_stmt_error since we