Discussion:
[Dev-C++] How connect c++ to a database?
manuel pintaldi
2006-02-12 12:50:03 UTC
Permalink
hi to all!
how i can connect a mysql database to a c++ project.? i would like to use mysql or access database.
Im using devcpp.
Thanks
_________________________________________________________________
Scarica gratuitamente MSN Toolbar!
http://toolbar.msn.it/
Aurimas Černius
2006-02-12 19:10:05 UTC
Permalink
Hi,
Post by manuel pintaldi
how i can connect a mysql database to a c++ project.? i would like to
use mysql or access database.
MySQL C-API comes together with the MySQL database. Manual is available
on http://www.mysql.com
Good luck :)

/Aurimas
Per Westermark
2006-02-12 20:45:01 UTC
Permalink
I have been doing a lot of work using the wxWidgets classes (wxDbTable
etc).

/Per W
Post by manuel pintaldi
hi to all!
how i can connect a mysql database to a c++ project.? i would like to use mysql or access database.
Im using devcpp.
Thanks
Reid Thompson
2006-02-12 20:58:02 UTC
Permalink
Post by manuel pintaldi
hi to all!
how i can connect a mysql database to a c++ project.? i would like to
use mysql or access database.
Im using devcpp.
PostgreSQL is another, ( in my opinion a better ), option.

http://sourceforge.net/mailarchive/message.php?msg_id=13151600http://sourceforge.net/mailarchive/message.php?msg_id=13151600


www.postgresql.org
lordSauron
2006-02-12 22:13:03 UTC
Permalink
Post by Reid Thompson
Post by manuel pintaldi
hi to all!
how i can connect a mysql database to a c++ project.? i would like to
use mysql or access database.
Im using devcpp.
PostgreSQL is another, ( in my opinion a better ), option.
Why is it better? Just wondering - I have no data as to why it should
be better than MySQL.
Post by Reid Thompson
http://sourceforge.net/mailarchive/message.php?msg_id=13151600http://sourceforge.net/mailarchive/message.php?msg_id=13151600
www.postgresql.org
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Dev-cpp-users mailing list
TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
--
========== GCv3.12 ==========
GCS d-(++) s+: a? C++ UL+>++++ P+
L++ E--- W+(+++) N++ o? K? w--- O? M+
V? PS- PE+ Y-(--) PGP- t+++ 5? X R tv-- b+
DI+++ D+ G e* h- !r !y
========= END GCv3.12 ========
Reid Thompson
2006-02-13 12:19:00 UTC
Permalink
Post by lordSauron
Post by Reid Thompson
PostgreSQL is another, ( in my opinion a better ), option.
Why is it better? Just wondering - I have no data as to why it should
be better than MySQL.
http://sql-info.de/mysql/gotchas.html vs
http://sql-info.de/postgresql/postgres-gotchas.html

http://sql-info.de/postgresql/

Also, PostgreSQL is completely free for ANY use -- BSD license, versus
MySQL which is only free for certain uses.
lordSauron
2006-02-13 18:40:04 UTC
Permalink
Post by Reid Thompson
Post by lordSauron
Post by Reid Thompson
PostgreSQL is another, ( in my opinion a better ), option.
Why is it better? Just wondering - I have no data as to why it should
be better than MySQL.
http://sql-info.de/mysql/gotchas.html vs
http://sql-info.de/postgresql/postgres-gotchas.html
So basically you're moaning about how MySQL handles some undefined behaviour?
Post by Reid Thompson
http://sql-info.de/postgresql/
Also, PostgreSQL is completely free for ANY use -- BSD license, versus
MySQL which is only free for certain uses.
That could be an influence...

--
========== GCv3.12 ==========
GCS d-(++) s+: a? C++ UL+>++++ P+
L++ E--- W+(+++) N++ o? K? w--- O? M+
V? PS- PE+ Y-(--) PGP- t+++ 5? X R tv-- b+
DI+++ D+ G e* h- !r !y
========= END GCv3.12 ========
Reid Thompson
2006-02-13 20:16:03 UTC
Permalink
Post by lordSauron
Post by Reid Thompson
http://sql-info.de/mysql/gotchas.html vs
http://sql-info.de/postgresql/postgres-gotchas.html
So basically you're moaning about how MySQL handles some undefined behaviour?
Post by Reid Thompson
http://sql-info.de/postgresql/
Also, PostgreSQL is completely free for ANY use -- BSD license, versus
MySQL which is only free for certain uses.
That could be an influence...
Perhaps.....Perhaps not. See if you can find the defined behavior for
the gotchas( i seem to recall a table somewhere on the web that google
should be able to come up with). If you do, see which DB's ( MySQL,
PostgreSQL, ORACLE, DB2, SYBASE, MS SQL, INFORMIX, etc) most accurately
reflect the defined behaviors. For those with no defined behavior,
compare MySQL's behavior to the other DB's. In most cases I believe you
will find that the 'other' DB's more accurately reflect the defined
behavior, and that for undefined behaviors the 'other' DB's are more
alike in their behavior than MySQL (i.e. MySQL is the odd ball of the
bunch). That may or may not make any difference to the OP, or to you,
or even to other list members. It does to me, and should to anyone who
might be writing code that may have to be fronted onto different DB
backends.

Even if it's not defined, the gotchas listed on
http://sql-info.de/mysql/gotchas.html require extra work/code to account
for ( try applying the concept of 'least surprise' to the listing )....


What goes in - isn't (always) what comes out

So - your app messed up. It tried to insert an invalid value into a
column. There are two options here: 1) the database throws an error and
your app either deals with it gracefully or fails. 2) The database
truncates the value, or takes a guess at what might be an alternative
value and silently inserts it without giving you the teensiest hint that
what you put in is different to what you'll get out.

mysql> CREATE TABLE bounds_test (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
price NUMERIC(4,2),
code VARCHAR(8),
numbers_only INT
);
Query OK, 0 rows affected (0.06 sec)

mysql> INSERT INTO bounds_test VALUES (

99999999999999,
21474.83,
'ABCDEFGHIJK',
'A quick brown dolphin...'
);
Query OK, 1 row affected (0.03 sec)

mysql> SELECT * FROM bounds_test;
+------------+--------+----------+--------------+
| id | price | code | numbers_only |
+------------+--------+----------+--------------+
| 2147483647 | 999.99 | ABCDEFGH | 0 |
+------------+--------+----------+--------------+
1 row in set (0.01 sec)

(Note: in MySQL 4.1.x, the presence of warnings is notified on the query
status line; executing SHOW WARNINGS after the INSERT displays Data
truncated messages for each column).

