{"record":{"id":"f4bafc5111dd10bd","repo":"jackc/pgx","slug":"cannot-use-queryexecmodecachestatement-with-disabl","errorCode":null,"errorMessage":"cannot use QueryExecModeCacheStatement with disabled statement cache","messagePattern":"cannot use QueryExecModeCacheStatement with disabled statement cache","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"conn.go","lineNumber":130,"sourceCode":"\nfunc newProxyErr(background error, msg string) error {\n\treturn &proxyError{\n\t\tmsg:        msg,\n\t\tbackground: background,\n\t}\n}\n\ntype proxyError struct {\n\tmsg        string\n\tbackground error\n}\n\nfunc (err *proxyError) Error() string { return err.msg }\n\nfunc (err *proxyError) Unwrap() error { return err.background }\n\nvar (\n\terrDisabledStatementCache   = fmt.Errorf(\"cannot use QueryExecModeCacheStatement with disabled statement cache\")\n\terrDisabledDescriptionCache = fmt.Errorf(\"cannot use QueryExecModeCacheDescribe with disabled description cache\")\n)\n\n// Connect establishes a connection with a PostgreSQL server with a connection string. See\n// [pgconn.Connect] for details.\nfunc Connect(ctx context.Context, connString string) (*Conn, error) {\n\tconnConfig, err := ParseConfig(connString)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn connect(ctx, connConfig)\n}\n\n// ConnectWithOptions behaves exactly like Connect with the addition of options. At the present options is only used to\n// provide a [pgconn.GetSSLPasswordFunc] function.\nfunc ConnectWithOptions(ctx context.Context, connString string, options ParseConfigOptions) (*Conn, error) {\n\tconnConfig, err := ParseConfigWithOptions(connString, options)\n\tif err != nil {","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/conn.go#L112-L148","documentation":"Sentinel errDisabledStatementCache: QueryExecModeCacheStatement was selected as the default query execution mode, but the connection's statement cache was explicitly disabled (via DisablePreparedStatementCache or equivalent config). The mode requires the cache to store prepared statements, so pgx refuses the combination at query time.","triggerScenarios":"Thrown at conn.go:130 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pick a different QueryExecMode (e.g. QueryExecModeExec, QueryExecModeSimpleProtocol, or QueryExecModeCacheDescription)","Re-enable the statement cache if caching prepared statements is acceptable"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ec1a0befd22592cffffdeeb0a50311b506372f4c","analyzedAt":"2026-08-04T22:52:11.263Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}