[GRASS-SVN] r57274 - in grass/trunk/db: db.columns db.copy db.select
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Jul 25 11:44:07 PDT 2013
Author: mmetz
Date: 2013-07-25 11:44:06 -0700 (Thu, 25 Jul 2013)
New Revision: 57274
Modified:
grass/trunk/db/db.columns/main.c
grass/trunk/db/db.copy/main.c
grass/trunk/db/db.select/main.c
Log:
db.*: add test if table exists where appropriate
Modified: grass/trunk/db/db.columns/main.c
===================================================================
--- grass/trunk/db/db.columns/main.c 2013-07-25 18:37:56 UTC (rev 57273)
+++ grass/trunk/db/db.columns/main.c 2013-07-25 18:44:06 UTC (rev 57274)
@@ -39,6 +39,12 @@
parse_command_line(argc, argv);
+ if (!db_table_exists(parms.driver, parms.database, parms.table)) {
+ G_warning(_("Table <%s> not found in database <%s> using driver <%s>"),
+ parms.table, parms.database, parms.driver);
+ exit(EXIT_FAILURE);
+ }
+
driver = db_start_driver(parms.driver);
if (driver == NULL)
G_fatal_error(_("Unable to start driver <%s>"), parms.driver);
Modified: grass/trunk/db/db.copy/main.c
===================================================================
--- grass/trunk/db/db.copy/main.c 2013-07-25 18:37:56 UTC (rev 57273)
+++ grass/trunk/db/db.copy/main.c 2013-07-25 18:44:06 UTC (rev 57274)
@@ -95,6 +95,14 @@
if (select->answer)
G_fatal_error(_("Cannot combine 'from_table' and 'select' options"));
+ if (!db_table_exists(from_driver->answer, from_database->answer,
+ from_table->answer)) {
+ G_warning(_("Table <%s> not found in database <%s> using driver <%s>"),
+ from_table->answer, from_database->answer,
+ from_driver->answer);
+ exit(EXIT_FAILURE);
+ }
+
if (where->answer) {
ret =
db_copy_table_where(from_driver->answer,
Modified: grass/trunk/db/db.select/main.c
===================================================================
--- grass/trunk/db/db.select/main.c 2013-07-25 18:37:56 UTC (rev 57273)
+++ grass/trunk/db/db.select/main.c 2013-07-25 18:44:06 UTC (rev 57274)
@@ -48,6 +48,14 @@
parse_command_line(argc, argv);
+ if (parms.table) {
+ if (!db_table_exists(parms.driver, parms.database, parms.table)) {
+ G_warning(_("Table <%s> not found in database <%s> using driver <%s>"),
+ parms.table, parms.database, parms.driver);
+ exit(EXIT_FAILURE);
+ }
+ }
+
/* read from file or stdin ? */
if (parms.input && strcmp(parms.input, "-") != 0) {
fd = fopen(parms.input, "r");
@@ -92,7 +100,7 @@
}
}
- if(parms.test_only)
+ if (parms.test_only)
G_verbose_message(_("Test %s."), stat ? _("failed") : _("succeeded"));
db_close_database(driver);
More information about the grass-commit
mailing list