As a nice extra touch note that although the price was defined with a
precision of 4 digits, MySQL inserted a number containing 5. Possibly
this is because MySQL internally adds an extra "digit" to store a minus
sign, and because the storage space is there uses it with positive
numbers to pack an extra digit in, if the explanation here:
http://dev.mysql.com/doc/mysql/en/Numeric_types.html is anything to go by.

Other databases (tested: Firebird 1.5rc4, Oracle 8.1.7 and PostgreSQL
7.4) raised errors with the same data. On a column defined as
NUMERIC(4,2) the highest value accepted in all databases was the
expected 99.99.

For another reason why this is seriously bad database mojo see section
3.5 <http://sql-info.de/mysql/referential-integrity.html#3_5>

Division by zero

mysql> SELECT 1/0;
+------+

| 1/0 |
+------+
| NULL |
+------+
1 row in set (0.02 sec)

Other databases (tested: DB2 8.1, Firebird 1.5rc4, Oracle 8.1.7,
PostgreSQL 7.3.4) all raise a "division by zero" error when performing
the same calculation.

See: http://dev.mysql.com/doc/mysql/en/Arithmetic_functions.html


February 31st

Throughout history many different calendar systems have been developed
around the world. Although the way of counting years still varies, most
countries and regions have adopted the Roman-Nordic system of months and
weekdays - except, ironically enough, a small corner of Scandinavia with
a high dolphin population ;-).

mysql> CREATE TABLE datetest (id INT, a_date DATE);
Query OK, 0 rows affected (0.00 sec)

mysql> INSERT INTO datetest VALUES(1, '2003-02-31');
Query OK, 1 row affected (0.00 sec)

mysql> SELECT * FROM datetest;
+------+------------+
| id | a_date |
+------+------------+
| 1 | 2003-02-31 |
+------+------------+
1 row in set (0.00 sec)

So, what's the day before February 31st?

mysql> SELECT DATE_SUB('2003-02-31', INTERVAL 1 DAY);
+----------------------------------------+
| DATE_SUB('2003-02-31', INTERVAL 1 DAY) |
+----------------------------------------+
| 2003-03-02 |
+----------------------------------------+
1 row in set (0.00 sec)

Which is of course two days before the day after February 31st:

mysql> SELECT DATE_ADD('2003-02-31', INTERVAL 1 DAY);
+----------------------------------------+
| DATE_ADD('2003-02-31', INTERVAL 1 DAY) |
+----------------------------------------+
| 2003-03-04 |
+----------------------------------------+
1 row in set (0.00 sec)

So what kind of checking does MySQL do on date values? A hint:




If you use really malformed dates, the result is NULL.


--http://dev.mysql.com/doc/mysql/en/Date_and_time_functions.html

Obviously, the 31st of February is not malformed enough. Let's try again:

mysql> SELECT DATE_ADD('2003-02-!!!!!!31!!!!!', INTERVAL 1 DAY);
+---------------------------------------------------+
| DATE_ADD('2003-02-!!!!!!31!!!!!', INTERVAL 1 DAY) |
+---------------------------------------------------+
| 2003-03-04 |
+---------------------------------------------------+
1 row in set (0.00 sec)

Nope.

mysql> SELECT DATE_ADD('2003-02-99', INTERVAL 1 DAY);
+----------------------------------------+
| DATE_ADD('2003-02-99', INTERVAL 1 DAY) |
+----------------------------------------+
| NULL |
+----------------------------------------+
1 row in set (0.00 sec

Hmmm. A pattern emerges...




The MySQL server only performs basic checking on the validity of a date:
days 00-31, months 00-12, years 1000-9999. Any date not within this
range will revert to 0000-00-00. Please note that this still allows you
to store invalid dates such as 2002-04-31. It allows web applications to
store data from a form without further checking. To ensure a date is
valid, perform a check in your application.


--http://dev.mysql.com/doc/mysql/en/DATETIME.html

Makes you wonder why they bother...

Addendum: future MySQL versions are scheduled to contain server options
which enable sane data checks, although the need to retain
backwards-compatibility means these will probably not be enabled by
default.
lordSauron
2006-02-13 20:30:06 UTC
Permalink
Post by Reid Thompson
Post by lordSauron
Post by Reid Thompson
http://sql-info.de/mysql/gotchas.html vs
http://sql-info.de/postgresql/postgres-gotchas.html
So basically you're moaning about how MySQL handles some undefined behaviour?
Post by Reid Thompson
http://sql-info.de/postgresql/
Also, PostgreSQL is completely free for ANY use -- BSD license, versus
MySQL which is only free for certain uses.
That could be an influence...
Perhaps.....Perhaps not. See if you can find the defined behavior for
the gotchas( i seem to recall a table somewhere on the web that google
should be able to come up with). If you do, see which DB's ( MySQL,
PostgreSQL, ORACLE, DB2, SYBASE, MS SQL, INFORMIX, etc) most accurately
reflect the defined behaviors. For those with no defined behavior,
compare MySQL's behavior to the other DB's. In most cases I believe you
will find that the 'other' DB's more accurately reflect the defined
behavior, and that for undefined behaviors the 'other' DB's are more
alike in their behavior than MySQL (i.e. MySQL is the odd ball of the
bunch). That may or may not make any difference to the OP, or to you,
or even to other list members. It does to me, and should to anyone who
might be writing code that may have to be fronted onto different DB
backends.
I don't have the raw time right now to go hunting for things like
that, but if I ever do, I'll by all means try it : )
Post by Reid Thompson
Even if it's not defined, the gotchas listed on
http://sql-info.de/mysql/gotchas.html require extra work/code to account
for ( try applying the concept of 'least surprise' to the listing )....
What goes in - isn't (always) what comes out
Yeah, that one concerned me just a bit. However, I don't know of an
app where that doesn't happen from time to time.
Post by Reid Thompson
So - your app messed up. It tried to insert an invalid value into a
column. There are two options here: 1) the database throws an error and
your app either deals with it gracefully or fails. 2) The database
truncates the value, or takes a guess at what might be an alternative
value and silently inserts it without giving you the teensiest hint that
what you put in is different to what you'll get out.
mysql> CREATE TABLE bounds_test (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
price NUMERIC(4,2),
code VARCHAR(8),
numbers_only INT
);
Query OK, 0 rows affected (0.06 sec)
mysql> INSERT INTO bounds_test VALUES (
99999999999999,
21474.83,
'ABCDEFGHIJK',
'A quick brown dolphin...'
);
Query OK, 1 row affected (0.03 sec)
mysql> SELECT * FROM bounds_test;
+------------+--------+----------+--------------+
| id | price | code | numbers_only |
+------------+--------+----------+--------------+
| 2147483647 | 999.99 | ABCDEFGH | 0 |
+------------+--------+----------+--------------+
1 row in set (0.01 sec)
(Note: in MySQL 4.1.x, the presence of warnings is notified on the query
status line; executing SHOW WARNINGS after the INSERT displays Data
truncated messages for each column).
As a nice extra touch note that although the price was defined with a
precision of 4 digits, MySQL inserted a number containing 5. Possibly
this is because MySQL internally adds an extra "digit" to store a minus
sign, and because the storage space is there uses it with positive
http://dev.mysql.com/doc/mysql/en/Numeric_types.html is anything to go by.
Other databases (tested: Firebird 1.5rc4, Oracle 8.1.7 and PostgreSQL
7.4) raised errors with the same data. On a column defined as
NUMERIC(4,2) the highest value accepted in all databases was the
expected 99.99.
For another reason why this is seriously bad database mojo see section
3.5 <http://sql-info.de/mysql/referential-integrity.html#3_5>
Division by zero
mysql> SELECT 1/0;
+------+
| 1/0 |
+------+
| NULL |
+------+
1 row in set (0.02 sec)
Other databases (tested: DB2 8.1, Firebird 1.5rc4, Oracle 8.1.7,
PostgreSQL 7.3.4) all raise a "division by zero" error when performing
the same calculation.
This brings up my age-old arguement:

