jackc/pgx · error

extended protocol limited to

Error message

extended protocol limited to %v parameters

What it means

An extended-protocol query (parameterized) was attempted with more than 65535 parameters, which is the protocol limit (uint16 parameter count in Bind). The command is rejected before any bytes are sent.

Solutions

  1. Reduce the number of parameters below 65536
  2. Batch the work into multiple statements
  3. Use CopyFrom for bulk data insertion
  4. Build the SQL with fewer placeholders per statement
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pgconn/pgconn.go:1345 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of jackc/pgx@ec1a0befd2 (2026-08-04). Data as JSON: /api/errors/9b77d6ca0e4eadb2. Report an issue: GitHub.

Appendix: source

Thrown at pgconn/pgconn.go:1345

	return result
}

func (pgConn *PgConn) execExtendedPrefix(ctx context.Context, paramValues [][]byte) *ResultReader {
	pgConn.resultReader = ResultReader{
		pgConn: pgConn,
		ctx:    ctx,
	}
	result := &pgConn.resultReader

	if err := pgConn.lock(); err != nil {
		result.concludeCommand(CommandTag{}, err)
		result.closed = true
		return result
	}

	if len(paramValues) > math.MaxUint16 {
		result.concludeCommand(CommandTag{}, fmt.Errorf("extended protocol limited to %v parameters", math.MaxUint16))
		result.closed = true
		pgConn.unlock()
		return result
	}

	if ctx != context.Background() {
		select {
		case <-ctx.Done():
			result.concludeCommand(CommandTag{}, newContextAlreadyDoneError(ctx))
			result.closed = true
			pgConn.unlock()
			return result
		default:
		}
		pgConn.contextWatcher.Watch(ctx)
	}

	return result

View on GitHub (pinned to ec1a0befd2)