code: func getCharsetAndCollateInTableOption(startIdx int, options []*ast.TableOption) (ca, co string, err error) {
  	charsets := make([]string, 0, len(options))
  	collates := make([]string, 0, len(options))
  	for i := startIdx; i < len(options); i++ {
  		opt := options[i]
  		// we set the charset to the last option. example: alter table t charset latin1 charset utf8 collate utf8_bin;
  		// the charset will be utf8, collate will be utf8_bin
  		switch opt.Tp {
  		case ast.TableOptionCharset:
  			charsets = append(charsets, opt.StrValue)
  		case ast.TableOptionCollate:
  			collates = append(collates, opt.StrValue)
  		}
  	}
  
  	if len(charsets) > 1 {
  		return "", "", ErrConflictingDeclarations.GenWithStackByArgs(charsets[0], charsets[1])
  	}
  	if len(charsets) == 1 {
  		if charsets[0] == "" {
  			return "", "", ErrUnknownCharacterSet.GenWithStackByArgs("")
  		}
  		ca = charsets[0]
  	}
  	if len(collates) != 0 {
  		for i := range collates {
  			if collates[i] == "" {
  				return "", "", ErrUnknownCollation.GenWithStackByArgs("")
  			}
  			if len(ca) != 0 && !charset.ValidCharsetAndCollation(ca, collates[i]) {
  				return "", "", ErrCollationCharsetMismatch.GenWithStackByArgs(collates[i], ca)
  			}
  		}
  		co = collates[len(collates)-1]
  	}
  	return
  }
docs: // getCharsetAndCollateInTableOption will iterate the charset and collate in the options,
  // and returns the last charset and collate in options. If there is no charset in the options,
  // the returns charset will be "", the same as collate.