[Shein-Feature] support auto_increment attribute for part column
This commit is contained in:
		@ -1875,6 +1875,10 @@ int ObInsertResolver::save_autoinc_params(uint64_t table_offset /*default 0*/)
 | 
			
		||||
          if (OB_HIDDEN_PK_INCREMENT_COLUMN_ID == column_id) {
 | 
			
		||||
            param.autoinc_increment_ = 1;
 | 
			
		||||
            param.autoinc_offset_ = 1;
 | 
			
		||||
            param.part_value_no_order_ = true;
 | 
			
		||||
          } else if (column_schema->is_tbl_part_key_column()) {
 | 
			
		||||
            // don't keep intra-partition value asc order when partkey column is auto inc
 | 
			
		||||
            param.part_value_no_order_ = true;
 | 
			
		||||
          }
 | 
			
		||||
          uint64_t tid = insert_stmt->get_insert_table_id(table_offset);
 | 
			
		||||
          const ObIArray<ObColumnRefRawExpr*>* table_columns = NULL;
 | 
			
		||||
 | 
			
		||||
@ -619,6 +619,32 @@ int ObInsertStmt::part_key_has_rand_value(bool& has)
 | 
			
		||||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int ObInsertStmt::part_key_has_auto_inc(bool& has)
 | 
			
		||||
{
 | 
			
		||||
  int ret = OB_SUCCESS;
 | 
			
		||||
  const ObIArray<ObColumnRefRawExpr*>* table_columns = get_table_columns();
 | 
			
		||||
  if (OB_ISNULL(table_columns)) {
 | 
			
		||||
    ret = OB_ERR_UNEXPECTED;
 | 
			
		||||
  } else {
 | 
			
		||||
    has = false;
 | 
			
		||||
    for (int64_t i = 0; OB_SUCCESS == ret && i < table_columns->count(); ++i) {
 | 
			
		||||
      ObColumnRefRawExpr* col_expr = table_columns->at(i);
 | 
			
		||||
      if (IS_SHADOW_COLUMN(col_expr->get_column_id())) {
 | 
			
		||||
        // do nothing
 | 
			
		||||
      } else if (OB_FAIL(ObTransformUtils::get_base_column(this, col_expr))) {
 | 
			
		||||
        LOG_WARN("failed to get base column", K(ret));
 | 
			
		||||
      } else if (OB_ISNULL(col_expr)) {
 | 
			
		||||
        ret = OB_ERR_UNEXPECTED;
 | 
			
		||||
        LOG_WARN("get unexpected null", K(ret));
 | 
			
		||||
      } else if (col_expr->is_table_part_key_column() && col_expr->is_auto_increment()) {
 | 
			
		||||
        has = true;
 | 
			
		||||
        break;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int ObInsertStmt::part_key_has_subquery(bool& has)
 | 
			
		||||
{
 | 
			
		||||
  int ret = OB_SUCCESS;
 | 
			
		||||
 | 
			
		||||
@ -209,6 +209,7 @@ public:
 | 
			
		||||
      const common::ObIArray<ObRawExpr*>& other_exprs, const common::ObIArray<ObRawExpr*>& new_exprs) override;
 | 
			
		||||
  int part_key_has_rand_value(bool& has);
 | 
			
		||||
  int part_key_has_subquery(bool& has);
 | 
			
		||||
  int part_key_has_auto_inc(bool& has);
 | 
			
		||||
  int get_value_exprs(ObIArray<ObRawExpr*>& value_exprs);
 | 
			
		||||
 | 
			
		||||
  // if generated col is partition key in heap table, we need to store all dep cols,
 | 
			
		||||
 | 
			
		||||
@ -2964,11 +2964,6 @@ int ObResolverUtils::resolve_columns_for_partition_expr(ObRawExpr*& expr, ObIArr
 | 
			
		||||
              q_name.col_name_.ptr(),
 | 
			
		||||
              scope_name.length(),
 | 
			
		||||
              scope_name.ptr());
 | 
			
		||||
        } else if (col_schema->is_autoincrement()) {
 | 
			
		||||
          ret = OB_ERR_AUTO_PARTITION_KEY;
 | 
			
		||||
          LOG_USER_ERROR(OB_ERR_AUTO_PARTITION_KEY,
 | 
			
		||||
              col_schema->get_column_name_str().length(),
 | 
			
		||||
              col_schema->get_column_name_str().ptr());
 | 
			
		||||
        } else if (OB_FAIL(partition_keys.push_back(q_name.col_name_))) {
 | 
			
		||||
          LOG_WARN("add column name failed", K(ret), K_(q_name.col_name));
 | 
			
		||||
        } else if (OB_FAIL(ObRawExprUtils::init_column_expr(*col_schema, *col_expr))) {
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user