Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 925c4f8

Browse files
committed
Merge branch 'PGPROEE10_DEV' into PGPROEE10_pg_shardman
2 parents c457b3e + cdb2033 commit 925c4f8

Some content is hidden

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

47 files changed

+2784
-878
lines changed

contrib/pageinspect/expected/page.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ SELECT get_raw_page('test1', 0) = get_raw_page('test1', 'main', 0);
4646
SELECT pagesize, version FROM page_header(get_raw_page('test1', 0));
4747
pagesize | version
4848
----------+---------
49-
8192 | 4
49+
8192 | 254
5050
(1 row)
5151

5252
SELECT page_checksum(get_raw_page('test1', 0), 0) IS NOT NULL AS silly_checksum_test;

doc/src/sgml/charset.sgml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -580,19 +580,6 @@ SELECT * FROM test1 ORDER BY a || b COLLATE "fr_FR";
580580
</para>
581581
</important>
582582

583-
<important>
584-
<para>
585-
On Windows, if the collation provider is <literal>icu</literal>,
586-
you cannot use long locale names with the <literal>locale</literal>,
587-
<literal>lc_collate</literal>, and <literal>lc_ctype</literal> options.
588-
Instead, you must use canonical locale names supported on your
589-
operating system. For example, <literal>"ru-RU"</literal> or
590-
<literal>"en-US"</literal>. Specifying the encoding with these
591-
options is not allowed either. If required, you can specify the
592-
UTF8 encoding using the <literal>--encoding</literal> option.
593-
</para>
594-
</important>
595-
596583
<para>
597584
When you start a cluster server or connect to a database,
598585
<productname>&productname;</> checks that the selected collation

doc/src/sgml/demodb-bookings-schema.svg

Lines changed: 225 additions & 277 deletions
Loading

doc/src/sgml/demodb-bookings.sgml

Lines changed: 272 additions & 156 deletions
Large diffs are not rendered by default.

doc/src/sgml/ref/pgupgrade.sgml

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -720,12 +720,30 @@ psql --username=postgres --file=script.sql postgres
720720
</para>
721721

722722
<para>
723-
When upgrading from <productname>Postgres Pro</> 9.6 or lower that
724-
uses indexes or constraints with non-default collations,
725-
<application>pg_upgrade</> generates separate SQL files with
726-
<command>REINDEX</command>/<command>VALIDATE</command> commands,
727-
respectively. You need to run these files to rebuild indexes
728-
and re-validate constraints.
723+
When performing an upgrade from <productname>Postgres Pro</> 9.6 or lower,
724+
for databases with a multibyte encoding, <application>pg_upgrade</> may
725+
generate SQL files with
726+
<command>REINDEX</command>/<command>VALIDATE</command> commands. You must
727+
run these files to rebuild indexes and re-validate constraints.
728+
This can happen in the following cases:
729+
<itemizedlist spacing="compact">
730+
<listitem>
731+
<para>
732+
The old cluster uses indexes or constraints depending on collations
733+
other than the default collation of the database, <literal>C</literal>,
734+
or <literal>POSIX</literal>.
735+
</para>
736+
</listitem>
737+
<listitem>
738+
<para>
739+
On Windows, the old cluster uses indexes or constraints depending on the
740+
default collation with a verbose name, such as
741+
<literal>"Russian_Russia[.<replaceable>encoding</replaceable>]"</literal>
742+
or <literal>"English_United
743+
States[.<replaceable>encoding</replaceable>]"</literal>.
744+
</para>
745+
</listitem>
746+
</itemizedlist>
729747
</para>
730748

731749
<para>

doc/src/sgml/release-pro-10.sgml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,18 @@
183183
If the previous <productname>Postgres Pro</productname> installation
184184
contained any indexes or constraints depending on collations
185185
other than the default collation of the database, <literal>C</literal>,
186-
or <literal>POSIX</literal>, such databases could contain some data
187-
that violated the specified constraints and made indexes inconsistent.
186+
or <literal>POSIX</literal> in databases with multibyte encodings,
187+
such databases could contain some data that violated the specified
188+
constraints and made indexes inconsistent. On Windows, this situation
189+
can also happen if the database with a multibyte encoding contained
190+
any indexes or constraints depending on the default collation with a
191+
verbose name, such as
192+
<literal>"Russian_Russia[.<replaceable>encoding</replaceable>]"</literal>
193+
or <literal>"English_United
194+
States[.<replaceable>encoding</replaceable>]"</literal>.
188195
In such cases, you can only use <application>pg_upgrade</application> to upgrade to
189196
<productname>Postgres Pro</productname> 10, as a dump/restore scenario may be impossible.
190-
To resolve such issues, <application>pg_upgrade</application> declares such indexes and
197+
To resolve these issues, <application>pg_upgrade</application> declares such indexes and
191198
constraints invalid and creates <filename>reindex_text_indexes.sql</filename>
192199
and <filename>validate_text_contraints.sql</filename>, respectively.
193200
</para>

