Browse Source

db-pg driver: print notice message only on verbose level

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@51961 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 13 years ago
parent
commit
d7fe2509aa
1 changed files with 16 additions and 4 deletions
  1. 16 4
      db/drivers/postgres/db.c

+ 16 - 4
db/drivers/postgres/db.c

@@ -18,6 +18,14 @@
 #include "globals.h"
 #include "proto.h"
 
+static void notice_processor(void *arg, const char *message)
+{
+    /* print notice messages only on verbose level */
+    if (G_verbose() > G_verbose_std()) {
+        fprintf(stderr, "%s", message);
+    }
+}
+
 int db__driver_open_database(dbHandle * handle)
 {
     char buf[500];
@@ -64,10 +72,11 @@ int db__driver_open_database(dbHandle * handle)
 	return DB_FAILED;
     }
 
-    /* Set schema */
+    /* set schema */
     schema = db_get_handle_dbschema(handle);
 
-    /* Cannot use default schema because link to table can point to different database */
+    /* Cannot use default schema because link to table can point to
+       different database */
     /*
        if ( schema ) 
        schema = connection.schemaName;
@@ -92,7 +101,7 @@ int db__driver_open_database(dbHandle * handle)
 	}
     }
 
-    /* Read internal codes */
+    /* read internal codes */
     res = PQexec(pg_conn,
 		 "select oid, typname from pg_type where typname in ( "
 		 "'bit', 'int2', 'int4', 'int8', 'serial', 'oid', "
@@ -164,7 +173,10 @@ int db__driver_open_database(dbHandle * handle)
 		PQgetvalue(res, row, 1), type);
 	pg_types[row][1] = type;
     }
-
+    
+    /* print notice messages only on verbose level */
+    PQsetNoticeProcessor(pg_conn, notice_processor, NULL);
+    
     PQclear(res);
 
     return DB_OK;