~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table_list.h

  • Committer: Olaf van der Spek
  • Date: 2011-02-12 18:24:24 UTC
  • mto: (2167.1.2 build) (2172.1.4 build)
  • mto: This revision was merged to the branch mainline in revision 2168.
  • Revision ID: olafvdspek@gmail.com-20110212182424-kgnm9osi7qo97at2
casts

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems
 
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
21
21
#ifndef DRIZZLED_TABLE_LIST_H
22
22
#define DRIZZLED_TABLE_LIST_H
23
23
 
 
24
#include <drizzled/nested_join.h>
24
25
#include <drizzled/table.h>
25
26
 
26
27
namespace drizzled
41
42
  class StorageEngine;
42
43
}
43
44
 
44
 
struct nested_join_st;
45
 
 
46
45
/**
47
46
 * A Table referenced in the FROM clause.
48
47
 *
94
93
    straight(false),
95
94
    force_index(false),
96
95
    ignore_leaves(false),
97
 
    create(false),
98
96
    join_using_fields(NULL),
99
97
    join_columns(NULL),
100
98
    next_name_resolution_table(NULL),
105
103
    select_lex(NULL),
106
104
    next_leaf(NULL),
107
105
    outer_join(0),
108
 
    shared(0),
109
 
    i_s_requested_object(0),
110
106
    db_length(0),
111
107
    table_name_length(0),
112
108
    dep_tables(0),
118
114
    internal_tmp_table(false),
119
115
    is_alias(false),
120
116
    is_fqtn(false),
121
 
    has_db_lookup_value(false),
122
 
    has_table_lookup_value(false)
 
117
    create(false)
123
118
  {}
124
119
 
125
120
  /**
133
128
  TableList *next_global; 
134
129
  TableList **prev_global;
135
130
 
 
131
private:
136
132
  char *db;
 
133
 
 
134
public:
 
135
  const char *getSchemaName()
 
136
  {
 
137
    return db;
 
138
  }
 
139
 
 
140
  char **getSchemaNamePtr()
 
141
  {
 
142
    return &db;
 
143
  }
 
144
 
 
145
  void setSchemaName(char *arg)
 
146
  {
 
147
    db= arg;
 
148
  }
 
149
 
137
150
  const char *alias;
 
151
 
 
152
private:
138
153
  char *table_name;
 
154
 
 
155
public:
 
156
  const char *getTableName()
 
157
  {
 
158
    return table_name;
 
159
  }
 
160
 
 
161
  char **getTableNamePtr()
 
162
  {
 
163
    return &table_name;
 
164
  }
 
165
 
 
166
  void setTableName(char *arg)
 
167
  {
 
168
    table_name= arg;
 
169
  }
 
170
 
139
171
  char *option; ///< Used by cache index
140
172
  Item *on_expr; ///< Used with outer join
141
173
  Table *table; ///< opened table
170
202
  bool force_index; ///< prefer index over table scan
171
203
  bool ignore_leaves; ///< preload only non-leaf nodes
172
204
 
173
 
  /**
174
 
   * This TableList object corresponds to the table to be created
175
 
   * so it is possible that it does not exist (used in CREATE TABLE
176
 
   * ... SELECT implementation).
177
 
   */
178
 
  bool create;
 
205
  /*
 
206
    is the table a cartesian join, assumption is yes unless "solved"
 
207
  */
 
208
  bool isCartesian() const;
179
209
 
180
210
  /** Field names in a USING clause for JOIN ... USING. */
181
211
  List<String> *join_using_fields;
212
242
  TableList *next_leaf;
213
243
  thr_lock_type lock_type;
214
244
  uint32_t outer_join; ///< Which join type
215
 
  uint32_t shared; ///<Used in multi-upd
216
 
  uint32_t i_s_requested_object;
217
245
  size_t db_length;
218
246
  size_t table_name_length;
219
 
  table_map dep_tables; ///< tables the table depends on
220
 
  table_map on_expr_dep_tables; ///< tables on expression depends on
221
 
  nested_join_st *nested_join; ///< if the element is a nested join
222
 
  TableList *embedding; ///< nested join containing the table
223
 
  List<TableList> *join_list; ///< join list the table belongs to
224
 
  plugin::StorageEngine *db_type; ///< table_type for handler
225
 
  char timestamp_buffer[20]; ///< buffer for timestamp (19+1)
226
 
  bool internal_tmp_table;
227
 
  /** true if an alias for this table was specified in the SQL. */
228
 
  bool is_alias;
229
 
  /** 
230
 
   * true if the table is referred to in the statement using a fully
231
 
   * qualified name (<db_name>.<table_name>).
232
 
   */
233
 
  bool is_fqtn;
234
 
 
235
 
  bool has_db_lookup_value;
236
 
  bool has_table_lookup_value;
237
247
 
238
248
  void set_underlying_merge();
239
249
  bool setup_underlying(Session *session);
386
396
   *   true found and reported an error.
387
397
   */
388
398
  bool process_index_hints(Table *table);
 
399
 
 
400
  friend std::ostream& operator<<(std::ostream& output, const TableList &list)
 
