Skip to content

Commit

Permalink
Merge pull request #651 from linas/ovr
Browse files Browse the repository at this point in the history
Add length check for bug #650
  • Loading branch information
linas committed Feb 18, 2016
2 parents fe883c3 + c9b1085 commit 32f8353
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions opencog/persist/sql/AtomStorage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,20 @@ void AtomStorage::do_store_single_atom(AtomPtr atom, int aheight)
qname += n->getName();
qname += "$ocp$ ";
#endif
// The Atoms table has a UNIQUE constraint on the
// node name. If a node name is too long, a postgres
// error is generated:
// ERROR: index row size 4440 exceeds maximum 2712
// for index "atoms_type_name_key"
// There's not much that can be done about this, without
// a redesign of the table format, in some way. Maybe
// we could hash the long node names, store the hash,
// and make sure that is unique.
if (2700 < qname.size())
{
throw RuntimeException(TRACE_INFO,
"Error: do_store_single_atom: Maxiumum Node name size is 2700.\n");
}
STMT("name", qname);

// Nodes have a height of zero by definition.
Expand All @@ -875,6 +889,22 @@ void AtomStorage::do_store_single_atom(AtomPtr atom, int aheight)
if (l)
{
int arity = l->getArity();

// The Atoms table has a UNIQUE constraint on the
// outgoing set. If a link is too large, a postgres
// error is generated:
// ERROR: index row size 4440 exceeds maximum 2712
// for index "atoms_type_outgoing_key"
// The simplest solution that I see requires a database
// redesign. One could hash together the UUID's in the
// outgoing set, and then force a unique constraint on
// the hash.
if (330 < arity)
{
throw RuntimeException(TRACE_INFO,
"Error: do_store_single_atom: Maxiumum Link size is 330.\n");
}

if (arity)
{
cols += ", outgoing";
Expand Down

0 comments on commit 32f8353

Please sign in to comment.