citus/src
Onder Kalaci 29ba5a6251
Only change the sequence types if the target column type is a supported sequence type
Before this commit, we erroneously converted the sequence
type to the column's type it is used. However, it is possible
that the sequence is used in an expression which then converted
to a type that cannot be a sequence, such as text.

With this commit, we only try this conversion if the column
type is a supported sequence type (e.g., smallint, int and bigint).

Note that we do this conversion because if the column type is a
bigint and the sequence is NOT a bigint, users would be in trouble
because sequences would generate values that are out of the range
of the column. (The other ways are already not supported such as
the column is int and the sequence is bigint would fail on the worker.)

In other words, with this commit, we scope this optimization only
when the target column type is a supported sequence type. Otherwise,
we let users to more freely use the sequences.

(cherry picked from commit db529facab)

Conflicts:
- src/backend/distributed/commands/create_distributed_table.c
- src/include/distributed/metadata_utility.h
    EnsureSequenceTypeSupported did not have the third parameter prior
	to Citus 11. I removed the references to ownerRelationId.

- src/test/regress/multi_schedule

    Trivial conflict for the newly introduced test files. This conflict
    was easy to resolve, but I modified the tests to prevent failures
    due to the following:

	a) MX is not on by default on 10.2 contrary to Citus 11
	b) We set replication factor = 2 here contrary to 1 in Citus 11
2022-03-17 00:42:12 +03:00
..
backend Only change the sequence types if the target column type is a supported sequence type 2022-03-17 00:42:12 +03:00
include Only change the sequence types if the target column type is a supported sequence type 2022-03-17 00:42:12 +03:00
test Only change the sequence types if the target column type is a supported sequence type 2022-03-17 00:42:12 +03:00