src/backend/access/nbtree/nbtxlog.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,6 @@ btree_xlog_unlink_page(uint8 info, XLogReaderState *record)
10101010
_bt_pageinit(page, BufferGetPageSize(buffer));
10111011
pageop = (BTPageOpaque) PageGetSpecialPointer(page);
10121012

1013-
pageop->btpo1.btpo_prev = leftsib;
10141013
pageop->btpo_next = rightsib;
10151014
BTP_SET_XACT(pageop, xlrec->btpo_xact);
10161015
pageop->btpo_flags = BTP_DELETED;

src/backend/access/transam/twophase.c

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
#include "access/twophase_rmgr.h"
8585
#include "access/xact.h"
8686
#include "access/xlog.h"
87+
#include "access/xlog_internal.h"
8788
#include "access/xloginsert.h"
8889
#include "access/xlogutils.h"
8990
#include "access/xlogreader.h"
@@ -2414,3 +2415,106 @@ PrepareRedoRemove(TransactionId xid, bool giveWarning)
24142415

24152416
return;
24162417
}
2418+
2419+
Datum
2420+
pg_prepared_xact_status(PG_FUNCTION_ARGS)
2421+
{
2422+
char const* gid = text_to_cstring(PG_GETARG_TEXT_PP(0));
2423+
XLogRecord *record;
2424+
XLogReaderState *xlogreader;
2425+
char *errormsg;
2426+
XLogRecPtr start_lsn;
2427+
XLogRecPtr lsn;
2428+
char const* xact_status = "unknown";
2429+
bool done = false;
2430+
TimeLineID timeline;
2431+
TransactionId xid = InvalidTransactionId;
2432+
XLogRecPtr end_lsn = GetFlushRecPtr();
2433+
2434+
GetOldestRestartPoint(&start_lsn, &timeline);
2435+
2436+
xlogreader = XLogReaderAllocate(&read_local_xlog_page, NULL);
2437+
if (!xlogreader)
2438+
ereport(ERROR,
2439+
(errcode(ERRCODE_OUT_OF_MEMORY),
2440+
errmsg("out of memory"),
2441+
errdetail("Failed while allocating a WAL reading processor.")));
2442+
while (true)
2443+
{
2444+
lsn = start_lsn;
2445+
do
2446+
{
2447+
record = XLogReadRecord(xlogreader, lsn, &errormsg);
2448+
if (record == NULL)
2449+
break;
2450+
lsn = InvalidXLogRecPtr; /* continue after the record */
2451+
if (XLogRecGetRmid(xlogreader) == RM_XACT_ID)
2452+
{
2453+
uint32 info = XLogRecGetInfo(xlogreader);
2454+
switch (info & XLOG_XACT_OPMASK)
2455+
{
2456+
case XLOG_XACT_PREPARE:
2457+
{
2458+
TwoPhaseFileHeader *hdr = (TwoPhaseFileHeader *)XLogRecGetData(xlogreader);
2459+
char* xact_gid = (char*)hdr + MAXALIGN(sizeof(TwoPhaseFileHeader));
2460+
if (strcmp(xact_gid, gid) == 0)
2461+
{
2462+
xid = hdr->xid;
2463+
xact_status = "prepared";
2464+
}
2465+
break;
2466+
}
2467+
case XLOG_XACT_COMMIT_PREPARED:
2468+
{
2469+
xl_xact_commit *xlrec;
2470+
xl_xact_parsed_commit parsed;
2471+
2472+
xlrec = (xl_xact_commit *) XLogRecGetData(xlogreader);
2473+
ParseCommitRecord(info, xlrec, &parsed);
2474+
if (xid == parsed.twophase_xid)
2475+
{
2476+
Assert(TransactionIdIsValid(xid));
2477+
xact_status = "committed";
2478+
done = true;
2479+
}
2480+
break;
2481+
}
2482+
case XLOG_XACT_ABORT_PREPARED:
2483+
{
2484+
xl_xact_abort *xlrec;
2485+
xl_xact_parsed_abort parsed;
2486+
2487+
xlrec = (xl_xact_abort *) XLogRecGetData(xlogreader);
2488+
ParseAbortRecord(info, xlrec, &parsed);
2489+
if (xid == parsed.twophase_xid)
2490+
{
2491+
Assert(TransactionIdIsValid(xid));
2492+
xact_status = "aborted";
2493+
done = true;
2494+
}
2495+
break;
2496+
}
2497+
default:
2498+
break;
2499+
}
2500+
}
2501+
} while (!done && xlogreader->EndRecPtr < end_lsn);
2502+
2503+
if (done)
2504+
break;
2505+
2506+
end_lsn = start_lsn;
2507+
XLogSegNoOffsetToRecPtr(end_lsn/XLogSegSize, 0, start_lsn);
2508+
start_lsn = XLogFindNextRecord(xlogreader, start_lsn);
2509+
if (start_lsn == end_lsn)
2510+
{
2511+
if (end_lsn <= XLogSegSize)
2512+
break;
2513+
XLogSegNoOffsetToRecPtr(lsn/XLogSegSize-1, 0, start_lsn);
2514+
start_lsn = XLogFindNextRecord(xlogreader, start_lsn);
2515+
}
2516+
}
2517+
2518+
XLogReaderFree(xlogreader);
2519+
PG_RETURN_TEXT_P(cstring_to_text(xact_status));
2520+
}

src/backend/access/transam/xact.c

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1861,6 +1861,7 @@ typedef struct {
18611861
void *PredicateState;
18621862
void *StorageState;
18631863
struct TransInvalidationInfo* InvalidationInfo;
1864+
List *on_commit_actions;
18641865
} SuspendedTransactionState;
18651866

18661867
static int suspendedXactNum = 0;
@@ -2019,8 +2020,10 @@ CommitTransaction(void)
20192020
TransactionState s = CurrentTransactionState;
20202021
TransactionId latestXid;
20212022
bool is_parallel_worker;
2023+
bool is_autonomous_transaction;
20222024

20232025
is_parallel_worker = (s->blockState == TBLOCK_PARALLEL_INPROGRESS);
2026+
is_autonomous_transaction = getNestLevelATX() != 0;
20242027

20252028
/* Enforce parallel mode restrictions during parallel worker commit. */
20262029
if (is_parallel_worker)
@@ -2054,7 +2057,7 @@ CommitTransaction(void)
20542057
* If there weren't any, we are done ... otherwise loop back to check
20552058
* if they queued deferred triggers. Lather, rinse, repeat.
20562059
*/
2057-
if (!PreCommit_Portals(false))
2060+
if (is_autonomous_transaction || !PreCommit_Portals(false))
20582061
break;
20592062
}
20602063

@@ -2168,7 +2171,7 @@ CommitTransaction(void)
21682171
RESOURCE_RELEASE_BEFORE_LOCKS,
21692172
true, true);
21702173

