~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_parse.cc

  • Committer: Lee Bieber
  • Date: 2010-11-20 01:33:21 UTC
  • mfrom: (1878.10.4 drizzle_bug665252)
  • Revision ID: kalebral@gmail.com-20101120013321-7nk9lq4nnr20zk6b
Merge Billy - removed my_getsysdate, my_micro_time and my_micro_time_and_time and replaced with boost::date_time for compatibility.

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
#include <drizzled/statement.h>
40
40
#include <drizzled/statement/alter_table.h>
41
41
#include "drizzled/probes.h"
42
 
#include "drizzled/session/cache.h"
 
42
#include "drizzled/session_list.h"
43
43
#include "drizzled/global_charset_info.h"
44
44
 
45
45
#include "drizzled/plugin/logging.h"
222
222
      break;                                    // fatal error is set
223
223
    DRIZZLE_QUERY_START(session->getQueryString()->c_str(),
224
224
                        session->thread_id,
225
 
                        const_cast<const char *>(session->schema()->c_str()));
 
225
                        const_cast<const char *>(session->db.empty() ? "" : session->db.c_str()));
226
226
 
 
227
    plugin::QueryRewriter::rewriteQuery(session->getSchema(), session->getQueryString());
227
228
    mysql_parse(session, session->getQueryString()->c_str(), session->getQueryString()->length());
228
229
 
229
230
    break;
743
744
      {
744
745
        DRIZZLE_QUERY_EXEC_START(session->getQueryString()->c_str(),
745
746
                                 session->thread_id,
746
 
                                 const_cast<const char *>(session->schema()->c_str()));
 
747
                                 const_cast<const char *>(session->db.empty() ? "" : session->db.c_str()));
747
748
        // Implement Views here --Brian
748
749
        /* Actually execute the query */
749
750
        try 
754
755
        {
755
756
          // Just try to catch any random failures that could have come
756
757
          // during execution.
757
 
          unireg_abort(1);
758
758
        }
759
759
        DRIZZLE_QUERY_EXEC_DONE(0);
760
760
      }
959
959
 
960
960
  ptr->alias= alias_str;
961
961
  ptr->setIsAlias(alias ? true : false);
 
962
  if (table->table.length)
 
963
    table->table.length= my_casedn_str(files_charset_info, table->table.str);
962
964
  ptr->setTableName(table->table.str);
963
965
  ptr->table_name_length=table->table.length;
964
966
  ptr->lock_type=   lock_type;
1415
1417
 
1416
1418
 
1417
1419
/**
 
1420
  kill on thread.
 
1421
 
 
1422
  @param session                        Thread class
 
1423
  @param id                     Thread id
 
1424
  @param only_kill_query        Should it kill the query or the connection
 
1425
 
 
1426
  @note
 
1427
    This is written such that we have a short lock on LOCK_thread_count
 
1428
*/
 
1429
 
 
1430
static unsigned int kill_one_thread(session_id_t id, bool only_kill_query)
 
1431
{
 
1432
  uint32_t error= ER_NO_SUCH_THREAD;
 
1433
  
 
1434
  Session::shared_ptr session= session::Cache::singleton().find(id);
 
1435
 
 
1436
  if (not session)
 
1437
    return error;
 
1438
 
 
1439
  if (session->isViewable())
 
1440
  {
 
1441
    session->awake(only_kill_query ? Session::KILL_QUERY : Session::KILL_CONNECTION);
 
1442
    error= 0;
 
1443
  }
 
1444
 
 
1445
  return error;
 
1446
}
 
1447
 
 
1448
 
 
1449
/*
 
1450
  kills a thread and sends response
 
1451
 
 
1452
  SYNOPSIS
 
1453
    sql_kill()
 
1454
    session                     Thread class
 
1455
    id                  Thread id
 
1456
    only_kill_query     Should it kill the query or the connection
 
1457
*/
 
1458
 
 
1459
void sql_kill(Session *session, int64_t id, bool only_kill_query)
 
1460
{
 
1461
  uint32_t error;
 
1462
 
 
1463
  if (not (error= kill_one_thread(id, only_kill_query)))
 
1464
    session->my_ok();
 
1465
  else
 
1466
    my_error(error, MYF(0), id);
 
1467
}
 
1468
 
 
1469
 
 
1470
/**
1418
1471
  Check if the select is a simple select (not an union).
1419
1472
 
1420
1473
  @retval
1542
1595
 
1543
1596
 
1544
1597
/**
 
1598
  CREATE TABLE query pre-check.
 
1599
 
 
1600
  @param session                        Thread handler
 
1601
  @param tables         Global table list
 
1602
  @param create_table           Table which will be created
 
1603
 
 
1604
  @retval
 
1605
    false   OK
 
1606
  @retval
 
1607
    true   Error
 
1608
*/
 
1609
 
 
1610
bool create_table_precheck(TableIdentifier &identifier)
 
1611
{
 
1612
  if (not plugin::StorageEngine::canCreateTable(identifier))
 
1613
  {
 
1614
    my_error(ER_DBACCESS_DENIED_ERROR, MYF(0), "", "", identifier.getSchemaName().c_str());
 
1615
    return true;
 
1616
  }
 
1617
 
 
1618
  if (not plugin::StorageEngine::doesSchemaExist(identifier))
 
1619
  {
 
1620
    my_error(ER_BAD_DB_ERROR, MYF(0), identifier.getSchemaName().c_str());
 
1621
    return true;
 
1622
  }
 
1623
 
 
1624
  return false;
 
1625
}
 
1626
 
 
1627
 
 
1628
/**
1545
1629
  negate given expression.
1546
1630
 
1547
1631
  @param session  thread handler