jackc/pgx · error

unknown value

Error message

unknown value %q

What it means

The 'default_query_exec_mode' runtime parameter in the connection string was set to a value outside the five recognized modes (cache_statement, cache_describe, describe_exec, exec, simple_protocol). ParseConfig rejects the configuration before a connection is used.

Solutions

  1. Correct the default_query_exec_mode value in the connection string or RuntimeParams to one of the five supported mode names
  2. Check for typos, trailing whitespace, or case differences in the parameter value
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at conn.go:208 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/589a4c0f091968b5. Report an issue: GitHub.

Appendix: source

Thrown at conn.go:208

	}

	defaultQueryExecMode := QueryExecModeCacheStatement
	if s, ok := config.RuntimeParams["default_query_exec_mode"]; ok {
		delete(config.RuntimeParams, "default_query_exec_mode")
		switch s {
		case "cache_statement":
			defaultQueryExecMode = QueryExecModeCacheStatement
		case "cache_describe":
			defaultQueryExecMode = QueryExecModeCacheDescribe
		case "describe_exec":
			defaultQueryExecMode = QueryExecModeDescribeExec
		case "exec":
			defaultQueryExecMode = QueryExecModeExec
		case "simple_protocol":
			defaultQueryExecMode = QueryExecModeSimpleProtocol
		default:
			return nil, pgconn.NewParseConfigError(
				connString, "invalid default_query_exec_mode", fmt.Errorf("unknown value %q", s),
			)
		}
	}

	connConfig := &ConnConfig{
		Config:                   *config,
		createdByParseConfig:     true,
		StatementCacheCapacity:   statementCacheCapacity,
		DescriptionCacheCapacity: descriptionCacheCapacity,
		DefaultQueryExecMode:     defaultQueryExecMode,
		connString:               connString,
	}

	return connConfig, nil
}

// ParseConfig creates a ConnConfig from a connection string. ParseConfig handles all options that [pgconn.ParseConfig]
// does. In addition, it accepts the following options:

View on GitHub (pinned to ec1a0befd2)