google-code-export / sqljet

Automatically exported from code.google.com/p/sqljet
0 stars 1 forks source link

Cannot read table definition if two consecutive FOREIGN KEY definitions are found without being separated by comma #160

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Try to open a file (with the jnlp app available) that contains a table 
structure like this:

CREATE TABLE dummy_table (
    id integer PRIMARY KEY AUTOINCREMENT NOT NULL,
    content_id INTEGER,
    content_page_id INTEGER,
    FOREIGN KEY(content_id) REFERENCES content(id)
    FOREIGN KEY(content_page_id) REFERENCES content_page(id)
)

What is the expected output? What do you see instead?

Expected: file opens ok. Instead I get the exception trace:
org.tmatesoft.sqljet.core.internal.lang.SqlJetParserException: [line 10:4] no 
viable alternative at input 'FOREIGN'

CREATE TABLE dummy_table (
    id integer PRIMARY KEY AUTOINCREMENT NOT NULL,
    content_id INTEGER,
    content_page_id INTEGER,
    FOREIGN KEY(content_id) REFERENCES content(id)
    FOREIGN KEY(content_page_id) REFERENCES content_page(id)
)
    at org.tmatesoft.sqljet.core.internal.lang.SqlParser.displayRecognitionError(SqlParser.java:299)
    at org.antlr.runtime.BaseRecognizer.reportError(BaseRecognizer.java:186)
    at org.tmatesoft.sqljet.core.internal.lang.SqlParser.fk_clause(SqlParser.java:12241)
    at org.tmatesoft.sqljet.core.internal.lang.SqlParser.table_constraint_fk(SqlParser.java:11949)
    at org.tmatesoft.sqljet.core.internal.lang.SqlParser.table_constraint(SqlParser.java:11331)
    at org.tmatesoft.sqljet.core.internal.lang.SqlParser.create_table_stmt(SqlParser.java:9759)
    at org.tmatesoft.sqljet.core.internal.lang.SqlParser.schema_create_table_stmt(SqlParser.java:1105)
    at org.tmatesoft.sqljet.core.internal.schema.SqlJetSchema.parseTable(SqlJetSchema.java:409)
    at org.tmatesoft.sqljet.core.internal.schema.SqlJetSchema.readShema(SqlJetSchema.java:315)
    at org.tmatesoft.sqljet.core.internal.schema.SqlJetSchema.init(SqlJetSchema.java:168)
    at org.tmatesoft.sqljet.core.internal.schema.SqlJetSchema.<init>(SqlJetSchema.java:154)
    at org.tmatesoft.sqljet.core.table.SqlJetDb$2.runWithLock(SqlJetDb.java:249)
    at org.tmatesoft.sqljet.core.table.SqlJetDb.runWithLock(SqlJetDb.java:307)
    at org.tmatesoft.sqljet.core.table.SqlJetDb.readSchema(SqlJetDb.java:244)
    at org.tmatesoft.sqljet.core.table.SqlJetDb.refreshSchema(SqlJetDb.java:715)
    at org.tmatesoft.sqljet.core.table.SqlJetDb.getSchemaInternal(SqlJetDb.java:338)
    at org.tmatesoft.sqljet.core.table.SqlJetDb.getSchema(SqlJetDb.java:333)
    at org.tmatesoft.sqljet.browser.core.schema.SchemaComponent.open(SchemaComponent.java:51)
    at org.tmatesoft.sqljet.browser.core.BrowserComponentManager.stateChanged(BrowserComponentManager.java:220)
    at org.tmatesoft.sqljet.browser.core.BrowserComponentManager.open(BrowserComponentManager.java:195)
    at org.tmatesoft.sqljet.browser.core.actions.OpenAction.actionPerformed(OpenAction.java:68)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
    at javax.swing.AbstractButton.doClick(AbstractButton.java:357)
    at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:809)
    at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:850)
    at java.awt.Component.processMouseEvent(Component.java:6289)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
    at java.awt.Component.processEvent(Component.java:6054)
    at java.awt.Container.processEvent(Container.java:2041)
    at java.awt.Component.dispatchEventImpl(Component.java:4652)
    at java.awt.Container.dispatchEventImpl(Container.java:2099)
    at java.awt.Component.dispatchEvent(Component.java:4482)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
    at java.awt.Container.dispatchEventImpl(Container.java:2085)
    at java.awt.Window.dispatchEventImpl(Window.java:2478)
    at java.awt.Component.dispatchEvent(Component.java:4482)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:644)
    at java.awt.EventQueue.access$000(EventQueue.java:85)
    at java.awt.EventQueue$1.run(EventQueue.java:603)
    at java.awt.EventQueue$1.run(EventQueue.java:601)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
    at java.awt.EventQueue$2.run(EventQueue.java:617)
    at java.awt.EventQueue$2.run(EventQueue.java:615)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:614)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Caused by: NoViableAltException(163@[()* loopback of 462:3: ( fk_clause_action 
)*])
    at org.antlr.runtime.DFA.noViableAlt(DFA.java:158)
    at org.antlr.runtime.DFA.predict(DFA.java:116)
    at org.tmatesoft.sqljet.core.internal.lang.SqlParser.fk_clause(SqlParser.java:12136)
    ... 56 more

