~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_parse.cc

  • Committer: Brian Aker
  • Date: 2009-06-08 16:51:22 UTC
  • mto: This revision was merged to the branch mainline in revision 1058.
  • Revision ID: brian@gaz-20090608165122-4zvh22zgsaqadcjy
Remove lock_tables list from session.

Show diffs side-by-side

added added

removed removed

Lines of Context:
67
67
  "NON-EXISTING", "ACTIVE", "IDLE", "PREPARED"
68
68
};
69
69
 
70
 
static void unlock_locked_tables(Session *session)
71
 
{
72
 
  if (session->locked_tables)
73
 
  {
74
 
    session->lock= session->locked_tables;
75
 
    session->locked_tables= 0;                  // Will be automatically closed
76
 
    session->close_thread_tables();                     // Free tables
77
 
  }
78
 
}
79
 
 
80
70
/**
81
71
  Mark all commands that somehow changes a table.
82
72
 
630
620
      TABLE in the same way. That way we avoid that a new table is
631
621
      created during a gobal read lock.
632
622
    */
633
 
    if (!session->locked_tables &&
634
 
        !(need_start_waiting= !wait_if_global_read_lock(session, 0, 1)))
 
623
    if (!(need_start_waiting= !wait_if_global_read_lock(session, 0, 1)))
635
624
    {
636
625
      res= 1;
637
626
      goto end_with_restore_list;
788
777
      if (! session->endActiveTransaction())
789
778
        goto error;
790
779
 
791
 
      if (!session->locked_tables &&
792
 
          !(need_start_waiting= !wait_if_global_read_lock(session, 0, 1)))
 
780
      if (!(need_start_waiting= !wait_if_global_read_lock(session, 0, 1)))
793
781
      {
794
782
        res= 1;
795
783
        break;
918
906
    if ((res= insert_precheck(session, all_tables)))
919
907
      break;
920
908
 
921
 
    if (!session->locked_tables &&
922
 
        !(need_start_waiting= !wait_if_global_read_lock(session, 0, 1)))
 
909
    if (!(need_start_waiting= !wait_if_global_read_lock(session, 0, 1)))
923
910
    {
924
911
      res= 1;
925
912
      break;
944
931
 
945
932
    unit->set_limit(select_lex);
946
933
 
947
 
    if (! session->locked_tables &&
948
 
        ! (need_start_waiting= ! wait_if_global_read_lock(session, 0, 1)))
 
934
    if (! (need_start_waiting= ! wait_if_global_read_lock(session, 0, 1)))
949
935
    {
950
936
      res= 1;
951
937
      break;
1001
987
      Don't allow this within a transaction because we want to use
1002
988
      re-generate table
1003
989
    */
1004
 
    if (session->locked_tables || session->inTransaction())
 
990
    if (session->inTransaction())
1005
991
    {
1006
992
      my_message(ER_LOCK_OR_ACTIVE_TRANSACTION, ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0));
1007
993
      goto error;
1016
1002
    assert(select_lex->offset_limit == 0);
1017
1003
    unit->set_limit(select_lex);
1018
1004
 
1019
 
    if (!session->locked_tables &&
1020
 
        !(need_start_waiting= !wait_if_global_read_lock(session, 0, 1)))
 
1005
    if (!(need_start_waiting= !wait_if_global_read_lock(session, 0, 1)))
1021
1006
    {
1022
1007
      res= 1;
1023
1008
      break;
1036
1021
      (TableList *)session->lex->auxiliary_table_list.first;
1037
1022
    multi_delete *del_result;
1038
1023
 
1039
 
    if (!session->locked_tables &&
1040
 
        !(need_start_waiting= !wait_if_global_read_lock(session, 0, 1)))
 
1024
    if (!(need_start_waiting= !wait_if_global_read_lock(session, 0, 1)))
1041
1025
    {
1042
1026
      res= 1;
1043
1027
      break;
1154
1138
      done FLUSH TABLES WITH READ LOCK + BEGIN. If this assumption becomes
1155
1139
      false, mysqldump will not work.
1156
1140
    */
1157
 
    unlock_locked_tables(session);
1158
 
    if (session->options & OPTION_TABLE_LOCK)
1159
 
    {
1160
 
      (void) session->endActiveTransaction();
1161
 
      session->options&= ~(OPTION_TABLE_LOCK);
1162
 
    }
1163
1141
    if (session->global_read_lock)
1164
1142
      unlock_global_read_lock(session);
1165
1143
    session->my_ok();
1199
1177
      my_error(ER_WRONG_DB_NAME, MYF(0), lex->name.str);
1200
1178
      break;
1201
1179
    }
1202
 
    if (session->locked_tables || session->inTransaction())
 
1180
    if (session->inTransaction())
1203
1181
    {
1204
1182
      my_message(ER_LOCK_OR_ACTIVE_TRANSACTION, ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0));
1205
1183
      goto error;
1216
1194
      my_error(ER_WRONG_DB_NAME, MYF(0), db->str);
1217
1195
      break;
1218
1196
    }
1219
 
    if (session->locked_tables || session->inTransaction())
 
1197
    if (session->inTransaction())
1220
1198
    {
1221
1199
      my_message(ER_LOCK_OR_ACTIVE_TRANSACTION, ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0));
1222
1200
      goto error;
2434
2412
  {
2435
2413
    if ((options & REFRESH_READ_LOCK) && session)
2436
2414
    {
2437
 
      /*
2438
 
        We must not try to aspire a global read lock if we have a write
2439
 
        locked table. This would lead to a deadlock when trying to
2440
 
        reopen (and re-lock) the table after the flush.
2441
 
      */
2442
 
      if (session->locked_tables)
2443
 
      {
2444
 
        THR_LOCK_DATA **lock_p= session->locked_tables->locks;
2445
 
        THR_LOCK_DATA **end_p= lock_p + session->locked_tables->lock_count;
2446
 
 
2447
 
        for (; lock_p < end_p; lock_p++)
2448
 
        {
2449
 
          if ((*lock_p)->type >= TL_WRITE_ALLOW_WRITE)
2450
 
          {
2451
 
            my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0));
2452
 
            return 1;
2453
 
          }
2454
 
        }
2455
 
      }
2456
2415
      if (lock_global_read_lock(session))
2457
 
        return 1;                               // Killed
 
2416
        return true;                               // Killed
2458
2417
      result= close_cached_tables(session, tables, (options & REFRESH_FAST) ?
2459
2418
                                  false : true, true);
2460
2419
      if (make_global_read_lock_block_commit(session)) // Killed
2461
2420
      {
2462
2421
        /* Don't leave things in a half-locked state */
2463
2422
        unlock_global_read_lock(session);
2464
 
        return 1;
 
2423
 
 
2424
        return true;
2465
2425
      }
2466
2426
    }
2467
2427
    else