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

Commit875786c

Browse files
authored
Merge branch 'postgres:master' into master
2 parents075fa6a +a1de1b0 commit875786c

File tree

12 files changed

+250
-64
lines changed

12 files changed

+250
-64
lines changed

‎contrib/pg_stat_statements/expected/extended.out

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,61 @@ SELECT calls, rows, query FROM pg_stat_statements ORDER BY query COLLATE "C";
6868
1 | 1 | SELECT pg_stat_statements_reset() IS NOT NULL AS t
6969
(4 rows)
7070

71+
-- Various parameter numbering patterns
72+
SELECT pg_stat_statements_reset() IS NOT NULL AS t;
73+
t
74+
---
75+
t
76+
(1 row)
77+
78+
-- Unique query IDs with parameter numbers switched.
79+
SELECT WHERE ($1::int, 7) IN ((8, $2::int), ($3::int, 9)) \bind '1' '2' '3' \g
80+
--
81+
(0 rows)
82+
83+
SELECT WHERE ($2::int, 10) IN ((11, $3::int), ($1::int, 12)) \bind '1' '2' '3' \g
84+
--
85+
(0 rows)
86+
87+
SELECT WHERE $1::int IN ($2::int, $3::int) \bind '1' '2' '3' \g
88+
--
89+
(0 rows)
90+
91+
SELECT WHERE $2::int IN ($3::int, $1::int) \bind '1' '2' '3' \g
92+
--
93+
(0 rows)
94+
95+
SELECT WHERE $3::int IN ($1::int, $2::int) \bind '1' '2' '3' \g
96+
--
97+
(0 rows)
98+
99+
-- Two groups of two queries with the same query ID.
100+
SELECT WHERE '1'::int IN ($1::int, '2'::int) \bind '1' \g
101+
--
102+
(1 row)
103+
104+
SELECT WHERE '4'::int IN ($1::int, '5'::int) \bind '2' \g
105+
--
106+
(0 rows)
107+
108+
SELECT WHERE $2::int IN ($1::int, '1'::int) \bind '1' '2' \g
109+
--
110+
(0 rows)
111+
112+
SELECT WHERE $2::int IN ($1::int, '2'::int) \bind '3' '4' \g
113+
--
114+
(0 rows)
115+
116+
SELECT query, calls FROM pg_stat_statements ORDER BY query COLLATE "C";
117+
query | calls
118+
--------------------------------------------------------------+-------
119+
SELECT WHERE $1::int IN ($2::int, $3::int) | 1
120+
SELECT WHERE $2::int IN ($1::int, $3::int) | 2
121+
SELECT WHERE $2::int IN ($1::int, $3::int) | 2
122+
SELECT WHERE $2::int IN ($3::int, $1::int) | 1
123+
SELECT WHERE $3::int IN ($1::int, $2::int) | 1
124+
SELECT WHERE ($1::int, $4) IN (($5, $2::int), ($3::int, $6)) | 1
125+
SELECT WHERE ($2::int, $4) IN (($5, $3::int), ($1::int, $6)) | 1
126+
SELECT pg_stat_statements_reset() IS NOT NULL AS t | 1
127+
(8 rows)
128+

‎contrib/pg_stat_statements/expected/select.out

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,35 @@ SELECT pg_stat_statements_reset() IS NOT NULL AS t;
238238
t
239239
(1 row)
240240

241+
-- normalization of constants and parameters, with constant locations
242+
-- recorded one or more times.
243+
SELECT pg_stat_statements_reset() IS NOT NULL AS t;
244+
t
245+
---
246+
t
247+
(1 row)
248+
249+
SELECT WHERE '1' IN ('1'::int, '3'::int::text);
250+
--
251+
(1 row)
252+
253+
SELECT WHERE (1, 2) IN ((1, 2), (2, 3));
254+
--
255+
(1 row)
256+
257+
SELECT WHERE (3, 4) IN ((5, 6), (8, 7));
258+
--
259+
(0 rows)
260+
261+
SELECT query, calls FROM pg_stat_statements ORDER BY query COLLATE "C";
262+
query | calls
263+
------------------------------------------------------------------------+-------
264+
SELECT WHERE $1 IN ($2::int, $3::int::text) | 1
265+
SELECT WHERE ($1, $2) IN (($3, $4), ($5, $6)) | 2
266+
SELECT pg_stat_statements_reset() IS NOT NULL AS t | 1
267+
SELECT query, calls FROM pg_stat_statements ORDER BY query COLLATE "C" | 0
268+
(4 rows)
269+
241270
--
242271
-- queries with locking clauses
243272
--

