1 | // TABUTIL.H Olivier Bertrand 2013 |
2 | // Defines the TAB catalog tables |
3 | |
4 | #ifndef TABUTIL |
5 | #define TABUTIL 1 |
6 | |
7 | //#include "tabtbl.h" |
8 | |
9 | typedef class PRXDEF *PPRXDEF; |
10 | typedef class TDBPRX *PTDBPRX; |
11 | typedef class XXLCOL *PXXLCOL; |
12 | typedef class PRXCOL *PPRXCOL; |
13 | typedef class TBCDEF *PTBCDEF; |
14 | typedef class TDBTBC *PTDBTBC; |
15 | |
16 | TABLE_SHARE *GetTableShare(PGLOBAL g, THD *thd, const char *db, |
17 | const char *name, bool& mysql); |
18 | PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db, |
19 | const char *name, bool& info); |
20 | |
21 | void Remove_tshp(PCATLG cat); |
22 | |
23 | /* -------------------------- PROXY classes -------------------------- */ |
24 | |
25 | /***********************************************************************/ |
26 | /* PROXY: table based on another table. Can be used to have a */ |
27 | /* different view on an existing table. */ |
28 | /* However, its real use is to be the base of TBL and PRX tables. */ |
29 | /***********************************************************************/ |
30 | |
31 | /***********************************************************************/ |
32 | /* PRX table. */ |
33 | /***********************************************************************/ |
34 | class DllExport PRXDEF : public TABDEF { /* Logical table description */ |
35 | friend class TDBPRX; |
36 | friend class TDBTBC; |
37 | public: |
38 | // Constructor |
39 | PRXDEF(void); |
40 | |
41 | // Implementation |
42 | virtual const char *GetType(void) {return "PRX" ;} |
43 | |
44 | // Methods |
45 | virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); |
46 | virtual PTDB GetTable(PGLOBAL g, MODE mode); |
47 | |
48 | protected: |
49 | // Members |
50 | PTABLE Tablep; /* The object table */ |
51 | }; // end of PRXDEF |
52 | |
53 | /***********************************************************************/ |
54 | /* This is the class declaration for the XCSV table. */ |
55 | /***********************************************************************/ |
56 | class DllExport TDBPRX : public TDBASE { |
57 | friend class PRXDEF; |
58 | friend class PRXCOL; |
59 | public: |
60 | // Constructors |
61 | TDBPRX(PPRXDEF tdp); |
62 | TDBPRX(PTDBPRX tdbp); |
63 | |
64 | // Implementation |
65 | virtual AMT GetAmType(void) {return TYPE_AM_PRX;} |
66 | virtual PTDB Duplicate(PGLOBAL g) |
67 | {return (PTDB)new(g) TDBPRX(this);} |
68 | |
69 | // Methods |
70 | virtual PTDB Clone(PTABS t); |
71 | virtual int GetRecpos(void) {return Tdbp->GetRecpos();} |
72 | virtual void ResetDB(void) {Tdbp->ResetDB();} |
73 | virtual int RowNumber(PGLOBAL g, bool b = FALSE); |
74 | virtual PCSZ GetServer(void) {return (Tdbp) ? Tdbp->GetServer() : (PSZ)"?" ;} |
75 | |
76 | // Database routines |
77 | virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); |
78 | virtual bool InitTable(PGLOBAL g); |
79 | virtual int Cardinality(PGLOBAL g); |
80 | virtual int GetMaxSize(PGLOBAL g); |
81 | virtual bool OpenDB(PGLOBAL g); |
82 | virtual int ReadDB(PGLOBAL g); |
83 | virtual int WriteDB(PGLOBAL g); |
84 | virtual int DeleteDB(PGLOBAL g, int irc); |
85 | virtual void CloseDB(PGLOBAL g) {if (Tdbp) Tdbp->CloseDB(g);} |
86 | PTDB GetSubTable(PGLOBAL g, PTABLE tabp, bool b = false); |
87 | void RemoveNext(PTABLE tp); |
88 | |
89 | protected: |
90 | // Members |
91 | PTDB Tdbp; // The object table |
92 | }; // end of class TDBPRX |
93 | |
94 | /***********************************************************************/ |
95 | /* Class PRXCOL: PRX access method column descriptor. */ |
96 | /* This A.M. is used for PRX tables. */ |
97 | /***********************************************************************/ |
98 | class DllExport PRXCOL : public COLBLK { |
99 | friend class TDBPRX; |
100 | friend class TDBTBL; |
101 | friend class TDBOCCUR; |
102 | public: |
103 | // Constructors |
104 | PRXCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am = "PRX" ); |
105 | PRXCOL(PRXCOL *colp, PTDB tdbp); // Constructor used in copy process |
106 | |
107 | // Implementation |
108 | virtual int GetAmType(void) {return TYPE_AM_PRX;} |
109 | |
110 | // Methods |
111 | using COLBLK::Init; |
112 | virtual void Reset(void); |
113 | virtual bool IsSpecial(void) {return Pseudo;} |
114 | virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check) |
115 | {return false;} |
116 | virtual void ReadColumn(PGLOBAL g); |
117 | virtual void WriteColumn(PGLOBAL g); |
118 | virtual bool Init(PGLOBAL g, PTDB tp); |
119 | |
120 | protected: |
121 | char *Decode(PGLOBAL g, const char *cnm); |
122 | |
123 | // Default constructor not to be used |
124 | PRXCOL(void) {} |
125 | |
126 | // Members |
127 | PCOL Colp; // Points to matching table column |
128 | PVAL To_Val; // To the matching column value |
129 | bool Pseudo; // TRUE for special columns |
130 | int Colnum; // Used when retrieving columns by number |
131 | }; // end of class PRXCOL |
132 | |
133 | /***********************************************************************/ |
134 | /* This is the class declaration for the TBC column catalog table. */ |
135 | /***********************************************************************/ |
136 | class TDBTBC : public TDBCAT { |
137 | public: |
138 | // Constructors |
139 | TDBTBC(PPRXDEF tdp); |
140 | |
141 | protected: |
142 | // Specific routines |
143 | virtual PQRYRES GetResult(PGLOBAL g); |
144 | |
145 | // Members |
146 | PSZ Db; // Database of the table |
147 | PSZ Tab; // Table name |
148 | }; // end of class TDBMCL |
149 | |
150 | class XCOLBLK : public COLBLK { |
151 | friend class PRXCOL; |
152 | }; // end of class XCOLBLK |
153 | |
154 | #endif // TABUTIL |
155 | |