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

INSTEAD OF triggers for views [CORE1210] #1634

Open
firebird-automations opened this issue Apr 17, 2007 · 4 comments
Open

INSTEAD OF triggers for views [CORE1210] #1634

firebird-automations opened this issue Apr 17, 2007 · 4 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: Alexander Tyutik (tut)

Is related to CORE1157

I propose to change current trigger logic for views on next one:

1) Each view can have one and only one INSTEAD OF trigger
2) If view is updatable by default than INSTEAD OF trigger will override default behavior
3) If trigger is not updatable by default than INSTEAD OF trigger makes it updatable
4) BEFORE and AFTER triggers allowed for updatable views only
5) Logic for BEFORE/AFTER triggers same as logic for such triggers on tables (they should not have INSTEAD OF behavior as it exists now)

@firebird-automations
Copy link
Collaborator Author

Commented by: Sean Leyne (seanleyne)

This change would seem to create a significant problem for existing applications/systems.

Please explain why the proposed change is necessary (providing examples of why the current approach is deficient).

@firebird-automations
Copy link
Collaborator Author

Commented by: Alexander Tyutik (tut)

> This change would seem to create a significant problem for existing applications/systems.

This problem can be solved simple way: when restoring for old ODS server should create empty INSTEAD OF trigger for each view.

> Please explain why the proposed change is necessary (providing examples of why the current approach is deficient).

It is very long story to explain why :-( But i'll try (sorry for my bad english).

What we have now? Now we have next problems:

When a man read command CREATE BEFORE/AFTER TRIGGER what will hi think? I think that this trigger executes BEFORE of AFTER command which i run for a view. But here we have a few problems:

1) Where is a time point of command? How can i define when it was "before" and when main command action was done and when it was "after"? I should open each trigger and look at it for this. It is not clear logic, so i think it is bad.

2) I run one command, for example INSERT. In current implementation i can write 512 triggers and all of them will run instead of my INSERT command. This is very very strange. Imagine that you defined virtual method in C++ (equal to our INSERT command). How can you override it by 512 different methods in same time in descendant class? It sounds silly. But in FB it is possible. So i think it is incorrect and server should allow to create only one INSTEAD OF trigger which will override standard behavior.

3) What if you have simple view like CREATE VIEW MY_VIEW AS SELECT * FROM MY_TABLE and you want to add trigger logic on a view only, not on table. For example you want to set default value to fiend in BEFORE trigger on view. But in current implementation this trigger will discard default insert and you should manually write INSERT INTO MY_TABLE command in this trigger. But you want to have standart automatic behavior and don't want your trigger discard it and you don't want to write insert command manually. But it is impossible in current implementation, so it is bad.

4) Triggers for views have same syntax as triggers for tables, but have different behavior (see 3). This is additional source of problems, so i think it is bad.

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

Link: This issue is related to CORE1157 [ CORE1157 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

Workflow: jira [ 11882 ] => Firebird [ 15545 ]

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