@ -16843,6 +16843,10 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
* seqtype ;
* seqtype ;
bool cycled ;
bool cycled ;
bool is_ascending ;
bool is_ascending ;
int64 default_minv ,
default_maxv ;
char bufm [ 32 ] ,
bufx [ 32 ] ;
PQExpBuffer query = createPQExpBuffer ( ) ;
PQExpBuffer query = createPQExpBuffer ( ) ;
PQExpBuffer delqry = createPQExpBuffer ( ) ;
PQExpBuffer delqry = createPQExpBuffer ( ) ;
PQExpBuffer labelq = createPQExpBuffer ( ) ;
PQExpBuffer labelq = createPQExpBuffer ( ) ;
@ -16912,40 +16916,41 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
cache = PQgetvalue ( res , 0 , 5 ) ;
cache = PQgetvalue ( res , 0 , 5 ) ;
cycled = ( strcmp ( PQgetvalue ( res , 0 , 6 ) , " t " ) = = 0 ) ;
cycled = ( strcmp ( PQgetvalue ( res , 0 , 6 ) , " t " ) = = 0 ) ;
is_ascending = incby [ 0 ] ! = ' - ' ;
/* Calculate default limits for a sequence of this type */
is_ascending = ( incby [ 0 ] ! = ' - ' ) ;
if ( is_ascending & & atoi ( minv ) = = 1 )
minv = NULL ;
if ( ! is_ascending & & atoi ( maxv ) = = - 1 )
maxv = NULL ;
if ( strcmp ( seqtype , " smallint " ) = = 0 )
if ( strcmp ( seqtype , " smallint " ) = = 0 )
{
{
if ( ! is_ascending & & atoi ( minv ) = = PG_INT16_MIN )
default_minv = is_ascending ? 1 : PG_INT16_MIN ;
minv = NULL ;
default_maxv = is_ascending ? PG_INT16_MAX : - 1 ;
if ( is_ascending & & atoi ( maxv ) = = PG_INT16_MAX )
maxv = NULL ;
}
}
else if ( strcmp ( seqtype , " integer " ) = = 0 )
else if ( strcmp ( seqtype , " integer " ) = = 0 )
{
{
if ( ! is_ascending & & atoi ( minv ) = = PG_INT32_MIN )
default_minv = is_ascending ? 1 : PG_INT32_MIN ;
minv = NULL ;
default_maxv = is_ascending ? PG_INT32_MAX : - 1 ;
if ( is_ascending & & atoi ( maxv ) = = PG_INT32_MAX )
maxv = NULL ;
}
}
else if ( strcmp ( seqtype , " bigint " ) = = 0 )
else if ( strcmp ( seqtype , " bigint " ) = = 0 )
{
{
char bufm [ 100 ] ,
default_minv = is_ascending ? 1 : PG_INT64_MIN ;
bufx [ 100 ] ;
default_maxv = is_ascending ? PG_INT64_MAX : - 1 ;
}
else
{
exit_horribly ( NULL , " unrecognized sequence type: %s \n " , seqtype ) ;
default_minv = default_maxv = 0 ; /* keep compiler quiet */
}
snprintf ( bufm , sizeof ( bufm ) , INT64_FORMAT , PG_INT64_MIN ) ;
/*
snprintf ( bufx , sizeof ( bufx ) , INT64_FORMAT , PG_INT64_MAX ) ;
* 64 - bit strtol ( ) isn ' t very portable , so convert the limits to strings
* and compare that way .
*/
snprintf ( bufm , sizeof ( bufm ) , INT64_FORMAT , default_minv ) ;
snprintf ( bufx , sizeof ( bufx ) , INT64_FORMAT , default_maxv ) ;
if ( ! is_ascending & & strcmp ( minv , bufm ) = = 0 )
/* Don't print minv/maxv if they match the respective default limit */
if ( strcmp ( minv , bufm ) = = 0 )
minv = NULL ;
minv = NULL ;
if ( is_ascending & & strcmp ( maxv , bufx ) = = 0 )
if ( strcmp ( maxv , bufx ) = = 0 )
maxv = NULL ;
maxv = NULL ;
}
/*
/*
* DROP must be fully qualified in case same name appears in pg_catalog
* DROP must be fully qualified in case same name appears in pg_catalog