~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_select.cc

  • Committer: Andrew Hutchings
  • Date: 2011-02-07 17:20:59 UTC
  • mfrom: (2148 staging)
  • mto: (2148.2.3 build)
  • mto: This revision was merged to the branch mainline in revision 2149.
  • Revision ID: andrew@linuxjedi.co.uk-20110207172059-dyeahrgzrlincoe3
Merge with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
2307
2307
  @param cond       condition whose multiple equalities are to be checked
2308
2308
  @param table      constant table that has been read
2309
2309
*/
2310
 
static void update_const_equal_items(COND *cond, JoinTable *tab)
 
2310
void update_const_equal_items(COND *cond, JoinTable *tab)
2311
2311
{
2312
2312
  if (!(cond->used_tables() & tab->table->map))
2313
2313
    return;
2606
2606
         position:
2607
2607
          1. join->cur_embedding_map - bitmap of pairs of brackets (aka nested
2608
2608
             joins) we've opened but didn't close.
2609
 
          2. {each nested_join_st structure not simplified away}->counter - number
 
2609
          2. {each NestedJoin class not simplified away}->counter - number
2610
2610
             of this nested join's children that have already been added to to
2611
2611
             the partial join order.
2612
2612
  @endverbatim
3367
3367
  return 0;
3368
3368
}
3369
3369
 
3370
 
int join_read_const_table(JoinTable *tab, optimizer::Position *pos)
3371
 
{
3372
 
  int error;
3373
 
  Table *table=tab->table;
3374
 
  table->const_table=1;
3375
 
  table->null_row=0;
3376
 
  table->status=STATUS_NO_RECORD;
3377
 
 
3378
 
  if (tab->type == AM_SYSTEM)
3379
 
  {
3380
 
    if ((error=join_read_system(tab)))
3381
 
    {                                           // Info for DESCRIBE
3382
 
      tab->info="const row not found";
3383
 
      /* Mark for EXPLAIN that the row was not found */
3384
 
      pos->setFanout(0.0);
3385
 
      pos->clearRefDependMap();
3386
 
      if (! table->maybe_null || error > 0)
3387
 
        return(error);
3388
 
    }
3389
 
  }
3390
 
  else
3391
 
  {
3392
 
    if (! table->key_read && 
3393
 
        table->covering_keys.test(tab->ref.key) && 
3394
 
        ! table->no_keyread &&
3395
 
        (int) table->reginfo.lock_type <= (int) TL_READ_WITH_SHARED_LOCKS)
3396
 
    {
3397
 
      table->key_read=1;
3398
 
      table->cursor->extra(HA_EXTRA_KEYREAD);
3399
 
      tab->index= tab->ref.key;
3400
 
    }
3401
 
    error=join_read_const(tab);
3402
 
    if (table->key_read)
3403
 
    {
3404
 
      table->key_read=0;
3405
 
      table->cursor->extra(HA_EXTRA_NO_KEYREAD);
3406
 
    }
3407
 
    if (error)
3408
 
    {
3409
 
      tab->info="unique row not found";
3410
 
      /* Mark for EXPLAIN that the row was not found */
3411
 
      pos->setFanout(0.0);
3412
 
      pos->clearRefDependMap();
3413
 
      if (!table->maybe_null || error > 0)
3414
 
        return(error);
3415
 
    }
3416
 
  }
3417
 
  if (*tab->on_expr_ref && !table->null_row)
3418
 
  {
3419
 
    if ((table->null_row= test((*tab->on_expr_ref)->val_int() == 0)))
3420
 
      table->mark_as_null_row();
3421
 
  }
3422
 
  if (!table->null_row)
3423
 
    table->maybe_null=0;
3424
 
 
3425
 
  /* Check appearance of new constant items in Item_equal objects */
3426
 
  Join *join= tab->join;
3427
 
  if (join->conds)
3428
 
    update_const_equal_items(join->conds, tab);
3429
 
  TableList *tbl;
3430
 
  for (tbl= join->select_lex->leaf_tables; tbl; tbl= tbl->next_leaf)
3431
 
  {
3432
 
    TableList *embedded;
3433
 
    TableList *embedding= tbl;
3434
 
    do
3435
 
    {
3436
 
      embedded= embedding;
3437
 
      if (embedded->on_expr)
3438
 
         update_const_equal_items(embedded->on_expr, tab);
3439
 
      embedding= embedded->getEmbedding();
3440
 
    }
3441
 
    while (embedding &&
3442
 
           embedding->getNestedJoin()->join_list.head() == embedded);
3443
 
  }
3444
 
 
3445
 
  return(0);
3446
 
}
3447
3370
 
3448
3371
int join_read_system(JoinTable *tab)
3449
3372
{