‎contrib/pg_stat_statements/pg_stat_statements.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2818,9 +2818,7 @@ generate_normalized_query(JumbleState *jstate, const char *query,
28182818
last_off=0,/* Offset from start for previous tok */
28192819
last_tok_len=0;/* Length (in bytes) of that tok */
28202820
boolin_squashed= false;/* in a run of squashed consts? */
2821-
intskipped_constants=0;/* Position adjustment of later
2822-
* constants after squashed ones */
2823-
2821+
intnum_constants_replaced=0;
28242822

28252823
/*
28262824
* Get constants' lengths (core system only gives us locations). Note
@@ -2878,7 +2876,7 @@ generate_normalized_query(JumbleState *jstate, const char *query,
28782876

28792877
/* ... and then a param symbol replacing the constant itself */
28802878
n_quer_loc+=sprintf(norm_query+n_quer_loc,"$%d",
2881-
i+1+jstate->highest_extern_param_id-skipped_constants);
2879+
num_constants_replaced+++1+jstate->highest_extern_param_id);
28822880

28832881
/* In case previous constants were merged away, stop doing that */
28842882
in_squashed= false;
@@ -2902,12 +2900,10 @@ generate_normalized_query(JumbleState *jstate, const char *query,
29022900

29032901
/* ... and then start a run of squashed constants */
29042902
n_quer_loc+=sprintf(norm_query+n_quer_loc,"$%d /*, ... */",
2905-
i+1+jstate->highest_extern_param_id-skipped_constants);
2903+
num_constants_replaced+++1+jstate->highest_extern_param_id);
29062904

