hash_debug.patch

application/octet-stream

Filename: hash_debug.patch
Type: application/octet-stream
Part: 0
Message: Re: Compilation issues for HASH_STATISTICS and HASH_DEBUG options

Patch

Format: unified
File+
src/backend/utils/hash/dynahash.c 17 19
diff --git a/src/backend/utils/hash/dynahash.c b/src/backend/utils/hash/dynahash.c
index d0843551007..91cd5dfbf94 100644
--- a/src/backend/utils/hash/dynahash.c
+++ b/src/backend/utils/hash/dynahash.c
@@ -776,15 +776,15 @@ init_htab(HTAB *hashp, long nelem)
 	hctl->nelem_alloc = choose_nelem_alloc(hctl->entrysize);
 
 #ifdef HASH_DEBUG
-	fprintf(stderr, "init_htab:\n%s%p\n%s%ld\n%s%ld\n%s%d\n%s%u\n%s%x\n%s%x\n%s%ld\n",
-			"TABLE POINTER   ", hashp,
-			"DIRECTORY SIZE  ", hctl->dsize,
-			"SEGMENT SIZE    ", hctl->ssize,
-			"SEGMENT SHIFT   ", hctl->sshift,
-			"MAX BUCKET      ", hctl->max_bucket,
-			"HIGH MASK       ", hctl->high_mask,
-			"LOW  MASK       ", hctl->low_mask,
-			"NSEGS           ", hctl->nsegs);
+	elog(DEBUG4, "init_htab:\n%s%p\n%s%ld\n%s%ld\n%s%d\n%s%u\n%s%x\n%s%x\n%s%ld\n",
+		 "TABLE POINTER   ", hashp,
+		 "DIRECTORY SIZE  ", hctl->dsize,
+		 "SEGMENT SIZE    ", hctl->ssize,
+		 "SEGMENT SHIFT   ", hctl->sshift,
+		 "MAX BUCKET      ", hctl->max_bucket,
+		 "HIGH MASK       ", hctl->high_mask,
+		 "LOW  MASK       ", hctl->low_mask,
+		 "NSEGS           ", hctl->nsegs);
 #endif
 	return true;
 }
@@ -901,16 +901,14 @@ void
 hash_stats(const char *where, HTAB *hashp)
 {
 #ifdef HASH_STATISTICS
-	fprintf(stderr, "%s: this HTAB -- accesses %ld collisions %ld\n",
-			where, hashp->hctl->accesses, hashp->hctl->collisions);
-
-	fprintf(stderr, "hash_stats: entries %ld keysize %ld maxp %u segmentcount %ld\n",
-			hash_get_num_entries(hashp), (long) hashp->hctl->keysize,
-			hashp->hctl->max_bucket, hashp->hctl->nsegs);
-	fprintf(stderr, "%s: total accesses %ld total collisions %ld\n",
-			where, hash_accesses, hash_collisions);
-	fprintf(stderr, "hash_stats: total expansions %ld\n",
-			hash_expansions);
+	elog(DEBUG4, "%s: this HTAB -- accesses %ld collisions %ld\n", where,
+		 hashp->hctl->accesses, hashp->hctl->collisions);
+	elog(DEBUG4, "hash_stats: entries %ld keysize %ld maxp %u segmentcount %ld\n",
+		 hash_get_num_entries(hashp), (long) hashp->hctl->keysize,
+		 hashp->hctl->max_bucket, hashp->hctl->nsegs);
+	elog(DEBUG4, "%s: total accesses %ld total collisions %ld\n", where,
+		 hash_accesses, hash_collisions);
+	elog(DEBUG4, "hash_stats: total expansions %ld\n", hash_expansions);
 #endif
 }