mirror of https://github.com/citusdata/citus.git
Use new sequence struct field names
Bizarrely, PostgreSQL 10 renames all of Form_pg_sequence's fields.pull/1439/head
parent
aba4f2eff3
commit
3ca189ce08
|
@ -193,10 +193,18 @@ pg_get_sequencedef_string(Oid sequenceRelationId)
|
||||||
|
|
||||||
/* build our DDL command */
|
/* build our DDL command */
|
||||||
qualifiedSequenceName = generate_relation_name(sequenceRelationId, NIL);
|
qualifiedSequenceName = generate_relation_name(sequenceRelationId, NIL);
|
||||||
|
|
||||||
|
#if (PG_VERSION_NUM >= 100000)
|
||||||
|
sequenceDef = psprintf(CREATE_SEQUENCE_COMMAND, qualifiedSequenceName,
|
||||||
|
pgSequenceForm->seqincrement, pgSequenceForm->seqmin,
|
||||||
|
pgSequenceForm->seqmax, pgSequenceForm->seqstart,
|
||||||
|
pgSequenceForm->seqcycle ? "" : "NO ");
|
||||||
|
#else
|
||||||
sequenceDef = psprintf(CREATE_SEQUENCE_COMMAND, qualifiedSequenceName,
|
sequenceDef = psprintf(CREATE_SEQUENCE_COMMAND, qualifiedSequenceName,
|
||||||
pgSequenceForm->increment_by, pgSequenceForm->min_value,
|
pgSequenceForm->increment_by, pgSequenceForm->min_value,
|
||||||
pgSequenceForm->max_value, pgSequenceForm->start_value,
|
pgSequenceForm->max_value, pgSequenceForm->start_value,
|
||||||
pgSequenceForm->is_cycled ? "" : "NO ");
|
pgSequenceForm->is_cycled ? "" : "NO ");
|
||||||
|
#endif
|
||||||
|
|
||||||
return sequenceDef;
|
return sequenceDef;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1355,6 +1355,14 @@ AlterSequenceMinMax(Oid sequenceId, char *schemaName, char *sequenceName)
|
||||||
Form_pg_sequence sequenceData = pg_get_sequencedef(sequenceId);
|
Form_pg_sequence sequenceData = pg_get_sequencedef(sequenceId);
|
||||||
int64 startValue = 0;
|
int64 startValue = 0;
|
||||||
int64 maxValue = 0;
|
int64 maxValue = 0;
|
||||||
|
#if (PG_VERSION_NUM >= 100000)
|
||||||
|
int64 sequenceMaxValue = sequenceData->seqmax;
|
||||||
|
int64 sequenceMinValue = sequenceData->seqmin;
|
||||||
|
#else
|
||||||
|
int64 sequenceMaxValue = sequenceData->max_value;
|
||||||
|
int64 sequenceMinValue = sequenceData->min_value;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* calculate min/max values that the sequence can generate in this worker */
|
/* calculate min/max values that the sequence can generate in this worker */
|
||||||
startValue = (((int64) GetLocalGroupId()) << 48) + 1;
|
startValue = (((int64) GetLocalGroupId()) << 48) + 1;
|
||||||
|
@ -1365,7 +1373,7 @@ AlterSequenceMinMax(Oid sequenceId, char *schemaName, char *sequenceName)
|
||||||
* their correct values. This happens when the sequence has been created
|
* their correct values. This happens when the sequence has been created
|
||||||
* during shard, before the current worker having the metadata.
|
* during shard, before the current worker having the metadata.
|
||||||
*/
|
*/
|
||||||
if (sequenceData->min_value != startValue || sequenceData->max_value != maxValue)
|
if (sequenceMinValue != startValue || sequenceMaxValue != maxValue)
|
||||||
{
|
{
|
||||||
StringInfo startNumericString = makeStringInfo();
|
StringInfo startNumericString = makeStringInfo();
|
||||||
StringInfo maxNumericString = makeStringInfo();
|
StringInfo maxNumericString = makeStringInfo();
|
||||||
|
|
Loading…
Reference in New Issue