public inbox for [email protected]help / color / mirror / Atom feed
[PATCH 1/5] bootstrap: convert Typ to a List* 2+ messages / 2 participants [nested] [flat]
* [PATCH 1/5] bootstrap: convert Typ to a List* @ 2020-11-20 02:48 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 2+ messages in thread From: Justin Pryzby @ 2020-11-20 02:48 UTC (permalink / raw) --- src/backend/bootstrap/bootstrap.c | 69 ++++++++++++++----------------- 1 file changed, 31 insertions(+), 38 deletions(-) diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c index 6f615e6622..18eb62ca47 100644 --- a/src/backend/bootstrap/bootstrap.c +++ b/src/backend/bootstrap/bootstrap.c @@ -159,7 +159,7 @@ struct typmap FormData_pg_type am_typ; }; -static struct typmap **Typ = NULL; +static List *Typ = NIL; /* List of struct typmap* */ static struct typmap *Ap = NULL; static Datum values[MAXATTR]; /* current row's attribute values */ @@ -597,7 +597,7 @@ boot_openrel(char *relname) * pg_type must be filled before any OPEN command is executed, hence we * can now populate the Typ array if we haven't yet. */ - if (Typ == NULL) + if (Typ == NIL) populate_typ_array(); if (boot_reldesc != NULL) @@ -688,7 +688,7 @@ DefineAttr(char *name, char *type, int attnum, int nullness) typeoid = gettype(type); - if (Typ != NULL) + if (Typ != NIL) { attrtypes[attnum]->atttypid = Ap->am_oid; attrtypes[attnum]->attlen = Ap->am_typ.typlen; @@ -877,36 +877,25 @@ populate_typ_array(void) Relation rel; TableScanDesc scan; HeapTuple tup; - int nalloc; - int i; - - Assert(Typ == NULL); - nalloc = 512; - Typ = (struct typmap **) - MemoryContextAlloc(TopMemoryContext, nalloc * sizeof(struct typmap *)); + Assert(Typ == NIL); rel = table_open(TypeRelationId, NoLock); scan = table_beginscan_catalog(rel, 0, NULL); - i = 0; while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL) { Form_pg_type typForm = (Form_pg_type) GETSTRUCT(tup); + struct typmap *newtyp; + MemoryContext old; - /* make sure there will be room for a trailing NULL pointer */ - if (i >= nalloc - 1) - { - nalloc *= 2; - Typ = (struct typmap **) - repalloc(Typ, nalloc * sizeof(struct typmap *)); - } - Typ[i] = (struct typmap *) - MemoryContextAlloc(TopMemoryContext, sizeof(struct typmap)); - Typ[i]->am_oid = typForm->oid; - memcpy(&(Typ[i]->am_typ), typForm, sizeof(Typ[i]->am_typ)); - i++; + old = MemoryContextSwitchTo(TopMemoryContext); + newtyp = (struct typmap *) palloc(sizeof(struct typmap)); + Typ = lappend(Typ, newtyp); + MemoryContextSwitchTo(old); + + newtyp->am_oid = typForm->oid; + memcpy(&newtyp->am_typ, typForm, sizeof(newtyp->am_typ)); } - Typ[i] = NULL; /* Fill trailing NULL pointer */ table_endscan(scan); table_close(rel, NoLock); } @@ -925,16 +914,17 @@ populate_typ_array(void) static Oid gettype(char *type) { - if (Typ != NULL) + if (Typ != NIL) { - struct typmap **app; + ListCell *lc; - for (app = Typ; *app != NULL; app++) + foreach (lc, Typ) { - if (strncmp(NameStr((*app)->am_typ.typname), type, NAMEDATALEN) == 0) + struct typmap *app = lfirst(lc); + if (strncmp(NameStr(app->am_typ.typname), type, NAMEDATALEN) == 0) { - Ap = *app; - return (*app)->am_oid; + Ap = app; + return app->am_oid; } } } @@ -980,14 +970,17 @@ boot_get_type_io_data(Oid typid, if (Typ != NULL) { /* We have the boot-time contents of pg_type, so use it */ - struct typmap **app; - struct typmap *ap; - - app = Typ; - while (*app && (*app)->am_oid != typid) - ++app; - ap = *app; - if (ap == NULL) + struct typmap *ap = NULL; + ListCell *lc; + + foreach (lc, Typ) + { + ap = lfirst(lc); + if (ap->am_oid == typid) + break; + } + + if (!ap || ap->am_oid != typid) elog(ERROR, "type OID %u not found in Typ list", typid); *typlen = ap->am_typ.typlen; -- 2.26.2 --------------614DDB87AFFED893713AC0E9 Content-Type: text/x-patch; charset=UTF-8; name="0002-Allow-composite-types-in-bootstrap-20210304.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0002-Allow-composite-types-in-bootstrap-20210304.patch" ^ permalink raw reply [nested|flat] 2+ messages in thread
* TOAST versus toast @ 2025-01-16 03:57 Peter Smith <[email protected]> 0 siblings, 0 replies; 2+ messages in thread From: Peter Smith @ 2025-01-16 03:57 UTC (permalink / raw) To: PostgreSQL Hackers <[email protected]> Hi, During some recent reviews, I came across some comments mentioning "toast" ... TOAST is a PostgreSQL acronym for "The Oversized-Attribute Storage Technique" [1]. But, toast is just toast [2]. ~ AFAIK it is usual practice to uppercase acronyms to distinguish them from ordinary words, but PostgreSQL currently has a scattered mixture of "TOAST" versus "toast". Usage seems about 50:50. Now that I have seen the problem I can't unsee it, and it is everywhere, so here is a patch to address all the lowercase toast in the documentation. Note, for the unusual cases I have used the same wording as per the original TOAST page [1], so: - "toasted" becomes "TOASTed". - "toastable" becomes "TOAST-able" - "untoasted" becomes "un-TOASTed" - "detoasted" is unchanged (and so is "detoast") ~~~ There are many more "toast" examples found in the source code comments, but I'll first wait to see if this patch is accepted before looking to address those. ====== [1] TOAST -- https://www.postgresql.org/docs/current/storage-toast.html [2] toast -- https://en.wikipedia.org/wiki/Toast_(food) Kind Regards, Peter Smith. Fujitsu Australia Attachments: [application/octet-stream] v1-0001-TOAST-not-toast.patch (12.3K, ../../CAHut+PtxXLJFhwJFvx+M=Ux8WGHU85XbT3nDqk-aAUS3E5ANCw@mail.gmail.com/2-v1-0001-TOAST-not-toast.patch) download | inline diff: From 366fae80bcef4ba69725a6ddcd2004c565bf884e Mon Sep 17 00:00:00 2001 From: Peter Smith <[email protected]> Date: Thu, 16 Jan 2025 14:44:30 +1100 Subject: [PATCH v1] TOAST not toast. --- doc/src/sgml/amcheck.sgml | 10 +++++----- doc/src/sgml/bki.sgml | 2 +- doc/src/sgml/catalogs.sgml | 6 +++--- doc/src/sgml/logical-replication.sgml | 2 +- doc/src/sgml/logicaldecoding.sgml | 2 +- doc/src/sgml/ref/alter_table.sgml | 2 +- doc/src/sgml/ref/create_table.sgml | 2 +- doc/src/sgml/ref/create_type.sgml | 4 ++-- doc/src/sgml/ref/pg_amcheck.sgml | 12 ++++++------ doc/src/sgml/sepgsql.sgml | 2 +- doc/src/sgml/xfunc.sgml | 2 +- doc/src/sgml/xtypes.sgml | 2 +- 12 files changed, 24 insertions(+), 24 deletions(-) diff --git a/doc/src/sgml/amcheck.sgml b/doc/src/sgml/amcheck.sgml index 3af0656..4974e9c 100644 --- a/doc/src/sgml/amcheck.sgml +++ b/doc/src/sgml/amcheck.sgml @@ -254,12 +254,12 @@ SET client_min_messages = DEBUG1; <term><literal>check_toast</literal></term> <listitem> <para> - If true, toasted values are checked against the target relation's + If true, TOASTed values are checked against the target relation's TOAST table. </para> <para> - This option is known to be slow. Also, if the toast table or its - index is corrupt, checking it against toast values could conceivably + This option is known to be slow. Also, if the TOAST table or its + index is corrupt, checking it against TOAST values could conceivably crash the server, although in many cases this would just produce an error. </para> @@ -514,8 +514,8 @@ SET client_min_messages = DEBUG1; Relation pages which are correctly formatted, internally consistent, and correct relative to their own internal checksums may still contain logical corruption. As such, this kind of corruption cannot be detected - with <application>checksums</application>. Examples include toasted - values in the main table which lack a corresponding entry in the toast + with <application>checksums</application>. Examples include TOASTed + values in the main table which lack a corresponding entry in the TOAST table, and tuples in the main table with a Transaction ID that is older than the oldest valid Transaction ID in the database or cluster. </para> diff --git a/doc/src/sgml/bki.sgml b/doc/src/sgml/bki.sgml index 3cd5bee..53a982b 100644 --- a/doc/src/sgml/bki.sgml +++ b/doc/src/sgml/bki.sgml @@ -1042,7 +1042,7 @@ $ perl rewrite_dat_with_prokind.pl pg_proc.dat </listitem> <listitem> <para> - Define indexes and toast tables. + Define indexes and TOAST tables. </para> </listitem> <listitem> diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml index 238ed67..63e8aa2 100644 --- a/doc/src/sgml/catalogs.sgml +++ b/doc/src/sgml/catalogs.sgml @@ -1954,7 +1954,7 @@ SCRAM-SHA-256$<replaceable><iteration count></replaceable>:<replaceable>&l </para> <para> The OID of the data type that corresponds to this table's row type, - if any; zero for indexes, sequences, and toast tables, which have + if any; zero for indexes, sequences, and TOAST tables, which have no <structname>pg_type</structname> entry </para></entry> </row> @@ -9434,7 +9434,7 @@ SCRAM-SHA-256$<replaceable><iteration count></replaceable>:<replaceable>&l <para> <structfield>typstorage</structfield> tells for varlena types (those with <structfield>typlen</structfield> = -1) if - the type is prepared for toasting and what the default strategy + the type is prepared for TOASTing and what the default strategy for attributes of this type should be. Possible values are: <itemizedlist> @@ -9464,7 +9464,7 @@ SCRAM-SHA-256$<replaceable><iteration count></replaceable>:<replaceable>&l </para> </listitem> </itemizedlist> - <literal>x</literal> is the usual choice for toast-able types. + <literal>x</literal> is the usual choice for TOAST-able types. Note that <literal>m</literal> values can also be moved out to secondary storage, but only as a last resort (<literal>e</literal> and <literal>x</literal> values are moved first). diff --git a/doc/src/sgml/logical-replication.sgml b/doc/src/sgml/logical-replication.sgml index 8290cd1..1811617 100644 --- a/doc/src/sgml/logical-replication.sgml +++ b/doc/src/sgml/logical-replication.sgml @@ -1738,7 +1738,7 @@ DETAIL: <replaceable class="parameter">detailed_explanation</replaceable>. The <literal>remote tuple</literal> section includes the new tuple from the remote insert or update operation that caused the conflict. Note that for an update operation, the column value of the new tuple will be null - if the value is unchanged and toasted. + if the value is unchanged and TOASTed. </para> </listitem> <listitem> diff --git a/doc/src/sgml/logicaldecoding.sgml b/doc/src/sgml/logicaldecoding.sgml index 1c4ae38..ea65a4a 100644 --- a/doc/src/sgml/logicaldecoding.sgml +++ b/doc/src/sgml/logicaldecoding.sgml @@ -1368,7 +1368,7 @@ commit_prepared_cb(...); <-- commit of the prepared transaction currently used for decoded changes) is selected and streamed. However, in some cases we still have to spill to disk even if streaming is enabled because we exceed the memory threshold but still have not decoded the - complete tuple e.g., only decoded toast table insert but not the main table + complete tuple e.g., only decoded TOAST table insert but not the main table insert. </para> diff --git a/doc/src/sgml/ref/alter_table.sgml b/doc/src/sgml/ref/alter_table.sgml index 938450f..0c462d2 100644 --- a/doc/src/sgml/ref/alter_table.sgml +++ b/doc/src/sgml/ref/alter_table.sgml @@ -825,7 +825,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM <para> <literal>SHARE UPDATE EXCLUSIVE</literal> lock will be taken for - fillfactor, toast and autovacuum storage parameters, as well as the + fillfactor, TOAST and autovacuum storage parameters, as well as the planner parameter <varname>parallel_workers</varname>. </para> </listitem> diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml index 2237321..73fc8e3 100644 --- a/doc/src/sgml/ref/create_table.sgml +++ b/doc/src/sgml/ref/create_table.sgml @@ -1592,7 +1592,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM <para> The toast_tuple_target specifies the minimum tuple length required before we try to compress and/or move long column values into TOAST tables, and - is also the target length we try to reduce the length below once toasting + is also the target length we try to reduce the length below once TOASTing begins. This affects columns marked as External (for move), Main (for compression), or Extended (for both) and applies only to new tuples. There is no effect on existing rows. diff --git a/doc/src/sgml/ref/create_type.sgml b/doc/src/sgml/ref/create_type.sgml index 994dfc6..a491914 100644 --- a/doc/src/sgml/ref/create_type.sgml +++ b/doc/src/sgml/ref/create_type.sgml @@ -411,10 +411,10 @@ CREATE TYPE <replaceable class="parameter">name</replaceable> <para> All <replaceable class="parameter">storage</replaceable> values other than <literal>plain</literal> imply that the functions of the data type - can handle values that have been <firstterm>toasted</firstterm>, as described + can handle values that have been <firstterm>TOASTed</firstterm>, as described in <xref linkend="storage-toast"/> and <xref linkend="xtypes-toast"/>. The specific other value given merely determines the default TOAST - storage strategy for columns of a toastable data type; users can pick + storage strategy for columns of a TOAST-able data type; users can pick other strategies for individual columns using <literal>ALTER TABLE SET STORAGE</literal>. </para> diff --git a/doc/src/sgml/ref/pg_amcheck.sgml b/doc/src/sgml/ref/pg_amcheck.sgml index 6bfe287..ef2bdfd 100644 --- a/doc/src/sgml/ref/pg_amcheck.sgml +++ b/doc/src/sgml/ref/pg_amcheck.sgml @@ -41,7 +41,7 @@ PostgreSQL documentation </para> <para> - Only ordinary and toast table relations, materialized views, sequences, and + Only ordinary and TOAST table relations, materialized views, sequences, and btree indexes are currently supported. Other relation types are silently skipped. </para> @@ -276,7 +276,7 @@ PostgreSQL documentation <term><option>--no-dependent-toast</option></term> <listitem> <para> - By default, if a table is checked, its toast table, if any, will also + By default, if a table is checked, its TOAST table, if any, will also be checked, even if it is not explicitly selected by an option such as <literal>--table</literal> or <literal>--relation</literal>. This option suppresses that behavior. @@ -306,9 +306,9 @@ PostgreSQL documentation <term><option>--exclude-toast-pointers</option></term> <listitem> <para> - By default, whenever a toast pointer is encountered in a table, + By default, whenever a TOAST pointer is encountered in a table, a lookup is performed to ensure that it references apparently-valid - entries in the toast table. These checks can be quite slow, and this + entries in the TOAST table. These checks can be quite slow, and this option can be used to skip them. </para> </listitem> @@ -368,9 +368,9 @@ PostgreSQL documentation End checking at the specified block number. An error will occur if the table relation being checked has fewer than this number of blocks. This option does not apply to indexes, and is probably only useful when - checking a single table relation. If both a regular table and a toast + checking a single table relation. If both a regular table and a TOAST table are checked, this option will apply to both, but higher-numbered - toast blocks may still be accessed while validating toast pointers, + TOAST blocks may still be accessed while validating TOAST pointers, unless that is suppressed using <option>--exclude-toast-pointers</option>. </para> diff --git a/doc/src/sgml/sepgsql.sgml b/doc/src/sgml/sepgsql.sgml index ca038d7..eab5fde 100644 --- a/doc/src/sgml/sepgsql.sgml +++ b/doc/src/sgml/sepgsql.sgml @@ -433,7 +433,7 @@ UPDATE t1 SET x = 2, y = func1(y) WHERE z = 100; <para> The default database privilege system allows database superusers to modify system catalogs using DML commands, and reference or modify - toast tables. These operations are prohibited when + TOAST tables. These operations are prohibited when <filename>sepgsql</filename> is enabled. </para> </sect3> diff --git a/doc/src/sgml/xfunc.sgml b/doc/src/sgml/xfunc.sgml index af7864a..69747d0 100644 --- a/doc/src/sgml/xfunc.sgml +++ b/doc/src/sgml/xfunc.sgml @@ -2555,7 +2555,7 @@ CREATE FUNCTION concat_text(text, text) RETURNS text to be just pointless obscurantism, compared to using plain <literal>C</literal> calling conventions. They do however allow us to deal with <literal>NULL</literal>able arguments/return values, - and <quote>toasted</quote> (compressed or out-of-line) values. + and <quote>TOASTed</quote> (compressed or out-of-line) values. </para> <para> diff --git a/doc/src/sgml/xtypes.sgml b/doc/src/sgml/xtypes.sgml index e67e5bd..13af113 100644 --- a/doc/src/sgml/xtypes.sgml +++ b/doc/src/sgml/xtypes.sgml @@ -267,7 +267,7 @@ CREATE TYPE complex ( <para> To support <acronym>TOAST</acronym> storage, the C functions operating on the data - type must always be careful to unpack any toasted values they are handed + type must always be careful to unpack any TOASTed values they are handed by using <function>PG_DETOAST_DATUM</function>. (This detail is customarily hidden by defining type-specific <function>GETARG_DATATYPE_P</function> macros.) Then, when running the <command>CREATE TYPE</command> command, specify the -- 1.8.3.1 ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2025-01-16 03:57 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2020-11-20 02:48 [PATCH 1/5] bootstrap: convert Typ to a List* Justin Pryzby <[email protected]> 2025-01-16 03:57 TOAST versus toast Peter Smith <[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