2171-
if (getNestLevelATX() == 0)
2174+
if (!is_autonomous_transaction)
21722175
{
21732176
/* Check we've released all buffer pins */
21742177
AtEOXact_Buffers(true);
@@ -2188,7 +2191,10 @@ CommitTransaction(void)
21882191
xactHasRelcacheInvalidationMessages = HasRelcacheInvalidationMessages();
21892192
AtEOXact_Inval(true);
21902193

2191-
AtEOXact_MultiXact();
2194+
if (!is_autonomous_transaction)
2195+
{
2196+
AtEOXact_MultiXact();
2197+
}
21922198

21932199
ResourceOwnerRelease(TopTransactionResourceOwner,
21942200
RESOURCE_RELEASE_LOCKS,
@@ -2197,27 +2203,34 @@ CommitTransaction(void)
21972203
RESOURCE_RELEASE_AFTER_LOCKS,
21982204
true, true);
21992205

2200-
/*
2201-
* Likewise, dropping of files deleted during the transaction is best done
2202-
* after releasing relcache and buffer pins. (This is not strictly
2203-
* necessary during commit, since such pins should have been released
2204-
* already, but this ordering is definitely critical during abort.) Since
2205-
* this may take many seconds, also delay until after releasing locks.
2206-
* Other backends will observe the attendant catalog changes and not
2207-
* attempt to access affected files.
2208-
*/
2209-
smgrDoPendingDeletes(true);
2206+
if (!is_autonomous_transaction)
2207+
{
2208+
/*
2209+
* Likewise, dropping of files deleted during the transaction is best done
2210+
* after releasing relcache and buffer pins. (This is not strictly
2211+
* necessary during commit, since such pins should have been released
2212+
* already, but this ordering is definitely critical during abort.) Since
2213+
* this may take many seconds, also delay until after releasing locks.
2214+
* Other backends will observe the attendant catalog changes and not
2215+
* attempt to access affected files.
2216+
*/
2217+
smgrDoPendingDeletes(true);
2218+
}
22102219

22112220
AtCommit_Notify();
22122221
AtEOXact_GUC(true, s->gucNestLevel);
2213-
if (getNestLevelATX() == 0)
2222+
if (!is_autonomous_transaction)
2223+
{
22142224
AtEOXact_SPI(true);
2225+
}
22152226
AtEOXact_on_commit_actions(true);
22162227
AtEOXact_Namespace(true, is_parallel_worker);
2217-
AtEOXact_SMgr();
2218-
if (getNestLevelATX() == 0)
2228+
if (!is_autonomous_transaction)
2229+
{
2230+
AtEOXact_SMgr();
22192231
AtEOXact_Files();
2220-
AtEOXact_ComboCid();
2232+
AtEOXact_ComboCid();
2233+
}
22212234
AtEOXact_HashTables(true);
22222235
AtEOXact_PgStat(true);
22232236
AtEOXact_Snapshot(true, false);
@@ -2296,7 +2309,7 @@ PrepareTransaction(void)
22962309
* If there weren't any, we are done ... otherwise loop back to check
22972310
* if they queued deferred triggers. Lather, rinse, repeat.
22982311
*/
2299-
if (!PreCommit_Portals(true))
2312+
if (getNestLevelATX() != 0 || !PreCommit_Portals(true))
23002313
break;
23012314
}
23022315

@@ -3594,6 +3607,7 @@ void SuspendTransaction(void)
35943607

35953608
MOVELEFT(sus->vxid.backendId, MyProc->backendId, MyBackendId);
35963609
MOVELEFT(sus->vxid.localTransactionId, MyProc->lxid, GetNextLocalTransactionId());
3610+
MOVELEFT(sus->on_commit_actions, pg_on_commit_actions, NULL);
35973611

35983612
sus->PgStatState = PgStatSuspend();
35993613
sus->TriggerState = TriggerSuspend();
@@ -3669,6 +3683,8 @@ bool ResumeTransaction(void)
36693683

36703684
MyProc->backendId = sus->vxid.backendId;
36713685
MyProc->lxid = sus->vxid.localTransactionId;
3686+
3687+
pg_on_commit_actions = sus->on_commit_actions;
36723688
}
36733689

36743690
ResumePgXact(MyPgXact);

src/backend/access/transam/xlog.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "catalog/pg_database.h"
4343
#include "commands/tablespace.h"
4444
#include "commands/waitlsn.h"
45+
#include "common/edition.h"
4546
#include "common/controldata_utils.h"
4647
#include "miscadmin.h"
4748
#include "pgstat.h"
@@ -4421,6 +4422,8 @@ WriteControlFile(void)
44214422
Assert(sizeof(ControlFile->icu_version) == sizeof(UVersionInfo));
44224423
u_getVersion(ControlFile->icu_version);
44234424
#endif
4425+
CONTROLFILE_SET_OLDVERSION(ControlFile, 0);
4426+
CONTROLFILE_SET_OLDEDITION(ControlFile, PG_UNKNOWN);
44244427

44254428
/* Contents are protected with a CRC */
44264429
INIT_CRC32C(ControlFile->crc);

src/backend/access/transam/xlogreader.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,6 @@ ValidXLogPageHeader(XLogReaderState *state, XLogRecPtr recptr,
849849
return true;
850850
}
851851

852-
#ifdef FRONTEND
853852
/*
854853
* Functions that are currently not needed in the backend, but are better
855854
* implemented inside xlogreader.c because of the internal facilities available
@@ -974,8 +973,6 @@ XLogFindNextRecord(XLogReaderState *state, XLogRecPtr RecPtr)
974973
return found;
975974
}
976975

977-
#endif /* FRONTEND */
978-
979976

980977
/* ----------------------------------------
981978
* Functions for decoding the data and block references in a record.

0 commit comments

Comments
 (0)