当前位置: 首页>>代码示例>>C++>>正文


C++ TableDescriptor::getNumberOfAttribute方法代码示例

本文整理汇总了C++中TableDescriptor::getNumberOfAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ TableDescriptor::getNumberOfAttribute方法的具体用法?C++ TableDescriptor::getNumberOfAttribute怎么用?C++ TableDescriptor::getNumberOfAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TableDescriptor的用法示例。


在下文中一共展示了TableDescriptor::getNumberOfAttribute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: InsertData

void InsertData(Catalog *catalog, Node *node, ResultSet *&result_set, bool &result_flag, string &error_msg, string &info) {
	bool has_warning = false;
	bool is_correct = true;
	bool is_all_col = false;
	Insert_stmt *insert_stmt = (Insert_stmt *)node;

	string table_name(insert_stmt->tablename);
	TableDescriptor *table = Environment::getInstance()->getCatalog()->getTable(table_name);
	if(table == NULL)
	{
		//				ASTParserLogging::elog("The table %s does not exist!", table_name.c_str());
		error_msg = "The table "+table_name+" does not exist!";
		result_flag = false;
		result_set = NULL;
		return;
	}

	unsigned col_count = 0;
	Columns *col = (Columns *)insert_stmt->col_list;
	if (col == NULL) {	// insert all columns
		is_all_col = true;
	}
	else {	// get insert column count
		++col_count;
		while(col = (Columns *)col->next) ++col_count;
	}

	Insert_val_list *insert_value_list = (Insert_val_list*)insert_stmt->insert_val_list;
	if (insert_value_list == NULL) {
		//				ASTParserLogging::elog("No value!");
		error_msg = "No value!";
		result_flag = false;
		result_set = NULL;
		return;
	}

	ostringstream ostr;
	int changed_row_num = 0;
	while(insert_value_list)	// 循环获得 (……),(……),(……)中的每一个(……)
	{
		// make sure: the insert column count = insert value count = used column count = used value count

		// init
		Insert_vals *insert_value = (Insert_vals *)insert_value_list->insert_vals;
		col = (Columns *)insert_stmt->col_list;

		if (is_all_col)	// insert all columns
		{
			// by scdong: Claims adds a default row_id attribute for all tables which is attribute(0), when inserting tuples we should begin to construct the string_tuple from the second attribute.
			for(unsigned int position = 1; position < table->getNumberOfAttribute(); position++)
			{
				// check value count
				if (insert_value == NULL)
				{
					//							ASTParserLogging::elog("Value count is too few");
					is_correct = false;
					error_msg = "Value count is too few";
					result_flag = false;
					result_set = NULL;
					break;
				}

				// insert value to ostringstream and if has warning return 1;	look out the order!
				has_warning = InsertValueToStream(insert_value, table, position, ostr) || has_warning;

				// move back
				insert_value = (Insert_vals*)insert_value->next;
				ostr<<"|";
			}

			if (!is_correct) break;

			// check insert value count
			if (insert_value)
			{
				//						ASTParserLogging::elog("Value count is too many");
				error_msg = "Value count is too many";
				result_flag = false;
				result_set = NULL;
				is_correct = false;
				break;
			}
		}
		else	//insert part of columns
		{
			// get insert value count and check whether it match column count
			unsigned insert_value_count = 0;
			while (insert_value)
			{
				++insert_value_count;
				insert_value = (Insert_vals*)insert_value->next;
			}
			if (insert_value_count != col_count)
			{
				//						ASTParserLogging::elog("Column count doesn't match value count");
				error_msg = "Column count doesn't match value count";
				result_flag = false;
				result_set = NULL;
				is_correct = false;
				break;
//.........这里部分代码省略.........
开发者ID:wangli1426,项目名称:Claims,代码行数:101,代码来源:ExecuteLogicalQueryPlan.cpp


注:本文中的TableDescriptor::getNumberOfAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。