Skip to content

Commit 61f1fc6

Browse files
authored
Merge branch 'postgres:master' into master
2 parents 572b2d7 + 9e54059 commit 61f1fc6

File tree

154 files changed

+2240
-2935
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+2240
-2935
lines changed

contrib/bloom/t/001_wal.pl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@
88
use PostgreSQL::Test::Utils;
99
use Test::More;
1010

11-
if (PostgreSQL::Test::Utils::has_wal_read_bug)
12-
{
13-
# We'd prefer to use Test::More->builder->todo_start, but the bug causes
14-
# this test file to die(), not merely to fail.
15-
plan skip_all => 'filesystem bug';
16-
}
17-
1811
my $node_primary;
1912
my $node_standby;
2013

contrib/dblink/dblink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2838,7 +2838,7 @@ get_connect_string(const char *servername)
28382838
fdw = GetForeignDataWrapper(fdwid);
28392839

28402840
/* Check permissions, user must have usage on the server. */
2841-
aclresult = pg_foreign_server_aclcheck(serverid, userid, ACL_USAGE);
2841+
aclresult = object_aclcheck(ForeignServerRelationId, serverid, userid, ACL_USAGE);
28422842
if (aclresult != ACLCHECK_OK)
28432843
aclcheck_error(aclresult, OBJECT_FOREIGN_SERVER, foreign_server->servername);
28442844

contrib/pg_surgery/heap_surgery.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ heap_force_common(FunctionCallInfo fcinfo, HeapTupleForceOption heap_force_opt)
118118
errmsg("only heap AM is supported")));
119119

120120
/* Must be owner of the table or superuser. */
121-
if (!pg_class_ownercheck(RelationGetRelid(rel), GetUserId()))
121+
if (!object_ownercheck(RelationRelationId, RelationGetRelid(rel), GetUserId()))
122122
aclcheck_error(ACLCHECK_NOT_OWNER,
123123
get_relkind_objtype(rel->rd_rel->relkind),
124124
RelationGetRelationName(rel));

doc/src/sgml/config.sgml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3597,9 +3597,11 @@ include_dir 'conf.d'
35973597
</para>
35983598
<para>
35993599
This parameter can only be set in the <filename>postgresql.conf</filename>
3600-
file or on the server command line. It is ignored unless
3600+
file or on the server command line. It is only used if
36013601
<varname>archive_mode</varname> was enabled at server start and
3602-
<varname>archive_library</varname> is set to an empty string.
3602+
<varname>archive_library</varname> is set to an empty string. If both
3603+
<varname>archive_command</varname> and <varname>archive_library</varname>
3604+
are set, an error will be raised.
36033605
If <varname>archive_command</varname> is an empty string (the default) while
36043606
<varname>archive_mode</varname> is enabled (and <varname>archive_library</varname>
36053607
is set to an empty string), WAL archiving is temporarily
@@ -3624,7 +3626,9 @@ include_dir 'conf.d'
36243626
<para>
36253627
The library to use for archiving completed WAL file segments. If set to
36263628
an empty string (the default), archiving via shell is enabled, and
3627-
<xref linkend="guc-archive-command"/> is used. Otherwise, the specified
3629+
<xref linkend="guc-archive-command"/> is used. If both
3630+
<varname>archive_command</varname> and <varname>archive_library</varname>
3631+
are set, an error will be raised. Otherwise, the specified
36283632
shared library is used for archiving. The WAL archiver process is
36293633
restarted by the postmaster when this parameter changes. For more
36303634
information, see <xref linkend="backup-archiving-wal"/> and

doc/src/sgml/plpgsql.sgml

Lines changed: 28 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4032,129 +4032,120 @@ ASSERT <replaceable class="parameter">condition</replaceable> <optional> , <repl
40324032

40334033
<variablelist>
40344034
<varlistentry>
4035-
<term><varname>NEW</varname></term>
4035+
<term><varname>NEW</varname> <type>record</type></term>
40364036
<listitem>
40374037
<para>
4038-
Data type <type>RECORD</type>; variable holding the new
4039-
database row for <command>INSERT</command>/<command>UPDATE</command> operations in row-level
4038+
new database row for <command>INSERT</command>/<command>UPDATE</command> operations in row-level
40404039
triggers. This variable is null in statement-level triggers
40414040
and for <command>DELETE</command> operations.
40424041
</para>
40434042
</listitem>
40444043
</varlistentry>
40454044

40464045
<varlistentry>
4047-
<term><varname>OLD</varname></term>
4046+
<term><varname>OLD</varname> <type>record</type></term>
40484047
<listitem>
40494048
<para>
4050-
Data type <type>RECORD</type>; variable holding the old
4051-
database row for <command>UPDATE</command>/<command>DELETE</command> operations in row-level
4049+
old database row for <command>UPDATE</command>/<command>DELETE</command> operations in row-level
40524050
triggers. This variable is null in statement-level triggers
40534051
and for <command>INSERT</command> operations.
40544052
</para>
40554053
</listitem>
40564054
</varlistentry>
40574055

40584056
<varlistentry>
4059-
<term><varname>TG_NAME</varname></term>
4057+
<term><varname>TG_NAME</varname> <type>name</type></term>
40604058
<listitem>
40614059
<para>
4062-
Data type <type>name</type>; variable that contains the name of the trigger actually
4063-
fired.
4060+
name of the trigger which fired.
40644061
</para>
40654062
</listitem>
40664063
</varlistentry>
40674064

40684065
<varlistentry>
4069-
<term><varname>TG_WHEN</varname></term>
4066+
<term><varname>TG_WHEN</varname> <type>text</type></term>
40704067
<listitem>
40714068
<para>
4072-
Data type <type>text</type>; a string of
40734069
<literal>BEFORE</literal>, <literal>AFTER</literal>, or
40744070
<literal>INSTEAD OF</literal>, depending on the trigger's definition.
40754071
</para>
40764072
</listitem>
40774073
</varlistentry>
40784074

40794075
<varlistentry>
4080-
<term><varname>TG_LEVEL</varname></term>
4076+
<term><varname>TG_LEVEL</varname> <type>text</type></term>
40814077
<listitem>
40824078
<para>
4083-
Data type <type>text</type>; a string of either
4084-
<literal>ROW</literal> or <literal>STATEMENT</literal>
4079+
<literal>ROW</literal> or <literal>STATEMENT</literal>,
40854080
depending on the trigger's definition.
40864081
</para>
40874082
</listitem>
40884083
</varlistentry>
40894084

40904085
<varlistentry>
4091-
<term><varname>TG_OP</varname></term>
4086+
<term><varname>TG_OP</varname> <type>text</type></term>
40924087
<listitem>
40934088
<para>
4094-
Data type <type>text</type>; a string of
4089+
operation for which the trigger was fired:
40954090
<literal>INSERT</literal>, <literal>UPDATE</literal>,
4096-
<literal>DELETE</literal>, or <literal>TRUNCATE</literal>
4097-
telling for which operation the trigger was fired.
4091+
<literal>DELETE</literal>, or <literal>TRUNCATE</literal>.
40984092
</para>
40994093
</listitem>
41004094
</varlistentry>
41014095

41024096
<varlistentry>
4103-
<term><varname>TG_RELID</varname></term>
4097+
<term><varname>TG_RELID</varname> <type>oid</type> (references <link linkend="catalog-pg-class"><structname>pg_class</structname></link>.<structfield>oid</structfield>)</term>
41044098
<listitem>
41054099
<para>
4106-
Data type <type>oid</type>; the object ID of the table that caused the
4107-
trigger invocation.
4100+
object ID of the table that caused the trigger invocation.
41084101
</para>
41094102
</listitem>
41104103
</varlistentry>
41114104

41124105
<varlistentry>
4113-
<term><varname>TG_RELNAME</varname></term>
4106+
<term><varname>TG_RELNAME</varname> <type>name</type></term>
41144107
<listitem>
41154108
<para>
4116-
Data type <type>name</type>; the name of the table that caused the trigger
4109+
table that caused the trigger
41174110
invocation. This is now deprecated, and could disappear in a future
41184111
release. Use <literal>TG_TABLE_NAME</literal> instead.
41194112
</para>
41204113
</listitem>
41214114
</varlistentry>
41224115

41234116
<varlistentry>
4124-
<term><varname>TG_TABLE_NAME</varname></term>
4117+
<term><varname>TG_TABLE_NAME</varname> <type>name</type></term>
41254118
<listitem>
41264119
<para>
4127-
Data type <type>name</type>; the name of the table that
4128-
caused the trigger invocation.
4120+
table that caused the trigger invocation.
41294121
</para>
41304122
</listitem>
41314123
</varlistentry>
41324124

41334125
<varlistentry>
4134-
<term><varname>TG_TABLE_SCHEMA</varname></term>
4126+
<term><varname>TG_TABLE_SCHEMA</varname> <type>name</type></term>
41354127
<listitem>
41364128
<para>
4137-
Data type <type>name</type>; the name of the schema of the
4138-
table that caused the trigger invocation.
4129+
schema of the table that caused the trigger invocation.
41394130
</para>
41404131
</listitem>
41414132
</varlistentry>
41424133

41434134
<varlistentry>
4144-
<term><varname>TG_NARGS</varname></term>
4135+
<term><varname>TG_NARGS</varname> <type>integer</type></term>
41454136
<listitem>
41464137
<para>
4147-
Data type <type>integer</type>; the number of arguments given to the trigger
4138+
number of arguments given to the trigger
41484139
function in the <command>CREATE TRIGGER</command> statement.
41494140
</para>
41504141
</listitem>
41514142
</varlistentry>
41524143

41534144
<varlistentry>
4154-
<term><varname>TG_ARGV[]</varname></term>
4145+
<term><varname>TG_ARGV</varname> <type>text[]</type></term>
41554146
<listitem>
41564147
<para>
4157-
Data type array of <type>text</type>; the arguments from
4148+
arguments from
41584149
the <command>CREATE TRIGGER</command> statement.
41594150
The index counts from 0. Invalid
41604151
indexes (less than 0 or greater than or equal to <varname>tg_nargs</varname>)
@@ -4656,21 +4647,19 @@ CREATE TRIGGER emp_audit_del
46564647

46574648
<variablelist>
46584649
<varlistentry>
4659-
<term><varname>TG_EVENT</varname></term>
4650+
<term><varname>TG_EVENT</varname> <type>text</type></term>
46604651
<listitem>
46614652
<para>
4662-
Data type <type>text</type>; a string representing the event the
4663-
trigger is fired for.
4653+
event the trigger is fired for.
46644654
</para>
46654655
</listitem>
46664656
</varlistentry>
46674657

46684658
<varlistentry>
4669-
<term><varname>TG_TAG</varname></term>
4659+
<term><varname>TG_TAG</varname> <type>text</type></term>
46704660
<listitem>
46714661
<para>
4672-
Data type <type>text</type>; variable that contains the command tag
4673-
for which the trigger is fired.
4662+
command tag for which the trigger is fired.
46744663
</para>
46754664
</listitem>
46764665
</varlistentry>

doc/src/sgml/query.sgml

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -706,40 +706,39 @@ SELECT city FROM weather
706706
<indexterm><primary>HAVING</primary></indexterm>
707707

708708
Aggregates are also very useful in combination with <literal>GROUP
709-
BY</literal> clauses. For example, we can get the maximum low
710-
temperature observed in each city with:
709+
BY</literal> clauses. For example, we can get the number of readings
710+
and the maximum low temperature observed in each city with:
711711

712712
<programlisting>
713-
SELECT city, max(temp_lo)
713+
SELECT city, count(*), max(temp_lo)
714714
FROM weather
715715
GROUP BY city;
716716
</programlisting>
717717

718718
<screen>
719-
city | max
720-
---------------+-----
721-
Hayward | 37
722-
San Francisco | 46
719+
city | count | max
720+
---------------+-------+-----
721+
Hayward | 1 | 37
722+
San Francisco | 2 | 46
723723
(2 rows)
724724
</screen>
725725

726726
which gives us one output row per city. Each aggregate result is
727727
computed over the table rows matching that city.
728728
We can filter these grouped
729-
rows using <literal>HAVING</literal> and the output count using
730-
<literal>FILTER</literal>:
729+
rows using <literal>HAVING</literal>:
731730

732731
<programlisting>
733-
SELECT city, max(temp_lo), count(*) FILTER (WHERE temp_lo &lt; 30)
732+
SELECT city, count(*), max(temp_lo)
734733
FROM weather
735734
GROUP BY city
736735
HAVING max(temp_lo) &lt; 40;
737736
</programlisting>
738737

