Skip to content

Commit fc8cddc

Browse files
pgwire: update statusReportParams to match PostgreSQL 18 (#169847)
pgwire: update statusReportParams to match PostgreSQL 18
2 parents 0c5b33a + cef5645 commit fc8cddc

10 files changed

Lines changed: 58 additions & 11 deletions

File tree

docs/generated/sql/session_vars.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ SHOW application_name;
113113
<tr><td><code>foreign_key_cascades_limit</code></td><td>Sets the maximum number of cascading operations for foreign key actions.</td><td><code>10000</code></td><td>No</td><td><code>sql.defaults.foreign_key_cascades_limit</code></td></tr>
114114
<tr><td><code>idle_in_transaction_session_timeout</code></td><td>Sets the maximum allowed duration for an idle transaction session. The session is terminated if it exceeds this limit.</td><td><code>0s</code></td><td>No</td><td><code>sql.defaults.idle_in_transaction_session_timeout</code></td></tr>
115115
<tr><td><code>idle_session_timeout</code></td><td>Sets the maximum allowed duration for an idle session. The session is terminated if it exceeds this limit.</td><td><code>0s</code></td><td>No</td><td><code>sql.defaults.idle_in_session_timeout</code></td></tr>
116+
<tr><td><code>in_hot_standby</code></td><td>Reports whether the server is currently in hot standby mode (always off in CockroachDB).</td><td><code>off</code></td><td>Yes</td><td>-</td></tr>
116117
<tr><td><code>index_join_streamer_batch_size</code></td><td>Sets the size limit on input rows to the ColIndexJoin operator when using the Streamer API for a single lookup KV batch.</td><td><code>8.0 MiB</code></td><td>No</td><td><code>sql.distsql.index_join_streamer.batch_size</code></td></tr>
117118
<tr><td><code>index_recommendations_enabled</code></td><td>Controls whether index recommendations are enabled.</td><td><code>on</code></td><td>No</td><td>-</td></tr>
118119
<tr><td><code>initial_retry_backoff_for_read_committed</code></td><td>Sets the initial backoff duration for automatic retries of statements in explicit READ COMMITTED transactions that encounter retry errors.</td><td><code>2ms</code></td><td>No</td><td>-</td></tr>
@@ -213,6 +214,7 @@ SHOW application_name;
213214
<tr><td><code>results_buffer_size</code></td><td>Specifies the size at which the pgwire results buffer will self-flush.</td><td><code>-</code></td><td>Yes</td><td>-</td></tr>
214215
<tr><td><code>role</code></td><td>The current role for the session.</td><td><code>none</code></td><td>No</td><td>-</td></tr>
215216
<tr><td><code>row_security</code></td><td>Controls whether row level security is enabled.</td><td><code>on</code></td><td>No</td><td>-</td></tr>
217+
<tr><td><code>scram_iterations</code></td><td>Reports the iteration count for SCRAM-SHA-256 password hashing.</td><td><code>10610</code></td><td>Yes</td><td>-</td></tr>
216218
<tr><td><code>search_path</code></td><td>Sets the list of namespaces to search when resolving unqualified names.</td><td><code>"$user", public</code></td><td>No</td><td>-</td></tr>
217219
<tr><td><code>serial_normalization</code></td><td>Controls how `SERIAL` columns are normalized.</td><td><code>rowid</code></td><td>No</td><td><code>sql.defaults.serial_normalization</code></td></tr>
218220
<tr><td><code>server_encoding</code></td><td>Reports the database encoding (always UTF8). This cannot be changed.</td><td><code>UTF8</code></td><td>Yes</td><td>-</td></tr>

pkg/ccl/sqlproxyccl/authentication.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,12 @@ var authenticate = func(
4343
return nil
4444
}
4545

46-
// The auth step should require only a few back and forths so 20 iterations
47-
// should be enough.
46+
// The auth step should require only a few back and forths so 30 iterations
47+
// should be enough. Note that each ParameterStatus message sent after
48+
// authentication counts as one iteration, and there can be 15+ of these
49+
// in addition to auth exchange messages (e.g. 4 for SCRAM-SHA-256).
4850
var i int
49-
for ; i < 20; i++ {
51+
for ; i < 30; i++ {
5052
// Read the server response and forward it to the client.
5153
// TODO(spaskob): in verbose mode, log these messages.
5254
backendMsg, err := be.Receive()
@@ -202,10 +204,11 @@ var readTokenAuthResult = func(conn net.Conn) (*pgproto3.BackendKeyData, error)
202204
serverConn := interceptor.NewFrontendConn(conn)
203205

204206
var backendKeyData *pgproto3.BackendKeyData
205-
// The auth step should require only a few back and forths so 20 iterations
206-
// should be enough.
207+
// The auth step should require only a few back and forths so 30 iterations
208+
// should be enough. Note that each ParameterStatus message sent after
209+
// authentication counts as one iteration.
207210
var i int
208-
for ; i < 20; i++ {
211+
for ; i < 30; i++ {
209212
backendMsg, err := serverConn.ReadMsg()
210213
if err != nil {
211214
return nil, withCode(

pkg/cmd/roachtest/tests/npgsql_blocklist.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ var npgsqlBlocklist = blocklist{
190190
`Npgsql.Tests.FunctionTests.Param_Output`: "unknown",
191191
`Npgsql.Tests.FunctionTests.Resultset`: "unknown",
192192
`Npgsql.Tests.LargeObjectTests.Test`: "unknown",
193-
`Npgsql.Tests.MultipleHostsTests.Offline_state_on_query_execution_pg_non_critical_failure`: "169330",
194193
`Npgsql.Tests.NestedDataReaderTests.Basic`: "unknown",
195194
`Npgsql.Tests.NestedDataReaderTests.Composite`: "51480",
196195
`Npgsql.Tests.NestedDataReaderTests.Different_field_count`: "unknown",

pkg/sql/exec_util.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3560,6 +3560,8 @@ var bufferableParamStatusUpdates = func() []bufferableParamStatusUpdate {
35603560
"IntervalStyle",
35613561
"is_superuser",
35623562
"TimeZone",
3563+
"default_transaction_read_only",
3564+
"search_path",
35633565
}
35643566
ret := make([]bufferableParamStatusUpdate, len(params))
35653567
for i, param := range params {

pkg/sql/logictest/testdata/logic_test/information_schema

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3957,6 +3957,7 @@ force_savepoint_restart off
39573957
foreign_key_cascades_limit 10000
39583958
idle_in_transaction_session_timeout 0
39593959
idle_session_timeout 0
3960+
in_hot_standby off
39603961
index_join_streamer_batch_size 8.0 MiB
39613962
index_recommendations_enabled off
39623963
initial_retry_backoff_for_read_committed 2
@@ -4055,6 +4056,7 @@ require_explicit_primary_keys off
40554056
results_buffer_size 524288
40564057
role none
40574058
row_security on
4059+
scram_iterations 10610
40584060
search_path "$user", public
40594061
serial_normalization rowid
40604062
server_encoding UTF8

pkg/sql/logictest/testdata/logic_test/pg_catalog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3366,6 +3366,7 @@ force_savepoint_restart off
33663366
foreign_key_cascades_limit 10000 NULL NULL NULL string
33673367
idle_in_transaction_session_timeout 0 NULL NULL NULL string
33683368
idle_session_timeout 0 NULL NULL NULL string
3369+
in_hot_standby off NULL NULL NULL string
33693370
index_join_streamer_batch_size 8.0 MiB NULL NULL NULL string
33703371
index_recommendations_enabled off NULL NULL NULL string
33713372
initial_retry_backoff_for_read_committed 2 NULL NULL NULL string
@@ -3463,6 +3464,7 @@ require_explicit_primary_keys off
34633464
results_buffer_size 524288 NULL NULL NULL string
34643465
role none NULL NULL NULL string
34653466
row_security on NULL NULL NULL string
3467+
scram_iterations 10610 NULL NULL NULL string
34663468
search_path "$user", public NULL NULL NULL string
34673469
serial_normalization rowid NULL NULL NULL string
34683470
server_encoding UTF8 NULL NULL NULL string
@@ -3628,6 +3630,7 @@ force_savepoint_restart off
36283630
foreign_key_cascades_limit 10000 NULL user NULL 10000 10000
36293631
idle_in_transaction_session_timeout 0 ms user NULL 0s 0s
36303632
idle_session_timeout 0 ms user NULL 0s 0s
3633+
in_hot_standby off NULL user NULL off off
36313634
index_join_streamer_batch_size 8.0 MiB B user NULL 8.0 MiB 8.0 MiB
36323635
index_recommendations_enabled off NULL user NULL on false
36333636
initial_retry_backoff_for_read_committed 2 NULL user NULL 2ms 2ms
@@ -3725,6 +3728,7 @@ require_explicit_primary_keys off
37253728
results_buffer_size 524288 NULL user NULL 524288 524288
37263729
role none NULL user NULL none none
37273730
row_security on NULL user NULL on on
3731+
scram_iterations 10610 NULL user NULL 10610 10610
37283732
search_path "$user", public NULL user NULL "$user", public "$user", public
37293733
serial_normalization rowid NULL user NULL rowid rowid
37303734
server_encoding UTF8 NULL user NULL UTF8 UTF8
@@ -3878,6 +3882,7 @@ force_savepoint_restart NULL NULL
38783882
foreign_key_cascades_limit NULL NULL NULL NULL NULL
38793883
idle_in_transaction_session_timeout NULL NULL NULL NULL NULL
38803884
idle_session_timeout NULL NULL NULL NULL NULL
3885+
in_hot_standby NULL NULL NULL NULL NULL
38813886
index_join_streamer_batch_size NULL NULL NULL NULL NULL
38823887
index_recommendations_enabled NULL NULL NULL NULL NULL
38833888
initial_retry_backoff_for_read_committed NULL NULL NULL NULL NULL
@@ -3978,6 +3983,7 @@ require_explicit_primary_keys NULL NULL
39783983
results_buffer_size NULL NULL NULL NULL NULL
39793984
role NULL NULL NULL NULL NULL
39803985
row_security NULL NULL NULL NULL NULL
3986+
scram_iterations NULL NULL NULL NULL NULL
39813987
search_path NULL NULL NULL NULL NULL
39823988
serial_normalization NULL NULL NULL NULL NULL
39833989
server_encoding NULL NULL NULL NULL NULL

pkg/sql/logictest/testdata/logic_test/show_source

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ force_savepoint_restart off
123123
foreign_key_cascades_limit 10000 Sets the maximum number of cascading operations for foreign key actions.
124124
idle_in_transaction_session_timeout 0 Sets the maximum allowed duration for an idle transaction session. The session is terminated if it exceeds this limit.
125125
idle_session_timeout 0 Sets the maximum allowed duration for an idle session. The session is terminated if it exceeds this limit.
126+
in_hot_standby off Reports whether the server is currently in hot standby mode (always off in CockroachDB).
126127
index_join_streamer_batch_size 8.0 MiB Sets the size limit on input rows to the ColIndexJoin operator when using the Streamer API for a single lookup KV batch.
127128
index_recommendations_enabled off Controls whether index recommendations are enabled.
128129
initial_retry_backoff_for_read_committed 2 Sets the initial backoff duration for automatic retries of statements in explicit READ COMMITTED transactions that encounter retry errors.
@@ -220,6 +221,7 @@ require_explicit_primary_keys off
220221
results_buffer_size 524288 Specifies the size at which the pgwire results buffer will self-flush.
221222
role none The current role for the session.
222223
row_security on Controls whether row level security is enabled.
224+
scram_iterations 10610 Reports the iteration count for SCRAM-SHA-256 password hashing.
223225
search_path "$user", public Sets the list of namespaces to search when resolving unqualified names.
224226
serial_normalization rowid Controls how `SERIAL` columns are normalized.
225227
server_encoding UTF8 Reports the database encoding (always UTF8). This cannot be changed.

pkg/sql/pgwire/conn.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,7 @@ func (c *conn) sendInitialConnData(
322322
return sql.ConnectionHandler{}, err
323323
}
324324
}
325-
// The two following status parameters have no equivalent session
326-
// variable.
325+
// session_authorization has no equivalent session variable.
327326
if err := c.bufferParamStatus("session_authorization", c.sessionArgs.User.Normalized()); err != nil {
328327
return sql.ConnectionHandler{}, err
329328
}
@@ -1485,19 +1484,23 @@ func (r *pgwireReader) ReadByte() (byte, error) {
14851484
// initialization.
14861485
//
14871486
// The standard PostgreSQL status vars are listed here:
1488-
// https://www.postgresql.org/docs/10/static/libpq-status.html
1487+
// https://www.postgresql.org/docs/18/libpq-status.html
14891488
var statusReportParams = []string{
14901489
"server_version",
14911490
"server_encoding",
14921491
"client_encoding",
14931492
"application_name",
1494-
// Note: session_authorization is handled specially in serveImpl().
1493+
// Note: session_authorization is handled specially in sendInitialConnData().
14951494
"DateStyle",
14961495
"IntervalStyle",
14971496
"is_superuser",
14981497
"TimeZone",
14991498
"integer_datetimes",
15001499
"standard_conforming_strings",
1500+
"default_transaction_read_only",
1501+
"search_path",
1502+
"scram_iterations",
1503+
"in_hot_standby",
15011504
"crdb_version", // CockroachDB extension.
15021505
}
15031506

pkg/sql/session_var_descriptions.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ var sessionVarDescriptions = map[string]string{
106106
"initial_retry_backoff_for_read_committed": "Sets the initial backoff duration for automatic retries of statements in explicit READ COMMITTED transactions that encounter retry errors.",
107107
"inject_retry_errors_enabled": "Causes statements (except SET) inside explicit transactions to return a transaction retry error for testing application retry logic. If the client retries using the cockroach_restart savepoint, the transaction proceeds normally after the 3rd retry error.",
108108
"inject_retry_errors_on_commit_enabled": "Causes statements inside explicit transactions to return a retry error just before transaction commit for testing retry logic.",
109+
"in_hot_standby": "Reports whether the server is currently in hot standby mode (always off in CockroachDB).",
109110
"integer_datetimes": "Reports whether integer datetime representation is used (always on).",
110111
"internal": "Indicates whether this query came from InternalExecutor or an internal planner.",
111112
"intervalstyle": "Controls the display format for `INTERVAL` values.",
@@ -187,6 +188,7 @@ var sessionVarDescriptions = map[string]string{
187188
"parallelize_multi_key_lookup_joins_max_lookup_ratio": "Sets the maximum lookup ratio threshold for parallelizing multi-key lookup joins.",
188189
"parallelize_multi_key_lookup_joins_only_on_mr_mutations": "Controls whether parallelization of multi-key lookup joins is restricted to multi-row mutations only.",
189190
"password_encryption": "The encryption method used for passwords.",
191+
"scram_iterations": "Reports the iteration count for SCRAM-SHA-256 password hashing.",
190192
"pg_dump_compatibility": "Controls how CockroachDB presents metadata to external tools. Valid values: off (default), postgres (suppress CRDB-specific syntax for pg_dump compatibility), cockroachdb (show CRDB syntax explicitly).",
191193
"pg_trgm.similarity_threshold": "Sets the value used to compare trigram similarities for the string % string overload.",
192194
"plan_cache_mode": "Controls the method that the optimizer should use to choose between a custom and generic query plan.",

0 commit comments

Comments
 (0)