Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RDB$VIEW_RELATIONS is not cleaned when altering a view [CORE2202] #2630

Closed
firebird-automations opened this issue Nov 19, 2008 · 12 comments
Closed

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: Alex Bekhtin (afgm)

Is related to QA374

CREATE TABLE TABLE_1 (
ID INTEGER
);

CREATE TABLE TABLE_2 (
ID INTEGER
);

CREATE TABLE TABLE_3 (
ID INTEGER
);
-----------------
CREATE OR ALTER VIEW VW_TABLE(
ID)
AS
select
id
from table_1;

CREATE OR ALTER VIEW VW_TABLE(
ID)
AS
select
id
from table_2;

CREATE OR ALTER VIEW VW_TABLE(
ID)
AS
select
id
from table_3;
-----------------

select * from RDB$VIEW_RELATIONS

============================
RDB$VIEW_NAME RDB$RELATION_NAME RDB$VIEW_CONTEXT RDB$CONTEXT_NAME
VW_TABLE TABLE_1 1 TABLE_1
VW_TABLE TABLE_2 1 TABLE_2
VW_TABLE TABLE_3 1 TABLE_3

Commits: d113151

====== Test Details ======

Changed code to make it independent of system tables content.

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

assignee: Adriano dos Santos Fernandes [ asfernandes ]

@firebird-automations
Copy link
Collaborator Author

Commented by: Sean Leyne (seanleyne)

This is as designed, if you include the RDB$Format column in your select, you will see that each entry has a different value, to represent the different versions of the VIEW/Table which may be in use by connections.

@firebird-automations
Copy link
Collaborator Author

Commented by: @asfernandes

> This is as designed, if you include the RDB$Format column in your select, you will see that each entry has a different value, to represent the different versions of the VIEW/Table which may be in use by connections.
>
I don't think so. Looks like a problem of the new ALTER VIEW. AFAIR, RDB$VIEW_RELATIONS is not used for something very important, so nobody noticed problem. But I'll investigate it.

@firebird-automations
Copy link
Collaborator Author

Commented by: Alex Bekhtin (afgm)

> This is as designed, if you include the RDB$Format column in your select, you will see that each entry has a different value, to represent the different versions of the VIEW/Table which may be in use by connections.
but You can not delete tables table_1 and table_2, because FB sees dependencies.

@firebird-automations
Copy link
Collaborator Author

Commented by: Claudio Valderrama C. (robocop)

This is a bug.
A recreated object must not keep obsolete references. If I use the proposed db, I can do:
SQL> set term ^;
SQL> set list^
SQL> select * from rdb$dependencies^

RDB$DEPENDENT_NAME VW_TABLE
RDB$DEPENDED_ON_NAME TABLE_3
RDB$FIELD_NAME <null>
RDB$DEPENDENT_TYPE 1
RDB$DEPENDED_ON_TYPE 0

RDB$DEPENDENT_NAME VW_TABLE
RDB$DEPENDED_ON_NAME TABLE_3
RDB$FIELD_NAME ID
RDB$DEPENDENT_TYPE 1
RDB$DEPENDED_ON_TYPE 0

As you see, the only dependencies are due to the last definition. Previous definitions can hold the old format, but the new view doesn't have to be tied to objects it doesn't access. After all, if you try to drop the view, you're dropping the current version on disk.

Imagine the same sequence with procedures:

SQL> create procedure p1 as begin end^
SQL> create procedure p21 as begin end^
SQL> create procedure p2 as begin end^
SQL> create procedure p3 as begin end^
SQL> create or alter procedure p as begin execute procedure p1; end^
SQL> create or alter procedure p as begin execute procedure p21; end^
SQL> create or alter procedure p as begin execute procedure p2; end^
SQL> create or alter procedure p as begin execute procedure p3; end^
SQL> commit^
SQL> select * from rdb$dependencies^

RDB$DEPENDENT_NAME P
RDB$DEPENDED_ON_NAME P3
RDB$FIELD_NAME <null>
RDB$DEPENDENT_TYPE 5
RDB$DEPENDED_ON_TYPE 5

At this time, I should be able to drop p1, p21 and p2 and I indeed can do that.

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

summary: do not clean up relations for VIEW => RDB$VIEW_RELATIONS is not cleaned when altering a view

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

Fix Version: 2.5 Beta 1 [ 10251 ]

Version: 2.5 Beta 1 [ 10251 ] =>

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

Link: This issue is related to QA374 [ QA374 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @pcisar

QA test added.

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

status: Resolved [ 5 ] => Closed [ 6 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

status: Closed [ 6 ] => Closed [ 6 ]

QA Status: Done successfully

Test Details: Changed code to make it independent of system tables content.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants