Skip to content

Commit 67bd582

Browse files
committed
Merge branch 'master' into iam3
2 parents 01c3bce + 5229db6 commit 67bd582

Some content is hidden

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

71 files changed

+1047
-599
lines changed

configure

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12462,6 +12462,67 @@ $as_echo "#define LOCALE_T_IN_XLOCALE 1" >>confdefs.h
1246212462

1246312463
fi
1246412464

12465+
# MSVC doesn't cope well with defining restrict to __restrict, the
12466+
# spelling it understands, because it conflicts with
12467+
# __declspec(restrict). Therefore we define pg_restrict to the
12468+
# appropriate definition, which presumably won't conflict.
12469+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C/C++ restrict keyword" >&5
12470+
$as_echo_n "checking for C/C++ restrict keyword... " >&6; }
12471+
if ${ac_cv_c_restrict+:} false; then :
12472+
$as_echo_n "(cached) " >&6
12473+
else
12474+
ac_cv_c_restrict=no
12475+
# The order here caters to the fact that C++ does not require restrict.
12476+
for ac_kw in __restrict __restrict__ _Restrict restrict; do
12477+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
12478+
/* end confdefs.h. */
12479+
typedef int * int_ptr;
12480+
int foo (int_ptr $ac_kw ip) {
12481+
return ip[0];
12482+
}
12483+
int
12484+
main ()
12485+
{
12486+
int s[1];
12487+
int * $ac_kw t = s;
12488+
t[0] = 0;
12489+
return foo(t)
12490+
;
12491+
return 0;
12492+
}
12493+
_ACEOF
12494+
if ac_fn_c_try_compile "$LINENO"; then :
12495+
ac_cv_c_restrict=$ac_kw
12496+
fi
12497+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
12498+
test "$ac_cv_c_restrict" != no && break
12499+
done
12500+
12501+
fi
12502+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_restrict" >&5
12503+
$as_echo "$ac_cv_c_restrict" >&6; }
12504+
12505+
case $ac_cv_c_restrict in
12506+
restrict) ;;
12507+
no) $as_echo "#define restrict /**/" >>confdefs.h
12508+
;;
12509+
*) cat >>confdefs.h <<_ACEOF
12510+
#define restrict $ac_cv_c_restrict
12511+
_ACEOF
12512+
;;
12513+
esac
12514+
12515+
if test "$ac_cv_c_restrict" = "no" ; then
12516+
pg_restrict=""
12517+
else
12518+
pg_restrict="$ac_cv_c_restrict"
12519+
fi
12520+
12521+
cat >>confdefs.h <<_ACEOF
12522+
#define pg_restrict $pg_restrict
12523+
_ACEOF
12524+
12525+
1246512526
ac_fn_c_check_type "$LINENO" "struct cmsgcred" "ac_cv_type_struct_cmsgcred" "#include <sys/socket.h>
1246612527
#include <sys/param.h>
1246712528
#ifdef HAVE_SYS_UCRED_H

configure.in

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,6 +1325,20 @@ AC_TYPE_LONG_LONG_INT
13251325

13261326
PGAC_TYPE_LOCALE_T
13271327

