[GRASS5] [winGRASS] db driver problem?

Hi list,

Is no body interested in this issue just because the number of
winGRASS users is small? :slight_smile:

Huidae Cho

---------- Forwarded message ----------
From: Glynn Clements <glynn@gclements.plus.com>
Date: Sun, 24 Oct 2004 02:15:59 +0100
Subject: Re: [winGRASS] db driver problem?
To: Huidae Cho <grass4u@gmail.com>
Cc: 2win <wingrass@grass.itc.it>

Huidae Cho wrote:

I compiled grass 5.7 but I couldn't use any db driver. For example,
dbf.exe calls db_driver_* functions in libgrass_dbstubs.dll which do
nothing. But after installing pre-compiled 5.7, it worked! what's a
problem?

The way that the stub functions work makes certain assumptions about
the way in which the linker resolves multiply-defined symbols.

The drivers all depend upon libgrass_dbmidriver, which in turn
requires all of the db_driver_* symbols. libgrass_dbstubs provides
dummy versions of all of those functions, while individual drivers
provide real versions of some of them.

The intention is that libgrass_dbmidriver will use the real
implementation from the executable if it exists, and the dummy
implementation from libgrass_dbstubs if it doesn't. However, it's
possible that, depending upon the behaviour of the linker, the dummy
versions may override the actual implementation.

In fact, on Windows, I would expect this to happen; I'm not sure how
the pre-compiled version managed to avoid this issue.

A more robust solution would be for the stubs to have different names,
and for each driver to provide every symbol itself. For unimplemented
functions, the driver would have to include a wrapper around the stub
function, e.g.:

        int db_driver_begin_transaction(void)
        {
            return db_stub_begin_transaction();
        }

Relying upon the linker to get the priorities right saves the effort
of writing the wrappers, but it's rather fragile.

--
Glynn Clements <glynn.clements@virgin.net>

Huidae Cho wrote:

Is no body interested in this issue just because the number of
winGRASS users is small? :slight_smile:

More accurately, because the number of winGRASS *developers* is small.

AFAICT, most of the winGRASS users aren't developers, and most of the
GRASS developers don't use Windows.

--
Glynn Clements <glynn@gclements.plus.com>

Yes, you're right.

I spent some time to figure out how this can be solved and found that
I cannot use different function names for stub things because
libgrass_dbmidriver.dll cannot be built with undefined functions
(sould be defined either in the dbstub library or in real drivers).

So I tested some tricky way with success and changed db drivers,
please test new implementation.

Affected directories:
   grass51/lib/db/stubs
   grass51/lib/db/dbmi_driver
   grass51/db/drivers

Thank you.
Huidae Cho

On Wed, 10 Nov 2004 17:36:11 +0000, Glynn Clements
<glynn@gclements.plus.com> wrote:

Huidae Cho wrote:

> Is no body interested in this issue just because the number of
> winGRASS users is small? :slight_smile:

More accurately, because the number of winGRASS *developers* is small.

AFAICT, most of the winGRASS users aren't developers, and most of the
GRASS developers don't use Windows.

--

Glynn Clements <glynn@gclements.plus.com>

So I tested some tricky way with success and changed db drivers,
please test new implementation.

Affected directories:
   grass51/lib/db/stubs
   grass51/lib/db/dbmi_driver
   grass51/db/drivers

be sure to update the Doxygen comments while you're at it.....

Hamish

On Thu, 11 Nov 2004 17:52:43 +1300, Hamish <hamish_nospam@yahoo.com> wrote:

> So I tested some tricky way with success and changed db drivers,
> please test new implementation.
>
> Affected directories:
> grass51/lib/db/stubs
> grass51/lib/db/dbmi_driver
> grass51/db/drivers

be sure to update the Doxygen comments while you're at it.....

Sorry for my ignorance. Which file do you mean?

Huidae Cho

Hamish

On Wed, 10 Nov 2004 23:04:38 -0600
Huidae Cho <grass4u@gmail.com> wrote:

On Thu, 11 Nov 2004 17:52:43 +1300, Hamish <hamish_nospam@yahoo.com> wrote:
> > So I tested some tricky way with success and changed db drivers,
> > please test new implementation.
> >
> > Affected directories:
> > grass51/lib/db/stubs
> > grass51/lib/db/dbmi_driver
> > grass51/db/drivers
>
>
> be sure to update the Doxygen comments while you're at it.....

Sorry for my ignorance. Which file do you mean?

e.g.:

http://freegis.org/cgi-bin/viewcvs.cgi/grass51/lib/db/stubs/add_col.c?rev=2.1&content-type=text/vnd.viewcvs-markup

comments get turned into the Programmer's manual, so if the function name
changes the comment should as well.

Hamish

(leave in the _nospam)

On Thu, 11 Nov 2004, Hamish wrote:

e.g.:

http://freegis.org/cgi-bin/viewcvs.cgi/grass51/lib/db/stubs/add_col.c?rev=2.1&content-type=text/vnd.viewcvs-markup

comments get turned into the Programmer's manual, so if the function name
changes the comment should as well.

As far as I understand it Doxygen picks up the function name automatically and it is wrong to include it in the comment. (As we have seen here it is only something else to update and will quickly get out of date.) This is how I did the Doxygen comments in the gproj library. See some examples in
http://freegis.org/cgi-bin/viewcvs.cgi/grass51/lib/proj/do_proj.c?rev=1.1&content-type=text/vnd.viewcvs-markup

This doesn't seem to be currently included in the programmer's manual though so I can't really test it. Plus I didn't finish doxygenising all the source files. I think the "/** and start each line with a *" syntax is prettier to look at though and more in keeping with the style tradtionally used for function descriptions in the old old parts of GRASS (GIS lib etc.) than /*! and no specific start to each line. It also makes the function descriptions stand out better in the source code.

Anyway that's just a little suggestion for how I think the Doxygenisation could be made even better :slight_smile:

Paul