| From: | Nishant Sharma <nishant(dot)sharma(at)enterprisedb(dot)com> |
|---|---|
| To: | jian he <jian(dot)universality(at)gmail(dot)com> |
| Cc: | Kirill Reshke <reshkekirill(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: on_error table, saving error info to a table |
| Date: | 2025-11-07 05:28:06 |
| Message-ID: | CADrsxdbvG9f+vNRnetSjcSQPrQUKE9WyoSd7SsX+ESusYkFscA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Wed, Oct 22, 2025 at 10:45 AM jian he <jian(dot)universality(at)gmail(dot)com>
wrote:
> hi.
>
> The previous discussion mentioned using built-in typed tables for the
> error saving table.
> It's doable.
>
> first create an build-in composite type in system_functions.sql:
> CREATE TYPE copy_error_saving AS(
> userid oid,
> copy_tbl oid,
> filename text COLLATE "C",
> lineno bigint,
> line text COLLATE "C",
> colname text COLLATE "C",
> raw_field_value text COLLATE "C",
> err_message text COLLATE "C",
> err_detail text COLLATE "C",
> errorcode text COLLATE "C"
> );
>
> then we can use it to create a table like:
> CREATE TABLE error_saving_table OF copy_error_saving;
>
Exactly. This is what I was trying to convey about the suggestion by
Andrew.
Please find review comments on v7:-
1) I think we can improve below, and can avoid 3 conditional check
to only one
>if (cstate->escontext->error_data->detail == NULL)
> err_detail = NULL;
>else
> err_detail = cstate->escontext->error_data->detail;
>
>values[j] = err_detail ? CStringGetTextDatum(err_detail) : (Datum) 0;
>isnull[j++] = err_detail ? false : true;
TO
>if (cstate->escontext->error_data->detail == NULL)
>{
> values[j] = (Datum) 0;
> isnull[j++] = true;
>}
> else
> values[j++] =
CStringGetTextDatum(cstate->escontext->error_data->detail);
2) We can have "#define ERROR_TBL_COLUMNS 10" instead of
hardcoded 10 in file copyfromparse.c. Because now, it is used only
in copyfromparse.c.
3) Do we need a 'j' variable to assign data to values[j]? I see in src
code that hard coded numbers are directly used in other places.
Like values[0] = data1; values[1] = data2, so on. With this we can
avoid j++ execution cycles.
Regards,
Nishant Sharma.
EDB, Pune.
https://www.enterprisedb.com/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | vignesh C | 2025-11-07 05:28:19 | Re: Logical Replication of sequences |
| Previous Message | Japin Li | 2025-11-07 05:06:26 | Re: Improve pg_sync_replication_slots() to wait for primary to advance |