Issue 96716

Summary: writing to a writeable PostgreSQL view does not work
Product: Base Reporter: hjakobs <holger>
Component: codeAssignee: AOO issues mailing list <issues>
Status: CONFIRMED --- QA Contact:
Severity: Trivial    
Priority: P3 CC: issues,
Version: OOo 2.4.1   
Target Milestone: ---   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Latest Confirmation in: ---
Developer Difficulty: ---

Description hjakobs 2008-11-29 20:59:59 UTC
I clearly understand that writing to views - as opposed to tables - can lead to
difficulties and that OOo cannot easily solve these. If a query involving
several tables has been created within OOo it's ok that they are not writeable
because it is impossible to tell which of the joined table the data should go to.

BUT: If a database offers views which are easily writeable because the issue was
solved on the database side by including rules on how to deal with the
situation, OOo Base should not stop the users from taking advantage from this

Views defined in PostgreSQL (or in Oracle, for that matter) show as "tables" in
OOo Base, but have a different icon (containing an arrow). Please refrain from
taking the information that this is a view as a hint that this "table" is not
writeable. The database will complain if it cannot write to it, but it is quite
likely that it will work fine if the view has been set up by a knowledgeable person.

I connected PostgreSQL via JDBC org.postgresql.Driver to OOo Base.

Thank you in advance for understanding the problem. I am sure the person this
issue will be addressed to is in the position to find the position in the big
heap of code where it says 

if (table_type == "view") { deny writing }

and just delete this little piece of bad code from our beloved OOo.

Ust let the database do its job!
Comment 1 2009-06-13 17:51:29 UTC
Checked to see if PostgreSQL itself (natively) can insert into views what is
*NOT* the case. If I am wrong please feel free to correct me.

This is what I did:

demo=# \d packages
                                  Table "public.packages"
  Column  |          Type          |                       Modifiers           
 id       | bigint                 | not null default
 name     | character varying(100) | 
 version  | character varying(20)  | 
 url      | character varying(200) | 
 licenses | character varying(50)  | 
 groups   | character varying(100) | 
 size     | numeric                | 
 idate    | date                   | 
 descr    | text                   |

demo=# create view vw_testqa as SELECT, from packages

demo=# insert into vw_testqa (name) values ('asdasdasd asd');                  
ERROR:  cannot insert into a view
HINT:  You need an unconditional ON INSERT DO INSTEAD rule.

I am not an expert on how the rule system works and neither do I know how
difficult it'd be to implement that in the OOo PSQL driver.

Setting to ENHANC
Comment 2 hjakobs 2009-06-14 15:28:42 UTC
Please note that I wrote "if the view has been set up by a knowledgeable person".

Yes, if you just set up a view without a rule it won't be writable. But since it
is very easy for any PostgreSQL administrator to make certain views writable and
certain views with Oracle are writable without any special treatment, it is
still WRONG that OOo Base as a front end interferes and denies writing to a
writable view.

If a view is actually not writable, which is also very common, OOo Base should
just take the error message from the database system and forward it to the user.

Anything else is bad behaviour.