Skip to content

Commit a44d1e9

Browse files
committed
Merge remote-tracking branch 'publicppg/master' into create_table_storage
2 parents 3e7fe52 + e68570e commit a44d1e9

File tree

13 files changed

+69
-145
lines changed

13 files changed

+69
-145
lines changed

src/backend/access/transam/xlog.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -10714,13 +10714,13 @@ xlog_block_info(StringInfo buf, XLogReaderState *record)
1071410714

1071510715
XLogRecGetBlockTag(record, block_id, &rnode, &forknum, &blk);
1071610716
if (forknum != MAIN_FORKNUM)
10717-
appendStringInfo(buf, "; blkref #%u: rel %u/%u/%u, fork %u, blk %u",
10717+
appendStringInfo(buf, "; blkref #%d: rel %u/%u/%u, fork %u, blk %u",
1071810718
block_id,
1071910719
rnode.spcNode, rnode.dbNode, rnode.relNode,
1072010720
forknum,
1072110721
blk);
1072210722
else
10723-
appendStringInfo(buf, "; blkref #%u: rel %u/%u/%u, blk %u",
10723+
appendStringInfo(buf, "; blkref #%d: rel %u/%u/%u, blk %u",
1072410724
block_id,
1072510725
rnode.spcNode, rnode.dbNode, rnode.relNode,
1072610726
blk);

src/backend/access/transam/xlogutils.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -985,14 +985,14 @@ WALReadRaiseError(WALReadError *errinfo)
985985
errno = errinfo->wre_errno;
986986
ereport(ERROR,
987987
(errcode_for_file_access(),
988-
errmsg("could not read from log segment %s, offset %u: %m",
988+
errmsg("could not read from log segment %s, offset %d: %m",
989989
fname, errinfo->wre_off)));
990990
}
991991
else if (errinfo->wre_read == 0)
992992
{
993993
ereport(ERROR,
994994
(errcode(ERRCODE_DATA_CORRUPTED),
995-
errmsg("could not read from log segment %s, offset %u: read %d of %d",
995+
errmsg("could not read from log segment %s, offset %d: read %d of %d",
996996
fname, errinfo->wre_off, errinfo->wre_read,
997997
errinfo->wre_req)));
998998
}

src/backend/commands/user.c

-11
Original file line numberDiff line numberDiff line change
@@ -1259,18 +1259,7 @@ GrantRole(GrantRoleStmt *stmt)
12591259
ListCell *item;
12601260

12611261
if (stmt->grantor)
1262-
{
12631262
grantor = get_rolespec_oid(stmt->grantor, false);
1264-
1265-
/*
1266-
* Currently, this clause is only for SQL compatibility, not very
1267-
* interesting otherwise.
1268-
*/
1269-
if (grantor != GetUserId())
1270-
ereport(ERROR,
1271-
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1272-
errmsg("grantor must be current user")));
1273-
}
12741263
else
12751264
grantor = GetUserId();
12761265

src/backend/parser/gram.y

-2
Original file line numberDiff line numberDiff line change
@@ -7290,7 +7290,6 @@ RevokeRoleStmt:
72907290
n->admin_opt = false;
72917291
n->granted_roles = $2;
72927292
n->grantee_roles = $4;
7293-
n->grantor = $5;
72947293
n->behavior = $6;
72957294
$$ = (Node*)n;
72967295
}
@@ -7301,7 +7300,6 @@ RevokeRoleStmt:
73017300
n->admin_opt = true;
73027301
n->granted_roles = $5;
73037302
n->grantee_roles = $7;
7304-
n->grantor = $8;
73057303
n->behavior = $9;
73067304
$$ = (Node*)n;
73077305
}

src/backend/postmaster/pgarch.c

+43-27
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,20 @@ static PgArchData *PgArch = NULL;
111111
* completes, the file names are stored in ascending order of priority in
112112
* arch_files. pgarch_readyXlog() returns files from arch_files until it
113113
* is empty, at which point another directory scan must be performed.
114+
*
115+
* We only need this data in the archiver process, so make it a palloc'd
116+
* struct rather than a bunch of static arrays.
114117
*/
115-
static binaryheap *arch_heap = NULL;
116-
static char arch_filenames[NUM_FILES_PER_DIRECTORY_SCAN][MAX_XFN_CHARS];
117-
static char *arch_files[NUM_FILES_PER_DIRECTORY_SCAN];
118-
static int arch_files_size = 0;
118+
struct arch_files_state
119+
{
120+
binaryheap *arch_heap;
121+
int arch_files_size; /* number of live entries in arch_files[] */
122+
char *arch_files[NUM_FILES_PER_DIRECTORY_SCAN];
123+
/* buffers underlying heap, and later arch_files[], entries: */
124+
char arch_filenames[NUM_FILES_PER_DIRECTORY_SCAN][MAX_XFN_CHARS + 1];
125+
};
126+
127+
static struct arch_files_state *arch_files = NULL;
119128

120129
/*
121130
* Flags set by interrupt handlers for later service in the main loop.
@@ -231,9 +240,13 @@ PgArchiverMain(void)
231240
*/
232241
PgArch->pgprocno = MyProc->pgprocno;
233242

243+
/* Create workspace for pgarch_readyXlog() */
244+
arch_files = palloc(sizeof(struct arch_files_state));
245+
arch_files->arch_files_size = 0;
246+
234247
/* Initialize our max-heap for prioritizing files to archive. */
235-
arch_heap = binaryheap_allocate(NUM_FILES_PER_DIRECTORY_SCAN,
236-
ready_file_comparator, NULL);
248+
arch_files->arch_heap = binaryheap_allocate(NUM_FILES_PER_DIRECTORY_SCAN,
249+
ready_file_comparator, NULL);
237250

238251
pgarch_MainLoop();
239252

@@ -363,7 +376,7 @@ pgarch_ArchiverCopyLoop(void)
363376
char xlog[MAX_XFN_CHARS + 1];
364377

365378
/* force directory scan in the first call to pgarch_readyXlog() */
366-
arch_files_size = 0;
379+
arch_files->arch_files_size = 0;
367380

368381
/*
369382
* loop through all xlogs with archive_status of .ready and archive
@@ -658,22 +671,22 @@ pgarch_readyXlog(char *xlog)
658671
SpinLockRelease(&PgArch->arch_lck);
659672

660673
if (force_dir_scan)
661-
arch_files_size = 0;
674+
arch_files->arch_files_size = 0;
662675

663676
/*
664677
* If we still have stored file names from the previous directory scan,
665678
* try to return one of those. We check to make sure the status file
666679
* is still present, as the archive_command for a previous file may
667680
* have already marked it done.
668681
*/
669-
while (arch_files_size > 0)
682+
while (arch_files->arch_files_size > 0)
670683
{
671684
struct stat st;
672685
char status_file[MAXPGPATH];
673686
char *arch_file;
674687

675-
arch_files_size--;
676-
arch_file = arch_files[arch_files_size];
688+
arch_files->arch_files_size--;
689+
arch_file = arch_files->arch_files[arch_files->arch_files_size];
677690
StatusFilePath(status_file, arch_file, ".ready");
678691

679692
if (stat(status_file, &st) == 0)
@@ -687,6 +700,9 @@ pgarch_readyXlog(char *xlog)
687700
errmsg("could not stat file \"%s\": %m", status_file)));
688701
}
689702

