[GRASS-user] db.select limitation + psql workaround

Markus Neteler neteler at osgeo.org
Sat Jan 17 09:14:25 EST 2009


On Sat, Jan 17, 2009 at 11:51 AM, Glynn Clements
<glynn at gclements.plus.com> wrote:
> "Peter Löwe" wrote:
>> I do agree. However, since the statement begins with the
>> "SELECT"-string, db.execute refuses to execute it.
>
> This is a bug in db.execute, and the only simple fix is to remove the
> check altogether.

As simple as this?

Index: db/base/execute.c
===================================================================
--- db/base/execute.c   (revision 35372)
+++ db/base/execute.c   (working copy)
@@ -135,7 +135,7 @@

 static int get_stmt(FILE * fd, dbString * stmt)
 {
-    char buf[4000], buf2[4000], buf3[7];
+    char buf[4000], buf2[4000];
     int len, row = 0;

     db_init_string(stmt);
@@ -145,11 +145,6 @@
        G_chop(buf2);
        len = strlen(buf2);

-       G_strncpy(buf3, buf2, 6);
-       if (G_strcasecmp(buf3, "select") == 0)
-           G_fatal_error(_("Use db.select for SELECT SQL statements"));
-
-       len = strlen(buf2);
        if (buf2[len - 1] == ';') {     /* end of statement */
            buf2[len - 1] = 0;  /* truncate ';' */
            db_append_string(stmt, buf2);       /* append truncated */

If so, I suggest to do it also in GRASS 6.4.x.

Markus


More information about the grass-user mailing list