~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/main.cc

  • Committer: Brian Aker
  • Date: 2011-02-04 09:28:16 UTC
  • mfrom: (2140.1.4 timestamp)
  • mto: This revision was merged to the branch mainline in revision 2144.
  • Revision ID: brian@tangent.org-20110204092816-2s32j9hlh6ztz7ti
Merge in fix for not found table (simplifies the caller as well).

Events are now just being processed on shared tables.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include <config.h>
 
20
#include "config.h"
21
21
 
22
22
#include <pthread.h>
23
23
#include <signal.h>
44
44
 
45
45
#include <boost/filesystem.hpp>
46
46
 
47
 
#include <drizzled/abort_exception.h>
48
 
#include <drizzled/catalog/local.h>
49
 
#include <drizzled/configmake.h>
50
 
#include <drizzled/data_home.h>
 
47
#include "drizzled/plugin.h"
 
48
#include "drizzled/gettext.h"
 
49
#include "drizzled/configmake.h"
 
50
#include "drizzled/session.h"
 
51
#include "drizzled/session/cache.h"
 
52
#include "drizzled/internal/my_sys.h"
 
53
#include "drizzled/unireg.h"
 
54
#include "drizzled/drizzled.h"
 
55
#include "drizzled/errmsg_print.h"
 
56
#include "drizzled/data_home.h"
 
57
#include "drizzled/plugin/listen.h"
 
58
#include "drizzled/plugin/client.h"
 
59
#include "drizzled/pthread_globals.h"
 
60
#include "drizzled/tztime.h"
 
61
#include "drizzled/signal_handler.h"
 
62
#include "drizzled/replication_services.h"
 
63
#include "drizzled/transaction_services.h"
 
64
#include "drizzled/catalog/local.h"
 
65
#include "drizzled/abort_exception.h"
 
66
 
51
67
#include <drizzled/debug.h>
52
 
#include <drizzled/drizzled.h>
53
 
#include <drizzled/errmsg_print.h>
54
 
#include <drizzled/gettext.h>
55
 
#include <drizzled/internal/my_sys.h>
56
 
#include <drizzled/plugin.h>
57
 
#include <drizzled/plugin/client.h>
58
 
#include <drizzled/plugin/listen.h>
59
 
#include <drizzled/plugin/monitored_in_transaction.h>
60
 
#include <drizzled/pthread_globals.h>
61
 
#include <drizzled/replication_services.h>
62
 
#include <drizzled/session.h>
63
 
#include <drizzled/session/cache.h>
64
 
#include <drizzled/signal_handler.h>
65
 
#include <drizzled/transaction_services.h>
66
 
#include <drizzled/tztime.h>
67
 
#include <drizzled/unireg.h>
68
 
#include <drizzled/util/backtrace.h>
69
 
#include <drizzled/current_session.h>
70
 
#include <drizzled/daemon.h>
 
68
 
 
69
#include "drizzled/util/backtrace.h"
71
70
 
72
71
using namespace drizzled;
73
72
using namespace std;
 
73
namespace fs=boost::filesystem;
74
74
 
75
75
static pthread_t select_thread;
76
76
static uint32_t thr_kill_signal;
77
77
 
78
 
extern bool opt_daemon;
79
 
 
80
78
 
81
79
/**
82
80
  All global error messages are sent here where the first one is stored
95
93
      session->is_fatal_error= 1;
96
94
 
97
95
    /*
98
 
      @TODO There are two exceptions mechanism (Session and sp_rcontext),
 
96
      TODO: There are two exceptions mechanism (Session and sp_rcontext),
99
97
      this could be improved by having a common stack of handlers.
100
98
    */
101
 
    if (session->handle_error(error, str, DRIZZLE_ERROR::WARN_LEVEL_ERROR))
102
 
      return;
 
99
    if (session->handle_error(error, str,
 
100
                          DRIZZLE_ERROR::WARN_LEVEL_ERROR))
 
101
      return;;
103
102
 
104
103
    /*
105
 
      session->getLex()->current_select == 0 if lex structure is not inited
 
104
      session->lex->current_select == 0 if lex structure is not inited
106
105
      (not query command (COM_QUERY))
107
106
    */
108
 
    if (! (session->getLex()->current_select &&
109
 
           session->getLex()->current_select->no_error && !session->is_fatal_error))
 
107
    if (! (session->lex->current_select &&
 
108
        session->lex->current_select->no_error && !session->is_fatal_error))
110
109
    {
111
110
      if (! session->main_da.is_error())            // Return only first message
112
111
      {
129
128
      session->no_warnings_for_error= true;
130
129
      push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_ERROR, error, str);
131
130
      session->no_warnings_for_error= false;
 
131
      }
132
132
    }
133
 
  }
134
133
 
135
 
  if (not session || MyFlags & ME_NOREFRESH)
136
 
  {
137
 
    errmsg_printf(error::ERROR, "%s: %s",internal::my_progname,str);
138
 
  }
 
134
    if (not session || MyFlags & ME_NOREFRESH)
 
135
    {
 
136
      errmsg_printf(error::ERROR, "%s: %s",internal::my_progname,str);
 
137
    }
139
138
}
140
139
 
141
140
static void init_signals(void)
247
246
 
248
247
  /* Function generates error messages before abort */
249
248
  error_handler_hook= my_message_sql;
250
 
 
251
249
  /* init_common_variables must get basic settings such as data_home_dir
252
250
     and plugin_load_list. */
253
 
  if (init_basic_variables(argc, argv))
254
 
    unireg_abort(1);                            // Will do exit
255
 
 
256
 
  if (opt_daemon)
257
 
  {
258
 
    if (signal(SIGHUP, SIG_IGN) == SIG_ERR)
259
 
    {
260
 
      perror("Failed to ignore SIGHUP");
261
 
    }
262
 
    if (daemonize())
263
 
    {
264
 
      fprintf(stderr, "failed to daemon() in order to daemonize\n");
265
 
      exit(EXIT_FAILURE);
266
 
    }
267
 
  }
268
 
 
269
 
  if (init_remaining_variables(modules))
 
251
  if (init_common_variables(argc, argv, modules))
270
252
    unireg_abort(1);                            // Will do exit
271
253
 
272
254
  /*
300
282
      unireg_abort(1);
301
283
    }
302
284
 
303
 
    boost::filesystem::path &full_data_home= getFullDataHome();
304
 
    full_data_home= boost::filesystem::system_complete(getDataHome());
305
 
    errmsg_printf(error::INFO, "Data Home directory is : %s", full_data_home.native_file_string().c_str());
 
285
    full_data_home= fs::system_complete(getDataHome());
306
286
  }
307
287
 
308
288
 
347
327
    unireg_abort(1);
348
328
 
349
329
  assert(plugin::num_trx_monitored_objects > 0);
350
 
  if (drizzle_rm_tmp_tables())
 
330
  if (drizzle_rm_tmp_tables() || my_tz_init((Session *)0, default_tz_name))
351
331
  {
352
332
    abort_loop= true;
353
333
    select_thread_in_use=0;
380
360
    }
381
361
  }
382
362
 
383
 
  if (opt_daemon)
384
 
    daemon_is_ready();
385
363
 
386
364
  /* 
387
365
    Listen for new connections and start new session for each connection