RDFLib

MySQL floating point truncation warnings ( Resolved Issue )

The issue was created on Friday 02 March, 2007. The issue was added by Mike Pittaro.

We have been bumping into mysql floating point warnings like the following:
python testGraphMySQL.py
/usr/local/python244/lib/python2.4/site-packages/rdflib/store/FOPLRelationalModel/BinaryRelationPartition.py:631: Warning: Truncated incorrect DOUBLE value: 'F'
  cursor.execute(query,tuple(unionQueriesParams))
/usr/local/python244/lib/python2.4/site-packages/rdflib/store/MySQL.py:170: Warning: Truncated incorrect DOUBLE value: 'F'
  cursor.execute(qStr,tuple(params))
Theres a simple test case below that reproduces the warnings.  I ran this under linux 2.6, with python 2.4.4 and MySQL 5.0.19.
mike
---------------------------------
import sys
import MySQLdb
from rdflib             import RDF
from rdflib             import URIRef, plugin
from rdflib.store       import Store
from rdflib.Graph       import Graph
from rdflib.Graph       import ConjunctiveGraph
from rdflib.Namespace   import Namespace
from rdflib.Literal     import Literal
if __name__ == "__main__":
    id = 'testdb'
    db = 'rep2'
    usr = 'mikeyp'
    pwd = 'mikeyp'
    hst = 'localhost'
    cfgstr = "db=%s,user=%s,password=%s,host=%s" % (db,usr,pwd,hst)
    store = plugin.get('MySQL', Store)(id)
    try:
        store.open(cfgstr, True)
    except Exception, e:
        if e.args[0] == 1050:
            store.open(cfgstr, False)
        else:
            print "Exception", str(e)
            sys.exit(1)
    g = ConjunctiveGraph(store)
    s = URIRef('http://test-mysql-warning')
    p = Namespace('truncate-incorrect-DOUBLE-value')
    o = Literal('arbitray-string', lang='en')
    g.add((s, p, o))
    g.commit()
    pos = g.predicate_objects(s)
    for (p, o) in pos:
        g.remove((s, p, o))
        g.commit()

Comments regarding MySQL floating point truncation warnings

by Daniel Krech on Monday 05 March, 2007:

chimezie * r940 rdflib/store/FOPLRelationalModel/BinaryRelationPartition.py: Fixed context column comparison. The hash integer was being compared with 'F' causing a warning:Warning: Truncated incorrect DOUBLE value: 'F'

by Mike Pittaro on Friday 02 March, 2007:

Here's a trace of the actual SQL statements we saw during execution, printing out the SQL, and the parameters to the SQL.
The following output indicates that a large number is inserted to the 'context' column (datatype BIGINT(20)) in _literalProperties table.  Whereas in the subsequent SELECT and DELETE statements, a condition of _literalProperties.context != 'F' is embdded.
$ python Quick/Utils/repository/test/testGraphMySQL.py
========= flushInsertions ============ (BinaryRelationPartition.py)
(False, True) INSERT INTO kb_22199ec38c_literalProperties (subject,subject_term,predicate,predicate_term,object,context,
context_term,language) VALUES (%s,%s,%s,%s,%s,%s,%s,%s)
[(2089168256456688139L, 'U', 7938321822530351659L, 'U', 14154739877016554841L, 6385400757550499479L, 'B', 'en')]
======= PatternResolution ========== (BinaryRelationPartition.py)
(SELECT rt_subject.lexical as subject,rt_subject.term_type as subjectTermType,rt_predicate.lexical as predicate,rt_predi
cate.term_type as predicateTermType,rt_object.lexical as object,'L' as objectTermType,rt_context.lexical as context,rt_c
ontext.term_type as contextTermType,rt_data_type.lexical as dataType,kb_22199ec38c_literalProperties.language as languag
e FROM kb_22199ec38c_literalProperties LEFT JOIN kb_22199ec38c_identifiers rt_data_type ON (kb_22199ec38c_literalPropert
ies.data_type = rt_data_type.id) INNER JOIN kb_22199ec38c_identifiers rt_predicate ON (kb_22199ec38c_literalProperties.p
redicate = rt_predicate.id AND kb_22199ec38c_literalProperties.predicate_term = rt_predicate.term_type) INNER JOIN kb_22
199ec38c_identifiers rt_context ON (kb_22199ec38c_literalProperties.context = rt_context.id AND kb_22199ec38c_literalPro
perties.context_term = rt_context.term_type) INNER JOIN kb_22199ec38c_literals rt_object ON (kb_22199ec38c_literalProper
ties.object = rt_object.id) INNER JOIN kb_22199ec38c_identifiers rt_subject ON (kb_22199ec38c_literalProperties.subject
= rt_subject.id AND kb_22199ec38c_literalProperties.subject_term = rt_subject.term_type) WHERE kb_22199ec38c_literalProp
erties.subject = %s AND kb_22199ec38c_literalProperties.subject_term = %s AND kb_22199ec38c_literalProperties.context !=
 'F') union all (SELECT rt_subject.lexical,rt_subject.term_type,rt_predicate.lexical,rt_predicate.term_type,rt_object.le
xical,rt_object.term_type,rt_context.lexical,rt_context.term_type,NULL,NULL FROM kb_22199ec38c_relations INNER JOIN kb_2
2199ec38c_identifiers rt_predicate ON (kb_22199ec38c_relations.predicate = rt_predicate.id AND kb_22199ec38c_relations.p
redicate_term = rt_predicate.term_type) INNER JOIN kb_22199ec38c_identifiers rt_context ON (kb_22199ec38c_relations.cont
ext = rt_context.id AND kb_22199ec38c_relations.context_term = rt_context.term_type) INNER JOIN kb_22199ec38c_identifier
s rt_object ON (kb_22199ec38c_relations.object = rt_object.id AND kb_22199ec38c_relations.object_term = rt_object.term_t
ype) INNER JOIN kb_22199ec38c_identifiers rt_subject ON (kb_22199ec38c_relations.subject = rt_subject.id AND kb_22199ec3
8c_relations.subject_term = rt_subject.term_type) WHERE kb_22199ec38c_relations.subject = %s AND kb_22199ec38c_relations
.subject_term = %s AND kb_22199ec38c_relations.context != 'F') union all (SELECT rt_subject.lexical,rt_subject.term_type
,'http://www.w3.org/1999/02/22-rdf-syntax-ns#type','U',rt_object.lexical,rt_object.term_type,rt_context.lexical,rt_conte
xt.term_type,NULL,NULL FROM kb_22199ec38c_associativeBox INNER JOIN kb_22199ec38c_identifiers rt_object ON (kb_22199ec38
c_associativeBox.class = rt_object.id AND kb_22199ec38c_associativeBox.class_term = rt_object.term_type) INNER JOIN kb_2
2199ec38c_identifiers rt_context ON (kb_22199ec38c_associativeBox.context = rt_context.id AND kb_22199ec38c_associativeB
ox.context_term = rt_context.term_type) INNER JOIN kb_22199ec38c_identifiers rt_subject ON (kb_22199ec38c_associativeBox
.member = rt_subject.id AND kb_22199ec38c_associativeBox.member_term = rt_subject.term_type) WHERE kb_22199ec38c_associa
tiveBox.member = %s AND kb_22199ec38c_associativeBox.member_term = %s AND kb_22199ec38c_associativeBox.context != 'F') O
RDER BY subject,predicate,object
[2089168256456688139L, 'U', 2089168256456688139L, 'U', 2089168256456688139L, 'U']
c:\Programs\Python24\lib\site-packages\rdflib\store\FOPLRelationalModel\BinaryRelationPartition.py:637: Warning: Truncat
ed incorrect DOUBLE value: 'F'
  cursor.execute(query,tuple(unionQueriesParams))
======= MySQL 1 ========== (MySQL.py)
select count(*) from kb_22199ec38c_literalProperties
None
======= MySQL 1 ========== (MySQL.py)
select count(*) from kb_22199ec38c_relations
None
======= MySQL 1 ========== (MySQL.py)
select count(*) from kb_22199ec38c_associativeBox
None
======= MySQL 3 ========== (MySQL.py)
DELETE kb_22199ec38c_literalProperties from kb_22199ec38c_literalProperties LEFT JOIN kb_22199ec38c_identifiers rt_data_
type ON (kb_22199ec38c_literalProperties.data_type = rt_data_type.id) INNER JOIN kb_22199ec38c_identifiers rt_predicate
ON (kb_22199ec38c_literalProperties.predicate = rt_predicate.id AND kb_22199ec38c_literalProperties.predicate_term = rt_
predicate.term_type) INNER JOIN kb_22199ec38c_identifiers rt_context ON (kb_22199ec38c_literalProperties.context = rt_co
ntext.id AND kb_22199ec38c_literalProperties.context_term = rt_context.term_type) INNER JOIN kb_22199ec38c_literals rt_o
bject ON (kb_22199ec38c_literalProperties.object = rt_object.id) INNER JOIN kb_22199ec38c_identifiers rt_subject ON (kb_
22199ec38c_literalProperties.subject = rt_subject.id AND kb_22199ec38c_literalProperties.subject_term = rt_subject.term_
type) WHERE kb_22199ec38c_literalProperties.subject = %s AND kb_22199ec38c_literalProperties.subject_term = %s AND kb_22
199ec38c_literalProperties.predicate = %s AND kb_22199ec38c_literalProperties.predicate_term = %s AND kb_22199ec38c_lite
ralProperties.object = %s AND kb_22199ec38c_literalProperties.context != 'F' AND kb_22199ec38c_literalProperties.languag
e = %s
[2089168256456688139L, 'U', 7938321822530351659L, 'U', 14154739877016554841L, 'en']
c:\Programs\Python24\lib\site-packages\rdflib\store\MySQL.py:178: Warning: Truncated incorrect DOUBLE value: 'F'
  cursor.execute(qStr,tuple(params))

Login to submit a comment.