GDA_CONNECTION_OPTIONS_THREAD_SAFE issue.

View: New views
5 Messages — Rating Filter:   Alert me  

GDA_CONNECTION_OPTIONS_THREAD_SAFE issue.

by Bas Driessen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Vivien,

You recently introduced the GDA_CONNECTION_OPTIONS_THREAD_SAFE option. There is a problem with this that if set and a partial meta store update is performed, the meta store is not updated. If using any of the other GDA_CONNECTION_OPTIONS all works fine.

I have attached 2 small c programs to re-produce this issue. The database provider is MySQL, my (test) database is called  'stock' and the DSN is 'mystock'

-1 rm /tmp/mysql_meta.db
-2 in MySQL: drop table xPartsUC;
-3 Run mysql_full (source attached)
-4 in MySQL: CREATE TABLE xPartsUC (Part_ID varchar(5) PRIMARY KEY, Description varchar(30));
-5 Run mysql_partial (source attached)
-6 sqlite3 /tmp/mysql_meta.db  then run: select * from _tables where table_name = '"xPartsUC"';
-7 nothing there. Run mysql_full and the entry is there.

On a side note, how do I pass 2 or more GDA_CONNECTION_OPTIONS to gda_connection_open_from_dsn() ?

ie, if I want to set GDA_CONNECTION_OPTIONS_THREAD_SAFE and the GDA_CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE option?


The following appears to work, but there must be a better way.

GdaConnectionOptions options = GDA_CONNECTION_OPTIONS_THREADSAFE;
options = (GdaConnectionOptions)(options + GDA_CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE);
gda_connection_open_from_dsn(dsn, NULL, options, NULL);

Thanks,
Bas.


[Makefile]

CFLAGS = -Wall -g -DGDA_DISABLE_DEPRECATED `pkg-config --cflags libgda-4.0`
LDFLAGS = `pkg-config --libs libgda-4.0`

all: mysql_full mysql_partial

mysql_full: mysql_full.c
        $(CC) -o mysql_full mysql_full.c $(CFLAGS) $(LDFLAGS)

mysql_partial: mysql_partial.c
        $(CC) -o mysql_partial mysql_partial.c $(CFLAGS) $(LDFLAGS)

clean:
        rm -f *~
        rm -f *.o
        rm -f mysql_full
        rm -f mysql_partial


[mysql_full.c]

#include <libgda/libgda.h>

int
main (int argc, char *argv[])
{
        GdaConnection* connection;
        GError* error = NULL;
        GdaMetaStore *store;

        gda_init();
        error = NULL;


        /* open connection */
        printf("Start.\n");
        printf("Open connection.\n");
 //       connection = gda_connection_open_from_dsn ("mystock", NULL, GDA_CONNECTION_OPTIONS_NONE, &error);
        connection = gda_connection_open_from_dsn ("mystock", NULL, GDA_CONNECTION_OPTIONS_THREAD_SAFE, &error);
  //      connection = gda_connection_open_from_dsn ("mystock", NULL, GDA_CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE, &error);
        if (!connection)
        {
                fprintf (stderr, "%s\n", error->message);
                return -1;
        }

        /* Open Meta Store */
        printf("Open Meta Store.\n");
        store = gda_meta_store_new_with_file("/tmp/mysql_meta.db");
        g_object_set(G_OBJECT(connection), "meta-store", store, NULL);
        if (!store)
        {
                printf("Can not open store.\n");
                return -1;
        }

        /* Build Complete store */
        printf("Build complete store.\n");
        if (!gda_connection_update_meta_store(connection, NULL, &error))
        {
                fprintf (stderr, "%s\n", error->message);
                return -1;
        }

        /* The End */
        printf("End.\n");
        return 0;
}


[mysql_partial.c]

#include <libgda/libgda.h>

int
main (int argc, char *argv[])
{
        GdaConnection* connection;
        GError* error = NULL;
        GdaMetaStore *store;
        gchar *tableName;
        GdaMetaContext mcontext = {"_tables", 1, NULL, NULL};

        gda_init();
        error = NULL;


        /* open connection */
        printf("Start.\n");
        printf("Open connection.\n");
        connection = gda_connection_open_from_dsn ("mystock", NULL, GDA_CONNECTION_OPTIONS_THREAD_SAFE, &error);
//        connection = gda_connection_open_from_dsn ("mystock", NULL, GDA_CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE, &error);
//        connection = gda_connection_open_from_dsn ("mystock", NULL, GDA_CONNECTION_OPTIONS_NONE, &error);
        if (!connection)
        {
                fprintf (stderr, "%s\n", error->message);
                return -1;
        }

        /* Open Meta Store */
        printf("Open Meta Store.\n");
        store = gda_meta_store_new_with_file("/tmp/mysql_meta.db");
        g_object_set(G_OBJECT(connection), "meta-store", store, NULL);
        if (!store)
        {
                printf("Can not open store.\n");
                return -1;
        }

        /* Update store for just a SINGLE table */
        printf("Update Meta Store with SINGLE table.\n");
        mcontext.column_names = g_new (gchar *, 1);
        mcontext.column_names[0] = "table_name";
        mcontext.column_values = g_new (GValue *, 1);
        tableName = gda_sql_identifier_quote("xPartsUC", connection, NULL, TRUE, FALSE);
        g_value_set_string ((mcontext.column_values[0] = gda_value_new(G_TYPE_STRING)), tableName);
        g_free(tableName);
        if (!gda_connection_update_meta_store(connection, &mcontext, &error))
        {
                fprintf (stderr, "%s\n", error->message);
                return -1;
        }
       
        /* Clean up */
        gda_value_free (mcontext.column_values[0]);
       
        /* The End */
        printf("End.\n");
        return 0;
}


_______________________________________________
gnome-db-list mailing list
gnome-db-list@...
http://mail.gnome.org/mailman/listinfo/gnome-db-list

Re: GDA_CONNECTION_OPTIONS_THREAD_SAFE issue.

by Vivien Malerba :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



2009/8/14 Bas Driessen <bas.driessen@...>
Hi Vivien,

You recently introduced the GDA_CONNECTION_OPTIONS_THREAD_SAFE option. There is a problem with this that if set and a partial meta store update is performed, the meta store is not updated. If using any of the other GDA_CONNECTION_OPTIONS all works fine.

I have attached 2 small c programs to re-produce this issue. The database provider is MySQL, my (test) database is called  'stock' and the DSN is 'mystock'

-1 rm /tmp/mysql_meta.db
-2 in MySQL: drop table xPartsUC;
-3 Run mysql_full (source attached)
-4 in MySQL: CREATE TABLE xPartsUC (Part_ID varchar(5) PRIMARY KEY, Description varchar(30));
-5 Run mysql_partial (source attached)
-6 sqlite3 /tmp/mysql_meta.db  then run: select * from _tables where table_name = '"xPartsUC"';
-7 nothing there. Run mysql_full and the entry is there.

The cause of this problem was that I had forgotten to implement a virtual method. This should now be fixed in the master branch, can you check?


On a side note, how do I pass 2 or more GDA_CONNECTION_OPTIONS to gda_connection_open_from_dsn() ?

ie, if I want to set GDA_CONNECTION_OPTIONS_THREAD_SAFE and the GDA_CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE option?

simply use the logical OR operator:
..., GDA_CONNECTION_OPTIONS_THREAD_SAFE | GDA_CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE,...


Regards,

Vivien



_______________________________________________
gnome-db-list mailing list
gnome-db-list@...
http://mail.gnome.org/mailman/listinfo/gnome-db-list

Re: GDA_CONNECTION_OPTIONS_THREAD_SAFE issue.

by Bas Driessen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, 2009-08-25 at 19:33 +0200, Vivien Malerba wrote:


2009/8/14 Bas Driessen <bas.driessen@...>
Hi Vivien,

You recently introduced the GDA_CONNECTION_OPTIONS_THREAD_SAFE option. There is a problem with this that if set and a partial meta store update is performed, the meta store is not updated. If using any of the other GDA_CONNECTION_OPTIONS all works fine.

I have attached 2 small c programs to re-produce this issue. The database provider is MySQL, my (test) database is called  'stock' and the DSN is 'mystock'

-1 rm /tmp/mysql_meta.db
-2 in MySQL: drop table xPartsUC;
-3 Run mysql_full (source attached)
-4 in MySQL: CREATE TABLE xPartsUC (Part_ID varchar(5) PRIMARY KEY, Description varchar(30));
-5 Run mysql_partial (source attached)
-6 sqlite3 /tmp/mysql_meta.db  then run: select * from _tables where table_name = '"xPartsUC"';
-7 nothing there. Run mysql_full and the entry is there.

The cause of this problem was that I had forgotten to implement a virtual method. This should now be fixed in the master branch, can you check?


