Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1f8bc44

Browse files
committed
Remove workarounds for avoiding [U]INT64_FORMAT in translatable strings.
Further code simplification along the same lines asd914eb3and earlier patches.Aleksander Alekseev, Japin LiDiscussion:https://postgr.es/m/CAJ7c6TMSKi3Xs8h5MP38XOnQQpBLazJvVxVfPn++roitDJcR7g@mail.gmail.com
1 parentc540d37 commit1f8bc44

File tree

5 files changed

+66
-143
lines changed

5 files changed

+66
-143
lines changed

‎src/backend/access/brin/brin.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,13 +1017,10 @@ brin_summarize_range(PG_FUNCTION_ARGS)
10171017
errhint("BRIN control functions cannot be executed during recovery.")));
10181018

10191019
if (heapBlk64>BRIN_ALL_BLOCKRANGES||heapBlk64<0)
1020-
{
1021-
char*blk=psprintf(INT64_FORMAT,heapBlk64);
1022-
10231020
ereport(ERROR,
10241021
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
1025-
errmsg("block number out of range: %s",blk)));
1026-
}
1022+
errmsg("block number out of range: %lld",
1023+
(long long)heapBlk64)));
10271024
heapBlk= (BlockNumber)heapBlk64;
10281025

10291026
/*
@@ -1094,13 +1091,10 @@ brin_desummarize_range(PG_FUNCTION_ARGS)
10941091
errhint("BRIN control functions cannot be executed during recovery.")));
10951092

10961093
if (heapBlk64>MaxBlockNumber||heapBlk64<0)
1097-
{
1098-
char*blk=psprintf(INT64_FORMAT,heapBlk64);
1099-
11001094
ereport(ERROR,
11011095
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
1102-
errmsg("block number out of range: %s",blk)));
1103-
}
1096+
errmsg("block number out of range: %lld",
1097+
(long long)heapBlk64)));
11041098
heapBlk= (BlockNumber)heapBlk64;
11051099

11061100
/*

‎src/backend/commands/copyfrom.c

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -115,21 +115,19 @@ void
115115
CopyFromErrorCallback(void*arg)
116116
{
117117
CopyFromStatecstate= (CopyFromState)arg;
118-
charcurlineno_str[32];
119-
120-
snprintf(curlineno_str,sizeof(curlineno_str),UINT64_FORMAT,
121-
cstate->cur_lineno);
122118

123119
if (cstate->opts.binary)
124120
{
125121
/* can't usefully display the data */
126122
if (cstate->cur_attname)
127-
errcontext("COPY %s, line %s, column %s",
128-
cstate->cur_relname,curlineno_str,
123+
errcontext("COPY %s, line %llu, column %s",
124+
cstate->cur_relname,
125+
(unsigned long long)cstate->cur_lineno,
129126
cstate->cur_attname);
130127
else
131-
errcontext("COPY %s, line %s",
132-
cstate->cur_relname,curlineno_str);
128+
errcontext("COPY %s, line %llu",
129+
cstate->cur_relname,
130+
(unsigned long long)cstate->cur_lineno);
133131
}
134132
else
135133
{
@@ -139,16 +137,19 @@ CopyFromErrorCallback(void *arg)
139137
char*attval;
140138

141139
attval=limit_printout_length(cstate->cur_attval);
142-
errcontext("COPY %s, line %s, column %s: \"%s\"",
143-
cstate->cur_relname,curlineno_str,
144-
cstate->cur_attname,attval);
140+
errcontext("COPY %s, line %llu, column %s: \"%s\"",
141+
cstate->cur_relname,
142+
(unsigned long long)cstate->cur_lineno,
143+
cstate->cur_attname,
144+
attval);
145145
pfree(attval);
146146
}
147147
elseif (cstate->cur_attname)
148148
{
149149
/* error is relevant to a particular column, value is NULL */
150-
errcontext("COPY %s, line %s, column %s: null input",
151-
cstate->cur_relname,curlineno_str,
150+
errcontext("COPY %s, line %llu, column %s: null input",
151+
cstate->cur_relname,
152+
(unsigned long long)cstate->cur_lineno,
152153
cstate->cur_attname);
153154
}
154155
else
@@ -163,14 +164,16 @@ CopyFromErrorCallback(void *arg)
163164
char*lineval;
164165

165166
lineval=limit_printout_length(cstate->line_buf.data);
166-
errcontext("COPY %s, line %s: \"%s\"",
167-
cstate->cur_relname,curlineno_str,lineval);
167+
errcontext("COPY %s, line %llu: \"%s\"",
168+
cstate->cur_relname,
169+
(unsigned long long)cstate->cur_lineno,lineval);
168170
pfree(lineval);
169171
}
170172
else
171173
{
172-
errcontext("COPY %s, line %s",
173-
cstate->cur_relname,curlineno_str);
174+
errcontext("COPY %s, line %llu",
175+
cstate->cur_relname,
176+
(unsigned long long)cstate->cur_lineno);
174177
}
175178
}
176179
}

