Skip to content

Commit ebcbfdc

Browse files
committed
remove setting getting transaction isolation on connect, add tests to see if we can set and retrieve the transaction isolation level
1 parent 3caf764 commit ebcbfdc

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

connection.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,14 +1094,6 @@ LIBPQ_CC_connect(ConnectionClass *self, char *salt_para)
10941094

10951095
if (ret = LIBPQ_connect(self), ret <= 0)
10961096
return ret;
1097-
res = CC_send_query(self, ISOLATION_SHOW_QUERY, NULL, READ_ONLY_QUERY, NULL);
1098-
if (QR_command_maybe_successful(res))
1099-
{
1100-
handle_show_results(res);
1101-
ret = 1;
1102-
}
1103-
else
1104-
ret = 0;
11051097
QR_Destructor(res);
11061098

11071099
return ret;

test/expected/commands.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ Testing VACUUM with SQLPrepare/SQLExecute...
44
Disabling autocommit...
55
Testing VACUUM with SQLExecDirect...
66
Testing VACUUM with SQLPrepare/SQLExecute...
7+
Retrieved isolation level: 2
78
disconnecting

test/src/commands-test.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,24 @@ int main(int argc, char **argv)
7373
rc = SQLFreeStmt(hstmt, SQL_CLOSE);
7474
CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt);
7575

76+
77+
rc = SQLSetConnectAttr(conn, SQL_ATTR_TXN_ISOLATION, (SQLPOINTER)SQL_TXN_READ_COMMITTED, SQL_IS_UINTEGER);
78+
CHECK_CONN_RESULT(rc, "SQLSetConnectAttr failed", conn);
79+
80+
/* Verify the isolation level was set correctly using SQLGetConnectAttr */
81+
SQLUINTEGER isolation_level;
82+
rc = SQLGetConnectAttr(conn, SQL_ATTR_TXN_ISOLATION, &isolation_level, SQL_IS_UINTEGER, NULL);
83+
CHECK_CONN_RESULT(rc, "SQLGetConnectAttr failed", conn);
84+
85+
printf("Retrieved isolation level: %u\n", isolation_level);
86+
if (isolation_level != SQL_TXN_READ_COMMITTED) {
87+
printf("ERROR: Expected %ld (SQL_TXN_READ_COMMITTED), got %u\n", SQL_TXN_READ_COMMITTED, isolation_level);
88+
exit(1);
89+
}
90+
91+
rc = SQLFreeStmt(hstmt, SQL_CLOSE);
92+
CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt);
93+
7694
/* Clean up */
7795
test_disconnect();
7896

0 commit comments

Comments
 (0)