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

Fill RDB$FIELDS.RDB$COMPUTED_SOURCE for view fields [CORE6179] #2286

Open
firebird-automations opened this issue Nov 1, 2019 · 2 comments
Open

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: Valdir Stiebe Junior (ogecrom)

Votes: 2

Every RDB$FIELDS.RDB$COMPUTED_SOURCE are null except for the ones from table computed fields.
Views with subqueries or expressions as fields should also have the correct computed source.

I've found this because I would like to pinpoint fields from views and try to execute statement the view source with only selected fields.

This is the sql query I was trying to build.

select
RF.RDB$FIELD_POSITION,
coalesce(trim(VR.RDB$CONTEXT_NAME) || '.' || trim(RF.RDB$BASE_FIELD), F.RDB$COMPUTED_SOURCE)
from
RDB$RELATION_FIELDS RF left join
RDB$VIEW_RELATIONS VR on RF.RDB$RELATION_NAME = VR.RDB$VIEW_NAME and RF.RDB$VIEW_CONTEXT = VR.RDB$VIEW_CONTEXT left join
RDB$FIELDS F on F.RDB$FIELD_NAME = RF.RDB$FIELD_SOURCE
where
RF.RDB$RELATION_NAME = 'VIEW_NAME'
order by
RF.RDB$FIELD_POSITION

@firebird-automations
Copy link
Collaborator Author

Commented by: F.D.Castel (fdcastel)

I did like the idea of having access to the view column source. However, I don't know if RDB$COMPUTED_SOURCE would be the best place for it.

Alternative suggestion: to add a new RDB$VIEW_SOURCE column into RDB$FIELDS. Only used for view fields.

This way we could keep the RDB$COMPUTED_SOURCE and RDB$COMPUTED_BLR fields just for COMPUTED BY fields.

@firebird-automations
Copy link
Collaborator Author

Commented by: @dyemanov

System tables are for the engine to operate and for extracting the source code as DDL. These tasks work fine without this new feature. So far I don't see any good rationale why this is necessary.

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

1 participant