connection.reset() implemented using DISCARD ALL

This commit is contained in:
Daniele Varrazzo 2012-05-30 12:13:24 +01:00
parent 7a33ebd580
commit f9a13eb563
2 changed files with 13 additions and 5 deletions

2
NEWS
View File

@ -7,6 +7,8 @@ What's new in psycopg 2.4.6
- Dropped GIL release during string adaptation around a function call
invoking a Python API function, which could cause interpreter crash.
Thanks to Manu Cupcic for the report (ticket #110).
- connection.reset() implemented using DISCARD ALL on server versions
supporting it.
What's new in psycopg 2.4.5

View File

@ -557,12 +557,18 @@ pq_reset_locked(connectionObject *conn, PGresult **pgres, char **error,
if (retvalue != 0) return retvalue;
}
retvalue = pq_execute_command_locked(conn, "RESET ALL", pgres, error, tstate);
if (retvalue != 0) return retvalue;
if (conn->server_version >= 80300) {
retvalue = pq_execute_command_locked(conn, "DISCARD ALL", pgres, error, tstate);
if (retvalue != 0) return retvalue;
}
else {
retvalue = pq_execute_command_locked(conn, "RESET ALL", pgres, error, tstate);
if (retvalue != 0) return retvalue;
retvalue = pq_execute_command_locked(conn,
"SET SESSION AUTHORIZATION DEFAULT", pgres, error, tstate);
if (retvalue != 0) return retvalue;
retvalue = pq_execute_command_locked(conn,
"SET SESSION AUTHORIZATION DEFAULT", pgres, error, tstate);
if (retvalue != 0) return retvalue;
}
/* should set the tpc xid to null: postponed until we get the GIL again */
conn->status = CONN_STATUS_READY;