public inbox for [email protected]  
help / color / mirror / Atom feed
Typos
19+ messages / 10 participants
[nested] [flat]

* Typos
@ 2011-03-30 05:34  Fujii Masao <[email protected]>
  0 siblings, 1 reply; 19+ messages in thread

From: Fujii Masao @ 2011-03-30 05:34 UTC (permalink / raw)
  To: pgsql-hackers

Hi,

The attached patch fixes two typos.

Regards,

-- 
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center


Attachments:

  [application/octet-stream] typos_v1.patch (1.1K, ../../[email protected]/2-typos_v1.patch)
  download | inline diff:
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index f76b5b0..2e2659a 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -506,7 +506,7 @@ ProcessRepliesIfAny(void)
 			default:
 				ereport(FATAL,
 						(errcode(ERRCODE_PROTOCOL_VIOLATION),
-						 errmsg("invalid standby closing message type %d",
+						 errmsg("invalid standby message type %d",
 								firstchar)));
 		}
 	}
diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c
index dcdb1a9..42da1a8 100644
--- a/src/interfaces/libpq/fe-exec.c
+++ b/src/interfaces/libpq/fe-exec.c
@@ -2869,7 +2869,7 @@ PQparamtype(const PGresult *res, int param_num)
 
 /* PQsetnonblocking:
  *	sets the PGconn's database connection non-blocking if the arg is TRUE
- *	or makes it non-blocking if the arg is FALSE, this will not protect
+ *	or makes it blocking if the arg is FALSE, this will not protect
  *	you from PQexec(), you'll only be safe when using the non-blocking API.
  *	Needs to be called only on a connected database connection.
  */


^ permalink  raw  reply  [nested|flat] 19+ messages in thread

* Re: Typos
@ 2011-03-30 05:59  Heikki Linnakangas <[email protected]>
  parent: Fujii Masao <[email protected]>
  0 siblings, 0 replies; 19+ messages in thread

From: Heikki Linnakangas @ 2011-03-30 05:59 UTC (permalink / raw)
  To: Fujii Masao <[email protected]>; +Cc: pgsql-hackers

On 30.03.2011 08:34, Fujii Masao wrote:
> The attached patch fixes two typos.

Thanks, applied.

-- 
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com



^ permalink  raw  reply  [nested|flat] 19+ messages in thread

* typos
@ 2014-03-24 06:40  Erik Rijkers <[email protected]>
  0 siblings, 1 reply; 19+ messages in thread

From: Erik Rijkers @ 2014-03-24 06:40 UTC (permalink / raw)
  To: pgsql-hackers

A few 'the the' typos in code & docs.

-- 
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Attachments:

  [text/x-diff] thethe.patch (1.9K, ../../[email protected]/2-thethe.patch)
  download | inline diff:
--- src/backend/access/transam/xlog.c.orig	2014-03-23 22:43:44.864504319 +0100
+++ src/backend/access/transam/xlog.c	2014-03-23 22:44:02.735634100 +0100
@@ -1089,7 +1089,7 @@
 	 * has progressed. There is a small fixed number of insertion locks,
 	 * determined by the num_xloginsert_locks GUC. When an inserter crosses a
 	 * page boundary, it updates the value stored in the lock to the how far it
-	 * has inserted, to allow the the previous buffer to be flushed.
+	 * has inserted, to allow the previous buffer to be flushed.
 	 *
 	 * Holding onto an insertion lock also protects RedoRecPtr and
 	 * fullPageWrites from changing until the insertion is finished.
--- doc/src/sgml/json.sgml.orig	2014-03-23 22:44:19.622807673 +0100
+++ doc/src/sgml/json.sgml	2014-03-23 22:44:37.082954235 +0100
@@ -24,7 +24,7 @@
   There are two JSON data types: <type>json</> and <type>jsonb</>.
   Both accept <emphasis>almost</emphasis> identical sets of values as
   input.  The major practical difference is one of efficiency.  The
-  <type>json</> data type stores an exact copy of the the input text,
+  <type>json</> data type stores an exact copy of the input text,
   which processing functions must continually reparse, while
   <type>jsonb</> data is stored in a decomposed binary format that
   makes it slightly less efficient to input due to added serialization
--- doc/src/sgml/logicaldecoding.sgml.orig	2014-03-23 22:44:54.198118825 +0100
+++ doc/src/sgml/logicaldecoding.sgml	2014-03-23 22:45:14.746112339 +0100
@@ -169,7 +169,7 @@
     </indexterm>
     <title>Logical Decoding</title>
     <para>
-     Logical decoding is the the process of extracting all persistent changes
+     Logical decoding is the process of extracting all persistent changes
      to a database's tables into a coherent, easy to understand format which
      can be interpreted without detailed knowledge of the database's internal
      state.

^ permalink  raw  reply  [nested|flat] 19+ messages in thread

* Re: typos
@ 2014-03-24 06:42  Heikki Linnakangas <[email protected]>
  parent: Erik Rijkers <[email protected]>
  0 siblings, 0 replies; 19+ messages in thread

From: Heikki Linnakangas @ 2014-03-24 06:42 UTC (permalink / raw)
  To: Erik Rijkers <[email protected]>; +Cc: pgsql-hackers

On 03/24/2014 08:40 AM, Erik Rijkers wrote:
> A few 'the the' typos in code & docs.

Thanks, fixed.

- Heikki


-- 
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



^ permalink  raw  reply  [nested|flat] 19+ messages in thread

* [PATCH 3/4] typos
@ 2020-11-28 22:58  Justin Pryzby <[email protected]>
  0 siblings, 0 replies; 19+ messages in thread

From: Justin Pryzby @ 2020-11-28 22:58 UTC (permalink / raw)

