Skip to content

Commit e3a16c5

Browse files
committed
Merge branch 'master' into logical_twophase_regresstest
2 parents 60ef2ba + ea69a0d commit e3a16c5

File tree

295 files changed

+9625
-3258
lines changed

Some content is hidden

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

295 files changed

+9625
-3258
lines changed

config/c-compiler.m4

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,33 @@ fi])# PGAC_C_STATIC_ASSERT
178178

179179

180180

181+
# PGAC_C_TYPEOF
182+
# -------------
183+
# Check if the C compiler understands typeof or a variant. Define
184+
# HAVE_TYPEOF if so, and define 'typeof' to the actual key word.
185+
#
186+
AC_DEFUN([PGAC_C_TYPEOF],
187+
[AC_CACHE_CHECK(for typeof, pgac_cv_c_typeof,
188+
[pgac_cv_c_typeof=no
189+
for pgac_kw in typeof __typeof__ decltype; do
190+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
191+
[int x = 0;
192+
$pgac_kw(x) y;
193+
y = x;
194+
return y;])],
195+
[pgac_cv_c_typeof=$pgac_kw])
196+
test "$pgac_cv_c_typeof" != no && break
197+
done])
198+
if test "$pgac_cv_c_typeof" != no; then
199+
AC_DEFINE(HAVE_TYPEOF, 1,
200+
[Define to 1 if your compiler understands `typeof' or something similar.])
201+
if test "$pgac_cv_c_typeof" != typeof; then
202+
AC_DEFINE_UNQUOTED(typeof, $pgac_cv_c_typeof, [Define to how the compiler spells `typeof'.])
203+
fi
204+
fi])# PGAC_C_TYPEOF
205+
206+
207+
181208
# PGAC_C_TYPES_COMPATIBLE
182209
# -----------------------
183210
# Check if the C compiler understands __builtin_types_compatible_p,

configure

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11667,6 +11667,48 @@ if test x"$pgac_cv__static_assert" = xyes ; then
1166711667

1166811668
$as_echo "#define HAVE__STATIC_ASSERT 1" >>confdefs.h
1166911669

11670+
fi
11671+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for typeof" >&5
11672+
$as_echo_n "checking for typeof... " >&6; }
11673+
if ${pgac_cv_c_typeof+:} false; then :
11674+
$as_echo_n "(cached) " >&6
11675+
else
11676+
pgac_cv_c_typeof=no
11677+
for pgac_kw in typeof __typeof__ decltype; do
11678+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
11679+
/* end confdefs.h. */
11680+
11681+
int
11682+
main ()
11683+
{
11684+
int x = 0;
11685+
$pgac_kw(x) y;
11686+
y = x;
11687+
return y;
11688+
;
11689+
return 0;
11690+
}
11691+
_ACEOF
11692+
if ac_fn_c_try_compile "$LINENO"; then :
11693+
pgac_cv_c_typeof=$pgac_kw
11694+
fi
11695+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
11696+
test "$pgac_cv_c_typeof" != no && break
11697+
done
11698+
fi
11699+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_c_typeof" >&5
11700+
$as_echo "$pgac_cv_c_typeof" >&6; }
11701+
if test "$pgac_cv_c_typeof" != no; then
11702+
11703+
$as_echo "#define HAVE_TYPEOF 1" >>confdefs.h
11704+
11705+
if test "$pgac_cv_c_typeof" != typeof; then
11706+
11707+
cat >>confdefs.h <<_ACEOF
11708+
#define typeof $pgac_cv_c_typeof
11709+
_ACEOF
11710+
11711+
fi
1167011712
fi
1167111713
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_types_compatible_p" >&5
1167211714
$as_echo_n "checking for __builtin_types_compatible_p... " >&6; }

configure.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,6 +1330,7 @@ AC_C_FLEXIBLE_ARRAY_MEMBER
13301330
PGAC_C_SIGNED
13311331
PGAC_C_FUNCNAME_SUPPORT
13321332
PGAC_C_STATIC_ASSERT
1333+
PGAC_C_TYPEOF
13331334
PGAC_C_TYPES_COMPATIBLE
13341335
PGAC_C_BUILTIN_BSWAP32
13351336
PGAC_C_BUILTIN_BSWAP64