703+
/* arch_heap is probably empty, but let's make sure */
704+
binaryheap_reset(arch_files->arch_heap);
705+
690706
/*
691707
* Open the archive status directory and read through the list of files
692708
* with the .ready suffix, looking for the earliest files.
@@ -720,53 +736,53 @@ pgarch_readyXlog(char *xlog)
720736
/*
721737
* Store the file in our max-heap if it has a high enough priority.
722738
*/
723-
if (arch_heap->bh_size < NUM_FILES_PER_DIRECTORY_SCAN)
739+
if (arch_files->arch_heap->bh_size < NUM_FILES_PER_DIRECTORY_SCAN)
724740
{
725741
/* If the heap isn't full yet, quickly add it. */
726-
arch_file = arch_filenames[arch_heap->bh_size];
742+
arch_file = arch_files->arch_filenames[arch_files->arch_heap->bh_size];
727743
strcpy(arch_file, basename);
728-
binaryheap_add_unordered(arch_heap, CStringGetDatum(arch_file));
744+
binaryheap_add_unordered(arch_files->arch_heap, CStringGetDatum(arch_file));
729745

730746
/* If we just filled the heap, make it a valid one. */
731-
if (arch_heap->bh_size == NUM_FILES_PER_DIRECTORY_SCAN)
732-
binaryheap_build(arch_heap);
747+
if (arch_files->arch_heap->bh_size == NUM_FILES_PER_DIRECTORY_SCAN)
748+
binaryheap_build(arch_files->arch_heap);
733749
}
734-
else if (ready_file_comparator(binaryheap_first(arch_heap),
750+
else if (ready_file_comparator(binaryheap_first(arch_files->arch_heap),
735751
CStringGetDatum(basename), NULL) > 0)
736752
{
737753
/*
738754
* Remove the lowest priority file and add the current one to
739755
* the heap.
740756
*/
741-
arch_file = DatumGetCString(binaryheap_remove_first(arch_heap));
757+
arch_file = DatumGetCString(binaryheap_remove_first(arch_files->arch_heap));
742758
strcpy(arch_file, basename);
743-
binaryheap_add(arch_heap, CStringGetDatum(arch_file));
759+
binaryheap_add(arch_files->arch_heap, CStringGetDatum(arch_file));
744760
}
745761
}
746762
FreeDir(rldir);
747763

748764
/* If no files were found, simply return. */
749-
if (arch_heap->bh_size == 0)
765+
if (arch_files->arch_heap->bh_size == 0)
750766
return false;
751767

752768
/*
753769
* If we didn't fill the heap, we didn't make it a valid one. Do that
754770
* now.
755771
*/
756-
if (arch_heap->bh_size < NUM_FILES_PER_DIRECTORY_SCAN)
757-
binaryheap_build(arch_heap);
772+
if (arch_files->arch_heap->bh_size < NUM_FILES_PER_DIRECTORY_SCAN)
773+
binaryheap_build(arch_files->arch_heap);
758774

759775
/*
760776
* Fill arch_files array with the files to archive in ascending order
761777
* of priority.
762778
*/
763-
arch_files_size = arch_heap->bh_size;
764-
for (int i = 0; i < arch_files_size; i++)
765-
arch_files[i] = DatumGetCString(binaryheap_remove_first(arch_heap));
779+
arch_files->arch_files_size = arch_files->arch_heap->bh_size;
780+
for (int i = 0; i < arch_files->arch_files_size; i++)
781+
arch_files->arch_files[i] = DatumGetCString(binaryheap_remove_first(arch_files->arch_heap));
766782

767783
/* Return the highest priority file. */
768-
arch_files_size--;
769-
strcpy(xlog, arch_files[arch_files_size]);
784+
arch_files->arch_files_size--;
785+
strcpy(xlog, arch_files->arch_files[arch_files->arch_files_size]);
770786

771787
return true;
772788
}

src/backend/utils/misc/guc.c

+1-48
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,6 @@ static bool check_recovery_target_lsn(char **newval, void **extra, GucSource sou
235235
static void assign_recovery_target_lsn(const char *newval, void *extra);
236236
static bool check_primary_slot_name(char **newval, void **extra, GucSource source);
237237
static bool check_default_with_oids(bool *newval, void **extra, GucSource source);
238-
static void check_reserved_prefixes(const char *varName);
239-
static List *reserved_class_prefix = NIL;
240238

241239
/* Private functions in guc-file.l that need to be called from guc.c */
242240
static ConfigVariable *ProcessConfigFileInternal(GucContext context,
@@ -8764,7 +8762,6 @@ ExecSetVariableStmt(VariableSetStmt *stmt, bool isTopLevel)
87648762
(superuser() ? PGC_SUSET : PGC_USERSET),
87658763
PGC_S_SESSION,
87668764
action, true, 0, false);
8767-
check_reserved_prefixes(stmt->name);
87688765
break;
87698766
case VAR_SET_MULTI:
87708767

@@ -8850,8 +8847,6 @@ ExecSetVariableStmt(VariableSetStmt *stmt, bool isTopLevel)
88508847
(superuser() ? PGC_SUSET : PGC_USERSET),
88518848
PGC_S_SESSION,
88528849
action, true, 0, false);
8853-
8854-
check_reserved_prefixes(stmt->name);
88558850
break;
88568851
case VAR_RESET_ALL:
88578852
ResetAllOptions();
@@ -9338,14 +9333,13 @@ DefineCustomEnumVariable(const char *name,
93389333

93399334
/*
93409335
* Extensions should call this after they've defined all of their custom
9341-
* GUCs, to help catch misspelled config-file entries,
9336+
* GUCs, to help catch misspelled config-file entries.
93429337
*/
93439338
void
93449339
EmitWarningsOnPlaceholders(const char *className)
93459340
{
93469341
int classLen = strlen(className);
93479342
int i;
9348-
MemoryContext oldcontext;
93499343

93509344
for (i = 0; i < num_guc_variables; i++)
93519345
{
@@ -9361,49 +9355,8 @@ EmitWarningsOnPlaceholders(const char *className)
93619355
var->name)));
93629356
}
93639357
}
9364-
9365-
oldcontext = MemoryContextSwitchTo(TopMemoryContext);
9366-
reserved_class_prefix = lappend(reserved_class_prefix, pstrdup(className));
9367-
MemoryContextSwitchTo(oldcontext);
93689358
}
93699359

9370-
/*
9371-
* Check a setting name against prefixes previously reserved by
9372-
* EmitWarningsOnPlaceholders() and throw a warning if matching.
9373-
*/
9374-
static void
9375-
check_reserved_prefixes(const char *varName)
9376-
{
9377-
char *sep = strchr(varName, GUC_QUALIFIER_SEPARATOR);
9378-
9379-
if (sep)
9380-
{
9381-
size_t classLen = sep - varName;
9382-
ListCell *lc;
9383-
9384-
foreach(lc, reserved_class_prefix)
9385-
{
9386-
char *rcprefix = lfirst(lc);
9387-
9388-
if (strncmp(varName, rcprefix, classLen) == 0)
9389-
{
9390-
for (int i = 0; i < num_guc_variables; i++)
9391-
{
9392-
struct config_generic *var = guc_variables[i];
9393-
9394-
if ((var->flags & GUC_CUSTOM_PLACEHOLDER) != 0 &&
9395-
strcmp(varName, var->name) == 0)
9396-
{
9397-
ereport(WARNING,
9398-
(errcode(ERRCODE_UNDEFINED_OBJECT),
9399-
errmsg("unrecognized configuration parameter \"%s\"", var->name),
9400-
errdetail("\"%.*s\" is a reserved prefix.", (int) classLen, var->name)));
9401-
}
9402-
}
9403-
}
9404-
}
9405-
}
9406-
}
94079360

94089361
/*
94099362
* SHOW command

src/backend/utils/misc/pg_controldata.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ pg_control_system(PG_FUNCTION_ARGS)
7979
Datum
8080
pg_control_checkpoint(PG_FUNCTION_ARGS)
8181
{
82-
Datum values[19];
83-
bool nulls[19];
82+
Datum values[18];
83+
bool nulls[18];
8484
TupleDesc tupdesc;
8585
HeapTuple htup;
8686
ControlFileData *ControlFile;

src/bin/pg_waldump/pg_waldump.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -382,11 +382,11 @@ WALDumpReadPage(XLogReaderState *state, XLogRecPtr targetPagePtr, int reqLen,
382382
if (errinfo.wre_errno != 0)
383383
{
384384
errno = errinfo.wre_errno;
385-
fatal_error("could not read from file %s, offset %u: %m",
385+
fatal_error("could not read from file %s, offset %d: %m",
386386
fname, errinfo.wre_off);
387387
}
388388
else
389-
fatal_error("could not read from file %s, offset %u: read %d of %d",
389+
fatal_error("could not read from file %s, offset %d: read %d of %d",
390390
fname, errinfo.wre_off, errinfo.wre_read,
391391
errinfo.wre_req);
392392
}
@@ -518,13 +518,13 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record)
518518

519519
XLogRecGetBlockTag(record, block_id, &rnode, &forknum, &blk);
520520
if (forknum != MAIN_FORKNUM)
521-
printf(", blkref #%u: rel %u/%u/%u fork %s blk %u",
521+
printf(", blkref #%d: rel %u/%u/%u fork %s blk %u",
522522
block_id,
523523
rnode.spcNode, rnode.dbNode, rnode.relNode,
524524
forkNames[forknum],
525525
blk);
526526
else
527-
printf(", blkref #%u: rel %u/%u/%u blk %u",
527+
printf(", blkref #%d: rel %u/%u/%u blk %u",
528528
block_id,
529529
rnode.spcNode, rnode.dbNode, rnode.relNode,
530530
blk);
@@ -548,7 +548,7 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record)
548548
continue;
549549

550550
XLogRecGetBlockTag(record, block_id, &rnode, &forknum, &blk);
551-
printf("\tblkref #%u: rel %u/%u/%u fork %s blk %u",
551+
printf("\tblkref #%d: rel %u/%u/%u fork %s blk %u",
552552
block_id,
553553
rnode.spcNode, rnode.dbNode, rnode.relNode,
554554
forkNames[forknum],
@@ -943,7 +943,7 @@ main(int argc, char **argv)
943943
private.startptr = (uint64) xlogid << 32 | xrecoff;
944944
break;
945945
case 't':
946-
if (sscanf(optarg, "%d", &private.timeline) != 1)
946+
if (sscanf(optarg, "%u", &private.timeline) != 1)
947947
{
948948
pg_log_error("could not parse timeline \"%s\"", optarg);
949949
goto bad_argument;

src/test/regress/expected/guc.out

-19
Original file line numberDiff line numberDiff line change
@@ -813,22 +813,3 @@ set default_with_oids to f;
813813
-- Should not allow to set it to true.
814814
set default_with_oids to t;
815815
ERROR: tables declared WITH OIDS are not supported
816-
-- test SET unrecognized parameter
817-
SET foo = false; -- no such setting
818-
ERROR: unrecognized configuration parameter "foo"
819-
-- test setting a parameter with a registered prefix (plpgsql)
820-
SET plpgsql.extra_foo_warnings = false; -- no such setting
821-
WARNING: unrecognized configuration parameter "plpgsql.extra_foo_warnings"
822-
DETAIL: "plpgsql" is a reserved prefix.
823-
SHOW plpgsql.extra_foo_warnings; -- but the parameter is set
824-
plpgsql.extra_foo_warnings
825-
----------------------------
826-
false
827-
(1 row)
828-
829-
-- cleanup
830-
RESET foo;
831-
ERROR: unrecognized configuration parameter "foo"
832-
RESET plpgsql.extra_foo_warnings;
833-
WARNING: unrecognized configuration parameter "plpgsql.extra_foo_warnings"
834-
DETAIL: "plpgsql" is a reserved prefix.

0 commit comments

Comments
 (0)