Laurenz Albe wrote: > > Or is there a libpq API on PGresult that would allow to get the type > > of statement the result is from? > > The command tag is not what you look at. Yet that's what psql does. from PrintQueryResult(): /* if it's INSERT/UPDATE/DELETE RETURNING, also print status */ if (last || pset.show_all_results) { cmdstatus = PQcmdStatus(result); if (strncmp(cmdstatus, "INSERT", 6) == 0 || strncmp(cmdstatus, "UPDATE", 6) == 0 || strncmp(cmdstatus, "DELETE", 6) == 0) PrintQueryStatus(result, printStatusFout); } > You simply check the result from an INSERT statement. If it is > PGRES_TUPLES_OK, it must have been INSERT ... RETRUNING. Or a SELECT, or an UPDATE RETURNING, or a DELETE RETURNING. The code still need to look at PQcmdStatus() to learn which kind it is, if it needs to know this. Best regards, -- Daniel Vérité https://postgresql.verite.pro/ Twitter: @DanielVerite