[GRASS-SVN] r65329 - grass/trunk/db/drivers/sqlite
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue May 26 09:45:48 PDT 2015
Author: martinl
Date: 2015-05-26 09:45:48 -0700 (Tue, 26 May 2015)
New Revision: 65329
Added:
grass/trunk/db/drivers/sqlite/table.c
Modified:
grass/trunk/db/drivers/sqlite/dbdriver.h
Log:
sqlite driver: implement db__driver_drop_table()
Modified: grass/trunk/db/drivers/sqlite/dbdriver.h
===================================================================
--- grass/trunk/db/drivers/sqlite/dbdriver.h 2015-05-26 13:19:24 UTC (rev 65328)
+++ grass/trunk/db/drivers/sqlite/dbdriver.h 2015-05-26 16:45:48 UTC (rev 65329)
@@ -8,6 +8,8 @@
int db__driver_close_cursor();
int db__driver_open_database();
int db__driver_close_database();
+int db__driver_create_database();
+int db__driver_delete_database();
int db__driver_describe_table();
int db__driver_init();
int db__driver_finish();
@@ -17,14 +19,18 @@
int db__driver_fetch();
int db__driver_get_num_rows();
int db__driver_create_index();
+int db__driver_list_databases();
int db__driver_list_tables();
int db__driver_open_select_cursor();
+int db__driver_drop_table();
#define init_dbdriver() do{\
db_driver_create_table = db__driver_create_table;\
db_driver_close_cursor = db__driver_close_cursor;\
db_driver_open_database = db__driver_open_database;\
db_driver_close_database = db__driver_close_database;\
+db_driver_create_database = db__driver_create_database;\
+db_driver_delete_database = db__driver_delete_database;\
db_driver_describe_table = db__driver_describe_table;\
db_driver_init = db__driver_init;\
db_driver_finish = db__driver_finish;\
@@ -34,8 +40,10 @@
db_driver_fetch = db__driver_fetch;\
db_driver_get_num_rows = db__driver_get_num_rows;\
db_driver_create_index = db__driver_create_index;\
+db_driver_list_databases = db__driver_list_databases;\
db_driver_list_tables = db__driver_list_tables;\
db_driver_open_select_cursor = db__driver_open_select_cursor;\
+db_driver_drop_table = db__driver_drop_table;\
}while(0)
#endif
Added: grass/trunk/db/drivers/sqlite/table.c
===================================================================
--- grass/trunk/db/drivers/sqlite/table.c (rev 0)
+++ grass/trunk/db/drivers/sqlite/table.c 2015-05-26 16:45:48 UTC (rev 65329)
@@ -0,0 +1,44 @@
+/*!
+ * \file table.c
+ *
+ * \brief Low level drop table function.
+ *
+ * This program is free software under the GNU General Public License
+ * (>=v2). Read the file COPYING that comes with GRASS for details.
+ *
+ * \author Martin Landa <landa.martin gmail.com>
+ *
+ * \date 2015
+ */
+
+#include <grass/gis.h>
+#include <grass/dbmi.h>
+#include <grass/glocale.h>
+#include "globals.h"
+#include "proto.h"
+
+/*!
+ * \brief Low level driver drop table from database.
+ *
+ * \param name table name to drop
+ * \return DB_FAILED on error; DB_OK on success
+ */
+int db__driver_drop_table(dbString *name)
+{
+ int ret;
+ char cmd[DB_SQL_MAX];
+
+ sprintf(cmd, "DROP TABLE %s", db_get_string(name));
+
+ ret = sqlite3_exec(sqlite, cmd, NULL, NULL, NULL);
+
+ if (ret != SQLITE_OK) {
+ db_d_append_error("%s\n%s",
+ _("Error in sqlite3_exec():"),
+ (char *)sqlite3_errmsg(sqlite));
+ db_d_report_error();
+ return DB_FAILED;
+ }
+
+ return DB_OK;
+}
Property changes on: grass/trunk/db/drivers/sqlite/table.c
___________________________________________________________________
Added: svn:mime-type
+ text/x-csrc
Added: svn:eol-style
+ native
More information about the grass-commit
mailing list