After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 604690 - does not build with gda
does not build with gda
Status: RESOLVED FIXED
Product: Gnumeric
Classification: Applications
Component: Database plugin
1.9.x
Other Linux
: Normal normal
: ---
Assigned To: Rodrigo Moya
Jody Goldberg
Depends on:
Blocks:
 
 
Reported: 2009-12-16 09:33 UTC by Götz Waschk
Modified: 2013-08-16 19:45 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Initial patch (5.14 KB, patch)
2010-07-05 05:46 UTC, Jean Bréfort
needs-work Details | Review
Bring GDA plugin back, the initial version (9.65 KB, patch)
2013-07-31 12:57 UTC, Dmitry Matveev
none Details | Review

Description Götz Waschk 2009-12-16 09:33:24 UTC
gnumeric 1.9.17 does not build with libgda 4.1.3:

checking for GDA... yes
checking libgda/control-center/gdaui-login-dialog.h usability... no
checking libgda/control-center/gdaui-login-dialog.h presence... no
checking for libgda/control-center/gdaui-login-dialog.h... no


The control-center headers are not installed by libgda, maybe they are internal?
Comment 1 mdeka 2010-02-26 14:23:24 UTC
(In reply to comment #0)
> gnumeric 1.9.17 does not build with libgda 4.1.3:
> 
> checking for GDA... yes
> checking libgda/control-center/gdaui-login-dialog.h usability... no
> checking libgda/control-center/gdaui-login-dialog.h presence... no
> checking for libgda/control-center/gdaui-login-dialog.h... no
> 
> 
> The control-center headers are not installed by libgda, maybe they are
> internal?

Hi,

I have exactly the same with gnumeric 1.10.0

I tried libgda-4.1.4 and libgda sources taken from git as well but control-center/gdaui-login-dialog.h is never installed.

I tried to copy control-center/gdaui-login-dialog.h into include/libgda-4.0/libgda but it doesnt help.

Regards,
Marcin
Comment 2 Jean Bréfort 2010-04-27 15:54:58 UTC
This code must be rewritten to follow the changes in the gda API. Will need gda-4.2.x.
Comment 3 Jean Bréfort 2010-07-05 05:46:26 UTC
Created attachment 165256 [details] [review]
Initial patch

This makes build work again, but things don't work yet.
Comment 4 Morten Welinder 2010-10-03 00:21:41 UTC
Feel free to commit if you feel this improves the situation.  I am not
able to evaluate this.
Comment 5 Jean Bréfort 2010-10-17 13:29:58 UTC
As things still don't work, it's better to leave thigs as they currently are. Having menus which do not do anything useful would be worse.
Comment 6 Zhihao Yuan 2011-10-16 12:15:13 UTC
The problem is caused by a transitional patch:

http://mail.gnome.org/archives/commits-list/2009-November/msg01194.html

Currently, this plugin does not work. Before we find a way to make use of the new API, please revert this patch to make the old libgnomedb-3.0 work. However, I still hope this plugin show up in next version, since libgda4.x is an obviously better solution.
Comment 7 Jean Bréfort 2011-10-16 13:28:43 UTC
There is no chance that next release can work with libgnomedb-3.0 since they don't use the same gtk+ major version. We need to use a recent libgda version.
Comment 8 Adam Dingle 2013-05-03 12:06:03 UTC
These days the current version of libgda is 5.x.  (5.0.0 was released over a year ago, in October 2011.)  It would be really nice to update Gnumeric to work with this version of GDA.
Comment 9 Dmitry Matveev 2013-07-31 12:57:05 UTC
Created attachment 250543 [details] [review]
Bring GDA plugin back, the initial version
Comment 10 Dmitry Matveev 2013-07-31 12:57:38 UTC
Hello,

I've prepared a patch that brings the libgda support back and makes the GDA
plugin available.


Tested on
---------
1. Debian sid amd64
2. PostgreSQL 9.1.9
3. SQLite 3.7.17


Requirements
------------
1. libgda-5.0 >= 5.0.0
2. libgda-ui-5.0* >= 5.0.0

*Important: my Debian sid doesn't provide the libgda-ui part in the packages,
I've built it manually from git.


Test scenario
-------------
1. Create one or more GDA Data Sources (using gda-control-center-5.0)
2. Open Gnumeric (assuming that the plugin is already built and installed)
3. Select a region, type a sample query, like

   =readdbtable("MyDSN","MyUsername","MyPassword","MyTable")

   or

   =execsql("AnotherDSN",,,"SELECT Something FROM Sometable")

   and press Ctrl+Shift+Enter

4. GDA login dialog appears, confirm the settings and click "Ok"
5. Data should appear on the worksheet.


Good news
---------
It even works with PostgreSQL and SQLite, when you specify initially *correct*
arguments to readdbtable()/execsql() functions. When you query the same DSN with
the same connection arguments from the spreadsheet, it even will not show the
login dialog again, because the plugin caches the connection information.


Bad news
--------
It works ONLY when you specify initially *correct* arguments to readdbtable()
and execsql() functions. It will not work otherwise, and now I will try to
show, why.

During the debugging sessions I've noticed that plugin queries the database
more than once, even if I typed the execsql()/readdbtable() once in the cell.

After analyzing the control flow, I've determined that Gnumeric calls
gnm_expr_top_eval() multiple times (probably for the same cell) after I type
my expression. There some iterations occur in the gnm_cell_eval_content() (in
the src/dependent.c). What actually happens there is magic for me, at least
today. Anyway it has no relation to the changes in the gda plugin (I hope so).

So. If the user typed something (not correct initially) in the arguments of
readdbtable()/execsql() functions, and then corrected the same information in
the GDA login dialog (i.e., specified a correct DSN, supplied correct username
and password), he will not receive his data from the database. The changes
in the login dialog are not reflected in the initial cell expression, so even
after first successfull request gnm_expr_top_eval() will call readdbtable()
/execsql() again with the old, spreadsheet-supplied arguments. The useless (in
this case) login dialog will appear some times, and then nothing will happen.

I really do not know how to solve this situation.

If the DSN and login information are initially correct, the login dialog will
appear once, then this data will be cached, and on the following calls to 
gnm_expr_top_eval()->...readdbtable()/execsql(), it will not appear.

Also, when user types the =readdbtable()/=execsql() expression in a cell, then
presses Ctrl+Shift+Enter and cancels the login dialog, the login dialog will
appear again and again then.


Brief patch overview
--------------------
* configure.ac
  Added checks for newer version of libgda and for libgda-ui.

* plugins/gda/plugin-gda.c

  display_recordset()
    - Fixed a memory leak. When array is created and then an error reported,
      array was not detroyed.

  cnc_key_fill()
    - Added a new function that unifies how the CncKey will look for various
      cases. The purpose is to make hash of ("DSN",NULL,NULL) be equal to hash
      of ("DSN","","").
  
  build_gdadsn_auth_info()
    - Just moved the code to a separate function to make open_connectionm less
      bloated

  query_connection_info()
    - Same as above. All UI functions are used here and only here.

  open_connection()
    - Refactored using the changes described above.

  conn_error()
    - Introduced to remove redundancy. Also the error message is now properly
      formatted (it displayed "%s" in the cell before).

  gnumeric_execSQL()
  gnumeric_readDBTable()
    - Modified these functions to use conn_error()

  GnmFuncDescriptor gdaif_functions[]
    - Modified according to the changes in the API.
Comment 11 Jean Bréfort 2013-07-31 13:57:21 UTC
Dmitry, nice work!
I think that Morten will review the issues you raise. Otherwise, I would say commit.
Comment 12 Morten Welinder 2013-08-01 16:37:11 UTC
I am guessing that what you see has to do with checking validations.

We tentatively poke the new contents into a cell, then check validation
constraints (if any), then undo, and then finally do the full entering
of the new contents into the cell.

Not elegant, and not easy to fix.

Go ahead and commit what you have.  Consider adding yourself to dialog-about.c
Comment 13 Morten Welinder 2013-08-16 19:45:07 UTC
Committed.

This problem has been fixed in our software repository. The fix will go into the next software release. Thank you for your bug report.