---
 src/bin/pg_dump/pg_dump.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 990f890ff4..43e3a022d5 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -316,9 +316,9 @@ static void read_options_from_file(char *filename,
 #define OPTIONS_FILE_OPT_NUMBER			12
 
 /*
- * It assign the values of options to related DumpOption fields or to
- * some global values. It is called from twice. First, for processing
- * the command line argumens. Second, for processing an options from
+ * It assigns the values of options to related DumpOption fields or to
+ * some global values. It is called twice. First, for processing
+ * the command line arguments. Second, for processing options from
  * options file.
  */
 static bool
@@ -18711,8 +18711,8 @@ exit_invalid_optfile_format(FILE *fp,
 }
 
 /*
- * Reads an option argument from file. Supports double qoutes
- * bounded strings. In this case multi lines strings are supported.
+ * Reads an option argument from file. Supports double-quoted
+ * strings. In this case multi-line strings are supported.
  */
 static void
 read_optarg(FILE *fp,
@@ -18796,7 +18796,7 @@ read_optarg(FILE *fp,
 		}
 	}
 
-	/* check garbage after optarg, but ignore white spaces */
+	/* check garbage after optarg, but ignore white-space */
 	while (isspace(*str))
 		str++;
 
-- 
2.17.0


--7CZp05NP8/gJM8Cl
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="0004-Allow-option-file-to-include-options-files.patch"



^ permalink  raw  reply  [nested|flat] 19+ messages in thread

* typos
@ 2021-09-24 21:58  Justin Pryzby <[email protected]>
  0 siblings, 0 replies; 19+ messages in thread

From: Justin Pryzby @ 2021-09-24 21:58 UTC (permalink / raw)
  To: pgsql-hackers

A compilation of fixes for master.

The first patch should be applied to v13 - the typo was already fixed in master
but not backpatched.


^ permalink  raw  reply  [nested|flat] 19+ messages in thread

* Re: typos
@ 2022-04-13 20:56  David Rowley <[email protected]>
  0 siblings, 1 reply; 19+ messages in thread

From: David Rowley @ 2022-04-13 20:56 UTC (permalink / raw)
  To: Justin Pryzby <[email protected]>; +Cc: Robert Haas <[email protected]>; Joe Conway <[email protected]>; pgsql-hackers; Fabien COELHO <[email protected]>; Amit Kapila <[email protected]>; Masahiko Sawada <[email protected]>

On Mon, 11 Apr 2022 at 22:10, Justin Pryzby <[email protected]> wrote:
> Thanks for amending and pushing those.  There's some more less obvious ones
> attached.

Here are my notes from yesterday that I made when reviewing and
pushing many of the 2nd batch of patches.

0001: Pushed and back patched to v12

0002: Didn't push. Compression method/algorithm.

0003: Pushed and backpatched to v13

0004: Pushed (reviewed by Robert)

0005: Alvaro Pushed
0006: Alvaro Pushed

0007: Not pushed. No space after comment and closing */  pgindent
fixed one of these but not the other 2.  I've not looked into why
pgindent does 1 and not the other 2.

0008: Pushed

I've left out the following change as it does not seem to be bringing
any sort of consistency to the docs overall. It only brings
consistency to a single source file in the docs.

-      You need <productname>zstd</productname>, if you want to support
+      You need <productname>ZSTD</productname>, if you want to support

See: git grep -i ">zstd<"

0009:

This contains a few fixes that look correct. Not sure if the following
has any use as a change:

-    See the description of the respective commands and programs for the
-    respective details.  Note that you can mix locale providers on different
+    See the description of the respective commands and programs for
+    details.  Note that you can mix locale providers at different

0010: Pushed

0011: Not pushed. Not sure if this is worth the change.

0012: Amit Pushed

0013: Not pushed. Adds a missing comma.

David






^ permalink  raw  reply  [nested|flat] 19+ messages in thread

* Re: typos
@ 2022-04-21 04:36  Michael Paquier <[email protected]>
  1 sibling, 0 replies; 19+ messages in thread

From: Michael Paquier @ 2022-04-21 04:36 UTC (permalink / raw)
  To: Alvaro Herrera <[email protected]>; +Cc: Justin Pryzby <[email protected]>; David Rowley <[email protected]>; pgsql-hackers; Fabien COELHO <[email protected]>; Amit Kapila <[email protected]>

On Wed, Apr 20, 2022 at 11:32:08PM +0200, Alvaro Herrera wrote:
> So the attached.
> 
> --- a/doc/src/sgml/install-windows.sgml
> +++ b/doc/src/sgml/install-windows.sgml
> @@ -307,9 +307,9 @@ $ENV{MSBFLAGS}="/m";
>      </varlistentry>
>  
>      <varlistentry>
> -     <term><productname>ZSTD</productname></term>
> +     <term><productname>Zstd</productname></term>
>       <listitem><para>
> -      Required for supporting <productname>ZSTD</productname> compression
> +      Required for supporting <productname>Zstd</productname> compression

Looking at the zstd project itself for reference or just wiki-sensei,
I don't think that this is correct:
https://github.com/facebook/zstd
https://en.wikipedia.org/wiki/Zstd

Their README uses "zstd" in lower-case, while "Zstd" (first letter
upper-case) is used at the beginning of a sentence.
--
Michael


Attachments:

  [application/pgp-signature] signature.asc (833B, ../../[email protected]/2-signature.asc)
  download

^ permalink  raw  reply  [nested|flat] 19+ messages in thread

* [PATCH v2022051001 2/2] typos
@ 2022-05-11 00:02  Justin Pryzby <[email protected]>
  0 siblings, 0 replies; 19+ messages in thread

From: Justin Pryzby @ 2022-05-11 00:02 UTC (permalink / raw)

---
 contrib/citext/expected/citext.out          | 2 +-
 contrib/citext/expected/citext_1.out        | 2 +-
 contrib/citext/sql/citext.sql               | 2 +-
 src/backend/executor/execGrouping.c         | 2 +-
 src/backend/parser/parse_expr.c             | 2 +-
 src/backend/replication/basebackup_target.c | 2 +-
 src/backend/utils/adt/int8.c                | 2 +-
 src/bin/pg_basebackup/bbstreamer_tar.c      | 2 +-
 src/bin/pg_rewind/t/007_standby_source.pl   | 2 +-
 src/bin/pg_rewind/t/009_growing_files.pl    | 2 +-
 src/test/regress/expected/psql.out          | 2 +-
 src/test/regress/sql/psql.sql               | 2 +-
 src/test/ssl/t/SSL/Backend/OpenSSL.pm       | 2 +-
 13 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/contrib/citext/expected/citext.out b/contrib/citext/expected/citext.out
index 5afcc50920e..1c555981363 100644
--- a/contrib/citext/expected/citext.out
+++ b/contrib/citext/expected/citext.out
@@ -2270,7 +2270,7 @@ SELECT COUNT(*) = 8::bigint AS t FROM try;
 
 INSERT INTO try
 VALUES ( to_char(  now()::timestamp,          'HH12:MI:SS') ),
-       ( to_char(  now() + '1 sec'::interval, 'HH12:MI:SS') ), -- timetamptz
+       ( to_char(  now() + '1 sec'::interval, 'HH12:MI:SS') ), -- timestamptz
        ( to_char(  '15h 2m 12s'::interval,    'HH24:MI:SS') ),
        ( to_char(  current_date,              '999') ),
        ( to_char(  125::int,                  '999') ),
diff --git a/contrib/citext/expected/citext_1.out b/contrib/citext/expected/citext_1.out
index 8aa2b9e1dbc..4a979d7a0d9 100644
--- a/contrib/citext/expected/citext_1.out
+++ b/contrib/citext/expected/citext_1.out
@@ -2270,7 +2270,7 @@ SELECT COUNT(*) = 8::bigint AS t FROM try;
 
 INSERT INTO try
 VALUES ( to_char(  now()::timestamp,          'HH12:MI:SS') ),
-       ( to_char(  now() + '1 sec'::interval, 'HH12:MI:SS') ), -- timetamptz
+       ( to_char(  now() + '1 sec'::interval, 'HH12:MI:SS') ), -- timestamptz
        ( to_char(  '15h 2m 12s'::interval,    'HH24:MI:SS') ),
        ( to_char(  current_date,              '999') ),
        ( to_char(  125::int,                  '999') ),
diff --git a/contrib/citext/sql/citext.sql b/contrib/citext/sql/citext.sql
index 8c87be6b1d2..b329253d379 100644
--- a/contrib/citext/sql/citext.sql
+++ b/contrib/citext/sql/citext.sql
@@ -696,7 +696,7 @@ SELECT to_timestamp('05 Dec 2000',         'DD Mon YYYY'::citext)
 SELECT COUNT(*) = 8::bigint AS t FROM try;
 INSERT INTO try
 VALUES ( to_char(  now()::timestamp,          'HH12:MI:SS') ),
-       ( to_char(  now() + '1 sec'::interval, 'HH12:MI:SS') ), -- timetamptz
+       ( to_char(  now() + '1 sec'::interval, 'HH12:MI:SS') ), -- timestamptz
        ( to_char(  '15h 2m 12s'::interval,    'HH24:MI:SS') ),
        ( to_char(  current_date,              '999') ),
        ( to_char(  125::int,                  '999') ),
diff --git a/src/backend/executor/execGrouping.c b/src/backend/executor/execGrouping.c
index 5da4b375300..0cc54a3449e 100644
--- a/src/backend/executor/execGrouping.c
+++ b/src/backend/executor/execGrouping.c
@@ -246,7 +246,7 @@ BuildTupleHashTableExt(PlanState *parent,
 }
 
 /*
- * BuildTupleHashTable is a backwards-compatibilty wrapper for
+ * BuildTupleHashTable is a backwards-compatibility wrapper for
  * BuildTupleHashTableExt(), that allocates the hashtable's metadata in
  * tablecxt. Note that hashtables created this way cannot be reset leak-free
  * with ResetTupleHashTable().
diff --git a/src/backend/parser/parse_expr.c b/src/backend/parser/parse_expr.c
index 33eb19a33fc..c1f194cc5b0 100644
--- a/src/backend/parser/parse_expr.c
+++ b/src/backend/parser/parse_expr.c
@@ -4536,7 +4536,7 @@ transformJsonParseExpr(ParseState *pstate, JsonParseExpr *jsexpr)
 	else
 	{
 		/*
-		 * Coerce argument to target type using CAST for compatibilty with PG
+		 * Coerce argument to target type using CAST for compatibility with PG
 		 * function-like CASTs.
 		 */
 		arg = transformJsonValueExprExt(pstate, jsexpr->expr, JS_FORMAT_JSON,
diff --git a/src/backend/replication/basebackup_target.c b/src/backend/replication/basebackup_target.c
index cff65611ef6..faa80b2f2ec 100644
--- a/src/backend/replication/basebackup_target.c
+++ b/src/backend/replication/basebackup_target.c
@@ -1,7 +1,7 @@
 /*-------------------------------------------------------------------------
  *
  * basebackup_target.c
- *	  Base backups can be "targetted," which means that they can be sent
+ *	  Base backups can be "targeted," which means that they can be sent
  *	  somewhere other than to the client which requested the backup.
  *	  Furthermore, new targets can be defined by extensions. This file
  *	  contains code to support that functionality.
diff --git a/src/backend/utils/adt/int8.c b/src/backend/utils/adt/int8.c
index 98d43237556..c7448ec565e 100644
--- a/src/backend/utils/adt/int8.c
+++ b/src/backend/utils/adt/int8.c
@@ -1171,7 +1171,7 @@ int28div(PG_FUNCTION_ARGS)
 	PG_RETURN_INT64((int64) arg1 / arg2);
 }
 
-/* Binary arithmetics
+/* Binary arithmetic
  *
  *		int8and		- returns arg1 & arg2
  *		int8or		- returns arg1 | arg2
diff --git a/src/bin/pg_basebackup/bbstreamer_tar.c b/src/bin/pg_basebackup/bbstreamer_tar.c
index fcbad579df1..ef5586c488f 100644
--- a/src/bin/pg_basebackup/bbstreamer_tar.c
+++ b/src/bin/pg_basebackup/bbstreamer_tar.c
@@ -423,7 +423,7 @@ bbstreamer_tar_archiver_content(bbstreamer *streamer,
 		data = buffer;
 		len = pad_bytes;
 
-		/* Don't do this agian unless we replace another header. */
+		/* Don't do this again unless we replace another header. */
 		mystreamer->rearchive_member = false;
 	}
 	else if (context == BBSTREAMER_ARCHIVE_TRAILER)
diff --git a/src/bin/pg_rewind/t/007_standby_source.pl b/src/bin/pg_rewind/t/007_standby_source.pl
index 47320ea5a67..f89a4df09d9 100644
--- a/src/bin/pg_rewind/t/007_standby_source.pl
+++ b/src/bin/pg_rewind/t/007_standby_source.pl
@@ -141,7 +141,7 @@ move(
 # Restart the node.
 $node_c->start;
 
-# set RewindTest::node_primary to point to the rewinded node, so that we can
+# set RewindTest::node_primary to point to the rewound node, so that we can
 # use check_query()
 $node_primary = $node_c;
 
diff --git a/src/bin/pg_rewind/t/009_growing_files.pl b/src/bin/pg_rewind/t/009_growing_files.pl
index 2c81406cc07..a5a58dbe060 100644
--- a/src/bin/pg_rewind/t/009_growing_files.pl
+++ b/src/bin/pg_rewind/t/009_growing_files.pl
@@ -47,7 +47,7 @@ mkdir "$standby_pgdata/tst_both_dir";
 append_to_file "$standby_pgdata/tst_both_dir/file1", 'a';
 
 # Run pg_rewind and pipe the output from the run into the extra file we want
-# to copy. This will ensure that the file is continously growing during the
+# to copy. This will ensure that the file is continuously growing during the
 # copy operation and the result will be an error.
 my $ret = run_log(
 	[
diff --git a/src/test/regress/expected/psql.out b/src/test/regress/expected/psql.out
index 1c5b5d2763d..2a38a93a3b3 100644
--- a/src/test/regress/expected/psql.out
+++ b/src/test/regress/expected/psql.out
@@ -5481,7 +5481,7 @@ INSERT INTO bla VALUES ('Susie');         -- succeeds
 INSERT INTO bla VALUES ('Rosalyn') \;     -- will rollback
 SELECT 'before error' AS show \;          -- will show nevertheless!
   SELECT psql_error('boum!') \;           -- failure
-  SELECT 'after error' AS noshow;         -- hidden by preceeding error
+  SELECT 'after error' AS noshow;         -- hidden by preceding error
      show     
 --------------
  before error
diff --git a/src/test/regress/sql/psql.sql b/src/test/regress/sql/psql.sql
index 6fc0ac6bd17..1149c6a839e 100644
--- a/src/test/regress/sql/psql.sql
+++ b/src/test/regress/sql/psql.sql
@@ -1432,7 +1432,7 @@ INSERT INTO bla VALUES ('Susie');         -- succeeds
 INSERT INTO bla VALUES ('Rosalyn') \;     -- will rollback
 SELECT 'before error' AS show \;          -- will show nevertheless!
   SELECT psql_error('boum!') \;           -- failure
-  SELECT 'after error' AS noshow;         -- hidden by preceeding error
+  SELECT 'after error' AS noshow;         -- hidden by preceding error
 INSERT INTO bla(s) VALUES ('Moe') \;      -- will rollback
   SELECT psql_error('bam!');
 INSERT INTO bla VALUES ('Miss Wormwood'); -- succeeds
diff --git a/src/test/ssl/t/SSL/Backend/OpenSSL.pm b/src/test/ssl/t/SSL/Backend/OpenSSL.pm
index 1546b5081ba..d6d99fa636a 100644
--- a/src/test/ssl/t/SSL/Backend/OpenSSL.pm
+++ b/src/test/ssl/t/SSL/Backend/OpenSSL.pm
@@ -135,7 +135,7 @@ sub get_sslkey
 =item $backend->set_server_cert(params)
 
 Change the configuration to use given server cert, key and crl file(s). The
-following paramters are supported:
+following parameters are supported:
 
 =over
 
-- 
2.17.1


--IiVenqGWf+H9Y6IX--





^ permalink  raw  reply  [nested|flat] 19+ messages in thread

* [PATCH v2022051001 2/2] typos
@ 2022-05-11 00:02  Justin Pryzby <[email protected]>
  0 siblings, 0 replies; 19+ messages in thread

From: Justin Pryzby @ 2022-05-11 00:02 UTC (permalink / raw)

---
 contrib/citext/expected/citext.out          | 2 +-
 contrib/citext/expected/citext_1.out        | 2 +-
 contrib/citext/sql/citext.sql               | 2 +-
 src/backend/executor/execGrouping.c         | 2 +-
 src/backend/parser/parse_expr.c             | 2 +-
 src/backend/replication/basebackup_target.c | 2 +-
 src/backend/utils/adt/int8.c                | 2 +-
 src/bin/pg_basebackup/bbstreamer_tar.c      | 2 +-
 src/bin/pg_rewind/t/007_standby_source.pl   | 2 +-
 src/bin/pg_rewind/t/009_growing_files.pl    | 2 +-
 src/test/regress/expected/psql.out          | 2 +-
 src/test/regress/sql/psql.sql               | 2 +-
 src/test/ssl/t/SSL/Backend/OpenSSL.pm       | 2 +-
 13 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/contrib/citext/expected/citext.out b/contrib/citext/expected/citext.out
index 5afcc50920e..1c555981363 100644
--- a/contrib/citext/expected/citext.out
+++ b/contrib/citext/expected/citext.out
@@ -2270,7 +2270,7 @@ SELECT COUNT(*) = 8::bigint AS t FROM try;
 
 INSERT INTO try
 VALUES ( to_char(  now()::timestamp,          'HH12:MI:SS') ),
-       ( to_char(  now() + '1 sec'::interval, 'HH12:MI:SS') ), -- timetamptz
+       ( to_char(  now() + '1 sec'::interval, 'HH12:MI:SS') ), -- timestamptz
        ( to_char(  '15h 2m 12s'::interval,    'HH24:MI:SS') ),
        ( to_char(  current_date,              '999') ),
        ( to_char(  125::int,                  '999') ),
diff --git a/contrib/citext/expected/citext_1.out b/contrib/citext/expected/citext_1.out
index 8aa2b9e1dbc..4a979d7a0d9 100644
--- a/contrib/citext/expected/citext_1.out
+++ b/contrib/citext/expected/citext_1.out
@@ -2270,7 +2270,7 @@ SELECT COUNT(*) = 8::bigint AS t FROM try;
 
 INSERT INTO try
 VALUES ( to_char(  now()::timestamp,          'HH12:MI:SS') ),
-       ( to_char(  now() + '1 sec'::interval, 'HH12:MI:SS') ), -- timetamptz
+       ( to_char(  now() + '1 sec'::interval, 'HH12:MI:SS') ), -- timestamptz
        ( to_char(  '15h 2m 12s'::interval,    'HH24:MI:SS') ),
        ( to_char(  current_date,              '999') ),
        ( to_char(  125::int,                  '999') ),
diff --git a/contrib/citext/sql/citext.sql b/contrib/citext/sql/citext.sql
index 8c87be6b1d2..b329253d379 100644
--- a/contrib/citext/sql/citext.sql
+++ b/contrib/citext/sql/citext.sql
@@ -696,7 +696,7 @@ SELECT to_timestamp('05 Dec 2000',         'DD Mon YYYY'::citext)
 SELECT COUNT(*) = 8::bigint AS t FROM try;
 INSERT INTO try
 VALUES ( to_char(  now()::timestamp,          'HH12:MI:SS') ),
-       ( to_char(  now() + '1 sec'::interval, 'HH12:MI:SS') ), -- timetamptz
+       ( to_char(  now() + '1 sec'::interval, 'HH12:MI:SS') ), -- timestamptz
        ( to_char(  '15h 2m 12s'::interval,    'HH24:MI:SS') ),
        ( to_char(  current_date,              '999') ),
        ( to_char(  125::int,                  '999') ),
diff --git a/src/backend/executor/execGrouping.c b/src/backend/executor/execGrouping.c
index 5da4b375300..0cc54a3449e 100644
--- a/src/backend/executor/execGrouping.c
+++ b/src/backend/executor/execGrouping.c
@@ -246,7 +246,7 @@ BuildTupleHashTableExt(PlanState *parent,
 }
 
 /*
- * BuildTupleHashTable is a backwards-compatibilty wrapper for
+ * BuildTupleHashTable is a backwards-compatibility wrapper for
  * BuildTupleHashTableExt(), that allocates the hashtable's metadata in
  * tablecxt. Note that hashtables created this way cannot be reset leak-free
  * with ResetTupleHashTable().
diff --git a/src/backend/parser/parse_expr.c b/src/backend/parser/parse_expr.c
index 33eb19a33fc..c1f194cc5b0 100644
--- a/src/backend/parser/parse_expr.c
+++ b/src/backend/parser/parse_expr.c
@@ -4536,7 +4536,7 @@ transformJsonParseExpr(ParseState *pstate, JsonParseExpr *jsexpr)
 	else
 	{
 		/*
-		 * Coerce argument to target type using CAST for compatibilty with PG
+		 * Coerce argument to target type using CAST for compatibility with PG
 		 * function-like CASTs.
 		 */
 		arg = transformJsonValueExprExt(pstate, jsexpr->expr, JS_FORMAT_JSON,
diff --git a/src/backend/replication/basebackup_target.c b/src/backend/replication/basebackup_target.c
index cff65611ef6..faa80b2f2ec 100644
--- a/src/backend/replication/basebackup_target.c
+++ b/src/backend/replication/basebackup_target.c
@@ -1,7 +1,7 @@
 /*-------------------------------------------------------------------------
  *
  * basebackup_target.c
- *	  Base backups can be "targetted," which means that they can be sent
+ *	  Base backups can be "targeted," which means that they can be sent
  *	  somewhere other than to the client which requested the backup.
  *	  Furthermore, new targets can be defined by extensions. This file
  *	  contains code to support that functionality.
diff --git a/src/backend/utils/adt/int8.c b/src/backend/utils/adt/int8.c
index 98d43237556..c7448ec565e 100644
--- a/src/backend/utils/adt/int8.c
+++ b/src/backend/utils/adt/int8.c
@@ -1171,7 +1171,7 @@ int28div(PG_FUNCTION_ARGS)
 	PG_RETURN_INT64((int64) arg1 / arg2);
 }
 
-/* Binary arithmetics
+/* Binary arithmetic
  *
  *		int8and		- returns arg1 & arg2
  *		int8or		- returns arg1 | arg2
diff --git a/src/bin/pg_basebackup/bbstreamer_tar.c b/src/bin/pg_basebackup/bbstreamer_tar.c
index fcbad579df1..ef5586c488f 100644
--- a/src/bin/pg_basebackup/bbstreamer_tar.c
+++ b/src/bin/pg_basebackup/bbstreamer_tar.c
@@ -423,7 +423,7 @@ bbstreamer_tar_archiver_content(bbstreamer *streamer,
 		data = buffer;
 		len = pad_bytes;
 
-		/* Don't do this agian unless we replace another header. */
+		/* Don't do this again unless we replace another header. */
 		mystreamer->rearchive_member = false;
 	}
 	else if (context == BBSTREAMER_ARCHIVE_TRAILER)
diff --git a/src/bin/pg_rewind/t/007_standby_source.pl b/src/bin/pg_rewind/t/007_standby_source.pl
index 47320ea5a67..f89a4df09d9 100644
--- a/src/bin/pg_rewind/t/007_standby_source.pl
+++ b/src/bin/pg_rewind/t/007_standby_source.pl
@@ -141,7 +141,7 @@ move(
 # Restart the node.
 $node_c->start;
 
-# set RewindTest::node_primary to point to the rewinded node, so that we can
+# set RewindTest::node_primary to point to the rewound node, so that we can
 # use check_query()
 $node_primary = $node_c;
 
diff --git a/src/bin/pg_rewind/t/009_growing_files.pl b/src/bin/pg_rewind/t/009_growing_files.pl
index 2c81406cc07..a5a58dbe060 100644
--- a/src/bin/pg_rewind/t/009_growing_files.pl
+++ b/src/bin/pg_rewind/t/009_growing_files.pl
@@ -47,7 +47,7 @@ mkdir "$standby_pgdata/tst_both_dir";
 append_to_file "$standby_pgdata/tst_both_dir/file1", 'a';
 
 # Run pg_rewind and pipe the output from the run into the extra file we want
-# to copy. This will ensure that the file is continously growing during the
+# to copy. This will ensure that the file is continuously growing during the
 # copy operation and the result will be an error.
 my $ret = run_log(
 	[
diff --git a/src/test/regress/expected/psql.out b/src/test/regress/expected/psql.out
index 1c5b5d2763d..2a38a93a3b3 100644
--- a/src/test/regress/expected/psql.out
+++ b/src/test/regress/expected/psql.out
@@ -5481,7 +5481,7 @@ INSERT INTO bla VALUES ('Susie');         -- succeeds
 INSERT INTO bla VALUES ('Rosalyn') \;     -- will rollback
 SELECT 'before error' AS show \;          -- will show nevertheless!
   SELECT psql_error('boum!') \;           -- failure
-  SELECT 'after error' AS noshow;         -- hidden by preceeding error
+  SELECT 'after error' AS noshow;         -- hidden by preceding error
      show     
 --------------
  before error
diff --git a/src/test/regress/sql/psql.sql b/src/test/regress/sql/psql.sql
index 6fc0ac6bd17..1149c6a839e 100644
--- a/src/test/regress/sql/psql.sql
+++ b/src/test/regress/sql/psql.sql
@@ -1432,7 +1432,7 @@ INSERT INTO bla VALUES ('Susie');         -- succeeds
 INSERT INTO bla VALUES ('Rosalyn') \;     -- will rollback
 SELECT 'before error' AS show \;          -- will show nevertheless!
   SELECT psql_error('boum!') \;           -- failure
-  SELECT 'after error' AS noshow;         -- hidden by preceeding error
+  SELECT 'after error' AS noshow;         -- hidden by preceding error
 INSERT INTO bla(s) VALUES ('Moe') \;      -- will rollback
   SELECT psql_error('bam!');
 INSERT INTO bla VALUES ('Miss Wormwood'); -- succeeds
diff --git a/src/test/ssl/t/SSL/Backend/OpenSSL.pm b/src/test/ssl/t/SSL/Backend/OpenSSL.pm
index 1546b5081ba..d6d99fa636a 100644
--- a/src/test/ssl/t/SSL/Backend/OpenSSL.pm
+++ b/src/test/ssl/t/SSL/Backend/OpenSSL.pm
@@ -135,7 +135,7 @@ sub get_sslkey
 =item $backend->set_server_cert(params)
 
 Change the configuration to use given server cert, key and crl file(s). The
-following paramters are supported:
+following parameters are supported:
 
 =over
 
-- 
2.17.1


--IiVenqGWf+H9Y6IX--





^ permalink  raw  reply  [nested|flat] 19+ messages in thread

* Re: typos
@ 2022-05-11 02:03  Justin Pryzby <[email protected]>
  1 sibling, 1 reply; 19+ messages in thread

From: Justin Pryzby @ 2022-05-11 02:03 UTC (permalink / raw)
  To: pgsql-hackers

I found a bunch more typos; a couple from codespell, and several which are the
result of looking for previously-reported typos, like:

time git log origin --grep '[tT]ypo' --word-diff -U1 |grep -Eo '\[-[[:lower:]]+-\]' |sed 's/^\[-//; s/-\]$//' |sort -u |grep -Fxvwf /usr/share/dict/words >badwords.txt
time grep -rhoFwf badwords.txt doc |sort -u >not-badwords.txt
time grep -Fxvwf not-badwords.txt ./badwords.txt >./badwords.txt.new
time grep -rhoIFwf ./badwords.txt.new src --incl='*.[chly]' --incl='*.p[lm]' |sort |uniq -c |sort -nr |less



^ permalink  raw  reply  [nested|flat] 19+ messages in thread

* Re: typos
@ 2022-05-11 06:41  Michael Paquier <[email protected]>
  parent: Justin Pryzby <[email protected]>
  0 siblings, 0 replies; 19+ messages in thread

From: Michael Paquier @ 2022-05-11 06:41 UTC (permalink / raw)
  To: Justin Pryzby <[email protected]>; +Cc: pgsql-hackers

On Tue, May 10, 2022 at 09:03:34PM -0500, Justin Pryzby wrote:
> I found a bunch more typos; a couple from codespell, and several which are the
> result of looking for previously-reported typos, like:

Thanks, applied 0002.

Regarding 0001, I don't really know which one of {AND,OR}ed or
{AND,OR}-ed is better.  Note that the code prefers the former, but
your patch changes the docs to use the latter.
--
Michael


Attachments:

  [application/pgp-signature] signature.asc (833B, ../../[email protected]/2-signature.asc)
  download

^ permalink  raw  reply  [nested|flat] 19+ messages in thread

* Re: typos
@ 2022-07-05 07:51  Noah Misch <[email protected]>
  parent: David Rowley <[email protected]>
  0 siblings, 0 replies; 19+ messages in thread

From: Noah Misch @ 2022-07-05 07:51 UTC (permalink / raw)
  To: David Rowley <[email protected]>; +Cc: Justin Pryzby <[email protected]>; Robert Haas <[email protected]>; Joe Conway <[email protected]>; pgsql-hackers; Fabien COELHO <[email protected]>; Amit Kapila <[email protected]>; Masahiko Sawada <[email protected]>

On Thu, Apr 14, 2022 at 08:56:22AM +1200, David Rowley wrote:
> 0007: Not pushed. No space after comment and closing */  pgindent
> fixed one of these but not the other 2.  I've not looked into why
> pgindent does 1 and not the other 2.

> -/* get operation priority  by its code*/
> +/* get operation priority by its code */

pgindent never touches comments that start in column zero.  (That's why many
column-0 comments are wrapped to widths other than the standard 78.)





^ permalink  raw  reply  [nested|flat] 19+ messages in thread

* [PATCH 1/4] typos
@ 2022-07-05 19:12  Justin Pryzby <[email protected]>
  0 siblings, 0 replies; 19+ messages in thread

From: Justin Pryzby @ 2022-07-05 19:12 UTC (permalink / raw)

---
 doc/src/sgml/brin.sgml                  | 2 +-
 src/backend/commands/dbcommands.c       | 6 +++---
 src/include/replication/reorderbuffer.h | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/doc/src/sgml/brin.sgml b/doc/src/sgml/brin.sgml
index 4ee8908b65a..71697155d7c 100644
--- a/doc/src/sgml/brin.sgml
+++ b/doc/src/sgml/brin.sgml
@@ -75,7 +75,7 @@
    summarized will cause the summary information to be updated with data
    from the new tuples.
    When a new page is created that does not fall within the last
-   summarized range, the range that the new page belongs into
+   summarized range, the range that the new page belongs to
    does not automatically acquire a summary tuple;
    those tuples remain unsummarized until a summarization run is
    invoked later, creating the initial summary for that range.
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index 7bc53f3a0bb..9f990a8d68f 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -188,7 +188,7 @@ CreateDatabaseUsingWalLog(Oid src_dboid, Oid dst_dboid,
 
 		/*
 		 * If the relation is from the source db's default tablespace then we
-		 * need to create it in the destinations db's default tablespace.
+		 * need to create it in the destination db's default tablespace.
 		 * Otherwise, we need to create in the same tablespace as it is in the
 		 * source database.
 		 */
@@ -1351,8 +1351,8 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
 	/*
 	 * If we're going to be reading data for the to-be-created database into
 	 * shared_buffers, take a lock on it. Nobody should know that this
-	 * database exists yet, but it's good to maintain the invariant that a
-	 * lock an AccessExclusiveLock on the database is sufficient to drop all
+	 * database exists yet, but it's good to maintain the invariant that an
+	 * AccessExclusiveLock on the database is sufficient to drop all
 	 * of its buffers without worrying about more being read later.
 	 *
 	 * Note that we need to do this before entering the
diff --git a/src/include/replication/reorderbuffer.h b/src/include/replication/reorderbuffer.h
index d109d0baede..2c9206ace41 100644
--- a/src/include/replication/reorderbuffer.h
+++ b/src/include/replication/reorderbuffer.h
@@ -262,7 +262,7 @@ typedef struct ReorderBufferTXN
 	 * aborted. This can be a
 	 * * plain commit record
 	 * * plain commit record, of a parent transaction
-	 * * prepared tansaction
+	 * * prepared transaction
 	 * * prepared transaction commit
 	 * * plain abort record
 	 * * prepared transaction abort
-- 
2.17.1


--GN/IAAAoV4GJoJGS
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="0002-fix-whitespace.patch"



^ permalink  raw  reply  [nested|flat] 19+ messages in thread

* [PATCH 1/9] typos
@ 2022-09-25 23:40  Justin Pryzby <[email protected]>
  0 siblings, 0 replies; 19+ messages in thread

From: Justin Pryzby @ 2022-09-25 23:40 UTC (permalink / raw)

---
 .cirrus.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.cirrus.yml b/.cirrus.yml
index 69837bcd5ad..048a004e309 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -655,7 +655,7 @@ task:
 
     # Use larger ccache cache, as this task compiles with multiple compilers /
     # flag combinations
-    CCACHE_MAXSIZE: "1GB"
+    CCACHE_MAXSIZE: "1G"
     CCACHE_DIR: "/tmp/ccache_dir"
 
     LINUX_CONFIGURE_FEATURES: *LINUX_CONFIGURE_FEATURES
-- 
2.25.1


--KFztAG8eRSV9hGtP
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="0002-comments-grammar-extended-and-other-stats.patch"



^ permalink  raw  reply  [nested|flat] 19+ messages in thread

* [PATCH 06/16] typos
@ 2022-09-25 23:40  Justin Pryzby <[email protected]>
  0 siblings, 0 replies; 19+ messages in thread

From: Justin Pryzby @ 2022-09-25 23:40 UTC (permalink / raw)

---
 .cirrus.yml                               | 12 ++++++------
 doc/src/sgml/ref/grant.sgml               |  2 +-
 meson.build                               |  4 ++--
 src/backend/optimizer/util/tlist.c        |  2 +-
 src/bin/pg_dump/pg_dumpall.c              |  2 +-
 src/include/lib/ilist.h                   |  2 +-
 src/test/regress/expected/copy.out        |  2 +-
 src/test/regress/expected/expressions.out |  2 +-
 src/test/regress/sql/copy.sql             |  2 +-
 src/test/regress/sql/expressions.sql      |  2 +-
 src/test/ssl/t/SSL/Server.pm              |  2 +-
 11 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/.cirrus.yml b/.cirrus.yml
index 993af888659..082ba84c2b2 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -11,7 +11,7 @@ env:
   CONTAINER_REPO: us-docker.pkg.dev/${GCP_PROJECT}/ci
 
   # The lower depth accelerates git clone. Use a bit of depth so that
-  # concurrent tasks and retrying older jobs has a chance of working.
+  # concurrent tasks and retrying older jobs have a chance of working.
   CIRRUS_CLONE_DEPTH: 500
   # Useful to be able to analyse what in a script takes long
   CIRRUS_LOG_TIMESTAMP: true
@@ -47,7 +47,7 @@ on_failure_meson: &on_failure_meson
 
   # In theory it'd be nice to upload the junit files meson generates, so that
   # cirrus will nicely annotate the commit. Unfortunately the files don't
-  # contain identifieable file + line numbers right now, so the annotations
+  # contain identifiable file + line numbers right now, so the annotations
   # don't end up useful. We could probably improve on that with a some custom
   # conversion script, but ...
   meson_log_artifacts:
@@ -160,7 +160,7 @@ task:
 
   ccache_cache:
     folder: $CCACHE_DIR
-  # Workaround around performance issues due to 32KB block size
+  # Work around performance issues due to 32KB block size
   repartition_script: src/tools/ci/gcp_freebsd_repartition.sh
   create_user_script: |
     pw useradd postgres
@@ -251,7 +251,7 @@ task:
     DEBUGINFOD_URLS: "https://debuginfod.debian.net";
 
     # Enable a reasonable set of sanitizers. Use the linux task for that, as
-    # it one of the fastest tasks (without sanitizers). Also several of the
+    # it's one of the fastest tasks (without sanitizers). Also several of the
     # sanitizers work best on linux.
     #
     # The overhead of alignment sanitizer is low, undefined behaviour has
@@ -600,7 +600,7 @@ task:
     CCACHE_MAXSIZE: "500M"
     CCACHE_SLOPPINESS: pch_defines,time_macros
     CCACHE_DEPEND: 1
-    # for some reason mingw plpython cannot find it's installation without this
+    # for some reason mingw plpython cannot find its installation without this
     PYTHONHOME: C:/msys64/ucrt64
     # prevents MSYS bash from resetting error mode
     MSYS: winjitdebug
@@ -655,7 +655,7 @@ task:
 
     # Use larger ccache cache, as this task compiles with multiple compilers /
     # flag combinations
-    CCACHE_MAXSIZE: "1GB"
+    CCACHE_MAXSIZE: "1G"
     CCACHE_DIR: "/tmp/ccache_dir"
 
     LINUX_CONFIGURE_FEATURES: *LINUX_CONFIGURE_FEATURES
diff --git a/doc/src/sgml/ref/grant.sgml b/doc/src/sgml/ref/grant.sgml
index c8ca2b1d641..518bdb32d82 100644
--- a/doc/src/sgml/ref/grant.sgml
+++ b/doc/src/sgml/ref/grant.sgml
@@ -253,7 +253,7 @@ GRANT <replaceable class="parameter">role_name</replaceable> [, ...] TO <replace
    in a role to one or more other roles.  Membership in a role is significant
    because it potentially allows access to the privileges granted to a role
    to each of its members, and potentially also the ability to make changes
-   to the role itself. However, the actual permisions conferred depend on
+   to the role itself. However, the actual permissions conferred depend on
    the options associated with the grant.
   </para>
 
diff --git a/meson.build b/meson.build
index b872470cdfe..c60dc2c4111 100644
--- a/meson.build
+++ b/meson.build
@@ -21,7 +21,7 @@ project('postgresql',
     'buildtype=release',
     # For compatibility with the autoconf build, set a default prefix. This
     # works even on windows, where it's a drive-relative path (i.e. when on
-    # d:/sompath it'll install to d:/usr/local/pgsql)
+    # d:/somepath it'll install to d:/usr/local/pgsql)
     'prefix=/usr/local/pgsql',
   ]
 )
@@ -1078,7 +1078,7 @@ if not get_option('readline').disabled()
 
     if not at_least_one_header_found
       error('''readline header not found
-If you have @0@ already installed, see see meson-log/meson-log.txt for details on the
+If you have @0@ already installed, see meson-log/meson-log.txt for details on the
 failure. It is possible the compiler isn't looking in the proper directory.
 Use -Dreadline=false to disable readline support.'''.format(readline_dep))
     endif
diff --git a/src/backend/optimizer/util/tlist.c b/src/backend/optimizer/util/tlist.c
index 784a1af82df..eed3e3fb75a 100644
--- a/src/backend/optimizer/util/tlist.c
+++ b/src/backend/optimizer/util/tlist.c
@@ -865,7 +865,7 @@ apply_pathtarget_labeling_to_tlist(List *tlist, PathTarget *target)
  *
  * The outputs of this function are two parallel lists, one a list of
  * PathTargets and the other an integer list of bool flags indicating
- * whether the corresponding PathTarget contains any evaluatable SRFs.
+ * whether the corresponding PathTarget contains any evaluable SRFs.
  * The lists are given in the order they'd need to be evaluated in, with
  * the "lowest" PathTarget first.  So the last list entry is always the
  * originally given PathTarget, and any entries before it indicate evaluation
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index 7b40081678b..6f351034039 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -1034,7 +1034,7 @@ dumpRoleMembership(PGconn *conn)
 		ht = rolename_create(remaining, NULL);
 
 		/*
-		 * Make repeated passses over the grants for this role until all have
+		 * Make repeated passes over the grants for this role until all have
 		 * been dumped.
 		 */
 		while (remaining > 0)
diff --git a/src/include/lib/ilist.h b/src/include/lib/ilist.h
index 3c543e7c365..d7c4b2da5ed 100644
--- a/src/include/lib/ilist.h
+++ b/src/include/lib/ilist.h
@@ -162,7 +162,7 @@ typedef struct dlist_head
 
 
 /*
- * Doubly linked list iterator type for dlist_head and and dclist_head types.
+ * Doubly linked list iterator type for dlist_head and dclist_head types.
  *
  * Used as state in dlist_foreach() and dlist_reverse_foreach() (and the
  * dclist variant thereof).
diff --git a/src/test/regress/expected/copy.out b/src/test/regress/expected/copy.out
index 3fad1c52d1f..8a8bf43fdea 100644
--- a/src/test/regress/expected/copy.out
+++ b/src/test/regress/expected/copy.out
@@ -182,7 +182,7 @@ create table header_copytest (
 	b int,
 	c text
 );
--- Make sure it works with with dropped columns
+-- Make sure it works with dropped columns
 alter table header_copytest drop column c;
 alter table header_copytest add column c text;
 copy header_copytest to stdout with (header match);
diff --git a/src/test/regress/expected/expressions.out b/src/test/regress/expected/expressions.out
index df432d4c927..2d5342ab281 100644
--- a/src/test/regress/expected/expressions.out
+++ b/src/test/regress/expected/expressions.out
@@ -86,7 +86,7 @@ WARNING:  TIMESTAMP(7) precision reduced to maximum allowed, 6
  t
 (1 row)
 
--- current_role/user/user is tested in rolnames.sql
+-- current_role/user/user is tested in rolenames.sql
 -- current database / catalog
 SELECT current_catalog = current_database();
  ?column? 
diff --git a/src/test/regress/sql/copy.sql b/src/test/regress/sql/copy.sql
index 285022e07c6..f9da7b1508f 100644
--- a/src/test/regress/sql/copy.sql
+++ b/src/test/regress/sql/copy.sql
@@ -204,7 +204,7 @@ create table header_copytest (
 	b int,
 	c text
 );
--- Make sure it works with with dropped columns
+-- Make sure it works with dropped columns
 alter table header_copytest drop column c;
 alter table header_copytest add column c text;
 copy header_copytest to stdout with (header match);
diff --git a/src/test/regress/sql/expressions.sql b/src/test/regress/sql/expressions.sql
index fea5358d252..d315ef5af50 100644
--- a/src/test/regress/sql/expressions.sql
+++ b/src/test/regress/sql/expressions.sql
@@ -29,7 +29,7 @@ SELECT current_timestamp = current_timestamp(7);
 SELECT localtime = localtime(7);
 SELECT localtimestamp = localtimestamp(7);
 
--- current_role/user/user is tested in rolnames.sql
+-- current_role/user/user is tested in rolenames.sql
 
 -- current database / catalog
 SELECT current_catalog = current_database();
diff --git a/src/test/ssl/t/SSL/Server.pm b/src/test/ssl/t/SSL/Server.pm
index 9520578e7d9..0a9e5da01e4 100644
--- a/src/test/ssl/t/SSL/Server.pm
+++ b/src/test/ssl/t/SSL/Server.pm
@@ -257,7 +257,7 @@ The certificate file to use. Implementation is SSL backend specific.
 
 =item keyfile => B<value>
 
-The private key to use. Implementation is SSL backend specific.
+The private key file to use. Implementation is SSL backend specific.
 
 =item crlfile => B<value>
 
-- 
2.25.1


--TBNym+cBXeFsS4Vs
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="0007-nondecimal.patch"



^ permalink  raw  reply  [nested|flat] 19+ messages in thread

* typos
@ 2022-12-30 23:12  Justin Pryzby <[email protected]>
  0 siblings, 0 replies; 19+ messages in thread

From: Justin Pryzby @ 2022-12-30 23:12 UTC (permalink / raw)
  To: [email protected]



^ permalink  raw  reply  [nested|flat] 19+ messages in thread

* [PATCH 6/9] typos
@ 2023-01-05 03:51  Justin Pryzby <[email protected]>
  0 siblings, 0 replies; 19+ messages in thread

From: Justin Pryzby @ 2023-01-05 03:51 UTC (permalink / raw)

misspell-fixer and codespell
---
 src/backend/access/transam/xlogrecovery.c                       | 2 +-
 src/bin/psql/common.c                                           | 2 +-
 .../expected/test_pg_db_role_setting.out                        | 2 +-
 .../test_pg_db_role_setting/sql/test_pg_db_role_setting.sql     | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index bc3c3eb3e79..5e657853066 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -2114,7 +2114,7 @@ CheckRecoveryConsistency(void)
 
 		/*
 		 * Check that pg_tblspc doesn't contain any real directories. Replay
-		 * of Database/CREATE_* records may have created ficticious tablespace
+		 * of Database/CREATE_* records may have created fictitious tablespace
 		 * directories that should have been removed by the time consistency
 		 * was reached.
 		 */
diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c
index 38f9b10b7c9..00627830c47 100644
--- a/src/bin/psql/common.c
+++ b/src/bin/psql/common.c
@@ -1447,7 +1447,7 @@ ExecQueryAndProcessResults(const char *query,
 		if (!AcceptResult(result, false))
 		{
 			/*
-			 * Some error occured, either a server-side failure or a failure
+			 * Some error occurred, either a server-side failure or a failure
 			 * to submit the command string.  Record that.
 			 */
 			const char *error = PQresultErrorMessage(result);
diff --git a/src/test/modules/test_pg_db_role_setting/expected/test_pg_db_role_setting.out b/src/test/modules/test_pg_db_role_setting/expected/test_pg_db_role_setting.out
index bee237cf40b..ec18692c558 100644
--- a/src/test/modules/test_pg_db_role_setting/expected/test_pg_db_role_setting.out
+++ b/src/test/modules/test_pg_db_role_setting/expected/test_pg_db_role_setting.out
@@ -122,7 +122,7 @@ SHOW test_pg_db_role_setting.user_param;
  bbb
 (1 row)
 
--- module is loaded, and placeholder values are succesfully set
+-- module is loaded, and placeholder values are successfully set
 SELECT load_test_pg_db_role_setting();
  load_test_pg_db_role_setting 
 ------------------------------
diff --git a/src/test/modules/test_pg_db_role_setting/sql/test_pg_db_role_setting.sql b/src/test/modules/test_pg_db_role_setting/sql/test_pg_db_role_setting.sql
index c6095dfa98c..44f231c6b4b 100644
--- a/src/test/modules/test_pg_db_role_setting/sql/test_pg_db_role_setting.sql
+++ b/src/test/modules/test_pg_db_role_setting/sql/test_pg_db_role_setting.sql
@@ -56,7 +56,7 @@ ALTER ROLE regress_regular_user SET test_pg_db_role_setting.superuser_param = 'c
 SHOW test_pg_db_role_setting.superuser_param;
 SHOW test_pg_db_role_setting.user_param;
 
--- module is loaded, and placeholder values are succesfully set
+-- module is loaded, and placeholder values are successfully set
 SELECT load_test_pg_db_role_setting();
 
 SHOW test_pg_db_role_setting.superuser_param;
-- 
2.25.1


--KFztAG8eRSV9hGtP
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="0007-f-typos-from-43620e328617c1f41a2a54c8cee01723064e3ff.patch"



^ permalink  raw  reply  [nested|flat] 19+ messages in thread

* [PATCH v29 09/11] Add support for min/max aggregates for IVM
@ 2023-05-31 11:58  Yugo Nagata <[email protected]>
  0 siblings, 0 replies; 19+ messages in thread

From: Yugo Nagata @ 2023-05-31 11:58 UTC (permalink / raw)

Supporting min and max is more complicated than count, sum, or avg.

For an example of min, when tuples are inserted, the current min value
in the view and the min value in the inseteted tuples are compared,
then the smaller one is used as the latest min value. On the other
hand, when tuples are deleted, if the current min value in the view
equals to the min in the deleted tuples, we need re-computation the
latest min value from base tables. Otherwise, the current value in
the view remains.
---
 src/backend/commands/createas.c |  45 +++
 src/backend/commands/matview.c  | 644 +++++++++++++++++++++++++++++++-
 2 files changed, 680 insertions(+), 9 deletions(-)

diff --git a/src/backend/commands/createas.c b/src/backend/commands/createas.c
index c8aa558f2e..c40ea6b2bc 100644
--- a/src/backend/commands/createas.c
+++ b/src/backend/commands/createas.c
@@ -1312,6 +1312,51 @@ check_aggregate_supports_ivm(Oid aggfnoid)
 		case F_AVG_FLOAT8:
 		case F_AVG_INTERVAL:
 
+		/* min */
+		case F_MIN_ANYARRAY:
+		case F_MIN_INT8:
+		case F_MIN_INT4:
+		case F_MIN_INT2:
+		case F_MIN_OID:
+		case F_MIN_FLOAT4:
+		case F_MIN_FLOAT8:
+		case F_MIN_DATE:
+		case F_MIN_TIME:
+		case F_MIN_TIMETZ:
+		case F_MIN_MONEY:
+		case F_MIN_TIMESTAMP:
+		case F_MIN_TIMESTAMPTZ:
+		case F_MIN_INTERVAL:
+		case F_MIN_TEXT:
+		case F_MIN_NUMERIC:
+		case F_MIN_BPCHAR:
+		case F_MIN_TID:
+		case F_MIN_ANYENUM:
+		case F_MIN_INET:
+		case F_MIN_PG_LSN:
+
+		/* max */
+		case F_MAX_ANYARRAY:
+		case F_MAX_INT8:
+		case F_MAX_INT4:
+		case F_MAX_INT2:
+		case F_MAX_OID:
+		case F_MAX_FLOAT4:
+		case F_MAX_FLOAT8:
+		case F_MAX_DATE:
+		case F_MAX_TIME:
+		case F_MAX_TIMETZ:
+		case F_MAX_MONEY:
+		case F_MAX_TIMESTAMP:
+		case F_MAX_TIMESTAMPTZ:
+		case F_MAX_INTERVAL:
+		case F_MAX_TEXT:
+		case F_MAX_NUMERIC:
+		case F_MAX_BPCHAR:
+		case F_MAX_TID:
+		case F_MAX_ANYENUM:
+		case F_MAX_INET:
+		case F_MAX_PG_LSN:
 			return true;
 
 		default:
diff --git a/src/backend/commands/matview.c b/src/backend/commands/matview.c
index ee41f0007d..eff512d40c 100644
--- a/src/backend/commands/matview.c
+++ b/src/backend/commands/matview.c
@@ -73,6 +73,34 @@ typedef struct
 
 #define MV_INIT_QUERYHASHSIZE	16
 
+/* MV query type codes */
+#define MV_PLAN_RECALC			1
+#define MV_PLAN_SET_VALUE		2
+
+/*
+ * MI_QueryKey
+ *
+ * The key identifying a prepared SPI plan in our query hashtable
+ */
+typedef struct MV_QueryKey
+{
+	Oid			matview_id;	/* OID of materialized view */
+	int32		query_type;	/* query type ID, see MV_PLAN_XXX above */
+} MV_QueryKey;
+
+/*
+ * MV_QueryHashEntry
+ *
+ * Hash entry for cached plans used to maintain materialized views.
+ */
+typedef struct MV_QueryHashEntry
+{
+	MV_QueryKey key;
+	SPIPlanPtr	plan;
+	SearchPathMatcher *search_path;        /* search_path used for parsing
+											 * and planning */
+} MV_QueryHashEntry;
+
 /*
  * MV_TriggerHashEntry
  *
@@ -109,6 +137,7 @@ typedef struct MV_TriggerTable
 	TupleTableSlot *slot;		/* for checking visibility in the pre-state table */
 } MV_TriggerTable;
 
+static HTAB *mv_query_cache = NULL;
 static HTAB *mv_trigger_info = NULL;
 
 static bool in_delta_calculation = false;
@@ -169,6 +198,9 @@ static void append_set_clause_for_sum(const char *resname, StringInfo buf_old,
 static void append_set_clause_for_avg(const char *resname, StringInfo buf_old,
 						  StringInfo buf_new, StringInfo aggs_list,
 						  const char *aggtype);
+static void append_set_clause_for_minmax(const char *resname, StringInfo buf_old,
+							 StringInfo buf_new, StringInfo aggs_list,
+							 bool is_min);
 static char *get_operation_string(IvmOp op, const char *col, const char *arg1, const char *arg2,
 					 const char* count_col, const char *castType);
 static char *get_null_condition_string(IvmOp op, const char *arg1, const char *arg2,
@@ -177,17 +209,30 @@ static void apply_old_delta(const char *matviewname, const char *deltaname_old,
 				List *keys);
 static void apply_old_delta_with_count(const char *matviewname, const char *deltaname_old,
 				List *keys, StringInfo aggs_list, StringInfo aggs_set,
-				const char *count_colname);
+				List *minmax_list, List *is_min_list,
+				const char *count_colname,
+				SPITupleTable **tuptable_recalc, uint64 *num_recalc);
 static void apply_new_delta(const char *matviewname, const char *deltaname_new,
 				StringInfo target_list);
 static void apply_new_delta_with_count(const char *matviewname, const char* deltaname_new,
 				List *keys, StringInfo target_list, StringInfo aggs_set,
 				const char* count_colname);
 static char *get_matching_condition_string(List *keys);
+static char *get_returning_string(List *minmax_list, List *is_min_list, List *keys);
+static char *get_minmax_recalc_condition_string(List *minmax_list, List *is_min_list);
+static char *get_select_for_recalc_string(List *keys);
+static void recalc_and_set_values(SPITupleTable *tuptable_recalc, int64 num_tuples,
+					  List *namelist, List *keys, Relation matviewRel);
+static SPIPlanPtr get_plan_for_recalc(Oid matviewOid, List *namelist, List *keys, Oid *keyTypes);
+static SPIPlanPtr get_plan_for_set_values(Oid matviewOid, char *matviewname, List *namelist,
+						Oid *valTypes);
 static void generate_equal(StringInfo querybuf, Oid opttype,
 			   const char *leftop, const char *rightop);
 
 static void mv_InitHashTables(void);
+static SPIPlanPtr mv_FetchPreparedPlan(MV_QueryKey *key);
+static void mv_HashPreparedPlan(MV_QueryKey *key, SPIPlanPtr plan);
+static void mv_BuildQueryKey(MV_QueryKey *key, Oid matview_id, int32 query_type);
 static void clean_up_IVM_hash_entry(MV_TriggerHashEntry *entry, bool is_abort);
 
 /*
@@ -2101,6 +2146,8 @@ apply_delta(Oid matviewOid, Tuplestorestate *old_tuplestores, Tuplestorestate *n
 	ListCell	*lc;
 	int			i;
 	List	   *keys = NIL;
+	List	   *minmax_list = NIL;
+	List	   *is_min_list = NIL;
 
 
 	/*
@@ -2182,6 +2229,17 @@ apply_delta(Oid matviewOid, Tuplestorestate *old_tuplestores, Tuplestorestate *n
 				append_set_clause_for_avg(resname, aggs_set_old, aggs_set_new, aggs_list_buf,
 										  format_type_be(aggref->aggtype));
 
+			/* min/max */
+			else if (!strcmp(aggname, "min") || !strcmp(aggname, "max"))
+			{
+				bool	is_min = (!strcmp(aggname, "min"));
+
+				append_set_clause_for_minmax(resname, aggs_set_old, aggs_set_new, aggs_list_buf, is_min);
+
+				/* make a resname list of min and max aggregates */
+				minmax_list = lappend(minmax_list, resname);
+				is_min_list = lappend_int(is_min_list, is_min);
+			}
 			else
 				elog(ERROR, "unsupported aggregate function: %s", aggname);
 		}
@@ -2211,6 +2269,8 @@ apply_delta(Oid matviewOid, Tuplestorestate *old_tuplestores, Tuplestorestate *n
 	if (old_tuplestores && tuplestore_tuple_count(old_tuplestores) > 0)
 	{
 		EphemeralNamedRelation enr = palloc(sizeof(EphemeralNamedRelationData));
+		SPITupleTable  *tuptable_recalc = NULL;
+		uint64			num_recalc;
 		int				rc;
 
 		/* convert tuplestores to ENR, and register for SPI */
@@ -2229,10 +2289,18 @@ apply_delta(Oid matviewOid, Tuplestorestate *old_tuplestores, Tuplestorestate *n
 			/* apply old delta and get rows to be recalculated */
 			apply_old_delta_with_count(matviewname, OLD_DELTA_ENRNAME,
 									   keys, aggs_list_buf, aggs_set_old,
-									   count_colname);
+									   minmax_list, is_min_list,
+									   count_colname, &tuptable_recalc, &num_recalc);
 		else
 			apply_old_delta(matviewname, OLD_DELTA_ENRNAME, keys);
 
+		/*
+		 * If we have min or max, we might have to recalculate aggregate values from base tables
+		 * on some tuples. TIDs and keys such tuples are returned as a result of the above query.
+		 */
+		if (minmax_list && tuptable_recalc)
+			recalc_and_set_values(tuptable_recalc, num_recalc, minmax_list, keys, matviewRel);
+
 	}
 	/* For tuple insertion */
 	if (new_tuplestores && tuplestore_tuple_count(new_tuplestores) > 0)
@@ -2424,6 +2492,70 @@ append_set_clause_for_avg(const char *resname, StringInfo buf_old,
 	);
 }
 
+/*
+ * append_set_clause_for_minmax
+ *
+ * Append SET clause string for min or max aggregation to given buffers.
+ * Also, append resnames required for calculating the aggregate value.
+ * is_min is true if this is min, false if not.
+ */
+static void
+append_set_clause_for_minmax(const char *resname, StringInfo buf_old,
+							 StringInfo buf_new, StringInfo aggs_list,
+							 bool is_min)
+{
+	char *count_col = IVM_colname("count", resname);
+
+	/* For tuple deletion */
+	if (buf_old)
+	{
+		/*
+		 * If the new value doesn't became NULL then use the value remaining
+		 * in the view although this will be recomputated afterwords.
+		 */
+		appendStringInfo(buf_old,
+			", %s = CASE WHEN %s THEN NULL ELSE %s END",
+			quote_qualified_identifier(NULL, resname),
+			get_null_condition_string(IVM_SUB, "mv", "t", count_col),
+			quote_qualified_identifier("mv", resname)
+		);
+		/* count = mv.count - t.count */
+		appendStringInfo(buf_old,
+			", %s = %s",
+			quote_qualified_identifier(NULL, count_col),
+			get_operation_string(IVM_SUB, count_col, "mv", "t", NULL, NULL)
+		);
+	}
+	/* For tuple insertion */
+	if (buf_new)
+	{
+		/*
+		 * min = LEAST(mv.min, diff.min)
+		 * max = GREATEST(mv.max, diff.max)
+		 */
+		appendStringInfo(buf_new,
+			", %s = CASE WHEN %s THEN NULL ELSE %s(%s,%s) END",
+			quote_qualified_identifier(NULL, resname),
+			get_null_condition_string(IVM_ADD, "mv", "diff", count_col),
+
+			is_min ? "LEAST" : "GREATEST",
+			quote_qualified_identifier("mv", resname),
+			quote_qualified_identifier("diff", resname)
+		);
+		/* count = mv.count + diff.count */
+		appendStringInfo(buf_new,
+			", %s = %s",
+			quote_qualified_identifier(NULL, count_col),
+			get_operation_string(IVM_ADD, count_col, "mv", "diff", NULL, NULL)
+		);
+	}
+
+	appendStringInfo(aggs_list, ", %s, %s",
+		quote_qualified_identifier("diff", resname),
+		quote_qualified_identifier("diff", IVM_colname("count", resname))
+	);
+}
+
 /*
  * get_operation_string
  *
@@ -2526,19 +2658,44 @@ get_null_condition_string(IvmOp op, const char *arg1, const char *arg2,
  * list to identify a tuple in the view. If the view has aggregates, this
  * requires strings representing resnames of aggregates and SET clause for
  * updating aggregate values.
+ *
+ * If the view has min or max aggregate, this requires a list of resnames of
+ * min/max aggregates and a list of boolean which represents which entries in
+ * minmax_list is min. These are necessary to check if we need to recalculate
+ * min or max aggregate values. In this case, this query returns TID and keys
+ * of tuples which need to be recalculated.  This result and the number of rows
+ * are stored in tuptables and num_recalc repectedly.
+ *
  */
 static void
 apply_old_delta_with_count(const char *matviewname, const char *deltaname_old,
 				List *keys, StringInfo aggs_list, StringInfo aggs_set,
-				const char *count_colname)
+				List *minmax_list, List *is_min_list,
+				const char *count_colname,
+				SPITupleTable **tuptable_recalc, uint64 *num_recalc)
 {
 	StringInfoData	querybuf;
 	char   *match_cond;
+	char   *updt_returning = "";
+	char   *select_for_recalc = "SELECT";
 	bool	agg_without_groupby = (list_length(keys) == 0);
 
+	Assert(tuptable_recalc != NULL);
+	Assert(num_recalc != NULL);
+
 	/* build WHERE condition for searching tuples to be deleted */
 	match_cond = get_matching_condition_string(keys);
 
+	/*
+	 * We need a special RETURNING clause and SELECT statement for min/max to
+	 * check which tuple needs re-calculation from base tables.
+	 */
+	if (minmax_list)
+	{
+		updt_returning = get_returning_string(minmax_list, is_min_list, keys);
+		select_for_recalc = get_select_for_recalc_string(keys);
+	}
+
 	/* Search for matching tuples from the view and update or delete if found. */
 	initStringInfo(&querybuf);
 	appendStringInfo(&querybuf,
@@ -2553,10 +2710,11 @@ apply_old_delta_with_count(const char *matviewname, const char *deltaname_old,
 						"UPDATE %s AS mv SET %s = mv.%s OPERATOR(pg_catalog.-) t.%s "
 											"%s"	/* SET clauses for aggregates */
 						"FROM t WHERE mv.ctid OPERATOR(pg_catalog.=) t.ctid AND NOT for_dlt "
-					")"
-					/* delete a tuple if this is to be deleted */
-					"DELETE FROM %s AS mv USING t "
-					"WHERE mv.ctid OPERATOR(pg_catalog.=) t.ctid AND for_dlt",
+						"%s"						/* RETURNING clause for recalc infomation */
+					"), dlt AS ("			/* delete a tuple if this is to be deleted */
+						"DELETE FROM %s AS mv USING t "
+						"WHERE mv.ctid OPERATOR(pg_catalog.=) t.ctid AND for_dlt"
+					") %s",							/* SELECT returning which tuples need to be recalculated */
 					count_colname,
 					count_colname, count_colname, (agg_without_groupby ? "false" : "true"),
 					(aggs_list != NULL ? aggs_list->data : ""),
@@ -2564,10 +2722,25 @@ apply_old_delta_with_count(const char *matviewname, const char *deltaname_old,
 					match_cond,
 					matviewname, count_colname, count_colname, count_colname,
 					(aggs_set != NULL ? aggs_set->data : ""),
-					matviewname);
+					updt_returning,
+					matviewname,
+					select_for_recalc);
 
-	if (SPI_exec(querybuf.data, 0) != SPI_OK_DELETE)
+	if (SPI_exec(querybuf.data, 0) != SPI_OK_SELECT)
 		elog(ERROR, "SPI_exec failed: %s", querybuf.data);
+
+
+	/* Return tuples to be recalculated. */
+	if (minmax_list)
+	{
+		*tuptable_recalc = SPI_tuptable;
+		*num_recalc = SPI_processed;
+	}
+	else
+	{
+		*tuptable_recalc = NULL;
+		*num_recalc = 0;
+	}
 }
 
 /*
@@ -2750,6 +2923,349 @@ get_matching_condition_string(List *keys)
 	return match_cond.data;
 }
 
+/*
+ * get_returning_string
+ *
+ * Build a string for RETURNING clause of UPDATE used in apply_old_delta_with_count.
+ * This clause returns ctid and a boolean value that indicates if we need to
+ * recalculate min or max value, for each updated row.
+ */
+static char *
+get_returning_string(List *minmax_list, List *is_min_list, List *keys)
+{
+	StringInfoData returning;
+	char		*recalc_cond;
+	ListCell	*lc;
+
+	Assert(minmax_list != NIL && is_min_list != NIL);
+	recalc_cond = get_minmax_recalc_condition_string(minmax_list, is_min_list);
+
+	initStringInfo(&returning);
+
+	appendStringInfo(&returning, "RETURNING mv.ctid AS tid, (%s) AS recalc", recalc_cond);
+	foreach (lc, keys)
+	{
+		Form_pg_attribute attr = (Form_pg_attribute) lfirst(lc);
+		char *resname = NameStr(attr->attname);
+		appendStringInfo(&returning, ", %s", quote_qualified_identifier("mv", resname));
+	}
+
+	return returning.data;
+}
+
+/*
+ * get_minmax_recalc_condition_string
+ *
+ * Build a predicate string for checking if any min/max aggregate
+ * value needs to be recalculated.
+ */
+static char *
+get_minmax_recalc_condition_string(List *minmax_list, List *is_min_list)
+{
+	StringInfoData recalc_cond;
+	ListCell	*lc1, *lc2;
+
+	initStringInfo(&recalc_cond);
+
+	Assert (list_length(minmax_list) == list_length(is_min_list));
+
+	forboth (lc1, minmax_list, lc2, is_min_list)
+	{
+		char   *resname = (char *) lfirst(lc1);
+		bool	is_min = (bool) lfirst_int(lc2);
+		char   *op_str = (is_min ? ">=" : "<=");
+
+		appendStringInfo(&recalc_cond, "%s OPERATOR(pg_catalog.%s) %s",
+			quote_qualified_identifier("mv", resname),
+			op_str,
+			quote_qualified_identifier("t", resname)
+		);
+
+		if (lnext(minmax_list, lc1))
+			appendStringInfo(&recalc_cond, " OR ");
+	}
+
+	return recalc_cond.data;
+}
+
+/*
+ * get_select_for_recalc_string
+ *
+ * Build a query to return tid and keys of tuples which need
+ * recalculation. This is used as the result of the query
+ * built by apply_old_delta.
+ */
+static char *
+get_select_for_recalc_string(List *keys)
+{
+	StringInfoData qry;
+	ListCell	*lc;
+
+	initStringInfo(&qry);
+
+	appendStringInfo(&qry, "SELECT tid");
+	foreach (lc, keys)
+	{
+		Form_pg_attribute attr = (Form_pg_attribute) lfirst(lc);
+		appendStringInfo(&qry, ", %s", NameStr(attr->attname));
+	}
+
+	appendStringInfo(&qry, " FROM updt WHERE recalc");
+
+	return qry.data;
+}
+
+/*
+ * recalc_and_set_values
+ *
+ * Recalculate tuples in a materialized from base tables and update these.
+ * The tuples which needs recalculation are specified by keys, and resnames
+ * of columns to be updated are specified by namelist. TIDs and key values
+ * are given by tuples in tuptable_recalc. Its first attribute must be TID
+ * and key values must be following this.
+ */
+static void
+recalc_and_set_values(SPITupleTable *tuptable_recalc, int64 num_tuples,
+					  List *namelist, List *keys, Relation matviewRel)
+{
+	TupleDesc   tupdesc_recalc = tuptable_recalc->tupdesc;
+	Oid		   *keyTypes = NULL, *types = NULL;
+	char	   *keyNulls = NULL, *nulls = NULL;
+	Datum	   *keyVals = NULL, *vals = NULL;
+	int			num_vals = list_length(namelist);
+	int			num_keys = list_length(keys);
+	uint64      i;
+	Oid			matviewOid;
+	char	   *matviewname;
+
+	matviewOid = RelationGetRelid(matviewRel);
+	matviewname = quote_qualified_identifier(get_namespace_name(RelationGetNamespace(matviewRel)),
+											 RelationGetRelationName(matviewRel));
+
+	/* If we have keys, initialize arrays for them. */
+	if (keys)
+	{
+		keyTypes = palloc(sizeof(Oid) * num_keys);
+		keyNulls = palloc(sizeof(char) * num_keys);
+		keyVals = palloc(sizeof(Datum) * num_keys);
+		/* a tuple contains keys to be recalculated and ctid to be updated*/
+		Assert(tupdesc_recalc->natts == num_keys + 1);
+
+		/* Types of key attributes  */
+		for (i = 0; i < num_keys; i++)
+			keyTypes[i] = TupleDescAttr(tupdesc_recalc, i + 1)->atttypid;
+	}
+
+	/* allocate memory for all attribute names and tid */
+	types = palloc(sizeof(Oid) * (num_vals + 1));
+	nulls = palloc(sizeof(char) * (num_vals + 1));
+	vals = palloc(sizeof(Datum) * (num_vals + 1));
+
+	/* For each tuple which needs recalculation */
+	for (i = 0; i < num_tuples; i++)
+	{
+		int j;
+		bool isnull;
+		SPIPlanPtr plan;
+		SPITupleTable *tuptable_newvals;
+		TupleDesc   tupdesc_newvals;
+
+		/* Set group key values as parameters if needed. */
+		if (keys)
+		{
+			for (j = 0; j < num_keys; j++)
+			{
+				keyVals[j] = SPI_getbinval(tuptable_recalc->vals[i], tupdesc_recalc, j + 2, &isnull);
+				if (isnull)
+					keyNulls[j] = 'n';
+				else
+					keyNulls[j] = ' ';
+			}
+		}
+
+		/*
+		 * Get recalculated values from base tables. The result must be
+		 * only one tuple thich contains the new values for specified keys.
+		 */
+		plan = get_plan_for_recalc(matviewOid, namelist, keys, keyTypes);
+		if (SPI_execute_plan(plan, keyVals, keyNulls, false, 0) != SPI_OK_SELECT)
+			elog(ERROR, "SPI_execute_plan");
+		if (SPI_processed != 1)
+			elog(ERROR, "SPI_execute_plan returned zero or more than one rows");
+
+		tuptable_newvals = SPI_tuptable;
+		tupdesc_newvals = tuptable_newvals->tupdesc;
+
+		Assert(tupdesc_newvals->natts == num_vals);
+
+		/* Set the new values as parameters */
+		for (j = 0; j < tupdesc_newvals->natts; j++)
+		{
+			if (i == 0)
+				types[j] = TupleDescAttr(tupdesc_newvals, j)->atttypid;
+
+			vals[j] = SPI_getbinval(tuptable_newvals->vals[0], tupdesc_newvals, j + 1, &isnull);
+			if (isnull)
+				nulls[j] = 'n';
+			else
+				nulls[j] = ' ';
+		}
+		/* Set TID of the view tuple to be updated as a parameter */
+		types[j] = TIDOID;
+		vals[j] = SPI_getbinval(tuptable_recalc->vals[i], tupdesc_recalc, 1, &isnull);
+		nulls[j] = ' ';
+
+		/* Update the view tuple to the new values */
+		plan = get_plan_for_set_values(matviewOid, matviewname, namelist, types);
+		if (SPI_execute_plan(plan, vals, nulls, false, 0) != SPI_OK_UPDATE)
+			elog(ERROR, "SPI_execute_plan");
+	}
+}
+
+
+/*
+ * get_plan_for_recalc
+ *
+ * Create or fetch a plan for recalculating value in the view's target list
+ * from base tables using the definition query of materialized view specified
+ * by matviewOid. namelist is a list of resnames of values to be recalculated.
+ *
+ * keys is a list of keys to identify tuples to be recalculated if this is not
+ * empty. KeyTypes is an array of types of keys.
+ */
+static SPIPlanPtr
+get_plan_for_recalc(Oid matviewOid, List *namelist, List *keys, Oid *keyTypes)
+{
+	MV_QueryKey hash_key;
+	SPIPlanPtr	plan;
+
+	/* Fetch or prepare a saved plan for the recalculation */
+	mv_BuildQueryKey(&hash_key, matviewOid, MV_PLAN_RECALC);
+	if ((plan = mv_FetchPreparedPlan(&hash_key)) == NULL)
+	{
+		ListCell	   *lc;
+		StringInfoData	str;
+		char   *viewdef;
+
+		/* get view definition of matview */
+		viewdef = text_to_cstring((text *) DatumGetPointer(
+					DirectFunctionCall1(pg_get_viewdef, ObjectIdGetDatum(matviewOid))));
+		/* get rid of trailing semi-colon */
+		viewdef[strlen(viewdef)-1] = '\0';
+
+		/*
+		 * Build a query string for recalculating values. This is like
+		 *
+		 *  SELECT x1, x2, x3, ... FROM ( ... view definition query ...) mv
+		 *   WHERE (key1, key2, ...) = ($1, $2, ...);
+		 */
+
+		initStringInfo(&str);
+		appendStringInfo(&str, "SELECT ");
+		foreach (lc, namelist)
+		{
+			appendStringInfo(&str, "%s", (char *) lfirst(lc));
+			if (lnext(namelist, lc))
+				appendStringInfoString(&str, ", ");
+		}
+		appendStringInfo(&str, " FROM (%s) mv", viewdef);
+
+		if (keys)
+		{
+			int		i = 1;
+			char	paramname[16];
+
+			appendStringInfo(&str, " WHERE (");
+			foreach (lc, keys)
+			{
+				Form_pg_attribute attr = (Form_pg_attribute) lfirst(lc);
+				char   *resname = NameStr(attr->attname);
+				Oid		typid = attr->atttypid;
+
+				sprintf(paramname, "$%d", i);
+				appendStringInfo(&str, "(");
+				generate_equal(&str, typid, resname, paramname);
+				appendStringInfo(&str, " OR (%s IS NULL AND %s IS NULL))",
+								 resname, paramname);
+
+				if (lnext(keys, lc))
+					appendStringInfoString(&str, " AND ");
+				i++;
+			}
+			appendStringInfo(&str, ")");
+		}
+		else
+			keyTypes = NULL;
+
+		plan = SPI_prepare(str.data, list_length(keys), keyTypes);
+		if (plan == NULL)
+			elog(ERROR, "SPI_prepare returned %s for %s", SPI_result_code_string(SPI_result), str.data);
+
+		SPI_keepplan(plan);
+		mv_HashPreparedPlan(&hash_key, plan);
+	}
+
+	return plan;
+}
+
+/*
+ * get_plan_for_set_values
+ *
+ * Create or fetch a plan for applying new values calculated by
+ * get_plan_for_recalc to a materialized view specified by matviewOid.
+ * matviewname is the name of the view.  namelist is a list of resnames
+ * of attributes to be updated, and valTypes is an array of types of the
+ * values.
+ */
+static SPIPlanPtr
+get_plan_for_set_values(Oid matviewOid, char *matviewname, List *namelist,
+						Oid *valTypes)
+{
+	MV_QueryKey	key;
+	SPIPlanPtr	plan;
+
+	/* Fetch or prepare a saved plan for the real check */
+	mv_BuildQueryKey(&key, matviewOid, MV_PLAN_SET_VALUE);
+	if ((plan = mv_FetchPreparedPlan(&key)) == NULL)
+	{
+		ListCell	  *lc;
+		StringInfoData str;
+		int		i;
+
+		/*
+		 * Build a query string for applying min/max values. This is like
+		 *
+		 *  UPDATE matviewname AS mv
+		 *   SET (x1, x2, x3, x4) = ($1, $2, $3, $4)
+		 *   WHERE ctid = $5;
+		 */
+
+		initStringInfo(&str);
+		appendStringInfo(&str, "UPDATE %s AS mv SET (", matviewname);
+		foreach (lc, namelist)
+		{
+			appendStringInfo(&str, "%s", (char *) lfirst(lc));
+			if (lnext(namelist, lc))
+				appendStringInfoString(&str, ", ");
+		}
+		appendStringInfo(&str, ") = ROW(");
+
+		for (i = 1; i <= list_length(namelist); i++)
+			appendStringInfo(&str, "%s$%d", (i==1 ? "" : ", "), i);
+
+		appendStringInfo(&str, ") WHERE ctid OPERATOR(pg_catalog.=) $%d", i);
+
+		plan = SPI_prepare(str.data, list_length(namelist) + 1, valTypes);
+		if (plan == NULL)
+			elog(ERROR, "SPI_prepare returned %s for %s", SPI_result_code_string(SPI_result), str.data);
+
+		SPI_keepplan(plan);
+		mv_HashPreparedPlan(&key, plan);
+	}
+
+	return plan;
+}
+
 /*
  * generate_equals
  *
@@ -2783,6 +3299,13 @@ mv_InitHashTables(void)
 {
 	HASHCTL		ctl;
 
+	memset(&ctl, 0, sizeof(ctl));
+	ctl.keysize = sizeof(MV_QueryKey);
+	ctl.entrysize = sizeof(MV_QueryHashEntry);
+	mv_query_cache = hash_create("MV query cache",
+								 MV_INIT_QUERYHASHSIZE,
+								 &ctl, HASH_ELEM | HASH_BLOBS);
+
 	memset(&ctl, 0, sizeof(ctl));
 	ctl.keysize = sizeof(Oid);
 	ctl.entrysize = sizeof(MV_TriggerHashEntry);
@@ -2791,6 +3314,109 @@ mv_InitHashTables(void)
 								 &ctl, HASH_ELEM | HASH_BLOBS);
 }
 
+/*
+ * mv_FetchPreparedPlan
+ */
+static SPIPlanPtr
+mv_FetchPreparedPlan(MV_QueryKey *key)
+{
+	MV_QueryHashEntry *entry;
+	SPIPlanPtr	plan;
+
+	/*
+	 * On the first call initialize the hashtable
+	 */
+	if (!mv_query_cache)
+		mv_InitHashTables();
+
+	/*
+	 * Lookup for the key
+	 */
+	entry = (MV_QueryHashEntry *) hash_search(mv_query_cache,
+											  (void *) key,
+											  HASH_FIND, NULL);
+	if (entry == NULL)
+		return NULL;
+
+	/*
+	 * Check whether the plan is still valid.  If it isn't, we don't want to
+	 * simply rely on plancache.c to regenerate it; rather we should start
+	 * from scratch and rebuild the query text too.  This is to cover cases
+	 * such as table/column renames.  We depend on the plancache machinery to
+	 * detect possible invalidations, though.
+	 *
+	 * CAUTION: this check is only trustworthy if the caller has already
+	 * locked both materialized views and base tables.
+	 *
+	 * Also, check whether the search_path is still the same as when we made it.
+	 * If it isn't, we need to rebuild the query text because the result of
+	 * pg_ivm_get_viewdef() will change.
+	 */
+	plan = entry->plan;
+	if (plan && SPI_plan_is_valid(plan) &&
+		SearchPathMatchesCurrentEnvironment(entry->search_path))
+		return plan;
+
+	/*
+	 * Otherwise we might as well flush the cached plan now, to free a little
+	 * memory space before we make a new one.
+	 */
+	if (plan)
+		SPI_freeplan(plan);
+	if (entry->search_path)
+		pfree(entry->search_path);
+
+	entry->plan = NULL;
+	entry->search_path = NULL;
+
+	return NULL;
+}
+
+/*
+ * mv_HashPreparedPlan
+ *
+ * Add another plan to our private SPI query plan hashtable.
+ */
+static void
+mv_HashPreparedPlan(MV_QueryKey *key, SPIPlanPtr plan)
+{
+	MV_QueryHashEntry *entry;
+	bool		found;
+
+	/*
+	 * On the first call initialize the hashtable
+	 */
+	if (!mv_query_cache)
+		mv_InitHashTables();
+
+	/*
+	 * Add the new plan.  We might be overwriting an entry previously found
+	 * invalid by mv_FetchPreparedPlan.
+	 */
+	entry = (MV_QueryHashEntry *) hash_search(mv_query_cache,
+											  (void *) key,
+											  HASH_ENTER, &found);
+	Assert(!found || entry->plan == NULL);
+	entry->plan = plan;
+	entry->search_path = GetSearchPathMatcher(TopMemoryContext);
+}
+
+/*
+ * mv_BuildQueryKey
+ *
+ * Construct a hashtable key for a prepared SPI plan for IVM.
+ */
+static void
+mv_BuildQueryKey(MV_QueryKey *key, Oid matview_id, int32 query_type)
+{
+	/*
+	 * We assume struct MV_QueryKey contains no padding bytes, else we'd need
+	 * to use memset to clear them.
+	 */
+	key->matview_id = matview_id;
+	key->query_type = query_type;
+}
+
 /*
  * AtAbort_IVM
  *
-- 
2.25.1


--Multipart=_Mon__28_Aug_2023_16_05_30_+0900_b1OvQD_3A3ZMTGvj
Content-Type: text/x-diff;
 name="v29-0010-Add-regression-tests-for-Incremental-View-Mainte.patch"
Content-Disposition: attachment;
 filename="v29-0010-Add-regression-tests-for-Incremental-View-Mainte.patch"
Content-Transfer-Encoding: 7bit



^ permalink  raw  reply  [nested|flat] 19+ messages in thread


end of thread, other threads:[~2023-05-31 11:58 UTC | newest]

Thread overview: 19+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-03-30 05:34 Typos Fujii Masao <[email protected]>
2011-03-30 05:59 ` Heikki Linnakangas <[email protected]>
2014-03-24 06:40 typos Erik Rijkers <[email protected]>
2014-03-24 06:42 ` Re: typos Heikki Linnakangas <[email protected]>
2020-11-28 22:58 [PATCH 3/4] typos Justin Pryzby <[email protected]>
2021-09-24 21:58 typos Justin Pryzby <[email protected]>
2022-04-13 20:56 Re: typos David Rowley <[email protected]>
2022-07-05 07:51 ` Re: typos Noah Misch <[email protected]>
2022-04-21 04:36 ` Re: typos Michael Paquier <[email protected]>
2022-05-11 02:03 ` Re: typos Justin Pryzby <[email protected]>
2022-05-11 06:41   ` Re: typos Michael Paquier <[email protected]>
2022-05-11 00:02 [PATCH v2022051001 2/2] typos Justin Pryzby <[email protected]>
2022-05-11 00:02 [PATCH v2022051001 2/2] typos Justin Pryzby <[email protected]>
2022-07-05 19:12 [PATCH 1/4] typos Justin Pryzby <[email protected]>
2022-09-25 23:40 [PATCH 1/9] typos Justin Pryzby <[email protected]>
2022-09-25 23:40 [PATCH 06/16] typos Justin Pryzby <[email protected]>
2022-12-30 23:12 typos Justin Pryzby <[email protected]>
2023-01-05 03:51 [PATCH 6/9] typos Justin Pryzby <[email protected]>
2023-05-31 11:58 [PATCH v29 09/11] Add support for min/max aggregates for IVM 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