Bug #58554 Error when creating relationship between tables created from a plugin
Submitted: 29 Nov 2010 10:37 Modified: 4 Mar 2011 15:11
Reporter: Peter Pfannkuch Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench Severity:S1 (Critical)
Version:5.2.29 OS:Windows (7)
Assigned to: Alfredo Kojima CPU Architecture:Any

[29 Nov 2010 10:37] Peter Pfannkuch
Description:
When I try to create a relationship between two tables, create from a plugin, there comes the following error message:
"MySQL Workbench has encountered a problem
Es wurde versucht, im geschützten Speicher zu lesen oder zu schreiben. Dies ist häufig ein Hinweis darauf, dass anderer Speicher beschädigt ist."

How to repeat:
Take a plugin which creates two tables. Then try to create a relationship between these tables.
[29 Nov 2010 17:02] Alfredo Kojima
Please provide the plugin or the code from the plugin where the tables are created. Sounds like the plugin is not creating the tables correctly.
[30 Nov 2010 7:26] Peter Pfannkuch
here is the code, where the tables are created:

    schema = catalog.defaultSchema
    myfile = open(f.tbfile.get_string_value(),'r')
    for line in myfile:
      line = line[7:]
      line = line.replace('`', '')
      bracket = line.find('(')
      tableName = line[0:bracket]
      table = schema.addNewTable('db.mysql')
      table.name = tableName
      line = line[bracket:]
      comma = line.find(',')
      while comma != -1:
        atrStr = line[0:comma]
        parts = atrStr.split(':')
        column = grt.classes.db_mysql_Column()
        column.name = parts[0][1:]
        atrStr = parts[1][1:]
        parts = atrStr.split(' ')
        column.setParseType(parts[0], grt.root.wb.doc.physicalModels[0].catalog.simpleDatatypes)
        if len(parts) >= 2:
          column.flags.append('UNSIGNED')
        table.addColumn(column)
        line = line[comma + 1:]
        comma = line.find(',')
      column = grt.classes.db_mysql_Column()
      parts = line.split(':')
      column.name = parts[0][1:]
      line = parts[1][1:]
      parts = line.split(' ')
      if len(parts) >= 2:
        column.setParseType(parts[0], grt.root.wb.doc.physicalModels[0].catalog.simpleDatatypes)
        column.flags.append('UNSIGNED')
      else:
        column.setParseType(parts[0][0:-2], grt.root.wb.doc.physicalModels[0].catalog.simpleDatatypes)        
      table.addColumn(column)

And here are some lines from the input file:
Create `Capacity`(`upperDeviation`: Integer, `weight`: Integer, `resourceId`: Integer, `rate`: Integer, `recCreatedDate`: Datetime, `isAbsValue`: Boolean, `id`: Integer, `timeDimensionId`: Integer, `upperAmount`: Integer, `amount`: Integer, `priority`: Integer, `lowerAmount`: Integer, `deviation`: Integer, `forPreselection`: Boolean, `calendarId`: Integer, `recCreator`: Integer, `enumerationId`: Integer, `recUser`: Integer, `groupId`: Integer, `productStructureElementId`: Integer, `filter`: String, `lowerDeviation`: Integer, `attributeId`: Integer, `recChangedDate`: Datetime, `shiftNumber`: Integer)
Create `OrderMixModelLimits`(`orderMixModelId`: Integer, `orderMixLimitId`: Integer)
Create `SeqModelRuleVarValue`(`name`: String, `ruleId`: Integer, `rulevarId`: Integer, `value`: String, `id`: Integer, `modelId`: Integer)
[7 Dec 2010 12:54] Alfredo Kojima
Duplicate of bug #58752
[7 Dec 2010 13:28] Alfredo Kojima
Sorry, jumped on the gun. This is actually not a duplicate, you must set the owner field of
the columns to the table.

I'll change addColumn so that it's done automatically.
[3 Mar 2011 13:55] Johannes Taxacher
fix confirmed in repository
[4 Mar 2011 15:11] Tony Bedford
An entry has been added to the 5.2.32 changelog:

        When trying to create a relationship between two tables, created
        in a plugin, the following error was generated:

MySQL Workbench has encountered a problem
Es wurde versucht, im geschützten Speicher zu lesen oder zu schreiben. Dies ist häufig
ein Hinweis darauf, dass anderer Speicher beschädigt ist.