Bug 145186 - Base Form can not access hidden filtered table when 'Content type' is a table and form is set "Analyze SQL" → 'yes'
Summary: Base Form can not access hidden filtered table when 'Content type' is a table...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
6.4.7.2 release
Hardware: x86-64 (AMD64) All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-10-17 15:03 UTC by intmail01
Modified: 2023-10-19 10:15 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
Table missing error message (14.58 KB, image/png)
2021-10-17 15:08 UTC, intmail01
Details
Open the different forms. Form connected to table with "Analyze SQL - Yes" don't find the table. (73.49 KB, application/vnd.oasis.opendocument.database)
2021-10-17 16:06 UTC, Robert Großkopf
Details
bt with debug symbols (10.11 KB, text/plain)
2021-10-18 17:38 UTC, Julien Nabet
Details

Note You need to log in before you can comment on or make changes to this bug.
Description intmail01 2021-10-17 15:03:55 UTC
Description:
When I hide a table with the menu Tools > Table Filter then any query based on this table can always access it.
But with Form it shows an error message when 'Content type' is a Table based on the hidden one.
It is good thing to let Form to access an hidden table like in query.
(When doing tests please save, close then re-open the .odb file)


Steps to Reproduce:
1.Hide the table with menu Tools > Table Filter
2.Save the file, close, then reopen it
2.Open the form
3.An error message box is displayed

Actual Results:
Error message box

Expected Results:
No error


Reproducible: Always


User Profile Reset: Yes


OpenGL enabled: Yes

Additional Info:
Version: 7.0.6.2
Build ID: 144abb84a525d8e30c9dbbefa69cbbf2d8d4ae3b
CPU threads: 4; OS: Linux 4.19; UI render: default; VCL: gtk3
Locale: fr-FR (en_US); UI: en-US
Calc: threaded
Comment 1 intmail01 2021-10-17 15:08:21 UTC
Created attachment 175794 [details]
Table missing error message
Comment 2 Robert Großkopf 2021-10-17 16:06:45 UTC
Created attachment 175795 [details]
Open the different forms. Form connected to table with "Analyze SQL - Yes" don't find the table.

Have tested it with different forms.
Only the form, which is linked to a table and is set to "Analyze SQL → 'Yes'" shows an error.
All other forms will show the content. 
But: All other forms will only show the content. The content is write protected.

I would prefer to show a warning "content is write protected, because table is hidden" or something else. And then: Open the form in write protected mode.

My system: OpenSUSE 15.2 64bit rpm Linux.

Tested with different versions of LO, fails in LO 7.2.2.2, also in LO 6.4.7.2. Could be a bug introduced by OOo.
Comment 3 intmail01 2021-10-17 16:46:37 UTC
For my usage the write protection is not good idea. The goal is not to prevent table modification because this can be done on the server.
The fact to hide a table is just for good looking and good design for the user working space on the screen, then display only  essential tables. It help user to not have to navigate through too many table structure.