‎src/backend/commands/sequence.c

Lines changed: 32 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -706,15 +706,11 @@ nextval_internal(Oid relid, bool check_permissions)
706706
if (rescnt>0)
707707
break;/* stop fetching */
708708
if (!cycle)
709-
{
710-
charbuf[100];
711-
712-
snprintf(buf,sizeof(buf),INT64_FORMAT,maxv);
713709
ereport(ERROR,
714710
(errcode(ERRCODE_SEQUENCE_GENERATOR_LIMIT_EXCEEDED),
715-
errmsg("nextval: reached maximum value of sequence \"%s\" (%s)",
716-
RelationGetRelationName(seqrel),buf)));
717-
}
711+
errmsg("nextval: reached maximum value of sequence \"%s\" (%lld)",
712+
RelationGetRelationName(seqrel),
713+
(long long)maxv)));
718714
next=minv;
719715
}
720716
else
@@ -729,15 +725,11 @@ nextval_internal(Oid relid, bool check_permissions)
729725
if (rescnt>0)
730726
break;/* stop fetching */
731727
if (!cycle)
732-
{
733-
charbuf[100];
734-
735-
snprintf(buf,sizeof(buf),INT64_FORMAT,minv);
736728
ereport(ERROR,
737729
(errcode(ERRCODE_SEQUENCE_GENERATOR_LIMIT_EXCEEDED),
738-
errmsg("nextval: reached minimum value of sequence \"%s\" (%s)",
739-
RelationGetRelationName(seqrel),buf)));
740-
}
730+
errmsg("nextval: reached minimum value of sequence \"%s\" (%lld)",
731+
RelationGetRelationName(seqrel),
732+
(long long)minv)));
741733
next=maxv;
742734
}
743735
else
@@ -975,20 +967,11 @@ do_setval(Oid relid, int64 next, bool iscalled)
975967
seq=read_seq_tuple(seqrel,&buf,&seqdatatuple);
976968

977969
if ((next<minv)|| (next>maxv))
978-
{
979-
charbufv[100],
980-
bufm[100],
981-
bufx[100];
982-
983-
snprintf(bufv,sizeof(bufv),INT64_FORMAT,next);
984-
snprintf(bufm,sizeof(bufm),INT64_FORMAT,minv);
985-
snprintf(bufx,sizeof(bufx),INT64_FORMAT,maxv);
986970
ereport(ERROR,
987971
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
988-
errmsg("setval: value %s is out of bounds for sequence \"%s\" (%s..%s)",
989-
bufv,RelationGetRelationName(seqrel),
990-
bufm,bufx)));
991-
}
972+
errmsg("setval: value %lld is out of bounds for sequence \"%s\" (%lld..%lld)",
973+
(long long)next,RelationGetRelationName(seqrel),
974+
(long long)minv, (long long)maxv)));
992975

993976
/* Set the currval() state only if iscalled = true */
994977
if (iscalled)
@@ -1468,16 +1451,11 @@ init_params(ParseState *pstate, List *options, bool for_identity,
14681451
/* Validate maximum value. No need to check INT8 as seqmax is an int64 */
14691452
if ((seqform->seqtypid==INT2OID&& (seqform->seqmax<PG_INT16_MIN||seqform->seqmax>PG_INT16_MAX))
14701453
|| (seqform->seqtypid==INT4OID&& (seqform->seqmax<PG_INT32_MIN||seqform->seqmax>PG_INT32_MAX)))
1471-
{
1472-
charbufx[100];
1473-
1474-
snprintf(bufx,sizeof(bufx),INT64_FORMAT,seqform->seqmax);
1475-
14761454
ereport(ERROR,
14771455
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1478-
errmsg("MAXVALUE (%s) is out of range for sequence data type %s",
1479-
bufx,format_type_be(seqform->seqtypid))));
1480-
}
1456+
errmsg("MAXVALUE (%lld) is out of range for sequence data type %s",
1457+
(long long)seqform->seqmax,
1458+
format_type_be(seqform->seqtypid))));
14811459

14821460
/* MINVALUE (null arg means NO MINVALUE) */
14831461
if (min_value!=NULL&&min_value->arg)
@@ -1505,30 +1483,19 @@ init_params(ParseState *pstate, List *options, bool for_identity,
15051483
/* Validate minimum value. No need to check INT8 as seqmin is an int64 */
15061484
if ((seqform->seqtypid==INT2OID&& (seqform->seqmin<PG_INT16_MIN||seqform->seqmin>PG_INT16_MAX))
15071485
|| (seqform->seqtypid==INT4OID&& (seqform->seqmin<PG_INT32_MIN||seqform->seqmin>PG_INT32_MAX)))
1508-
{
1509-
charbufm[100];
1510-
1511-
snprintf(bufm,sizeof(bufm),INT64_FORMAT,seqform->seqmin);
1512-
15131486
ereport(ERROR,
15141487
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1515-
errmsg("MINVALUE (%s) is out of range for sequence data type %s",
1516-
bufm,format_type_be(seqform->seqtypid))));
1517-
}
1488+
errmsg("MINVALUE (%lld) is out of range for sequence data type %s",
1489+
(long long)seqform->seqmin,
1490+
format_type_be(seqform->seqtypid))));
15181491

15191492
/* crosscheck min/max */
15201493
if (seqform->seqmin >=seqform->seqmax)
1521-
{
1522-
charbufm[100],
1523-
bufx[100];
1524-
1525-
snprintf(bufm,sizeof(bufm),INT64_FORMAT,seqform->seqmin);
1526-
snprintf(bufx,sizeof(bufx),INT64_FORMAT,seqform->seqmax);
15271494
ereport(ERROR,
15281495
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1529-
errmsg("MINVALUE (%s) must be less than MAXVALUE (%s)",
1530-
bufm,bufx)));
1531-
}
1496+
errmsg("MINVALUE (%lld) must be less than MAXVALUE (%lld)",
1497+
(long long)seqform->seqmin,
1498+
(long long)seqform->seqmax)));
15321499

15331500
/* START WITH */
15341501
if (start_value!=NULL)
@@ -1545,29 +1512,17 @@ init_params(ParseState *pstate, List *options, bool for_identity,
15451512

15461513
/* crosscheck START */
15471514
if (seqform->seqstart<seqform->seqmin)
1548-
{
1549-
charbufs[100],
1550-
bufm[100];
1551-
1552-
snprintf(bufs,sizeof(bufs),INT64_FORMAT,seqform->seqstart);
1553-
snprintf(bufm,sizeof(bufm),INT64_FORMAT,seqform->seqmin);
15541515
ereport(ERROR,
15551516
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1556-
errmsg("START value (%s) cannot be less than MINVALUE (%s)",
1557-
bufs,bufm)));
1558-
}
1517+
errmsg("START value (%lld) cannot be less than MINVALUE (%lld)",
1518+
(long long)seqform->seqstart,
1519+
(long long)seqform->seqmin)));
15591520
if (seqform->seqstart>seqform->seqmax)
1560-
{
1561-
charbufs[100],
1562-
bufm[100];
1563-
1564-
snprintf(bufs,sizeof(bufs),INT64_FORMAT,seqform->seqstart);
1565-
snprintf(bufm,sizeof(bufm),INT64_FORMAT,seqform->seqmax);
15661521
ereport(ERROR,
15671522
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1568-
errmsg("START value (%s) cannot be greater than MAXVALUE (%s)",
1569-
bufs,bufm)));
1570-
}
1523+
errmsg("START value (%lld) cannot be greater than MAXVALUE (%lld)",
1524+
(long long)seqform->seqstart,
1525+
(long long)seqform->seqmax)));
15711526

15721527
/* RESTART [WITH] */
15731528
if (restart_value!=NULL)
@@ -1587,44 +1542,27 @@ init_params(ParseState *pstate, List *options, bool for_identity,
15871542

15881543
/* crosscheck RESTART (or current value, if changing MIN/MAX) */
15891544
if (seqdataform->last_value<seqform->seqmin)
1590-
{
1591-
charbufs[100],
1592-
bufm[100];
1593-
1594-
snprintf(bufs,sizeof(bufs),INT64_FORMAT,seqdataform->last_value);
1595-
snprintf(bufm,sizeof(bufm),INT64_FORMAT,seqform->seqmin);
15961545
ereport(ERROR,
15971546
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1598-
errmsg("RESTART value (%s) cannot be less than MINVALUE (%s)",
1599-
bufs,bufm)));
1600-
}
1547+
errmsg("RESTART value (%lld) cannot be less than MINVALUE (%lld)",
1548+
(long long)seqdataform->last_value,
1549+
(long long)seqform->seqmin)));
16011550
if (seqdataform->last_value>seqform->seqmax)
1602-
{
1603-
charbufs[100],
1604-
bufm[100];
1605-
1606-
snprintf(bufs,sizeof(bufs),INT64_FORMAT,seqdataform->last_value);
1607-
snprintf(bufm,sizeof(bufm),INT64_FORMAT,seqform->seqmax);
16081551
ereport(ERROR,
16091552
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1610-
errmsg("RESTART value (%s) cannot be greater than MAXVALUE (%s)",
1611-
bufs,bufm)));
1612-
}
1553+
errmsg("RESTART value (%lld) cannot be greater than MAXVALUE (%lld)",
1554+
(long long)seqdataform->last_value,
1555+
(long long)seqform->seqmax)));
16131556

