It seems that certain table schemas do not work well with NDB events. That is, if you create a table with a particular schema and then create an event on that table, some of the column values will always be undefined when you receive that event.
After looking through the code a little, I think it might have to do with buffer alignment issues and type sizes? Something about when the NdbRecAttr objects are created. But I don't really know.
Reproducability:
Using the following schema, create a table:
CREATE TABLE `example` (
`column1` BIGINT NOT NULL,
`column2` INT NOT NULL,
`column3` TINYINT NOT NULL,
`column4` BIGINT NOT NULL,
`column5` BIGINT NOT NULL,
`column6` BIGINT NOT NULL,
PRIMARY KEY (`column1`, `column4`, `column6`)
) ENGINE=NDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs;
You can use this modified version of ndb_apievent.cpp to test: https://pastebin.com/jsLcffnQ
Or you can use your own program/modify the example yourself. Just specify the name of the table created above and use the same event columns. I created an event and specified "column1", "column2", "column3", "column4". For every received event (INSERT, UPDATE, DELETE), the pre- and post-values for "column2" and "column3" will be undefined.
Observations:
- If I specify all of the columns, then they all receive values correctly.
- If the primary key is set to just
column1, then the event described above works.
- Likewise, the event works if the primary key is set to (
column1, column4).
If this is intended behavior, then maybe it could be documented a little more clearly?
It seems that certain table schemas do not work well with NDB events. That is, if you create a table with a particular schema and then create an event on that table, some of the column values will always be undefined when you receive that event.
After looking through the code a little, I think it might have to do with buffer alignment issues and type sizes? Something about when the
NdbRecAttrobjects are created. But I don't really know.Reproducability:
Using the following schema, create a table:
You can use this modified version of
ndb_apievent.cppto test: https://pastebin.com/jsLcffnQOr you can use your own program/modify the example yourself. Just specify the name of the table created above and use the same event columns. I created an event and specified "column1", "column2", "column3", "column4". For every received event (
INSERT,UPDATE,DELETE), the pre- and post-values for "column2" and "column3" will be undefined.Observations:
column1, then the event described above works.column1,column4).If this is intended behavior, then maybe it could be documented a little more clearly?