Description

Turns out the "RETURNING" change in r10029 isn't supported in PostgreSQL 8.1. So that new feature is only going to be possible in later PostgreSQL versions and we can't use the one statement version in the default code path, unless there's an alternative compatible version.

Oldest firstNewest firstThreaded

Comments only

Change History (9)

Maybe this should be a separate ticket, but it's close enough that I'll be lazy and just add it to this one. The existing "RETURNING" support doesn't seem to be complete, since the "SELECT CURRVAL" query is still happening:

I introduced a bad regression in r10029, forgetting to check that some
syntax was supported. For now, you can't use autocommit=True with 8.1
and earlier (it's still available for later versions). I'll fix the
broader issue later and re-enable it for those versions, but I want to
get the SQL regression for the default path out of the code right now.

I'm afraid this one isn't quite fixed. If the very first database operation on a connection is a save() you still get the error reporting in #10474: syntax error at or near "RETURNING". It looks like the test for PostgreSQL version is only done at the point a query is issued. I'm afraid I'm new to Django and haven't been able to propose a patch.

#10509 has been opened to track the bigger problem here. For now, I'm disabling returning the ID values unless autocommit requires it (for PostgreSQL). That avoids the immediate problem, but it's only (deliberate) symptom patching.

(In [10065]) More fixing of PostgreSQL < 8.2 problems with the psycopg2 backend.

Affects the postgresql_psycopg2 backend only. We now don't use the
"RETURNING" syntax in SQL INSERT statements unless it's required by the
autocommit behaviour. This fixes an edge-case that could cause crashes
with earlier PostgreSQL versions, but the broader problem remains to be
fixed (which is #10509).