Missing primary keys on MySQL

Hi,

I’m facing an issue with Orthanc when using MySQL as the database backend.

In a MySQL cluster, there is a strict requirement that every table must have a primary key (sql_require_primary_key).

I’ve found a couple of issues in Orthanc and its MySQL plugin:

  1. The DeletedFiles table is created without a primary key.
  2. The temporary table DeletedResources (used when deleting studies or patients) is also created without a primary key.

The first issue prevents Orthanc from initializing the database correctly, but it can be bypassed by manually creating the table in one single SQL statement that includes a primary key.

The second issue prevents Orthanc from deleting studies or patients entirely.

There is a possible workaround in MySQL by enabling the sql_generate_invisible_primary_key setting, but this is not always possible — for example, when the database is managed by another team or provided as a managed/shared service.

I have a small patch that fixes both issues, and I would like to contribute it, but I’m not sure what the correct procedure is to open a pull request for the MySQL plugin.

Could you point me in the right direction?

Thank you.
Marco

Hi @marcogattibr

Since we are using a self-hosted mercurial repo, it is actually not possible to submit a PR. If it is fine with you, you can submit the patch here.

Best regards,

Alain

Hi @alainmazy

I’m posting my small patch here.
I’ve tested it a bit but if you spot any issue, please let me know if I can help you.

Cheers
Marco

orthanc-mysql-pk.patch.txt (1.8 KB)

Thanks @marcogattibr

I have added it in our todo.

Best regards,

Alain

1 Like