8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $Header: /cvsroot/pgsql/src/backend/commands/sequence.c,v 1.85 2002/08/30 19:23:19 tgl Exp $
11
+ * $Header: /cvsroot/pgsql/src/backend/commands/sequence.c,v 1.86 2002/09/03 18:50:54 petere Exp $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
@@ -400,8 +400,12 @@ nextval(PG_FUNCTION_ARGS)
400
400
if (rescnt > 0 )
401
401
break ; /* stop fetching */
402
402
if (!seq -> is_cycled )
403
- elog (ERROR , "%s.nextval: reached MAXVALUE (" INT64_FORMAT ")" ,
404
- sequence -> relname , maxv );
403
+ {
404
+ char buf [100 ];
405
+ snprintf (buf , 100 , INT64_FORMAT , maxv );
406
+ elog (ERROR , "%s.nextval: reached MAXVALUE (%s)" ,
407
+ sequence -> relname , buf );
408
+ }
405
409
next = minv ;
406
410
}
407
411
else
@@ -416,8 +420,12 @@ nextval(PG_FUNCTION_ARGS)
416
420
if (rescnt > 0 )
417
421
break ; /* stop fetching */
418
422
if (!seq -> is_cycled )
419
- elog (ERROR , "%s.nextval: reached MINVALUE (" INT64_FORMAT ")" ,
420
- sequence -> relname , minv );
423
+ {
424
+ char buf [100 ];
425
+ snprintf (buf , 100 , INT64_FORMAT , minv );
426
+ elog (ERROR , "%s.nextval: reached MINVALUE (%s)" ,
427
+ sequence -> relname , buf );
428
+ }
421
429
next = maxv ;
422
430
}
423
431
else
@@ -551,8 +559,14 @@ do_setval(RangeVar *sequence, int64 next, bool iscalled)
551
559
seq = read_info ("setval" , elm , seqrel , & buf );
552
560
553
561
if ((next < seq -> min_value ) || (next > seq -> max_value ))
554
- elog (ERROR , "%s.setval: value " INT64_FORMAT " is out of bounds (" INT64_FORMAT "," INT64_FORMAT ")" ,
555
- sequence -> relname , next , seq -> min_value , seq -> max_value );
562
+ {
563
+ char bufv [100 ], bufm [100 ], bufx [100 ];
564
+ snprintf (bufv , 100 , INT64_FORMAT , next );
565
+ snprintf (bufm , 100 , INT64_FORMAT , seq -> min_value );
566
+ snprintf (bufx , 100 , INT64_FORMAT , seq -> max_value );
567
+ elog (ERROR , "%s.setval: value %s is out of bounds (%s,%s)" ,
568
+ sequence -> relname , bufv , bufm , bufx );
569
+ }
556
570
557
571
/* save info in local cache */
558
572
elm -> last = next ; /* last returned number */
@@ -813,8 +827,13 @@ init_params(CreateSeqStmt *seq, Form_pg_sequence new)
813
827
new -> min_value = defGetInt64 (min_value );
814
828
815
829
if (new -> min_value >= new -> max_value )
816
- elog (ERROR , "DefineSequence: MINVALUE (" INT64_FORMAT ") can't be >= MAXVALUE (" INT64_FORMAT ")" ,
817
- new -> min_value , new -> max_value );
830
+ {
831
+ char bufm [100 ], bufx [100 ];
832
+ snprintf (bufm , 100 , INT64_FORMAT , new -> min_value );
833
+ snprintf (bufx , 100 , INT64_FORMAT , new -> max_value );
834
+ elog (ERROR , "DefineSequence: MINVALUE (%s) must be less than MAXVALUE (%s)" ,
835
+ bufm , bufx );
836
+ }
818
837
819
838
if (last_value == (DefElem * ) NULL ) /* START WITH */
820
839
{
@@ -827,17 +846,31 @@ init_params(CreateSeqStmt *seq, Form_pg_sequence new)
827
846
new -> last_value = defGetInt64 (last_value );
828
847
829
848
if (new -> last_value < new -> min_value )
830
- elog (ERROR , "DefineSequence: START value (" INT64_FORMAT ") can't be < MINVALUE (" INT64_FORMAT ")" ,
831
- new -> last_value , new -> min_value );
849
+ {
850
+ char bufs [100 ], bufm [100 ];
851
+ snprintf (bufs , 100 , INT64_FORMAT , new -> last_value );
852
+ snprintf (bufm , 100 , INT64_FORMAT , new -> min_value );
853
+ elog (ERROR , "DefineSequence: START value (%s) can't be less than MINVALUE (%s)" ,
854
+ bufs , bufm );
855
+ }
832
856
if (new -> last_value > new -> max_value )
833
- elog (ERROR , "DefineSequence: START value (" INT64_FORMAT ") can't be > MAXVALUE (" INT64_FORMAT ")" ,
834
- new -> last_value , new -> max_value );
857
+ {
858
+ char bufs [100 ], bufm [100 ];
859
+ snprintf (bufs , 100 , INT64_FORMAT , new -> last_value );
860
+ snprintf (bufm , 100 , INT64_FORMAT , new -> max_value );
861
+ elog (ERROR , "DefineSequence: START value (%s) can't be greater than MAXVALUE (%s)" ,
862
+ bufs , bufm );
863
+ }
835
864
836
865
if (cache_value == (DefElem * ) NULL ) /* CACHE */
837
866
new -> cache_value = 1 ;
838
867
else if ((new -> cache_value = defGetInt64 (cache_value )) <= 0 )
839
- elog (ERROR , "DefineSequence: CACHE (" INT64_FORMAT ") can't be <= 0" ,
840
- new -> cache_value );
868
+ {
869
+ char buf [100 ];
870
+ snprintf (buf , 100 , INT64_FORMAT , new -> cache_value );
871
+ elog (ERROR , "DefineSequence: CACHE (%s) can't be <= 0" ,
872
+ buf );
873
+ }
841
874
842
875
}
843
876
0 commit comments