~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/join_table.cc

  • Committer: vjsamuel1990 at gmail
  • Date: 2011-02-04 18:26:39 UTC
  • mto: This revision was merged to the branch mainline in revision 2147.
  • Revision ID: vjsamuel1990@gmail.com-20110204182639-e8tbwkbdzdw86it6
Merge encapsulate join_read_const_table() into JoinTable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include "config.h"
22
22
#include <drizzled/join_table.h>
23
23
#include <drizzled/field/blob.h>
 
24
#include <drizzled/sql_select.h>
24
25
 
25
26
namespace drizzled
26
27
{
27
28
 
 
29
int JoinTable::join_read_const_table(optimizer::Position *pos)
 
30
{
 
31
  int error;
 
32
  Table *Table= this->table;
 
33
  Table->const_table=1;
 
34
  Table->null_row=0;
 
35
  Table->status=STATUS_NO_RECORD;
 
36
 
 
37
  if (this->type == AM_SYSTEM)
 
38
  {
 
39
    if ((error=join_read_system(this)))
 
40
    {                                           // Info for DESCRIBE
 
41
      this->info="const row not found";
 
42
      /* Mark for EXPLAIN that the row was not found */
 
43
      pos->setFanout(0.0);
 
44
      pos->clearRefDependMap();
 
45
      if (! Table->maybe_null || error > 0)
 
46
        return(error);
 
47
    }
 
48
  }
 
49
  else
 
50
  {
 
51
    if (! Table->key_read && 
 
52
        Table->covering_keys.test(this->ref.key) && 
 
53
        ! Table->no_keyread &&
 
54
        (int) Table->reginfo.lock_type <= (int) TL_READ_WITH_SHARED_LOCKS)
 
55
    {
 
56
      Table->key_read=1;
 
57
      Table->cursor->extra(HA_EXTRA_KEYREAD);
 
58
      this->index= this->ref.key;
 
59
    }
 
60
    error=join_read_const(this);
 
61
    if (Table->key_read)
 
62
    {
 
63
      Table->key_read=0;
 
64
      Table->cursor->extra(HA_EXTRA_NO_KEYREAD);
 
65
    }
 
66
    if (error)
 
67
    {
 
68
      this->info="unique row not found";
 
69
      /* Mark for EXPLAIN that the row was not found */
 
70
      pos->setFanout(0.0);
 
71
      pos->clearRefDependMap();
 
72
      if (!Table->maybe_null || error > 0)
 
73
        return(error);
 
74
    }
 
75
  }
 
76
  if (*this->on_expr_ref && !Table->null_row)
 
77
  {
 
78
    if ((Table->null_row= test((*this->on_expr_ref)->val_int() == 0)))
 
79
      Table->mark_as_null_row();
 
80
  }
 
81
  if (!Table->null_row)
 
82
    Table->maybe_null=0;
 
83
 
 
84
  /* Check appearance of new constant items in Item_equal objects */
 
85
  Join *Join= this->join;
 
86
  if (Join->conds)
 
87
    update_const_equal_items(Join->conds, this);
 
88
  TableList *tbl;
 
89
  for (tbl= Join->select_lex->leaf_tables; tbl; tbl= tbl->next_leaf)
 
90
  {
 
91
    TableList *embedded;
 
92
    TableList *embedding= tbl;
 
93
    do
 
94
    {
 
95
      embedded= embedding;
 
96
      if (embedded->on_expr)
 
97
         update_const_equal_items(embedded->on_expr, this);
 
98
      embedding= embedded->getEmbedding();
 
99
    }
 
100
    while (embedding &&
 
101
           embedding->getNestedJoin()->join_list.head() == embedded);
 
102
  }
 
103
 
 
104
  return(0);
 
105
}
 
106
 
28
107
void JoinTable::readCachedRecord()
29
108
{
30
109
  unsigned char *pos;