Hi Manfred,
I am having a look at your work regarding MySQL for D. When I compile and link the example (mysql_test.d) there are no complaints. When I run the test it end with a segmentation fault. I am not skilled enough to understand what the problem is. Could you help me out?
My configuration is as follows:
dmd version 0.111
libmsqlclient.so.14
Debian Linux unstable kernel 2.6.10
Thanks,
Martijn.

I had problems myself (access violations) but it turned out to be because I made a typo when changing the SELECT statement for my test database.
The example does no error checking; please make sure the queries used therein correspond with your database properly. For example, this query:
SELECT a
FROM xyz;
Will obviously fail if there's no xyz table, or if the login to the database failed. However, the test program is unaware of this, and will chug right along and cause you a nice pretty seg fault or similar. Which is only because, imho, that's not within the realm of the example anyway.
But it works fine ;). In fact, I've done testing with libmysqld in D.
-[Unknown]
> Hi Manfred,
> > I am having a look at your work regarding MySQL for D. When I compile and link the example (mysql_test.d) there are no complaints. When I run the test it end with a segmentation fault. I am not skilled enough to understand what the problem is. Could you help me out?
> > My configuration is as follows:
> dmd version 0.111
> libmsqlclient.so.14
> Debian Linux unstable kernel 2.6.10
> > Thanks,
> > > Martijn.

> But it works fine ;). In fact, I've done testing with libmysqld in D.
> -[Unknown]
When I run the example, with modified query string, it does give me the correct results (which is one row in the table). So that seems to work fine. The segmentation fault occurs when the database is closed (I think).
Because there are several versions of MySQL (and it's libs) I was wondering if I am using the correct version of the lib.
I will have another look at the code and put some checks in.
What is libmysqld?
Thanks,
Martijn.
> > > >>>> My configuration is as follows:
>> dmd version 0.111
>> libmsqlclient.so.14
>> Debian Linux unstable kernel 2.6.10

Same here. It was writing out non-existant rows, I think. I ran it on Windows, though, so I got an "access violation" error instead. Are you sure you modified the code to only output as many columns as there are in the result?
I'm not sure about the library. I believe I was using MySQL 4.1.8's DLL and imported lib file, but I can't imagine why it would have problems with any other version. Again, I only use Linux for web servers so I'm not sure on which version libmysqlclient.so.14 corresponds to.
MySQL has released an "embedded" version of MySQL for, essentially, using a stripped down version of MySQL within your program without requiring the installation of the entire server. More information available here:
http://dev.mysql.com/doc/mysql/en/libmysqld.html
-[Unknown]
>> But it works fine ;). In fact, I've done testing with libmysqld in D.
> > > -[Unknown]
> > When I run the example, with modified query string, it does give me the correct results (which is one row in the table). So that seems to work fine. The segmentation fault occurs when the database is closed (I think).
> > Because there are several versions of MySQL (and it's libs) I was wondering if I am using the correct version of the lib.
> > I will have another look at the code and put some checks in.
> > What is libmysqld?
> > Thanks,
> > Martijn.

Unknown W. Brackets wrote:
>> When I run the example, with modified query string, it does give me the correct results (which is one row in the table). So that seems to work fine. The segmentation fault occurs when the database is closed (I think).
I have the following two tests:
void test1()
{
MYSQL mysql;
mysql_init(&mysql);
mysql_close(&mysql);
}
void test2()
{
MYSQL* mysql;
mysql = mysql_init(null);
mysql_close(mysql);
}
test1 is a reduced version of the test program that comes with mysql.d. This one end with a segmentation fault for me.
test2 uses the pointer way, this seems to run ok. Both compiled in the following way:
dmd -c mysql_test.d mysql.d
dmd mysql_test.d mysql.d -L/usr/lib/libmysqlclient.so
Could you verify this?
>>>> Because there are several versions of MySQL (and it's libs) I was wondering if I am using the correct version of the lib.
>>>> I will have another look at the code and put some checks in.
>>>> What is libmysqld?
>>>> Thanks,
>>>> Martijn.

Neither example causes an access violation for me, using libmysql.lib. Both cause one for me using libmysqld.lib, unless I call mysql_server_init() and mysql_server_end() before and after.
For all I know, this is a bug in the Linux version of dmd. But, I'm using a makefile to do my testing, but it boils down to this:
dmd -odlib mysql_test.d lib/mysql.d -L/ma/co lib/libmysql.lib
-[Unknown]
> I have the following two tests:
> > void test1()
> {
> MYSQL mysql;
> > mysql_init(&mysql);
> mysql_close(&mysql);
> }
> > void test2()
> {
> MYSQL* mysql;
> > mysql = mysql_init(null);
> mysql_close(mysql);
> }
> > test1 is a reduced version of the test program that comes with mysql.d. This one end with a segmentation fault for me.
> > test2 uses the pointer way, this seems to run ok. Both compiled in the following way:
> dmd -c mysql_test.d mysql.d
> dmd mysql_test.d mysql.d -L/usr/lib/libmysqlclient.so
> > Could you verify this?

Hello Martijn,
for me the both test programms compiled without any errors.
I will add an example from the test2 programm in the mysql_binding.
Thanks.
In article <ctl3oe$2u8h$1@digitaldaemon.com>, Martijn says...
> >Unknown W. Brackets wrote:
>>> When I run the example, with modified query string, it does give me the correct results (which is one row in the table). So that seems to work fine. The segmentation fault occurs when the database is closed (I think).
> >I have the following two tests:
> >void test1() {
> MYSQL mysql;
> > mysql_init(&mysql);
> mysql_close(&mysql);
>}
> >void test2() {
> MYSQL* mysql;
> > mysql = mysql_init(null);
> mysql_close(mysql);
>}
> >test1 is a reduced version of the test program that comes with mysql.d. This one end with a segmentation fault for me.
> >test2 uses the pointer way, this seems to run ok. Both compiled in the following way: dmd -c mysql_test.d mysql.d dmd mysql_test.d mysql.d -L/usr/lib/libmysqlclient.so
> >Could you verify this?
> >>> >>> Because there are several versions of MySQL (and it's libs) I was wondering if I am using the correct version of the lib.
>>> >>> I will have another look at the code and put some checks in.
>>> >>> What is libmysqld?
>>> >>> Thanks,
>>> >>> Martijn.

Hi nix,
They compile fine, but when I run them the first test gives me a segmentation fault. I am running linux and dmd 0.111.
Unknown W. does not have this problem.
If the the code in test2 is valid code, then I just use it that way. Although I am not keen in using pointers, but I guess when interfacing with a C lib it is unavoidable.
nix wrote:
> Hello Martijn,
> > for me the both test programms compiled without any errors.
> > I will add an example from the test2 programm in the mysql_binding.
> > > Thanks.
> > > In article <ctl3oe$2u8h$1@digitaldaemon.com>, Martijn says...
> >>Unknown W. Brackets wrote:
>>>>>>When I run the example, with modified query string, it does give me the correct results (which is one row in the table). So that seems to work fine. The segmentation fault occurs when the database is closed (I think).
>>>>I have the following two tests:
>>>>void test1() {
>> MYSQL mysql;
>>>> mysql_init(&mysql);
>> mysql_close(&mysql);
>>}
>>>>void test2() {
>> MYSQL* mysql;
>>>> mysql = mysql_init(null);
>> mysql_close(mysql);
>>}
>>>>test1 is a reduced version of the test program that comes with mysql.d. This one end with a segmentation fault for me.
>>>>test2 uses the pointer way, this seems to run ok. Both compiled in the following way: dmd -c mysql_test.d mysql.d dmd mysql_test.d mysql.d -L/usr/lib/libmysqlclient.so
>>>>Could you verify this?
>>>>>>>>Because there are several versions of MySQL (and it's libs) I was wondering if I am using the correct version of the lib.
>>>>>>>>I will have another look at the code and put some checks in.
>>>>>>>>What is libmysqld?
>>>>>>>>Thanks,
>>>>>>>>Martijn.
> > > >