suppose I have a nonzero number x. x==x, right? so, x/0 should be
precisely equal to itself, no? We don't know what it is, true, since
it approximates to infinity, however, it should be the same unless I'm
hitting some grand inconsistency no one has yet told me about.
Post by Reid Thompson
See: http://dev.mysql.com/doc/mysql/en/Arithmetic_functions.html
February 31st
Throughout history many different calendar systems have been developed
around the world. Although the way of counting years still varies, most
countries and regions have adopted the Roman-Nordic system of months and
weekdays - except, ironically enough, a small corner of Scandinavia with
a high dolphin population ;-).
mysql> CREATE TABLE datetest (id INT, a_date DATE);
Query OK, 0 rows affected (0.00 sec)
mysql> INSERT INTO datetest VALUES(1, '2003-02-31');
Query OK, 1 row affected (0.00 sec)
mysql> SELECT * FROM datetest;
+------+------------+
| id | a_date |
+------+------------+
| 1 | 2003-02-31 |
+------+------------+
1 row in set (0.00 sec)
So, what's the day before February 31st?
mysql> SELECT DATE_SUB('2003-02-31', INTERVAL 1 DAY);
+----------------------------------------+
| DATE_SUB('2003-02-31', INTERVAL 1 DAY) |
+----------------------------------------+
| 2003-03-02 |
+----------------------------------------+
1 row in set (0.00 sec)
mysql> SELECT DATE_ADD('2003-02-31', INTERVAL 1 DAY);
+----------------------------------------+
| DATE_ADD('2003-02-31', INTERVAL 1 DAY) |
+----------------------------------------+
| 2003-03-04 |
+----------------------------------------+
1 row in set (0.00 sec)
If you use really malformed dates, the result is NULL.
If you give it bad input, you're asking for bad output. If you spend
all your time idiot proofing your software, the world will just throw
a better idiot at it.
Post by Reid Thompson
--http://dev.mysql.com/doc/mysql/en/Date_and_time_functions.html
mysql> SELECT DATE_ADD('2003-02-!!!!!!31!!!!!', INTERVAL 1 DAY);
+---------------------------------------------------+
| DATE_ADD('2003-02-!!!!!!31!!!!!', INTERVAL 1 DAY) |
+---------------------------------------------------+
| 2003-03-04 |
+---------------------------------------------------+
1 row in set (0.00 sec)
Nope.
mysql> SELECT DATE_ADD('2003-02-99', INTERVAL 1 DAY);
+----------------------------------------+
| DATE_ADD('2003-02-99', INTERVAL 1 DAY) |
+----------------------------------------+
| NULL |
+----------------------------------------+
1 row in set (0.00 sec
Hmmm. A pattern emerges...
days 00-31, months 00-12, years 1000-9999. Any date not within this
range will revert to 0000-00-00. Please note that this still allows you
to store invalid dates such as 2002-04-31. It allows web applications to
store data from a form without further checking. To ensure a date is
valid, perform a check in your application.
Sounds like fun!
Post by Reid Thompson
--http://dev.mysql.com/doc/mysql/en/DATETIME.html
Makes you wonder why they bother...
Addendum: future MySQL versions are scheduled to contain server options
which enable sane data checks, although the need to retain
backwards-compatibility means these will probably not be enabled by
default.
Future stuff... MySQL works, that's all I ever am going to ask of it.
If it's built-in datatypes stop working, I'll just use a varchar and
parse my life away - I don't really care that much ATM.

--
========== GCv3.12 ==========
GCS d-(++) s+: a? C++ UL+>++++ P+
L++ E--- W+(+++) N++ o? K? w--- O? M+
V? PS- PE+ Y-(--) PGP- t+++ 5? X R tv-- b+
DI+++ D+ G e* h- !r !y
========= END GCv3.12 ========
Per Westermark
2006-02-13 19:54:02 UTC
Permalink
MySQL is used quite successfully in a huge number of systems, but just
like Windows, there are a lot of people who like to critizise it.

A number of well-needed functions didn't arrive until version 5, but
version 4 was quite capable of solving most problems too. There is
often more than one way to skin a cat. Some tools can handle more
alternatives, some may handle fewer. However, the involved developer(s)
are most often the limiting factors - do they have enough time and
fantacy to produce really great things.

But never forget that operating systems, databases, programming languages,
editors etc are very sensitive affairs. Don't post a bad review of a
well-known product to the wrong mailing list or you'll have a flame war on
your hands :)

