Skip to content

Commit 8ee59ff

Browse files
committed
Merge remote-tracking branch 'pg/master' into fast2pc
2 parents 0a77efb + c202ecf commit 8ee59ff

File tree

98 files changed

+3851
-813
lines changed

Some content is hidden

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

98 files changed

+3851
-813
lines changed

doc/src/sgml/catalogs.sgml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,18 @@
412412
<entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
413413
<entry>Combine function (zero if none)</entry>
414414
</row>
415+
<row>
416+
<entry><structfield>aggserialfn</structfield></entry>
417+
<entry><type>regproc</type></entry>
418+
<entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
419+
<entry>Serialization function (zero if none)</entry>
420+
</row>
421+
<row>
422+
<entry><structfield>aggdeserialfn</structfield></entry>
423+
<entry><type>regproc</type></entry>
424+
<entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
425+
<entry>Deserialization function (zero if none)</entry>
426+
</row>
415427
<row>
416428
<entry><structfield>aggmtransfn</structfield></entry>
417429
<entry><type>regproc</type></entry>
@@ -454,6 +466,12 @@
454466
<entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
455467
<entry>Data type of the aggregate function's internal transition (state) data</entry>
456468
</row>
469+
<row>
470+
<entry><structfield>aggserialtype</structfield></entry>
471+
<entry><type>oid</type></entry>
472+
<entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
473+
<entry>Return data type of the aggregate function's serialization function (zero if none)</entry>
474+
</row>
457475
<row>
458476
<entry><structfield>aggtransspace</structfield></entry>
459477
<entry><type>int4</type></entry>

doc/src/sgml/config.sgml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2143,8 +2143,8 @@ include_dir 'conf.d'
21432143
Specifies whether transaction commit will wait for WAL records
21442144
to be written to disk before the command returns a <quote>success</>
21452145
indication to the client. Valid values are <literal>on</>,
2146-
<literal>remote_write</>, <literal>local</>, and <literal>off</>.
2147-
The default, and safe, setting
2146+
<literal>remote_write</>, <literal>remote_apply</>, <literal>local</>,
2147+
and <literal>off</>. The default, and safe, setting
21482148
is <literal>on</>. When <literal>off</>, there can be a delay between
21492149
when success is reported to the client and when the transaction is
21502150
really guaranteed to be safe against a server crash. (The maximum
@@ -2169,6 +2169,10 @@ include_dir 'conf.d'
21692169
the commit record of the transaction and flushed it to disk. This
21702170
ensures the transaction will not be lost unless both primary and
21712171
standby suffer corruption of their database storage.
2172+
When set to <literal>remote_apply</>, commits will wait until a reply
2173+
from the current synchronous standby indicates it has received the
2174+
commit record of the transaction and applied it, so that it has become
2175+
visible to queries.
21722176
When set to <literal>remote_write</>, commits will wait
21732177
until a reply from the current synchronous standby indicates it has
21742178
received the commit record of the transaction and written it out to
@@ -2186,9 +2190,9 @@ include_dir 'conf.d'
21862190
setting <literal>local</> is available for transactions that
21872191
wish to wait for local flush to disk, but not synchronous replication.
21882192
If <varname>synchronous_standby_names</> is not set, the settings
2189-
<literal>on</>, <literal>remote_write</> and <literal>local</> all
2190-
provide the same synchronization level: transaction commits only wait
2191-
for local flush to disk.
2193+
<literal>on</>, <literal>remote_apply</>, <literal>remote_write</>
2194+
and <literal>local</> all provide the same synchronization level:
2195+
transaction commits only wait for local flush to disk.
21922196
</para>
21932197
<para>
21942198
This parameter can be changed at any time; the behavior for any

doc/src/sgml/func.sgml

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5579,15 +5579,6 @@ SELECT regexp_matches('abc01234xyz', '(?:(.*?)(\d+)(.*)){1,1}');
55795579
argument is the value to be formatted and the second argument is a
55805580
template that defines the output or input format.
55815581
</para>
5582-
<para>
5583-
A single-argument <function>to_timestamp</function> function is also
5584-
available; it accepts a
5585-
<type>double precision</type> argument and converts from Unix epoch
5586-
(seconds since 1970-01-01 00:00:00+00) to
5587-
<type>timestamp with time zone</type>.
5588-
(<type>Integer</type> Unix epochs are implicitly cast to
5589-
<type>double precision</type>.)
5590-
</para>
55915582

55925583
<table id="functions-formatting-table">
55935584
<title>Formatting Functions</title>
@@ -5670,16 +5661,17 @@ SELECT regexp_matches('abc01234xyz', '(?:(.*?)(\d+)(.*)){1,1}');
56705661
<entry>convert string to time stamp</entry>
56715662
<entry><literal>to_timestamp('05&nbsp;Dec&nbsp;2000', 'DD&nbsp;Mon&nbsp;YYYY')</literal></entry>
56725663
</row>
5673-
<row>
5674-
<entry><literal><function>to_timestamp(<type>double precision</type>)</function></literal></entry>
5675-
<entry><type>timestamp with time zone</type></entry>
5676-
<entry>convert Unix epoch to time stamp</entry>
5677-
<entry><literal>to_timestamp(1284352323)</literal></entry>
5678-
</row>
56795664
</tbody>
56805665
</tgroup>
56815666
</table>
56825667

5668+
<note>
5669+
<para>
5670+
There is also a single-argument <function>to_timestamp</function>
5671+
function; see <xref linkend="functions-datetime-table">.
5672+
</para>
5673+
</note>
5674+
56835675
<para>
56845676
In a <function>to_char</> output template string, there are certain
56855677
patterns that are recognized and replaced with appropriately-formatted
@@ -7060,8 +7052,8 @@ SELECT regexp_matches('abc01234xyz', '(?:(.*?)(\d+)(.*)){1,1}');
70607052
<entry><type>timestamp with time zone</type></entry>
70617053
<entry>
70627054
Create timestamp with time zone from year, month, day, hour, minute
7063-
and seconds fields. When <parameter>timezone</parameter> is not specified,
7064-
then current time zone is used.
7055+
and seconds fields; if <parameter>timezone</parameter> is not
7056+
specified, the current time zone is used
70657057
</entry>
70667058
<entry><literal>make_timestamptz(2013, 7, 15, 8, 15, 23.5)</literal></entry>
70677059
<entry><literal>2013-07-15 08:15:23.5+01</literal></entry>
@@ -7127,6 +7119,19 @@ SELECT regexp_matches('abc01234xyz', '(?:(.*?)(\d+)(.*)){1,1}');
71277119
<entry></entry>
71287120
<entry></entry>
71297121
</row>
7122+
<row>
7123+
<entry>
7124+
<indexterm>
7125+
<primary>to_timestamp</primary>
7126+
</indexterm>
7127+
<literal><function>to_timestamp(<type>double precision</type>)</function></literal>
7128+
</entry>
7129+
<entry><type>timestamp with time zone</type></entry>
7130+
<entry>Convert Unix epoch (seconds since 1970-01-01 00:00:00+00) to
7131+
timestamp</entry>
7132+
<entry><literal>to_timestamp(1284352323)</literal></entry>
7133+
<entry><literal>2010-09-13 04:32:03+00</literal></entry>
7134+
</row>
71307135
</tbody>
71317136
</tgroup>
71327137
</table>
@@ -7377,16 +7382,13 @@ SELECT EXTRACT(EPOCH FROM INTERVAL '5 days 3 hours');
73777382
</screen>
73787383

73797384
<para>
7380-
Here is how you can convert an epoch value back to a time
7381-
stamp:
7385+
You can convert an epoch value back to a time stamp
7386+
with <function>to_timestamp</>:
73827387
</para>
73837388
<screen>
7384-
SELECT TIMESTAMP WITH TIME ZONE 'epoch' + 982384720.12 * INTERVAL '1 second';
7389+
SELECT to_timestamp(982384720.12);
7390+
<lineannotation>Result: </lineannotation><computeroutput>2001-02-17 04:38:40.12+00</computeroutput>
73857391
</screen>
7386-
<para>
7387-
(The <function>to_timestamp</> function encapsulates the above
7388-
conversion.)
7389-
</para>
73907392
</listitem>
73917393
</varlistentry>
73927394

doc/src/sgml/high-availability.sgml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,6 +1081,9 @@ primary_slot_name = 'node_a_slot'
10811081
WAL record is then sent to the standby. The standby sends reply
10821082
messages each time a new batch of WAL data is written to disk, unless
10831083
<varname>wal_receiver_status_interval</> is set to zero on the standby.
1084+
In the case that <varname>synchronous_commit</> is set to
1085+
<literal>remote_apply</>, the standby sends reply messages when the commit
1086+
record is replayed, making the transaction visible.
10841087
If the standby is the first matching standby, as specified in
10851088
<varname>synchronous_standby_names</> on the primary, the reply
10861089
messages from that standby will be used to wake users waiting for
@@ -1106,6 +1109,14 @@ primary_slot_name = 'node_a_slot'
11061109
the database of the primary gets corrupted at the same time.
11071110
</para>
11081111

1112+
<para>
1113+
Setting <varname>synchronous_commit</> to <literal>remote_apply</> will
1114+
cause each commit to wait until the current synchronous standby reports
1115+
that it has replayed the transaction, making it visible to user queries.
1116+
In simple cases, this allows for load balancing with causal consistency
1117+
on a single hot standby.
1118+
</para>
1119+
11091120
<para>
11101121
Users will stop waiting if a fast shutdown is requested. However, as
11111122
when using asynchronous replication, the server will not fully
@@ -1160,9 +1171,10 @@ primary_slot_name = 'node_a_slot'
11601171
<title>Planning for High Availability</title>
11611172

11621173
<para>
1163-
Commits made when <varname>synchronous_commit</> is set to <literal>on</>
1164-
or <literal>remote_write</> will wait until the synchronous standby responds. The response
1165-
may never occur if the last, or only, standby should crash.
1174+
Commits made when <varname>synchronous_commit</> is set to <literal>on</>,
1175+
<literal>remote_apply</> or <literal>remote_write</> will wait until the
1176+
synchronous standby responds. The response may never occur if the last, or
1177+
only, standby should crash.
11661178
</para>
11671179

11681180
<para>

doc/src/sgml/ref/create_aggregate.sgml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ CREATE AGGREGATE <replaceable class="parameter">name</replaceable> ( [ <replacea
2828
[ , FINALFUNC = <replaceable class="PARAMETER">ffunc</replaceable> ]
2929
[ , FINALFUNC_EXTRA ]
3030
[ , COMBINEFUNC = <replaceable class="PARAMETER">combinefunc</replaceable> ]
31+
[ , SERIALFUNC = <replaceable class="PARAMETER">serialfunc</replaceable> ]
32+
[ , DESERIALFUNC = <replaceable class="PARAMETER">deserialfunc</replaceable> ]
33+
[ , SERIALTYPE = <replaceable class="PARAMETER">serialtype</replaceable> ]
3134
[ , INITCOND = <replaceable class="PARAMETER">initial_condition</replaceable> ]
3235
[ , MSFUNC = <replaceable class="PARAMETER">msfunc</replaceable> ]
3336
[ , MINVFUNC = <replaceable class="PARAMETER">minvfunc</replaceable> ]
@@ -47,6 +50,9 @@ CREATE AGGREGATE <replaceable class="parameter">name</replaceable> ( [ [ <replac
4750
[ , FINALFUNC = <replaceable class="PARAMETER">ffunc</replaceable> ]
4851
[ , FINALFUNC_EXTRA ]
4952
[ , COMBINEFUNC = <replaceable class="PARAMETER">combinefunc</replaceable> ]
53+
[ , SERIALFUNC = <replaceable class="PARAMETER">serialfunc</replaceable> ]
54+
[ , DESERIALFUNC = <replaceable class="PARAMETER">deserialfunc</replaceable> ]
55+
[ , SERIALTYPE = <replaceable class="PARAMETER">serialtype</replaceable> ]
5056
[ , INITCOND = <replaceable class="PARAMETER">initial_condition</replaceable> ]
5157
[ , HYPOTHETICAL ]
5258
)
@@ -61,6 +67,9 @@ CREATE AGGREGATE <replaceable class="PARAMETER">name</replaceable> (
6167
[ , FINALFUNC = <replaceable class="PARAMETER">ffunc</replaceable> ]
6268
[ , FINALFUNC_EXTRA ]
6369
[ , COMBINEFUNC = <replaceable class="PARAMETER">combinefunc</replaceable> ]
70+
[ , SERIALFUNC = <replaceable class="PARAMETER">serialfunc</replaceable> ]
71+
[ , DESERIALFUNC = <replaceable class="PARAMETER">deserialfunc</replaceable> ]
72+
[ , SERIALTYPE = <replaceable class="PARAMETER">serialtype</replaceable> ]
6473
[ , INITCOND = <replaceable class="PARAMETER">initial_condition</replaceable> ]
6574
[ , MSFUNC = <replaceable class="PARAMETER">msfunc</replaceable> ]
6675
[ , MINVFUNC = <replaceable class="PARAMETER">minvfunc</replaceable> ]
@@ -436,6 +445,47 @@ SELECT col FROM tab ORDER BY col USING sortop LIMIT 1;
436445
</listitem>
437446
</varlistentry>
438447

448+
<varlistentry>
449+
<term><replaceable class="PARAMETER">serialfunc</replaceable></term>
450+
<listitem>
451+
<para>
452+
In order to allow aggregate functions with an <literal>INTERNAL</>
453+
<replaceable class="PARAMETER">state_data_type</replaceable> to
454+
participate in parallel aggregation, the aggregate must have a valid
455+
<replaceable class="PARAMETER">serialfunc</replaceable>, which must
456+
serialize the aggregate state into <replaceable class="PARAMETER">
457+
serialtype</replaceable>. This function must take a single argument of
458+
<replaceable class="PARAMETER">state_data_type</replaceable> and return
459+
<replaceable class="PARAMETER">serialtype</replaceable>. A
460+
corresponding <replaceable class="PARAMETER">deserialfunc</replaceable>
461+
is also required.
462+
</para>
463+
</listitem>
464+
</varlistentry>
465+
466+
<varlistentry>
467+
<term><replaceable class="PARAMETER">deserialfunc</replaceable></term>
468+
<listitem>
469+
<para>
470+
Deserializes a previously serialized aggregate state back into
471+
<replaceable class="PARAMETER">state_data_type</replaceable>. This
472+
function must take a single argument of <replaceable class="PARAMETER">
473+
serialtype</replaceable> and return <replaceable class="PARAMETER">
474+
state_data_type</replaceable>.
475+
</para>
476+
</listitem>
477+
</varlistentry>
478+
479+
<varlistentry>
480+
<term><replaceable class="PARAMETER">serialtype</replaceable></term>
481+
<listitem>
482+
<para>
483+
The data type to into which an <literal>INTERNAL</literal> aggregate
484+
state should be serialized.
485+
</para>
486+
</listitem>
487+
</varlistentry>
488+
439489
<varlistentry>
440490
<term><replaceable class="PARAMETER">initial_condition</replaceable></term>
441491
<listitem>

doc/src/sgml/ref/pgbench.sgml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,7 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
698698
Each script may be given a relative weight specified after a
699699
<literal>@</> so as to change its drawing probability.
700700
The default weight is <literal>1</>.
701+
Scripts with a weight of <literal>0</> are ignored.
701702
</para>
702703

703704
<para>
@@ -1134,12 +1135,12 @@ END;
11341135
The format of the log is:
11351136

11361137
<synopsis>
1137-
<replaceable>client_id</> <replaceable>transaction_no</> <replaceable>time</> <replaceable>file_no</> <replaceable>time_epoch</> <replaceable>time_us</> <optional><replaceable>schedule_lag</replaceable></optional>
1138+
<replaceable>client_id</> <replaceable>transaction_no</> <replaceable>time</> <replaceable>script_no</> <replaceable>time_epoch</> <replaceable>time_us</> <optional><replaceable>schedule_lag</replaceable></optional>
11381139
</synopsis>
11391140

11401141
where <replaceable>time</> is the total elapsed transaction time in microseconds,
1141-
<replaceable>file_no</> identifies which script file was used
1142-
(useful when multiple scripts were specified with <option>-f</>),
1142+
<replaceable>script_no</> identifies which script file was used (useful when
1143+
multiple scripts were specified with <option>-f</> or <option>-b</>),
11431144
and <replaceable>time_epoch</>/<replaceable>time_us</> are a
11441145
Unix epoch format time stamp and an offset
11451146
in microseconds (suitable for creating an ISO 8601
@@ -1148,10 +1149,9 @@ END;
11481149
Field <replaceable>schedule_lag</> is the difference between the
11491150
transaction's scheduled start time, and the time it actually started, in
11501151
microseconds. It is only present when the <option>--rate</> option is used.
1151-
The last field <replaceable>skipped_transactions</> reports the number of
1152-
transactions skipped because they were too far behind schedule. It is only
1153-
present when both options <option>--rate</> and <option>--latency-limit</>
1154-
are used.
1152+
When both <option>--rate</> and <option>--latency-limit</> are used,
1153+
the <replaceable>time</> for a skipped transaction will be reported as
1154+
<literal>skipped</>.
11551155
</para>
11561156

11571157
<para>
@@ -1259,17 +1259,17 @@ tps = 618.764555 (including connections establishing)
12591259
tps = 622.977698 (excluding connections establishing)
12601260
script statistics:
12611261
- statement latencies in milliseconds:
1262-
0.002522 \set aid random(1, 100000 * :scale)
1263-
0.005459 \set bid random(1, 1 * :scale)
1264-
0.002348 \set tid random(1, 10 * :scale)
1265-
0.001078 \set delta random(-5000, 5000)
1266-
0.326152 BEGIN;
1267-
0.603376 UPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;
1268-
0.454643 SELECT abalance FROM pgbench_accounts WHERE aid = :aid;
1269-
5.528491 UPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;
1270-
7.335435 UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;
1271-
0.371851 INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);
1272-
1.212976 END;
1262+
0.002 \set aid random(1, 100000 * :scale)
1263+
0.005 \set bid random(1, 1 * :scale)
1264+
0.002 \set tid random(1, 10 * :scale)
1265+
0.001 \set delta random(-5000, 5000)
1266+
0.326 BEGIN;
1267+
0.603 UPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;
1268+
0.454 SELECT abalance FROM pgbench_accounts WHERE aid = :aid;
1269+
5.528 UPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;
1270+
7.335 UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;
1271+
0.371 INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);
1272+
1.212 END;
12731273
</screen>
12741274
</para>
12751275

doc/src/sgml/ref/postgres-ref.sgml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -636,16 +636,6 @@ PostgreSQL documentation
636636
</listitem>
637637
</varlistentry>
638638

639-
<varlistentry>
640-
<term><envar>TZ</envar></term>
641-
642-
<listitem>
643-
<para>
644-
Server time zone
645-
</para>
646-
</listitem>
647-
</varlistentry>
648-
649639
</variablelist>
650640
</refsect1>
651641

0 commit comments

Comments
 (0)