29072905
/* The next location will match the block below, to end the run */
29082906
in_squashed= true;
2909-
2910-
skipped_constants++;
29112907
}
29122908
else
29132909
{

‎contrib/pg_stat_statements/sql/extended.sql

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,19 @@ SELECT $1 \bind 'unnamed_val1' \g
1919
\bind_named stmt1'stmt1_val1' \g
2020

2121
SELECT calls, rows, queryFROM pg_stat_statementsORDER BY query COLLATE"C";
22+
23+
-- Various parameter numbering patterns
24+
SELECT pg_stat_statements_reset()IS NOT NULLAS t;
25+
-- Unique query IDs with parameter numbers switched.
26+
SELECTWHERE ($1::int,7)IN ((8, $2::int), ($3::int,9)) \bind'1''2''3' \g
27+
SELECTWHERE ($2::int,10)IN ((11, $3::int), ($1::int,12)) \bind'1''2''3' \g
28+
SELECTWHERE $1::intIN ($2::int, $3::int) \bind'1''2''3' \g
29+
SELECTWHERE $2::intIN ($3::int, $1::int) \bind'1''2''3' \g
30+
SELECTWHERE $3::intIN ($1::int, $2::int) \bind'1''2''3' \g
31+
-- Two groups of two queries with the same query ID.
32+
SELECTWHERE'1'::intIN ($1::int,'2'::int) \bind'1' \g
33+
SELECTWHERE'4'::intIN ($1::int,'5'::int) \bind'2' \g
34+
SELECTWHERE $2::intIN ($1::int,'1'::int) \bind'1''2' \g
35+
SELECTWHERE $2::intIN ($1::int,'2'::int) \bind'3''4' \g
36+
37+
SELECT query, callsFROM pg_stat_statementsORDER BY query COLLATE"C";

‎contrib/pg_stat_statements/sql/select.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ DEALLOCATE pgss_test;
7979
SELECT calls, rows, queryFROM pg_stat_statementsORDER BY query COLLATE"C";
8080
SELECT pg_stat_statements_reset()IS NOT NULLAS t;
8181

82+
-- normalization of constants and parameters, with constant locations
83+
-- recorded one or more times.
84+
SELECT pg_stat_statements_reset()IS NOT NULLAS t;
85+
SELECTWHERE'1'IN ('1'::int,'3'::int::text);
86+
SELECTWHERE (1,2)IN ((1,2), (2,3));
87+
SELECTWHERE (3,4)IN ((5,6), (8,7));
88+
SELECT query, callsFROM pg_stat_statementsORDER BY query COLLATE"C";
89+
8290
--
8391
-- queries with locking clauses
8492
--

‎doc/src/sgml/config.sgml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7527,12 +7527,12 @@ local0.* /var/log/postgresql
75277527
<entry><literal>setup_durations</literal></entry>
75287528
<entry>
75297529
Logs the time spent establishing the connection and setting up the
7530-
backendat the time the connection is ready to execute its first
7531-
query. The log message includesthe total setup duration, starting
7532-
from the postmaster accepting the incoming connection and ending
7533-
when theconnectionis ready for query. It also includes the time
7534-
it took to fork the new backend and the time it took to
7535-
authenticate the user.
7530+
backenduntil the connection is ready to execute its first
7531+
query. The log message includesthree durations: the total
7532+
setup duration (startingfrom the postmaster accepting the
7533+
incomingconnectionand ending when the connection is ready
7534+
for query), the timeit took to fork the new backend, and
7535+
the time it took toauthenticate the user.
75367536
</entry>
75377537
</row>
75387538

‎doc/src/sgml/release-18.sgml

Lines changed: 51 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,7 @@ Add an asynchronous I/O subsystem (Andres Freund, Thomas Munro, Nazir Bilal Yavu
569569
</para>
570570

571571
<para>
572+
This feature allows backends to queue multiple read requests, which allows for more efficient sequential scans, bitmap heap scans, and vacuums.
572573
This is enabled by server variable io_method, with server variables io_combine_limit and io_max_combine_limit added to control it. This also enables
573574
effective_io_concurrency and maintenance_io_concurrency values greater than zero for systems without fadvise() support. The new system view pg_aios shows the file handles being used
574575
for asynchronous I/O.
@@ -682,22 +683,31 @@ This more accurately reflects modern hardware.
682683
<!--
683684
Author: Melanie Plageman <melanieplageman@gmail.com>
684685
2025-03-12 [9219093ca] Modularize log_connections output
685-
Author: Melanie Plageman <melanieplageman@gmail.com>
686-
2025-03-12 [18cd15e70] Add connection establishment duration logging
687686
-->
688687

689688
<listitem>
690689
<para>
691690
Increase the logging granularity of server variable log_connections (Melanie Plageman)
692691
<ulink url="&commit_baseurl;9219093ca">&sect;</ulink>
693-
<ulink url="&commit_baseurl;18cd15e70">&sect;</ulink>
694692
</para>
695693

696694
<para>
697695
This server variable was previously only boolean; these options are still supported.
698696
</para>
699697
</listitem>
700698

699+
<!--
700+
Author: Melanie Plageman <melanieplageman@gmail.com>
701+
2025-03-12 [18cd15e70] Add connection establishment duration logging
702+
-->
703+
704+
<listitem>
705+
<para>
706+
Add log_connections option to report the duration of connection stages (Melanie Plageman)
707+
<ulink url="&commit_baseurl;18cd15e70">&sect;</ulink>
708+
</para>
709+
</listitem>
710+
701711
<!--
702712
Author: Tom Lane <tgl@sss.pgh.pa.us>
703713
2025-04-07 [3516ea768] Add local-address escape "%L" to log_line_prefix.
@@ -762,6 +772,33 @@ mode; tracking must be enabled with the server variable track_cost_delay_timing.
762772
</para>
763773
</listitem>
764774

775+
<!--
776+
Author: Masahiko Sawada <msawada@postgresql.org>
777+
2024-08-13 [4c1b4cdb8] Add resource statistics reporting to ANALYZE VERBOSE.
778+
Author: Masahiko Sawada <msawada@postgresql.org>
779+
2024-09-09 [bb7775234] Add WAL usage reporting to ANALYZE VERBOSE output.
780+
-->
781+
782+
<listitem>
783+
<para>
784+
Add WAL, CPU, and average read statistics output to ANALYZE VERBOSE (Anthonin Bonnefoy)
785+
<ulink url="&commit_baseurl;4c1b4cdb8">&sect;</ulink>
786+
<ulink url="&commit_baseurl;bb7775234">&sect;</ulink>
787+
</para>
788+
</listitem>
789+
790+
<!--
791+
Author: Michael Paquier <michael@paquier.xyz>
792+
2025-02-17 [6a8a7ce47] Add information about WAL buffers full to VACUUM/ANALYZE
793+
-->
794+
795+
<listitem>
796+
<para>
797+
Add full WAL buffer count to VACUUM/ANALYZE (VERBOSE) and autovacuum log output (Bertrand Drouvot)
798+
<ulink url="&commit_baseurl;6a8a7ce47">&sect;</ulink>
799+
</para>
800+
</listitem>
801+
765802
<!--
766803
Author: Michael Paquier <michael@paquier.xyz>
767804
2024-12-19 [9aea73fc6] Add backend-level statistics to pgstats
@@ -1740,33 +1777,15 @@ Automatically include BUFFERS output in EXPLAIN ANALYZE (Guillaume Lelarge, Davi
17401777
</para>
17411778
</listitem>
17421779

1743-
<!--
1744-
Author: Masahiko Sawada <msawada@postgresql.org>
1745-
2024-08-13 [4c1b4cdb8] Add resource statistics reporting to ANALYZE VERBOSE.
1746-
Author: Masahiko Sawada <msawada@postgresql.org>
1747-
2024-09-09 [bb7775234] Add WAL usage reporting to ANALYZE VERBOSE output.
1748-
-->
1749-
1750-
<listitem>
1751-
<para>
1752-
Add WAL, CPU, and average read statistics output to EXPLAIN ANALYZE VERBOSE (Anthonin Bonnefoy)
1753-
<ulink url="&commit_baseurl;4c1b4cdb8">&sect;</ulink>
1754-
<ulink url="&commit_baseurl;bb7775234">&sect;</ulink>
1755-
</para>
1756-
</listitem>
1757-
17581780
<!--
17591781
Author: Michael Paquier <michael@paquier.xyz>
17601782
2025-02-17 [320545bfc] Add information about WAL buffers being full to EXPLAIN
1761-
Author: Michael Paquier <michael@paquier.xyz>
1762-
2025-02-17 [6a8a7ce47] Add information about WAL buffers full to VACUUM/ANALYZE
17631783
-->
17641784

17651785
<listitem>
17661786
<para>
1767-
Add full WAL buffer count to EXPLAIN (WAL), VACUUM/ANALYZE (VERBOSE), and autovacuum log output (Bertrand Drouvot)
1787+
Add full WAL buffer count to EXPLAIN (WAL) output (Bertrand Drouvot)
17681788
<ulink url="&commit_baseurl;320545bfc">&sect;</ulink>
1769-
<ulink url="&commit_baseurl;6a8a7ce47">&sect;</ulink>
17701789
</para>
17711790
</listitem>
17721791

@@ -2905,13 +2924,22 @@ Add ARM Neon and SVE CPU intrinsics for popcount (integer bit counting) (Chiranm
29052924

29062925
<!--
29072926
Author: Dean Rasheed <dean.a.rasheed@gmail.com>
2927+
2024-07-09 [ca481d3c9] Optimise numeric multiplication for short inputs.
2928+
Author: Dean Rasheed <dean.a.rasheed@gmail.com>
2929+
2024-08-15 [c4e44224c] Extend mul_var_short() to 5 and 6-digit inputs.
2930+
Author: Dean Rasheed <dean.a.rasheed@gmail.com>
29082931
2024-08-15 [8dc28d7eb] Optimise numeric multiplication using base-NBASE^2 arith
2932+
Author: Dean Rasheed <dean.a.rasheed@gmail.com>
2933+
2024-10-04 [9428c001f] Speed up numeric division by always using the "fast" alg
29092934
-->
29102935

29112936
<listitem>
29122937
<para>
2913-
Improve the speed of multiplication (Joel Jacobson, Dean Rasheed)
2938+
Improve the speed of numeric multiplication and division (Joel Jacobson, Dean Rasheed)
2939+
<ulink url="&commit_baseurl;ca481d3c9">&sect;</ulink>
2940+
<ulink url="&commit_baseurl;c4e44224c">&sect;</ulink>
29142941
<ulink url="&commit_baseurl;8dc28d7eb">&sect;</ulink>
2942+
<ulink url="&commit_baseurl;9428c001f">&sect;</ulink>
29152943
</para>
29162944
</listitem>
29172945

‎src/backend/utils/adt/datetime.c

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -702,9 +702,18 @@ ParseFraction(char *cp, double *frac)
702702
}
703703
else
704704
{
705+
/*
706+
* On the other hand, let's reject anything that's not digits after
707+
* the ".". strtod is happy with input like ".123e9", but that'd
708+
* break callers' expectation that the result is in 0..1. (It's quite
709+
* difficult to get here with such input, but not impossible.)
710+
*/
711+
if (strspn(cp+1,"0123456789")!=strlen(cp+1))
712+
returnDTERR_BAD_FORMAT;
713+
705714
errno=0;
706715
*frac=strtod(cp,&cp);
707-
/* check for parse failure */
716+
/* check for parse failure(probably redundant given prior check)*/
708717
if (*cp!='\0'||errno!=0)
709718
returnDTERR_BAD_FORMAT;
710719
}
@@ -2958,31 +2967,28 @@ DecodeNumberField(int len, char *str, int fmask,
29582967
{
29592968
char*cp;
29602969

2970+
/*
2971+
* This function was originally meant to cope only with DTK_NUMBER fields,
2972+
* but we now sometimes abuse it to parse (parts of) DTK_DATE fields,
2973+
* which can contain letters and other punctuation. Reject if it's not a
2974+
* valid DTK_NUMBER, that is digits and decimal point(s). (ParseFraction
2975+
* will reject if there's more than one decimal point.)
2976+
*/
2977+
if (strspn(str,"0123456789.")!=len)
2978+
returnDTERR_BAD_FORMAT;
2979+
29612980
/*
29622981
* Have a decimal point? Then this is a date or something with a seconds
29632982
* field...
29642983
*/
29652984
if ((cp=strchr(str,'.'))!=NULL)
29662985
{
2967-
/*
2968-
* Can we use ParseFractionalSecond here? Not clear whether trailing
2969-
* junk should be rejected ...
2970-
*/
2971-
if (cp[1]=='\0')
2972-
{
2973-
/* avoid assuming that strtod will accept "." */
2974-
*fsec=0;
2975-
}
2976-
else
2977-
{
2978-
doublefrac;
2986+
intdterr;
29792987

2980-
errno=0;
2981-
frac=strtod(cp,NULL);
2982-
if (errno!=0)
2983-
returnDTERR_BAD_FORMAT;
2984-
*fsec=rint(frac*1000000);
2985-
}
2988+
/* Convert the fraction and store at *fsec */
2989+
dterr=ParseFractionalSecond(cp,fsec);
2990+
if (dterr)
2991+
returndterr;
29862992
/* Now truncate off the fraction for further processing */
29872993
*cp='\0';
29882994
len=strlen(str);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp