[GRASS-SVN] r73038 - grass/branches/releasebranch_7_4/lib/db/dbmi_base
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Aug 3 14:15:05 PDT 2018
Author: mmetz
Date: 2018-08-03 14:15:04 -0700 (Fri, 03 Aug 2018)
New Revision: 73038
Modified:
grass/branches/releasebranch_7_4/lib/db/dbmi_base/connect.c
grass/branches/releasebranch_7_4/lib/db/dbmi_base/default_name.c
Log:
lib/dbmibase: fix get/set connection parameters, clarify default and current parameters (backport trunk r72941)
Modified: grass/branches/releasebranch_7_4/lib/db/dbmi_base/connect.c
===================================================================
--- grass/branches/releasebranch_7_4/lib/db/dbmi_base/connect.c 2018-08-03 18:49:03 UTC (rev 73037)
+++ grass/branches/releasebranch_7_4/lib/db/dbmi_base/connect.c 2018-08-03 21:15:04 UTC (rev 73038)
@@ -29,15 +29,19 @@
{
/* TODO: add checks and return DB_* error code if needed */
+ G_unsetenv2("DB_DRIVER", G_VAR_MAPSET);
if (connection->driverName)
G_setenv2("DB_DRIVER", connection->driverName, G_VAR_MAPSET);
+ G_unsetenv2("DB_DATABASE", G_VAR_MAPSET);
if (connection->databaseName)
G_setenv2("DB_DATABASE", connection->databaseName, G_VAR_MAPSET);
+ G_unsetenv2("DB_SCHEMA", G_VAR_MAPSET);
if (connection->schemaName)
G_setenv2("DB_SCHEMA", connection->schemaName, G_VAR_MAPSET);
+ G_unsetenv2("DB_GROUP", G_VAR_MAPSET);
if (connection->group)
G_setenv2("DB_GROUP", connection->group, G_VAR_MAPSET);
@@ -59,7 +63,7 @@
}
/*!
- \brief Get default DB connection settings
+ \brief Get default DB connection settings for the current mapset
\param[out] connection pointer to dbConnection to be modified
Modified: grass/branches/releasebranch_7_4/lib/db/dbmi_base/default_name.c
===================================================================
--- grass/branches/releasebranch_7_4/lib/db/dbmi_base/default_name.c 2018-08-03 18:49:03 UTC (rev 73037)
+++ grass/branches/releasebranch_7_4/lib/db/dbmi_base/default_name.c 2018-08-03 21:15:04 UTC (rev 73038)
@@ -19,9 +19,9 @@
#include <grass/glocale.h>
/*!
- \brief Get default driver name
+ \brief Get driver name from current DB connection settings
- \return pointer to default driver name
+ \return pointer to driver name
\return NULL if not set
*/
const char *db_get_default_driver_name(void)
@@ -35,9 +35,9 @@
}
/*!
- \brief Get default database name
+ \brief Get database name from current DB connection settings
- \return pointer to default database name
+ \return pointer to database name
\return NULL if not set
*/
const char *db_get_default_database_name(void)
@@ -51,9 +51,9 @@
}
/*!
- \brief Get default schema name
+ \brief Get schema name from current DB connection settings
- \return pointer to default schema name
+ \return pointer to schema name
\return NULL if not set
*/
const char *db_get_default_schema_name(void)
@@ -67,9 +67,9 @@
}
/*!
- \brief Get default group name
+ \brief Get group name from current DB connection settings
- \return pointer to default group name
+ \return pointer to group name
\return NULL if not set
*/
const char *db_get_default_group_name(void)
@@ -85,6 +85,9 @@
/*!
\brief Sets up database connection settings using GRASS default from dbmi.h
+ This function ignores current DB connection settings and uses GRASS
+ default settings instead.
+
\todo DB_OK on success, DB_* error code on fail
\return returns DB_OK
@@ -97,8 +100,8 @@
G_debug(1,
"Creating new default DB params with db_set_default_connection()");
- /* is this really needed ? */
- db_get_connection(&connection);
+ /* do not use default DB connection settings for the current mapset */
+ G_zero(&connection, sizeof(dbConnection));
if (strcmp(DB_DEFAULT_DRIVER, "dbf") == 0) {
/* Set default values and create dbf db dir */
More information about the grass-commit
mailing list