babelfish_extensions icon indicating copy to clipboard operation
babelfish_extensions copied to clipboard

[Bug]: can not alter table

Open killerwzb opened this issue 6 months ago • 2 comments

What happened?

Hi

I ran the following SQL, but I got an error message. However, these SQL statements can be executed normally in SQL Server.

create table test(a nvarchar(10),b int);

create view v_test as select * from test;

alter table test alter column a nvarchar(20);

message: can not alter type of a column used by a view or rule

Version

BABEL_5_X_DEV (Default)

Extension

None

Which flavor of Linux are you using when you see the bug?

No response

Relevant log output


Code of Conduct

  • [x] I agree to follow this project's Code of Conduct.

killerwzb avatar Jun 12 '25 13:06 killerwzb

PostgreSQL only supports what SQL Server would call WITH SCHEMABINDING. So a T-SQL view that is not specifying the SCHEMABINDING keyword is created as if SCHEMABINDING was specified (the Compass report indicates this). This aspect of T-SQL has not yet been addressed by Babelfish.

robverschoor avatar Jun 12 '25 14:06 robverschoor

We did add a limited support for weak binded views in babelfish https://github.com/babelfish-for-postgresql/babelfish_extensions/commit/012882bd4265f35394342d4edcd6629b5e9095c3

In future we could support ALTER TABLE ALTER COLUMN when columns have dependant weak views.

tanscorpio7 avatar Aug 29 '25 10:08 tanscorpio7