Initial testing shows that this is working OK now. Will hit it a bit harder over the next couple of days, but it looks like this bug is fixed.

Thanks for that Vivien!

Bas.


_______________________________________________
gnome-db-list mailing list
gnome-db-list@...
http://mail.gnome.org/mailman/listinfo/gnome-db-list

Re: GDA_CONNECTION_OPTIONS_THREAD_SAFE issue.

by Vivien Malerba :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/8/26 Bas Driessen <bas.driessen@...>:

> On Tue, 2009-08-25 at 19:33 +0200, Vivien Malerba wrote:
>
>
> 2009/8/14 Bas Driessen <bas.driessen@...>
>
> Hi Vivien,
>
> You recently introduced the GDA_CONNECTION_OPTIONS_THREAD_SAFE option. There
> is a problem with this that if set and a partial meta store update is
> performed, the meta store is not updated. If using any of the other
> GDA_CONNECTION_OPTIONS all works fine.
>
> I have attached 2 small c programs to re-produce this issue. The database
> provider is MySQL, my (test) database is called  'stock' and the DSN is
> 'mystock'
>
> -1 rm /tmp/mysql_meta.db
> -2 in MySQL: drop table xPartsUC;
> -3 Run mysql_full (source attached)
> -4 in MySQL: CREATE TABLE xPartsUC (Part_ID varchar(5) PRIMARY KEY,
> Description varchar(30));
> -5 Run mysql_partial (source attached)
> -6 sqlite3 /tmp/mysql_meta.db  then run: select * from _tables where
> table_name = '"xPartsUC"';
> -7 nothing there. Run mysql_full and the entry is there.
>
> The cause of this problem was that I had forgotten to implement a virtual
> method. This should now be fixed in the master branch, can you check?
>
>
> Initial testing shows that this is working OK now. Will hit it a bit harder
> over the next couple of days, but it looks like this bug is fixed.
>

Ok, great.

BTW, next time you find a bug it'd be better if you could file a bug
report in bugzilla at http://bugzilla.gnome.org/, as it's then easier
to follow its correction and keep an history than in a mail.

Regards,

Vivien
_______________________________________________
gnome-db-list mailing list
gnome-db-list@...
http://mail.gnome.org/mailman/listinfo/gnome-db-list

Re: GDA_CONNECTION_OPTIONS_THREAD_SAFE issue.

by Bas Driessen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, 2009-08-26 at 10:26 +0200, Vivien Malerba wrote:
2009/8/26 Bas Driessen <bas.driessen@...>:
> On Tue, 2009-08-25 at 19:33 +0200, Vivien Malerba wrote:
>
>
> 2009/8/14 Bas Driessen <bas.driessen@...>
>
> Hi Vivien,
>
> You recently introduced the GDA_CONNECTION_OPTIONS_THREAD_SAFE option. There
> is a problem with this that if set and a partial meta store update is
> performed, the meta store is not updated. If using any of the other
> GDA_CONNECTION_OPTIONS all works fine.
>
> I have attached 2 small c programs to re-produce this issue. The database
> provider is MySQL, my (test) database is called  'stock' and the DSN is
> 'mystock'
>
> -1 rm /tmp/mysql_meta.db
> -2 in MySQL: drop table xPartsUC;
> -3 Run mysql_full (source attached)
> -4 in MySQL: CREATE TABLE xPartsUC (Part_ID varchar(5) PRIMARY KEY,
> Description varchar(30));
> -5 Run mysql_partial (source attached)
> -6 sqlite3 /tmp/mysql_meta.db  then run: select * from _tables where
> table_name = '"xPartsUC"';
> -7 nothing there. Run mysql_full and the entry is there.
>
> The cause of this problem was that I had forgotten to implement a virtual
> method. This should now be fixed in the master branch, can you check?
>
>
> Initial testing shows that this is working OK now. Will hit it a bit harder
> over the next couple of days, but it looks like this bug is fixed.
>

Ok, great.

BTW, next time you find a bug it'd be better if you could file a bug
report in bugzilla at http://bugzilla.gnome.org/, as it's then easier
to follow its correction and keep an history than in a mail.

No problem Vivien. Was not sure if bugs in bugzilla were actually followed up, therefore the mailing list requests. Will channel them through bugzilla in the future as requested.

Bas.
_______________________________________________
gnome-db-list mailing list
gnome-db-list@...
http://mail.gnome.org/mailman/listinfo/gnome-db-list