739738
<screen>
740-
city | max | count
741-
---------+-----+-------
742-
Hayward | 37 | 5
739+
city | count | max
740+
---------+-------+-----
741+
Hayward | 1 | 37
743742
(1 row)
744743
</screen>
745744

@@ -749,12 +748,18 @@ SELECT city, max(temp_lo), count(*) FILTER (WHERE temp_lo &lt; 30)
749748
names begin with <quote><literal>S</literal></quote>, we might do:
750749

751750
<programlisting>
752-
SELECT city, max(temp_lo), count(*) FILTER (WHERE temp_lo &lt; 30)
751+
SELECT city, count(*), max(temp_lo)
753752
FROM weather
754753
WHERE city LIKE 'S%' -- <co id="co.tutorial-agg-like"/>
755-
GROUP BY city
756-
HAVING max(temp_lo) &lt; 40;
754+
GROUP BY city;
757755
</programlisting>
756+
757+
<screen>
758+
city | count | max
759+
---------------+-------+-----
760+
San Francisco | 2 | 46
761+
(1 row)
762+
</screen>
758763
<calloutlist>
759764
<callout arearefs="co.tutorial-agg-like">
760765
<para>
@@ -791,6 +796,34 @@ SELECT city, max(temp_lo), count(*) FILTER (WHERE temp_lo &lt; 30)
791796
because we avoid doing the grouping and aggregate calculations
792797
for all rows that fail the <literal>WHERE</literal> check.
793798
</para>
799+
800+
<para>
801+
Another way to select the rows that go into an aggregate
802+
computation is to use <literal>FILTER</literal>, which is a
803+
per-aggregate option:
804+
805+
<programlisting>
806+
SELECT city, count(*) FILTER (WHERE temp_lo &lt; 45), max(temp_lo)
807+
FROM weather
808+
GROUP BY city;
809+
</programlisting>
810+
811+
<screen>
812+
city | count | max
813+
---------------+-------+-----
814+
Hayward | 1 | 37
815+
San Francisco | 1 | 46
816+
(2 rows)
817+
</screen>
818+
819+
<literal>FILTER</literal> is much like <literal>WHERE</literal>,
820+
except that it removes rows only from the input of the particular
821+
aggregate function that it is attached to.
822+
Here, the <literal>count</literal> aggregate counts only
823+
rows with <literal>temp_lo</literal> below 45; but the
824+
<literal>max</literal> aggregate is still applied to all rows,
825+
so it still finds the reading of 46.
826+
</para>
794827
</sect1>
795828

796829

doc/src/sgml/ref/alter_foreign_table.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ ALTER FOREIGN TABLE [ IF EXISTS ] <replaceable class="parameter">name</replaceab
4141
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> SET STATISTICS <replaceable class="parameter">integer</replaceable>
4242
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> SET ( <replaceable class="parameter">attribute_option</replaceable> = <replaceable class="parameter">value</replaceable> [, ... ] )
4343
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> RESET ( <replaceable class="parameter">attribute_option</replaceable> [, ... ] )
44-
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN }
44+
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN | DEFAULT }
4545
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> OPTIONS ( [ ADD | SET | DROP ] <replaceable class="parameter">option</replaceable> ['<replaceable class="parameter">value</replaceable>'] [, ... ])
4646
ADD <replaceable class="parameter">table_constraint</replaceable> [ NOT VALID ]
4747
VALIDATE CONSTRAINT <replaceable class="parameter">constraint_name</replaceable>

doc/src/sgml/ref/alter_materialized_view.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ ALTER MATERIALIZED VIEW ALL IN TABLESPACE <replaceable class="parameter">name</r
3939
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> SET STATISTICS <replaceable class="parameter">integer</replaceable>
4040
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> SET ( <replaceable class="parameter">attribute_option</replaceable> = <replaceable class="parameter">value</replaceable> [, ... ] )
4141
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> RESET ( <replaceable class="parameter">attribute_option</replaceable> [, ... ] )
42-
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN }
42+
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN | DEFAULT }
4343
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> SET COMPRESSION <replaceable class="parameter">compression_method</replaceable>
4444
CLUSTER ON <replaceable class="parameter">index_name</replaceable>
4545
SET WITHOUT CLUSTER

0 commit comments

Comments
 (0)