/Per W
Post by lordSauron
Post by Reid Thompson
Post by lordSauron
Post by Reid Thompson
PostgreSQL is another, ( in my opinion a better ), option.
Why is it better? Just wondering - I have no data as to why it should
be better than MySQL.
http://sql-info.de/mysql/gotchas.html vs
http://sql-info.de/postgresql/postgres-gotchas.html
So basically you're moaning about how MySQL handles some undefined behaviour?
Post by Reid Thompson
http://sql-info.de/postgresql/
Also, PostgreSQL is completely free for ANY use -- BSD license, versus
MySQL which is only free for certain uses.
That could be an influence...
--
========== GCv3.12 ==========
GCS d-(++) s+: a? C++ UL+>++++ P+
L++ E--- W+(+++) N++ o? K? w--- O? M+
V? PS- PE+ Y-(--) PGP- t+++ 5? X R tv-
lordSauron
2006-02-13 19:57:02 UTC
Permalink
Post by Per Westermark
MySQL is used quite successfully in a huge number of systems, but just
like Windows, there are a lot of people who like to critizise it.
Of course! Critics are your friends! How good do you think books
would be if the editors never *used* their red pens? Good,
constructive critiscism is something that you MUST learn to accept and
at best even welcome, since it's the only real way we can get a better
end-product.
Post by Per Westermark
A number of well-needed functions didn't arrive until version 5, but
version 4 was quite capable of solving most problems too. There is
often more than one way to skin a cat. Some tools can handle more
alternatives, some may handle fewer. However, the involved developer(s)
are most often the limiting factors - do they have enough time and
fantacy to produce really great things.
But never forget that operating systems, databases, programming languages,
editors etc are very sensitive affairs. Don't post a bad review of a
well-known product to the wrong mailing list or you'll have a flame war on
your hands :)
Yeah, I was just curious about why the two were different. For my
needs ATM MySQL should work just fine - it's free, Open Source, fast,
stable, and well known and supported. However, I was really curious
as to why one could be better than the other - to me SQL is SQL no
matter how I look at it.

--
========== GCv3.12 ==========
GCS d-(++) s+: a? C++ UL+>++++ P+
L++ E--- W+(+++) N++ o? K? w--- O? M+
V? PS- PE+ Y-(--) PGP- t+++ 5? X R tv-- b+
DI+++ D+ G e* h- !r !y
========= END GCv3.12 ========
Reid Thompson
2006-02-13 20:27:01 UTC
Permalink
Post by Per Westermark
MySQL is used quite successfully in a huge number of systems, but just
like Windows, there are a lot of people who like to critizise it.
A number of well-needed functions didn't arrive until version 5, but
version 4 was quite capable of solving most problems too. There is
often more than one way to skin a cat. Some tools can handle more
alternatives, some may handle fewer. However, the involved developer(s)
are most often the limiting factors - do they have enough time and
fantacy to produce really great things.
But never forget that operating systems, databases, programming languages,
editors etc are very sensitive affairs. Don't post a bad review of a
well-known product to the wrong mailing list or you'll have a flame war on
your hands :)
/Per W
Didn't post a bad review, posted an opinion ( "PostgreSQL is another, (
in my opinion a better ), option.") and an example of how to implement a
PostgreSQL enabled application in Dev-C++.
Then, posted link in attempt to respond to "Why is it better? Just
wondering - I have no data as to why it should be better than MySQL."
Also posted the link to the PostgreSQL gotchas. Also would expect
anyone to do their own due diligence as to which DB ( PG, MySQL, DB2 (
now free in a form that should support a large number of apps), ORACLE,
free for use under certain spec limitations, etc) to use.

Didn't intend, nor want a flame war.

Last post from me to the list on this thread.
Post by Per Westermark
Post by lordSauron
Post by Reid Thompson
Post by lordSauron
Post by Reid Thompson
PostgreSQL is another, ( in my opinion a better ), option.
Why is it better? Just wondering - I have no data as to why it should
be better than MySQL.
http://sql-info.de/mysql/gotchas.html vs
http://sql-info.de/postgresql/postgres-gotchas.html
So basically you're moaning about how MySQL handles some undefined behaviour?
Post by Reid Thompson
http://sql-info.de/postgresql/
Also, PostgreSQL is completely free for ANY use -- BSD license, versus
MySQL which is only free for certain uses.
That could be an influence...
--
========== GCv3.12 ==========
GCS d-(++) s+: a? C++ UL+>++++ P+
L++ E--- W+(+++) N++ o? K? w--- O? M+
V? PS- PE+ Y-(--) PGP- t+++ 5? X R tv-
Per Westermark
2006-02-13 20:33:01 UTC
Permalink
Sorry for the swedish form of 'yyyy-mm-dd' dates, but anyway...

Just quick note - I really love the ability to store '2006-02-00' as date
if I know that i bought something in february, but don't know the exact
date. With some databases, I am not allowed to store zero for day, month
or year and have to add a flags field to mention which fields of the data
that are valid.

Another example: I know that someone have a birthday at nov 10, but I
don't know the birth year. Then I can enter birthday '0000-11-10'.
Sometime later I might finally find out the birth year and correct the
date with the missing information.

