{"record":{"id":"cc369db56a8e910b","repo":"t8y2/dbx","slug":"s-s-is-the-auto-generated-row-type-of-a-relation","errorCode":null,"errorMessage":"%s.%s is the auto-generated row type of a relation, not an independent custom type","messagePattern":"(.+?)\\.(.+?) is the auto-generated row type of a relation, not an independent custom type","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/kingbase-go/kingbase_metadata.go","lineNumber":715,"sourceCode":"\tvar typtypmod int64\n\tif 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 {\n\t\treturn nil, fmt.Errorf(\"failed to read type %s.%s: %w\", schema, name, err)\n\t}\n\tif err := rows.Close(); err != nil {\n\t\treturn nil, err\n\t}\n\tif !typisdefined {\n\t\treturn nil, fmt.Errorf(\"custom type %s.%s is not fully defined\", schema, name)\n\t}\n\tif typelem != 0 {\n\t\treturn nil, fmt.Errorf(\"custom type %s.%s is an array companion type\", schema, name)\n\t}\n\tkind, ok := customTypeKindFromCode(typtype)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"custom type %s.%s is a pseudo type (typtype=%s)\", schema, name, typtype)\n\t}\n\tif relkind.Valid && relkind.String != \"\" && relkind.String != \"c\" {\n\t\treturn nil, fmt.Errorf(\"%s.%s is the auto-generated row type of a relation, not an independent custom type\", schema, name)\n\t}\n\n\tproperties := customTypeCommonProperties(inputFn, outputFn, receiveFn, sendFn, analyzeFn, typlen, typbyval, typalign, typstorage)\n\tproperties.DomainConstraints = []customTypeDomainConstraint{}\n\tdetails := &customTypeDetails{\n\t\tName:       name,\n\t\tSchema:     schema,\n\t\tKind:       kind,\n\t\tComment:    nullStringPtr(comment),\n\t\tMembers:    []customTypeMember{},\n\t\tProperties: properties,\n\t}\n\n\tvar warnings []string\n\tswitch kind {\n\tcase customTypeKindEnum:\n\t\tdetails.Members, err = s.customTypeEnumMembers(queries.enumMembers, oid)\n\t\tif err != nil {","sourceCodeStart":697,"sourceCodeEnd":733,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/kingbase-go/kingbase_metadata.go#L697-L733","documentation":"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.","triggerScenarios":"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'.","commonSituations":"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.","solutions":["Describe the object as a table instead — use the table metadata API for the relation with that name","Exclude types whose relkind is not 'c' from the set of names you pass to the type details API","Rename your custom composite type if it unintentionally shares a name with a table","If you truly want the row-type DDL, reconstruct it from the table's CREATE TABLE statement, not the type API"],"exampleFix":"// before\ndetails, err := server.GetTypeDetails(\"public\", \"orders\") // row type of table orders\n// after\ntable, err := server.GetTableMetadata(\"public\", \"orders\") // describe it as a table","handlingStrategy":"validation","validationCode":"// check pg_class/sys_class relkind for the type's typrelid before requesting details\n// relkind 'c' = composite type relation; anything else means it's a table/view row type\nif relkind != \"\" && relkind != \"c\" { describeAsTable(schema, name) } else { requestTypeDetails(schema, name) }","typeGuard":"func isIndependentComposite(relkind string, valid bool) bool {\n  return valid && relkind == \"c\"\n}","tryCatchPattern":"details, err := server.GetTypeDetails(schema, name)\nif err != nil {\n  if strings.Contains(err.Error(), \"auto-generated row type\") {\n    return describeTableInstead(schema, name)\n  }\n  return err\n}","preventionTips":["Join pg_class/sys_class in your type enumeration and drop rows whose relkind != 'c'","Avoid naming custom composite types the same as tables in the same schema","Treat type names that match table names as relations, not types"],"tags":["metadata","custom-types","catalog","row-type","kingbase"],"backgroundTag":"relation-row-type-not-custom-type","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}