[GRASS-SVN] r38211 - in grass/trunk: db/db.connect db/db.execute include lib/gis

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Jul 4 12:49:04 EDT 2009


Author: martinl
Date: 2009-07-04 12:49:04 -0400 (Sat, 04 Jul 2009)
New Revision: 38211

Modified:
   grass/trunk/db/db.connect/main.c
   grass/trunk/db/db.execute/main.c
   grass/trunk/include/gis.h
   grass/trunk/lib/gis/parser.c
Log:
G_OPT_DB_SCHEMA added to gislib
db.execute: 'schema' paramater added


Modified: grass/trunk/db/db.connect/main.c
===================================================================
--- grass/trunk/db/db.connect/main.c	2009-07-04 16:47:31 UTC (rev 38210)
+++ grass/trunk/db/db.connect/main.c	2009-07-04 16:49:04 UTC (rev 38211)
@@ -69,15 +69,8 @@
     database->answer = (char *) db_get_default_database_name();
     database->guisection = _("Set");
 
-    schema = G_define_option();
-    schema->key = "schema";
-    schema->type = TYPE_STRING;
-    schema->required = NO;
-    schema->multiple = NO;
+    schema = G_define_standard_option(G_OPT_DB_SCHEMA);
     schema->answer = (char *) db_get_default_schema_name();
-    schema->label = _("Database schema");
-    schema->description = _("Do not use this option if schemas "
-			    "are not supported by driver/database server");
     schema->guisection = _("Set");
 
     group = G_define_option();

Modified: grass/trunk/db/db.execute/main.c
===================================================================
--- grass/trunk/db/db.execute/main.c	2009-07-04 16:47:31 UTC (rev 38210)
+++ grass/trunk/db/db.execute/main.c	2009-07-04 16:49:04 UTC (rev 38211)
@@ -23,7 +23,7 @@
 
 struct
 {
-    char *driver, *database, *input;
+    const char *driver, *database, *schema, *input;
     int i;
 } parms;
 
@@ -39,7 +39,6 @@
     dbString stmt;
     dbDriver *driver;
     dbHandle handle;
-    const char *schema;
     int ret;
     FILE *fd;
     int error;
@@ -64,9 +63,8 @@
 	G_fatal_error(_("Unable to start driver <%s>"), parms.driver);
     }
 
-    schema = db_get_default_schema_name();
     db_init_handle(&handle);
-    db_set_handle(&handle, parms.database, schema);
+    db_set_handle(&handle, parms.database, parms.schema);
     if (db_open_database(driver, &handle) != DB_OK)
 	G_fatal_error(_("Unable to open database <%s>"), parms.database);
 
@@ -98,10 +96,10 @@
 
 static void parse_command_line(int argc, char **argv)
 {
-    struct Option *driver, *database, *input;
+    struct Option *driver, *database, *schema, *input;
     struct Flag *i;
     struct GModule *module;
-    const char *drv, *db;
+    const char *drv, *db, *schema_name;
 
     /* Initialize the GIS calls */
     G_gisinit(argv[0]);
@@ -126,6 +124,11 @@
     if ((db = db_get_default_database_name()))
 	database->answer = (char *) db;
 
+    schema = G_define_standard_option(G_OPT_DB_SCHEMA);
+    if ((schema_name = db_get_default_schema_name()))
+	schema->answer = (char *) schema_name;
+    schema->guisection = _("Set");
+
     i = G_define_flag();
     i->key = 'i';
     i->description = _("Ignore SQL errors and continue");
@@ -135,6 +138,7 @@
 
     parms.driver = driver->answer;
     parms.database = database->answer;
+    parms.schema = schema->answer;
     parms.input = input->answer;
     parms.i = i->answer;
 }

Modified: grass/trunk/include/gis.h
===================================================================
--- grass/trunk/include/gis.h	2009-07-04 16:47:31 UTC (rev 38210)
+++ grass/trunk/include/gis.h	2009-07-04 16:49:04 UTC (rev 38211)
@@ -152,6 +152,7 @@
     G_OPT_DB_TABLE,		/* table name */
     G_OPT_DB_DRIVER,		/* driver name */
     G_OPT_DB_DATABASE,		/* database name */
+    G_OPT_DB_SCHEMA,            /* database schema */
     G_OPT_DB_COLUMN,		/* one attr column */
     G_OPT_DB_COLUMNS,		/* one or more attr columns */
 

Modified: grass/trunk/lib/gis/parser.c
===================================================================
--- grass/trunk/lib/gis/parser.c	2009-07-04 16:47:31 UTC (rev 38210)
+++ grass/trunk/lib/gis/parser.c	2009-07-04 16:49:04 UTC (rev 38211)
@@ -309,6 +309,7 @@
  *   - G_OPT_DB_TABLE
  *   - G_OPT_DB_DRIVER
  *   - G_OPT_DB_DATABASE
+ *   - G_OPT_DB_SCHEMA
  *
  *  - imagery:
  *   - G_OPT_I_GROUP
@@ -390,6 +391,16 @@
 	Opt->description = _("Database name");
 	Opt->gisprompt = "old_dbname,dbname,dbname";
 	break;
+    case G_OPT_DB_SCHEMA:
+	Opt->key = "schema";
+	Opt->type = TYPE_STRING;
+	Opt->key_desc = "name";
+	Opt->required = NO;
+	Opt->multiple = NO;
+	Opt->label = _("Database schema");
+	Opt->description = _("Do not use this option if schemas "
+			     "are not supported by driver/database server");
+	break;
     case G_OPT_DB_COLUMN:
 	Opt->key = "column";
 	Opt->type = TYPE_STRING;
@@ -406,7 +417,7 @@
 	Opt->required = NO;
 	Opt->multiple = YES;
 	Opt->description = _("Name of attribute column(s)");
-	Opt->gisprompt = "old_table,table,dbcolumn";
+	Opt->gisprompt = "old_dbcolumn,dbcolumn,dbcolumn";
 	break;
 
 	/* imagery group */



More information about the grass-commit mailing list