What version of the product are you using? On what operating system?
jar file: 1.0.7 and 1.0.6. Ubuntu 10.10. For the stack trace I used the app 
available on the site.

Additional info:
I tried to create a table using the CREATE statement from above in sqlite 
2.6.17 and it didn't work. However, sqlite3 v.3.7.7.1 could parse and execute 
the statement. My guess is that there are differences btw. sqlite v.2 and v.3 
that are not properly reflected in the driver.

Original issue reported on code.google.com by dan.bo...@gmail.com on 9 Aug 2011 at 6:12

GoogleCodeExporter commented 9 years ago

Original comment by sergey.s...@gmail.com on 9 Aug 2011 at 6:48

GoogleCodeExporter commented 9 years ago
Sorry, shouldn't there be comma between FOREIGN KEY's ? Like as:

CREATE TABLE dummy_table (
    id integer PRIMARY KEY AUTOINCREMENT NOT NULL,
    content_id INTEGER,
    content_page_id INTEGER,
    FOREIGN KEY(content_id) REFERENCES content(id),
    FOREIGN KEY(content_page_id) REFERENCES content_page(id)
)

With comma it works.

Original comment by sergey.s...@gmail.com on 9 Aug 2011 at 7:04

GoogleCodeExporter commented 9 years ago
I've made comma as optional between constraints. Test it from 'trunk', please.

Original comment by sergey.s...@gmail.com on 9 Aug 2011 at 7:10

GoogleCodeExporter commented 9 years ago
Thanks for the reply. Wow, that was quick (and unexpected actually ;-)).

Do you use an eclipse gradle plugin when building the project? I get

java.lang.NoClassDefFoundError: 
org.gradle.plugins.ide.eclipse.GenerateEclipseProject
    at org.tmatesoft.build.BuildPlugin.class$(BuildPlugin.groovy)
    at org.tmatesoft.build.BuildPlugin.$get$$class$org$gradle$plugins$ide$eclipse$GenerateEclipseProject(BuildPlugin.groovy)
    at org.tmatesoft.build.BuildPlugin.updateEclipseTasks(BuildPlugin.groovy:84)
    at org.tmatesoft.build.BuildPlugin$_apply_closure1.doCall(BuildPlugin.groovy:45)

Would it be cumbersome for you to send me the latest jar with your changes?

Thanks,
Dan.

Original comment by dan.bo...@gmail.com on 9 Aug 2011 at 7:46

GoogleCodeExporter commented 9 years ago
Thanks for the reply. Wow, that was quick (and unexpected actually ;-)).

Do you use an eclipse gradle plugin when building the project? I get

java.lang.NoClassDefFoundError:
org.gradle.plugins.ide.eclipse.GenerateEclipseProject
    at org.tmatesoft.build.BuildPlugin.class$(BuildPlugin.groovy)
    at
org.tmatesoft.build.BuildPlugin.$get$$class$org$gradle$plugins$ide$eclipse$Gener
ateEclipseProject(BuildPlugin.groovy)
    at
org.tmatesoft.build.BuildPlugin.updateEclipseTasks(BuildPlugin.groovy:84)
    at
org.tmatesoft.build.BuildPlugin$_apply_closure1.doCall(BuildPlugin.groovy:45)

Would it be cumbersome for you to send me the latest jar with your changes?

Original comment by dan.bo...@gmail.com on 9 Aug 2011 at 7:46

GoogleCodeExporter commented 9 years ago
http://teamcity.tmatesoft.com/repository/download/bt12/1584:id/Binaries+and+Sour
ces/sqljet-1.1.0-SNAPSHOT_r1158_v20110809_2108-all.zip

Original comment by sergey.s...@gmail.com on 9 Aug 2011 at 7:51

GoogleCodeExporter commented 9 years ago
Thanks, I've managed to download the jar using the guest account. WIll test
it tomorrow.
Really appreciate your help.

D

Original comment by dan.bo...@gmail.com on 9 Aug 2011 at 8:27

GoogleCodeExporter commented 9 years ago
This issue is now fixed in 1.0.x branch of SqlJet and will be included into 
v1.0.8

Original comment by kit...@gmail.com on 15 Aug 2011 at 5:42