File: MYXResultSetSource.h

package info (click to toggle)
mysql-gui-tools 5.0r14%2BopenSUSE-2.1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 116,956 kB
  • ctags: 48,715
  • sloc: sql: 341,918; pascal: 276,698; ansic: 91,020; cpp: 90,451; objc: 33,236; sh: 29,481; yacc: 10,756; xml: 10,589; java: 10,079; php: 2,806; python: 2,092; makefile: 1,783; perl: 4
file content (121 lines) | stat: -rw-r--r-- 3,203 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/* Copyright (C) 2005 MySQL AB

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */

#ifndef _MYXRESULTSETSOURCE_H_
#define _MYXRESULTSETSOURCE_H_

#include "myx_util_public_interface.h"
#include <vector>
#include <list>

enum MYXRSColumnType {
  MYX_RSCT_INTEGER= 0,
    MYX_RSCT_BIGINT,
    MYX_RSCT_DOUBLE,
    MYX_RSCT_STRING,
    MYX_RSCT_DATE,
    MYX_RSCT_TIME,
    MYX_RSCT_DATETIME,
    MYX_RSCT_BLOB,
    MYX_RSCT_TEXT,
    MYX_RSCT_ENUM,
    MYX_RSCT_SET,
    MYX_RSCT_DECIMAL
};


class MYXResultSetStorage;

class MYXResultSetSource {
  public:
    struct ColumnInfo {
      char *catalog;
      char *schema;
      char *table;
      char *name;
      int length;
      int display_length;
      int display_decimals;
      MYXRSColumnType type;
      char *type_name;
      unsigned int is_pk:1;
      unsigned int not_null:1;
      unsigned int is_autoincrement:1;
      unsigned int is_blob:1;
      
      ~ColumnInfo() {
        g_free(catalog);
        g_free(schema);
        g_free(table);
        g_free(name);
        g_free(type_name);
      };
    };
    
    struct TimeValue {
      int year, month, day;
      int hour, minute, second;
      unsigned long second_frac;
    };
    
    struct QueryParameter {
      MYXRSColumnType type;
      char *value;
      size_t value_length;
      int value_int;
      double value_double;
      bigint value_bigint;
      TimeValue value_time;
      MYXResultSetStorage *master;
      char *master_column;
      bool is_null;
    };

  protected:
    char *_query;

    std::list<char*> _schema_stack;
    
  public:
    virtual ~MYXResultSetSource() {};

    virtual bool prepare(const char *query)= 0;
    virtual bool execute_prepared(QueryParameter *params, int paramCount)= 0;
    virtual bool close_prepared()= 0;
    virtual bool supports_prepared()= 0;

    virtual bool execute(const char *query) { return execute(query, strlen(query)); };
    virtual bool execute(const char *query, size_t length)= 0;

    virtual void push_schema(const char *schema)= 0;
    virtual void pop_schema()= 0;

    virtual int get_error_number()= 0;
    virtual const char *get_error_message()= 0;
    
    virtual bool next()= 0;
    virtual bool get_value(int column, const char *&value, size_t &length)= 0;
    virtual bool get_row(const char **values, size_t *lengths)= 0;
    virtual void reset()= 0;

    virtual std::vector<ColumnInfo*> get_columns()= 0;

    virtual bool eof()= 0;
    virtual unsigned long get_server_version()= 0;
};


#endif /* _MYXRESULTSETSOURCE_H_ */