Bug #39388 Falcon crashes when doing INSERT if column name in Falcon table contains ""
Submitted: 11 Sep 2008 10:28 Modified: 13 Dec 2008 10:04
Reporter: Lars-Erik Bjørk Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Falcon storage engine Severity:S3 (Non-critical)
Version:6.0-falcon-team OS:Linux (Ubuntu 8.04)
Assigned to: Lars-Erik Bjørk CPU Architecture:Any
Tags: F_ENCODING

[11 Sep 2008 10:28] Lars-Erik Bjørk
Description:
1) Create database and table with falcon storage engine.
2) Create a column name using "" as part of the name
3) Insert some into the table
Falcon crashes on an assertion

The ASSERT itself is not the problem. It was added to ensure that NULL is not secretly inserted into the database. The problem is that Falcon does not recognize a column with "" as part of the name.

StorageInterface::encodeRecord has the following code

for (int n = 0; n < maxId; ++n, ++fieldFormat)
        {
        if (fieldFormat->fieldId < 0 || fieldFormat->offset == 0)
                continue;
                        
        Field *field = fieldMap[fieldFormat->fieldId];
        ASSERT(field);   // This one is hit

In StorageInterface::mapFields, when populating the fieldMap, before we try to look up the fieldId, we
do:

storageShare->cleanupFieldName(field->field_name, nameBuffer,
sizeof(nameBuffer));

This does, for some reason, add an additional " for every " in the name,
turning the "clean" field name into ""strangename"". This doesn't match
with "strangename" when comparing before (not) inserting into the fieldMap.

Digression:
----------------
However, I try to remove the addition of an extra " in
StorageTableShare::cleanupFieldName, I am not even able to create a
table like this anymore. This seems to be because SQLParse::getToken() expects three "s in the case where an identifier name contains "s (\"\"\"strangename\"\"\"), but only gets two (\"\"strangename\"\").

How to repeat:
mysql> use test;

Database changed

mysql> create table t1 (`"strangename"` int) engine=falcon;
Query OK, 0 rows affected (0.00 sec)

mysql> insert into t1 values (1);
ERROR 2013 (HY000): Lost connection to MySQL server during query

Suggested fix:
Fix so that the two strings are equal, and the fieldMap is populated correctly.
[11 Sep 2008 21:30] MySQL Verification Team
When doing the shutdown I got a Falcon assertion, that is the same behavior you got?:

c:\dbs>c:\dbs\6.0\bin\mysqld --defaults-file=c:\dbs\6.0\my.ini --standalone --console
080911 12:14:50  InnoDB: Started; log sequence number 0 49901
080911 12:14:50 [Note] Event Scheduler: Loaded 0 events
080911 12:14:50 [Note] c:\dbs\6.0\bin\mysqld: ready for connections.
Version: '6.0.7-alpha-nt-log'  socket: ''  port: 3600  Source distribution
080911 18:23:05 [Note] c:\dbs\6.0\bin\mysqld: Normal shutdown

080911 18:23:06 [Note] Event Scheduler: Purging the queue. 0 events
[Falcon] Error: assertion (lockState == 0) failed at line 131 in file .\SyncObject.cpp

080911 18:23:11 - mysqld got exception 0x80000003 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help diagnose
the problem, but since we have already crashed, something is definitely wrong
and this may fail.

key_buffer_size=8388600
read_buffer_size=131072
max_used_connections=1
max_threads=151
thread_count=0
connection_count=0
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 337741 K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

thd: 0x0
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
7C90120E    ntdll.dll!DbgBreakPoint()
EEEEEEEE
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.
[12 Sep 2008 8:18] Lars-Erik Bjørk
The assertion that is hit is:
[Falcon] Error: assertion (field) failed at line 2645 in file ha_falcon.cpp

This is only reproducible on the 6.0-falcon-team branch, and is there to prevent silently insert NULL values (which should be fixed).

However, before the ASSERT was added, this insert would go ok, but when doing a SELECT on the table, you would see that the value that was actually inserted was NULL

I have never seen the situation that you came across in this scenario, so that may be another bug (or two), I don't know. But I have not tried this on the 6.0 branch.
[30 Oct 2008 12:05] Lars-Erik Bjørk
This bug is a duplicate of bug#40158
[13 Dec 2008 10:04] MC Brown
A note has been added to the 6.0.8 changelog: 

Creating a table, or selecting from a table using the FALCON storage engine and with a double quote in the name would cause an assertion failure.