Thanks for all.
Comment 4 Robert Großkopf 2021-10-17 17:10:37 UTC
(In reply to intmail01 from comment #3)
> For my usage the write protection is not good idea. The goal is not to
> prevent table modification because this can be done on the server.

You are right. Hiding tables in Base is only for good looking - couldn't be protected. But for this moment all queries will show a hidden table also write protected. So this bug is: Show also the table write protected in a form.

An enhancement would be: Don't set a table write protected, if it is only set unvisible in Base.
Comment 5 Alex Thurgood 2021-10-18 09:04:21 UTC
It all comes down to what people expect when they mark the table as excluded from display in the list of tables.

On the one hand, it could be argued marking a table as filtered, which is something usually an admin would do, should work to completely make that table unaccessible to any user within the Base UI space.

On the other hand, it could also be argued that the Base UI should be capable of managing the user determined rights to see and/or interact with any table that the DBA has authorised.

Clearly, the current filter mechanism doesn't do either of these completely.
Comment 6 Alex Thurgood 2021-10-18 09:05:26 UTC
Adding Julien and Lionel for their input, if they wish to comment.
Comment 7 Julien Nabet 2021-10-18 17:38:53 UTC
Created attachment 175822 [details]
bt with debug symbols

On pc Debian x86-64 with master sources updated today, I had the error message.
I noticed this log on console:
warn:connectivity.parse:11353:11353:connectivity/source/parse/sqliterator.cxx:2024: Adding error com.sun.star.sdbc.SQLException message: The database does contain neither a table nor a query named "starter". /home/julien/lo/libreoffice/connectivity/source/parse/sqliterator.cxx:2017 SQLState: HY000 ErrorCode: 1000

So I retrieved a bt from this part.
Comment 8 Julien Nabet 2021-10-18 17:42:09 UTC
I got the same log with Form_Source_Table so not relevant.
Comment 9 Julien Nabet 2021-10-18 17:53:26 UTC
The difference is in this part:
   2319     switch (m_nCommandType)
   2320     {
   2321         case CommandType::TABLE:
   2322         {
   2323             impl_resetTables_nothrow();
   2324             if ( bDoEscapeProcessing )
   2325             {
   2326                 Reference< XNameAccess > xTables( impl_getTables_throw() );
   2327                 if ( xTables->hasByName(m_aCommand) )
   2328                 {
   2329                 }
   2330                 else
   2331                 {
   2332                     OUString sMessage( DBA_RES( RID_STR_TABLE_DOES_NOT_EXIST ) );
   2333                     throwGenericSQLException(sMessage.replaceAll( "$table$", m_aCommand ),*this);
   2334                 }
   2335             }
   2336             else
   2337             {
   2338                 sCommand = "SELECT * FROM ";
   2339                 OUString sCatalog, sSchema, sTable;
   2340                 ::dbtools::qualifiedNameComponents( m_xActiveConnection->getMetaData(), m_aCommand, sCatalog, sSchema, sTable, ::dbtools::EComposeRule::InDataManipulation );
   2341                 sCommand += ::dbtools::composeTableNameForSelect( m_xActiveConnection, sCatalog, sSchema, sTable );
   2342             }
   2343         }

With SQL Analyze at no, LO goes into "else" from line 2336
with SQL Analyze at yes, LO goes into "if" from line 2324 and since "starter" isn't found, it throws at line 2333

(see https://opengrok.libreoffice.org/xref/core/dbaccess/source/core/api/RowSet.cxx?r=c7f8a54e#2324)
Comment 10 Julien Nabet 2021-10-18 18:12:50 UTC
Now about the functional, I don't know at all what should be expected or not.
Comment 11 Robert Großkopf 2021-10-18 18:43:23 UTC
(In reply to Julien Nabet from comment #9)

>    2327                 if ( xTables->hasByName(m_aCommand) )

Seems the table isn't only hidden. It has been pushed somewhere else and doesn't exist for the code "hasByName"

When I have a look with xray:
The tables should be read from oDatabaseDocument.Datasource.Tables.ElementNames or oDatabaseDocument.Datasource.Tables.hasByName

Seems it is looking also at DatasSource.TableFilter, which will show the names of the tables, which aren't hidden.
Comment 12 QA Administrators 2023-10-19 03:15:16 UTC Comment hidden (obsolete)
Comment 13 Robert Großkopf 2023-10-19 06:35:01 UTC
Buggy behavior still exists in LO 7.6.2.1 on OpenSUSE 15.4 64bit rpm Linux.

1. If a table is hidden by Tools → Tablefilter a form couldn't connect directly to the table. But a query could connect and a form connecting to a query or SQL-code could connect also. This different behavior is a bug.

2. What do we expect? I expect: Hiding a table should be only hide the table and nothing else. It shouldn't write protect the table, it shouldn't report this table doesn't exist.

With this expected behavior there are 2 bugs: 
1. Every contact to the table should give the same behavior.
2. Hidden tables are only hidden and no other "feature" (like "not exists" or "write protected") has to be added.
Comment 14 Alex Thurgood 2023-10-19 10:15:41 UTC
(In reply to Robert Großkopf from comment #13)
> Buggy behavior still exists in LO 7.6.2.1 on OpenSUSE 15.4 64bit rpm Linux.
> 
> 1. If a table is hidden by Tools → Tablefilter a form couldn't connect
> directly to the table. But a query could connect and a form connecting to a
> query or SQL-code could connect also. This different behavior is a bug.
> 
> 2. What do we expect? I expect: Hiding a table should be only hide the table
> and nothing else. It shouldn't write protect the table, it shouldn't report
> this table doesn't exist.
> 

@Robert : I would agree with you. The current approach is inconsistent. Hiding a table, or rather filtering a table from the list visible to the user shouldn't prevent a form configured to analyse SQL relating to that table if we accept that a query to that table will still function, and a form, based on that query, is still functional.