Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MariaDB programming error after upgrading to 11.0.3 #2732

Closed
schmyd opened this issue Jan 11, 2024 · 6 comments
Closed

MariaDB programming error after upgrading to 11.0.3 #2732

schmyd opened this issue Jan 11, 2024 · 6 comments

Comments

@schmyd
Copy link

schmyd commented Jan 11, 2024

I am running 11.0.3 on Debian and I am using MariaDB 11.2.2 as database. After upgrading to v11 I noticed the following exception in seahub.log.

(1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-db.SharedRepo s\n WHERE\n repo_id = '<myId>...' at line 4")

which can be triggered by calling this endpoint
https://my.tld/api/v2.1/repo-folder-share-info/?repo_id=<myId>

digging a bit further I noticed that the following query gets generated for MariaDB

            SELECT
                s.repo_id, s.from_email, s.to_email, s.permission
            FROM
                seafile-db.SharedRepo s
            WHERE
                repo_id = '<myId>';

which fails because my database name contains a hyphen (seafile-db). Adding backticks (seafile-db) to the query works (db_api.py#45), but then the next query fails with the same issue.

Two workarounds

  1. Migrating to single word database names
  2. Changing the seafile.conf and adding backticks there

    db_name = `seafile-db`

Would it be possible to get a structural solution? Patching all queries could be avoided by adding backticks automatically when parsing the seafile.conf file.

Best Regards

@imwhatiam
Copy link
Member

imwhatiam commented Jan 12, 2024

Hi, given that it's not recommended to have hyphens in the database name, can you rename the database to seafile_db or just seafile

@schmyd
Copy link
Author

schmyd commented Jan 12, 2024

Renaming the database to a single word would probably work, as mentioned. But in my opinion this isn't a structural solution.

The current documentation still lists the hyphen-version as the default database name

(Default is "seafile-db", the database is created if it does not exist

But even when this would be resolved, I would expect a warning or similar for any user that is upgrading from a previous version and have a hyphen in their database names. Maybe when running the migration script, maybe when reading the db table name from config. Or by actually fixing the queries.

Given that this happens with the default settings I noticed that there are also other users affected.

@imwhatiam
Copy link
Member

Given that this happens with the default settings I noticed that there are also other users affected.

Hello, we will carefully examine the code to see how to avoid this issue at the code level.

@freeplant
Copy link
Member

The problem has been fixed in the latest release.

@freeplant
Copy link
Member

The problem has been fixed in the latest release.

@schmyd
Copy link
Author

schmyd commented Feb 17, 2024

looks good, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants