public inbox for [email protected]help / color / mirror / Atom feed
[PATCH v2 1/1] Add hint message for check_log_destination 10+ messages / 3 participants [nested] [flat]
* [PATCH v2 1/1] Add hint message for check_log_destination @ 2023-07-07 07:48 Japin Li <[email protected]> 0 siblings, 0 replies; 10+ messages in thread From: Japin Li @ 2023-07-07 07:48 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index 5898100acb..a32f9613be 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -2228,8 +2228,22 @@ check_log_destination(char **newval, void **extra, GucSource source) #endif else { + StringInfoData errhint; + + initStringInfo(&errhint); + appendStringInfo(&errhint, "\"stderr\""); +#ifdef HAVE_SYSLOG + appendStringInfo(&errhint, ", \"syslog\""); +#endif +#ifdef WIN32 + appendStringInfo(&errhint, ", \"eventlog\""); +#endif + appendStringInfo(&errhint, ", \"csvlog\", and \"jsonlog\""); + GUC_check_errdetail("Unrecognized key word: \"%s\".", tok); + GUC_check_errhint("Valid values are combinations of %s.", errhint.data); pfree(rawstring); + pfree(errhint.data); list_free(elemlist); return false; } -- 2.25.1 --=-=-=-- ^ permalink raw reply [nested|flat] 10+ messages in thread
* [PATCH v3 1/1] Add hint message for check_log_destination @ 2023-07-07 07:48 Japin Li <[email protected]> 0 siblings, 0 replies; 10+ messages in thread From: Japin Li @ 2023-07-07 07:48 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index 5898100acb..a7545dcbd9 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -2228,8 +2228,22 @@ check_log_destination(char **newval, void **extra, GucSource source) #endif else { + StringInfoData errhint; + + initStringInfo(&errhint); + appendStringInfoString(&errhint, "\"stderr\""); +#ifdef HAVE_SYSLOG + appendStringInfoString(&errhint, ", \"syslog\""); +#endif +#ifdef WIN32 + appendStringInfoString(&errhint, ", \"eventlog\""); +#endif + appendStringInfoString(&errhint, ", \"csvlog\", and \"jsonlog\""); + GUC_check_errdetail("Unrecognized key word: \"%s\".", tok); + GUC_check_errhint("Valid values are combinations of %s.", errhint.data); pfree(rawstring); + pfree(errhint.data); list_free(elemlist); return false; } -- 2.25.1 --=-=-= Content-Type: text/plain -- Regrads, Japin Li. --=-=-=-- ^ permalink raw reply [nested|flat] 10+ messages in thread
* [PATCH v2 1/1] Add hint message for check_log_destination @ 2023-07-07 07:48 Japin Li <[email protected]> 0 siblings, 0 replies; 10+ messages in thread From: Japin Li @ 2023-07-07 07:48 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index 5898100acb..a32f9613be 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -2228,8 +2228,22 @@ check_log_destination(char **newval, void **extra, GucSource source) #endif else { + StringInfoData errhint; + + initStringInfo(&errhint); + appendStringInfo(&errhint, "\"stderr\""); +#ifdef HAVE_SYSLOG + appendStringInfo(&errhint, ", \"syslog\""); +#endif +#ifdef WIN32 + appendStringInfo(&errhint, ", \"eventlog\""); +#endif + appendStringInfo(&errhint, ", \"csvlog\", and \"jsonlog\""); + GUC_check_errdetail("Unrecognized key word: \"%s\".", tok); + GUC_check_errhint("Valid values are combinations of %s.", errhint.data); pfree(rawstring); + pfree(errhint.data); list_free(elemlist); return false; } -- 2.25.1 --=-=-=-- ^ permalink raw reply [nested|flat] 10+ messages in thread
* [PATCH v3 1/1] Add hint message for check_log_destination @ 2023-07-07 07:48 Japin Li <[email protected]> 0 siblings, 0 replies; 10+ messages in thread From: Japin Li @ 2023-07-07 07:48 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index 5898100acb..a7545dcbd9 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -2228,8 +2228,22 @@ check_log_destination(char **newval, void **extra, GucSource source) #endif else { + StringInfoData errhint; + + initStringInfo(&errhint); + appendStringInfoString(&errhint, "\"stderr\""); +#ifdef HAVE_SYSLOG + appendStringInfoString(&errhint, ", \"syslog\""); +#endif +#ifdef WIN32 + appendStringInfoString(&errhint, ", \"eventlog\""); +#endif + appendStringInfoString(&errhint, ", \"csvlog\", and \"jsonlog\""); + GUC_check_errdetail("Unrecognized key word: \"%s\".", tok); + GUC_check_errhint("Valid values are combinations of %s.", errhint.data); pfree(rawstring); + pfree(errhint.data); list_free(elemlist); return false; } -- 2.25.1 --=-=-= Content-Type: text/plain -- Regrads, Japin Li. --=-=-=-- ^ permalink raw reply [nested|flat] 10+ messages in thread
* [PATCH v4 1/1] Add hint message for check_log_destination @ 2023-07-14 01:26 Japin Li <[email protected]> 0 siblings, 0 replies; 10+ messages in thread From: Japin Li @ 2023-07-14 01:26 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index 5898100acb..dccbabf40a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -2228,8 +2228,22 @@ check_log_destination(char **newval, void **extra, GucSource source) #endif else { + StringInfoData errhint; + + initStringInfo(&errhint); + appendStringInfoString(&errhint, "stderr"); +#ifdef HAVE_SYSLOG + appendStringInfoString(&errhint, ", syslog"); +#endif +#ifdef WIN32 + appendStringInfoString(&errhint, ", eventlog"); +#endif + appendStringInfoString(&errhint, ", csvlog, and jsonlog"); + GUC_check_errdetail("Unrecognized key word: \"%s\".", tok); + GUC_check_errhint("Valid values are combinations of %s.", errhint.data); pfree(rawstring); + pfree(errhint.data); list_free(elemlist); return false; } -- 2.41.0 --=-=-=-- ^ permalink raw reply [nested|flat] 10+ messages in thread
* [PATCH v4 1/1] Add hint message for check_log_destination @ 2023-07-14 01:26 Japin Li <[email protected]> 0 siblings, 0 replies; 10+ messages in thread From: Japin Li @ 2023-07-14 01:26 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index 5898100acb..dccbabf40a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -2228,8 +2228,22 @@ check_log_destination(char **newval, void **extra, GucSource source) #endif else { + StringInfoData errhint; + + initStringInfo(&errhint); + appendStringInfoString(&errhint, "stderr"); +#ifdef HAVE_SYSLOG + appendStringInfoString(&errhint, ", syslog"); +#endif +#ifdef WIN32 + appendStringInfoString(&errhint, ", eventlog"); +#endif + appendStringInfoString(&errhint, ", csvlog, and jsonlog"); + GUC_check_errdetail("Unrecognized key word: \"%s\".", tok); + GUC_check_errhint("Valid values are combinations of %s.", errhint.data); pfree(rawstring); + pfree(errhint.data); list_free(elemlist); return false; } -- 2.41.0 --=-=-=-- ^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: pg_column_toast_chunk_id: a function to get a chunk ID of a TOASTed value @ 2024-03-13 03:07 Nathan Bossart <[email protected]> 0 siblings, 1 reply; 10+ messages in thread From: Nathan Bossart @ 2024-03-13 03:07 UTC (permalink / raw) To: Yugo NAGATA <[email protected]>; +Cc: jian he <[email protected]>; Sergei Kornilov <[email protected]>; Nikita Malakhov <[email protected]>; pgsql-hackers I did some light editing to prepare this for commit. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com Attachments: [text/x-diff] v10-0001-Add-pg_column_toast_chunk_id.patch (6.0K, ../../20240313030717.GA2507890@nathanxps13/2-v10-0001-Add-pg_column_toast_chunk_id.patch) download | inline diff: From 38c78bd92a7b4d4600e6f0dbe58283c21ea87d50 Mon Sep 17 00:00:00 2001 From: Nathan Bossart <[email protected]> Date: Tue, 12 Mar 2024 22:04:25 -0500 Subject: [PATCH v10 1/1] Add pg_column_toast_chunk_id(). This function returns the chunk_id of an on-disk TOASTed value, or NULL if the value is un-TOASTed or not on-disk. This is useful for identifying which values are actually TOASTed and for investigating "unexpected chunk number" errors. XXX: REQUIRES CATVERSION BUMP Author: Yugo Nagata Reviewed-by: Jian He Discussion: https://postgr.es/m/20230329105507.d764497456eeac1ca491b5bd%40sraoss.co.jp --- doc/src/sgml/func.sgml | 17 ++++++++ src/backend/utils/adt/varlena.c | 41 ++++++++++++++++++++ src/include/catalog/pg_proc.dat | 3 ++ src/test/regress/expected/misc_functions.out | 16 ++++++++ src/test/regress/sql/misc_functions.sql | 12 ++++++ 5 files changed, 89 insertions(+) diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 0bb7aeb40e..fe9c1a38b9 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -28552,6 +28552,23 @@ postgres=# SELECT '0/0'::pg_lsn + pd.segment_number * ps.setting::int + :offset </para></entry> </row> + <row> + <entry role="func_table_entry"><para role="func_signature"> + <indexterm> + <primary>pg_column_toast_chunk_id</primary> + </indexterm> + <function>pg_column_toast_chunk_id</function> ( <type>"any"</type> ) + <returnvalue>oid</returnvalue> + </para> + <para> + Shows the <structfield>chunk_id</structfield> of an on-disk + <acronym>TOAST</acronym>ed value. Returns <literal>NULL</literal> + if the value is un-<acronym>TOAST</acronym>ed or not on-disk. See + <xref linkend="storage-toast"/> for more information about + <acronym>TOAST</acronym>. + </para></entry> + </row> + <row> <entry role="func_table_entry"><para role="func_signature"> <indexterm> diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c index 543afb66e5..8d28dd42ce 100644 --- a/src/backend/utils/adt/varlena.c +++ b/src/backend/utils/adt/varlena.c @@ -5105,6 +5105,47 @@ pg_column_compression(PG_FUNCTION_ARGS) PG_RETURN_TEXT_P(cstring_to_text(result)); } +/* + * Return the chunk_id of the on-disk TOASTed value. Return NULL if the value + * is un-TOASTed or not on-disk. + */ +Datum +pg_column_toast_chunk_id(PG_FUNCTION_ARGS) +{ + int typlen; + struct varlena *attr; + struct varatt_external toast_pointer; + + /* On first call, get the input type's typlen, and save at *fn_extra */ + if (fcinfo->flinfo->fn_extra == NULL) + { + /* Lookup the datatype of the supplied argument */ + Oid argtypeid = get_fn_expr_argtype(fcinfo->flinfo, 0); + + typlen = get_typlen(argtypeid); + if (typlen == 0) /* should not happen */ + elog(ERROR, "cache lookup failed for type %u", argtypeid); + + fcinfo->flinfo->fn_extra = MemoryContextAlloc(fcinfo->flinfo->fn_mcxt, + sizeof(int)); + *((int *) fcinfo->flinfo->fn_extra) = typlen; + } + else + typlen = *((int *) fcinfo->flinfo->fn_extra); + + if (typlen != -1) + PG_RETURN_NULL(); + + attr = (struct varlena *) DatumGetPointer(PG_GETARG_DATUM(0)); + + if (!VARATT_IS_EXTERNAL_ONDISK(attr)) + PG_RETURN_NULL(); + + VARATT_EXTERNAL_GET_POINTER(toast_pointer, attr); + + PG_RETURN_OID(toast_pointer.va_valueid); +} + /* * string_agg - Concatenates values and returns string. * diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 291ed876fc..443ca854a6 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -7447,6 +7447,9 @@ { oid => '2121', descr => 'compression method for the compressed datum', proname => 'pg_column_compression', provolatile => 's', prorettype => 'text', proargtypes => 'any', prosrc => 'pg_column_compression' }, +{ oid => '8393', descr => 'chunk ID of on-disk TOASTed value', + proname => 'pg_column_toast_chunk_id', provolatile => 's', prorettype => 'oid', + proargtypes => 'any', prosrc => 'pg_column_toast_chunk_id' }, { oid => '2322', descr => 'total disk space usage for the specified tablespace', proname => 'pg_tablespace_size', provolatile => 'v', prorettype => 'int8', diff --git a/src/test/regress/expected/misc_functions.out b/src/test/regress/expected/misc_functions.out index d5f61dfad9..e0ba9fdafa 100644 --- a/src/test/regress/expected/misc_functions.out +++ b/src/test/regress/expected/misc_functions.out @@ -703,3 +703,19 @@ SELECT has_function_privilege('regress_current_logfile', (1 row) DROP ROLE regress_current_logfile; +-- pg_column_toast_chunk_id +CREATE TABLE test_chunk_id (a TEXT, b TEXT STORAGE EXTERNAL); +INSERT INTO test_chunk_id VALUES ('x', repeat('x', 8192)); +SELECT t.relname AS toastrel FROM pg_class c + LEFT JOIN pg_class t ON c.reltoastrelid = t.oid + WHERE c.relname = 'test_chunk_id' +\gset +SELECT pg_column_toast_chunk_id(a) IS NULL, + pg_column_toast_chunk_id(b) IN (SELECT chunk_id FROM pg_toast.:toastrel) + FROM test_chunk_id; + ?column? | ?column? +----------+---------- + t | t +(1 row) + +DROP TABLE test_chunk_id; diff --git a/src/test/regress/sql/misc_functions.sql b/src/test/regress/sql/misc_functions.sql index 928b04db7f..ff5ed5edde 100644 --- a/src/test/regress/sql/misc_functions.sql +++ b/src/test/regress/sql/misc_functions.sql @@ -265,3 +265,15 @@ GRANT pg_monitor TO regress_current_logfile; SELECT has_function_privilege('regress_current_logfile', 'pg_current_logfile()', 'EXECUTE'); DROP ROLE regress_current_logfile; + +-- pg_column_toast_chunk_id +CREATE TABLE test_chunk_id (a TEXT, b TEXT STORAGE EXTERNAL); +INSERT INTO test_chunk_id VALUES ('x', repeat('x', 8192)); +SELECT t.relname AS toastrel FROM pg_class c + LEFT JOIN pg_class t ON c.reltoastrelid = t.oid + WHERE c.relname = 'test_chunk_id' +\gset +SELECT pg_column_toast_chunk_id(a) IS NULL, + pg_column_toast_chunk_id(b) IN (SELECT chunk_id FROM pg_toast.:toastrel) + FROM test_chunk_id; +DROP TABLE test_chunk_id; -- 2.25.1 ^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: pg_column_toast_chunk_id: a function to get a chunk ID of a TOASTed value @ 2024-03-13 06:09 Yugo NAGATA <[email protected]> parent: Nathan Bossart <[email protected]> 0 siblings, 1 reply; 10+ messages in thread From: Yugo NAGATA @ 2024-03-13 06:09 UTC (permalink / raw) To: Nathan Bossart <[email protected]>; +Cc: jian he <[email protected]>; Sergei Kornilov <[email protected]>; Nikita Malakhov <[email protected]>; pgsql-hackers On Tue, 12 Mar 2024 22:07:17 -0500 Nathan Bossart <[email protected]> wrote: > I did some light editing to prepare this for commit. Thank you. I confirmed the test you improved and I am fine with that. Regards, Yugo Nagata > > -- > Nathan Bossart > Amazon Web Services: https://aws.amazon.com -- Yugo NAGATA <[email protected]> ^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: pg_column_toast_chunk_id: a function to get a chunk ID of a TOASTed value @ 2024-03-14 16:10 Nathan Bossart <[email protected]> parent: Yugo NAGATA <[email protected]> 0 siblings, 1 reply; 10+ messages in thread From: Nathan Bossart @ 2024-03-14 16:10 UTC (permalink / raw) To: Yugo NAGATA <[email protected]>; +Cc: jian he <[email protected]>; Sergei Kornilov <[email protected]>; Nikita Malakhov <[email protected]>; pgsql-hackers On Wed, Mar 13, 2024 at 01:09:18PM +0700, Yugo NAGATA wrote: > On Tue, 12 Mar 2024 22:07:17 -0500 > Nathan Bossart <[email protected]> wrote: >> I did some light editing to prepare this for commit. > > Thank you. I confirmed the test you improved and I am fine with that. Committed. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com ^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: pg_column_toast_chunk_id: a function to get a chunk ID of a TOASTed value @ 2024-03-18 07:44 Yugo NAGATA <[email protected]> parent: Nathan Bossart <[email protected]> 0 siblings, 0 replies; 10+ messages in thread From: Yugo NAGATA @ 2024-03-18 07:44 UTC (permalink / raw) To: Nathan Bossart <[email protected]>; +Cc: jian he <[email protected]>; Sergei Kornilov <[email protected]>; Nikita Malakhov <[email protected]>; pgsql-hackers On Thu, 14 Mar 2024 11:10:42 -0500 Nathan Bossart <[email protected]> wrote: > On Wed, Mar 13, 2024 at 01:09:18PM +0700, Yugo NAGATA wrote: > > On Tue, 12 Mar 2024 22:07:17 -0500 > > Nathan Bossart <[email protected]> wrote: > >> I did some light editing to prepare this for commit. > > > > Thank you. I confirmed the test you improved and I am fine with that. > > Committed. Thank you! > > -- > Nathan Bossart > Amazon Web Services: https://aws.amazon.com -- Yugo NAGATA <[email protected]> ^ permalink raw reply [nested|flat] 10+ messages in thread
end of thread, other threads:[~2024-03-18 07:44 UTC | newest] Thread overview: 10+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2023-07-07 07:48 [PATCH v3 1/1] Add hint message for check_log_destination Japin Li <[email protected]> 2023-07-07 07:48 [PATCH v2 1/1] Add hint message for check_log_destination Japin Li <[email protected]> 2023-07-07 07:48 [PATCH v3 1/1] Add hint message for check_log_destination Japin Li <[email protected]> 2023-07-07 07:48 [PATCH v2 1/1] Add hint message for check_log_destination Japin Li <[email protected]> 2023-07-14 01:26 [PATCH v4 1/1] Add hint message for check_log_destination Japin Li <[email protected]> 2023-07-14 01:26 [PATCH v4 1/1] Add hint message for check_log_destination Japin Li <[email protected]> 2024-03-13 03:07 Re: pg_column_toast_chunk_id: a function to get a chunk ID of a TOASTed value Nathan Bossart <[email protected]> 2024-03-13 06:09 ` Re: pg_column_toast_chunk_id: a function to get a chunk ID of a TOASTed value Yugo NAGATA <[email protected]> 2024-03-14 16:10 ` Re: pg_column_toast_chunk_id: a function to get a chunk ID of a TOASTed value Nathan Bossart <[email protected]> 2024-03-18 07:44 ` Re: pg_column_toast_chunk_id: a function to get a chunk ID of a TOASTed value Yugo NAGATA <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox