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

Commit74c1723

Browse files
committed
Remove user-selectable ANALYZE option for range types.
It's not clear that a per-datatype typanalyze function would be any moreuseful than a generic typanalyze for ranges. What *is* clear is thatletting unprivileged users select typanalyze functions is a crash risk orworse. So remove the option from CREATE TYPE AS RANGE, and instead put ina generic typanalyze function for ranges. The generic function doesnothing as yet, but hopefully we'll improve that before 9.2 release.
1 parentdf73584 commit74c1723

File tree

8 files changed

+36
-40
lines changed

8 files changed

+36
-40
lines changed

‎doc/src/sgml/ref/create_type.sgml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ CREATE TYPE <replaceable class="parameter">name</replaceable> AS RANGE (
3333
[ , COLLATION = <replaceable class="parameter">collation</replaceable> ]
3434
[ , CANONICAL = <replaceable class="parameter">canonical_function</replaceable> ]
3535
[ , SUBTYPE_DIFF = <replaceable class="parameter">subtype_diff_function</replaceable> ]
36-
[ , ANALYZE = <replaceable class="parameter">analyze_function</replaceable> ]
3736
)
3837

3938
CREATE TYPE <replaceable class="parameter">name</replaceable> (
@@ -167,12 +166,6 @@ CREATE TYPE <replaceable class="parameter">name</replaceable>
167166
that is, its result should be positive whenever its first argument is
168167
greater than its second according to the sort ordering.
169168
</para>
170-
171-
<para>
172-
The optional <replaceable class="parameter">analyze</replaceable>
173-
function performs type-specific statistics collection for columns of the
174-
range type. This is defined the same as for base types; see below.
175-
</para>
176169
</refsect2>
177170

178171
<refsect2>

‎src/backend/commands/typecmds.c

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,12 +1225,10 @@ DefineRange(CreateRangeStmt *stmt)
12251225
List*rangeCollationName=NIL;
12261226
List*rangeCanonicalName=NIL;
12271227
List*rangeSubtypeDiffName=NIL;
1228-
List*rangeAnalyzeName=NIL;
12291228
OidrangeSubOpclass;
12301229
OidrangeCollation;
12311230
regprocrangeCanonical;
12321231
regprocrangeSubtypeDiff;
1233-
regprocrangeAnalyze;
12341232
int16subtyplen;
12351233
boolsubtypbyval;
12361234
charsubtypalign;
@@ -1326,14 +1324,6 @@ DefineRange(CreateRangeStmt *stmt)
13261324
errmsg("conflicting or redundant options")));
13271325
rangeSubtypeDiffName=defGetQualifiedName(defel);
13281326
}
1329-
elseif (pg_strcasecmp(defel->defname,"analyze")==0)
1330-
{
1331-
if (rangeAnalyzeName!=NIL)
1332-
ereport(ERROR,
1333-
(errcode(ERRCODE_SYNTAX_ERROR),
1334-
errmsg("conflicting or redundant options")));
1335-
rangeAnalyzeName=defGetQualifiedName(defel);
1336-
}
13371327
else
13381328
ereport(ERROR,
13391329
(errcode(ERRCODE_SYNTAX_ERROR),
@@ -1386,12 +1376,6 @@ DefineRange(CreateRangeStmt *stmt)
13861376
else
13871377
rangeSubtypeDiff=InvalidOid;
13881378

1389-
if (rangeAnalyzeName!=NIL)
1390-
rangeAnalyze=findTypeAnalyzeFunction(rangeAnalyzeName,
1391-
typoid);
1392-
else
1393-
rangeAnalyze=InvalidOid;
1394-
13951379
get_typlenbyvalalign(rangeSubtype,
13961380
&subtyplen,&subtypbyval,&subtypalign);
13971381

@@ -1420,7 +1404,7 @@ DefineRange(CreateRangeStmt *stmt)
14201404
F_RANGE_SEND,/* send procedure */
14211405
InvalidOid,/* typmodin procedure - none */
14221406
InvalidOid,/* typmodout procedure - none */
1423-
rangeAnalyze,/* analyze procedure */
1407+
F_RANGE_TYPANALYZE,/* analyze procedure */
14241408
InvalidOid,/* element type ID - none */
14251409
false,/* this is not an array type */
14261410
rangeArrayOid,/* array type we are about to create */

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,6 +1135,23 @@ hash_range(PG_FUNCTION_ARGS)
11351135
PG_RETURN_INT32(result);
11361136
}
11371137

1138+
/* ANALYZE support */
1139+
1140+
/* typanalyze function for range datatypes */
1141+
Datum
1142+
range_typanalyze(PG_FUNCTION_ARGS)
1143+
{
1144+
/*
1145+
* For the moment, just punt and don't analyze range columns. If we
1146+
* get close to release without having a better answer, we could
1147+
* consider letting std_typanalyze do what it can ... but those stats
1148+
* are probably next door to useless for most activity with range
1149+
* columns, so it's not clear it's worth gathering them.
1150+
*/
1151+
PG_RETURN_BOOL(false);
1152+
}
1153+
1154+
11381155
/*
11391156
*----------------------------------------------------------
11401157
* CANONICAL FUNCTIONS

‎src/bin/pg_dump/pg_dump.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7482,11 +7482,11 @@ dumpRangeType(Archive *fout, TypeInfo *tyinfo)
74827482
"opc.opcdefault, "
74837483
"CASE WHEN rngcollation = st.typcollation THEN 0 "
74847484
" ELSE rngcollation END AS collation, "
7485-
"rngcanonical, rngsubdiff, t.typanalyze "
7486-
"FROM pg_catalog.pg_type t, pg_catalog.pg_type st, "
7487-
" pg_catalog.pg_opclass opc, pg_catalog.pg_range r "
7488-
"WHEREt.oid =rngtypid ANDst.oid =rngsubtype AND "
7489-
" opc.oid = rngsubopc ANDrngtypid = '%u'",
7485+
"rngcanonical, rngsubdiff "
7486+
"FROM pg_catalog.pg_range r, pg_catalog.pg_type st, "
7487+
" pg_catalog.pg_opclass opc "
7488+
"WHEREst.oid =rngsubtype ANDopc.oid =rngsubopc AND "
7489+
"rngtypid = '%u'",
74907490
tyinfo->dobj.catId.oid);
74917491

74927492
res=PQexec(g_conn,query->data);
@@ -7552,10 +7552,6 @@ dumpRangeType(Archive *fout, TypeInfo *tyinfo)
75527552
if (strcmp(procname,"-")!=0)
75537553
appendPQExpBuffer(q,",\n subtype_diff = %s",procname);
75547554

7555-
procname=PQgetvalue(res,0,PQfnumber(res,"typanalyze"));
7556-
if (strcmp(procname,"-")!=0)
7557-
appendPQExpBuffer(q,",\n analyze = %s",procname);
7558-
75597555
appendPQExpBuffer(q,"\n);\n");
75607556

75617557
appendPQExpBuffer(labelq,"TYPE %s",fmtId(tyinfo->dobj.name));

‎src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/*yyyymmddN */
56-
#defineCATALOG_VERSION_NO201111222
56+
#defineCATALOG_VERSION_NO201111231
5757

5858
#endif

‎src/include/catalog/pg_proc.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4413,6 +4413,9 @@ DATA(insert OID = 3881 ( range_gist_samePGNSP PGUID 12 1 0 0 0 f f f t f i 3
44134413
DESCR("GiST support");
44144414
DATA(insertOID=3902 (hash_rangePGNSPPGUID121000ffftfi1023"3831"_null__null__null__null_hash_range_null__null__null_ ));
44154415
DESCR("hash a range");
4416+
DATA(insertOID=3916 (range_typanalyzePGNSPPGUID121000ffftfs1016"2281"_null__null__null__null_range_typanalyze_null__null__null_ ));
4417+
DESCR("range typanalyze");
4418+
44164419
DATA(insertOID=3914 (int4range_canonicalPGNSPPGUID121000ffftfi103904"3904"_null__null__null__null_int4range_canonical_null__null__null_ ));
44174420
DESCR("convert an int4 range to canonical form");
44184421
DATA(insertOID=3928 (int8range_canonicalPGNSPPGUID121000ffftfi103926"3926"_null__null__null__null_int8range_canonical_null__null__null_ ));

‎src/include/catalog/pg_type.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -593,23 +593,23 @@ DESCR("txid snapshot");
593593
DATA(insertOID=2949 (_txid_snapshotPGNSPPGUID-1fbAft \054029700array_inarray_outarray_recvarray_send---dxf0-100_null__null_ ));
594594

595595
/* range types */
596-
DATA(insertOID=3904 (int4rangePGNSPPGUID-1frRft \054003905range_inrange_outrange_recvrange_send---ixf0-100_null__null_ ));
596+
DATA(insertOID=3904 (int4rangePGNSPPGUID-1frRft \054003905range_inrange_outrange_recvrange_send--range_typanalyzeixf0-100_null__null_ ));
597597
DESCR("range of integers");
598598
#defineINT4RANGEOID3904
599599
DATA(insertOID=3905 (_int4rangePGNSPPGUID-1fbAft \054039040array_inarray_outarray_recvarray_send---ixf0-100_null__null_ ));
600-
DATA(insertOID=3906 (numrangePGNSPPGUID-1frRft \054003907range_inrange_outrange_recvrange_send---ixf0-100_null__null_ ));
600+
DATA(insertOID=3906 (numrangePGNSPPGUID-1frRft \054003907range_inrange_outrange_recvrange_send--range_typanalyzeixf0-100_null__null_ ));
601601
DESCR("range of numerics");
602602
DATA(insertOID=3907 (_numrangePGNSPPGUID-1fbAft \054039060array_inarray_outarray_recvarray_send---ixf0-100_null__null_ ));
603-
DATA(insertOID=3908 (tsrangePGNSPPGUID-1frRft \054003909range_inrange_outrange_recvrange_send---dxf0-100_null__null_ ));
603+
DATA(insertOID=3908 (tsrangePGNSPPGUID-1frRft \054003909range_inrange_outrange_recvrange_send--range_typanalyzedxf0-100_null__null_ ));
604604
DESCR("range of timestamps without time zone");
605605
DATA(insertOID=3909 (_tsrangePGNSPPGUID-1fbAft \054039080array_inarray_outarray_recvarray_send---dxf0-100_null__null_ ));
606-
DATA(insertOID=3910 (tstzrangePGNSPPGUID-1frRft \054003911range_inrange_outrange_recvrange_send---dxf0-100_null__null_ ));
606+
DATA(insertOID=3910 (tstzrangePGNSPPGUID-1frRft \054003911range_inrange_outrange_recvrange_send--range_typanalyzedxf0-100_null__null_ ));
607607
DESCR("range of timestamps with time zone");
608608
DATA(insertOID=3911 (_tstzrangePGNSPPGUID-1fbAft \054039100array_inarray_outarray_recvarray_send---dxf0-100_null__null_ ));
609-
DATA(insertOID=3912 (daterangePGNSPPGUID-1frRft \054003913range_inrange_outrange_recvrange_send---ixf0-100_null__null_ ));
609+
DATA(insertOID=3912 (daterangePGNSPPGUID-1frRft \054003913range_inrange_outrange_recvrange_send--range_typanalyzeixf0-100_null__null_ ));
610610
DESCR("range of dates");
611611
DATA(insertOID=3913 (_daterangePGNSPPGUID-1fbAft \054039120array_inarray_outarray_recvarray_send---ixf0-100_null__null_ ));
612-
DATA(insertOID=3926 (int8rangePGNSPPGUID-1frRft \054003927range_inrange_outrange_recvrange_send---dxf0-100_null__null_ ));
612+
DATA(insertOID=3926 (int8rangePGNSPPGUID-1frRft \054003927range_inrange_outrange_recvrange_send--range_typanalyzedxf0-100_null__null_ ));
613613
DESCR("range of bigints");
614614
DATA(insertOID=3927 (_int8rangePGNSPPGUID-1fbAft \054039260array_inarray_outarray_recvarray_send---dxf0-100_null__null_ ));
615615

‎src/include/utils/rangetypes.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ extern Datum range_gt(PG_FUNCTION_ARGS);
127127
/* Hash support */
128128
externDatumhash_range(PG_FUNCTION_ARGS);
129129

130+
/* ANALYZE support */
131+
externDatumrange_typanalyze(PG_FUNCTION_ARGS);
132+
130133
/* Canonical functions */
131134
externDatumint4range_canonical(PG_FUNCTION_ARGS);
132135
externDatumint8range_canonical(PG_FUNCTION_ARGS);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp