Bug 264101 - Importing table with reserved name make a sql error
Summary: Importing table with reserved name make a sql error
Status: CLOSED FIXED
Alias: None
Product: KEXI
Classification: Applications
Component: Migration/Import/Export (other bugs)
Version First Reported In: 2.3.1 (KOffice 2.3.1)
Platform: Ubuntu Linux
: NOR minor
Target Milestone: ---
Assignee: Jarosław Staniek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-23 18:48 UTC by Julien Tattevin
Modified: 2011-01-27 00:45 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Julien Tattevin 2011-01-23 18:48:33 UTC
Version:           2.3.1 (KOffice 2.3.1) (using KDE 4.5.1) 
OS:                Linux

I'm trying to import data from an already existing database for an online game.
There is a table char(id,name,str,dex,int,etc...). And when i'm trying to import, kexi say "BLOB/TEXT column 'str' used in key specification without a key length"
Because he doesn't put field and table name in `
SELECT * FROM `char`; work but SELECT * FROM char; doesn't



Reproducible: Always

Steps to Reproduce:
Create a table with name "char", or field named "str" or "int"


Actual Results:  
The import stop but no crash, i can retry and continue (after renomming field)

Expected Results:  
Kexi should have escaped the name to prevent reserved name to fail.

I have not test further than import (still in progress)
I will edit or comment (if i can) to say if it have the same behavior or not after import.
Comment 1 Adam Pigg 2011-01-23 21:21:48 UTC
Do you have any more info, like, what is the source database (mysql/postgresql), and were you doing a full migration, or just a single table import?
Comment 2 Julien Tattevin 2011-01-23 21:27:42 UTC
I was doing a full migration, from mysqld  Ver 5mysqld  Ver 5.1.37-1ubuntu5.4 for debian-linux-gnu on i486 ((Ubuntu)).1.37-1ubuntu5.4 for debian-linux-gnu on i486 ((Ubuntu))
to mysqld  Ver 5.1.49-1ubuntu8.1 for debian-linux-gnu on x86_64 ((Ubuntu))mysqld  Ver 5.1.49-1ubuntu8.1 for debian-linux-gnu on x86_64 ((Ubuntu))

And it cause an sql syntax error because of reserved name and kexi stop migration.
Comment 3 Adam Pigg 2011-01-23 21:42:22 UTC
could you attach a dump of the database so i can recreate it here and give it a go
Comment 4 Julien Tattevin 2011-01-23 21:48:52 UTC
Yes,

This file was creating the database i was trying to import.

http://svn.eathena.ws/svn/ea/trunk/sql-files/main.sql
Comment 5 Adam Pigg 2011-01-24 23:06:40 UTC
Git commit b8e212ecf8bddfe56568ce9a6a02b983d4d1e0d3 by Adam Pigg.
Pushed by piggz into branch 'master'.

Properly escape SQL key words.
BUG:264101

M  +1    -1    kexi/kexidb/driver.cpp     
M  +3    -2    kexi/kexiutils/utils.cpp     
M  +1    -1    kexi/migration/mysql/mysqlmigrate.cpp     
M  +1    -1    kexi/migration/pqxx/pqxxmigrate.cpp     

http://commits.kde.org/47e7010d/b8e212ecf8bddfe56568ce9a6a02b983d4d1e0d3
Comment 6 Adam Pigg 2011-01-24 23:09:13 UTC
Unfortunately, the attached patch doesnt entirely fix your problem.  It makes the migration much better, in that keywords should be properly escaped now, but some of the tables in your schema have composite keys which are unsupported in kexi.  If you would like to open another bug/wish it would be great for tracking that.
Comment 7 Julien Tattevin 2011-01-25 00:09:28 UTC
Ok, for tonight i can't test but i will try asap and tell you and i will also open an second wish for the composite keys.

And thank you for answering quickly !
Comment 8 Julien Tattevin 2011-01-27 00:45:00 UTC
Ok, it work nice, not importing everything but this bug is resolved

(Not sure to close it properly)