[GRASS5] [bug #2818] (grass) db.execute: want to do like /bin/sh -e

this bug's URL: http://intevation.de/rt/webrt?serial_num=2818
-------------------------------------------------------------------------

db.execute should have an option to cause it to stop after the first
error it encounters back from the driver, not just go on sending the
next line to the driver. E.g., don't go on after
DBMI-DBF driver error:
SQL parser error in statement:
UPDATE largeHouseNumbers SET housenum = 1 WHERE cat = 1 FROM tmp2
Error in db_execute_immediate()
WARNING: Error while executing: "UPDATE largeHouseNumbers SET housenum = 1
         WHERE cat = 1 FROM tmp2"
Also
WARNING: Error
just like e.g.,
Error: WARNING
look silly.

--- Headers Follow ---

From jidanni@jidanni.org Thu Dec 9 00:15:44 2004

Return-Path: <jidanni@jidanni.org>
Delivered-To: grass-bugs@lists.intevation.de
Received: from mail.intevation.de (aktaia [212.95.126.10])
  by lists.intevation.de (Postfix) with ESMTP id 1EBAA102C35
  for <grass-bugs@lists.intevation.de>; Thu, 9 Dec 2004 00:15:44 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
  by mail.intevation.de (Postfix) with ESMTP id E351036CE0
  for <grass-bugs@lists.intevation.de>; Thu, 9 Dec 2004 00:15:43 +0100 (CET)
Received: from frodo.hserus.net (frodo.hserus.net [204.74.68.40])
  by mail.intevation.de (Postfix) with ESMTP id C9EE336CD8
  for <grass-bugs@intevation.de>; Thu, 9 Dec 2004 00:15:42 +0100 (CET)
Received: from [219.69.72.86] (port=32784 helo=jidanni1)
  by frodo.hserus.net with esmtpsa
  (Cipher TLSv1:RC4-SHA:128) (Exim 4.43 #0)
  id 1CcB25-0003gK-1K by authid <jidanni> with plain
  for <grass-bugs@intevation.de>; Thu, 09 Dec 2004 04:45:42 +0530
To: grass-bugs@intevation.de
Subject: db.execute: want to do like /bin/sh -e
From: Dan Jacobson <jidanni@jidanni.org>
Date: Thu, 09 Dec 2004 05:39:37 +0800
Message-ID: <87mzwoxyee.fsf@jidanni.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Spam-Status: No, hits=-4.9 tagged_above=-999.0 required=3.0 tests=BAYES_00
X-Spam-Level:

-------------------------------------------- Managed by Request Tracker

On Thu, Dec 09, 2004 at 12:15:44AM +0100, Request Tracker wrote:

this bug's URL: http://intevation.de/rt/webrt?serial_num=2818
-------------------------------------------------------------------------

db.execute should have an option to cause it to stop after the first
error it encounters back from the driver, not just go on sending the
next line to the driver. E.g., don't go on after
DBMI-DBF driver error:
SQL parser error in statement:
UPDATE largeHouseNumbers SET housenum = 1 WHERE cat = 1 FROM tmp2
Error in db_execute_immediate()
WARNING: Error while executing: "UPDATE largeHouseNumbers SET housenum = 1
         WHERE cat = 1 FROM tmp2"
Also
WARNING: Error
just like e.g.,
Error: WARNING
look silly.

I have added a new flag '-i' to db/base/execute.c:

Usage:
db.execute [-i] [driver=name] [database=name] [input=filename]

Flags:
  -i ignore SQL errors and continue

which switches between G_warning and G_fatal_error (default now).
Of course it could be also reverted in functionality to make
G_warning the default as it was before.
However, I agree that it should stop upon error and only continue
with an additional flag to make the user aware of the problem.

Markus