Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdbffe5f

Browse files
committed
Merge branch 'REL9_5_STABLE' into PGPRO9_5
2 parents6b894fc +e12b83a commitdbffe5f

File tree

14 files changed

+109
-51
lines changed

14 files changed

+109
-51
lines changed

‎doc/src/sgml/func.sgml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15347,6 +15347,21 @@ SET search_path TO <replaceable>schema</> <optional>, <replaceable>schema</>, ..
1534715347
<entry><type>boolean</type></entry>
1534815348
<entry>does current user have privilege for tablespace</entry>
1534915349
</row>
15350+
<row>
15351+
<entry><literal><function>has_type_privilege</function>(<parameter>user</parameter>,
15352+
<parameter>type</parameter>,
15353+
<parameter>privilege</parameter>)</literal>
15354+
</entry>
15355+
<entry><type>boolean</type></entry>
15356+
<entry>does user have privilege for type</entry>
15357+
</row>
15358+
<row>
15359+
<entry><literal><function>has_type_privilege</function>(<parameter>type</parameter>,
15360+
<parameter>privilege</parameter>)</literal>
15361+
</entry>
15362+
<entry><type>boolean</type></entry>
15363+
<entry>does current user have privilege for type</entry>
15364+
</row>
1535015365
<row>
1535115366
<entry><literal><function>pg_has_role</function>(<parameter>user</parameter>,
1535215367
<parameter>role</parameter>,
@@ -15405,6 +15420,9 @@ SET search_path TO <replaceable>schema</> <optional>, <replaceable>schema</>, ..
1540515420
<indexterm>
1540615421
<primary>has_tablespace_privilege</primary>
1540715422
</indexterm>
15423+
<indexterm>
15424+
<primary>has_type_privilege</primary>
15425+
</indexterm>
1540815426
<indexterm>
1540915427
<primary>pg_has_role</primary>
1541015428
</indexterm>
@@ -15559,6 +15577,18 @@ SELECT has_function_privilege('joeuser', 'myfunc(int, text)', 'execute');
1555915577
<literal>CREATE</literal>.
1556015578
</para>
1556115579

15580+
<para>
15581+
<function>has_type_privilege</function> checks whether a user
15582+
can access a type in a particular way.
15583+
Its argument possibilities
15584+
are analogous to <function>has_table_privilege</function>.
15585+
When specifying a type by a text string rather than by OID,
15586+
the allowed input is the same as for the <type>regtype</> data type
15587+
(see <xref linkend="datatype-oid">).
15588+
The desired access privilege type must evaluate to
15589+
<literal>USAGE</literal>.
15590+
</para>
15591+
1556215592
<para>
1556315593
<function>pg_has_role</function> checks whether a user
1556415594
can access a role in a particular way.

‎src/backend/catalog/objectaddress.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2237,23 +2237,18 @@ get_object_namespace(const ObjectAddress *address)
22372237
int
22382238
read_objtype_from_string(constchar*objtype)
22392239
{
2240-
ObjectTypetype;
22412240
inti;
22422241

22432242
for (i=0;i<lengthof(ObjectTypeMap);i++)
22442243
{
22452244
if (strcmp(ObjectTypeMap[i].tm_name,objtype)==0)
2246-
{
2247-
type=ObjectTypeMap[i].tm_type;
2248-
break;
2249-
}
2245+
returnObjectTypeMap[i].tm_type;
22502246
}
2251-
if (i >=lengthof(ObjectTypeMap))
2252-
ereport(ERROR,
2253-
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2254-
errmsg("unrecognized object type \"%s\"",objtype)));
2247+
ereport(ERROR,
2248+
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2249+
errmsg("unrecognized object type \"%s\"",objtype)));
22552250

2256-
returntype;
2251+
return-1;/* keep compiler quiet */
22572252
}
22582253

22592254
/*

‎src/backend/libpq/auth.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
#include<netinet/in.h>
2121
#include<arpa/inet.h>
2222
#include<unistd.h>
23+
#ifdefHAVE_SYS_SELECT_H
24+
#include<sys/select.h>
25+
#endif
2326

2427
#include"libpq/auth.h"
2528
#include"libpq/crypt.h"

‎src/backend/postmaster/pgstat.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
#include<arpa/inet.h>
2929
#include<signal.h>
3030
#include<time.h>
31+
#ifdefHAVE_SYS_SELECT_H
32+
#include<sys/select.h>
33+
#endif
3134

3235
#include"pgstat.h"
3336

‎src/backend/postmaster/postmaster.c

Lines changed: 18 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4618,10 +4618,17 @@ SubPostmasterMain(int argc, char *argv[])
46184618
/* Setup essential subsystems (to ensure elog() behaves sanely) */
46194619
InitializeGUCOptions();
46204620

