--- zabbix-1.4.6/src/zabbix_server/nodewatcher/nodewatcher.c	2008-07-23 08:47:30.000000000 -0300
+++ zabbix-1.4.6.fike/src/zabbix_server/nodewatcher/nodewatcher.c	2008-08-05 08:31:50.000000000 -0300
@@ -112,6 +112,9 @@
 #ifdef	HAVE_MYSQL
 				zbx_snprintf_alloc(&sql, &sql_allocated, &sql_offset, 128, "coalesce(%s,'1234567890'),",
 					tables[i].fields[j].name);
+#elif HAVE_POSTGRESQL
+				zbx_snprintf_alloc(&sql, &sql_allocated, &sql_offset, 128, "cast(coalesce(%s,'1234567890')as varchar)||",
+					tables[i].fields[j].name);
 #else
 				if(tables[i].fields[j].type == ZBX_TYPE_BLOB) /* postgresql is not work: coalesce(blob,'1234567890')||coalesce(varchar,'1234567890') */
 				{
@@ -141,6 +144,15 @@
 					(zbx_uint64_t)__UINT64_C(100000000000000)*(zbx_uint64_t)nodeid,
 					tables[i].recid,
 					(zbx_uint64_t)__UINT64_C(100000000000000)*(zbx_uint64_t)nodeid+__UINT64_C(99999999999999));
+#elif	HAVE_POSTGRESQL				
+			zbx_snprintf_alloc(&sql, &sql_allocated, &sql_offset, 4096,
+					") from %s where %s>=" ZBX_FS_UI64 " and %s<=" ZBX_FS_UI64 "\n",
+					tables[i].table,
+					tables[i].recid,
+					(zbx_uint64_t)__UINT64_C(100000000000000)*(zbx_uint64_t)nodeid,
+					tables[i].recid,
+					(zbx_uint64_t)__UINT64_C(100000000000000)*(zbx_uint64_t)nodeid+__UINT64_C(99999999999999));
+
 #else
 			zbx_snprintf_alloc(&sql, &sql_allocated, &sql_offset, 4096,
 					") from %s where %s>=" ZBX_FS_UI64 " and %s<=" ZBX_FS_UI64 "\n",
