​Hi!

We are facing a problem with MERGE Tables.​ 

We have a process in php which connects to the DB using the mapi (https://www.monetdb.org/Documentation/Manuals/SQLreference/Programming/MAPI

The process creates a new table everyday as follows:
CREATE TABLE cub8_20160717 AS (SELECT * FROM cub8) WITH NO DATA;

Then, attaches that new table to the MERGE table called cub8_cubo as follows:
ALTER TABLE cub8_cubo ADD TABLE cub8_20160717 ;

Once all this is created, it start inserting data.

Everything works fine, with NO errors. BUT if I run a query against cub8_cubo I dont see cub8_20160717 data.

So I run this query in order to check if the new table was attached to the merge:
SELECT a.name, b.name, s.name FROM sys.tables as a JOIN sys.dependencies d ON a.id = d.depend_id JOIN sys.tables as b ON b.id= d.id JOIN sys.schemas as s ON a.schema_id = s.id WHERE a.type= 3 AND a.name  ILIKE '%cub8%' ORDER BY 1,2;

+-----------+---------------+
| name      | name          |
+===========+===============+
| cub8_cubo | cub8_20160710 |
| cub8_cubo | cub8_20160711 |
| cub8_cubo | cub8_20160712 |
| cub8_cubo | cub8_20160713 |
| cub8_cubo | cub8_20160714 |
| cub8_cubo | cub8_20160715 |
| cub8_cubo | cub8_20160716 |
| cub8_cubo | cub8_20160717 |


So I try to detached from cub8_cubo, with the command:
ALTER TABLE cub8_cubo DROP TABLE cub8_20160717;

ALTER TABLE: table 'sb_traf.cub8_20160717' isn't part of the MERGE TABLE 'sb_traf.cub8_cubo'

So I ADD it again:
ALTER TABLE cub8_cubo ADD TABLE cub8_20160717;

and now yes... I can see the data. If I need to detach that table, I need to run ALTER ... DROP twice or three times to get it done.

It seems to be a bug?, are we doing something wrong ??

Thks in advance!

PS.:We are using 
MonetDB Database Server v1.7 (Jun2016)
Welcome to mclient, the MonetDB/SQL interactive terminal (Jun2016)