ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/branches/udr/client/FBMessages.pas
Revision: 372
Committed: Wed Jan 5 16:20:22 2022 UTC (2 years, 10 months ago) by tony
Content type: text/x-pascal
File size: 16562 byte(s)
Log Message:
string overflow fix

File Contents

# User Rev Content
1 tony 45 (*
2     * Firebird Interface (fbintf). The fbintf components provide a set of
3     * Pascal language bindings for the Firebird API. Although predominantly
4     * a new development they include source code taken from IBX and may be
5     * considered a derived product. This software thus also includes the copyright
6     * notice and license conditions from IBX.
7     *
8     * Except for those parts dervied from IBX, contents of this file are subject
9     * to the Initial Developer's Public License Version 1.0 (the "License"); you
10     * may not use this file except in compliance with the License. You may obtain a
11     * copy of the License here:
12     *
13     * http://www.firebirdsql.org/index.php?op=doc&id=idpl
14     *
15     * Software distributed under the License is distributed on an "AS
16     * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
17     * implied. See the License for the specific language governing rights
18     * and limitations under the License.
19     *
20     * The Initial Developer of the Original Code is Tony Whyman.
21     *
22     * The Original Code is (C) 2016 Tony Whyman, MWA Software
23     * (http://www.mwasoftware.co.uk).
24     *
25     * All Rights Reserved.
26     *
27     * Contributor(s): ______________________________________.
28     *
29     *)
30     {************************************************************************}
31     { }
32     { Borland Delphi Visual Component Library }
33     { InterBase Express core components }
34     { }
35     { Copyright (c) 1998-2000 Inprise Corporation }
36     { }
37     { InterBase Express is based in part on the product }
38     { Free IB Components, written by Gregory H. Deatz for }
39     { Hoagland, Longo, Moran, Dunst & Doukas Company. }
40     { Free IB Components is used under license. }
41     { }
42     { The contents of this file are subject to the InterBase }
43     { Public License Version 1.0 (the "License"); you may not }
44     { use this file except in compliance with the License. You }
45     { may obtain a copy of the License at http://www.Inprise.com/IPL.html }
46     { Software distributed under the License is distributed on }
47     { an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either }
48     { express or implied. See the License for the specific language }
49     { governing rights and limitations under the License. }
50     { The Original Code was created by InterBase Software Corporation }
51     { and its successors. }
52     { Portions created by Inprise Corporation are Copyright (C) Inprise }
53     { Corporation. All Rights Reserved. }
54     { Contributor(s): Jeff Overcash }
55     { }
56     { IBX For Lazarus (Firebird Express) }
57     { Contributor: Tony Whyman, MWA Software http://www.mwasoftware.co.uk }
58     { Portions created by MWA Software are copyright McCallum Whyman }
59     { Associates Ltd 2011 - 2015 }
60     { }
61     {************************************************************************}
62     unit FBMessages;
63 tony 291 {$IFDEF MSWINDOWS}
64     {$DEFINE WINDOWS}
65 tony 56 {$ENDIF}
66 tony 45
67     {$IFDEF FPC}
68 tony 56 {$mode delphi}
69 tony 45 {$codepage UTF8}
70     {$ENDIF}
71    
72     interface
73    
74     uses
75     Classes, SysUtils;
76    
77     type
78     TIBClientError = (
79     ibxeInterBaseMissing,
80     ibxeIB60feature,
81     ibxeNotSupported,
82     ibxeNotPermitted,
83     ibxeDatabaseClosed,
84     ibxeNotInTransaction,
85     ibxeTransactionNotAssigned,
86     ibxeEOF,
87     ibxeBOF,
88     ibxeInvalidStatementHandle,
89     ibxeSQLClosed,
90     ibxeUnknownSQLDataType,
91     ibxeInvalidColumnIndex,
92     ibxeInvalidDataConversion,
93     ibxeBlobCannotBeRead,
94     ibxeBlobCannotBeWritten,
95     ibxeBlobNotOpen,
96     ibxeEmptyQuery,
97     ibxeFieldNotFound,
98     ibxeSQLParseError,
99     ibxeIsASelectStatement,
100     ibxeIsAExecuteProcedure,
101     ibxeMaximumEvents,
102     ibxeServiceActive,
103     ibxeServiceInActive,
104     ibxeServerNameMissing,
105     ibxeOutputParsingError,
106     ibxeEmptyAttachmentsList,
107     ibxeInfoBufferTypeError,
108     ibxServiceRequestIndexError,
109     ibxServiceParamTypeError,
110     ibxeOutputBlockIndexError,
111     ibxeOutputBlockTypeError,
112     ibxePBIndexError,
113     ibxePBParamTypeError,
114     ibxeDuplicateParamName,
115     ibxeInvalidArrayDimensions,
116     ibxeNotAMultiDatabaseTransaction,
117     ibxeAttachmentListIndexError,
118     ibxeNotAnArray,
119     ibxeNotABlob,
120     ibxeInvalidSubscript,
121     ibxeArrayElementOverFlow,
122     ibxArrayBoundsCantIncrease ,
123     ibxeStatementNotPrepared,
124     ibxeInterfaceOutofDate,
125     ibxeInvalidBlobMetaData,
126     ibxeNoDPB,
127     ibxeInEventWait,
128     ibxeIncompatibleBlob,
129     ibxeMissingColumnName,
130     ibxStringTooLong,
131     ibxFieldNotinDataSet,
132     ibxeNoDefaultCharacterSet,
133     ibxeParamBufferOverflow,
134     ibxeInvalidParamCount,
135     ibxeInvalidVariantType,
136 tony 60 ibxeInterfaceNotSupported,
137     ibxeCharacterSetExists,
138 tony 68 ibxeUnknownUserCharSet,
139 tony 103 ibxeUninitializedInputParameter,
140 tony 221 ibxeMultiThreadRequired,
141 tony 263 ibxeTokenQueueOverflow,
142     ibxeTokenQueueUnderflow,
143     ibxErrorParsing,
144     ibxeDLInfoError,
145 tony 315 ibxeDifferentAPIs,
146     ibxeInvalidDateTimeStr,
147     ibxeBadTimeZoneID,
148     ibxeBadBCDConversion,
149     ibxeBadTimeZoneName,
150     ibxeTimeZoneUnknown,
151     ibxeBadTimeSpecification,
152     ibxeBCDTooBig,
153     ibxeInvalidTimeZoneID,
154     ibxeBadTimestampOrNoTimeZoneDBEntry,
155     ibxeBCDOverflow,
156     ibxeNoTimezoneSupport,
157     ibxeDecFloatNotSupported,
158     ibxeInt128NotSupported,
159 tony 345 ibxeUnknownParamTypeName,
160     ibxInvalidQueryAction,
161     ibxeSQLTypeUnchangeable,
162     ibxeCannotIncreaseMetadatasize,
163     ibxeBatchModeNotSupported,
164     ibxeNotInBatchMode,
165     ibxeInBatchMode,
166     ibxeInvalidBatchQuery,
167     ibxeBatchRowBufferOverflow,
168 tony 350 ibxeBatchBufferSizeTooBig,
169 tony 371 ibxeNoScrollableCursors,
170     ibxeUnableTosetaTextType,
171     ibxeCantDropAcquiredDB,
172     ibxeTransactionNotOwned,
173     ibxeIntegerOverflow,
174     ibxIntegerUnderflow,
175 tony 372 ibxeScaleCannotBeChanged,
176     ibxeStringOverflow
177 tony 45 );
178    
179 tony 56 function GetErrorMessage(ErrMess: TIBClientError): AnsiString;
180 tony 45
181 tony 291 {IBError is used internally and by IBX to throw an EIBClientError}
182    
183     procedure IBError(ErrMess: TIBClientError; const Args: array of const);
184    
185 tony 45 resourcestring
186     { generic strings used in code }
187     SParamNameExpected = 'Parameter name expected';
188     sSQLErrorSeparator = ' When Executing: ';
189     SFirebirdAPIFuncNotFound = 'Unable to load Firebird Client Library Function "%s"';
190     STrue = 'true';
191     SFalse = 'false';
192 tony 47 SArray = '(array)';
193 tony 345 SBatchCompletionError = 'Error Processing update/insert batch on row number %d - ';
194 tony 45
195     implementation
196    
197 tony 291 uses IBUtils, IB;
198 tony 45
199     resourcestring
200    
201     { strings used in error messages}
202     SInterBaseMissing = 'Firebird library not found in the path. Please install Firebird to use this functionality';
203     SIB60feature = '%s is an InterBase 6 function. Please upgrade to InterBase 6 to use this functonality';
204     SNotSupported = 'Unsupported feature';
205     SNotPermitted = 'Not permitted';
206     SDatabaseClosed = 'Cannot perform operation -- DB is not open';
207     SNotInTransaction = 'Transaction is not active';
208     STransactionNotAssigned = 'Transaction not assigned';
209     SEOF = 'End of file';
210     SBOF = 'Beginning of file';
211     SInvalidStatementHandle = 'Invalid statement handle';
212     SSQLClosed = 'IBSQL Closed';
213     SUnknownSQLDataType = 'Unknown SQL Data type (%d)';
214     SInvalidColumnIndex = 'Invalid column index (index exceeds permitted range)';
215 tony 315 SInvalidDataConversion = 'Invalid data conversion from %s';
216 tony 45 SBlobCannotBeRead = 'Blob stream cannot be read';
217     SBlobCannotBeWritten = 'Blob stream cannot be written';
218     SBlobNotOpen = 'The Blob is not open';
219     SEmptyQuery = 'Empty query';
220     SFieldNotFound = 'Field "%s" not found';
221     SSQLParseError = 'SQL Parse Error:' + CRLF + CRLF + '%s';
222     SIsASelectStatement = 'use Open for a Select Statement';
223     SIsAExecuteProcedure = 'use ExecProc for Procedure; use TQuery for Select procedures';
224     SMaximumEvents = 'Exceded Maximum Event limits';
225     SServiceActive = 'Cannot perform operation -- service is not attached';
226     SServiceInActive = 'Cannot perform operation -- service is attached';
227     SServerNameMissing = 'Server Name Missing';
228 tony 144 SOutputParsingError = 'Unexpected Output buffer value (%d) - %s';
229 tony 45 SEmptyAttachmentsList = 'The list of database attachments cannot be empty';
230     SInfoBufferTypeError = 'Invalid operation for Info Buffer Type (%d)';
231     SServiceRequestIndexError = 'Service Request Index Out of Range (%d)';
232     SServiceParamTypeError = 'Invalid Request for Service Param Type';
233     SOutputBlockIndexError = 'Output Block Index Out of Range (%d)';
234     SOutputBlockTypeError = 'Invalid Request for Output Block Type';
235     SPBIndexError = 'DPB Index out of range (%d)';
236     SPBParamTypeError = 'Invalid Request for DPB Param Type';
237     SDuplicateParamName = 'Blob or array parameter name must be unique (%s)';
238 tony 47 SInvalidArrayDimensions = 'Invalid number of array dimensions (%d)';
239 tony 45 SNotAMultiDatabaseTransaction = 'This is not a multi-database transaction';
240     SAttachmentListIndexError = 'Attachment List index out of range (%d)';
241     SNotAnArray = 'Table Column must be an array';
242     SNotABlob = 'Table Column must be a Blob';
243     SInvalidSubscript = 'Invalid Subscript (%d) for Array Dimension %d';
244     SArrayElementOverFlow = 'Array Element too big';
245     SArrayBoundsCantIncrease = 'Array Bounds can only be narrowed';
246     SStatementNotPrepared = 'The Statement has not been prepared';
247     SInterfaceOutofDate = 'This interface is no longer up-to-date';
248     SInvalidBlobMetaData = 'Unable to Access Blob Meta Data';
249     SNoDPB = 'A DPB must be provided';
250     SInEventWait = 'Already in Event Wait State';
251     SIncompatibleBlob = 'Incompatible Blob SubTypes. %d expected, %d found';
252     SMissingColumnName = 'Relation or Column Name Missing';
253     SStringTooLong = 'String "%s" is too long. Max %d characters';
254     SFieldNotinDataSet = 'Field %s is not a member of DataSet %s';
255     SNoDefaultCharacterSet = 'A connection default character set is required to perform this operation';
256     SParamBufferOverflow = 'Parameter Buffer Overflow';
257     SInvalidParamCount = 'Invalid Parameter Count. %d expected, %d found';
258     SInvalidVariantType = 'Invalid variant type';
259 tony 56 SInterfaceNotSupported = 'Interface not supported; Guid %s not found';
260 tony 60 SCharacterSetExists = 'Character set "%s" is already defined';
261     SUnknownUserCharSet = 'Unknown user character set "%s"';
262 tony 68 SUninitializedInputParameter = 'SQL Param No. %d (%s) is uninitialised';
263 tony 217 SMultiThreadRequired = 'Multi-threading required for %s but not enabled. Please recompile with multi-threading support enabled. '+
264     'Hint: you probably need to add -dUseCThreads to the Custom Options.';
265 tony 263 STokenQueueOverflow = 'Error in SQL Token Analyser - token queue overflow';
266     STokenQueueUnderflow = 'Error in SQL Token Analyser - token queue underflow';
267     SErrorParsing = 'Error parsing SQL Statement at clause starting with %s';
268     SDLInfoError = 'dlinfo returned error - %s';
269     SDifferentAPIs = 'All transaction attachments must use the same Firebird Library';
270 tony 315 SInvalidDateTimeStr = '%s is not a valid Date/Time string';
271     SBadTimeZoneID = 'Invalid Time Zone ID (%d,%d)';
272     SBadBCDConversion = 'Conversion to BCD failed';
273     SBadTimeZoneName = 'Invalid Time Zone Name "%s"';
274     STimeZoneUnknown = 'Time Zone Unknown';
275     SBadTimeSpecification = '%d:%d:%d.%d is not a valid time specification';
276     SBCDTooBig = 'BCD Precision (%d) is too large for Firebird Data Type max precision (%d)';
277     SInvalidTimeZoneID = 'Invalid Time Zone ID (%d)';
278     SBadTimestampOrNoTimeZoneDBEntry = 'Bad Timestamp or missing time zone DB entry (%s) TZ ID = %d';
279     SBCDOverflow = 'BCD Precision too large for Firebird data type,[%s]';
280     SNoTimezoneSupport = 'TIME/TIMESTAMP WITH TIME ZONE data type not supported';
281     SDecFloatNotSupported = 'DecFloat Data Type not supported';
282     SInt128NotSupported = 'INT128 Data Type not supported';
283     SUnknownParamTypeName = '%s:Unknown Param Type Name "%s"';
284 tony 345 SInvalidQueryAction = 'Query Action only valid for an Update or Insert Query';
285     SSQLTypeUnchangeable = 'Cannot change SQL Type from %s to %s';
286     SCannotIncreaseMetadatasize = 'Cannot increase Metadata size from %d to %d';
287     SBatchModeNotSupported = 'Batch Mode is not available. Firebird 4 or later client and server is required';
288     SNotInBatchMode = 'Not in Batch Mode - have you called AddToBatch?';
289     SInBatchMode = 'Invalid Operation: a Batch is pending';
290     SInvalidBatchQuery = 'This query type (%s) cannot be batched';
291     SBatchRowBufferOverflow = 'Adding Row No. %d - batch buffer size limit (%d bytes) exceeded';
292     SBatchBufferSizeTooBig = 'Requested Batch Buffer Size (%d bytes) exceeds 256MB limit';
293 tony 350 SNoScrollableCursors = 'Scrollable cursors are not supported';
294 tony 371 SUnableTosetaTextType = 'Param[%d] "%s": Unable to change from a %s to a string type';
295     SCantDropAcquiredDB = 'Drop database not allowed by acquired attachment';
296     STransactionNotOwned = 'Cannot Commit or Rollback a linked transaction';
297     SIntegerOverflow = 'Integer overflow when scaling numeric';
298     SIntegerUnderflow = 'Integer underflow when scaling numeric';
299     SScaleCannotBeChanged = 'Unable to change numeric field scale';
300 tony 372 SStringOverflow = 'String overflow. String Length %d exceeds permitted maximum (%d)';
301 tony 45
302     const
303     IBErrorMessages: array[TIBClientError] of string = (
304     SInterBaseMissing,
305     SIB60feature,
306     SNotSupported,
307     SNotPermitted,
308     SDatabaseClosed,
309     SNotInTransaction,
310     STransactionNotAssigned,
311     SEOF,
312     SBOF,
313     SInvalidStatementHandle,
314     SSQLClosed,
315     SUnknownSQLDataType,
316     SInvalidColumnIndex,
317     SInvalidDataConversion,
318     SBlobCannotBeRead,
319     SBlobCannotBeWritten,
320     SBlobNotOpen,
321     SEmptyQuery,
322     SFieldNotFound,
323     SSQLParseError,
324     SIsASelectStatement,
325     SIsAExecuteProcedure,
326     SMaximumEvents,
327     SServiceActive,
328     SServiceInActive,
329     SServerNameMissing,
330     SOutputParsingError,
331     SEmptyAttachmentsList,
332     SInfoBufferTypeError,
333     SServiceRequestIndexError,
334     SServiceParamTypeError,
335     SOutputBlockIndexError,
336     SOutputBlockTypeError,
337     SPBIndexError,
338     SPBParamTypeError,
339     SDuplicateParamName,
340     SInvalidArrayDimensions,
341     SNotAMultiDatabaseTransaction,
342     SAttachmentListIndexError,
343     SNotAnArray,
344     SNotABlob,
345     SInvalidSubscript,
346     SArrayElementOverFlow,
347     SArrayBoundsCantIncrease,
348     SStatementNotPrepared,
349     SInterfaceOutofDate,
350     SInvalidBlobMetaData,
351     SNoDPB,
352     SInEventWait,
353     SIncompatibleBlob,
354     SMissingColumnName,
355     SStringTooLong,
356     SFieldNotinDataSet,
357     SNoDefaultCharacterSet,
358     SParamBufferOverflow,
359     SInvalidParamCount,
360     SInvalidVariantType,
361 tony 60 SInterfaceNotSupported,
362     SCharacterSetExists,
363 tony 68 SUnknownUserCharSet,
364 tony 103 SUninitializedInputParameter,
365 tony 221 SMultiThreadRequired,
366 tony 263 STokenQueueOverflow,
367     STokenQueueUnderflow,
368     SErrorParsing,
369     SDLInfoError,
370 tony 315 SDifferentAPIs,
371     SInvalidDateTimeStr,
372     SBadTimeZoneID,
373     SBadBCDConversion,
374     SBadTimeZoneName,
375     STimeZoneUnknown,
376     SBadTimeSpecification,
377     SBCDTooBig,
378     SInvalidTimeZoneID,
379     SBadTimestampOrNoTimeZoneDBEntry,
380     SBCDOverflow,
381     SNoTimezoneSupport,
382     SDecFloatNotSupported,
383     SInt128NotSupported,
384 tony 345 SUnknownParamTypeName,
385     SInvalidQueryAction,
386     SSQLTypeUnchangeable,
387     SCannotIncreaseMetadatasize,
388     SBatchModeNotSupported,
389     SNotInBatchMode,
390     SInBatchMode,
391     SInvalidBatchQuery,
392     SBatchRowBufferOverflow,
393 tony 350 SBatchBufferSizeTooBig,
394 tony 371 SNoScrollableCursors,
395     SUnableTosetaTextType,
396     SCantDropAcquiredDB,
397     STransactionNotOwned,
398     SIntegerOverflow,
399     SIntegerUnderflow,
400 tony 372 SScaleCannotBeChanged,
401     SStringOverflow
402 tony 45 );
403    
404 tony 56 function GetErrorMessage(ErrMess: TIBClientError): AnsiString;
405 tony 45 begin
406     Result := IBErrorMessages[ErrMess];
407     end;
408    
409 tony 291 procedure IBError(ErrMess: TIBClientError; const Args: array of const);
410     begin
411     raise EIBClientError.Create(Ord(ErrMess),
412     Format(GetErrorMessage(ErrMess), Args));
413     end;
414    
415 tony 345
416 tony 45 end.
417