Summary:
Use custom SQL codes instead of yb_txn_errcode internally.
The main problem is that yb_txn_errcode is not known to Postgres
and therefore effectively dropped when ErrorData is transferred
between processed.
One case is the parallel query, the errors from parallel workers
come to the main worker without the code, and are not retried,
even if error calls for retry.
Custom SQL error codes are transmitted from process to process
correctly, easier to identify and more machine friendly.
SQL error codes are exposed to the user, and may be handled by
the application. We are aware of some users handling errors like
40001 and for them YBxxx codes would be breaking. To address
that concern we translate YBxxx codes to Postgres standard codes
we used to use. Users who want to take advantage of the new
codes can use yb_enable_extended_sql_codes GUC variable to
turn translation off when they are ready.
Jira: DB-11258
Test Plan: ./yb_build.sh --java-test org.yb.pgsql.TestPgTransparentRestarts
Reviewers: kfranz, pjain
Reviewed By: kfranz, pjain
Subscribers: yql
Tags: #jenkins-ready
Differential Revision: https://phorge.dev.yugabyte.com/D35016