/Per W
Post by Reid Thompson
Post by lordSauron
Post by Reid Thompson
http://sql-info.de/mysql/gotchas.html vs
http://sql-info.de/postgresql/postgres-gotchas.html
So basically you're moaning about how MySQL handles some undefined behaviour?
Post by Reid Thompson
http://sql-info.de/postgresql/
Also, PostgreSQL is completely free for ANY use -- BSD license, versus
MySQL which is only free for certain uses.
That could be an influence...
Perhaps.....Perhaps not. See if you can find the defined behavior for
the gotchas( i seem to recall a table somewhere on the web that google
should be able to come up with). If you do, see which DB's ( MySQL,
PostgreSQL, ORACLE, DB2, SYBASE, MS SQL, INFORMIX, etc) most accurately
reflect the defined behaviors. For those with no defined behavior,
compare MySQL's behavior to the other DB's. In most cases I believe you
will find that the 'other' DB's more accurately reflect the defined
behavior, and that for undefined behaviors the 'other' DB's are more
alike in their behavior than MySQL (i.e. MySQL is the odd ball of the
bunch). That may or may not make any difference to the OP, or to you,
or even to other list members. It does to me, and should to anyone who
might be writing code that may have to be fronted onto different DB
backends.
Even if it's not defined, the gotchas listed on
http://sql-info.de/mysql/gotchas.html require extra work/code to account
for ( try applying the concept of 'least surprise' to the listing )....
What goes in - isn't (always) what comes out
So - your app messed up. It tried to insert an invalid value into a
column. There are two options here: 1) the database throws an error and
your app either deals with it gracefully or fails. 2) The database
truncates the value, or takes a guess at what might be an alternative
value and silently inserts it without giving you the teensiest hint that
what you put in is different to what you'll get out.
mysql> CREATE TABLE bounds_test (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
price NUMERIC(4,2),
code VARCHAR(8),
numbers_only INT
);
Query OK, 0 rows affected (0.06 sec)
mysql> INSERT INTO bounds_test VALUES (
99999999999999,
21474.83,
'ABCDEFGHIJK',
'A quick brown dolphin...'
);
Query OK, 1 row affected (0.03 sec)
mysql> SELECT * FROM bounds_test;
+------------+--------+----------+--------------+
| id | price | code | numbers_only |
+------------+--------+----------+--------------+
| 2147483647 | 999.99 | ABCDEFGH | 0 |
+------------+--------+----------+--------------+
1 row in set (0.01 sec)
(Note: in MySQL 4.1.x, the presence of warnings is notified on the query
status line; executing SHOW WARNINGS after the INSERT displays Data
truncated messages for each column).
As a nice extra touch note that although the price was defined with a
precision of 4 digits, MySQL inserted a number containing 5. Possibly
this is because MySQL internally adds an extra "digit" to store a minus
sign, and because the storage space is there uses it with positive
http://dev.mysql.com/doc/mysql/en/Numeric_types.html is anything to go by.
Other databases (tested: Firebird 1.5rc4, Oracle 8.1.7 and PostgreSQL
7.4) raised errors with the same data. On a column defined as
NUMERIC(4,2) the highest value accepted in all databases was the
expected 99.99.
For another reason why this is seriously bad database mojo see section
3.5 <http://sql-info.de/mysql/referential-integrity.html#3_5>
Division by zero
mysql> SELECT 1/0;
+------+
| 1/0 |
+------+
| NULL |
+------+
1 row in set (0.02 sec)
Other databases (tested: DB2 8.1, Firebird 1.5rc4, Oracle 8.1.7,
PostgreSQL 7.3.4) all raise a "division by zero" error when performing
the same calculation.
See: http://dev.mysql.com/doc/mysql/en/Arithmetic_functions.html
February 31st
Throughout history many different calendar systems have been developed
around the world. Although the way of counting years still varies, most
countries and regions have adopted the Roman-Nordic system of months and
weekdays - except, ironically enough, a small corner of Scandinavia with
a high dolphin population ;-).
mysql> CREATE TABLE datetest (id INT, a_date DATE);
Query OK, 0 rows affected (0.00 sec)
mysql> INSERT INTO datetest VALUES(1, '2003-02-31');
Query OK, 1 row affected (0.00 sec)
mysql> SELECT * FROM datetest;
+------+------------+
| id | a_date |
+------+------------+
| 1 | 2003-02-31 |
+------+------------+
1 row in set (0.00 sec)
So, what's the day before February 31st?
mysql> SELECT DATE_SUB('2003-02-31', INTERVAL 1 DAY);
+----------------------------------------+
| DATE_SUB('2003-02-31', INTERVAL 1 DAY) |
+----------------------------------------+
| 2003-03-02 |
+----------------------------------------+
1 row in set (0.00 sec)
mysql> SELECT DATE_ADD('2003-02-31', INTERVAL 1 DAY);
+----------------------------------------+
| DATE_ADD('2003-02-31', INTERVAL 1 DAY) |
+----------------------------------------+
| 2003-03-04 |
+----------------------------------------+
1 row in set (0.00 sec)
If you use really malformed dates, the result is NULL.
--http://dev.mysql.com/doc/mysql/en/Date_and_time_functions.html
mysql> SELECT DATE_ADD('2003-02-!!!!!!31!!!!!', INTERVAL 1 DAY);
+---------------------------------------------------+
| DATE_ADD('2003-02-!!!!!!31!!!!!', INTERVAL 1 DAY) |
+---------------------------------------------------+
| 2003-03-04 |
+---------------------------------------------------+
1 row in set (0.00 sec)
Nope.
mysql> SELECT DATE_ADD('2003-02-99', INTERVAL 1 DAY);
+----------------------------------------+
| DATE_ADD('2003-02-99', INTERVAL 1 DAY) |
+----------------------------------------+
| NULL |
+----------------------------------------+
1 row in set (0.00 sec
Hmmm. A pattern emerges...
days 00-31, months 00-12, years 1000-9999. Any date not within this
range will revert to 0000-00-00. Please note that this still allows you
to store invalid dates such as 2002-04-31. It allows web applications to
store data from a form without further checking. To ensure a date is
valid, perform a check in your application.
--http://dev.mysql.com/doc/mysql/en/DATETIME.html
Makes you wonder why they bother...
Addendum: future MySQL versions are scheduled to contain server options
which enable sane data checks, although the need to retain
backwards-compatibility means these will probably not be enabled by
default.
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Dev-cpp-users mailing list
TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
Per Westermark
2006-02-13 20:49:05 UTC
Permalink
No, I never claimed that you posted a bad review. Your post was a very
specific - and valued - answer to his request. A specific reason why you
personally recommended PostgreSQL instead of MySQL.

I just mentioned to lordSauron that there are no one single great tool.
Some people prefer one tool. Someone prefer another. Most tools are able
to solve the problems. Most unsolveable problems are caused by bad
programmers, not by bad tools.

Whenever you have good information about a sitionation where a specific
tool is good - please post. It's by processing information we may learn.

About flame wars - only stupid people, or uninformed people - goes to
flame wars over different products. Comparisons and suggestions are needed
to help people to find their favorites. In this case it was a note that
constructive criticism is good, while one-handed critizism of a specific
product on the other hand requires a carefully selected audience.

I have a number of times on this list written about M$ Windoze. While
DevC++ is almost totally a Windows product, I survive because a lot of
programmers thinks the same about Windows. Would it be recommendable with
the same comments in a .NET forum...

About PostgreSQL - the only thing I haven't completely come to grip with
is how to upgrade it. To me, it feels a lot harder to have not too
computer-savy people install and maintain a PostgreSQL installation than a
MySQL installation. With MySQL, I know quite well how to take care of the
valued data during an upgrade.

When running an installation myself, it doesn't matter so much. I know
where I have my backups, and I can always populate new empty databases if
something goes wrong. With an application out there running on 10, 100 or
1000 installations, I don't want the slightest involvment with the
customers, their backup policies, computer upgrades etc.

/Per W
Post by Reid Thompson
Post by Per Westermark
MySQL is used quite successfully in a huge number of systems, but just
like Windows, there are a lot of people who like to critizise it.
A number of well-needed functions didn't arrive until version 5, but
version 4 was quite capable of solving most problems too. There is
often more than one way to skin a cat. Some tools can handle more
alternatives, some may handle fewer. However, the involved developer(s)
are most often the limiting factors - do they have enough time and
fantacy to produce really great things.
But never forget that operating systems, databases, programming languages,
editors etc are very sensitive affairs. Don't post a bad review of a
well-known product to the wrong mailing list or you'll have a flame war on
your hands :)
/Per W
Didn't post a bad review, posted an opinion ( "PostgreSQL is another, (
in my opinion a better ), option.") and an example of how to implement a
PostgreSQL enabled application in Dev-C++.
Then, posted link in attempt to respond to "Why is it better? Just
wondering - I have no data as to why it should be better than MySQL."
Also posted the link to the PostgreSQL gotchas. Also would expect
anyone to do their own due diligence as to which DB ( PG, MySQL, DB2 (
now free in a form that should support a large number of apps), ORACLE,
free for use under certain spec limitations, etc) to use.
Didn't intend, nor want a flame war.
Last post from me to the list on this thread.
Post by Per Westermark
Post by lordSauron
Post by Reid Thompson
Post by lordSauron
Post by Reid Thompson
PostgreSQL is another, ( in my opinion a better ), option.
Why is it better? Just wondering - I have no data as to why it should
be better than MySQL.
http://sql-info.de/mysql/gotchas.html vs
http://sql-info.de/postgresql/postgres-gotchas.html
So basically you're moaning about how MySQL handles some undefined behaviour?
Post by Reid Thompson
http://sql-info.de/postgresql/
Also, PostgreSQL is completely free for ANY use -- BSD license, versus
MySQL which is only free for certain uses.
That could be an influence...
--
========== GCv3.12 ==========
GCS d-(++) s+: a? C++ UL+>++++ P+
L++ E--- W+(+++) N++ o? K? w--- O? M+
V? PS- PE+ Y-(--) PGP- t+++ 5? X R tv-
Per Westermark
2006-02-13 20:57:05 UTC
Permalink
Why do you say that x/0 approximates to infinity?

