'INSERT IGNORE INTO `',keepTabl,'` (id, _iversion) SELECT entity_id AS id, _iversion FROM ',data,
' as data',IF(propertiesTableISNULL,'',CONCAT(
...
...
@@ -322,15 +299,7 @@ POV_LABEL: BEGIN
DEALLOCATEPREPAREstmtPOVkeepTbl;
ELSE
#-- generate statement from statement parts
#-- (unversioned section)
SET@stmtPOVkeepTblStr=CONCAT('INSERT IGNORE INTO `',keepTabl,'` (id)
SELECT DISTINCT entity_id AS id FROM ',data,' as data',
IF(propertiesTableISNULL,
'',
/* restrict to properties with one of the appropriate ids
* and where the domain (???) equals the entity*/
CONCAT(' WHERE EXISTS (Select 1 from `',propertiesTable,'` AS prop
WHERE prop.id = data.property_id AND (prop.id2=data.entity_id OR prop.id2=0))')));
SET@stmtPOVkeepTblStr=CONCAT('INSERT IGNORE INTO `',keepTabl,'` (id) SELECT DISTINCT entity_id AS id FROM ',data,' as data',IF(propertiesTableISNULL,'',CONCAT(' WHERE EXISTS (Select 1 from `',propertiesTable,'` AS prop WHERE prop.id = data.property_id AND (prop.id2=data.entity_id OR prop.id2=0))')));