@@ -706,15 +706,11 @@ nextval_internal(Oid relid, bool check_permissions)
706
706
if (rescnt > 0 )
707
707
break ; /* stop fetching */
708
708
if (!cycle )
709
- {
710
- char buf [100 ];
711
-
712
- snprintf (buf , sizeof (buf ), INT64_FORMAT , maxv );
713
709
ereport (ERROR ,
714
710
(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 )));
718
714
next = minv ;
719
715
}
720
716
else
@@ -729,15 +725,11 @@ nextval_internal(Oid relid, bool check_permissions)
729
725
if (rescnt > 0 )
730
726
break ; /* stop fetching */
731
727
if (!cycle )
732
- {
733
- char buf [100 ];
734
-
735
- snprintf (buf , sizeof (buf ), INT64_FORMAT , minv );
736
728
ereport (ERROR ,
737
729
(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 )));
741
733
next = maxv ;
742
734
}
743
735
else
@@ -975,20 +967,11 @@ do_setval(Oid relid, int64 next, bool iscalled)
975
967
seq = read_seq_tuple (seqrel , & buf , & seqdatatuple );
976
968
977
969
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 );
986
970
ereport (ERROR ,
987
971
(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 )));
992
975
993
976
/* Set the currval() state only if iscalled = true */
994
977
if (iscalled )
@@ -1468,16 +1451,11 @@ init_params(ParseState *pstate, List *options, bool for_identity,
1468
1451
/* Validate maximum value. No need to check INT8 as seqmax is an int64 */
1469
1452
if ((seqform -> seqtypid == INT2OID && (seqform -> seqmax < PG_INT16_MIN || seqform -> seqmax > PG_INT16_MAX ))
1470
1453
|| (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
-
1476
1454
ereport (ERROR ,
1477
1455
(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 ))));
1481
1459
1482
1460
/* MINVALUE (null arg means NO MINVALUE) */
1483
1461
if (min_value != NULL && min_value -> arg )
@@ -1505,30 +1483,19 @@ init_params(ParseState *pstate, List *options, bool for_identity,
1505
1483
/* Validate minimum value. No need to check INT8 as seqmin is an int64 */
1506
1484
if ((seqform -> seqtypid == INT2OID && (seqform -> seqmin < PG_INT16_MIN || seqform -> seqmin > PG_INT16_MAX ))
1507
1485
|| (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
-
1513
1486
ereport (ERROR ,
1514
1487
(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 ))));
1518
1491
1519
1492
/* crosscheck min/max */
1520
1493
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 );
1527
1494
ereport (ERROR ,
1528
1495
(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 )));
1532
1499
1533
1500
/* START WITH */
1534
1501
if (start_value != NULL )
@@ -1545,29 +1512,17 @@ init_params(ParseState *pstate, List *options, bool for_identity,
1545
1512
1546
1513
/* crosscheck START */
1547
1514
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 );
1554
1515
ereport (ERROR ,
1555
1516
(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 )));
1559
1520
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 );
1566
1521
ereport (ERROR ,
1567
1522
(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 )));
1571
1526
1572
1527
/* RESTART [WITH] */
1573
1528
if (restart_value != NULL )
@@ -1587,44 +1542,27 @@ init_params(ParseState *pstate, List *options, bool for_identity,
1587
1542
1588
1543
/* crosscheck RESTART (or current value, if changing MIN/MAX) */
1589
1544
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 );
1596
1545
ereport (ERROR ,
1597
1546
(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 )));
1601
1550
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 );
1608
1551
ereport (ERROR ,
1609
1552
(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 )));
1613
1556
1614
1557
/* CACHE */
1615
1558
if (cache_value != NULL )
1616
1559
{
1617
1560
seqform -> seqcache = defGetInt64 (cache_value );
1618
1561
if (seqform -> seqcache <= 0 )
1619
- {
1620
- char buf [100 ];
1621
-
1622
- snprintf (buf , sizeof (buf ), INT64_FORMAT , seqform -> seqcache );
1623
1562
ereport (ERROR ,
1624
1563
(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 )));
1628
1566
seqdataform -> log_cnt = 0 ;
1629
1567
}
1630
1568
else if (isInit )
0 commit comments