Bug 61203 - SQL syntax error inserting new record into empty table
Summary: SQL syntax error inserting new record into empty table
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
4.1.0.0.alpha0+ Master
Hardware: Other Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:4.1.0
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-21 03:17 UTC by Terrence Enger
Modified: 2013-03-03 16:13 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
odbc trace (292.22 KB, text/plain)
2013-02-21 03:17 UTC, Terrence Enger
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Terrence Enger 2013-02-21 03:17:20 UTC
Created attachment 75224 [details]
odbc trace

Steps to reproduce 

(1) Download and open the database file attached to bug 61198
    <https://bugs.freedesktop.org/attachment.cgi?id=75216>.

    LibreOffice displays window "New Database1.odb".

(2) In left pane click <Tables>.

    Program displays table name OneColumn in the lower right pane.

(3) In lower right pane, right-click OneColumn and in the pop-up menu
    select Open.

    Program displays window Table Data View.  The cursor is in the
    empty cell at the top left.

(4) In Table Data View, type 1<TAB>.

    Actual program action is to display error message ...

        Error inserting the new record
        Unexpected token: ( in statement [INSERT INTO ("ID") VALUES (?)]

    Expected program action is to add the record to the table an to
    move the caret to the second row in preparation for the entry of
    another record.


The problem is not restricted to embedded databases.  In a test
against an odbc connection, the second line of the error message
read ...

    [unixODBC][SQLite]near "(": syntax error (1)

and the attached ODBC trace file at line 2583 shows a call to
SQLPrepare with missing table name ...

    SQL = [INSERT INTO  ( "ID") VALUES ( ?)][length = 32]

It follows naturally that the call to SQLExecute at line 2616 fails
with ...

    DIAG [HY000] [SQLite]near "(": syntax error (1)


I observed this in master commit 2e367c0, pulled 2012-02-17, built and
running on ubuntu-natty 32-bit.  The configuration options are ...

    --enable-dbgutil
    --enable-crashdump
    --disable-build-mozilla
    --without-system-postgresql
    --without-myspell-dicts
    --without-help
    --with-extra-buildid
Comment 1 Julien Nabet 2013-02-21 18:07:25 UTC
On pc Debian x86-64 with master sources updated today (commit 81e065b0ec2764ef44116512631d2ae8260df47a), I reproduced the problem.
Again logs like these:
warn:connectivity.parse:22224:1:workdir/unxlngx6/YaccTarget/connectivity/source/parse/sqlbison.cxx:9272: connectivity::OSQLParser::RuleIDToRule cannot reverse-lookup rule. Reverse mapping incomplete? _nRule='367' yytname[_nRule]='opt_all_distinct'
warn:connectivity.parse:22224:1:workdir/unxlngx6/YaccTarget/connectivity/source/parse/sqlbison.cxx:9272: connectivity::OSQLParser::RuleIDToRule cannot reverse-lookup rule. Reverse mapping incomplete? _nRule='398' yytname[_nRule]='opt_group_by_clause'
warn:connectivity.parse:22224:1:workdir/unxlngx6/YaccTarget/connectivity/source/parse/sqlbison.cxx:9272: connectivity::OSQLParser::RuleIDToRule cannot reverse-lookup rule. Reverse mapping incomplete? _nRule='400' yytname[_nRule]='opt_having_clause'
warn:connectivity.parse:22224:1:workdir/unxlngx6/YaccTarget/connectivity/source/parse/sqlbison.cxx:9272: connectivity::OSQLParser::RuleIDToRule cannot reverse-lookup rule. Reverse mapping incomplete? _nRule='489' yytname[_nRule]='opt_window_clause'

Lionel: Just for my information, I noticed http://cgit.freedesktop.org/libreoffice/core/commit/?id=09109f3dcde24fcd13426ce5b77bb40032f58947. So do these logs show multiple problems or should each case be analyzed (because some may be false positive or just warnings)?

(Terrence: Your local master sources are not very updated "2012-02-17" :-p)
Comment 2 Terrence Enger 2013-02-22 18:42:53 UTC
(In reply to comment #1)
> ...
> Again logs like these:

For this warning I have created bug 61298 '"cannot reverse-lookup
rule. Reverse mapping incomplete?"', with a comment referencing this
bug and a couple of others where you have mentioned the warning.

> ...
> 
> (Terrence: Your local master sources are not very updated "2012-02-17" :-p)

Whoops, I shoud have typed 2013.  My time off the internet just *felt*
like it was a year <grin />.
Comment 3 Not Assigned 2013-02-28 17:20:36 UTC
Lionel Elie Mamane committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=a2db9096e2674bfb1cb125bf6036c990f35579e7

fdo#61203 initialise m_aComposedTableName *before* trying to use it



The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 4 Terrence Enger 2013-03-03 16:13:30 UTC
Thank you, Lionel.  The problem is fixed for me with recent master.