@@ -706,15 +706,11 @@ nextval_internal(Oid relid, bool check_permissions)
706706 if (rescnt > 0 )
707707 break ; /* stop fetching */
708708 if (!cycle )
709- {
710- char buf [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- char buf [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- char bufv [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- char bufx [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- char bufm [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- char bufm [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- char bufs [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- char bufs [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- char bufs [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- char bufs [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- char buf [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 else if (isInit )
0 commit comments