On 21.03.22 15:37, Aleksander Alekseev wrote:
It would not simplify things for them at all, just mess it up.
The master copies of the .po files are kept in a different repo.
Also, I believe that extraction of new message strings is automated
already.

Got it, thanks. Here is the corrected patch. It includes all the
changes by me and Japin, and doesn't touch PO files.

I think in some cases we can make this even simpler (and cast-free) by changing the underlying variable to be long long instead of int64. Especially in cases where the whole point of the variable is to be some counter that ends up being printed, there isn't a need to use int64 in the first place. See attached patch for examples.
From 9c5109c32b8702d14e42324cba027ee987df6cd0 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Wed, 23 Mar 2022 21:44:48 +0100
Subject: [PATCH] Change some variables to long long from int64

This makes printing them simpler.
---
 src/backend/commands/copy.c              |  2 +-
 src/backend/commands/copyfrom.c          | 20 ++++++++--------
 src/backend/commands/copyto.c            |  2 +-
 src/backend/tcop/utility.c               |  2 +-
 src/bin/pg_checksums/pg_checksums.c      | 30 ++++++++++++------------
 src/include/commands/copy.h              |  6 ++---
 src/include/commands/copyfrom_internal.h |  2 +-
 7 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index 7da7105d44..8bcfc305ee 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -63,7 +63,7 @@
 void
 DoCopy(ParseState *pstate, const CopyStmt *stmt,
           int stmt_location, int stmt_len,
-          uint64 *processed)
+          unsigned long long *processed)
 {
        bool            is_from = stmt->is_from;
        bool            pipe = (stmt->filename == NULL);
diff --git a/src/backend/commands/copyfrom.c b/src/backend/commands/copyfrom.c
index db6eb6fae7..5696c7e857 100644
--- a/src/backend/commands/copyfrom.c
+++ b/src/backend/commands/copyfrom.c
@@ -80,7 +80,7 @@ typedef struct CopyMultiInsertBuffer
        ResultRelInfo *resultRelInfo;   /* ResultRelInfo for 'relid' */
        BulkInsertState bistate;        /* BulkInsertState for this rel */
        int                     nused;                  /* number of 'slots' 
containing tuples */
-       uint64          linenos[MAX_BUFFERED_TUPLES];   /* Line # of tuple in 
copy
+       unsigned long long linenos[MAX_BUFFERED_TUPLES];        /* Line # of 
tuple in copy
                                                                                
                 * stream */
 } CopyMultiInsertBuffer;
 
@@ -122,12 +122,12 @@ CopyFromErrorCallback(void *arg)
                if (cstate->cur_attname)
                        errcontext("COPY %s, line %llu, column %s",
                                           cstate->cur_relname,
-                                          (unsigned long long) 
cstate->cur_lineno,
+                                          cstate->cur_lineno,
                                           cstate->cur_attname);
                else
                        errcontext("COPY %s, line %llu",
                                           cstate->cur_relname,
-                                          (unsigned long long) 
cstate->cur_lineno);
+                                          cstate->cur_lineno);
        }
        else
        {
@@ -139,7 +139,7 @@ CopyFromErrorCallback(void *arg)
                        attval = limit_printout_length(cstate->cur_attval);
                        errcontext("COPY %s, line %llu, column %s: \"%s\"",
                                           cstate->cur_relname,
-                                          (unsigned long long) 
cstate->cur_lineno,
+                                          cstate->cur_lineno,
                                           cstate->cur_attname,
                                           attval);
                        pfree(attval);
@@ -149,7 +149,7 @@ CopyFromErrorCallback(void *arg)
                        /* error is relevant to a particular column, value is 
NULL */
                        errcontext("COPY %s, line %llu, column %s: null input",
                                           cstate->cur_relname,
-                                          (unsigned long long) 
cstate->cur_lineno,
+                                          cstate->cur_lineno,
                                           cstate->cur_attname);
                }
                else
@@ -166,14 +166,14 @@ CopyFromErrorCallback(void *arg)
                                lineval = 
limit_printout_length(cstate->line_buf.data);
                                errcontext("COPY %s, line %llu: \"%s\"",
                                                   cstate->cur_relname,
-                                                  (unsigned long long) 
cstate->cur_lineno, lineval);
+                                                  cstate->cur_lineno, lineval);
                                pfree(lineval);
                        }
                        else
                        {
                                errcontext("COPY %s, line %llu",
                                                   cstate->cur_relname,
-                                                  (unsigned long long) 
cstate->cur_lineno);
+                                                  cstate->cur_lineno);
                        }
                }
        }
@@ -303,7 +303,7 @@ CopyMultiInsertBufferFlush(CopyMultiInsertInfo *miinfo,
 {
        MemoryContext oldcontext;
        int                     i;
-       uint64          save_cur_lineno;
+       unsigned long long save_cur_lineno;
        CopyFromState cstate = miinfo->cstate;
        EState     *estate = miinfo->estate;
        CommandId       mycid = miinfo->mycid;
@@ -503,7 +503,7 @@ CopyMultiInsertInfoNextFreeSlot(CopyMultiInsertInfo *miinfo,
  */
 static inline void
 CopyMultiInsertInfoStore(CopyMultiInsertInfo *miinfo, ResultRelInfo *rri,
-                                                TupleTableSlot *slot, int 
tuplen, uint64 lineno)
+                                                TupleTableSlot *slot, int 
tuplen, unsigned long long lineno)
 {
        CopyMultiInsertBuffer *buffer = rri->ri_CopyMultiInsertBuffer;
 
@@ -524,7 +524,7 @@ CopyMultiInsertInfoStore(CopyMultiInsertInfo *miinfo, 
ResultRelInfo *rri,
 /*
  * Copy FROM file to relation.
  */
-uint64
+unsigned long long
 CopyFrom(CopyFromState cstate)
 {
        ResultRelInfo *resultRelInfo;
diff --git a/src/backend/commands/copyto.c b/src/backend/commands/copyto.c
index 55c38b04c4..6debafec17 100644
--- a/src/backend/commands/copyto.c
+++ b/src/backend/commands/copyto.c
@@ -767,7 +767,7 @@ EndCopyTo(CopyToState cstate)
 /*
  * Copy from relation or query TO file.
  */
-uint64
+unsigned long long
 DoCopyTo(CopyToState cstate)
 {
        bool            pipe = (cstate->filename == NULL);
diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c
index 3780c6e812..db8f2a191d 100644
--- a/src/backend/tcop/utility.c
+++ b/src/backend/tcop/utility.c
@@ -736,7 +736,7 @@ standard_ProcessUtility(PlannedStmt *pstmt,
 
                case T_CopyStmt:
                        {
-                               uint64          processed;
+                               unsigned long long processed;
 
                                DoCopy(pstate, (CopyStmt *) parsetree,
                                           pstmt->stmt_location, 
pstmt->stmt_len,
diff --git a/src/bin/pg_checksums/pg_checksums.c 
b/src/bin/pg_checksums/pg_checksums.c
index 5f0f5ee62d..82ecab8483 100644
--- a/src/bin/pg_checksums/pg_checksums.c
+++ b/src/bin/pg_checksums/pg_checksums.c
@@ -33,11 +33,11 @@
 #include "storage/checksum_impl.h"
 
 
-static int64 files_scanned = 0;
-static int64 files_written = 0;
-static int64 blocks_scanned = 0;
-static int64 blocks_written = 0;
-static int64 badblocks = 0;
+static long long files_scanned = 0;
+static long long files_written = 0;
+static long long blocks_scanned = 0;
+static long long blocks_written = 0;
+static long long badblocks = 0;
 static ControlFileData *ControlFile;
 
 static char *only_filenode = NULL;
@@ -69,8 +69,8 @@ static const char *progname;
 /*
  * Progress status information.
  */
-int64          total_size = 0;
-int64          current_size = 0;
+long long      total_size = 0;
+long long      current_size = 0;
 static pg_time_t last_progress_report = 0;
 
 static void
@@ -151,8 +151,8 @@ progress_report(bool finished)
        percent = total_size ? (int) ((current_size) * 100 / total_size) : 0;
 
        fprintf(stderr, _("%lld/%lld MB (%d%%) computed"),
-                       (long long) (current_size / (1024 * 1024)),
-                       (long long) (total_size / (1024 * 1024)),
+                       current_size / (1024 * 1024),
+                       total_size / (1024 * 1024),
                        percent);
 
        /*
@@ -188,7 +188,7 @@ scan_file(const char *fn, int segmentno)
        int                     f;
        BlockNumber blockno;
        int                     flags;
-       int64           blocks_written_in_file = 0;
+       long long       blocks_written_in_file = 0;
 
        Assert(mode == PG_MODE_ENABLE ||
                   mode == PG_MODE_CHECK);
@@ -646,11 +646,11 @@ main(int argc, char *argv[])
                        progress_report(true);
 
                printf(_("Checksum operation completed\n"));
-               printf(_("Files scanned:   %lld\n"), (long long) files_scanned);
-               printf(_("Blocks scanned:  %lld\n"), (long long) 
blocks_scanned);
+               printf(_("Files scanned:   %lld\n"), files_scanned);
+               printf(_("Blocks scanned:  %lld\n"), blocks_scanned);
                if (mode == PG_MODE_CHECK)
                {
-                       printf(_("Bad checksums:  %lld\n"), (long long) 
badblocks);
+                       printf(_("Bad checksums:  %lld\n"), badblocks);
                        printf(_("Data checksum version: %u\n"), 
ControlFile->data_checksum_version);
 
                        if (badblocks > 0)
@@ -658,8 +658,8 @@ main(int argc, char *argv[])
                }
                else if (mode == PG_MODE_ENABLE)
                {
-                       printf(_("Files written:  %lld\n"), (long long) 
files_written);
-                       printf(_("Blocks written: %lld\n"), (long long) 
blocks_written);
+                       printf(_("Files written:  %lld\n"), files_written);
+                       printf(_("Blocks written: %lld\n"), blocks_written);
                }
        }
 
diff --git a/src/include/commands/copy.h b/src/include/commands/copy.h
index 8694da5004..a685ed3fbb 100644
--- a/src/include/commands/copy.h
+++ b/src/include/commands/copy.h
@@ -58,7 +58,7 @@ typedef int (*copy_data_source_cb) (void *outbuf, int 
minread, int maxread);
 
 extern void DoCopy(ParseState *state, const CopyStmt *stmt,
                                   int stmt_location, int stmt_len,
-                                  uint64 *processed);
+                                  unsigned long long *processed);
 
 extern void ProcessCopyOptions(ParseState *pstate, CopyFormatOptions *ops_out, 
bool is_from, List *options);
 extern CopyFromState BeginCopyFrom(ParseState *pstate, Relation rel, Node 
*whereClause,
@@ -71,7 +71,7 @@ extern bool NextCopyFromRawFields(CopyFromState cstate,
                                                                  char 
***fields, int *nfields);
 extern void CopyFromErrorCallback(void *arg);
 
-extern uint64 CopyFrom(CopyFromState cstate);
+extern unsigned long long CopyFrom(CopyFromState cstate);
 
 extern DestReceiver *CreateCopyDestReceiver(void);
 
@@ -82,7 +82,7 @@ extern CopyToState BeginCopyTo(ParseState *pstate, Relation 
rel, RawStmt *query,
                                                           Oid queryRelId, 
const char *filename, bool is_program,
                                                           List *attnamelist, 
List *options);
 extern void EndCopyTo(CopyToState cstate);
-extern uint64 DoCopyTo(CopyToState cstate);
+extern unsigned long long DoCopyTo(CopyToState cstate);
 extern List *CopyGetAttnums(TupleDesc tupDesc, Relation rel,
                                                        List *attnamelist);
 
diff --git a/src/include/commands/copyfrom_internal.h 
b/src/include/commands/copyfrom_internal.h
index 3df1c5a97c..bec8f97bc6 100644
--- a/src/include/commands/copyfrom_internal.h
+++ b/src/include/commands/copyfrom_internal.h
@@ -78,7 +78,7 @@ typedef struct CopyFromStateData
 
        /* these are just for error messages, see CopyFromErrorCallback */
        const char *cur_relname;        /* table name for error messages */
-       uint64          cur_lineno;             /* line number for error 
messages */
+       unsigned long long cur_lineno;          /* line number for error 
messages */
        const char *cur_attname;        /* current att for error messages */
        const char *cur_attval;         /* current att value for error messages 
*/
 
-- 
2.35.1

Reply via email to