Bug 154037 - MySQL/MariaDB direct connection: Deleted tables won't be deleted in content.xml, when deleted directly in MySQL
Summary: MySQL/MariaDB direct connection: Deleted tables won't be deleted in content.x...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
7.5.1.2 release
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Database-Tables
  Show dependency treegraph
 
Reported: 2023-03-07 08:23 UTC by Robert Großkopf
Modified: 2023-05-23 07:40 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Großkopf 2023-03-07 08:23:09 UTC
Open a database file, which connects directly to a MySQL/MariaDB database.
Create a new table in Base.
Close the connection.
Open another connection to MySQL/MariaDB - tested here with phpMyAdmin.
Delete the table, which you have created new in Base.
Now open the Base file again.

Create a macro like this:
SUB Tables
	oDB = ThisDatabaseDocument.DataSource
	oTables = oDB.getTables()
	DIM stTablenames() AS STRING
	stTablenames = oTables.getElementNames	
END SUB
Start the macro watching stTablenames (step by step)
You will get a list of all tables - including the table, which is deleted and won't be shown any more in Base GUI.
Macro will only read all tables out of content.xml in Base file. Tables, which are created directly in MySQL, not by Base GUI, won't be shown there up to the moment you open this tables and use this tables for input new data or something else.

For external databases Base should refresh the list of tables when connecting to the database. The shown tables shouldn't contain tables, which doesn't exist any more. The shown tables should contain all tables, which exist.

Entries in content.xml might be used for formatting of cells of the table, so this entries should be deleted by default.
Comment 1 Stang 2023-03-08 16:30:16 UTC
Have confirmed this with:

Version: 7.5.1.2 (X86_64) / LibreOffice Community
Build ID: fcbaee479e84c6cd81291587d2ee68cba099e129
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded

Also noted this occurs with PostgreSQL.
Comment 2 flywire 2023-04-15 01:52:45 UTC
https://ask.libreoffice.org/t/possible-synch-error-between-mysql-and-base/88846/14

> AndrewBase 2.2.4 speaks precisely about this issue. There is a workaround listed > there, which I have slightly modified, and it seems to be working just fine:

sub refreshTables()
dim dbURL as string: dbURL = ConvertToURL(“C:\filename.odb”)
dim oBaseContext as object: oBaseContext = CreateUnoService(“com.sun.star.sdb.DatabaseContext”)
dim oDB as object: oDB = oBaseContext.getByName(dbURL)
dim oDoc as object: oDoc = oDB.DatabaseDocument
dim oDisp as object: oDisp = createUnoService(“com.sun.star.frame.DispatchHelper”)
dim oFrame as object: oFrame = oDoc.getCurrentController().getFrame()

oDisp.executeDispatch(oFrame, “.uno:DBRefreshTables”, “”, 0, Array())
end sub


Download AndrewBase from https://www.pitonyak.org/database/ - 2.2.4 Refresh the tables
Comment 3 Robert Großkopf 2023-05-23 07:40:33 UTC
(In reply to flywire from comment #2)
> https://ask.libreoffice.org/t/possible-synch-error-between-mysql-and-base/
> 88846/14
> 
> > AndrewBase 2.2.4 speaks precisely about this issue. There is a workaround listed > there, which I have slightly modified, and it seems to be working just fine:
> 
> sub refreshTables()

…

Have tested this one. Is the same as using View → Refresh Tables.
It doesn't solve the problem. All old entries in the database file will be there. Entries in content.xml are like this:
<db:table-representation db:name="Musik.MUSIK"/>
And this has nothing to do with the tables, which are shown. Many times ago I had a database 'Musik' on my system. It isn't there any more but I connected the *.odb-file to this database in the past. So the table-representation is almost there.