t8y2/dbx · error

%s.%s is the auto-generated row type of a relation, not an i

Error message

%s.%s is the auto-generated row type of a relation, not an independent custom type

What it means

Every table, view, or foreign table in the catalog implicitly owns a composite type (its row type) with the same name, and relkind records the relation kind. The driver refuses to describe such auto-generated row types as 'custom types' because they have no independent CREATE TYPE statement — only a composite ('c') relkind is accepted.

Source

Thrown at agents/drivers/kingbase-go/kingbase_metadata.go:715

	var typtypmod int64
	if err := rows.Scan(&oid, &typtype, &typisdefined, &typbasetype, &typnotnull, &typrelid, &typelem, &typcollation, &typdefaultbin, &typdefault, &typlen, &typbyval, &typalign, &typstorage, &typtypmod, &inputFn, &outputFn, &receiveFn, &sendFn, &analyzeFn, &comment, &relkind, &collname); err != nil {
		return nil, fmt.Errorf("failed to read type %s.%s: %w", schema, name, err)
	}
	if err := rows.Close(); err != nil {
		return nil, err
	}
	if !typisdefined {
		return nil, fmt.Errorf("custom type %s.%s is not fully defined", schema, name)
	}
	if typelem != 0 {
		return nil, fmt.Errorf("custom type %s.%s is an array companion type", schema, name)
	}
	kind, ok := customTypeKindFromCode(typtype)
	if !ok {
		return nil, fmt.Errorf("custom type %s.%s is a pseudo type (typtype=%s)", schema, name, typtype)
	}
	if relkind.Valid && relkind.String != "" && relkind.String != "c" {
		return nil, fmt.Errorf("%s.%s is the auto-generated row type of a relation, not an independent custom type", schema, name)
	}

	properties := customTypeCommonProperties(inputFn, outputFn, receiveFn, sendFn, analyzeFn, typlen, typbyval, typalign, typstorage)
	properties.DomainConstraints = []customTypeDomainConstraint{}
	details := &customTypeDetails{
		Name:       name,
		Schema:     schema,
		Kind:       kind,
		Comment:    nullStringPtr(comment),
		Members:    []customTypeMember{},
		Properties: properties,
	}

	var warnings []string
	switch kind {
	case customTypeKindEnum:
		details.Members, err = s.customTypeEnumMembers(queries.enumMembers, oid)
		if err != nil {

View on GitHub (pinned to c0390bff16)

Solutions

  1. Describe the object as a table instead — use the table metadata API for the relation with that name
  2. Exclude types whose relkind is not 'c' from the set of names you pass to the type details API
  3. Rename your custom composite type if it unintentionally shares a name with a table
  4. If you truly want the row-type DDL, reconstruct it from the table's CREATE TABLE statement, not the type API

Example fix

// before
details, err := server.GetTypeDetails("public", "orders") // row type of table orders
// after
table, err := server.GetTableMetadata("public", "orders") // describe it as a table
Defensive patterns

Strategy: validation

Validate before calling

// check pg_class/sys_class relkind for the type's typrelid before requesting details
// relkind 'c' = composite type relation; anything else means it's a table/view row type
if relkind != "" && relkind != "c" { describeAsTable(schema, name) } else { requestTypeDetails(schema, name) }

Type guard

func isIndependentComposite(relkind string, valid bool) bool {
  return valid && relkind == "c"
}

Try / catch

details, err := server.GetTypeDetails(schema, name)
if err != nil {
  if strings.Contains(err.Error(), "auto-generated row type") {
    return describeTableInstead(schema, name)
  }
  return err
}

Prevention

When it happens

Trigger: Calling getTypeDetails (or the custom type details metadata API) with a type name that is actually the row type of a table or view, e.g. table 'foo' implicitly creating type 'foo' — detected when relkind is valid, non-empty, and not 'c'.

Common situations: Developer introspects a type name that collides with a table name in the same schema; enumerating all composite types from pg_type/sys_type without joining the relation catalog; an ORM named a type after a table.

Related errors


AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05). Data as JSON: /api/errors/cc369db56a8e910b. Report an issue: GitHub.