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

Error during restore: "Error 1064: You have an error in your SQL syntax;" #5602

Closed
1 of 6 tasks
kdeenkhoorn opened this issue Jan 27, 2019 · 5 comments · Fixed by #6142
Closed
1 of 6 tasks

Error during restore: "Error 1064: You have an error in your SQL syntax;" #5602

kdeenkhoorn opened this issue Jan 27, 2019 · 5 comments · Fixed by #6142
Assignees
Labels
💊 bug Something isn't working
Milestone

Comments

@kdeenkhoorn
Copy link

kdeenkhoorn commented Jan 27, 2019

  • Gogs version (or commit ref): 0.11.79
  • Git version: Not applicable
  • Operating system: Debian 9 (Arm)
  • Database (replace [ ] with [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gogs.io:
    • Yes: provide example URL
    • No: explain why
  • Log gist (usually found in log/gogs.log):

I'm trying to restore my gogs database and repositories from my old system using a SQLite database to my new system using an MySQL 8.0.14 database.
During restore i get the following error:

2019/01/27 15:39:31 [ERROR] [...ogs/models/models.go:371 ImportDatabase()] Failed to reset 'created_unix': Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'release SET created_unix=? WHERE id=?' at line 1

I've been searching for the reason for this error and i have found it, in the lines 372 and 379 of the file 'models/models.go' back tics are missing around the table name.
During restore the script tries to update fields in the table with the name 'restore', but as the term 'restore' also seems to be a reserved command this fails if you just state: UPDATE restore WHERE ....
If you change this to UPDATE `restore` WHERE .... it is solved and the restore executes normally.

So change line 372 from:

if _, err = x.Exec("UPDATE "+rawTableName+" SET created_unix=? WHERE id=?", meta["CreatedUnix"], meta["ID"]); err != nil {

to

if _, err = x.Exec("UPDATE `"+rawTableName+"` SET created_unix=? WHERE id=?", meta["CreatedUnix"], meta["ID"]); err != nil {

And also the same for line 379.

Thanks for the great product!

Klaas Eenkhoorn

@unknwon unknwon added the 💊 bug Something isn't working label Feb 1, 2019
@unknwon unknwon added this to the 0.12 milestone Feb 1, 2019
@elico
Copy link

elico commented Apr 30, 2020

@unknwon Was this fixed?

@unknwon
Copy link
Member

unknwon commented May 1, 2020

@elico I don't think so, but I'm currently working on backup&restore related things, will take a look.

@unknwon unknwon self-assigned this May 1, 2020
@unknwon unknwon modified the milestones: Triaging priority, 0.12 May 1, 2020
@elico
Copy link

elico commented May 2, 2020

@unknwon Thanks.

@unknwon
Copy link
Member

unknwon commented May 4, 2020

Should work with latest master :) If not, please let me know!

@unknwon
Copy link
Member

unknwon commented May 4, 2020

Just a heads up, there is another blocker before you wanna try again: #6146

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
💊 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants