Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions pkg/sql/logictest/logic.go
Original file line number Diff line number Diff line change
Expand Up @@ -1253,26 +1253,30 @@ func (t *logicTest) getOrOpenClient(user string, nodeIdx int, newSession bool) *
}
pgURL.Path = "test"

db := t.openDB(pgURL)

// The default value for extra_float_digits assumed by tests is
// 1. However, lib/pq by default configures this to 2 during
// connection initialization, so we need to set it back to 1 before
// we run anything.
if _, err := db.Exec("SET extra_float_digits = 1"); err != nil {
// Set some session variables to non-default values in every connection. We do
// this via PG URL options rather than SET SQL statements because we need
// lib/pq to set these session variables in every new connection created for
// the database/sql connection pool.
opts, err := url.ParseQuery(pgURL.RawQuery)
if err != nil {
t.Fatal(err)
}
// The default value for extra_float_digits assumed by tests is 1. However,
// lib/pq by default configures this to 2 during connection initialization, so
// we need to set it back to 1 before we run anything.
opts.Add("extra_float_digits", "1")
// The default setting for index_recommendations_enabled is true. We do not
// want to display index recommendations in logic tests, so we disable them
// here.
if _, err := db.Exec("SET index_recommendations_enabled = false"); err != nil {
t.Fatal(err)
}
opts.Add("index_recommendations_enabled", "false")
// Set default transaction isolation if it is not serializable.
if iso := t.cfg.EnableDefaultIsolationLevel; iso != 0 {
if _, err := db.Exec(fmt.Sprintf("SET default_transaction_isolation = '%s'", iso)); err != nil {
t.Fatal(err)
}
opts.Add("default_transaction_isolation", iso.String())
}
pgURL.RawQuery = opts.Encode()

db := t.openDB(pgURL)

if t.clients == nil {
t.clients = make(map[string]map[int]*gosql.DB)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/sql/logictest/testdata/logic_test/pg_catalog
Original file line number Diff line number Diff line change
Expand Up @@ -3095,13 +3095,13 @@ experimental_enable_implicit_column_partitioning off N
experimental_enable_temp_tables off NULL user NULL off off
experimental_enable_unique_without_index_constraints on NULL user NULL off off
experimental_hash_group_join_enabled off NULL user NULL off off
extra_float_digits 1 NULL user NULL 1 2
extra_float_digits 1 NULL user NULL 1 1
force_savepoint_restart off NULL user NULL off off
foreign_key_cascades_limit 10000 NULL user NULL 10000 10000
idle_in_transaction_session_timeout 0 NULL user NULL 0s 0s
idle_session_timeout 0 NULL user NULL 0s 0s
index_join_streamer_batch_size 8.0 MiB NULL user NULL 8.0 MiB 8.0 MiB
index_recommendations_enabled off NULL user NULL on on
index_recommendations_enabled off NULL user NULL on false
inject_retry_errors_enabled off NULL user NULL off off
inject_retry_errors_on_commit_enabled off NULL user NULL off off
integer_datetimes on NULL user NULL on on
Expand Down
5 changes: 0 additions & 5 deletions pkg/sql/logictest/testdata/logic_test/select_for_share
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,6 @@ SELECT * FROM t WHERE a = 1 FOR SHARE;

user root

query TTTTTTTBB colnames,retry,rowsort
SELECT database_name, schema_name, table_name, lock_key_pretty, lock_strength, durability, isolation_level, granted, contended FROM crdb_internal.cluster_locks
----
database_name schema_name table_name lock_key_pretty lock_strength durability isolation_level granted contended

# Locks:
# 1: Shared
# 2: None
Expand Down
30 changes: 27 additions & 3 deletions pkg/sql/logictest/testdata/logic_test/txn
Original file line number Diff line number Diff line change
Expand Up @@ -1068,11 +1068,18 @@ COMMIT
statement ok
RESET DEFAULT_TRANSACTION_ISOLATION

skipif config weak-iso-level-configs
query T
SHOW DEFAULT_TRANSACTION_ISOLATION
----
serializable

onlyif config local-read-committed
query T
SHOW DEFAULT_TRANSACTION_ISOLATION
----
read committed

# SHOW TRANSACTION STATUS

query T
Expand Down Expand Up @@ -1136,9 +1143,14 @@ COMMIT
statement ok
BEGIN TRANSACTION; SAVEPOINT cockroach_restart; SELECT 1

skipif config local-read-committed
query error pgcode 40001 restart transaction: crdb_internal.force_retry\(\): TransactionRetryWithProtoRefreshError: forced by crdb_internal.force_retry\(\).*\nHINT:.*transaction-retry-error-reference.html
SELECT crdb_internal.force_retry('1h':::INTERVAL)

onlyif config local-read-committed
query error pgcode 40001 pq: restart transaction: read committed retry limit exceeded; set by max_retries_for_read_committed=10: crdb_internal.force_retry\(\): TransactionRetryWithProtoRefreshError: forced by crdb_internal.force_retry\(\)
SELECT crdb_internal.force_retry('1h':::INTERVAL)

query T
SHOW TRANSACTION STATUS
----
Expand Down Expand Up @@ -1273,9 +1285,14 @@ BEGIN TRANSACTION;
SAVEPOINT cockroach_restart;
SELECT 1;

skipif config local-read-committed
query error pgcode 40001 restart transaction: crdb_internal.force_retry\(\): TransactionRetryWithProtoRefreshError: forced by crdb_internal.force_retry\(\)
SELECT crdb_internal.force_retry('1h':::INTERVAL)

onlyif config local-read-committed
query error pgcode 40001 pq: restart transaction: read committed retry limit exceeded; set by max_retries_for_read_committed=10: crdb_internal.force_retry\(\): TransactionRetryWithProtoRefreshError: forced by crdb_internal.force_retry\(\)
SELECT crdb_internal.force_retry('1h':::INTERVAL)

statement ok
ROLLBACK TO SAVEPOINT COCKROACH_RESTART;

Expand Down Expand Up @@ -1534,9 +1551,14 @@ BEGIN ISOLATION LEVEL SERIALIZABLE, ISOLATION LEVEL SERIALIZABLE
statement ok
BEGIN; SELECT 1

skipif config local-read-committed
query error pgcode 40001 restart transaction: crdb_internal.force_retry\(\): TransactionRetryWithProtoRefreshError: forced by crdb_internal.force_retry\(\)
SELECT crdb_internal.force_retry('1h':::INTERVAL)

onlyif config local-read-committed
query error pgcode 40001 pq: restart transaction: read committed retry limit exceeded; set by max_retries_for_read_committed=10: crdb_internal.force_retry\(\): TransactionRetryWithProtoRefreshError: forced by crdb_internal.force_retry\(\)
SELECT crdb_internal.force_retry('1h':::INTERVAL)

statement ok
ROLLBACK

Expand Down Expand Up @@ -1624,7 +1646,9 @@ SET SESSION CHARACTERISTICS AS TRANSACTION DEFERRABLE
# Test retry rewinds correctly.

statement ok
SET intervalstyle = 'postgres';
SET intervalstyle = 'postgres'

statement ok
CREATE TABLE rewind_session_test (s string primary key);

statement ok
Expand All @@ -1647,10 +1671,10 @@ SHOW intervalstyle
iso_8601

statement ok
TRUNCATE rewind_session_test;
TRUNCATE rewind_session_test

statement ok
SET intervalstyle = 'postgres';
SET intervalstyle = 'postgres'

statement ok
BEGIN;
Expand Down