88 *
99 *
1010 * 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 $
1212 *
1313 *-------------------------------------------------------------------------
1414 */
@@ -400,8 +400,12 @@ nextval(PG_FUNCTION_ARGS)
400400 if (rescnt > 0 )
401401 break ; /* stop fetching */
402402 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+ }
405409 next = minv ;
406410 }
407411 else
@@ -416,8 +420,12 @@ nextval(PG_FUNCTION_ARGS)
416420 if (rescnt > 0 )
417421 break ; /* stop fetching */
418422 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+ }
421429 next = maxv ;
422430 }
423431 else
@@ -551,8 +559,14 @@ do_setval(RangeVar *sequence, int64 next, bool iscalled)
551559 seq = read_info ("setval" , elm , seqrel , & buf );
552560
553561 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+ }
556570
557571 /* save info in local cache */
558572 elm -> last = next ; /* last returned number */
@@ -813,8 +827,13 @@ init_params(CreateSeqStmt *seq, Form_pg_sequence new)
813827 new -> min_value = defGetInt64 (min_value );
814828
815829 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+ }
818837
819838 if (last_value == (DefElem * ) NULL ) /* START WITH */
820839 {
@@ -827,17 +846,31 @@ init_params(CreateSeqStmt *seq, Form_pg_sequence new)
827846 new -> last_value = defGetInt64 (last_value );
828847
829848 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+ }
832856 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+ }
835864
836865 if (cache_value == (DefElem * ) NULL ) /* CACHE */
837866 new -> cache_value = 1 ;
838867 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+ }
841874
842875}
843876
0 commit comments