contrib/dblink/dblink.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -687,23 +687,25 @@ dblink_record_internal(FunctionCallInfo fcinfo, bool is_async)
687687
if (PG_NARGS() == 3)
688688
{
689689
/* text,text,bool */
690-
dblink_get_conn(text_to_cstring(PG_GETARG_TEXT_PP(0)), &conn, &conname, &freeconn);
690+
conname = text_to_cstring(PG_GETARG_TEXT_PP(0));
691691
sql = text_to_cstring(PG_GETARG_TEXT_PP(1));
692692
fail = PG_GETARG_BOOL(2);
693+
dblink_get_conn(conname, &conn, &conname, &freeconn);
693694
}
694695
else if (PG_NARGS() == 2)
695696
{
696697
/* text,text or text,bool */
697698
if (get_fn_expr_argtype(fcinfo->flinfo, 1) == BOOLOID)
698699
{
699-
conn = pconn->conn;
700700
sql = text_to_cstring(PG_GETARG_TEXT_PP(0));
701701
fail = PG_GETARG_BOOL(1);
702+
conn = pconn->conn;
702703
}
703704
else
704705
{
705-
dblink_get_conn(text_to_cstring(PG_GETARG_TEXT_PP(0)), &conn, &conname, &freeconn);
706+
conname = text_to_cstring(PG_GETARG_TEXT_PP(0));
706707
sql = text_to_cstring(PG_GETARG_TEXT_PP(1));
708+
dblink_get_conn(conname, &conn, &conname, &freeconn);
707709
}
708710
}
709711
else if (PG_NARGS() == 1)
@@ -719,16 +721,18 @@ dblink_record_internal(FunctionCallInfo fcinfo, bool is_async)
719721
else /* is_async */
720722
{
721723
/* get async result */
724+
conname = text_to_cstring(PG_GETARG_TEXT_PP(0));
725+
722726
if (PG_NARGS() == 2)
723727
{
724728
/* text,bool */
725-
conn = dblink_get_named_conn(text_to_cstring(PG_GETARG_TEXT_PP(0)));
726729
fail = PG_GETARG_BOOL(1);
730+
conn = dblink_get_named_conn(conname);
727731
}
728732
else if (PG_NARGS() == 1)
729733
{
730734
/* text */
731-
conn = dblink_get_named_conn(text_to_cstring(PG_GETARG_TEXT_PP(0)));
735+
conn = dblink_get_named_conn(conname);
732736
}
733737
else
734738
/* shouldn't happen */
@@ -1390,23 +1394,25 @@ dblink_exec(PG_FUNCTION_ARGS)
13901394
if (PG_NARGS() == 3)
13911395
{
13921396
/* must be text,text,bool */
1393-
dblink_get_conn(text_to_cstring(PG_GETARG_TEXT_PP(0)), &conn, &conname, &freeconn);
1397+
conname = text_to_cstring(PG_GETARG_TEXT_PP(0));
13941398
sql = text_to_cstring(PG_GETARG_TEXT_PP(1));
13951399
fail = PG_GETARG_BOOL(2);
1400+
dblink_get_conn(conname, &conn, &conname, &freeconn);
13961401
}
13971402
else if (PG_NARGS() == 2)
13981403
{
13991404
/* might be text,text or text,bool */
14001405
if (get_fn_expr_argtype(fcinfo->flinfo, 1) == BOOLOID)
14011406
{
1402-
conn = pconn->conn;
14031407
sql = text_to_cstring(PG_GETARG_TEXT_PP(0));
14041408
fail = PG_GETARG_BOOL(1);
1409+
conn = pconn->conn;
14051410
}
14061411
else
14071412
{
1408-
dblink_get_conn(text_to_cstring(PG_GETARG_TEXT_PP(0)), &conn, &conname, &freeconn);
1413+
conname = text_to_cstring(PG_GETARG_TEXT_PP(0));
14091414
sql = text_to_cstring(PG_GETARG_TEXT_PP(1));
1415+
dblink_get_conn(conname, &conn, &conname, &freeconn);
14101416
}
14111417
}
14121418
else if (PG_NARGS() == 1)

contrib/earthdistance/earthdistance.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,8 @@ geo_distance_internal(Point *pt1, Point *pt2)
8888
*
8989
* returns: float8
9090
* distance between the points in miles on earth's surface
91-
*
92-
* If float8 is passed-by-value, the oldstyle version-0 calling convention
93-
* is unportable, so we use version-1. However, if it's passed-by-reference,
94-
* continue to use oldstyle. This is just because we'd like earthdistance
95-
* to serve as a canary for any unintentional breakage of version-0 functions
96-
* with float8 results.
9791
******************************************************/
9892

99-
#ifdef USE_FLOAT8_BYVAL
100-
10193
PG_FUNCTION_INFO_V1(geo_distance);
10294

10395
Datum
@@ -110,17 +102,3 @@ geo_distance(PG_FUNCTION_ARGS)
110102
result = geo_distance_internal(pt1, pt2);
111103
PG_RETURN_FLOAT8(result);
112104
}
113-
#else /* !USE_FLOAT8_BYVAL */
114-
115-
double *geo_distance(Point *pt1, Point *pt2);
116-
117-
double *
118-
geo_distance(Point *pt1, Point *pt2)
119-
{
120-
double *resultp = palloc(sizeof(double));
121-
122-
*resultp = geo_distance_internal(pt1, pt2);
123-
return resultp;
124-
}
125-
126-
#endif /* USE_FLOAT8_BYVAL */