16141557
/* CACHE */
16151558
if (cache_value!=NULL)
16161559
{
16171560
seqform->seqcache=defGetInt64(cache_value);
16181561
if (seqform->seqcache <=0)
1619-
{
1620-
charbuf[100];
1621-
1622-
snprintf(buf,sizeof(buf),INT64_FORMAT,seqform->seqcache);
16231562
ereport(ERROR,
16241563
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1625-
errmsg("CACHE (%s) must be greater than zero",
1626-
buf)));
1627-
}
1564+
errmsg("CACHE (%lld) must be greater than zero",
1565+
(long long)seqform->seqcache)));
16281566
seqdataform->log_cnt=0;
16291567
}
16301568
elseif (isInit)

‎src/backend/utils/adt/xid8funcs.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,8 @@ TransactionIdInRecentPast(FullTransactionId fxid, TransactionId *extracted_xid)
113113
if (!FullTransactionIdPrecedes(fxid,now_fullxid))
114114
ereport(ERROR,
115115
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
116-
errmsg("transaction ID %s is in the future",
117-
psprintf(UINT64_FORMAT,
118-
U64FromFullTransactionId(fxid)))));
116+
errmsg("transaction ID %llu is in the future",
117+
(unsigned long long)U64FromFullTransactionId(fxid))));
119118

120119
/*
121120
* ShmemVariableCache->oldestClogXid is protected by XactTruncationLock,

‎src/bin/pg_checksums/pg_checksums.c

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,6 @@ static void
132132
progress_report(boolfinished)
133133
{
134134
intpercent;
135-
chartotal_size_str[32];
136-
charcurrent_size_str[32];
137135
pg_time_tnow;
138136

139137
Assert(showprogress);
@@ -152,18 +150,9 @@ progress_report(bool finished)
152150
/* Calculate current percentage of size done */
153151
percent=total_size ? (int) ((current_size)*100 /total_size) :0;
154152

155-
/*
156-
* Separate step to keep platform-dependent format code out of
157-
* translatable strings. And we only test for INT64_FORMAT availability
158-
* in snprintf, not fprintf.
159-
*/
160-
snprintf(total_size_str,sizeof(total_size_str),INT64_FORMAT,
161-
total_size / (1024*1024));
162-
snprintf(current_size_str,sizeof(current_size_str),INT64_FORMAT,
163-
current_size / (1024*1024));
164-
165-
fprintf(stderr,_("%*s/%s MB (%d%%) computed"),
166-
(int)strlen(current_size_str),current_size_str,total_size_str,
153+
fprintf(stderr,_("%lld/%lld MB (%d%%) computed"),
154+
(long long) (current_size / (1024*1024)),
155+
(long long) (total_size / (1024*1024)),
167156
percent);
168157

169158
/*
@@ -657,20 +646,20 @@ main(int argc, char *argv[])
657646
progress_report(true);
658647

659648
printf(_("Checksum operation completed\n"));
660-
printf(_("Files scanned: %s\n"),psprintf(INT64_FORMAT,files_scanned));
661-
printf(_("Blocks scanned: %s\n"),psprintf(INT64_FORMAT,blocks_scanned));
649+
printf(_("Files scanned: %lld\n"),(long long)files_scanned);
650+
printf(_("Blocks scanned: %lld\n"),(long long)blocks_scanned);
662651
if (mode==PG_MODE_CHECK)
663652
{
664-
printf(_("Bad checksums: %s\n"),psprintf(INT64_FORMAT,badblocks));
653+
printf(_("Bad checksums: %lld\n"),(long long)badblocks);
665654
printf(_("Data checksum version: %u\n"),ControlFile->data_checksum_version);
666655

667656
if (badblocks>0)
668657
exit(1);
669658
}
670659
elseif (mode==PG_MODE_ENABLE)
671660
{
672-
printf(_("Files written: %s\n"),psprintf(INT64_FORMAT,files_written));
673-
printf(_("Blocks written: %s\n"),psprintf(INT64_FORMAT,blocks_written));
661+
printf(_("Files written: %lld\n"),(long long)files_written);
662+
printf(_("Blocks written: %lld\n"),(long long)blocks_written);
674663
}
675664
}
676665

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp