internal/database: CopyUpsert honors QueryLoggingDisabled

Don't log from CopyUpsert if query logging is disabled.

Change-Id: Iee6d1998b6330294043d8f80ab5b5507651750ee
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/307471
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Julie Qiu <julie@golang.org>
diff --git a/internal/database/copy.go b/internal/database/copy.go
index 7a092c0..77c79b5 100644
--- a/internal/database/copy.go
+++ b/internal/database/copy.go
@@ -62,7 +62,9 @@
 		if err != nil {
 			return fmt.Errorf("CopyFrom: %w", err)
 		}
-		log.Debugf(ctx, "CopyUpsert(%q): copied %d rows in %s", table, n, time.Since(start))
+		if !QueryLoggingDisabled {
+			log.Debugf(ctx, "CopyUpsert(%q): copied %d rows in %s", table, n, time.Since(start))
+		}
 		conflictAction := buildUpsertConflictAction(columns, conflictColumns)
 		cols := strings.Join(columns, ", ")
 		query := fmt.Sprintf("INSERT INTO %s (%s) SELECT %s FROM %s %s", table, cols, cols, tempTable, conflictAction)
@@ -72,7 +74,9 @@
 		if err != nil {
 			return err
 		}
-		log.Debugf(ctx, "CopyUpsert(%q): upserted %d rows in %s", table, ctag.RowsAffected(), time.Since(start))
+		if !QueryLoggingDisabled {
+			log.Debugf(ctx, "CopyUpsert(%q): upserted %d rows in %s", table, ctag.RowsAffected(), time.Since(start))
+		}
 		return nil
 	})
 }