On 7-2-2015 15:54, Dimitry Sibiryakov wrote: > 07.02.2015 14:40, Mark Rotteveel wrote: >> Warnings are an existing feature in Firebird and I see no reason why >> they should be removed. > > Because they make API inconsistent and complicate application development. > Modern programming ideology is that function must returning only one > result and any > unexpected thing is thrown as an exception. Warnings break that.
The differences is that an exception is a failure condition, while a warning signals that the action completed successfully, but it might not have been what the user intended or wanted. And yes, with production use of an application you'd likely ignore (or only log) the warnings, but during development they might be very useful to detect **potential** problems. Similar when executing queries directly in flamerobin or isql. >> If anything, Firebird should return more >> warnings (eg connecting without an explicit character set, truncation >> during select, etc). > > All that you listed, are, actually, errors. Regarding not specifying a connection character set: not specifying a character set implies NONE. It is something that works, but might not be what the user actually wanted to do: so it should be a warning. Regarding truncation (or conversions) during select: it is a warning according to the SQL standard (and existing behavior in Firebird is wrong!). As a simplified example: SELECT CAST('abcdefgh' AS VARCHAR(1)) FROM RDB$DATABASE currently fails in Firebird, while according to the SQL standard **it should succeed and raise a warning**. To quote a few usages of warnings in the SQL standard (some of which are not currently supported by Firebird): "With two exceptions, a character string expression is assignable only to sites of a character string type whose character set is the same. The exceptions are as specified in Subclause 4.2.8, “Universal character sets”, and such other cases as may be implementation-defined. If a store assignment would result in the loss of non-<space> characters due to truncation, then an exception condition is raised. If a retrieval assignment or evaluation of a <cast specification> would result in the loss of characters due to truncation, then **a warning condition is raised**." (SQL:2011 Foundation 4.2.1) "A binary string is assignable only to sites of binary string type. If a store assignment would result in the loss of non-zero octets due to truncation, then an exception condition is raised. If a retrieval assignment would result in the loss of octets due to truncation, then **a warning condition is raised**." (SQL:2011 Foudation 4.3.1) "If a condition is raised that causes a statement to have no effect other than that associated with raising the condition (that is, not a completion condition), then the condition is said to be an exception condition or exception. If a condition is raised that permits a statement to have an effect other than that associated with raising the condition (corresponding to an SQLSTATE class value of successful completion, warning, or no data), then the condition is said to be a completion condition. ... The completion condition warning is broadly defined as **completion in which the effects are correct, but there is reason to caution the user about those effects**. It is raised for implementation-defined conditions as well as conditions specified in this part of ISO/IEC 9075. The completion condition no data has special significance and is used to indicate an empty result. The completion condition successful completion is defined to indicate a completion condition that does not correspond to warning or no data. This includes conditions in which the SQLSTATE subclass provides implementation-defined information of a non-cautionary nature." (SQL:2011 Foundation 4.30.2) "If the length in characters of SV is larger than LTD, then TV is the first LTD characters of SV. If any of the remaining characters of SV are non-<space> characters, then a completion condition is raised: warning — string data, right truncation." (SQL:2011 Foundation 6.13; + similar other statements) "If FRL is greater than FRML, then the result of the <fold> is the first FRML characters of FR with length FRML. If any of the right-most (FRL – FRML) characters of FR are not <space> characters, then a completion condition is raised: warning — string data, right truncation." (SQL:2011 Foundation 6.30; + similar other statements) "If the declared type of T is fixed-length character string with length in characters L, and the length in characters of V is greater than L, then the value of T is set to the first L characters of V and a completion condition is raised: warning — string data, right truncation." (SQL:2011 Foundation, 9.1; + similar other statements) "Let TX be the single-column table that is the result of applying the <value expression> to each row of T1 and eliminating null values. If one or more null values are eliminated, then a completion condition is raised: warning — null value eliminated in set function." (SQL:2011 Foundation, 10.9) -- Mark Rotteveel ------------------------------------------------------------------------------ Dive into the World of Parallel Programming. The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel