Example #1
0
static QueryOperator *
translateInsert(Insert *insert)
{
	List *attr = getAttributeNames(insert->tableName);
	List *dts = getAttributeDataTypes(insert->tableName);
	QueryOperator *insertQuery;

	TableAccessOperator *to;
	to = createTableAccessOp(insert->tableName, NULL, NULL, NIL, deepCopyStringList(attr), dts);
	SET_BOOL_STRING_PROP(to,PROP_TABLE_IS_UPDATED);

	if (isA(insert->query,  List))
	{
		ConstRelOperator *co;
		co = createConstRelOp((List *) insert->query,NIL, deepCopyStringList(attr), dts);
		insertQuery= (QueryOperator *) co;
	}
	else
	    insertQuery =  translateQuery((Node *) insert->query);

	SetOperator *seto;
	seto = createSetOperator(SETOP_UNION, NIL, NIL, deepCopyStringList(attr));

	addChildOperator((QueryOperator *) seto, (QueryOperator *) to);
	addChildOperator((QueryOperator *) seto, insertQuery);

	INFO_LOG("translated insert:\n%s", operatorToOverviewString((Node *) seto));
	DEBUG_LOG("translated insert:\n%s", nodeToString((Node *) seto));

	return (QueryOperator *) seto;
}
//---------------------------------------------------------
void ofxXmlSettings::clearTagAttributes(const string& tag, int which){
	vector<string> names;
    getAttributeNames( tag, names, which );
	for (vector<string>::iterator i = names.begin(); i != names.end(); i++)
		removeAttribute(tag, *i, which);
}