401
  {
 
402
    output << "TableList:(";
 
403
    output << list.db;
 
404
    output << ", ";
 
405
    output << list.table_name;
 
406
    output << ", ";
 
407
    output << list.alias;
 
408
    output << ", ";
 
409
    output << "is_natural_join:" << list.is_natural_join;
 
410
    output << ", ";
 
411
    output << "is_join_columns_complete:" << list.is_join_columns_complete;
 
412
    output << ", ";
 
413
    output << "straight:" << list.straight;
 
414
    output << ", ";
 
415
    output << "force_index" << list.force_index;
 
416
    output << ", ";
 
417
    output << "ignore_leaves:" << list.ignore_leaves;
 
418
    output << ", ";
 
419
    output << "create:" << list.create;
 
420
    output << ", ";
 
421
    output << "outer_join:" << list.outer_join;
 
422
    output << ", ";
 
423
    output << "nested_join:" << list.nested_join;
 
424
    output << ")";
 
425
 
 
426
    return output;  // for multiple << operators.
 
427
  }
 
428
 
 
429
  void setIsAlias(bool in_is_alias)
 
430
  {
 
431
    is_alias= in_is_alias;
 
432
  }
 
433
 
 
434
  void setIsFqtn(bool in_is_fqtn)
 
435
  {
 
436
    is_fqtn= in_is_fqtn;
 
437
  }
 
438
 
 
439
  void setCreate(bool in_create)
 
440
  {
 
441
    create= in_create;
 
442
  }
 
443
 
 
444
  void setInternalTmpTable(bool in_internal_tmp_table)
 
445
  {
 
446
    internal_tmp_table= in_internal_tmp_table;
 
447
  }
 
448
 
 
449
  void setDbType(plugin::StorageEngine *in_db_type)
 
450
  {
 
451
    db_type= in_db_type;
 
452
  }
 
453
 
 
454
  void setJoinList(List<TableList> *in_join_list)
 
455
  {
 
456
    join_list= in_join_list;
 
457
  }
 
458
 
 
459
  void setEmbedding(TableList *in_embedding)
 
460
  {
 
461
    embedding= in_embedding;
 
462
  }
 
463
 
 
464
  void setNestedJoin(NestedJoin *in_nested_join)
 
465
  {
 
466
    nested_join= in_nested_join;
 
467
  }
 
468
 
 
469
  void setDepTables(table_map in_dep_tables)
 
470
  {
 
471
    dep_tables= in_dep_tables;
 
472
  }
 
473
 
 
474
  void setOnExprDepTables(table_map in_on_expr_dep_tables)
 
475
  {
 
476
    on_expr_dep_tables= in_on_expr_dep_tables;
 
477
  }
 
478
 
 
479
  bool getIsAlias() const
 
480
  {
 
481
    return is_alias;
 
482
  }
 
483
 
 
484
  bool getIsFqtn() const
 
485
  {
 
486
    return is_fqtn;
 
487
  }
 
488
 
 
489
  bool isCreate() const
 
490
  {
 
491
    return create;
 
492
  }
 
493
 
 
494
  bool getInternalTmpTable() const
 
495
  {
 
496
    return internal_tmp_table;
 
497
  }
 
498
 
 
499
  plugin::StorageEngine *getDbType() const
 
500
  {
 
501
    return db_type;
 
502
  }
 
503
 
 
504
  TableList *getEmbedding() const
 
505
  {
 
506
    return embedding;
 
507
  }
 
508
 
 
509
  List<TableList> *getJoinList() const
 
510
  {
 
511
    return join_list;
 
512
  }
 
513
 
 
514
  NestedJoin *getNestedJoin() const
 
515
  {
 
516
    return nested_join;
 
517
  }
 
518
 
 
519
  table_map getDepTables() const
 
520
  {
 
521
    return dep_tables;
 
522
  }
 
523
 
 
524
  table_map getOnExprDepTables() const
 
525
  {
 
526
    return on_expr_dep_tables;
 
527
  }
 
528
 
 
529
  void unlock_table_name();
 
530
  void unlock_table_names(TableList *last_table= NULL);
 
531
 
 
532
private:
 
533
  table_map dep_tables; ///< tables the table depends on
 
534
  table_map on_expr_dep_tables; ///< tables on expression depends on
 
535
  NestedJoin *nested_join; ///< if the element is a nested join
 
536
  TableList *embedding; ///< nested join containing the table
 
537
  List<TableList> *join_list; ///< join list the table belongs to
 
538
  plugin::StorageEngine *db_type; ///< table_type for handler
 
539
  bool internal_tmp_table;
 
540
 
 
541
  /** true if an alias for this table was specified in the SQL. */
 
542
  bool is_alias;
 
543
 
 
544
  /** 
 
545
   * true if the table is referred to in the statement using a fully
 
546
   * qualified name (<db_name>.<table_name>).
 
547
   */
 
548
  bool is_fqtn;
 
549
 
389
550
  /**
390
 
   * Creates a table definition cache key for this table entry.
391
 
   *
392
 
   * @param[out] Create key here (must be of size MAX_DBKEY_LENGTH)
393
 
   *
394
 
   * @note
395
 
   *
396
 
   * The table cache_key is created from:
397
 
   *   db_name + \0
398
 
   *   table_name + \0
399
 
   *
400
 
   * if the table is a tmp table, we add the following to make each tmp table
401
 
   * unique on the slave:
402
 
   *
403
 
   * 4 bytes for master thread id
404
 
   * 4 bytes pseudo thread id
405
 
   *
406
 
   * @retval
407
 
   *  Length of key
 
551
   * This TableList object corresponds to the table to be created
 
552
   * so it is possible that it does not exist (used in CREATE TABLE
 
553
   * ... SELECT implementation).
408
554
   */
409
 
  uint32_t create_table_def_key(char *key);
 
555
  bool create;
 
556
 
410
557
};
411
558
 
412
559
void close_thread_tables(Session *session);