~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/console/console.cc

  • Committer: Andrew Hutchings
  • Date: 2011-02-01 10:23:22 UTC
  • mto: (2136.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 2137.
  • Revision ID: andrew@linuxjedi.co.uk-20110201102322-oxztcyrjzg3c7yta
Fix counters cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
   along with this program; if not, write to the Free Software
14
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
15
15
 
16
 
#include <config.h>
17
 
#include <drizzled/field.h>
 
16
#include "config.h"
18
17
#include <drizzled/gettext.h>
19
18
#include <drizzled/plugin/listen_tcp.h>
20
19
#include <drizzled/plugin/client.h>
21
20
#include <drizzled/session.h>
22
21
#include <drizzled/module/option_map.h>
 
22
 
23
23
#include <drizzled/plugin/catalog.h>
24
 
#include <drizzled/plugin.h>
25
24
 
26
25
#include <iostream>
27
26
 
116
115
  virtual bool authenticate(void)
117
116
  {
118
117
    printDebug("authenticate");
119
 
    identifier::user::mptr user= identifier::User::make_shared();
 
118
    identifier::User::shared_ptr user= identifier::User::make_shared();
120
119
    user->setUser(username);
121
120
    session->setUser(user);
122
121
 
181
180
    printDebug("sendEOF");
182
181
  }
183
182
 
184
 
  virtual void sendError(const drizzled::error_t sql_errno, const char *err)
 
183
  virtual void sendError(uint32_t sql_errno, const char *err)
185
184
  {
186
 
    cout << "Error: " << static_cast<long>(sql_errno) << " " << err << endl;
 
185
    cout << "Error: " << sql_errno << " " << err << endl;
187
186
  }
188
187
 
189
188
  virtual bool sendFields(List<Item> *list)
190
189
  {
191
 
    List<Item>::iterator it(list->begin());
 
190
    List_iterator_fast<Item> it(*list);
192
191
    Item *item;
193
192
 
194
193
    column= 0;
293
292
    return false;
294
293
  }
295
294
 
296
 
  bool isConsole() const
297
 
  {
298
 
    return true;
299
 
  }
300
 
 
301
 
  bool isInteractive() const
 
295
  bool isConsole()
302
296
  {
303
297
    return true;
304
298
  }
346
340
 
347
341
    if (pipe(pipe_fds) == -1)
348
342
    {
349
 
      errmsg_printf(error::ERROR, _("pipe() failed with errno %d"), errno);
 
343
      errmsg_printf(ERRMSG_LVL_ERROR, _("pipe() failed with errno %d"), errno);
350
344
      return true;
351
345
    }
352
346
 
367
361
static int init(drizzled::module::Context &context)
368
362
{
369
363
  const module::option_map &vm= context.getOptions();
370
 
  context.add(new ListenConsole("console", vm["username"].as<string>(), 
371
 
    vm["password"].as<string>(), vm["schema"].as<string>(), vm["catalog"].as<string>()));
 
364
  const string username(vm.count("username") ? vm["username"].as<string>() : "");
 
365
  const string password(vm.count("password") ? vm["password"].as<string>() : "");
 
366
  const string schema(vm.count("schema") ? vm["schema"].as<string>() : "");
 
367
 
 
368
  const std::string catalog(vm.count("catalog") ? vm["catalog"].as<string>() : "LOCAL");
 
369
 
 
370
  context.add(new ListenConsole("console", username, password, schema, catalog));
 
371
 
372
372
  return 0;
373
373
}
374
374
 
381
381
          po::value<bool>(&debug_enabled)->default_value(false)->zero_tokens(),
382
382
          N_("Turn on extra debugging."));
383
383
  context("username",
384
 
          po::value<string>()->default_value(""),
 
384
          po::value<string>(),
385
385
          N_("User to use for auth."));
386
386
  context("password",
387
 
          po::value<string>()->default_value(""),
 
387
          po::value<string>(),
388
388
          N_("Password to use for auth."));
389
389
  context("catalog",
390
 
          po::value<string>()->default_value("LOCAL"),
 
390
          po::value<string>(),
391
391
          N_("Default catalog to use."));
392
392
  context("schema",
393
 
          po::value<string>()->default_value(""),
 
393
          po::value<string>(),
394
394
          N_("Default schema to use."));
395
395
}
396
396