~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table_ident.h

  • Committer: Brian Aker
  • Date: 2009-02-08 03:02:04 UTC
  • Revision ID: brian@tangent.org-20090208030204-3gz6xwcq5niux5nm
Class rewrite of Session (aka get all of the junk out)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
4
 *  Copyright (C) 2008 Sun Microsystems
 
5
 *
 
6
 *  This program is free software; you can redistribute it and/or modify
 
7
 *  it under the terms of the GNU General Public License as published by
 
8
 *  the Free Software Foundation; version 2 of the License.
 
9
 *
 
10
 *  This program is distributed in the hope that it will be useful,
 
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 *  GNU General Public License for more details.
 
14
 *
 
15
 *  You should have received a copy of the GNU General Public License
 
16
 *  along with this program; if not, write to the Free Software
 
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
18
 */
 
19
 
 
20
 
 
21
#ifndef DRIZZLED_TABLE_IDENT_H
 
22
#define DRIZZLED_TABLE_IDENT_H
 
23
 
 
24
 
 
25
 
 
26
/* Structure for db & table in sql_yacc */
 
27
 
 
28
class Table_ident :public Sql_alloc
 
29
{
 
30
public:
 
31
  LEX_STRING db;
 
32
  LEX_STRING table;
 
33
  Select_Lex_Unit *sel;
 
34
  inline Table_ident(Session *session, LEX_STRING db_arg, LEX_STRING table_arg,
 
35
                     bool force)
 
36
    :table(table_arg), sel((Select_Lex_Unit *)0)
 
37
  {
 
38
    if (!force && (session->client_capabilities & CLIENT_NO_SCHEMA))
 
39
      db.str=0;
 
40
    else
 
41
      db= db_arg;
 
42
  }
 
43
  inline Table_ident(LEX_STRING table_arg)
 
44
    :table(table_arg), sel((Select_Lex_Unit *)0)
 
45
  {
 
46
    db.str=0;
 
47
  }
 
48
  /*
 
49
    This constructor is used only for the case when we create a derived
 
50
    table. A derived table has no name and doesn't belong to any database.
 
51
    Later, if there was an alias specified for the table, it will be set
 
52
    by add_table_to_list.
 
53
  */
 
54
  inline Table_ident(Select_Lex_Unit *s) : sel(s)
 
55
  {
 
56
    /* We must have a table name here as this is used with add_table_to_list */
 
57
    db.str= empty_c_string;                    /* a subject to casedn_str */
 
58
    db.length= 0;
 
59
    table.str= internal_table_name;
 
60
    table.length=1;
 
61
  }
 
62
  bool is_derived_table() const { return test(sel); }
 
63
  inline void change_db(char *db_name)
 
64
  {
 
65
    db.str= db_name; db.length= (uint) strlen(db_name);
 
66
  }
 
67
};
 
68
 
 
69
#endif /* DRIZZLED_TABLE_IDENT_H */