postgres icon indicating copy to clipboard operation
postgres copied to clipboard

add USING ?::? to `AlterColumn`

Open warren830 opened this issue 3 years ago • 4 comments

What did this pull request do?

Add USING ?::? to AlterColumn Without this, it will report error as I described in the issue #104

User Case Description

We used migrator to change column data type

warren830 avatar May 09 '22 09:05 warren830

LGTM if column without default value. Maybe we need to add conditions, use Using when no implicit (automatic) cast and change the defalut value

Sounds great, I will modify it and submit again

warren830 avatar May 10 '22 03:05 warren830

I did some shallow research, it's hard to add conditions. Cause there are too many data types. time <-> varchar, int <-> varchar longtext <-> int, varchar and so on

warren830 avatar May 10 '22 06:05 warren830

I don't know whether Using has side effects. If not, we can drop default value first when type changes and add it after completion. We can also judge whether to execute the above process through the error code.

a631807682 avatar May 10 '22 07:05 a631807682

I don't know whether Using has side effects. If not, we can drop default value first when type changes and add it after completion. We can also judge whether to execute the above process through the error code.

It's a better way to execute the above process according to the error code. If it's ok, I can do it

warren830 avatar May 11 '22 00:05 warren830

it is still broken. if the column is of part of the partition definition you'll get ERROR: cannot alter type of column named in partition key (SQLSTATE 42P16)

Gilwe avatar Sep 12 '22 11:09 Gilwe