x/0 approaches infinity if x gets closer and closer to zero from the
positive side.

It approaches -infinity if x gets closer and closer to zero from the
negative side.

Since limes x/0 -> infinity or -infinity depending on direction of
x->0, is x/0 infinity, negative infinity or something completely else -
the grand inconsistency you where thinking about :)

/Per W
Post by lordSauron
suppose I have a nonzero number x. x==x, right? so, x/0 should be
precisely equal to itself, no? We don't know what it is, true, since
it approximates to infinity, however, it should be the same unless I'm
hitting some grand inconsistency no one has yet told me about.
Alfred P. Reaud
2006-02-14 23:33:03 UTC
Permalink
That's all in the calculus, and the concept of limits.

In reality, think about what the zero operation means with respect to physics and quantum mechanics. As long as you deal with limits, the conventional wisdom applies. But at 0, things reach a boundary condition. This is illustrated by the Dirac Delta Function

First, for edification, let's address the identity: 1/(infinity) = 0, on a common object, an orange. This orange, when divided, will eventually reach a slice which can't be further divided and still give you an orange slice. That last slice, though of a molecular thickness, is still the last slice. If you divide it further, you're not dealing with an orange anymore, rather you are dealing with constituent atoms and molecules. So you don't get an infinite number of orange slices, rather you get a finite though large number of slices.

So what happens when you actually divide by 0? Physically, IMHO, you do not preform the operation. The physical operation 0 is a null operation (as in addition and subtraction). The logic is that if you try to divide an orange 0 times, you actually don't divide the orange by anything, i.e. 1/0 = 1 (with respect to physical objects). However, the identity 1*0 = 0 still works because as you're not preforming the multiplication (0 is the null operator, hence no operation), therefore the sum of additions which make a multiplication isn't done, so the result is 0.

This must be the reason why general relativity and quantum mechanics don't meet...;^)

Per Westermark <***@iapetus.neab.net> wrote:
Why do you say that x/0 approximates to infinity?

x/0 approaches infinity if x gets closer and closer to zero from the
positive side.

It approaches -infinity if x gets closer and closer to zero from the
negative side.

Since limes x/0 -> infinity or -infinity depending on direction of
x->0, is x/0 infinity, negative infinity or something completely else -
the grand inconsistency you where thinking about :)

/Per W
suppose I have a nonzero number x. x==x, right? so, x/0 should be
precisely equal to itself, no? We don't know what it is, true, since
it approximates to infinity, however, it should be the same unless I'm
hitting some grand inconsistency no one has yet told me about.
Alfred P. Reaud
lordSauron
2006-02-15 01:31:01 UTC
Permalink
Man... send in plaintext - it saves more space.
Post by Alfred P. Reaud
That's all in the calculus, and the concept of limits.
I try not to think with limits. When you put limits you limit
yourself. Leave yourself without limits and you are limitless. Don't
be scared by the concept of ininfity.
Post by Alfred P. Reaud
In reality, think about what the zero operation means with respect to physics and
quantum mechanics. As long as you deal with limits, the conventional wisdom applies.
But at 0, things reach a boundary condition. This is illustrated by the Dirac Delta
Function
I was talking more about logic, really, not physics and/or quantum mechanics.
Post by Alfred P. Reaud
First, for edification, let's address the identity: 1/(infinity) = 0, on a common object, an
orange. This orange, when divided, will eventually reach a slice which can't be further
divided and still give you an orange slice. That last slice, though of a molecular
You're not thinking abstractedly. When I think about math, I think
abstractedly, which has no limits. When you apply this to your
orange, while it's a good learning crutch, it natrually applies many
limits.
Post by Alfred P. Reaud
thickness, is still the last slice. If you divide it further, you're not dealing with an orange
anymore, rather you are dealing with constituent atoms and molecules. So you don't get
an infinite number of orange slices, rather you get a finite though large number of
slices.
So what happens when you actually divide by 0? Physically, IMHO, you do not preform
the operation. The physical operation 0 is a null operation (as in addition and
subtraction). The logic is that if you try to divide an orange 0 times, you actually don't
divide the orange by anything, i.e. 1/0 = 1 (with respect to physical objects). However,
the identity 1*0 = 0 still works because as you're not preforming the multiplication (0 is
the null operator, hence no operation), therefore the sum of additions which make a
multiplication isn't done, so the result is 0.
You're not making any logical or mathematical sense to me.
Post by Alfred P. Reaud
This must be the reason why general relativity and quantum mechanics don't meet...;^)
Since when do computers care about reality? When on a microprocessor,
you're working with the most abstractable thing there is! Pi can be 3
so long as it's proportionately reletive to the other numbers! What
is 1? Or 2? Numerics is entirely abstract. You can arbitrarily say
"that is 1 organge" but when you first defined the link between the
pure abstract and the numbers you lost a lot of precision, if you will
allow me to term it that way. Division by zero is very real, but real
division by zero is not, if you follow my meaning.
Post by Alfred P. Reaud
Why do you say that x/0 appr oximates to infinity?
That's how my math teacher termed it. What are we if nothing more
than parrots of what we were taught?

--
========== GCv3.12 ==========
GCS d-(++) s+: a? C++ UL+>++++ P+
L++ E--- W+(+++) N++ o? K? w--- O? M+
V? PS- PE+ Y-(--) PGP- t+++ 5? X R tv-- b+
DI+++ D+ G e* h- !r !y
========= END GCv3.12 ========
Daniel K. O.
2006-02-15 01:53:01 UTC
Permalink
And the article to end this pointless offtopic:
http://en.wikipedia.org/wiki/Division_by_zero

This is IMHO the relevant quote:

"Division by zero must be left undefined in any mathematical system that
obeys the axioms of a field
<http://en.wikipedia.org/wiki/Field_%28mathematics%29>."

If you define any kind of result from a division by zero, you open a
hole in your system for fallacies like "2=1" (see the example in the
Wikipedia article).


---
Daniel K. O.



_______________________________________________________
Yahoo! Acesso Grátis - Internet rápida e grátis. Instale o discador agora!
http://br.acesso.yahoo.com
Richard Van Wyk
2006-02-15 02:45:08 UTC
Permalink
We can use zero as shorthand for the following number:

0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001


Or as a quick way of writing 1 / infinity.

"1/Infinity" is quicker than writing zeros on every piece of paper in the
universe, forever, followed by a 1.











lordSauron <***@gmail.com>
Sent by: dev-cpp-users-***@lists.sourceforge.net
15/02/2006 01:30 PM


To: "Alfred P. Reaud" <***@yahoo.com>
cc: Dev-Cpp UserList <dev-cpp-***@lists.sourceforge.net>
Subject: Re: [Dev-C++] How connect c++ to a database?


Man... send in plaintext - it saves more space.
Post by Alfred P. Reaud
That's all in the calculus, and the concept of limits.
I try not to think with limits. When you put limits you limit
yourself. Leave yourself without limits and you are limitless. Don't
be scared by the concept of ininfity.
Post by Alfred P. Reaud
In reality, think about what the zero operation means with respect to
physics and
Post by Alfred P. Reaud
quantum mechanics. As long as you deal with limits, the conventional
wisdom applies.
Post by Alfred P. Reaud
But at 0, things reach a boundary condition. This is illustrated by
the Dirac Delta
Post by Alfred P. Reaud
Function
I was talking more about logic, really, not physics and/or quantum
mechanics.
Post by Alfred P. Reaud
First, for edification, let's address the identity: 1/(infinity) = 0, on
a common object, an
Post by Alfred P. Reaud
orange. This orange, when divided, will eventually reach a slice which
can't be further
Post by Alfred P. Reaud
divided and still give you an orange slice. That last slice, though of
a molecular

You're not thinking abstractedly. When I think about math, I think
abstractedly, which has no limits. When you apply this to your
orange, while it's a good learning crutch, it natrually applies many
limits.
Post by Alfred P. Reaud
thickness, is still the last slice. If you divide it further, you're
not dealing with an orange
Post by Alfred P. Reaud
anymore, rather you are dealing with constituent atoms and molecules. So
you don't get
Post by Alfred P. Reaud
an infinite number of orange slices, rather you get a finite though
large number of
Post by Alfred P. Reaud
slices.
So what happens when you actually divide by 0? Physically, IMHO, you do
not preform
Post by Alfred P. Reaud
the operation. The physical operation 0 is a null operation (as in
addition and
Post by Alfred P. Reaud
subtraction). The logic is that if you try to divide an orange 0 times,
you actually don't
Post by Alfred P. Reaud
divide the orange by anything, i.e. 1/0 = 1 (with respect to physical
objects). However,
Post by Alfred P. Reaud
the identity 1*0 = 0 still works because as you're not preforming the
multiplication (0 is
Post by Alfred P. Reaud
the null operator, hence no operation), therefore the sum of additions
which make a
Post by Alfred P. Reaud
multiplication isn't done, so the result is 0.
You're not making any logical or mathematical sense to me.
Post by Alfred P. Reaud
This must be the reason why general relativity and quantum mechanics
don't meet...;^)

Since when do computers care about reality? When on a microprocessor,
you're working with the most abstractable thing there is! Pi can be 3
so long as it's proportionately reletive to the other numbers! What
is 1? Or 2? Numerics is entirely abstract. You can arbitrarily say
"that is 1 organge" but when you first defined the link between the
pure abstract and the numbers you lost a lot of precision, if you will
allow me to term it that way. Division by zero is very real, but real
division by zero is not, if you follow my meaning.
Post by Alfred P. Reaud
Why do you say that x/0 appr oximates to infinity?
That's how my math teacher termed it. What are we if nothing more
than parrots of what we were taught?

--
========== GCv3.12 ==========
GCS d-(++) s+: a? C++ UL+>++++ P+
L++ E--- W+(+++) N++ o? K? w--- O? M+
V? PS- PE+ Y-(--) PGP- t+++ 5? X R tv-- b+
DI+++ D+ G e* h- !r !y
========= END GCv3.12 ========


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log
files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
Per Westermark
2006-02-15 04:14:01 UTC
Permalink
And that is why I observed that limes 1/x reaches different values when x
reaches zero from positive and negative side, i.e. we either have to
conclude that +infinity is identical to -infinity, or we have to think of
1/0 as just "undefined". In short, thinking of 1/0 as infinity is a
simplification of the problem - my original point.

When talking about division by zero in software-development terms, the
IEEE 754 floating point standard defines:
+n/0 -> +infinity
-n/0 -> -infinity
0/0 -> not a number (NaN)

/Per W
Post by Daniel K. O.
"Division by zero must be left undefined in any mathematical system that
obeys the axioms of a field
<http://en.wikipedia.org/wiki/Field_%28mathematics%29>."
---
Daniel K. O.
lordSauron
2006-02-15 17:51:07 UTC
Permalink
Post by Per Westermark
And that is why I observed that limes 1/x reaches different values when x
reaches zero from positive and negative side, i.e. we either have to
conclude that +infinity is identical to -infinity, or we have to think of
1/0 as just "undefined". In short, thinking of 1/0 as infinity is a
simplification of the problem - my original point.
When talking about division by zero in software-development terms, the
+n/0 -> +infinity
-n/0 -> -infinity
0/0 -> not a number (NaN)
If that's what the IEEE said then that's what we'll use while
programming. Outside of that, face the music: numbers can do
anything, you've just got to strech your thinking to accomidate that.
Richard Van Wyk
2006-02-15 04:45:04 UTC
Permalink
1/x

When considering x approaching zero from the negative side (-x),
when we reach zero, 1/x becomes positive infinity.
because there is no -0.







Per Westermark <***@iapetus.neab.net>
Sent by: dev-cpp-users-***@lists.sourceforge.net
15/02/2006 04:13 PM


To: "Daniel K. O." <***@yahoo.com.br>
cc: Dev-Cpp UserList <dev-cpp-***@lists.sourceforge.net>
Subject: Re: [Dev-C++] How connect c++ to a database?


And that is why I observed that limes 1/x reaches different values when x
reaches zero from positive and negative side, i.e. we either have to
conclude that +infinity is identical to -infinity, or we have to think of
1/0 as just "undefined". In short, thinking of 1/0 as infinity is a
simplification of the problem - my original point.

When talking about division by zero in software-development terms, the
IEEE 754 floating point standard defines:
+n/0 -> +infinity
-n/0 -> -infinity
0/0 -> not a number (NaN)

/Per W
Post by Daniel K. O.
"Division by zero must be left undefined in any mathematical system that
obeys the axioms of a field
<http://en.wikipedia.org/wiki/Field_%28mathematics%29>."
---
Daniel K. O.
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log
files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
Peter Boehm
2006-02-15 07:50:01 UTC
Permalink
Post by Richard Van Wyk
1/x
When considering x approaching zero from the negative side (-x),
when we reach zero, 1/x becomes positive infinity.
because there is no -0.
In mathematics (esp. Calculus) you consider a sequence of numbers x
getting closer to zero but without ever reaching it. You can do this by
coming from the negative side (all values of x are negative) or from the
positive side (all values of x are positive). This depends on the point
of interest. That is why they (the mathematicians) often write "x -> +0"
or "x -> -0". The "->" is the mathematical symbol describing the process
"getting closer to ... but without ever reaching ...".

In the case of the function 1/x it is interesting to differentiate
between positive and negative values of x, resulting in different
limits, resp. "1/x -> -infinity for x -> -0" and "1/x -> +infinity for x
-> +0". The simple conclusion is there will be no value for x=0, 1/0 is
undefined.

Peter
Per Westermark
2006-02-15 07:26:04 UTC
Permalink
Was that a correction of something that I said?

The limit function (also known as limes, lim) when x reaches zero from the
negative side is -infinity, not infinity, and as I noted, it is
problematic to use limes to define the value of 1/0, since we don't like
the duality of 1/0 being both -infinity and +infinity. Hence it should
normally be treated as "undefined", at least when working with real-valued
numbers. Looking at 1/0 as +infinity is a simplification that should be
avoided.

/Per W
Post by Richard Van Wyk
1/x
When considering x approaching zero from the negative side (-x),
when we reach zero, 1/x becomes positive infinity.
because there is no -0.
15/02/2006 04:13 PM
Subject: Re: [Dev-C++] How connect c++ to a database?
And that is why I observed that limes 1/x reaches different values when x
reaches zero from positive and negative side, i.e. we either have to
conclude that +infinity is identical to -infinity, or we have to think of
1/0 as just "undefined". In short, thinking of 1/0 as infinity is a
simplification of the problem - my original point.
When talking about division by zero in software-development terms, the
+n/0 -> +infinity
-n/0 -> -infinity
0/0 -> not a number (NaN)
/Per W
Post by Daniel K. O.
"Division by zero must be left undefined in any mathematical system that
obeys the axioms of a field
<http://en.wikipedia.org/wiki/Field_%28mathematics%29>."
---
Daniel K. O.
Renato Conte
2006-02-15 09:51:07 UTC
Permalink
The original problem was
"How connect C++ to a database?"
I use mySQL and DevC++, but with mySQL++ and/or DevC++ mysql-library
I'have many errors on linkink the code examples.
There is someboby who has run succesfully a simple example? With what
library?
--------------
Renato
Rafael Torres Jr.
2006-02-15 16:35:06 UTC
Permalink
Hello everybody,

I have a problem handling out of memory errors in C++

my program is about 13,819 lines long and it wont compile it anymore because the same error appears.

Fatal F1008 ogpeth.cpp 13578: Out of memory in function main()
***1 errors in Compile***

is there anything I can do in order to avoid this kind of memory leaks?


"Alfred P. Reaud" <***@yahoo.com> wrote: That's all in the calculus, and the concept of limits.

In reality, think about what the zero operation means with respect to physics and quantum mechanics. As long as you deal with limits, the conventional wisdom applies. But at 0, things reach a boundary condition. This is illustrated by the Dirac Delta Function

First, for edification, let's address the identity: 1/(infinity) = 0, on a common object, an orange. This orange, when divided, will eventually reach a slice which can't be further divided and still give you an orange slice. That last slice, though of a molecular thickness, is still the last slice. If you divide it further, you're not dealing with an orange anymore, rather you are dealing with constituent atoms and molecules. So you don't get an infinite number of orange slices, rather you get a finite though large number of slices.

So what happens when you actually divide by 0? Physically, IMHO, you do not preform the operation. The physical operation 0 is a null operation (as in addition and subtraction). The logic is that if you try to divide an orange 0 times, you actually don't divide the orange by anything, i.e. 1/0 = 1 (with respect to physical objects). However, the identity 1*0 = 0 still works because as you're not preforming the multiplication (0 is the null operator, hence no operation), therefore the sum of additions which make a multiplication isn't done, so the result is 0.

This must be the reason why general relativity and quantum mechanics don't meet...;^)

Per Westermark <***@iapetus.neab.net> wrote:
Why do you say that x/0 appr oximates to infinity?

x/0 approaches infinity if x gets closer and closer to zero from the
positive side.

It approaches -infinity if x gets closer and closer to zero from the
negative side.

Since limes x/0 -> infinity or -infinity depending on direction of
x->0, is x/0 infinity, negative infinity or something completely else -
the grand inconsistency you where thinking about :)

/Per W
suppose I have a nonzero number x. x==x, right? so, x/0 should be
precisely equal to itself, no? We don't know what it is, true, since
it approximates to infinity, however, it should be the same unless I'm
hitting some grand inconsistency no one has yet told me about.
Alfred P. Reaud





---------------------------------
Brings words and photos together (easily) with
PhotoMail - it's free and works with Yahoo! Mail.
Alfred P. Reaud
2006-02-15 17:29:01 UTC
Permalink
My suggestion would be to break it up into modules, individual C++ files. Maybe in the range of 1000-2000 each, or whatever works for you. If you've already done that, then maybe compile individually then link together.

I've found a few references to Fatal F1008 on the Web, none related to Dev-C++:
Windows NT, Borland C++ 5.4, 1999
Windows 95-XP, Borland C++ 5.0, 2005 Problem using += operator.
Borland C++ 5.5.1, 2002 Problem caused by 30K+ lines of code, suggests modularizing code.

"Rafael Torres Jr." <***@yahoo.com> wrote:
Hello everybody,

I have a problem handling out of memory errors in C++

my program is about 13,819 lines long and it wont compile it anymore because the same error appears.

Fatal F1008 ogpeth.cpp 13578: Out of memory in function main()
***1 errors in Compile***

is there anything I can do in order to avoid this kind of memory leaks?

<snip>



Alfred P. Reaud
Continue reading on narkive:
Loading...