[GRASS-SVN] r51988 - grass/trunk/lib/vector/Vlib
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Jun 6 08:05:03 PDT 2012
Author: martinl
Date: 2012-06-06 08:05:02 -0700 (Wed, 06 Jun 2012)
New Revision: 51988
Modified:
grass/trunk/lib/vector/Vlib/open_pg.c
Log:
vlib/pg: print PostgreSQL NOTICE messages only on verbose level
Modified: grass/trunk/lib/vector/Vlib/open_pg.c
===================================================================
--- grass/trunk/lib/vector/Vlib/open_pg.c 2012-06-06 14:47:05 UTC (rev 51987)
+++ grass/trunk/lib/vector/Vlib/open_pg.c 2012-06-06 15:05:02 UTC (rev 51988)
@@ -44,6 +44,7 @@
static int read_p_line(struct Plus_head *, int, const struct edge_data *);
static int read_p_area(struct Plus_head *, int, int, struct Format_info_pg *);
static int load_plus_head(struct Format_info_pg *, struct Plus_head *);
+static void notice_processor(void *, const char *);
#endif
/*!
@@ -216,13 +217,8 @@
pg_info->conninfo, pg_info->table_name);
/* connect database */
- pg_info->conn = PQconnectdb(pg_info->conninfo);
- G_debug(2, " PQconnectdb(): %s", pg_info->conninfo);
- if (PQstatus(pg_info->conn) == CONNECTION_BAD)
- G_fatal_error("%s\n%s",
- _("Connection ton PostgreSQL database failed."),
- PQerrorMessage(pg_info->conn));
-
+ connect_db(pg_info);
+
/* get DB name */
pg_info->db_name = G_store(PQdb(pg_info->conn));
if (!pg_info->db_name) {
@@ -763,6 +759,8 @@
/* create index ? */
if (spatial_index) {
+ G_verbose_message(_("Building spatial index on <%s>..."),
+ pg_info->geom_column);
sprintf(stmt,
"CREATE INDEX %s_%s_idx ON \"%s\".\"%s\" USING GIST (%s)",
pg_info->table_name, pg_info->geom_column,
@@ -797,6 +795,10 @@
G_fatal_error("%s\n%s",
_("Connection ton PostgreSQL database failed."),
PQerrorMessage(pg_info->conn));
+
+ /* print notice messages only on verbose level */
+ PQsetNoticeProcessor(pg_info->conn, notice_processor, NULL);
+
}
/*!
@@ -1445,4 +1447,16 @@
return 0;
}
+
+/*
+ \brief PostgreSQL notice processor
+
+ Print out NOTICE message only on verbose level
+*/
+void notice_processor(void *arg, const char *message)
+{
+ if (G_verbose() > G_verbose_std()) {
+ fprintf(stderr, "%s", message);
+ }
+}
#endif
More information about the grass-commit
mailing list