4621+
/* Check we got appropriate args */
4622+
if (argc<3)
4623+
elog(FATAL,"invalid subpostmaster invocation");
4624+
46214625
/* Read in the variables file */
46224626
memset(&port,0,sizeof(Port));
46234627
read_backend_variables(argv[2],&port);
46244628

4629+
/* Close the postmaster's sockets (as soon as we know them) */
4630+
ClosePostmasterPorts(strcmp(argv[1],"--forklog")==0);
4631+
46254632
/*
46264633
* Set reference point for stack-depth checking
46274634
*/
@@ -4639,15 +4646,21 @@ SubPostmasterMain(int argc, char *argv[])
46394646
errmsg("out of memory")));
46404647
#endif
46414648

4642-
/* Check we got appropriate args */
4643-
if (argc<3)
4644-
elog(FATAL,"invalid subpostmaster invocation");
4645-
46464649
/*
46474650
* If appropriate, physically re-attach to shared memory segment. We want
46484651
* to do this before going any further to ensure that we can attach at the
46494652
* same address the postmaster used. On the other hand, if we choose not
46504653
* to re-attach, we may have other cleanup to do.
4654+
*
4655+
* If testing EXEC_BACKEND on Linux, you should run this as root before
4656+
* starting the postmaster:
4657+
*
4658+
* echo 0 >/proc/sys/kernel/randomize_va_space
4659+
*
4660+
* This prevents using randomized stack and code addresses that cause the
4661+
* child process's memory map to be different from the parent's, making it
4662+
* sometimes impossible to attach to shared memory at the desired address.
4663+
* Return the setting to its old value (usually '1' or '2') when finished.
46514664
*/
46524665
if (strcmp(argv[1],"--forkbackend")==0||
46534666
strcmp(argv[1],"--forkavlauncher")==0||
@@ -4693,9 +4706,6 @@ SubPostmasterMain(int argc, char *argv[])
46934706
{
46944707
Assert(argc==3);/* shouldn't be any more args */
46954708

4696-
/* Close the postmaster's sockets */
4697-
ClosePostmasterPorts(false);
4698-
46994709
/*
47004710
* Need to reinitialize the SSL library in the backend, since the
47014711
* context structures contain function pointers and cannot be passed
@@ -4726,27 +4736,14 @@ SubPostmasterMain(int argc, char *argv[])
47264736
/* Need a PGPROC to run CreateSharedMemoryAndSemaphores */
47274737
InitProcess();
47284738

4729-
/*
4730-
* Attach process to shared data structures. If testing EXEC_BACKEND
4731-
* on Linux, you must run this as root before starting the postmaster:
4732-
*
4733-
* echo 0 >/proc/sys/kernel/randomize_va_space
4734-
*
4735-
* This prevents a randomized stack base address that causes child
4736-
* shared memory to be at a different address than the parent, making
4737-
* it impossible to attached to shared memory. Return the value to
4738-
* '1' when finished.
4739-
*/
4739+
/* Attach process to shared data structures */
47404740
CreateSharedMemoryAndSemaphores(false,0);
47414741

47424742
/* And run the backend */
47434743
BackendRun(&port);/* does not return */
47444744
}
47454745
if (strcmp(argv[1],"--forkboot")==0)
47464746
{
4747-
/* Close the postmaster's sockets */
4748-
ClosePostmasterPorts(false);
4749-
47504747
/* Restore basic shared memory pointers */
47514748
InitShmemAccess(UsedShmemSegAddr);
47524749

@@ -4760,9 +4757,6 @@ SubPostmasterMain(int argc, char *argv[])
47604757
}
47614758
if (strcmp(argv[1],"--forkavlauncher")==0)
47624759
{
4763-
/* Close the postmaster's sockets */
4764-
ClosePostmasterPorts(false);
4765-
47664760
/* Restore basic shared memory pointers */
47674761
InitShmemAccess(UsedShmemSegAddr);
47684762

@@ -4776,9 +4770,6 @@ SubPostmasterMain(int argc, char *argv[])
47764770
}
47774771
if (strcmp(argv[1],"--forkavworker")==0)
47784772
{
4779-
/* Close the postmaster's sockets */
4780-
ClosePostmasterPorts(false);
4781-
47824773
/* Restore basic shared memory pointers */
47834774
InitShmemAccess(UsedShmemSegAddr);
47844775

@@ -4797,9 +4788,6 @@ SubPostmasterMain(int argc, char *argv[])
47974788
/* do this as early as possible; in particular, before InitProcess() */
47984789
IsBackgroundWorker= true;
47994790

4800-
/* Close the postmaster's sockets */
4801-
ClosePostmasterPorts(false);
4802-
48034791
/* Restore basic shared memory pointers */
48044792
InitShmemAccess(UsedShmemSegAddr);
48054793

@@ -4817,27 +4805,18 @@ SubPostmasterMain(int argc, char *argv[])
48174805
}
48184806
if (strcmp(argv[1],"--forkarch")==0)
48194807
{
4820-
/* Close the postmaster's sockets */
4821-
ClosePostmasterPorts(false);
4822-
48234808
/* Do not want to attach to shared memory */
48244809

48254810
PgArchiverMain(argc,argv);/* does not return */
48264811
}
48274812
if (strcmp(argv[1],"--forkcol")==0)
48284813
{
4829-
/* Close the postmaster's sockets */
4830-
ClosePostmasterPorts(false);
4831-
48324814
/* Do not want to attach to shared memory */
48334815

48344816
PgstatCollectorMain(argc,argv);/* does not return */
48354817
}
48364818
if (strcmp(argv[1],"--forklog")==0)
48374819
{
4838-
/* Close the postmaster's sockets */
4839-
ClosePostmasterPorts(true);
4840-
48414820
/* Do not want to attach to shared memory */
48424821

48434822
SysLoggerMain(argc,argv);/* does not return */

‎src/bin/pg_basebackup/pg_basebackup.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
#include<sys/wait.h>
2121
#include<signal.h>
2222
#include<time.h>
23-
23+
#ifdefHAVE_SYS_SELECT_H
24+
#include<sys/select.h>
25+
#endif
2426
#ifdefHAVE_LIBZ
2527
#include<zlib.h>
2628
#endif

‎src/bin/pg_basebackup/pg_recvlogical.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
#include<dirent.h>
1616
#include<sys/stat.h>
1717
#include<unistd.h>
18+
#ifdefHAVE_SYS_SELECT_H
19+
#include<sys/select.h>
20+
#endif
1821

1922
/* local includes */
2023
#include"streamutil.h"

‎src/bin/pg_basebackup/receivelog.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
#include<sys/stat.h>
1818
#include<unistd.h>
19+
#ifdefHAVE_SYS_SELECT_H
20+
#include<sys/select.h>
21+
#endif
1922

2023
/* local includes */
2124
#include"receivelog.h"

‎src/bin/pg_dump/parallel.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@
5959

6060
#include"postgres_fe.h"
6161

62+
#ifdefHAVE_SYS_SELECT_H
63+
#include<sys/select.h>
64+
#endif
65+
6266
#include"parallel.h"
6367
#include"pg_backup_utils.h"
6468

‎src/bin/pg_xlogdump/pg_xlogdump.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ XLogDumpXLogRead(const char *directory, TimeLineID timeline_id,
249249
if (sendFile<0|| !XLByteInSeg(recptr,sendSegNo))
250250
{
251251
charfname[MAXFNAMELEN];
252+
inttries;
252253

253254
/* Switch to another logfile segment */
254255
if (sendFile >=0)
@@ -258,7 +259,30 @@ XLogDumpXLogRead(const char *directory, TimeLineID timeline_id,
258259

259260
XLogFileName(fname,timeline_id,sendSegNo);
260261

261-
sendFile=fuzzy_open_file(directory,fname);
262+
/*
263+
* In follow mode there is a short period of time after the
264+
* server has written the end of the previous file before the
265+
* new file is available. So we loop for 5 seconds looking
266+
* for the file to appear before giving up.
267+
*/
268+
for (tries=0;tries<10;tries++)
269+
{
270+
sendFile=fuzzy_open_file(directory,fname);
271+
if (sendFile >=0)
272+
break;
273+
if (errno==ENOENT)
274+
{
275+
intsave_errno=errno;
276+
277+
/* File not there yet, try again */
278+
pg_usleep(500*1000);
279+
280+
errno=save_errno;
281+
continue;
282+
}
283+
/* Any other error, fall through and fail */
284+
break;
285+
}
262286

263287
if (sendFile<0)
264288
fatal_error("could not find file \"%s\": %s",

‎src/bin/scripts/vacuumdb.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212

1313
#include"postgres_fe.h"
1414

15+
#ifdefHAVE_SYS_SELECT_H
16+
#include<sys/select.h>
17+
#endif
18+
1519
#include"common.h"
1620
#include"dumputils.h"
1721

‎src/port/pgsleep.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
#include<unistd.h>
1616
#include<sys/time.h>
17+
#ifdefHAVE_SYS_SELECT_H
18+
#include<sys/select.h>
19+
#endif
1720

1821
/*
1922
* In a Windows backend, we don't use this implementation, but rather

‎src/test/examples/testlibpq2.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
#include<errno.h>
3535
#include<sys/time.h>
3636
#include<sys/types.h>
37+
#ifdefHAVE_SYS_SELECT_H
38+
#include<sys/select.h>
39+
#endif
40+
3741
#include"libpq-fe.h"
3842

3943
staticvoid

‎src/test/modules/worker_spi/worker_spi.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ worker_spi_main(Datum main_arg)
292292
SPI_finish();
293293
PopActiveSnapshot();
294294
CommitTransactionCommand();
295+
pgstat_report_stat(false);
295296
pgstat_report_activity(STATE_IDLE,NULL);
296297
}
297298

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp