erlangbureau / jamdb_oracle

Oracle Database driver for Erlang
MIT License
106 stars 48 forks source link

Inconsistency when creating indices with a prefix #166

Closed dfrese closed 10 months ago

dfrese commented 1 year ago

The 'create index' migration with a prefix: mike option emits a statement like

create index tab_col on mike.tab (col)

but dropping it emits

drop index mike.tab_col

And depending on the username that is used in the connection, that actually makes a difference. This can cause a 'name already used error', as the index is apparently create under the logged in user, ignoring the prefix:

create index tab_col on mary.tab (col)
create index tab_col on mike.tab (col)   -- fails

I suggest to add the prefix like so

create index mike.tab_col on mike.tab (col)

In jamdb_oracle_sql.ex that is easily done by

quote_name(index.name)

=>

quote_table(index.prefix, index.name)

both in execute_ddl for the Index :create, and for the Index :rename case.

That would make it consistent with drop index and also avoid the name clash.

vstavskyi commented 1 year ago

fixed

dfrese commented 1 year ago

Are you sure it's not needed for alter/rename index (and alter/rename table for that matter)?

vstavskyi commented 1 year ago

I'm sure about rename ORA-01765: specifying owner's name of the table is not allowed