Commit 0bc1207a authored by Peter Eisentraut's avatar Peter Eisentraut

Fix default minimum value for descending sequences

For some reason that is lost in history, a descending sequence would
default its minimum value to -2^63+1 (-PG_INT64_MAX) instead of
-2^63 (PG_INT64_MIN), even though explicitly specifying a minimum value
of -2^63 would work.  Fix this inconsistency by using the full range by
default.
Reported-by: default avatarDaniel Verite <daniel@manitou-mail.org>
Reviewed-by: default avatarMichael Paquier <michael.paquier@gmail.com>
parent 46d48281
...@@ -133,7 +133,7 @@ SELECT * FROM <replaceable>name</replaceable>; ...@@ -133,7 +133,7 @@ SELECT * FROM <replaceable>name</replaceable>;
the minimum value a sequence can generate. If this clause is not the minimum value a sequence can generate. If this clause is not
supplied or <option>NO MINVALUE</option> is specified, then supplied or <option>NO MINVALUE</option> is specified, then
defaults will be used. The defaults are 1 and defaults will be used. The defaults are 1 and
-2<superscript>63</>-1 for ascending and descending sequences, -2<superscript>63</> for ascending and descending sequences,
respectively. respectively.
</para> </para>
</listitem> </listitem>
......
...@@ -1353,7 +1353,7 @@ init_params(ParseState *pstate, List *options, bool isInit, ...@@ -1353,7 +1353,7 @@ init_params(ParseState *pstate, List *options, bool isInit,
else if (isInit || max_value != NULL) else if (isInit || max_value != NULL)
{ {
if (seqform->seqincrement > 0) if (seqform->seqincrement > 0)
seqform->seqmax = SEQ_MAXVALUE; /* ascending seq */ seqform->seqmax = PG_INT64_MAX; /* ascending seq */
else else
seqform->seqmax = -1; /* descending seq */ seqform->seqmax = -1; /* descending seq */
seqdataform->log_cnt = 0; seqdataform->log_cnt = 0;
...@@ -1370,7 +1370,7 @@ init_params(ParseState *pstate, List *options, bool isInit, ...@@ -1370,7 +1370,7 @@ init_params(ParseState *pstate, List *options, bool isInit,
if (seqform->seqincrement > 0) if (seqform->seqincrement > 0)
seqform->seqmin = 1; /* ascending seq */ seqform->seqmin = 1; /* ascending seq */
else else
seqform->seqmin = SEQ_MINVALUE; /* descending seq */ seqform->seqmin = PG_INT64_MIN; /* descending seq */
seqdataform->log_cnt = 0; seqdataform->log_cnt = 0;
} }
......
...@@ -15876,8 +15876,8 @@ dumpSequence(Archive *fout, TableInfo *tbinfo) ...@@ -15876,8 +15876,8 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
/* Make sure we are in proper schema */ /* Make sure we are in proper schema */
selectSourceSchema(fout, tbinfo->dobj.namespace->dobj.name); selectSourceSchema(fout, tbinfo->dobj.namespace->dobj.name);
snprintf(bufm, sizeof(bufm), INT64_FORMAT, SEQ_MINVALUE); snprintf(bufm, sizeof(bufm), INT64_FORMAT, PG_INT64_MIN);
snprintf(bufx, sizeof(bufx), INT64_FORMAT, SEQ_MAXVALUE); snprintf(bufx, sizeof(bufx), INT64_FORMAT, PG_INT64_MAX);
if (fout->remoteVersion >= 100000) if (fout->remoteVersion >= 100000)
{ {
......
...@@ -50,12 +50,6 @@ ...@@ -50,12 +50,6 @@
*/ */
#define PARTITION_MAX_KEYS 32 #define PARTITION_MAX_KEYS 32
/*
* Set the upper and lower bounds of sequence values.
*/
#define SEQ_MAXVALUE PG_INT64_MAX
#define SEQ_MINVALUE (-SEQ_MAXVALUE)
/* /*
* When we don't have native spinlocks, we use semaphores to simulate them. * When we don't have native spinlocks, we use semaphores to simulate them.
* Decreasing this value reduces consumption of OS resources; increasing it * Decreasing this value reduces consumption of OS resources; increasing it
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment