{"id":"71a74c17ef0c5810","repo":"jackc/pgx","slug":"while-generating-load-types-query-w","errorCode":null,"errorMessage":"While generating load types query: %w","messagePattern":"While generating load types query: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"derived_types.go","lineNumber":181,"sourceCode":"}\n\n// LoadTypes performs a single (complex) query, returning all the required\n// information to register the named types, as well as any other types directly\n// or indirectly required to complete the registration.\n// The result of this call can be passed into RegisterTypes to complete the process.\nfunc (c *Conn) LoadTypes(ctx context.Context, typeNames []string) ([]*pgtype.Type, error) {\n\tm := c.TypeMap()\n\tif len(typeNames) == 0 {\n\t\treturn nil, fmt.Errorf(\"No type names were supplied.\")\n\t}\n\n\t// Disregard server version errors. This will result in\n\t// the SQL not support recent structures such as multirange\n\tserverVersion, _ := serverVersion(c)\n\tsql := buildLoadDerivedTypesSQL(serverVersion, typeNames)\n\trows, err := c.Query(ctx, sql, QueryResultFormats{TextFormatCode}, typeNames)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"While generating load types query: %w\", err)\n\t}\n\tdefer rows.Close()\n\tresult := make([]*pgtype.Type, 0, 100)\n\tfor rows.Next() {\n\t\tti := derivedTypeInfo{}\n\t\terr = rows.Scan(&ti.TypeName, &ti.NspName, &ti.Typtype, &ti.Typbasetype, &ti.Typelem, &ti.Oid, &ti.Rngtypid, &ti.Rngsubtype, &ti.Attnames, &ti.Atttypids)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"While scanning type information: %w\", err)\n\t\t}\n\t\tvar type_ *pgtype.Type\n\t\tswitch ti.Typtype {\n\t\tcase \"b\": // array\n\t\t\tdt, ok := m.TypeForOID(ti.Typelem)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"Array element OID %v not registered while loading pgtype %q\", ti.Typelem, ti.TypeName)\n\t\t\t}\n\t\t\ttype_ = &pgtype.Type{Name: ti.TypeName, OID: ti.Oid, Codec: &pgtype.ArrayCodec{ElementType: dt}}\n\t\tcase \"c\": // composite","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/derived_types.go#L163-L199","documentation":"Error \"While generating load types query: %w\" thrown in jackc/pgx.","triggerScenarios":"Thrown at derived_types.go:181 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"ec1a0befd22592cffffdeeb0a50311b506372f4c","analyzedAt":"2026-08-04T22:52:11.263Z","schemaVersion":2}