[Psycopg] lastrowid and INSERT ... RETURNING

Karsten Hilbert Karsten.Hilbert at gmx.net
Mon Aug 4 14:17:01 CEST 2008


> RETURNING can return anything so does it make sense to hack some magic
> to automatically populate .lastrowid when the query is an INSERT and the
> value returned is a long (like the OID were)
Please don't do it automagically without a switch to control it. Applications depending on "returning"
returning something specific would break in ever so subtle ways.

OTOH, if the "returning" result would end up in both of .lastrowid and a query
result instance that might capture the best of both worlds. In that case a switch to control whether .lastrowid is populated would allow those not needing it to gain some performance.

> I am for the second but I can hack .lastrowid if enough people need it
> to transition from old backends with automatic OIDs to the new ones
> where OIDs are not geneated by default.
Applications depending on OIDs should really enable OID generation in the backend rather
than depending on hoping that "returning" returns the relevant data (IMO).

Karsten
-- 
GMX Kostenlose Spiele: Einfach online spielen und Spaß haben mit Pastry Passion!
http://games.entertainment.gmx.net/de/entertainment/games/free/puzzle/6169196


More information about the Psycopg mailing list