contrib/pageinspect/btreefuncs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,8 @@ bt_page_items(PG_FUNCTION_ARGS)
363363
j = 0;
364364
values[j++] = psprintf("%d", uargs->offset);
365365
values[j++] = psprintf("(%u,%u)",
366-
BlockIdGetBlockNumber(&(itup->t_tid.ip_blkid)),
367-
itup->t_tid.ip_posid);
366+
ItemPointerGetBlockNumberNoCheck(&itup->t_tid),
367+
ItemPointerGetOffsetNumberNoCheck(&itup->t_tid));
368368
values[j++] = psprintf("%d", (int) IndexTupleSize(itup));
369369
values[j++] = psprintf("%c", IndexTupleHasNulls(itup) ? 't' : 'f');
370370
values[j++] = psprintf("%c", IndexTupleHasVarwidths(itup) ? 't' : 'f');

contrib/pageinspect/expected/hash.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ lowmask, ovflpoint, firstfree, nmaps, procid, spares, mapp FROM
4545
hash_metapage_info(get_raw_page('test_hash_a_idx', 0));
4646
-[ RECORD 1 ]----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
4747
magic | 105121344
48-
version | 2
48+
version | 3
4949
ntuples | 1
5050
bsize | 8152
5151
bmsize | 4096
@@ -57,7 +57,7 @@ ovflpoint | 2
5757
firstfree | 0
5858
nmaps | 1
5959
procid | 450
60-
spares | {0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
60+
spares | {0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
6161
mapp | {5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
6262

6363
SELECT magic, version, ntuples, bsize, bmsize, bmshift, maxbucket, highmask,

contrib/pg_buffercache/Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ MODULE_big = pg_buffercache
44
OBJS = pg_buffercache_pages.o $(WIN32RES)
55

66
EXTENSION = pg_buffercache
7-
DATA = pg_buffercache--1.2.sql pg_buffercache--1.1--1.2.sql \
8-
pg_buffercache--1.0--1.1.sql pg_buffercache--unpackaged--1.0.sql
7+
DATA = pg_buffercache--1.2.sql pg_buffercache--1.2--1.3.sql \
8+
pg_buffercache--1.1--1.2.sql pg_buffercache--1.0--1.1.sql \
9+
pg_buffercache--unpackaged--1.0.sql
910
PGFILEDESC = "pg_buffercache - monitoring of shared buffer cache in real-time"
1011

1112
ifdef USE_PGXS
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/* contrib/pg_buffercache/pg_buffercache--1.2--1.3.sql */
2+
3+
-- complain if script is sourced in psql, rather than via ALTER EXTENSION
4+
\echo Use "ALTER EXTENSION pg_buffercache UPDATE TO '1.3'" to load this file. \quit
5+
6+
GRANT EXECUTE ON FUNCTION pg_buffercache_pages() TO pg_monitor;
7+
GRANT SELECT ON pg_buffercache TO pg_monitor;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# pg_buffercache extension
22
comment = 'examine the shared buffer cache'
3-
default_version = '1.2'
3+
default_version = '1.3'
44
module_pathname = '$libdir/pg_buffercache'
55
relocatable = true

contrib/pg_freespacemap/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ MODULE_big = pg_freespacemap
44
OBJS = pg_freespacemap.o $(WIN32RES)
55

66
EXTENSION = pg_freespacemap
7-
DATA = pg_freespacemap--1.1.sql pg_freespacemap--1.0--1.1.sql \
8-
pg_freespacemap--unpackaged--1.0.sql
7+
DATA = pg_freespacemap--1.1.sql pg_freespacemap--1.1--1.2.sql \
8+
pg_freespacemap--1.0--1.1.sql pg_freespacemap--unpackaged--1.0.sql
99
PGFILEDESC = "pg_freespacemap - monitoring of free space map"
1010

1111
ifdef USE_PGXS
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/* contrib/pg_freespacemap/pg_freespacemap--1.1--1.2.sql */
2+
3+
-- complain if script is sourced in psql, rather than via ALTER EXTENSION
4+
\echo Use "ALTER EXTENSION pg_freespacemap UPDATE TO '1.2'" to load this file. \quit
5+
6+
GRANT EXECUTE ON FUNCTION pg_freespace(regclass, bigint) TO pg_stat_scan_tables;
7+
GRANT EXECUTE ON FUNCTION pg_freespace(regclass) TO pg_stat_scan_tables;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# pg_freespacemap extension
22
comment = 'examine the free space map (FSM)'
3-
default_version = '1.1'
3+
default_version = '1.2'
44
module_pathname = '$libdir/pg_freespacemap'
55
relocatable = true

contrib/pg_stat_statements/Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ MODULE_big = pg_stat_statements
44
OBJS = pg_stat_statements.o $(WIN32RES)
55

66
EXTENSION = pg_stat_statements
7-
DATA = pg_stat_statements--1.4.sql pg_stat_statements--1.3--1.4.sql \
8-
pg_stat_statements--1.2--1.3.sql pg_stat_statements--1.1--1.2.sql \
9-
pg_stat_statements--1.0--1.1.sql pg_stat_statements--unpackaged--1.0.sql
7+
DATA = pg_stat_statements--1.4.sql pg_stat_statements--1.4--1.5.sql \
8+
pg_stat_statements--1.3--1.4.sql pg_stat_statements--1.2--1.3.sql \
9+
pg_stat_statements--1.1--1.2.sql pg_stat_statements--1.0--1.1.sql \
10+
pg_stat_statements--unpackaged--1.0.sql
1011
PGFILEDESC = "pg_stat_statements - execution statistics of SQL statements"
1112

1213
LDFLAGS_SL += $(filter -lm, $(LIBS))
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/* contrib/pg_stat_statements/pg_stat_statements--1.4--1.5.sql */
2+
3+
-- complain if script is sourced in psql, rather than via ALTER EXTENSION
4+
\echo Use "ALTER EXTENSION pg_stat_statements UPDATE TO '1.5'" to load this file. \quit
5+
6+
GRANT EXECUTE ON FUNCTION pg_stat_statements_reset() TO pg_read_all_stats;

contrib/pg_stat_statements/pg_stat_statements.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
#include <unistd.h>
6363

6464
#include "access/hash.h"
65+
#include "catalog/pg_authid.h"
6566
#include "executor/instrument.h"
6667
#include "funcapi.h"
6768
#include "mb/pg_wchar.h"
@@ -298,6 +299,7 @@ static void pgss_ExecutorFinish(QueryDesc *queryDesc);
298299
static void pgss_ExecutorEnd(QueryDesc *queryDesc);
299300
static void pgss_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
300301
ProcessUtilityContext context, ParamListInfo params,
302+
QueryEnvironment *queryEnv,
301303
DestReceiver *dest, char *completionTag);
302304
static uint32 pgss_hash_fn(const void *key, Size keysize);
303305
static int pgss_match_fn(const void *key1, const void *key2, Size keysize);
@@ -955,7 +957,8 @@ pgss_ExecutorEnd(QueryDesc *queryDesc)
955957
*/
956958
static void
957959
pgss_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
958-
ProcessUtilityContext context, ParamListInfo params,
960+
ProcessUtilityContext context,
961+
ParamListInfo params, QueryEnvironment *queryEnv,
959962
DestReceiver *dest, char *completionTag)
960963
{
961964
Node *parsetree = pstmt->utilityStmt;
@@ -993,11 +996,11 @@ pgss_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
993996
{
994997
if (prev_ProcessUtility)
995998
prev_ProcessUtility(pstmt, queryString,
996-
context, params,
999+
context, params, queryEnv,
9971000
dest, completionTag);
9981001
else
9991002
standard_ProcessUtility(pstmt, queryString,
1000-
context, params,
1003+
context, params, queryEnv,
10011004
dest, completionTag);
10021005
nested_level--;
10031006
}
@@ -1057,11 +1060,11 @@ pgss_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
10571060
{
10581061
if (prev_ProcessUtility)
10591062
prev_ProcessUtility(pstmt, queryString,
1060-
context, params,
1063+
context, params, queryEnv,
10611064
dest, completionTag);
10621065
else
10631066
standard_ProcessUtility(pstmt, queryString,
1064-
context, params,
1067+
context, params, queryEnv,
10651068
dest, completionTag);
10661069
}
10671070
}
@@ -1391,14 +1394,17 @@ pg_stat_statements_internal(FunctionCallInfo fcinfo,
13911394
MemoryContext per_query_ctx;
13921395
MemoryContext oldcontext;
13931396
Oid userid = GetUserId();
1394-
bool is_superuser = superuser();
1397+
bool is_allowed_role = false;
13951398
char *qbuffer = NULL;
13961399
Size qbuffer_size = 0;
13971400
Size extent = 0;
13981401
int gc_count = 0;
13991402
HASH_SEQ_STATUS hash_seq;
14001403
pgssEntry *entry;
14011404

1405+
/* Superusers or members of pg_read_all_stats members are allowed */
1406+
is_allowed_role = is_member_of_role(GetUserId(), DEFAULT_ROLE_READ_ALL_STATS);
1407+
14021408
/* hash table must exist already */
14031409
if (!pgss || !pgss_hash)
14041410
ereport(ERROR,
@@ -1541,7 +1547,7 @@ pg_stat_statements_internal(FunctionCallInfo fcinfo,
15411547
values[i++] = ObjectIdGetDatum(entry->key.userid);
15421548
values[i++] = ObjectIdGetDatum(entry->key.dbid);
15431549

1544-
if (is_superuser || entry->key.userid == userid)
1550+
if (is_allowed_role || entry->key.userid == userid)
15451551
{
15461552
if (api_version >= PGSS_V1_2)
15471553
values[i++] = Int64GetDatumFast(queryid);
@@ -2420,6 +2426,9 @@ JumbleRangeTable(pgssJumbleState *jstate, List *rtable)
24202426
APP_JUMB_STRING(rte->ctename);
24212427
APP_JUMB(rte->ctelevelsup);
24222428
break;
2429+
case RTE_NAMEDTUPLESTORE:
2430+
APP_JUMB_STRING(rte->enrname);
2431+
break;
24232432
default:
24242433
elog(ERROR, "unrecognized RTE kind: %d", (int) rte->rtekind);
24252434
break;

0 commit comments

Comments
 (0)