{"record":{"id":"bce223463ed2711e","repo":"jackc/pgx","slug":"stmt-exec-deprecated-and-not-implemented","errorCode":null,"errorMessage":"Stmt.Exec deprecated and not implemented","messagePattern":"Stmt\\.Exec deprecated and not implemented","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"stdlib/sql.go","lineNumber":612,"sourceCode":"\tdefer cancel()\n\n\trefCount := s.conn.psRefCounts[s.sd]\n\tif refCount == 1 {\n\t\tdelete(s.conn.psRefCounts, s.sd)\n\t} else {\n\t\ts.conn.psRefCounts[s.sd]--\n\t\treturn nil\n\t}\n\n\treturn s.conn.conn.Deallocate(ctx, s.sd.SQL)\n}\n\nfunc (s *Stmt) NumInput() int {\n\treturn len(s.sd.ParamOIDs)\n}\n\nfunc (s *Stmt) Exec(argsV []driver.Value) (driver.Result, error) {\n\treturn nil, errors.New(\"Stmt.Exec deprecated and not implemented\")\n}\n\nfunc (s *Stmt) ExecContext(ctx context.Context, argsV []driver.NamedValue) (driver.Result, error) {\n\treturn s.conn.ExecContext(ctx, s.sd.SQL, argsV)\n}\n\nfunc (s *Stmt) Query(argsV []driver.Value) (driver.Rows, error) {\n\treturn nil, errors.New(\"Stmt.Query deprecated and not implemented\")\n}\n\nfunc (s *Stmt) QueryContext(ctx context.Context, argsV []driver.NamedValue) (driver.Rows, error) {\n\treturn s.conn.QueryContext(ctx, s.sd.SQL, argsV)\n}\n\ntype rowValueFunc func(src []byte) (driver.Value, error)\n\ntype Rows struct {\n\tconn         *Conn","sourceCodeStart":594,"sourceCodeEnd":630,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/stdlib/sql.go#L594-L630","documentation":"stdlib Stmt.Exec implements database/sql's deprecated single-round-trip Exec hook, which pgx deliberately does not support: it always returns this error. Any call is a faulty-input situation — modern database/sql always uses ExecContext instead, so hitting it means an old driver or direct invocation.","triggerScenarios":"Thrown at stdlib/sql.go:612 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use Stmt.ExecContext instead of Stmt.Exec; ExecContext is implemented and delegates to conn.ExecContext with the statement's SQL and named arguments.","Retrieve the underlying SQL via s.sd.SQL and execute it directly through the *sql.DB or *sql.Conn handle.","If implementing a driver.Stmt, note pgx deliberately does not support the deprecated Exec path."],"exampleFix":null,"handlingStrategy":"fallback","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"}