[GRASS-SVN] r65334 - grass/trunk/lib/db/dbmi_client
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue May 26 11:02:01 PDT 2015
Author: martinl
Date: 2015-05-26 11:02:01 -0700 (Tue, 26 May 2015)
New Revision: 65334
Modified:
grass/trunk/lib/db/dbmi_client/copy_tab.c
Log:
fix db_copy_table() for pg driver (db_list_tables() return names including schema name)
Modified: grass/trunk/lib/db/dbmi_client/copy_tab.c
===================================================================
--- grass/trunk/lib/db/dbmi_client/copy_tab.c 2015-05-26 18:00:25 UTC (rev 65333)
+++ grass/trunk/lib/db/dbmi_client/copy_tab.c 2015-05-26 18:02:01 UTC (rev 65334)
@@ -158,11 +158,33 @@
}
for (i = 0; i < count; i++) {
- const char *tblname = db_get_string(&tblnames[i]);
int ret;
-
+ char *tblname_i;
+
+ tblname_i = NULL;
+ if (strcmp(to_drvname, "pg") == 0) {
+ char *p, *tbl;
+ dbConnection connection;
+
+ tbl = db_get_string(&tblnames[i]);
+ db_get_connection(&connection);
+ p = strstr(tbl, ".");
+
+ if (p) {
+ char buf[GNAME_MAX];
+
+ sprintf(buf, "%s.%s", connection.schemaName ? connection.schemaName : "public",
+ to_tblname);
+ if (strcmp(buf, tbl) == 0)
+ tblname_i = G_store(p + 1); /* skip dot */
+ }
+ }
+ if (!tblname_i) {
+ tblname_i = G_store(db_get_string(&tblnames[i]));
+ }
+
ret = DB_FAILED;
- if (strcmp(to_tblname, tblname) == 0) {
+ if (strcmp(to_tblname, tblname_i) == 0) {
if (G_get_overwrite()) {
G_warning(_("Table <%s> already exists in database and will be overwritten"),
to_tblname);
@@ -181,6 +203,8 @@
return DB_FAILED;
}
}
+
+ G_free(tblname_i);
}
/* Create new table */
More information about the grass-commit
mailing list