Re: [gnome-db] Libgda Firebird provider patch



On Tue, 2004-07-06 at 16:44 +0000, Jeronimo Albi wrote:
> >>+static GdaDataModel *
> >>+fb_get_tables (GdaConnection *cnc,
> >>+		GdaParameterList *params,
> >>+		gboolean show_views)
> >>+{
> >>+	GList *reclist, *value_list;
> >>+	GdaDataModel *recset = NULL;
> >>+	GdaTransaction *transaction;
> >>+	GdaCommand *command;
> >>+	GdaValue *value;
> >>+	GdaRow *row;
> >>+	GdaParameter *par = NULL;
> >>+	gchar *sql, *sql_cond, *table_name;
> >>+	gint i;
> >>+	gboolean systables = FALSE;
> >>+
> >>+	g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
> >>+        
> >>+	transaction = gda_transaction_new ("temp_transaction");
> >>+	if (gda_connection_begin_transaction (cnc, transaction)) {
> >>
> >>    
> >>
> >why do we need a transaction for reading the tables?
> >
>  Yes Interbase/Firebird is a transactional database, so for almost
> any statement it needs an already started transaction. I know it might
> be annoying sometimes.
> 
ah, ok, seems annoying yeah, when you only want to read the database.

> >> gda_firebird_provider_drop_database (GdaServerProvider *provider,
> >>-				      GdaConnection *cnc,
> >>-				      const gchar *name)
> >>+				     GdaConnection *cnc,
> >>+				     const gchar *name)
> >> {
> >>+	GdaFirebirdConnection *fcnc;
> >>+    
> >>+	g_return_val_if_fail (GDA_IS_FIREBIRD_PROVIDER (provider), FALSE);
> >>+	g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
> >>+
> >>+	fcnc = g_object_get_data (G_OBJECT (cnc), CONNECTION_DATA);
> >>+	if (!fcnc) {
> >>+		gda_connection_add_error_string (cnc, _("Invalid Firebird handle"));
> >>+		return FALSE;
> >>+	}
> >>+    
> >>+	/* Connection must be open for database drop */	
> >>+	if (gda_connection_is_open (cnc)) {
> >>+  		if (isc_drop_database (fcnc->status, &(fcnc->handle))) {
> >>
> >>    
> >>
> >this is wrong, you should not drop the current database, but the database specified
> >by the 'name' argument. So, usually, you'll just use a DROP DATABASE SQL command.
> >  
> >
> Here we've got an important issue :-) !! Whe have 2 methods, one is to use
> API function "isc_drop_database" an the other is actually with a "DROP
> DATABASE" statement. In the first case function need a handle, already
> initialized by making a connection to the database we want to drop. In
> the second case we need to execute a "DROP DATABASE;" statement on
> the current connection. This statement hasnt database name as parameter :-),
> the command drops actual database, unlike other engines that accepts a
> database name as parameter.
> 
oh, then in both cases we need to open the connection to the database
specified in the drop_database provider method. But in no case should
you remove the current database, since it might not be the one the
client app is trying to drop.

So, I'd suggest you use the method you prefer, but you need to make sure
you drop the database specified by the libgda client app.

cheers




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]