Skip to content

Commit 89b849f

Browse files
committed
2 parents e6a296b + 4bc3b50 commit 89b849f

File tree

103 files changed

+2696
-823
lines changed

Some content is hidden

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

103 files changed

+2696
-823
lines changed

.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ contrib/tsearch2/sql/tsearch2.sql whitespace=space-before-tab,blank-at-eof,-bla
1717
contrib/pgcrypto/sql/pgp-armor.sql whitespace=-blank-at-eol
1818
doc/bug.template whitespace=space-before-tab,-blank-at-eof,blank-at-eol
1919
src/backend/catalog/sql_features.txt whitespace=space-before-tab,blank-at-eof,-blank-at-eol
20-
src/backend/tsearch/hunspell_sample.affix whitespace=-blank-at-eof
2120

2221
# Test output files that contain extra whitespace
2322
*.out -whitespace

config/tcl.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
AC_DEFUN([PGAC_PATH_TCLSH],
7-
[AC_PATH_PROGS(TCLSH, [tclsh tcl tclsh8.6 tclsh86 tclsh8.5 tclsh85 tclsh8.4 tclsh84 tclsh8.3 tclsh83])
7+
[AC_PATH_PROGS(TCLSH, [tclsh tcl tclsh8.6 tclsh86 tclsh8.5 tclsh85 tclsh8.4 tclsh84])
88
if test x"$TCLSH" = x""; then
99
AC_MSG_ERROR([Tcl shell not found])
1010
fi

configure

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3100,6 +3100,17 @@ _ACEOF
31003100

31013101

31023102

3103+
# It's worth validating port; you can get very confusing errors otherwise
3104+
if test x"$default_port" = x""; then
3105+
as_fn_error $? "invalid --with-pgport specification: empty string" "$LINENO" 5
3106+
elif test ! x`echo "$default_port" | sed -e 's/[0-9]*//'` = x""; then
3107+
as_fn_error $? "invalid --with-pgport specification: must be a number" "$LINENO" 5
3108+
elif test ! x`echo "$default_port" | sed -e 's/^0.//'` = x"$default_port"; then
3109+
as_fn_error $? "invalid --with-pgport specification: must not have leading 0" "$LINENO" 5
3110+
elif test "$default_port" -lt "1" -o "$default_port" -gt "65535"; then
3111+
as_fn_error $? "invalid --with-pgport specification: must be between 1 and 65535" "$LINENO" 5
3112+
fi
3113+
31033114
#
31043115
# '-rpath'-like feature can be disabled
31053116
#
@@ -14955,7 +14966,7 @@ fi
1495514966

1495614967
# Check for Tcl configuration script tclConfig.sh
1495714968
if test "$with_tcl" = yes; then
14958-
for ac_prog in tclsh tcl tclsh8.6 tclsh86 tclsh8.5 tclsh85 tclsh8.4 tclsh84 tclsh8.3 tclsh83
14969+
for ac_prog in tclsh tcl tclsh8.6 tclsh86 tclsh8.5 tclsh85 tclsh8.4 tclsh84
1495914970
do
1496014971
# Extract the first word of "$ac_prog", so it can be a program name with args.
1496114972
set dummy $ac_prog; ac_word=$2

configure.in

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,17 @@ AC_DEFINE_UNQUOTED(DEF_PGPORT_STR, "${default_port}",
165165
[Define to the default TCP port number as a string constant.])
166166
AC_SUBST(default_port)
167167

168+
# It's worth validating port; you can get very confusing errors otherwise
169+
if test x"$default_port" = x""; then
170+
AC_MSG_ERROR([invalid --with-pgport specification: empty string])
171+
elif test ! x`echo "$default_port" | sed -e 's/[[0-9]]*//'` = x""; then
172+
AC_MSG_ERROR([invalid --with-pgport specification: must be a number])
173+
elif test ! x`echo "$default_port" | sed -e 's/^0.//'` = x"$default_port"; then
174+
AC_MSG_ERROR([invalid --with-pgport specification: must not have leading 0])
175+
elif test "$default_port" -lt "1" -o "$default_port" -gt "65535"; then
176+
AC_MSG_ERROR([invalid --with-pgport specification: must be between 1 and 65535])
177+
fi
178+
168179
#
169180
# '-rpath'-like feature can be disabled
170181
#

contrib/auto_explain/auto_explain.c

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ static bool auto_explain_log_triggers = false;
2929
static bool auto_explain_log_timing = true;
3030
static int auto_explain_log_format = EXPLAIN_FORMAT_TEXT;
3131
static bool auto_explain_log_nested_statements = false;
32+
static double auto_explain_sample_rate = 1;
3233

3334
static const struct config_enum_entry format_options[] = {
3435
{"text", EXPLAIN_FORMAT_TEXT, false},
@@ -47,6 +48,9 @@ static ExecutorRun_hook_type prev_ExecutorRun = NULL;
4748
static ExecutorFinish_hook_type prev_ExecutorFinish = NULL;
4849
static ExecutorEnd_hook_type prev_ExecutorEnd = NULL;
4950

51+
/* Is the current query sampled, per backend */
52+
static bool current_query_sampled = true;
53+
5054
#define auto_explain_enabled() \
5155
(auto_explain_log_min_duration >= 0 && \
5256
(nesting_level == 0 || auto_explain_log_nested_statements))
@@ -57,7 +61,7 @@ void _PG_fini(void);
5761
static void explain_ExecutorStart(QueryDesc *queryDesc, int eflags);
5862
static void explain_ExecutorRun(QueryDesc *queryDesc,
5963
ScanDirection direction,
60-
long count);
64+
uint64 count);
6165
static void explain_ExecutorFinish(QueryDesc *queryDesc);
6266
static void explain_ExecutorEnd(QueryDesc *queryDesc);
6367

@@ -159,6 +163,19 @@ _PG_init(void)
159163
NULL,
160164
NULL);
161165

166+
DefineCustomRealVariable("auto_explain.sample_rate",
167+
"Fraction of queries to process.",
168+
NULL,
169+
&auto_explain_sample_rate,
170+
1.0,
171+
0.0,
172+
1.0,
173+
PGC_SUSET,
174+
0,
175+
NULL,
176+
NULL,
177+
NULL);
178+
162179
EmitWarningsOnPlaceholders("auto_explain");
163180

164181
/* Install hooks. */
@@ -191,7 +208,15 @@ _PG_fini(void)
191208
static void
192209
explain_ExecutorStart(QueryDesc *queryDesc, int eflags)
193210
{
194-
if (auto_explain_enabled())
211+
/*
212+
* For rate sampling, randomly choose top-level statement. Either
213+
* all nested statements will be explained or none will.
214+
*/
215+
if (auto_explain_log_min_duration >= 0 && nesting_level == 0)
216+
current_query_sampled = (random() < auto_explain_sample_rate *
217+
MAX_RANDOM_VALUE);
218+
219+
if (auto_explain_enabled() && current_query_sampled)
195220
{
196221
/* Enable per-node instrumentation iff log_analyze is required. */
197222
if (auto_explain_log_analyze && (eflags & EXEC_FLAG_EXPLAIN_ONLY) == 0)
@@ -210,7 +235,7 @@ explain_ExecutorStart(QueryDesc *queryDesc, int eflags)
210235
else
211236
standard_ExecutorStart(queryDesc, eflags);
212237

213-
if (auto_explain_enabled())
238+
if (auto_explain_enabled() && current_query_sampled)
214239
{
215240
/*
216241
* Set up to track total elapsed time in ExecutorRun. Make sure the
@@ -232,7 +257,7 @@ explain_ExecutorStart(QueryDesc *queryDesc, int eflags)
232257
* ExecutorRun hook: all we need do is track nesting depth
233258
*/
234259
static void
235-
explain_ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, long count)
260+
explain_ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, uint64 count)
236261
{
237262
nesting_level++;
238263
PG_TRY();
@@ -280,7 +305,7 @@ explain_ExecutorFinish(QueryDesc *queryDesc)
280305
static void
281306
explain_ExecutorEnd(QueryDesc *queryDesc)
282307
{
283-
if (queryDesc->totaltime && auto_explain_enabled())
308+
if (queryDesc->totaltime && auto_explain_enabled() && current_query_sampled)
284309
{
285310
double msec;
286311

contrib/file_fdw/file_fdw.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,7 @@ fileGetForeignPaths(PlannerInfo *root,
524524
*/
525525
add_path(baserel, (Path *)
526526
create_foreignscan_path(root, baserel,
527+
NULL, /* default pathtarget */
527528
baserel->rows,
528529
startup_cost,
529530
total_cost,
@@ -821,7 +822,7 @@ check_selective_binary_conversion(RelOptInfo *baserel,
821822
}
822823

823824
/* Collect all the attributes needed for joins or final output. */
824-
pull_varattnos((Node *) baserel->reltarget.exprs, baserel->relid,
825+
pull_varattnos((Node *) baserel->reltarget->exprs, baserel->relid,
825826
&attrs_used);
826827

827828
/* Add all the attributes used by restriction clauses. */
@@ -953,7 +954,7 @@ estimate_size(PlannerInfo *root, RelOptInfo *baserel,
953954
*/
954955
int tuple_width;
955956

956-
tuple_width = MAXALIGN(baserel->reltarget.width) +
957+
tuple_width = MAXALIGN(baserel->reltarget->width) +
957958
MAXALIGN(SizeofHeapTupleHeader);
958959
ntuples = clamp_row_est((double) stat_buf.st_size /
959960
(double) tuple_width);

contrib/pg_stat_statements/pg_stat_statements.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ static void pgss_post_parse_analyze(ParseState *pstate, Query *query);
289289
static void pgss_ExecutorStart(QueryDesc *queryDesc, int eflags);
290290
static void pgss_ExecutorRun(QueryDesc *queryDesc,
291291
ScanDirection direction,
292-
long count);
292+
uint64 count);
293293
static void pgss_ExecutorFinish(QueryDesc *queryDesc);
294294
static void pgss_ExecutorEnd(QueryDesc *queryDesc);
295295
static void pgss_ProcessUtility(Node *parsetree, const char *queryString,
@@ -866,7 +866,7 @@ pgss_ExecutorStart(QueryDesc *queryDesc, int eflags)
866866
* ExecutorRun hook: all we need do is track nesting depth
867867
*/
868868
static void
869-
pgss_ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, long count)
869+
pgss_ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, uint64 count)
870870
{
871871
nested_level++;
872872
PG_TRY();
@@ -1001,13 +1001,7 @@ pgss_ProcessUtility(Node *parsetree, const char *queryString,
10011001
/* parse command tag to retrieve the number of affected rows. */
10021002
if (completionTag &&
10031003
strncmp(completionTag, "COPY ", 5) == 0)
1004-
{
1005-
#ifdef HAVE_STRTOULL
1006-
rows = strtoull(completionTag + 5, NULL, 10);
1007-
#else
1008-
rows = strtoul(completionTag + 5, NULL, 10);
1009-
#endif
1010-
}
1004+
rows = pg_strtouint64(completionTag + 5, NULL, 10);
10111005
else
10121006
rows = 0;
10131007

contrib/postgres_fdw/deparse.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -728,10 +728,10 @@ build_tlist_to_deparse(RelOptInfo *foreignrel)
728728
PgFdwRelationInfo *fpinfo = (PgFdwRelationInfo *) foreignrel->fdw_private;
729729

730730
/*
731-
* We require columns specified in foreignrel->reltarget.exprs and those
731+
* We require columns specified in foreignrel->reltarget->exprs and those
732732
* required for evaluating the local conditions.
733733
*/
734-
tlist = add_to_flat_tlist(tlist, foreignrel->reltarget.exprs);
734+
tlist = add_to_flat_tlist(tlist, foreignrel->reltarget->exprs);
735735
tlist = add_to_flat_tlist(tlist,
736736
pull_var_clause((Node *) fpinfo->local_conds,
737737
PVC_RECURSE_PLACEHOLDERS));

contrib/postgres_fdw/postgres_fdw.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ postgresGetForeignRelSize(PlannerInfo *root,
485485
* columns used in them. Doesn't seem worth detecting that case though.)
486486
*/
487487
fpinfo->attrs_used = NULL;
488-
pull_varattnos((Node *) baserel->reltarget.exprs, baserel->relid,
488+
pull_varattnos((Node *) baserel->reltarget->exprs, baserel->relid,
489489
&fpinfo->attrs_used);
490490
foreach(lc, fpinfo->local_conds)
491491
{
@@ -536,7 +536,7 @@ postgresGetForeignRelSize(PlannerInfo *root,
536536

537537
/* Report estimated baserel size to planner. */
538538
baserel->rows = fpinfo->rows;
539-
baserel->reltarget.width = fpinfo->width;
539+
baserel->reltarget->width = fpinfo->width;
540540
}
541541
else
542542
{
@@ -553,7 +553,7 @@ postgresGetForeignRelSize(PlannerInfo *root,
553553
{
554554
baserel->pages = 10;
555555
baserel->tuples =
556-
(10 * BLCKSZ) / (baserel->reltarget.width +
556+
(10 * BLCKSZ) / (baserel->reltarget->width +
557557
MAXALIGN(SizeofHeapTupleHeader));
558558
}
559559

@@ -797,6 +797,7 @@ postgresGetForeignPaths(PlannerInfo *root,
797797
* to estimate cost and size of this path.
798798
*/
799799
path = create_foreignscan_path(root, baserel,
800+
NULL, /* default pathtarget */
800801
fpinfo->rows,
801802
fpinfo->startup_cost,
802803
fpinfo->total_cost,
@@ -968,6 +969,7 @@ postgresGetForeignPaths(PlannerInfo *root,
968969

969970
/* Make the path */
970971
path = create_foreignscan_path(root, baserel,
972+
NULL, /* default pathtarget */
971973
rows,
972974
startup_cost,
973975
total_cost,
@@ -2168,7 +2170,7 @@ estimate_path_cost_size(PlannerInfo *root,
21682170
* between foreign relations.
21692171
*/
21702172
rows = foreignrel->rows;
2171-
width = foreignrel->reltarget.width;
2173+
width = foreignrel->reltarget->width;
21722174

21732175
/* Back into an estimate of the number of retrieved rows. */
21742176
retrieved_rows = clamp_row_est(rows / fpinfo->local_conds_sel);
@@ -3353,10 +3355,8 @@ postgresImportForeignSchema(ImportForeignSchemaStmt *stmt, Oid serverOid)
33533355
*
33543356
* 1) Join type is INNER or OUTER (one of LEFT/RIGHT/FULL)
33553357
* 2) Both outer and inner portions are safe to push-down
3356-
* 3) All foreign tables in the join belong to the same foreign server and use
3357-
* the same user mapping.
3358-
* 4) All join conditions are safe to push down
3359-
* 5) No relation has local filter (this can be relaxed for INNER JOIN, if we
3358+
* 3) All join conditions are safe to push down
3359+
* 4) No relation has local filter (this can be relaxed for INNER JOIN, if we
33603360
* can move unpushable clauses upwards in the join tree).
33613361
*/
33623362
static bool
@@ -3571,6 +3571,7 @@ add_paths_with_pathkeys_for_rel(PlannerInfo *root, RelOptInfo *rel,
35713571

35723572
add_path(rel, (Path *)
35733573
create_foreignscan_path(root, rel,
3574+
NULL,
35743575
rows,
35753576
startup_cost,
35763577
total_cost,
@@ -3696,7 +3697,7 @@ postgresGetForeignJoinPaths(PlannerInfo *root,
36963697
&width, &startup_cost, &total_cost);
36973698
/* Now update this information in the joinrel */
36983699
joinrel->rows = rows;
3699-
joinrel->reltarget.width = width;
3700+
joinrel->reltarget->width = width;
37003701
fpinfo->rows = rows;
37013702
fpinfo->width = width;
37023703
fpinfo->startup_cost = startup_cost;
@@ -3708,6 +3709,7 @@ postgresGetForeignJoinPaths(PlannerInfo *root,
37083709
*/
37093710
joinpath = create_foreignscan_path(root,
37103711
joinrel,
3712+
NULL, /* default pathtarget */
37113713
rows,
37123714
startup_cost,
37133715
total_cost,

contrib/spi/refint.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ check_foreign_key(PG_FUNCTION_ARGS)
593593
else
594594
{
595595
#ifdef REFINT_VERBOSE
596-
elog(NOTICE, "%s: %d tuple(s) of %s are %s",
596+
elog(NOTICE, "%s: " UINT64_FORMAT " tuple(s) of %s are %s",
597597
trigger->tgname, SPI_processed, relname,
598598
(action == 'c') ? "deleted" : "set to null");
599599
#endif

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy