Roland Bouman wrote:
Gosh - i must've been at the KB for too long today - I forgot to paste
my table def....
sorry - all, here goes:

mysql> create table t(c char(10) );
Query OK, 0 rows affected (0.13 sec)

mysql> insert into t values ('0123456789');
Query OK, 1 row affected (0.08 sec)

mysql> select cast(c as char(9)) from t;
+--------------------+
| cast(c as char(9)) |
+--------------------+
| 012345678          |
+--------------------+
1 row in set, 1 warning (0.06 sec)

Warning (Code 1292): Truncated incorrect CHAR(9) value: '0123456789'

OK, so I still don't see the value of the warning in this case. What value does it give? If you did the following:

SELECT CAST(c as CHAR(9)) FROM t;
SELECT LEFT(c, 9) FROM t;

The first would raise a warning, but the second would not. So, I ask again, what real value is the warning in this case?

Currently, we have actually 3 levels:

ERROR, WARNING, and NOTE.

I could see the possible value of outputting a NOTE in this case:

SELECT CAST(c as CHAR(9)) FROM t;

But not a warning. By doing an explicit CAST(), you are essentially saying to the server "Yes, I know what I am doing, don't warn me about stuff...".

-jay

Hope this is clear now...I ask the db to cast, it knows how to do it,
it does it, but it results in data loss -> warning.
This is in fact standard behaviour in case you're in doubt.

The NULL thing discussed earlier - well, that should have been an
error according to the standard. Reason: column is defined as NOT
NULL, so you *cannot* legally store NULL in it without breaking the
constraint. MySQL in that case does *not* do what we ask from it (we
asked to store a NULL, but instead it stores the 'datatype default'
wetf that may be) so that *should* have been an error - not a warning.

I hope this helps.

On Fri, Dec 19, 2008 at 10:12 PM, Sheeri K. Cabral <[email protected]> wrote:
On 12/19/08, Jay Pipes <[email protected]> wrote:
FYI, if folks decide we can scrap warnings, I can mentor a community
member in the task of replacing warnings with errors.  It's not a
particularly difficult task, basically broken into 4 phases:

1) Identify all code locations that emit warnings
2) Replace with errors
3) Remove the warnings system entirely
4) Fix EXPLAIN EXTENDED to not use SHOW WARNINGS afterwards (this was
always a total hack)

-jay

While I agree with the ideas here, I don't think we can actually scrap all
warnings without someone going through the warning codes and making sure
there's no functionality being lost.  There very well may be times where we
want an error instead of a warning or having an error and a warning for two
similar issues that are different in severity.  No, I can't think of
anything concrete right now.

-Sheeri

_______________________________________________
Mailing list: https://launchpad.net/~drizzle-discuss
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~drizzle-discuss
More help   : https://help.launchpad.net/ListHelp







_______________________________________________
Mailing list: https://launchpad.net/~drizzle-discuss
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~drizzle-discuss
More help   : https://help.launchpad.net/ListHelp

Reply via email to