mirror of
https://github.com/postgres/postgres.git
synced 2025-06-14 18:42:34 +03:00
Workaround for format strings that are concatenated from macros
(INT64_FORMAT), which gettext cannot handle.
This commit is contained in:
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/commands/sequence.c,v 1.85 2002/08/30 19:23:19 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/commands/sequence.c,v 1.86 2002/09/03 18:50:54 petere Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -400,8 +400,12 @@ nextval(PG_FUNCTION_ARGS)
|
|||||||
if (rescnt > 0)
|
if (rescnt > 0)
|
||||||
break; /* stop fetching */
|
break; /* stop fetching */
|
||||||
if (!seq->is_cycled)
|
if (!seq->is_cycled)
|
||||||
elog(ERROR, "%s.nextval: reached MAXVALUE (" INT64_FORMAT ")",
|
{
|
||||||
sequence->relname, maxv);
|
char buf[100];
|
||||||
|
snprintf(buf, 100, INT64_FORMAT, maxv);
|
||||||
|
elog(ERROR, "%s.nextval: reached MAXVALUE (%s)",
|
||||||
|
sequence->relname, buf);
|
||||||
|
}
|
||||||
next = minv;
|
next = minv;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -416,8 +420,12 @@ nextval(PG_FUNCTION_ARGS)
|
|||||||
if (rescnt > 0)
|
if (rescnt > 0)
|
||||||
break; /* stop fetching */
|
break; /* stop fetching */
|
||||||
if (!seq->is_cycled)
|
if (!seq->is_cycled)
|
||||||
elog(ERROR, "%s.nextval: reached MINVALUE (" INT64_FORMAT ")",
|
{
|
||||||
sequence->relname, minv);
|
char buf[100];
|
||||||
|
snprintf(buf, 100, INT64_FORMAT, minv);
|
||||||
|
elog(ERROR, "%s.nextval: reached MINVALUE (%s)",
|
||||||
|
sequence->relname, buf);
|
||||||
|
}
|
||||||
next = maxv;
|
next = maxv;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -551,8 +559,14 @@ do_setval(RangeVar *sequence, int64 next, bool iscalled)
|
|||||||
seq = read_info("setval", elm, seqrel, &buf);
|
seq = read_info("setval", elm, seqrel, &buf);
|
||||||
|
|
||||||
if ((next < seq->min_value) || (next > seq->max_value))
|
if ((next < seq->min_value) || (next > seq->max_value))
|
||||||
elog(ERROR, "%s.setval: value " INT64_FORMAT " is out of bounds (" INT64_FORMAT "," INT64_FORMAT ")",
|
{
|
||||||
sequence->relname, next, seq->min_value, seq->max_value);
|
char bufv[100], bufm[100], bufx[100];
|
||||||
|
snprintf(bufv, 100, INT64_FORMAT, next);
|
||||||
|
snprintf(bufm, 100, INT64_FORMAT, seq->min_value);
|
||||||
|
snprintf(bufx, 100, INT64_FORMAT, seq->max_value);
|
||||||
|
elog(ERROR, "%s.setval: value %s is out of bounds (%s,%s)",
|
||||||
|
sequence->relname, bufv, bufm, bufx);
|
||||||
|
}
|
||||||
|
|
||||||
/* save info in local cache */
|
/* save info in local cache */
|
||||||
elm->last = next; /* last returned number */
|
elm->last = next; /* last returned number */
|
||||||
@ -813,8 +827,13 @@ init_params(CreateSeqStmt *seq, Form_pg_sequence new)
|
|||||||
new->min_value = defGetInt64(min_value);
|
new->min_value = defGetInt64(min_value);
|
||||||
|
|
||||||
if (new->min_value >= new->max_value)
|
if (new->min_value >= new->max_value)
|
||||||
elog(ERROR, "DefineSequence: MINVALUE (" INT64_FORMAT ") can't be >= MAXVALUE (" INT64_FORMAT ")",
|
{
|
||||||
new->min_value, new->max_value);
|
char bufm[100], bufx[100];
|
||||||
|
snprintf(bufm, 100, INT64_FORMAT, new->min_value);
|
||||||
|
snprintf(bufx, 100, INT64_FORMAT, new->max_value);
|
||||||
|
elog(ERROR, "DefineSequence: MINVALUE (%s) must be less than MAXVALUE (%s)",
|
||||||
|
bufm, bufx);
|
||||||
|
}
|
||||||
|
|
||||||
if (last_value == (DefElem *) NULL) /* START WITH */
|
if (last_value == (DefElem *) NULL) /* START WITH */
|
||||||
{
|
{
|
||||||
@ -827,17 +846,31 @@ init_params(CreateSeqStmt *seq, Form_pg_sequence new)
|
|||||||
new->last_value = defGetInt64(last_value);
|
new->last_value = defGetInt64(last_value);
|
||||||
|
|
||||||
if (new->last_value < new->min_value)
|
if (new->last_value < new->min_value)
|
||||||
elog(ERROR, "DefineSequence: START value (" INT64_FORMAT ") can't be < MINVALUE (" INT64_FORMAT ")",
|
{
|
||||||
new->last_value, new->min_value);
|
char bufs[100], bufm[100];
|
||||||
|
snprintf(bufs, 100, INT64_FORMAT, new->last_value);
|
||||||
|
snprintf(bufm, 100, INT64_FORMAT, new->min_value);
|
||||||
|
elog(ERROR, "DefineSequence: START value (%s) can't be less than MINVALUE (%s)",
|
||||||
|
bufs, bufm);
|
||||||
|
}
|
||||||
if (new->last_value > new->max_value)
|
if (new->last_value > new->max_value)
|
||||||
elog(ERROR, "DefineSequence: START value (" INT64_FORMAT ") can't be > MAXVALUE (" INT64_FORMAT ")",
|
{
|
||||||
new->last_value, new->max_value);
|
char bufs[100], bufm[100];
|
||||||
|
snprintf(bufs, 100, INT64_FORMAT, new->last_value);
|
||||||
|
snprintf(bufm, 100, INT64_FORMAT, new->max_value);
|
||||||
|
elog(ERROR, "DefineSequence: START value (%s) can't be greater than MAXVALUE (%s)",
|
||||||
|
bufs, bufm);
|
||||||
|
}
|
||||||
|
|
||||||
if (cache_value == (DefElem *) NULL) /* CACHE */
|
if (cache_value == (DefElem *) NULL) /* CACHE */
|
||||||
new->cache_value = 1;
|
new->cache_value = 1;
|
||||||
else if ((new->cache_value = defGetInt64(cache_value)) <= 0)
|
else if ((new->cache_value = defGetInt64(cache_value)) <= 0)
|
||||||
elog(ERROR, "DefineSequence: CACHE (" INT64_FORMAT ") can't be <= 0",
|
{
|
||||||
new->cache_value);
|
char buf[100];
|
||||||
|
snprintf(buf, 100, INT64_FORMAT, new->cache_value);
|
||||||
|
elog(ERROR, "DefineSequence: CACHE (%s) can't be <= 0",
|
||||||
|
buf);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.26 2002/08/28 20:46:24 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.27 2002/09/03 18:50:54 petere Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -1024,8 +1024,13 @@ _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th)
|
|||||||
die_horribly(AH, modulename, "could not close tar member: %s\n", strerror(errno));
|
die_horribly(AH, modulename, "could not close tar member: %s\n", strerror(errno));
|
||||||
|
|
||||||
if (len != th->fileLen)
|
if (len != th->fileLen)
|
||||||
die_horribly(AH, modulename, "actual file length (" INT64_FORMAT ") does not match expected (" INT64_FORMAT ")\n",
|
{
|
||||||
(int64) len, (int64) th->pos);
|
char buf1[100], buf2[100];
|
||||||
|
snprintf(buf1, 100, INT64_FORMAT, (int64) len);
|
||||||
|
snprintf(buf2, 100, INT64_FORMAT, (int64) th->pos);
|
||||||
|
die_horribly(AH, modulename, "actual file length (%s) does not match expected (%s)\n",
|
||||||
|
buf1, buf2);
|
||||||
|
}
|
||||||
|
|
||||||
pad = ((len + 511) & ~511) - len;
|
pad = ((len + 511) & ~511) - len;
|
||||||
for (i = 0; i < pad; i++)
|
for (i = 0; i < pad; i++)
|
||||||
@ -1055,14 +1060,21 @@ _tarPositionTo(ArchiveHandle *AH, const char *filename)
|
|||||||
/* Go to end of current file, if any */
|
/* Go to end of current file, if any */
|
||||||
if (ctx->tarFHpos != 0)
|
if (ctx->tarFHpos != 0)
|
||||||
{
|
{
|
||||||
ahlog(AH, 4, "moving from position " INT64_FORMAT " to next member at file position " INT64_FORMAT "\n",
|
char buf1[100], buf2[100];
|
||||||
(int64) ctx->tarFHpos, (int64) ctx->tarNextMember);
|
snprintf(buf1, 100, INT64_FORMAT, (int64) ctx->tarFHpos);
|
||||||
|
snprintf(buf2, 100, INT64_FORMAT, (int64) ctx->tarNextMember);
|
||||||
|
ahlog(AH, 4, "moving from position %s to next member at file position %s\n",
|
||||||
|
buf1, buf2);
|
||||||
|
|
||||||
while (ctx->tarFHpos < ctx->tarNextMember)
|
while (ctx->tarFHpos < ctx->tarNextMember)
|
||||||
_tarReadRaw(AH, &c, 1, NULL, ctx->tarFH);
|
_tarReadRaw(AH, &c, 1, NULL, ctx->tarFH);
|
||||||
}
|
}
|
||||||
|
|
||||||
ahlog(AH, 4, "now at file position " INT64_FORMAT "\n", (int64) ctx->tarFHpos);
|
{
|
||||||
|
char buf[100];
|
||||||
|
snprintf(buf, 100, INT64_FORMAT, (int64) ctx->tarFHpos);
|
||||||
|
ahlog(AH, 4, "now at file position %s\n", buf);
|
||||||
|
}
|
||||||
|
|
||||||
/* We are at the start of the file. or at the next member */
|
/* We are at the start of the file. or at the next member */
|
||||||
|
|
||||||
@ -1125,9 +1137,14 @@ _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th)
|
|||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
if (ftello(ctx->tarFH) != ctx->tarFHpos)
|
if (ftello(ctx->tarFH) != ctx->tarFHpos)
|
||||||
|
{
|
||||||
|
char buf1[100], buf2[100];
|
||||||
|
snprintf(buf1, 100, INT64_FORMAT, (int64) ftello(ctx->tarFH));
|
||||||
|
snprintf(buf2, 100, INT64_FORMAT, (int64) ftello(ctx->tarFHpos));
|
||||||
die_horribly(AH, modulename,
|
die_horribly(AH, modulename,
|
||||||
"mismatch in actual vs. predicted file position (" INT64_FORMAT " vs. " INT64_FORMAT ")\n",
|
"mismatch in actual vs. predicted file position (%s vs. %s)\n",
|
||||||
(int64) ftello(ctx->tarFH), (int64) ctx->tarFHpos);
|
buf1, buf2);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Save the pos for reporting purposes */
|
/* Save the pos for reporting purposes */
|
||||||
@ -1170,14 +1187,22 @@ _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th)
|
|||||||
sscanf(&h[124], "%12o", &len);
|
sscanf(&h[124], "%12o", &len);
|
||||||
sscanf(&h[148], "%8o", &sum);
|
sscanf(&h[148], "%8o", &sum);
|
||||||
|
|
||||||
ahlog(AH, 3, "TOC Entry %s at " INT64_FORMAT " (length %lu, checksum %d)\n",
|
{
|
||||||
&tag[0], (int64) hPos, (unsigned long) len, sum);
|
char buf[100];
|
||||||
|
snprintf(buf, 100, INT64_FORMAT, (int64) hPos);
|
||||||
|
ahlog(AH, 3, "TOC Entry %s at %s (length %lu, checksum %d)\n",
|
||||||
|
&tag[0], buf, (unsigned long) len, sum);
|
||||||
|
}
|
||||||
|
|
||||||
if (chk != sum)
|
if (chk != sum)
|
||||||
|
{
|
||||||
|
char buf[100];
|
||||||
|
snprintf(buf, 100, INT64_FORMAT, (int64) ftello(ctx->tarFH));
|
||||||
die_horribly(AH, modulename,
|
die_horribly(AH, modulename,
|
||||||
"corrupt tar header found in %s "
|
"corrupt tar header found in %s "
|
||||||
"(expected %d, computed %d) file position " INT64_FORMAT "\n",
|
"(expected %d, computed %d) file position %s\n",
|
||||||
&tag[0], sum, chk, (int64) ftello(ctx->tarFH));
|
&tag[0], sum, chk, buf);
|
||||||
|
}
|
||||||
|
|
||||||
th->targetFile = strdup(tag);
|
th->targetFile = strdup(tag);
|
||||||
th->fileLen = len;
|
th->fileLen = len;
|
||||||
|
Reference in New Issue
Block a user