[GRASS-SVN] r38208 - grass/trunk/db/db.execute
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Jul 4 12:23:53 EDT 2009
Author: martinl
Date: 2009-07-04 12:23:53 -0400 (Sat, 04 Jul 2009)
New Revision: 38208
Modified:
grass/trunk/db/db.execute/main.c
Log:
db.execute: input required
don't ignore default schema: trac #673
Modified: grass/trunk/db/db.execute/main.c
===================================================================
--- grass/trunk/db/db.execute/main.c 2009-07-04 15:54:46 UTC (rev 38207)
+++ grass/trunk/db/db.execute/main.c 2009-07-04 16:23:53 UTC (rev 38208)
@@ -5,7 +5,7 @@
* AUTHOR(S): Radim Blazek <radim.blazek gmail.com> (original contributor)
* Huidae Cho <grass4u gmail.com>, Glynn Clements <glynn gclements.plus.com>, Hamish Bowman <hamish_nospam yahoo.com>, Markus Neteler <neteler itc.it>, Stephan Holl
* PURPOSE: process one non-select sql statement
- * COPYRIGHT: (C) 2002-2006 by the GRASS Development Team
+ * COPYRIGHT: (C) 2002-2009 by the GRASS Development Team
*
* This program is free software under the GNU General Public
* License (>=v2). Read the file COPYING that comes with GRASS
@@ -39,29 +39,34 @@
dbString stmt;
dbDriver *driver;
dbHandle handle;
+ const char *schema;
int ret;
FILE *fd;
- int error = 0;
+ int error;
+ error = 0;
+
parse_command_line(argc, argv);
- if (parms.input) {
+ if (strcmp(parms.input, "-")) {
fd = fopen(parms.input, "r");
if (fd == NULL) {
perror(parms.input);
exit(EXIT_FAILURE);
}
}
- else
+ else {
fd = stdin;
-
+ }
+
driver = db_start_driver(parms.driver);
if (driver == NULL) {
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, NULL);
+ db_set_handle(&handle, parms.database, schema);
if (db_open_database(driver, &handle) != DB_OK)
G_fatal_error(_("Unable to open database <%s>"), parms.database);
@@ -109,8 +114,8 @@
module->description = _("Executes any SQL statement.");
input = G_define_standard_option(G_OPT_F_INPUT);
- input->required = NO;
- input->description = _("Name of file containing SQL statements");
+ input->label = _("Name of file containing SQL statements");
+ input->description = _("'-' to read from standard input");
driver = G_define_standard_option(G_OPT_DB_DRIVER);
driver->options = db_list_drivers();
More information about the grass-commit
mailing list