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
Add before and after "SELECT" trigger [CORE1176] #1598
Comments
Commented by: @dyemanov Isn't a selectable stored procedure good enough for that purpose? |
Commented by: Sean Leyne (seanleyne) This request makes little sense, can you please outline what you are expecting to accomplish with the feature. |
Commented by: maziar (maziar) Dmitry Yemanov: Sean Leyne: |
Commented by: @dyemanov You're wrong about security. If user A is granted to execute a procedure, then all table-level grants should be assigned to the procedure instead of the user. No security hole in this case, as users don't are not allowed to access tables directly. |
Commented by: maziar (maziar) Dmitry Yemanov : |
Commented by: @dyemanov Again, you're wrong. -- connect as SYSDBA create procedure pgr returns (col int) as grant execute on procedure pgr to user A; -- connect as A |
Commented by: maziar (maziar) YES but use each sp for each table is hard to do but event seprate it and more understandable .... |
Modified by: @pcisarWorkflow: jira [ 11710 ] => Firebird [ 15483 ] |
Commented by: Philip Williams (unordained) Possible use: auditing which users have accessed a record (important in the medical field.) Stored procedures could do this, as part of returning rows -- also insert into the audit log. The problem with a stored procedure in this case is that it can't detect and optimize extra "where" clauses: select * from patients where date_of_birth = '1/1/2003'; In this case, the stored procedure (to replace table "patients") would be required to return all patients. It would also mark them all as accessed by the user, even though that's clearly not the case. An "ON SELECT" trigger on the table or view would allow optimization of the WHERE clause, returning only the required rows, and marking only the truly returned rows as accessed. Would this work if joining between a table/view with a trigger, and others? Would it sometimes mark extra rows as accessed, when the query engine simply *had* to filter the rows out after the fact, possibly after retrieving, joining, and transforming them? I would expect edge cases. Another option: always also select a "column" that is the result of a stored procedure (and as of FB 2.5, this could be done in a view.) create procedure access_patient(patient_id integer) returns (x integer) as create view patients2 as Problem: if a user is granted access to patients2, could he avoid logging his access by doing the following? select id, ... ["x" column not included in select list] from patients2; It seems like rdb$db_key is somewhat preserved and silently selected when joining between tables, even if not explicitly selected; if true, could a mechanism be created to look at the "final" select results, and run the on-select triggers for the appropriate tables, based on the actual, visible rdb$db_key values being returned? Any anonymized information (via aggregates, particularly) would not be included, as their db_key values wouldn't be present in the final select. (Again, there would probably be tricks you could use to get around the logging? Casting values a lot? Selecting everything via min() or max(), for one-row queries, where the result is not anonymous, but the db_key is no longer tracked?) In all the scenarios I list, "before" and "after" don't matter. If you're interested in modifying the result of a select to selectively hide field values from some users (null for grunts, non-null for administrators), that can be done in a complex view, and would replace "before select", except for those who would rather not use a view. (Oracle's row/column security effectively acts as a complex view / select trigger that can modify or hide results based on credentials. It's a related technology, at least.) |
Commented by: @livius2 Hi, is this somehow planned? Stored procedures are not able to be optimized by optimizer in joins. This is really usefull feature. In the first step it can be readonly in the next steap i see that this trigger can modify values returned. |
Submitted by: maziar (maziar)
Is duplicated by CORE1929
Votes: 1
the trigger is very nice but seems fix for IB5 to now
but in really in many time is very nice if the same as UPDATE,DELETE,INSERT trigger, i have SELECT (before & after) select trigger is major update and extend ability of FB
is critically for many use specially for user & security control
The text was updated successfully, but these errors were encountered: