mirror of
https://github.com/postgres/postgres.git
synced 2025-07-21 00:01:45 -04:00
Compare commits
6 Commits
0013ba290b
...
22655aa231
Author | SHA1 | Date | |
---|---|---|---|
|
22655aa231 | ||
|
8d140c5822 | ||
|
c5a032e518 | ||
|
536f410111 | ||
|
d16eb83aba | ||
|
97957fdbaa |
@ -250,4 +250,62 @@ SELECT count(*) > 0 AS has_data FROM pg_stat_statements;
|
||||
t
|
||||
(1 row)
|
||||
|
||||
-- New views for pg_stat_statements in 1.11
|
||||
AlTER EXTENSION pg_stat_statements UPDATE TO '1.11';
|
||||
\d pg_stat_statements
|
||||
View "public.pg_stat_statements"
|
||||
Column | Type | Collation | Nullable | Default
|
||||
------------------------+------------------+-----------+----------+---------
|
||||
userid | oid | | |
|
||||
dbid | oid | | |
|
||||
toplevel | boolean | | |
|
||||
queryid | bigint | | |
|
||||
query | text | | |
|
||||
plans | bigint | | |
|
||||
total_plan_time | double precision | | |
|
||||
min_plan_time | double precision | | |
|
||||
max_plan_time | double precision | | |
|
||||
mean_plan_time | double precision | | |
|
||||
stddev_plan_time | double precision | | |
|
||||
calls | bigint | | |
|
||||
total_exec_time | double precision | | |
|
||||
min_exec_time | double precision | | |
|
||||
max_exec_time | double precision | | |
|
||||
mean_exec_time | double precision | | |
|
||||
stddev_exec_time | double precision | | |
|
||||
rows | bigint | | |
|
||||
shared_blks_hit | bigint | | |
|
||||
shared_blks_read | bigint | | |
|
||||
shared_blks_dirtied | bigint | | |
|
||||
shared_blks_written | bigint | | |
|
||||
local_blks_hit | bigint | | |
|
||||
local_blks_read | bigint | | |
|
||||
local_blks_dirtied | bigint | | |
|
||||
local_blks_written | bigint | | |
|
||||
temp_blks_read | bigint | | |
|
||||
temp_blks_written | bigint | | |
|
||||
blk_read_time | double precision | | |
|
||||
blk_write_time | double precision | | |
|
||||
temp_blk_read_time | double precision | | |
|
||||
temp_blk_write_time | double precision | | |
|
||||
wal_records | bigint | | |
|
||||
wal_fpi | bigint | | |
|
||||
wal_bytes | numeric | | |
|
||||
jit_functions | bigint | | |
|
||||
jit_generation_time | double precision | | |
|
||||
jit_inlining_count | bigint | | |
|
||||
jit_inlining_time | double precision | | |
|
||||
jit_optimization_count | bigint | | |
|
||||
jit_optimization_time | double precision | | |
|
||||
jit_emission_count | bigint | | |
|
||||
jit_emission_time | double precision | | |
|
||||
jit_deform_count | bigint | | |
|
||||
jit_deform_time | double precision | | |
|
||||
|
||||
SELECT count(*) > 0 AS has_data FROM pg_stat_statements;
|
||||
has_data
|
||||
----------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
DROP EXTENSION pg_stat_statements;
|
||||
|
@ -48,4 +48,9 @@ AlTER EXTENSION pg_stat_statements UPDATE TO '1.10';
|
||||
\d pg_stat_statements
|
||||
SELECT count(*) > 0 AS has_data FROM pg_stat_statements;
|
||||
|
||||
-- New views for pg_stat_statements in 1.11
|
||||
AlTER EXTENSION pg_stat_statements UPDATE TO '1.11';
|
||||
\d pg_stat_statements
|
||||
SELECT count(*) > 0 AS has_data FROM pg_stat_statements;
|
||||
|
||||
DROP EXTENSION pg_stat_statements;
|
||||
|
@ -10611,7 +10611,7 @@ SELECT date_bin('15 minutes', TIMESTAMP '2020-02-11 15:44:17', TIMESTAMP '2001-0
|
||||
</sect2>
|
||||
|
||||
<sect2 id="functions-datetime-zoneconvert">
|
||||
<title><literal>AT TIME ZONE</literal></title>
|
||||
<title><literal>AT TIME ZONE and AT LOCAL</literal></title>
|
||||
|
||||
<indexterm>
|
||||
<primary>time zone</primary>
|
||||
@ -10622,6 +10622,10 @@ SELECT date_bin('15 minutes', TIMESTAMP '2020-02-11 15:44:17', TIMESTAMP '2001-0
|
||||
<primary>AT TIME ZONE</primary>
|
||||
</indexterm>
|
||||
|
||||
<indexterm>
|
||||
<primary>AT LOCAL</primary>
|
||||
</indexterm>
|
||||
|
||||
<para>
|
||||
The <literal>AT TIME ZONE</literal> operator converts time
|
||||
stamp <emphasis>without</emphasis> time zone to/from
|
||||
@ -10632,7 +10636,7 @@ SELECT date_bin('15 minutes', TIMESTAMP '2020-02-11 15:44:17', TIMESTAMP '2001-0
|
||||
</para>
|
||||
|
||||
<table id="functions-datetime-zoneconvert-table">
|
||||
<title><literal>AT TIME ZONE</literal> Variants</title>
|
||||
<title><literal>AT TIME ZONE</literal> and <literal>AT LOCAL</literal> Variants</title>
|
||||
<tgroup cols="1">
|
||||
<thead>
|
||||
<row>
|
||||
@ -10665,6 +10669,22 @@ SELECT date_bin('15 minutes', TIMESTAMP '2020-02-11 15:44:17', TIMESTAMP '2001-0
|
||||
</para></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry role="func_table_entry"><para role="func_signature">
|
||||
<type>timestamp without time zone</type> <literal>AT LOCAL</literal>
|
||||
<returnvalue>timestamp with time zone</returnvalue>
|
||||
</para>
|
||||
<para>
|
||||
Converts given time stamp <emphasis>without</emphasis> time zone to
|
||||
time stamp <emphasis>with</emphasis> the session's
|
||||
<varname>TimeZone</varname> value as time zone.
|
||||
</para>
|
||||
<para>
|
||||
<literal>timestamp '2001-02-16 20:38:40' at local</literal>
|
||||
<returnvalue>2001-02-17 03:38:40+00</returnvalue>
|
||||
</para></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry role="func_table_entry"><para role="func_signature">
|
||||
<type>timestamp with time zone</type> <literal>AT TIME ZONE</literal> <replaceable>zone</replaceable>
|
||||
@ -10681,6 +10701,22 @@ SELECT date_bin('15 minutes', TIMESTAMP '2020-02-11 15:44:17', TIMESTAMP '2001-0
|
||||
</para></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry role="func_table_entry"><para role="func_signature">
|
||||
<type>timestamp with time zone</type> <literal>AT LOCAL</literal>
|
||||
<returnvalue>timestamp without time zone</returnvalue>
|
||||
</para>
|
||||
<para>
|
||||
Converts given time stamp <emphasis>with</emphasis> time zone to
|
||||
time stamp <emphasis>without</emphasis> time zone, as the time would
|
||||
appear with the session's <varname>TimeZone</varname> value as time zone.
|
||||
</para>
|
||||
<para>
|
||||
<literal>timestamp with time zone '2001-02-16 20:38:40-05' at local</literal>
|
||||
<returnvalue>2001-02-16 18:38:40</returnvalue>
|
||||
</para></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry role="func_table_entry"><para role="func_signature">
|
||||
<type>time with time zone</type> <literal>AT TIME ZONE</literal> <replaceable>zone</replaceable>
|
||||
@ -10696,6 +10732,25 @@ SELECT date_bin('15 minutes', TIMESTAMP '2020-02-11 15:44:17', TIMESTAMP '2001-0
|
||||
<returnvalue>10:34:17+00</returnvalue>
|
||||
</para></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry role="func_table_entry"><para role="func_signature">
|
||||
<type>time with time zone</type> <literal>AT LOCAL</literal>
|
||||
<returnvalue>time with time zone</returnvalue>
|
||||
</para>
|
||||
<para>
|
||||
Converts given time <emphasis>with</emphasis> time zone to a new time
|
||||
zone. Since no date is supplied, this uses the currently active UTC
|
||||
offset for the session's <varname>TimeZone</varname> value.
|
||||
</para>
|
||||
<para>
|
||||
Assuming the session's <varname>TimeZone</varname> is set to <literal>UTC</literal>:
|
||||
</para>
|
||||
<para>
|
||||
<literal>time with time zone '05:34:17-05' at local</literal>
|
||||
<returnvalue>10:34:17+00</returnvalue>
|
||||
</para></entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
@ -10710,6 +10765,13 @@ SELECT date_bin('15 minutes', TIMESTAMP '2020-02-11 15:44:17', TIMESTAMP '2001-0
|
||||
UTC, so it is not very common in practice.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The syntax <literal>AT LOCAL</literal> may be used as shorthand for
|
||||
<literal>AT TIME ZONE <replaceable>local</replaceable></literal>, where
|
||||
<replaceable>local</replaceable> is the session's
|
||||
<varname>TimeZone</varname> value.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Examples (assuming the current <xref linkend="guc-timezone"/> setting
|
||||
is <literal>America/Los_Angeles</literal>):
|
||||
@ -10722,6 +10784,12 @@ SELECT TIMESTAMP WITH TIME ZONE '2001-02-16 20:38:40-05' AT TIME ZONE 'America/D
|
||||
|
||||
SELECT TIMESTAMP '2001-02-16 20:38:40' AT TIME ZONE 'Asia/Tokyo' AT TIME ZONE 'America/Chicago';
|
||||
<lineannotation>Result: </lineannotation><computeroutput>2001-02-16 05:38:40</computeroutput>
|
||||
|
||||
SELECT TIMESTAMP WITH TIME ZONE '2001-02-16 20:38:40-05' AT LOCAL;
|
||||
<lineannotation>Result: </lineannotation><computeroutput>2001-02-16 17:38:40</computeroutput>
|
||||
|
||||
SELECT TIME WITH TIME ZONE '20:38:40-05' AT LOCAL;
|
||||
<lineannotation>Result: </lineannotation><computeroutput>17:38:40</computeroutput>
|
||||
</screen>
|
||||
The first example adds a time zone to a value that lacks it, and
|
||||
displays the value using the current <varname>TimeZone</varname>
|
||||
@ -10729,7 +10797,18 @@ SELECT TIMESTAMP '2001-02-16 20:38:40' AT TIME ZONE 'Asia/Tokyo' AT TIME ZONE 'A
|
||||
to the specified time zone, and returns the value without a time zone.
|
||||
This allows storage and display of values different from the current
|
||||
<varname>TimeZone</varname> setting. The third example converts
|
||||
Tokyo time to Chicago time.
|
||||
Tokyo time to Chicago time. The fourth example shifts the time stamp
|
||||
with time zone value to the time zone currently specified by the
|
||||
<varname>TimeZone</varname> setting and returns the value without a
|
||||
time zone.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The fifth example is a cautionary tale. Due to the fact that there is no
|
||||
date associated with the input value, the conversion is made using the
|
||||
current date of the session. Therefore, this static example may show a wrong
|
||||
result depending on the time of the year it is viewed because
|
||||
<literal>'America/Los_Angeles'</literal> observes Daylight Savings Time.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
@ -10745,6 +10824,18 @@ SELECT TIMESTAMP '2001-02-16 20:38:40' AT TIME ZONE 'Asia/Tokyo' AT TIME ZONE 'A
|
||||
<literal><replaceable>time</replaceable> AT TIME ZONE
|
||||
<replaceable>zone</replaceable></literal>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The function <literal><function>timezone</function>(<replaceable>timestamp</replaceable>)</literal>
|
||||
is equivalent to the SQL-conforming construct <literal><replaceable>timestamp</replaceable>
|
||||
AT LOCAL</literal>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The function <literal><function>timezone</function>(<replaceable>time</replaceable>)</literal>
|
||||
is equivalent to the SQL-conforming construct <literal><replaceable>time</replaceable>
|
||||
AT LOCAL</literal>.
|
||||
</para>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="functions-datetime-current">
|
||||
|
@ -274,9 +274,11 @@
|
||||
</para>
|
||||
<para>
|
||||
Normally, the remote replication slot is created automatically when the
|
||||
subscription is created using <command>CREATE SUBSCRIPTION</command> and it
|
||||
subscription is created using <link linkend="sql-createsubscription">
|
||||
<command>CREATE SUBSCRIPTION</command></link> and it
|
||||
is dropped automatically when the subscription is dropped using
|
||||
<command>DROP SUBSCRIPTION</command>. In some situations, however, it can
|
||||
<link linkend="sql-dropsubscription"><command>DROP SUBSCRIPTION</command></link>.
|
||||
In some situations, however, it can
|
||||
be useful or necessary to manipulate the subscription and the underlying
|
||||
replication slot separately. Here are some scenarios:
|
||||
|
||||
@ -306,8 +308,9 @@
|
||||
When dropping a subscription, the replication slot should be kept.
|
||||
This could be useful when the subscriber database is being moved to a
|
||||
different host and will be activated from there. In that case,
|
||||
disassociate the slot from the subscription using <command>ALTER
|
||||
SUBSCRIPTION</command> before attempting to drop the subscription.
|
||||
disassociate the slot from the subscription using
|
||||
<link linkend="sql-altersubscription"><command>ALTER SUBSCRIPTION</command></link>
|
||||
before attempting to drop the subscription.
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
@ -1349,7 +1352,8 @@ test_sub=# SELECT * FROM child ORDER BY a;
|
||||
If a subscription is affected by this problem, the only way to resume
|
||||
replication is to adjust one of the column lists on the publication
|
||||
side so that they all match; and then either recreate the subscription,
|
||||
or use <literal>ALTER SUBSCRIPTION ... DROP PUBLICATION</literal> to
|
||||
or use <link linkend="sql-altersubscription-params-setadddrop-publication">
|
||||
<literal>ALTER SUBSCRIPTION ... DROP PUBLICATION</literal></link> to
|
||||
remove one of the offending publications and add it again.
|
||||
</para>
|
||||
</warning>
|
||||
@ -1504,13 +1508,15 @@ CONTEXT: processing remote data for replication origin "pg_16395" during "INSER
|
||||
the replication origin name can be found from the server log (LSN 0/14C0378 and
|
||||
replication origin <literal>pg_16395</literal> in the above case). The
|
||||
transaction that produced the conflict can be skipped by using
|
||||
<command>ALTER SUBSCRIPTION ... SKIP</command> with the finish LSN
|
||||
<link linkend="sql-altersubscription-params-skip"><command>ALTER SUBSCRIPTION ... SKIP</command></link>
|
||||
with the finish LSN
|
||||
(i.e., LSN 0/14C0378). The finish LSN could be an LSN at which the transaction
|
||||
is committed or prepared on the publisher. Alternatively, the transaction can
|
||||
also be skipped by calling the <link linkend="pg-replication-origin-advance">
|
||||
<function>pg_replication_origin_advance()</function></link> function.
|
||||
Before using this function, the subscription needs to be disabled temporarily
|
||||
either by <command>ALTER SUBSCRIPTION ... DISABLE</command> or, the
|
||||
either by <link linkend="sql-altersubscription-params-disable">
|
||||
<command>ALTER SUBSCRIPTION ... DISABLE</command></link> or, the
|
||||
subscription can be used with the
|
||||
<link linkend="sql-createsubscription-with-disable-on-error"><literal>disable_on_error</literal></link>
|
||||
option. Then, you can use <function>pg_replication_origin_advance()</function>
|
||||
|
@ -51,7 +51,8 @@ ALTER PUBLICATION <replaceable class="parameter">name</replaceable> RENAME TO <r
|
||||
<literal>ADD</literal> and <literal>DROP</literal> clauses will add and
|
||||
remove one or more tables/schemas from the publication. Note that adding
|
||||
tables/schemas to a publication that is already subscribed to will require an
|
||||
<literal>ALTER SUBSCRIPTION ... REFRESH PUBLICATION</literal> action on the
|
||||
<link linkend="sql-altersubscription-params-refresh-publication">
|
||||
<literal>ALTER SUBSCRIPTION ... REFRESH PUBLICATION</literal></link> action on the
|
||||
subscribing side in order to become effective. Note also that
|
||||
<literal>DROP TABLES IN SCHEMA</literal> will not drop any schema tables
|
||||
that were specified using
|
||||
|
@ -85,7 +85,7 @@ ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> RENAME TO <
|
||||
<title>Parameters</title>
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<varlistentry id="sql-altersubscription-params-name">
|
||||
<term><replaceable class="parameter">name</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
@ -94,7 +94,7 @@ ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> RENAME TO <
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<varlistentry id="sql-altersubscription-params-connection">
|
||||
<term><literal>CONNECTION '<replaceable class="parameter">conninfo</replaceable>'</literal></term>
|
||||
<listitem>
|
||||
<para>
|
||||
@ -105,7 +105,7 @@ ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> RENAME TO <
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<varlistentry id="sql-altersubscription-params-setadddrop-publication">
|
||||
<term><literal>SET PUBLICATION <replaceable class="parameter">publication_name</replaceable></literal></term>
|
||||
<term><literal>ADD PUBLICATION <replaceable class="parameter">publication_name</replaceable></literal></term>
|
||||
<term><literal>DROP PUBLICATION <replaceable class="parameter">publication_name</replaceable></literal></term>
|
||||
@ -147,13 +147,14 @@ ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> RENAME TO <
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<varlistentry id="sql-altersubscription-params-refresh-publication">
|
||||
<term><literal>REFRESH PUBLICATION</literal></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Fetch missing table information from publisher. This will start
|
||||
replication of tables that were added to the subscribed-to publications
|
||||
since <command>CREATE SUBSCRIPTION</command> or
|
||||
since <link linkend="sql-createsubscription">
|
||||
<command>CREATE SUBSCRIPTION</command></link> or
|
||||
the last invocation of <command>REFRESH PUBLICATION</command>.
|
||||
</para>
|
||||
|
||||
@ -192,7 +193,7 @@ ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> RENAME TO <
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<varlistentry id="sql-altersubscription-params-enable">
|
||||
<term><literal>ENABLE</literal></term>
|
||||
<listitem>
|
||||
<para>
|
||||
@ -202,7 +203,7 @@ ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> RENAME TO <
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<varlistentry id="sql-altersubscription-params-disable">
|
||||
<term><literal>DISABLE</literal></term>
|
||||
<listitem>
|
||||
<para>
|
||||
@ -212,7 +213,7 @@ ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> RENAME TO <
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<varlistentry id="sql-altersubscription-params-set">
|
||||
<term><literal>SET ( <replaceable class="parameter">subscription_parameter</replaceable> [= <replaceable class="parameter">value</replaceable>] [, ... ] )</literal></term>
|
||||
<listitem>
|
||||
<para>
|
||||
@ -232,7 +233,7 @@ ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> RENAME TO <
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<varlistentry id="sql-altersubscription-params-skip">
|
||||
<term><literal>SKIP ( <replaceable class="parameter">skip_option</replaceable> = <replaceable class="parameter">value</replaceable> )</literal></term>
|
||||
<listitem>
|
||||
<para>
|
||||
@ -272,7 +273,7 @@ ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> RENAME TO <
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<varlistentry id="sql-altersubscription-params-new-owner">
|
||||
<term><replaceable class="parameter">new_owner</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
@ -281,7 +282,7 @@ ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> RENAME TO <
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<varlistentry id="sql-altersubscription-params-new-name">
|
||||
<term><replaceable class="parameter">new_name</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
|
@ -40,7 +40,7 @@ DROP SUBSCRIPTION [ IF EXISTS ] <replaceable class="parameter">name</replaceable
|
||||
<para>
|
||||
<command>DROP SUBSCRIPTION</command> cannot be executed inside a
|
||||
transaction block if the subscription is associated with a replication
|
||||
slot. (You can use <command>ALTER SUBSCRIPTION</command> to unset the
|
||||
slot. (You can use <link linkend="sql-altersubscription"><command>ALTER SUBSCRIPTION</command></link> to unset the
|
||||
slot.)
|
||||
</para>
|
||||
</refsect1>
|
||||
@ -87,9 +87,11 @@ DROP SUBSCRIPTION [ IF EXISTS ] <replaceable class="parameter">name</replaceable
|
||||
replication slot cannot be dropped or does not exist or never existed,
|
||||
the <command>DROP SUBSCRIPTION</command> command will fail. To proceed
|
||||
in this situation, first disable the subscription by executing
|
||||
<literal>ALTER SUBSCRIPTION ... DISABLE</literal>, and then disassociate
|
||||
<link linkend="sql-altersubscription-params-disable">
|
||||
<literal>ALTER SUBSCRIPTION ... DISABLE</literal></link>, and then disassociate
|
||||
it from the replication slot by executing
|
||||
<literal>ALTER SUBSCRIPTION ... SET (slot_name = NONE)</literal>.
|
||||
<link linkend="sql-altersubscription-params-set">
|
||||
<literal>ALTER SUBSCRIPTION ... SET (slot_name = NONE)</literal></link>.
|
||||
After that, <command>DROP SUBSCRIPTION</command> will no longer attempt any
|
||||
actions on a remote host. Note that if the remote replication slot still
|
||||
exists, it (and any related table synchronization slots) should then be
|
||||
|
@ -1792,6 +1792,17 @@ ReleaseBulkInsertStatePin(BulkInsertState bistate)
|
||||
if (bistate->current_buf != InvalidBuffer)
|
||||
ReleaseBuffer(bistate->current_buf);
|
||||
bistate->current_buf = InvalidBuffer;
|
||||
|
||||
/*
|
||||
* Despite the name, we also reset bulk relation extension
|
||||
* state. Otherwise we can end up erroring out due to looking for free
|
||||
* space in ->next_free of one partition, even though ->next_free was set
|
||||
* when extending another partition. It's obviously also could be bad for
|
||||
* efficiency to look at existing blocks at offsets from another
|
||||
* partition, even if we don't error out.
|
||||
*/
|
||||
bistate->next_free = InvalidBlockNumber;
|
||||
bistate->last_free = InvalidBlockNumber;
|
||||
}
|
||||
|
||||
|
||||
|
@ -130,7 +130,7 @@ bool *wal_consistency_checking = NULL;
|
||||
bool wal_init_zero = true;
|
||||
bool wal_recycle = true;
|
||||
bool log_checkpoints = true;
|
||||
int sync_method = DEFAULT_SYNC_METHOD;
|
||||
int wal_sync_method = DEFAULT_WAL_SYNC_METHOD;
|
||||
int wal_level = WAL_LEVEL_REPLICA;
|
||||
int CommitDelay = 0; /* precommit delay in microseconds */
|
||||
int CommitSiblings = 5; /* # concurrent xacts needed to sleep */
|
||||
@ -171,17 +171,17 @@ static bool check_wal_consistency_checking_deferred = false;
|
||||
/*
|
||||
* GUC support
|
||||
*/
|
||||
const struct config_enum_entry sync_method_options[] = {
|
||||
{"fsync", SYNC_METHOD_FSYNC, false},
|
||||
const struct config_enum_entry wal_sync_method_options[] = {
|
||||
{"fsync", WAL_SYNC_METHOD_FSYNC, false},
|
||||
#ifdef HAVE_FSYNC_WRITETHROUGH
|
||||
{"fsync_writethrough", SYNC_METHOD_FSYNC_WRITETHROUGH, false},
|
||||
{"fsync_writethrough", WAL_SYNC_METHOD_FSYNC_WRITETHROUGH, false},
|
||||
#endif
|
||||
{"fdatasync", SYNC_METHOD_FDATASYNC, false},
|
||||
{"fdatasync", WAL_SYNC_METHOD_FDATASYNC, false},
|
||||
#ifdef O_SYNC
|
||||
{"open_sync", SYNC_METHOD_OPEN, false},
|
||||
{"open_sync", WAL_SYNC_METHOD_OPEN, false},
|
||||
#endif
|
||||
#ifdef O_DSYNC
|
||||
{"open_datasync", SYNC_METHOD_OPEN_DSYNC, false},
|
||||
{"open_datasync", WAL_SYNC_METHOD_OPEN_DSYNC, false},
|
||||
#endif
|
||||
{NULL, 0, false}
|
||||
};
|
||||
@ -2343,8 +2343,8 @@ XLogWrite(XLogwrtRqst WriteRqst, TimeLineID tli, bool flexible)
|
||||
* have no open file or the wrong one. However, we do not need to
|
||||
* fsync more than one file.
|
||||
*/
|
||||
if (sync_method != SYNC_METHOD_OPEN &&
|
||||
sync_method != SYNC_METHOD_OPEN_DSYNC)
|
||||
if (wal_sync_method != WAL_SYNC_METHOD_OPEN &&
|
||||
wal_sync_method != WAL_SYNC_METHOD_OPEN_DSYNC)
|
||||
{
|
||||
if (openLogFile >= 0 &&
|
||||
!XLByteInPrevSeg(LogwrtResult.Write, openLogSegNo,
|
||||
@ -2974,7 +2974,7 @@ XLogFileInitInternal(XLogSegNo logsegno, TimeLineID logtli,
|
||||
*/
|
||||
*added = false;
|
||||
fd = BasicOpenFile(path, O_RDWR | PG_BINARY | O_CLOEXEC |
|
||||
get_sync_bit(sync_method));
|
||||
get_sync_bit(wal_sync_method));
|
||||
if (fd < 0)
|
||||
{
|
||||
if (errno != ENOENT)
|
||||
@ -3139,7 +3139,7 @@ XLogFileInit(XLogSegNo logsegno, TimeLineID logtli)
|
||||
|
||||
/* Now open original target segment (might not be file I just made) */
|
||||
fd = BasicOpenFile(path, O_RDWR | PG_BINARY | O_CLOEXEC |
|
||||
get_sync_bit(sync_method));
|
||||
get_sync_bit(wal_sync_method));
|
||||
if (fd < 0)
|
||||
ereport(ERROR,
|
||||
(errcode_for_file_access(),
|
||||
@ -3371,7 +3371,7 @@ XLogFileOpen(XLogSegNo segno, TimeLineID tli)
|
||||
XLogFilePath(path, tli, segno, wal_segment_size);
|
||||
|
||||
fd = BasicOpenFile(path, O_RDWR | PG_BINARY | O_CLOEXEC |
|
||||
get_sync_bit(sync_method));
|
||||
get_sync_bit(wal_sync_method));
|
||||
if (fd < 0)
|
||||
ereport(PANIC,
|
||||
(errcode_for_file_access(),
|
||||
@ -8137,16 +8137,16 @@ get_sync_bit(int method)
|
||||
* not included in the enum option array, and therefore will never
|
||||
* be seen here.
|
||||
*/
|
||||
case SYNC_METHOD_FSYNC:
|
||||
case SYNC_METHOD_FSYNC_WRITETHROUGH:
|
||||
case SYNC_METHOD_FDATASYNC:
|
||||
case WAL_SYNC_METHOD_FSYNC:
|
||||
case WAL_SYNC_METHOD_FSYNC_WRITETHROUGH:
|
||||
case WAL_SYNC_METHOD_FDATASYNC:
|
||||
return o_direct_flag;
|
||||
#ifdef O_SYNC
|
||||
case SYNC_METHOD_OPEN:
|
||||
case WAL_SYNC_METHOD_OPEN:
|
||||
return O_SYNC | o_direct_flag;
|
||||
#endif
|
||||
#ifdef O_DSYNC
|
||||
case SYNC_METHOD_OPEN_DSYNC:
|
||||
case WAL_SYNC_METHOD_OPEN_DSYNC:
|
||||
return O_DSYNC | o_direct_flag;
|
||||
#endif
|
||||
default:
|
||||
@ -8160,9 +8160,9 @@ get_sync_bit(int method)
|
||||
* GUC support
|
||||
*/
|
||||
void
|
||||
assign_xlog_sync_method(int new_sync_method, void *extra)
|
||||
assign_wal_sync_method(int new_wal_sync_method, void *extra)
|
||||
{
|
||||
if (sync_method != new_sync_method)
|
||||
if (wal_sync_method != new_wal_sync_method)
|
||||
{
|
||||
/*
|
||||
* To ensure that no blocks escape unsynced, force an fsync on the
|
||||
@ -8188,7 +8188,7 @@ assign_xlog_sync_method(int new_sync_method, void *extra)
|
||||
}
|
||||
|
||||
pgstat_report_wait_end();
|
||||
if (get_sync_bit(sync_method) != get_sync_bit(new_sync_method))
|
||||
if (get_sync_bit(wal_sync_method) != get_sync_bit(new_wal_sync_method))
|
||||
XLogFileClose();
|
||||
}
|
||||
}
|
||||
@ -8214,8 +8214,8 @@ issue_xlog_fsync(int fd, XLogSegNo segno, TimeLineID tli)
|
||||
* file.
|
||||
*/
|
||||
if (!enableFsync ||
|
||||
sync_method == SYNC_METHOD_OPEN ||
|
||||
sync_method == SYNC_METHOD_OPEN_DSYNC)
|
||||
wal_sync_method == WAL_SYNC_METHOD_OPEN ||
|
||||
wal_sync_method == WAL_SYNC_METHOD_OPEN_DSYNC)
|
||||
return;
|
||||
|
||||
/* Measure I/O timing to sync the WAL file */
|
||||
@ -8225,29 +8225,29 @@ issue_xlog_fsync(int fd, XLogSegNo segno, TimeLineID tli)
|
||||
INSTR_TIME_SET_ZERO(start);
|
||||
|
||||
pgstat_report_wait_start(WAIT_EVENT_WAL_SYNC);
|
||||
switch (sync_method)
|
||||
switch (wal_sync_method)
|
||||
{
|
||||
case SYNC_METHOD_FSYNC:
|
||||
case WAL_SYNC_METHOD_FSYNC:
|
||||
if (pg_fsync_no_writethrough(fd) != 0)
|
||||
msg = _("could not fsync file \"%s\": %m");
|
||||
break;
|
||||
#ifdef HAVE_FSYNC_WRITETHROUGH
|
||||
case SYNC_METHOD_FSYNC_WRITETHROUGH:
|
||||
case WAL_SYNC_METHOD_FSYNC_WRITETHROUGH:
|
||||
if (pg_fsync_writethrough(fd) != 0)
|
||||
msg = _("could not fsync write-through file \"%s\": %m");
|
||||
break;
|
||||
#endif
|
||||
case SYNC_METHOD_FDATASYNC:
|
||||
case WAL_SYNC_METHOD_FDATASYNC:
|
||||
if (pg_fdatasync(fd) != 0)
|
||||
msg = _("could not fdatasync file \"%s\": %m");
|
||||
break;
|
||||
case SYNC_METHOD_OPEN:
|
||||
case SYNC_METHOD_OPEN_DSYNC:
|
||||
case WAL_SYNC_METHOD_OPEN:
|
||||
case WAL_SYNC_METHOD_OPEN_DSYNC:
|
||||
/* not reachable */
|
||||
Assert(false);
|
||||
break;
|
||||
default:
|
||||
elog(PANIC, "unrecognized wal_sync_method: %d", sync_method);
|
||||
elog(PANIC, "unrecognized wal_sync_method: %d", wal_sync_method);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -14508,6 +14508,13 @@ a_expr: c_expr { $$ = $1; }
|
||||
COERCE_SQL_SYNTAX,
|
||||
@2);
|
||||
}
|
||||
| a_expr AT LOCAL %prec AT
|
||||
{
|
||||
$$ = (Node *) makeFuncCall(SystemFuncName("timezone"),
|
||||
list_make1($1),
|
||||
COERCE_SQL_SYNTAX,
|
||||
-1);
|
||||
}
|
||||
/*
|
||||
* These operators must be called out explicitly in order to make use
|
||||
* of bison's automatic operator-precedence handling. All other
|
||||
|
@ -398,9 +398,9 @@ pg_fsync(int fd)
|
||||
errno = 0;
|
||||
#endif
|
||||
|
||||
/* #if is to skip the sync_method test if there's no need for it */
|
||||
/* #if is to skip the wal_sync_method test if there's no need for it */
|
||||
#if defined(HAVE_FSYNC_WRITETHROUGH)
|
||||
if (sync_method == SYNC_METHOD_FSYNC_WRITETHROUGH)
|
||||
if (wal_sync_method == WAL_SYNC_METHOD_FSYNC_WRITETHROUGH)
|
||||
return pg_fsync_writethrough(fd);
|
||||
else
|
||||
#endif
|
||||
|
@ -3125,3 +3125,18 @@ timetz_izone(PG_FUNCTION_ARGS)
|
||||
|
||||
PG_RETURN_TIMETZADT_P(result);
|
||||
}
|
||||
|
||||
/* timetz_at_local()
|
||||
*
|
||||
* Unlike for timestamp[tz]_at_local, the type for timetz does not flip between
|
||||
* time with/without time zone, so we cannot just call the conversion function.
|
||||
*/
|
||||
Datum
|
||||
timetz_at_local(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Datum time = PG_GETARG_DATUM(0);
|
||||
const char *tzn = pg_get_timezone_name(session_timezone);
|
||||
Datum zone = PointerGetDatum(cstring_to_text(tzn));
|
||||
|
||||
return DirectFunctionCall2(timetz_zone, zone, time);
|
||||
}
|
||||
|
@ -10347,6 +10347,16 @@ get_func_sql_syntax(FuncExpr *expr, deparse_context *context)
|
||||
appendStringInfoChar(buf, ')');
|
||||
return true;
|
||||
|
||||
case F_TIMEZONE_TIMESTAMP:
|
||||
case F_TIMEZONE_TIMESTAMPTZ:
|
||||
case F_TIMEZONE_TIMETZ:
|
||||
/* AT LOCAL */
|
||||
appendStringInfoChar(buf, '(');
|
||||
get_rule_expr_paren((Node *) linitial(expr->args), context, false,
|
||||
(Node *) expr);
|
||||
appendStringInfoString(buf, " AT LOCAL)");
|
||||
return true;
|
||||
|
||||
case F_OVERLAPS_TIMESTAMPTZ_INTERVAL_TIMESTAMPTZ_INTERVAL:
|
||||
case F_OVERLAPS_TIMESTAMPTZ_INTERVAL_TIMESTAMPTZ_TIMESTAMPTZ:
|
||||
case F_OVERLAPS_TIMESTAMPTZ_TIMESTAMPTZ_TIMESTAMPTZ_INTERVAL:
|
||||
|
@ -5921,3 +5921,23 @@ generate_series_timestamptz_at_zone(PG_FUNCTION_ARGS)
|
||||
{
|
||||
return generate_series_timestamptz_internal(fcinfo);
|
||||
}
|
||||
|
||||
/* timestamp_at_local()
|
||||
* timestamptz_at_local()
|
||||
*
|
||||
* The regression tests do not like two functions with the same proargs and
|
||||
* prosrc but different proname, but the grammar for AT LOCAL needs an
|
||||
* overloaded name to handle both types of timestamp, so we make simple
|
||||
* wrappers for it.
|
||||
*/
|
||||
Datum
|
||||
timestamp_at_local(PG_FUNCTION_ARGS)
|
||||
{
|
||||
return timestamp_timestamptz(fcinfo);
|
||||
}
|
||||
|
||||
Datum
|
||||
timestamptz_at_local(PG_FUNCTION_ARGS)
|
||||
{
|
||||
return timestamptz_timestamp(fcinfo);
|
||||
}
|
||||
|
@ -485,7 +485,7 @@ static const struct config_enum_entry wal_compression_options[] = {
|
||||
extern const struct config_enum_entry wal_level_options[];
|
||||
extern const struct config_enum_entry archive_mode_options[];
|
||||
extern const struct config_enum_entry recovery_target_action_options[];
|
||||
extern const struct config_enum_entry sync_method_options[];
|
||||
extern const struct config_enum_entry wal_sync_method_options[];
|
||||
extern const struct config_enum_entry dynamic_shared_memory_options[];
|
||||
|
||||
/*
|
||||
@ -4843,9 +4843,9 @@ struct config_enum ConfigureNamesEnum[] =
|
||||
gettext_noop("Selects the method used for forcing WAL updates to disk."),
|
||||
NULL
|
||||
},
|
||||
&sync_method,
|
||||
DEFAULT_SYNC_METHOD, sync_method_options,
|
||||
NULL, assign_xlog_sync_method, NULL
|
||||
&wal_sync_method,
|
||||
DEFAULT_WAL_SYNC_METHOD, wal_sync_method_options,
|
||||
NULL, assign_wal_sync_method, NULL
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -4682,6 +4682,12 @@ psql_completion(const char *text, int start, int end)
|
||||
else if (TailMatches("JOIN"))
|
||||
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_selectables);
|
||||
|
||||
/* ... AT [ LOCAL | TIME ZONE ] ... */
|
||||
else if (TailMatches("AT"))
|
||||
COMPLETE_WITH("LOCAL", "TIME ZONE");
|
||||
else if (TailMatches("AT", "TIME", "ZONE"))
|
||||
COMPLETE_WITH_TIMEZONE_NAME();
|
||||
|
||||
/* Backslash commands */
|
||||
/* TODO: \dc \dd \dl */
|
||||
else if (TailMatchesCS("\\?"))
|
||||
|
@ -19,12 +19,15 @@
|
||||
|
||||
|
||||
/* Sync methods */
|
||||
#define SYNC_METHOD_FSYNC 0
|
||||
#define SYNC_METHOD_FDATASYNC 1
|
||||
#define SYNC_METHOD_OPEN 2 /* for O_SYNC */
|
||||
#define SYNC_METHOD_FSYNC_WRITETHROUGH 3
|
||||
#define SYNC_METHOD_OPEN_DSYNC 4 /* for O_DSYNC */
|
||||
extern PGDLLIMPORT int sync_method;
|
||||
typedef enum WalSyncMethod
|
||||
{
|
||||
WAL_SYNC_METHOD_FSYNC = 0,
|
||||
WAL_SYNC_METHOD_FDATASYNC,
|
||||
WAL_SYNC_METHOD_OPEN, /* for O_SYNC */
|
||||
WAL_SYNC_METHOD_FSYNC_WRITETHROUGH,
|
||||
WAL_SYNC_METHOD_OPEN_DSYNC /* for O_DSYNC */
|
||||
} WalSyncMethod;
|
||||
extern PGDLLIMPORT int wal_sync_method;
|
||||
|
||||
extern PGDLLIMPORT XLogRecPtr ProcLastRecPtr;
|
||||
extern PGDLLIMPORT XLogRecPtr XactLastRecEnd;
|
||||
|
@ -71,12 +71,12 @@ typedef uint16 RepOriginId;
|
||||
*
|
||||
* Note that we define our own O_DSYNC on Windows, but not O_SYNC.
|
||||
*/
|
||||
#if defined(PLATFORM_DEFAULT_SYNC_METHOD)
|
||||
#define DEFAULT_SYNC_METHOD PLATFORM_DEFAULT_SYNC_METHOD
|
||||
#if defined(PLATFORM_DEFAULT_WAL_SYNC_METHOD)
|
||||
#define DEFAULT_WAL_SYNC_METHOD PLATFORM_DEFAULT_WAL_SYNC_METHOD
|
||||
#elif defined(O_DSYNC) && (!defined(O_SYNC) || O_DSYNC != O_SYNC)
|
||||
#define DEFAULT_SYNC_METHOD SYNC_METHOD_OPEN_DSYNC
|
||||
#define DEFAULT_WAL_SYNC_METHOD WAL_SYNC_METHOD_OPEN_DSYNC
|
||||
#else
|
||||
#define DEFAULT_SYNC_METHOD SYNC_METHOD_FDATASYNC
|
||||
#define DEFAULT_WAL_SYNC_METHOD WAL_SYNC_METHOD_FDATASYNC
|
||||
#endif
|
||||
|
||||
#endif /* XLOG_DEFS_H */
|
||||
|
@ -57,6 +57,6 @@
|
||||
*/
|
||||
|
||||
/* yyyymmddN */
|
||||
#define CATALOG_VERSION_NO 202309251
|
||||
#define CATALOG_VERSION_NO 202310131
|
||||
|
||||
#endif
|
||||
|
@ -2319,6 +2319,9 @@
|
||||
{ oid => '1159', descr => 'adjust timestamp to new time zone',
|
||||
proname => 'timezone', prorettype => 'timestamp',
|
||||
proargtypes => 'text timestamptz', prosrc => 'timestamptz_zone' },
|
||||
{ oid => '9159', descr => 'adjust timestamp to local time zone',
|
||||
proname => 'timezone', provolatile => 's', prorettype => 'timestamp',
|
||||
proargtypes => 'timestamptz', prosrc => 'timestamptz_at_local' },
|
||||
|
||||
{ oid => '1160', descr => 'I/O',
|
||||
proname => 'interval_in', provolatile => 's', prorettype => 'interval',
|
||||
@ -6095,6 +6098,9 @@
|
||||
{ oid => '2038', descr => 'adjust time with time zone to new zone',
|
||||
proname => 'timezone', prorettype => 'timetz',
|
||||
proargtypes => 'interval timetz', prosrc => 'timetz_izone' },
|
||||
{ oid => '9161', descr => 'adjust time to local time zone',
|
||||
proname => 'timezone', provolatile => 's', prorettype => 'timetz',
|
||||
proargtypes => 'timetz', prosrc => 'timetz_at_local' },
|
||||
{ oid => '2039', descr => 'hash',
|
||||
proname => 'timestamp_hash', prorettype => 'int4', proargtypes => 'timestamp',
|
||||
prosrc => 'timestamp_hash' },
|
||||
@ -6190,6 +6196,9 @@
|
||||
{ oid => '2070', descr => 'adjust timestamp to new time zone',
|
||||
proname => 'timezone', prorettype => 'timestamptz',
|
||||
proargtypes => 'interval timestamp', prosrc => 'timestamp_izone' },
|
||||
{ oid => '9160', descr => 'adjust timestamp to local time zone',
|
||||
proname => 'timezone', provolatile => 's', prorettype => 'timestamptz',
|
||||
proargtypes => 'timestamp', prosrc => 'timestamp_at_local' },
|
||||
{ oid => '2071',
|
||||
proname => 'date_pl_interval', prorettype => 'timestamp',
|
||||
proargtypes => 'date interval', prosrc => 'date_pl_interval' },
|
||||
|
@ -5,4 +5,4 @@
|
||||
* would prefer open_datasync on FreeBSD 13+, but that is not a good choice on
|
||||
* many systems.
|
||||
*/
|
||||
#define PLATFORM_DEFAULT_SYNC_METHOD SYNC_METHOD_FDATASYNC
|
||||
#define PLATFORM_DEFAULT_WAL_SYNC_METHOD WAL_SYNC_METHOD_FDATASYNC
|
||||
|
@ -19,4 +19,4 @@
|
||||
* perform better and (b) causes outright failures on ext4 data=journal
|
||||
* filesystems, because those don't support O_DIRECT.
|
||||
*/
|
||||
#define PLATFORM_DEFAULT_SYNC_METHOD SYNC_METHOD_FDATASYNC
|
||||
#define PLATFORM_DEFAULT_WAL_SYNC_METHOD WAL_SYNC_METHOD_FDATASYNC
|
||||
|
@ -159,6 +159,6 @@ extern bool check_wal_consistency_checking(char **newval, void **extra,
|
||||
GucSource source);
|
||||
extern void assign_wal_consistency_checking(const char *newval, void *extra);
|
||||
extern bool check_wal_segment_size(int *newval, void **extra, GucSource source);
|
||||
extern void assign_xlog_sync_method(int new_sync_method, void *extra);
|
||||
extern void assign_wal_sync_method(int new_wal_sync_method, void *extra);
|
||||
|
||||
#endif /* GUC_HOOKS_H */
|
||||
|
@ -257,3 +257,40 @@ ERROR: value too long for type character varying(5)
|
||||
\.
|
||||
invalid command \.
|
||||
drop table oversized_column_default;
|
||||
--
|
||||
-- Create partitioned table that does not allow bulk insertions, to test bugs
|
||||
-- related to the reuse of BulkInsertState across partitions (only done when
|
||||
-- not using bulk insert). Switching between partitions often makes it more
|
||||
-- likely to encounter these bugs, so we just switch on roughly every insert
|
||||
-- by having an even/odd number partition and inserting evenly distributed
|
||||
-- data.
|
||||
--
|
||||
CREATE TABLE parted_si (
|
||||
id int not null,
|
||||
data text not null,
|
||||
-- prevent use of bulk insert by having a volatile function
|
||||
rand float8 not null default random()
|
||||
)
|
||||
PARTITION BY LIST((id % 2));
|
||||
CREATE TABLE parted_si_p_even PARTITION OF parted_si FOR VALUES IN (0);
|
||||
CREATE TABLE parted_si_p_odd PARTITION OF parted_si FOR VALUES IN (1);
|
||||
-- Test that bulk relation extension handles reusing a single BulkInsertState
|
||||
-- across partitions. Without the fix applied, this reliably reproduces
|
||||
-- #18130 unless shared_buffers is extremely small (preventing any use use of
|
||||
-- bulk relation extension). See
|
||||
-- https://postgr.es/m/18130-7a86a7356a75209d%40postgresql.org
|
||||
-- https://postgr.es/m/257696.1695670946%40sss.pgh.pa.us
|
||||
\set filename :abs_srcdir '/data/desc.data'
|
||||
COPY parted_si(id, data) FROM :'filename';
|
||||
-- An earlier bug (see commit b1ecb9b3fcf) could end up using a buffer from
|
||||
-- the wrong partition. This test is *not* guaranteed to trigger that bug, but
|
||||
-- does so when shared_buffers is small enough. To test if we encountered the
|
||||
-- bug, check that the partition condition isn't violated.
|
||||
SELECT tableoid::regclass, id % 2 = 0 is_even, count(*) from parted_si GROUP BY 1, 2 ORDER BY 1;
|
||||
tableoid | is_even | count
|
||||
------------------+---------+-------
|
||||
parted_si_p_even | t | 5000
|
||||
parted_si_p_odd | f | 5000
|
||||
(2 rows)
|
||||
|
||||
DROP TABLE parted_si;
|
||||
|
@ -3135,6 +3135,62 @@ SELECT '2014-10-25 23:00:00 UTC'::timestamptz AT TIME ZONE 'MSK';
|
||||
Sun Oct 26 02:00:00 2014
|
||||
(1 row)
|
||||
|
||||
--
|
||||
-- Test LOCAL time zone
|
||||
--
|
||||
BEGIN;
|
||||
SET LOCAL TIME ZONE 'Europe/Paris';
|
||||
VALUES (CAST('1978-07-07 19:38 America/New_York' AS TIMESTAMP WITH TIME ZONE) AT LOCAL);
|
||||
column1
|
||||
--------------------------
|
||||
Sat Jul 08 01:38:00 1978
|
||||
(1 row)
|
||||
|
||||
VALUES (TIMESTAMP '1978-07-07 19:38' AT LOCAL);
|
||||
column1
|
||||
-------------------------------
|
||||
Fri Jul 07 19:38:00 1978 CEST
|
||||
(1 row)
|
||||
|
||||
SET LOCAL TIME ZONE 'Australia/Sydney';
|
||||
VALUES (CAST('1978-07-07 19:38 America/New_York' AS TIMESTAMP WITH TIME ZONE) AT LOCAL);
|
||||
column1
|
||||
--------------------------
|
||||
Sat Jul 08 09:38:00 1978
|
||||
(1 row)
|
||||
|
||||
VALUES (TIMESTAMP '1978-07-07 19:38' AT LOCAL);
|
||||
column1
|
||||
-------------------------------
|
||||
Fri Jul 07 19:38:00 1978 AEST
|
||||
(1 row)
|
||||
|
||||
SET LOCAL TimeZone TO 'UTC';
|
||||
CREATE VIEW timestamp_local_view AS
|
||||
SELECT CAST('1978-07-07 19:38 America/New_York' AS TIMESTAMP WITH TIME ZONE) AT LOCAL AS ttz_at_local,
|
||||
timezone(CAST('1978-07-07 19:38 America/New_York' AS TIMESTAMP WITH TIME ZONE)) AS ttz_func,
|
||||
TIMESTAMP '1978-07-07 19:38' AT LOCAL AS t_at_local,
|
||||
timezone(TIMESTAMP '1978-07-07 19:38') AS t_func;
|
||||
SELECT pg_get_viewdef('timestamp_local_view', true);
|
||||
pg_get_viewdef
|
||||
----------------------------------------------------------------------------------------------
|
||||
SELECT ('Fri Jul 07 23:38:00 1978 UTC'::timestamp with time zone AT LOCAL) AS ttz_at_local,+
|
||||
timezone('Fri Jul 07 23:38:00 1978 UTC'::timestamp with time zone) AS ttz_func, +
|
||||
('Fri Jul 07 19:38:00 1978'::timestamp without time zone AT LOCAL) AS t_at_local, +
|
||||
timezone('Fri Jul 07 19:38:00 1978'::timestamp without time zone) AS t_func;
|
||||
(1 row)
|
||||
|
||||
\x
|
||||
TABLE timestamp_local_view;
|
||||
-[ RECORD 1 ]+-----------------------------
|
||||
ttz_at_local | Fri Jul 07 23:38:00 1978
|
||||
ttz_func | Fri Jul 07 23:38:00 1978
|
||||
t_at_local | Fri Jul 07 19:38:00 1978 UTC
|
||||
t_func | Fri Jul 07 19:38:00 1978 UTC
|
||||
|
||||
\x
|
||||
DROP VIEW timestamp_local_view;
|
||||
COMMIT;
|
||||
--
|
||||
-- Test that AT TIME ZONE isn't misoptimized when using an index (bug #14504)
|
||||
--
|
||||
|
@ -262,3 +262,45 @@ SELECT date_part('epoch', TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-
|
||||
63025.575401
|
||||
(1 row)
|
||||
|
||||
--
|
||||
-- AT LOCAL with timetz
|
||||
--
|
||||
BEGIN;
|
||||
SET LOCAL TimeZone TO 'UTC';
|
||||
CREATE VIEW timetz_local_view AS
|
||||
SELECT f1 AS dat,
|
||||
timezone(f1) AS dat_func,
|
||||
f1 AT LOCAL AS dat_at_local,
|
||||
f1 AT TIME ZONE current_setting('TimeZone') AS dat_at_time
|
||||
FROM TIMETZ_TBL
|
||||
ORDER BY f1;
|
||||
SELECT pg_get_viewdef('timetz_local_view', true);
|
||||
pg_get_viewdef
|
||||
------------------------------------------------------------------------
|
||||
SELECT f1 AS dat, +
|
||||
timezone(f1) AS dat_func, +
|
||||
(f1 AT LOCAL) AS dat_at_local, +
|
||||
(f1 AT TIME ZONE current_setting('TimeZone'::text)) AS dat_at_time+
|
||||
FROM timetz_tbl +
|
||||
ORDER BY f1;
|
||||
(1 row)
|
||||
|
||||
TABLE timetz_local_view;
|
||||
dat | dat_func | dat_at_local | dat_at_time
|
||||
----------------+----------------+----------------+----------------
|
||||
00:01:00-07 | 07:01:00+00 | 07:01:00+00 | 07:01:00+00
|
||||
01:00:00-07 | 08:00:00+00 | 08:00:00+00 | 08:00:00+00
|
||||
02:03:00-07 | 09:03:00+00 | 09:03:00+00 | 09:03:00+00
|
||||
08:08:00-04 | 12:08:00+00 | 12:08:00+00 | 12:08:00+00
|
||||
07:07:00-08 | 15:07:00+00 | 15:07:00+00 | 15:07:00+00
|
||||
11:59:00-07 | 18:59:00+00 | 18:59:00+00 | 18:59:00+00
|
||||
12:00:00-07 | 19:00:00+00 | 19:00:00+00 | 19:00:00+00
|
||||
12:01:00-07 | 19:01:00+00 | 19:01:00+00 | 19:01:00+00
|
||||
15:36:39-04 | 19:36:39+00 | 19:36:39+00 | 19:36:39+00
|
||||
15:36:39-05 | 20:36:39+00 | 20:36:39+00 | 20:36:39+00
|
||||
23:59:00-07 | 06:59:00+00 | 06:59:00+00 | 06:59:00+00
|
||||
23:59:59.99-07 | 06:59:59.99+00 | 06:59:59.99+00 | 06:59:59.99+00
|
||||
(12 rows)
|
||||
|
||||
DROP VIEW timetz_local_view;
|
||||
COMMIT;
|
||||
|
@ -283,3 +283,40 @@ copy oversized_column_default (col2) from stdin;
|
||||
copy oversized_column_default from stdin (default '');
|
||||
\.
|
||||
drop table oversized_column_default;
|
||||
|
||||
|
||||
--
|
||||
-- Create partitioned table that does not allow bulk insertions, to test bugs
|
||||
-- related to the reuse of BulkInsertState across partitions (only done when
|
||||
-- not using bulk insert). Switching between partitions often makes it more
|
||||
-- likely to encounter these bugs, so we just switch on roughly every insert
|
||||
-- by having an even/odd number partition and inserting evenly distributed
|
||||
-- data.
|
||||
--
|
||||
CREATE TABLE parted_si (
|
||||
id int not null,
|
||||
data text not null,
|
||||
-- prevent use of bulk insert by having a volatile function
|
||||
rand float8 not null default random()
|
||||
)
|
||||
PARTITION BY LIST((id % 2));
|
||||
|
||||
CREATE TABLE parted_si_p_even PARTITION OF parted_si FOR VALUES IN (0);
|
||||
CREATE TABLE parted_si_p_odd PARTITION OF parted_si FOR VALUES IN (1);
|
||||
|
||||
-- Test that bulk relation extension handles reusing a single BulkInsertState
|
||||
-- across partitions. Without the fix applied, this reliably reproduces
|
||||
-- #18130 unless shared_buffers is extremely small (preventing any use use of
|
||||
-- bulk relation extension). See
|
||||
-- https://postgr.es/m/18130-7a86a7356a75209d%40postgresql.org
|
||||
-- https://postgr.es/m/257696.1695670946%40sss.pgh.pa.us
|
||||
\set filename :abs_srcdir '/data/desc.data'
|
||||
COPY parted_si(id, data) FROM :'filename';
|
||||
|
||||
-- An earlier bug (see commit b1ecb9b3fcf) could end up using a buffer from
|
||||
-- the wrong partition. This test is *not* guaranteed to trigger that bug, but
|
||||
-- does so when shared_buffers is small enough. To test if we encountered the
|
||||
-- bug, check that the partition condition isn't violated.
|
||||
SELECT tableoid::regclass, id % 2 = 0 is_even, count(*) from parted_si GROUP BY 1, 2 ORDER BY 1;
|
||||
|
||||
DROP TABLE parted_si;
|
||||
|
@ -611,6 +611,29 @@ SELECT '2014-10-25 22:00:00 UTC'::timestamptz AT TIME ZONE 'MSK';
|
||||
SELECT '2014-10-25 22:00:01 UTC'::timestamptz AT TIME ZONE 'MSK';
|
||||
SELECT '2014-10-25 23:00:00 UTC'::timestamptz AT TIME ZONE 'MSK';
|
||||
|
||||
--
|
||||
-- Test LOCAL time zone
|
||||
--
|
||||
BEGIN;
|
||||
SET LOCAL TIME ZONE 'Europe/Paris';
|
||||
VALUES (CAST('1978-07-07 19:38 America/New_York' AS TIMESTAMP WITH TIME ZONE) AT LOCAL);
|
||||
VALUES (TIMESTAMP '1978-07-07 19:38' AT LOCAL);
|
||||
SET LOCAL TIME ZONE 'Australia/Sydney';
|
||||
VALUES (CAST('1978-07-07 19:38 America/New_York' AS TIMESTAMP WITH TIME ZONE) AT LOCAL);
|
||||
VALUES (TIMESTAMP '1978-07-07 19:38' AT LOCAL);
|
||||
SET LOCAL TimeZone TO 'UTC';
|
||||
CREATE VIEW timestamp_local_view AS
|
||||
SELECT CAST('1978-07-07 19:38 America/New_York' AS TIMESTAMP WITH TIME ZONE) AT LOCAL AS ttz_at_local,
|
||||
timezone(CAST('1978-07-07 19:38 America/New_York' AS TIMESTAMP WITH TIME ZONE)) AS ttz_func,
|
||||
TIMESTAMP '1978-07-07 19:38' AT LOCAL AS t_at_local,
|
||||
timezone(TIMESTAMP '1978-07-07 19:38') AS t_func;
|
||||
SELECT pg_get_viewdef('timestamp_local_view', true);
|
||||
\x
|
||||
TABLE timestamp_local_view;
|
||||
\x
|
||||
DROP VIEW timestamp_local_view;
|
||||
COMMIT;
|
||||
|
||||
--
|
||||
-- Test that AT TIME ZONE isn't misoptimized when using an index (bug #14504)
|
||||
--
|
||||
|
@ -84,3 +84,20 @@ SELECT date_part('microsecond', TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-
|
||||
SELECT date_part('millisecond', TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04');
|
||||
SELECT date_part('second', TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04');
|
||||
SELECT date_part('epoch', TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04');
|
||||
|
||||
--
|
||||
-- AT LOCAL with timetz
|
||||
--
|
||||
BEGIN;
|
||||
SET LOCAL TimeZone TO 'UTC';
|
||||
CREATE VIEW timetz_local_view AS
|
||||
SELECT f1 AS dat,
|
||||
timezone(f1) AS dat_func,
|
||||
f1 AT LOCAL AS dat_at_local,
|
||||
f1 AT TIME ZONE current_setting('TimeZone') AS dat_at_time
|
||||
FROM TIMETZ_TBL
|
||||
ORDER BY f1;
|
||||
SELECT pg_get_viewdef('timetz_local_view', true);
|
||||
TABLE timetz_local_view;
|
||||
DROP VIEW timetz_local_view;
|
||||
COMMIT;
|
||||
|
@ -3016,6 +3016,7 @@ WalSnd
|
||||
WalSndCtlData
|
||||
WalSndSendDataCallback
|
||||
WalSndState
|
||||
WalSyncMethod
|
||||
WalTimeSample
|
||||
WalUsage
|
||||
WalWriteMethod
|
||||
|
Loading…
x
Reference in New Issue
Block a user