0

I am using MySQL Connector to connect to a MariaDB server.

A function in my program periodically retrieves all entries in a table (with a select * from ... without any wheres, limits, etc.).

After it gets the data, it checks if these rows (using an auto-incremented id) are already present in its memory, and if not it adds them. But if a row does not exist in the retrieved list but presents in the memory-list, then that row must be deleted from memory.

Deleting that row from memory is not the only thing that's gonna happen. It also deletes a bunch of other tables/files linked to that row. So, if the connector somehow fails, does not retrieve the full list, and does not report this, then I'll get into trouble.

It might be a tad stupid question but I couldn't make sure if I needed any additional safety measures.

Shadow
  • 33,525
  • 10
  • 51
  • 64
  • 1
    why not using a datetime column and retive all rows that are newer than the last retrival? – nbk Feb 08 '22 at 23:06
  • It may be that you could do what you're looking to do with a trigger ON DELETE on your table to delete the associated records on other tables. It would then then happen straight away without running extra code. It should be more reliable. –  Feb 08 '22 at 23:26
  • Can you provide a [mre] where this is true: "Deleting that row from memory is not the only thing that's gonna happen. It also deletes a bunch of other tables/files linked to that row." ? (How does deleting from memory, also delete data from tables/files linked to that row ?, mayb you should not have a trigger on that memory table ? – Luuk Feb 09 '22 at 16:11

0 Answers0