1328+
# MSVC doesn't cope well with defining restrict to __restrict, the
1329+
# spelling it understands, because it conflicts with
1330+
# __declspec(restrict). Therefore we define pg_restrict to the
1331+
# appropriate definition, which presumably won't conflict.
1332+
AC_C_RESTRICT
1333+
if test "$ac_cv_c_restrict" = "no" ; then
1334+
pg_restrict=""
1335+
else
1336+
pg_restrict="$ac_cv_c_restrict"
1337+
fi
1338+
AC_DEFINE_UNQUOTED([pg_restrict], [$pg_restrict],
1339+
[Define to keyword to use for C99 restrict support, or to nothing if not
1340+
supported])
1341+
13281342
AC_CHECK_TYPES([struct cmsgcred], [], [],
13291343
[#include <sys/socket.h>
13301344
#include <sys/param.h>

contrib/hstore/hstore_io.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,23 +1207,23 @@ hstore_send(PG_FUNCTION_ARGS)
12071207

12081208
pq_begintypsend(&buf);
12091209

1210-
pq_sendint(&buf, count, 4);
1210+
pq_sendint32(&buf, count);
12111211

12121212
for (i = 0; i < count; i++)
12131213
{
12141214
int32 keylen = HSTORE_KEYLEN(entries, i);
12151215

1216-
pq_sendint(&buf, keylen, 4);
1216+
pq_sendint32(&buf, keylen);
12171217
pq_sendtext(&buf, HSTORE_KEY(entries, base, i), keylen);
12181218
if (HSTORE_VALISNULL(entries, i))
12191219
{
1220-
pq_sendint(&buf, -1, 4);
1220+
pq_sendint32(&buf, -1);
12211221
}
12221222
else
12231223
{
12241224
int32 vallen = HSTORE_VALLEN(entries, i);
12251225

1226-
pq_sendint(&buf, vallen, 4);
1226+
pq_sendint32(&buf, vallen);
12271227
pq_sendtext(&buf, HSTORE_VAL(entries, base, i), vallen);
12281228
}
12291229
}

contrib/pg_stat_statements/pg_stat_statements.c

Lines changed: 23 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* as the collations of Vars and, most notably, the values of constants.
2222
*
2323
* This jumble is acquired at the end of parse analysis of each query, and
24-
* a 32-bit hash of it is stored into the query's Query.queryId field.
24+
* a 64-bit hash of it is stored into the query's Query.queryId field.
2525
* The server then copies this value around, making it available in plan
2626
* tree(s) generated from the query. The executor can then use this value
2727
* to blame query costs on the proper queryId.
@@ -95,7 +95,7 @@ PG_MODULE_MAGIC;
9595
#define PGSS_TEXT_FILE PG_STAT_TMP_DIR "/pgss_query_texts.stat"
9696

9797
/* Magic number identifying the stats file format */
98-
static const uint32 PGSS_FILE_HEADER = 0x20140125;
98+
static const uint32 PGSS_FILE_HEADER = 0x20171004;
9999

100100
/* PostgreSQL major version number, changes in which invalidate all entries */
101101
static const uint32 PGSS_PG_MAJOR_VERSION = PG_VERSION_NUM / 100;
@@ -130,7 +130,7 @@ typedef struct pgssHashKey
130130
{
131131
Oid userid; /* user OID */
132132
Oid dbid; /* database OID */
133-
uint32 queryid; /* query identifier */
133+
uint64 queryid; /* query identifier */
134134
} pgssHashKey;
135135

136136
/*
@@ -301,10 +301,8 @@ static void pgss_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
301301
ProcessUtilityContext context, ParamListInfo params,
302302
QueryEnvironment *queryEnv,
303303
DestReceiver *dest, char *completionTag);
304-
static uint32 pgss_hash_fn(const void *key, Size keysize);
305-
static int pgss_match_fn(const void *key1, const void *key2, Size keysize);
306-
static uint32 pgss_hash_string(const char *str, int len);
307-
static void pgss_store(const char *query, uint32 queryId,
304+
static uint64 pgss_hash_string(const char *str, int len);
305+
static void pgss_store(const char *query, uint64 queryId,
308306
int query_location, int query_len,
309307
double total_time, uint64 rows,
310308
const BufferUsage *bufusage,
@@ -500,12 +498,10 @@ pgss_shmem_startup(void)
500498
memset(&info, 0, sizeof(info));
501499
info.keysize = sizeof(pgssHashKey);
502500
info.entrysize = sizeof(pgssEntry);
503-
info.hash = pgss_hash_fn;
504-
info.match = pgss_match_fn;
505501
pgss_hash = ShmemInitHash("pg_stat_statements hash",
506502
pgss_max, pgss_max,
507503
&info,
508-
HASH_ELEM | HASH_FUNCTION | HASH_COMPARE);
504+
HASH_ELEM | HASH_BLOBS);
509505

510506
LWLockRelease(AddinShmemInitLock);
511507

@@ -781,7 +777,7 @@ pgss_post_parse_analyze(ParseState *pstate, Query *query)
781777
prev_post_parse_analyze_hook(pstate, query);
782778

783779
/* Assert we didn't do this already */
784-
Assert(query->queryId == 0);
780+
Assert(query->queryId == UINT64CONST(0));
785781

786782
/* Safety check... */
787783
if (!pgss || !pgss_hash)
@@ -797,7 +793,7 @@ pgss_post_parse_analyze(ParseState *pstate, Query *query)
797793
*/
798794
if (query->utilityStmt)
799795
{
800-
query->queryId = 0;
796+
query->queryId = UINT64CONST(0);
801797
return;
802798
}
803799

@@ -812,14 +808,15 @@ pgss_post_parse_analyze(ParseState *pstate, Query *query)
812808

813809
/* Compute query ID and mark the Query node with it */
814810
JumbleQuery(&jstate, query);
815-
query->queryId = hash_any(jstate.jumble, jstate.jumble_len);
811+
query->queryId =
812+
DatumGetUInt64(hash_any_extended(jstate.jumble, jstate.jumble_len, 0));
816813

817814
/*
818815
* If we are unlucky enough to get a hash of zero, use 1 instead, to
819816
* prevent confusion with the utility-statement case.
820817
*/
821-
if (query->queryId == 0)
822-
query->queryId = 1;
818+
if (query->queryId == UINT64CONST(0))
819+
query->queryId = UINT64CONST(1);
823820

824821
/*
825822
* If we were able to identify any ignorable constants, we immediately
@@ -855,7 +852,7 @@ pgss_ExecutorStart(QueryDesc *queryDesc, int eflags)
855852
* counting of optimizable statements that are directly contained in
856853
* utility statements.
857854
*/
858-
if (pgss_enabled() && queryDesc->plannedstmt->queryId != 0)
855+
if (pgss_enabled() && queryDesc->plannedstmt->queryId != UINT64CONST(0))
859856
{
860857
/*
861858
* Set up to track total elapsed time in ExecutorRun. Make sure the
@@ -926,9 +923,9 @@ pgss_ExecutorFinish(QueryDesc *queryDesc)
926923
static void
927924
pgss_ExecutorEnd(QueryDesc *queryDesc)
928925
{
929-
uint32 queryId = queryDesc->plannedstmt->queryId;
926+
uint64 queryId = queryDesc->plannedstmt->queryId;
930927

931-
if (queryId != 0 && queryDesc->totaltime && pgss_enabled())
928+
if (queryId != UINT64CONST(0) && queryDesc->totaltime && pgss_enabled())
932929
{
933930
/*
934931
* Make sure stats accumulation is done. (Note: it's okay if several
@@ -1069,45 +1066,16 @@ pgss_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
10691066
}
10701067
}
10711068

1072-
/*
1073-
* Calculate hash value for a key
1074-
*/
1075-
static uint32
1076-
pgss_hash_fn(const void *key, Size keysize)
1077-
{
1078-
const pgssHashKey *k = (const pgssHashKey *) key;
1079-
1080-
return hash_uint32((uint32) k->userid) ^
1081-
hash_uint32((uint32) k->dbid) ^
1082-
hash_uint32((uint32) k->queryid);
1083-
}
1084-
1085-
/*
1086-
* Compare two keys - zero means match
1087-
*/
1088-
static int
1089-
pgss_match_fn(const void *key1, const void *key2, Size keysize)
1090-
{
1091-
const pgssHashKey *k1 = (const pgssHashKey *) key1;
1092-
const pgssHashKey *k2 = (const pgssHashKey *) key2;
1093-
1094-
if (k1->userid == k2->userid &&
1095-
k1->dbid == k2->dbid &&
1096-
k1->queryid == k2->queryid)
1097-
return 0;
1098-
else
1099-
return 1;
1100-
}
1101-
11021069
/*
11031070
* Given an arbitrarily long query string, produce a hash for the purposes of
11041071
* identifying the query, without normalizing constants. Used when hashing
11051072
* utility statements.
11061073
*/
1107-
static uint32
1074+
static uint64
11081075
pgss_hash_string(const char *str, int len)
11091076
{
1110-
return hash_any((const unsigned char *) str, len);
1077+
return DatumGetUInt64(hash_any_extended((const unsigned char *) str,
1078+
len, 0));
11111079
}
11121080

11131081
/*
@@ -1121,7 +1089,7 @@ pgss_hash_string(const char *str, int len)
11211089
* query string. total_time, rows, bufusage are ignored in this case.
11221090
*/
11231091
static void
1124-
pgss_store(const char *query, uint32 queryId,
1092+
pgss_store(const char *query, uint64 queryId,
11251093
int query_location, int query_len,
11261094
double total_time, uint64 rows,
11271095
const BufferUsage *bufusage,
@@ -1173,7 +1141,7 @@ pgss_store(const char *query, uint32 queryId,
11731141
/*
11741142
* For utility statements, we just hash the query string to get an ID.
11751143
*/
1176-
if (queryId == 0)
1144+
if (queryId == UINT64CONST(0))
11771145
queryId = pgss_hash_string(query, query_len);
11781146

11791147
/* Set up key for hashtable search */
@@ -2324,8 +2292,10 @@ AppendJumble(pgssJumbleState *jstate, const unsigned char *item, Size size)
23242292

23252293
if (jumble_len >= JUMBLE_SIZE)
23262294
{
2327-
uint32 start_hash = hash_any(jumble, JUMBLE_SIZE);
2295+
uint64 start_hash;
23282296

2297+
start_hash = DatumGetUInt64(hash_any_extended(jumble,
2298+
JUMBLE_SIZE, 0));
23292299
memcpy(jumble, &start_hash, sizeof(start_hash));
23302300
jumble_len = sizeof(start_hash);
23312301
}

doc/src/sgml/ref/grant.sgml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,22 @@ GRANT <replaceable class="parameter">role_name</replaceable> [, ...] TO <replace
156156
<para>
157157
PostgreSQL grants default privileges on some types of objects to
158158
<literal>PUBLIC</literal>. No privileges are granted to
159-
<literal>PUBLIC</literal> by default on tables,
160-
columns, schemas or tablespaces. For other types, the default privileges
159+
<literal>PUBLIC</literal> by default on
160+
tables,
161+
table columns,
162+
sequences,
163+
foreign data wrappers,
164+
foreign servers,
165+
large objects,
166+
schemas,
167+
or tablespaces.
168+
For other types of objects, the default privileges
161169
granted to <literal>PUBLIC</literal> are as follows:
162-
<literal>CONNECT</literal> and <literal>CREATE TEMP TABLE</literal> for
163-
databases; <literal>EXECUTE</literal> privilege for functions; and
164-
<literal>USAGE</literal> privilege for languages.
170+
<literal>CONNECT</literal> and <literal>TEMPORARY</literal> (create
171+
temporary tables) privileges for databases;
172+
<literal>EXECUTE</literal> privilege for functions; and
173+
<literal>USAGE</literal> privilege for languages and data types
174+
(including domains).
165175
The object owner can, of course, <command>REVOKE</command>
166176
both default and expressly granted privileges. (For maximum
167177
security, issue the <command>REVOKE</> in the same transaction that

doc/src/sgml/release-10.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1946,7 +1946,7 @@
19461946
-->
19471947
<para>
19481948
Add function <link
1949-
linkend="functions-txid-snapshot"><function>txid_current_ifassigned()</></>
1949+
linkend="functions-txid-snapshot"><function>txid_current_if_assigned()</></>
19501950
to return the current transaction ID or <literal>NULL</> if no
19511951
transaction ID has been assigned (Craig Ringer)
19521952
</para>

src/backend/access/common/printsimple.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,19 @@ printsimple_startup(DestReceiver *self, int operation, TupleDesc tupdesc)
3434
int i;
3535

3636
pq_beginmessage(&buf, 'T'); /* RowDescription */
37-
pq_sendint(&buf, tupdesc->natts, 2);
37+
pq_sendint16(&buf, tupdesc->natts);
3838

3939
for (i = 0; i < tupdesc->natts; ++i)
4040
{
4141
Form_pg_attribute attr = TupleDescAttr(tupdesc, i);
4242

4343
pq_sendstring(&buf, NameStr(attr->attname));
44-
pq_sendint(&buf, 0, 4); /* table oid */
45-
pq_sendint(&buf, 0, 2); /* attnum */
46-
pq_sendint(&buf, (int) attr->atttypid, 4);
47-
pq_sendint(&buf, attr->attlen, 2);
48-
pq_sendint(&buf, attr->atttypmod, 4);
49-
pq_sendint(&buf, 0, 2); /* format code */
44+
pq_sendint32(&buf, 0); /* table oid */
45+
pq_sendint16(&buf, 0); /* attnum */
46+
pq_sendint32(&buf, (int) attr->atttypid);
47+
pq_sendint16(&buf, attr->attlen);
48+
pq_sendint32(&buf, attr->atttypmod);
49+
pq_sendint16(&buf, 0); /* format code */
5050
}
5151

5252
pq_endmessage(&buf);
@@ -67,7 +67,7 @@ printsimple(TupleTableSlot *slot, DestReceiver *self)
6767

6868
/* Prepare and send message */
6969
pq_beginmessage(&buf, 'D');
70-
pq_sendint(&buf, tupdesc->natts, 2);
70+
pq_sendint16(&buf, tupdesc->natts);
7171

7272
for (i = 0; i < tupdesc->natts; ++i)
7373
{
@@ -76,7 +76,7 @@ printsimple(TupleTableSlot *slot, DestReceiver *self)
7676

7777
if (slot->tts_isnull[i])
7878
{
79-
pq_sendint(&buf, -1, 4);
79+
pq_sendint32(&buf, -1);
8080
continue;
8181
}
8282

0 commit comments

Comments
 (0)