1 | /* |
2 | * PROGRAM: Firebird basic API |
3 | * MODULE: firebird/Provider.h |
4 | * DESCRIPTION: Interfaces, used by yValve |
5 | * |
6 | * The contents of this file are subject to the Initial |
7 | * Developer's Public License Version 1.0 (the "License"); |
8 | * you may not use this file except in compliance with the |
9 | * License. You may obtain a copy of the License at |
10 | * http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl. |
11 | * |
12 | * Software distributed under the License is distributed AS IS, |
13 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. |
14 | * See the License for the specific language governing rights |
15 | * and limitations under the License. |
16 | * |
17 | * The Original Code was created by Alex Peshkov |
18 | * for the Firebird Open Source RDBMS project. |
19 | * |
20 | * Copyright (c) 2010 Alex Peshkov <peshkoff at mail.ru> |
21 | * and all contributors signed below. |
22 | * |
23 | * All Rights Reserved. |
24 | * Contributor(s): ______________________________________. |
25 | * |
26 | * |
27 | */ |
28 | |
29 | #ifndef FB_PROVIDER_INTERFACE |
30 | #define FB_PROVIDER_INTERFACE |
31 | |
32 | #include "./Plugin.h" |
33 | |
34 | namespace Firebird { |
35 | |
36 | // This interfaces are implemented by yvalve code and by each of providers. |
37 | |
38 | class IAttachment; // Forward |
39 | class ICryptKeyCallback; // From Crypt.h |
40 | |
41 | class IEventCallback : public IRefCounted |
42 | { |
43 | public: |
44 | virtual void FB_CARG eventCallbackFunction(unsigned int length, const unsigned char* events) = 0; |
45 | }; |
46 | #define FB_EVENT_CALLBACK_VERSION (FB_REFCOUNTED_VERSION + 1) |
47 | |
48 | /* |
49 | class ShutdownCallback |
50 | { |
51 | public: |
52 | virtual void FB_CARG shutdownCallbackFunction(int reason, int mask) = 0; |
53 | }; |
54 | */ |
55 | |
56 | class IBlob : public IRefCounted |
57 | { |
58 | public: |
59 | virtual void FB_CARG getInfo(IStatus* status, |
60 | unsigned int itemsLength, const unsigned char* items, |
61 | unsigned int bufferLength, unsigned char* buffer) = 0; |
62 | virtual unsigned int FB_CARG getSegment(IStatus* status, unsigned int length, |
63 | void* buffer) = 0; // returns real length |
64 | virtual void FB_CARG putSegment(IStatus* status, unsigned int length, |
65 | const void* buffer) = 0; |
66 | virtual void FB_CARG cancel(IStatus* status) = 0; |
67 | virtual void FB_CARG close(IStatus* status) = 0; |
68 | virtual int FB_CARG seek(IStatus* status, int mode, int offset) = 0; // returns position |
69 | }; |
70 | #define FB_BLOB_VERSION (FB_REFCOUNTED_VERSION + 6) |
71 | |
72 | class ITransaction : public IRefCounted |
73 | { |
74 | public: |
75 | virtual void FB_CARG getInfo(IStatus* status, |
76 | unsigned int itemsLength, const unsigned char* items, |
77 | unsigned int bufferLength, unsigned char* buffer) = 0; |
78 | virtual void FB_CARG prepare(IStatus* status, |
79 | unsigned int msgLength = 0, const unsigned char* message = 0) = 0; |
80 | virtual void FB_CARG commit(IStatus* status) = 0; |
81 | virtual void FB_CARG commitRetaining(IStatus* status) = 0; |
82 | virtual void FB_CARG rollback(IStatus* status) = 0; |
83 | virtual void FB_CARG rollbackRetaining(IStatus* status) = 0; |
84 | virtual void FB_CARG disconnect(IStatus* status) = 0; |
85 | virtual ITransaction* FB_CARG join(IStatus* status, ITransaction* transaction) = 0; |
86 | virtual ITransaction* FB_CARG validate(IStatus* status, IAttachment* attachment) = 0; |
87 | virtual ITransaction* FB_CARG enterDtc(IStatus* status) = 0; |
88 | }; |
89 | #define FB_TRANSACTION_VERSION (FB_REFCOUNTED_VERSION + 10) |
90 | |
91 | class IMetadataBuilder; // Forward |
92 | |
93 | class IMessageMetadata : public IRefCounted |
94 | { |
95 | public: |
96 | virtual unsigned FB_CARG getCount(IStatus* status) const = 0; |
97 | virtual const char* FB_CARG getField(IStatus* status, unsigned index) const = 0; |
98 | virtual const char* FB_CARG getRelation(IStatus* status, unsigned index) const = 0; |
99 | virtual const char* FB_CARG getOwner(IStatus* status, unsigned index) const = 0; |
100 | virtual const char* FB_CARG getAlias(IStatus* status, unsigned index) const = 0; |
101 | virtual unsigned FB_CARG getType(IStatus* status, unsigned index) const = 0; |
102 | virtual FB_BOOLEAN FB_CARG isNullable(IStatus* status, unsigned index) const = 0; |
103 | virtual int FB_CARG getSubType(IStatus* status, unsigned index) const = 0; |
104 | virtual unsigned FB_CARG getLength(IStatus* status, unsigned index) const = 0; |
105 | virtual int FB_CARG getScale(IStatus* status, unsigned index) const = 0; |
106 | virtual unsigned FB_CARG getCharSet(IStatus* status, unsigned index) const = 0; |
107 | virtual unsigned FB_CARG getOffset(IStatus* status, unsigned index) const = 0; |
108 | virtual unsigned FB_CARG getNullOffset(IStatus* status, unsigned index) const = 0; |
109 | |
110 | virtual IMetadataBuilder* FB_CARG getBuilder(IStatus* status) const = 0; |
111 | virtual unsigned FB_CARG getMessageLength(IStatus* status) const = 0; |
112 | }; |
113 | #define FB_MESSAGE_METADATA_VERSION (FB_REFCOUNTED_VERSION + 15) |
114 | |
115 | class IMetadataBuilder : public IRefCounted |
116 | { |
117 | public: |
118 | virtual void FB_CARG setType(IStatus* status, unsigned index, unsigned type) = 0; |
119 | virtual void FB_CARG setSubType(IStatus* status, unsigned index, int subType) = 0; |
120 | virtual void FB_CARG setLength(IStatus* status, unsigned index, unsigned length) = 0; |
121 | virtual void FB_CARG setCharSet(IStatus* status, unsigned index, unsigned charSet) = 0; |
122 | virtual void FB_CARG setScale(IStatus* status, unsigned index, unsigned scale) = 0; |
123 | |
124 | virtual void FB_CARG truncate(IStatus* status, unsigned count) = 0; |
125 | virtual void FB_CARG moveNameToIndex(IStatus* status, const char* name, unsigned index) = 0; |
126 | virtual void FB_CARG remove(IStatus* status, unsigned index) = 0; |
127 | |
128 | virtual IMessageMetadata* FB_CARG getMetadata(IStatus* status) = 0; |
129 | }; |
130 | #define FB_METADATA_BUILDER_VERSION (FB_REFCOUNTED_VERSION + 9) |
131 | |
132 | class IResultSet : public IRefCounted |
133 | { |
134 | public: |
135 | virtual FB_BOOLEAN FB_CARG fetchNext(IStatus* status, void* message) = 0; |
136 | virtual FB_BOOLEAN FB_CARG fetchPrior(IStatus* status, void* message) = 0; |
137 | virtual FB_BOOLEAN FB_CARG fetchFirst(IStatus* status, void* message) = 0; |
138 | virtual FB_BOOLEAN FB_CARG fetchLast(IStatus* status, void* message) = 0; |
139 | virtual FB_BOOLEAN FB_CARG fetchAbsolute(IStatus* status, unsigned int position, void* message) = 0; |
140 | virtual FB_BOOLEAN FB_CARG fetchRelative(IStatus* status, int offset, void* message) = 0; |
141 | virtual FB_BOOLEAN FB_CARG isEof(IStatus* status) = 0; |
142 | virtual FB_BOOLEAN FB_CARG isBof(IStatus* status) = 0; |
143 | virtual IMessageMetadata* FB_CARG getMetadata(IStatus* status) = 0; |
144 | virtual void FB_CARG setCursorName(IStatus* status, const char* name) = 0; |
145 | virtual void FB_CARG close(IStatus* status) = 0; |
146 | }; |
147 | #define FB_RESULTSET_VERSION (FB_REFCOUNTED_VERSION + 11) |
148 | |
149 | class IStatement : public IRefCounted |
150 | { |
151 | public: |
152 | // Prepare flags. |
153 | static const unsigned PREPARE_PREFETCH_NONE = 0x00; |
154 | static const unsigned PREPARE_PREFETCH_TYPE = 0x01; |
155 | static const unsigned PREPARE_PREFETCH_INPUT_PARAMETERS = 0x02; |
156 | static const unsigned PREPARE_PREFETCH_OUTPUT_PARAMETERS = 0x04; |
157 | static const unsigned PREPARE_PREFETCH_LEGACY_PLAN = 0x08; |
158 | static const unsigned PREPARE_PREFETCH_DETAILED_PLAN = 0x10; |
159 | static const unsigned PREPARE_PREFETCH_AFFECTED_RECORDS = 0x20; // not used yet |
160 | static const unsigned PREPARE_PREFETCH_FLAGS = 0x40; |
161 | static const unsigned PREPARE_PREFETCH_METADATA = |
162 | PREPARE_PREFETCH_TYPE | PREPARE_PREFETCH_FLAGS | |
163 | PREPARE_PREFETCH_INPUT_PARAMETERS | PREPARE_PREFETCH_OUTPUT_PARAMETERS; |
164 | static const unsigned PREPARE_PREFETCH_ALL = |
165 | PREPARE_PREFETCH_METADATA | PREPARE_PREFETCH_LEGACY_PLAN | PREPARE_PREFETCH_DETAILED_PLAN | |
166 | PREPARE_PREFETCH_AFFECTED_RECORDS; |
167 | |
168 | // Statement flags. |
169 | static const unsigned FLAG_HAS_CURSOR = 0x01; |
170 | static const unsigned FLAG_REPEAT_EXECUTE = 0x02; |
171 | |
172 | virtual void FB_CARG getInfo(IStatus* status, |
173 | unsigned int itemsLength, const unsigned char* items, |
174 | unsigned int bufferLength, unsigned char* buffer) = 0; |
175 | virtual unsigned FB_CARG getType(IStatus* status) = 0; |
176 | virtual const char* FB_CARG getPlan(IStatus* status, FB_BOOLEAN detailed) = 0; |
177 | virtual ISC_UINT64 FB_CARG getAffectedRecords(IStatus* status) = 0; |
178 | virtual IMessageMetadata* FB_CARG getInputMetadata(IStatus* status) = 0; |
179 | virtual IMessageMetadata* FB_CARG getOutputMetadata(IStatus* status) = 0; |
180 | virtual ITransaction* FB_CARG execute(IStatus* status, ITransaction* transaction, |
181 | IMessageMetadata* inMetadata, void* inBuffer, IMessageMetadata* outMetadata, void* outBuffer) = 0; |
182 | virtual IResultSet* FB_CARG openCursor(IStatus* status, ITransaction* transaction, |
183 | IMessageMetadata* inMetadata, void* inBuffer, IMessageMetadata* outMetadata) = 0; |
184 | virtual void FB_CARG free(IStatus* status) = 0; |
185 | virtual unsigned FB_CARG getFlags(IStatus* status) = 0; |
186 | }; |
187 | #define FB_STATEMENT_VERSION (FB_REFCOUNTED_VERSION + 10) |
188 | |
189 | class IRequest : public IRefCounted |
190 | { |
191 | public: |
192 | virtual void FB_CARG receive(IStatus* status, int level, unsigned int msgType, |
193 | unsigned int length, unsigned char* message) = 0; |
194 | virtual void FB_CARG send(IStatus* status, int level, unsigned int msgType, |
195 | unsigned int length, const unsigned char* message) = 0; |
196 | virtual void FB_CARG getInfo(IStatus* status, int level, |
197 | unsigned int itemsLength, const unsigned char* items, |
198 | unsigned int bufferLength, unsigned char* buffer) = 0; |
199 | virtual void FB_CARG start(IStatus* status, ITransaction* tra, int level) = 0; |
200 | virtual void FB_CARG startAndSend(IStatus* status, ITransaction* tra, int level, unsigned int msgType, |
201 | unsigned int length, const unsigned char* message) = 0; |
202 | virtual void FB_CARG unwind(IStatus* status, int level) = 0; |
203 | virtual void FB_CARG free(IStatus* status) = 0; |
204 | }; |
205 | #define FB_REQUEST_VERSION (FB_REFCOUNTED_VERSION + 7) |
206 | |
207 | class IEvents : public IRefCounted |
208 | { |
209 | public: |
210 | virtual void FB_CARG cancel(IStatus* status) = 0; |
211 | }; |
212 | #define FB_EVENTS_VERSION (FB_REFCOUNTED_VERSION + 1) |
213 | |
214 | class IAttachment : public IRefCounted |
215 | { |
216 | public: |
217 | virtual void FB_CARG getInfo(IStatus* status, |
218 | unsigned int itemsLength, const unsigned char* items, |
219 | unsigned int bufferLength, unsigned char* buffer) = 0; |
220 | virtual ITransaction* FB_CARG startTransaction(IStatus* status, |
221 | unsigned int tpbLength, const unsigned char* tpb) = 0; |
222 | virtual ITransaction* FB_CARG reconnectTransaction(IStatus* status, |
223 | unsigned int length, const unsigned char* id) = 0; |
224 | virtual IRequest* FB_CARG compileRequest(IStatus* status, |
225 | unsigned int blrLength, const unsigned char* blr) = 0; |
226 | virtual void FB_CARG transactRequest(IStatus* status, ITransaction* transaction, |
227 | unsigned int blrLength, const unsigned char* blr, |
228 | unsigned int inMsgLength, const unsigned char* inMsg, |
229 | unsigned int outMsgLength, unsigned char* outMsg) = 0; |
230 | virtual IBlob* FB_CARG createBlob(IStatus* status, ITransaction* transaction, ISC_QUAD* id, |
231 | unsigned int bpbLength = 0, const unsigned char* bpb = 0) = 0; |
232 | virtual IBlob* FB_CARG openBlob(IStatus* status, ITransaction* transaction, ISC_QUAD* id, |
233 | unsigned int bpbLength = 0, const unsigned char* bpb = 0) = 0; |
234 | virtual int FB_CARG getSlice(IStatus* status, ITransaction* transaction, ISC_QUAD* id, |
235 | unsigned int sdlLength, const unsigned char* sdl, |
236 | unsigned int paramLength, const unsigned char* param, |
237 | int sliceLength, unsigned char* slice) = 0; |
238 | virtual void FB_CARG putSlice(IStatus* status, ITransaction* transaction, ISC_QUAD* id, |
239 | unsigned int sdlLength, const unsigned char* sdl, |
240 | unsigned int paramLength, const unsigned char* param, |
241 | int sliceLength, unsigned char* slice) = 0; |
242 | virtual void FB_CARG executeDyn(IStatus* status, ITransaction* transaction, unsigned int length, |
243 | const unsigned char* dyn) = 0; |
244 | virtual IStatement* FB_CARG prepare(IStatus* status, ITransaction* tra, |
245 | unsigned int stmtLength, const char* sqlStmt, unsigned dialect, unsigned int flags) = 0; |
246 | virtual ITransaction* FB_CARG execute(IStatus* status, ITransaction* transaction, |
247 | unsigned int stmtLength, const char* sqlStmt, unsigned dialect, |
248 | IMessageMetadata* inMetadata, void* inBuffer, IMessageMetadata* outMetadata, void* outBuffer) = 0; |
249 | virtual IResultSet* FB_CARG openCursor(IStatus* status, ITransaction* transaction, |
250 | unsigned int stmtLength, const char* sqlStmt, unsigned dialect, |
251 | IMessageMetadata* inMetadata, void* inBuffer, IMessageMetadata* outMetadata) = 0; |
252 | virtual IEvents* FB_CARG queEvents(IStatus* status, IEventCallback* callback, |
253 | unsigned int length, const unsigned char* events) = 0; |
254 | virtual void FB_CARG cancelOperation(IStatus* status, int option) = 0; |
255 | virtual void FB_CARG ping(IStatus* status) = 0; |
256 | virtual void FB_CARG detach(IStatus* status) = 0; |
257 | virtual void FB_CARG dropDatabase(IStatus* status) = 0; |
258 | }; |
259 | #define FB_ATTACHMENT_VERSION (FB_REFCOUNTED_VERSION + 18) |
260 | |
261 | class IService : public IRefCounted |
262 | { |
263 | public: |
264 | virtual void FB_CARG detach(IStatus* status) = 0; |
265 | virtual void FB_CARG query(IStatus* status, |
266 | unsigned int sendLength, const unsigned char* sendItems, |
267 | unsigned int receiveLength, const unsigned char* receiveItems, |
268 | unsigned int bufferLength, unsigned char* buffer) = 0; |
269 | virtual void FB_CARG start(IStatus* status, |
270 | unsigned int spbLength, const unsigned char* spb) = 0; |
271 | }; |
272 | #define FB_SERVICE_VERSION (FB_REFCOUNTED_VERSION + 3) |
273 | |
274 | class IProvider : public IPluginBase |
275 | { |
276 | public: |
277 | virtual IAttachment* FB_CARG attachDatabase(IStatus* status, const char* fileName, |
278 | unsigned int dpbLength, const unsigned char* dpb) = 0; |
279 | virtual IAttachment* FB_CARG createDatabase(IStatus* status, const char* fileName, |
280 | unsigned int dpbLength, const unsigned char* dpb) = 0; |
281 | virtual IService* FB_CARG attachServiceManager(IStatus* status, const char* service, |
282 | unsigned int spbLength, const unsigned char* spb) = 0; |
283 | virtual void FB_CARG shutdown(IStatus* status, unsigned int timeout, const int reason) = 0; |
284 | virtual void FB_CARG setDbCryptCallback(IStatus* status, ICryptKeyCallback* cryptCallback) = 0; |
285 | }; |
286 | #define FB_PROVIDER_VERSION (FB_PLUGIN_VERSION + 5) |
287 | |
288 | // DtcStart - structure to start transaction over >1 attachments (former TEB) |
289 | struct DtcStart |
290 | { |
291 | IAttachment* attachment; |
292 | const unsigned char* tpb; |
293 | unsigned int tpbLength; |
294 | }; |
295 | |
296 | // Distributed transactions coordinator |
297 | class IDtc : public IVersioned |
298 | { |
299 | public: |
300 | virtual ITransaction* FB_CARG start(IStatus* status, unsigned int cnt, DtcStart* components) = 0; |
301 | virtual ITransaction* FB_CARG join(IStatus* status, ITransaction* one, ITransaction* two) = 0; |
302 | }; |
303 | #define FB_DTC_VERSION (FB_VERSIONED_VERSION + 2) |
304 | |
305 | } // namespace Firebird |
306 | |
307 | |
308 | #endif // FB_PROVIDER_INTERFACE |
309 | |