SQL replication: Unknown column 'NaN' in 'field list'

4,536 views
Skip to first unread message

Robert Edin

unread,
May 27, 2013, 11:26:46 AM5/27/13
to rav...@googlegroups.com
I get a strange error. How can the error be "NaN not in field list" when there are only constant strings in the INSERT INTO?

Failure to replicate changes to relational database for: Arne, will continue trying.
INSERT INTO `ParNum` (`RavenID`, `Name`, `Value`, `N`) 
VALUES (@RavenID, @Name, @Value, @N)

MySql.Data.MySqlClient.MySqlException (0x80004005): Unknown column 'NaN' in 'field list'
   at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
   at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)
   at MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int64& insertedId)
   at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
   at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()
   at Raven.Database.Bundles.SqlReplication.RelationalDatabaseWriter.InsertItems(String tableName, String pkName, List`1 dataForTable) in c:\Builds\RavenDB-Unstable-v2.5\Raven.Database\Bundles\SqlReplication\RelationalDatabaseWriter.cs:line 145


It origins from this line
replicateToParNum( { Name: param.Name, Value: param.Value, N: j } );
I have changed values to replicate to constants, but it still get the same error. 
 
stangely there is a very similar line earlier in the script that works fine. The only difference is a constat 0 instead if the loop variable 'j'.
replicateToParNum( { Name: param.Name, Value: param.Value, N: 0 } ); 
 
-- Robert

Oren Eini (Ayende Rahien)

unread,
May 28, 2013, 1:58:23 AM5/28/13
to ravendb
Is it possible that j is set to a NaN ? 



 
-- Robert

--
You received this message because you are subscribed to the Google Groups "ravendb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Robert Edin

unread,
May 28, 2013, 3:50:31 AM5/28/13
to rav...@googlegroups.com
No j can not be NaN. It is the index from the for loop.

    for ( var j = 0; j < param.Value.length; j++) {
     <- cut ->
       replicateToParNum( { Name: param.Name, Value: param.Value[j], N: j } );
       

and does not "Unknown column 'NaN' in 'field list'" indicate that it is 
the INSERT INTO and not VALUES that is said to contain the NaN? 
I also have a corresponding construct for strings that work fine. 
But of course does not strings have NaN problems :)

Oren Eini (Ayende Rahien)

unread,
May 28, 2013, 4:14:40 AM5/28/13
to rav...@googlegroups.com
Can you send a failing test?

Robert Edin

unread,
May 28, 2013, 7:17:53 AM5/28/13
to rav...@googlegroups.com
Yes. I must create a smaller example data first.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.

Robert Edin

unread,
May 28, 2013, 9:30:01 AM5/28/13
to rav...@googlegroups.com
Ok, problem identified!
The JavaScript function isFinite() does not work. It always return true, e.g. also for NaN.
That made the replication script to send NaN as value => crash.
However, isNaN() works and now data is replicated also when NaN exists as value.
The data we have also have a few Infinity values. How can I test for them until the isFinite() has been fixed?

Oren Eini (Ayende Rahien)

unread,
May 28, 2013, 9:24:24 PM5/28/13
to ravendb
Can you send me a failing test?

Robert Edin

unread,
May 29, 2013, 3:24:46 AM5/29/13
to rav...@googlegroups.com
It turns out that isFinite() works when constants are set in the JScript itself, but not when the non-finite value origins from a Raven document.
The isNaN() however recognizes the NaN from the document as expected..

Replication script:

replicateToStepDoc({
        RavenID: documentId,
        StepName: this.StepName,
        StepId: this.StepId,
        DeviceId: this.DeviceId
    });
output("isFinite(47.11)=" + isFinite(47.11));
output("isFinite(Number.NaN)=" + isFinite(Number.NaN));
output("isFinite(Number.POSITIVE_INFINITY)=" + isFinite(Number.POSITIVE_INFINITY));
output("isFinite(Number.NEGATIVE_INFINITY)=" + isFinite(Number.NEGATIVE_INFINITY));
output("isFinite(this.DeviceId)=" + isFinite(this.DeviceId));
output("isFinite(this.Parameters[0].Value)=" + isFinite(this.Parameters[0].Value) + " " + this.Parameters[0].Value.toString());
output("isFinite(this.Parameters[1].Value)=" + isFinite(this.Parameters[1].Value) + " " + this.Parameters[1].Value.toString());

Output:

Debug output for doc: lasers/23050719/400.130.160.130 for script i:
.isFinite(47.11)=true
isFinite(Number.NaN)=false
isFinite(Number.POSITIVE_INFINITY)=false
isFinite(Number.NEGATIVE_INFINITY)=false
isFinite(this.DeviceId)=true
isFinite(this.Parameters[0].Value)=true nan
isFinite(this.Parameters[1].Value)=true 10

Document:
lasers/23050719/400.130.160.130
{
  "WaferId": 2305,
  "StepId": "400.130.160.130",
  "StepName": "COC.TestAndBurnIn.PreBurnIn.Test",
  "DeviceType": "Laser",
  "StartTime": "2012-12-06T10:39:36.0000000+01:00",
  "StopTime": "2012-12-06T11:03:38.0000000+01:00",
  "Comments": [],
  "Parameters": [
    {
      "Name": "Age:Margin.D",
      "Value": NaN,
      "Tags": []
    },
    {
      "Name": "Age:MarginHigh.S",
      "Value": [
        10.0
      ],
      "Tags": []
    }
  ]
}

Oren Eini (Ayende Rahien)

unread,
May 29, 2013, 6:54:16 AM5/29/13
to ravendb
Thanks, fixed in the next build.

Robert Edin

unread,
May 29, 2013, 11:13:38 AM5/29/13
to rav...@googlegroups.com

Great! Thanks Oren.

You received this message because you are subscribed to a topic in the Google Groups "ravendb" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ravendb/Yt1_TfpkHiE/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to ravendb+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages