BUG: Error in defintion in the weather SQL table

From Johan Andersson user at Sourceforge

Hi,

There is a error in definition of the weather table used by mysql2300 program. The problem occurs only when the temperature is low outdoor ( or indoor...) belove -9.99 degrees.

The defintion of the columns temp_in, temp_out and dewpoint is decimal( 2,1) is shold at least be decimal( 3,1).

With the decimal(2,1) only values between 99.9 to -9.9 could be stored.

The fix is simple, just change the defintion to decimal(3,1), the program is correct so no changes is needed there. See the example belove.

Fix for a table that is in use.

alter table weather modify temp_out decimal(3,1) not null default 0;
alter table weather modify temp_in decimal(3,1) not null default 0;
alter table weather modify dewpoint decimal(3,1) not null default 0;

The defintion in the mysql2300.sql should also be altered .

Best regards / Johan Andersson Mail : jander (at) algonet.se

Test case

Example

mysql> create table test ( kol_1 decimal(2,1), kol_2
decimal(3,1));
Query OK, 0 rows affected (0.00 sec)

mysql> insert into test values (-14.2, -14.2);
Query OK, 1 row affected (0.00 sec)

mysql> select * from test;
+-------+-------+
| kol_1 | kol_2 |
+-------+-------+
| -9.9 | -14.2 |
+-------+-------+
1 row in set (0.00 sec)

mysql> alter table test modify kol_1 decimal(3,1);
Query OK, 1 row affected (0.00 sec)
Records: 1 Duplicates: 0 Warnings: 0

mysql> insert into test values (-14.2, -14.2);
Query OK, 1 row affected (0.00 sec)

mysql> select * from test;
+-------+-------+
| kol_1 | kol_2 |
+-------+-------+
| -9.9 | -14.2 |
| -14.2 | -14.2 |
+-------+-------+
2 rows in set (0.00 sec)

Environment

Open2300 version: 1.10
Shared libraries: mysql
Server OS:  

-- KennethLavrsen - 28 Dec 2005

Follow up

Fix record

I have updated the mysql2300.sql

Will be in open2300 1.11

BugReportForm edit

TopicTitle Error in defintion in the weather SQL table
BugStatus Resolved
AssignedBugTo KennethLavrsen
SubmittedBy Johan Andersson
Topic attachments
I Attachment Action Size Date Who Comment
mysql2300.sqlsql mysql2300.sql manage 1.2 K 28 Dec 2005 - 08:41 KennethLavrsen  
Topic revision: r1 - 28 Dec 2005 - 08:42:00 - KennethLavrsen
 
Open2300 - Bug Report 2005x 12x 28x 083648
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback