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

Commit719304a

Browse files
committed
Fix minor issues in psql's new \dAc and related commands.
The type-name pattern in \dAc and \dAf was matched only to the actualpg_type.typname string, which is fairly user-unfriendly in cases wherethat is not what's shown to the user by format_type (compare "_int4"and "integer[]"). Make this code match what \dT does, i.e. match thepattern against either typname or format_type() output. Also fix itsbroken handling of schema-name restrictions. (IOW, make theseprocessSQLNamePattern calls match \dT's.) While here, adjustwhitespace to make the query a little prettier in -E output, too.Also improve some inaccuracies and shaky grammar in the relateddocumentation.Noted while working on a patch for intarray's opclasses; I wonderedwhy I couldn't get a match to "integer*" for the input type name.
1 parent22c1055 commit719304a

File tree

3 files changed

+48
-27
lines changed

3 files changed

+48
-27
lines changed

‎doc/src/sgml/indices.sgml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,6 +1410,15 @@ SELECT am.amname AS index_method,
14101410
ORDER BY index_method, opfamily_name, opfamily_operator;
14111411
</programlisting>
14121412
</para>
1413+
1414+
<tip>
1415+
<para>
1416+
<xref linkend="app-psql"/> has
1417+
commands <command>\dAc</command>, <command>\dAf</command>,
1418+
and <command>\dAo</command>, which provide slightly more sophisticated
1419+
versions of these queries.
1420+
</para>
1421+
</tip>
14131422
</sect1>
14141423

14151424

‎doc/src/sgml/ref/psql-ref.sgml

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,13 +1245,13 @@ testdb=&gt;
12451245
<listitem>
12461246
<para>
12471247
Lists operator classes
1248-
(see <xref linkend="catalog-pg-opclass"/>).
1248+
(see <xref linkend="xindex-opclass"/>).
12491249
If <replaceable class="parameter">access-method-pattern</replaceable>
12501250
is specified, only operator classes associated with access methods whose
1251-
names matchthe pattern are listed.
1251+
names matchthat pattern are listed.
12521252
If <replaceable class="parameter">input-type-pattern</replaceable>
12531253
is specified, only operator classes associated with input types whose
1254-
names matchthe pattern are listed.
1254+
names matchthat pattern are listed.
12551255
If <literal>+</literal> is appended to the command name, each operator
12561256
class is listed with its associated operator family and owner.
12571257
</para>
@@ -1268,13 +1268,13 @@ testdb=&gt;
12681268
<listitem>
12691269
<para>
12701270
Lists operator families
1271-
(see <xref linkend="catalog-pg-opfamily"/>).
1271+
(see <xref linkend="xindex-opfamily"/>).
12721272
If <replaceable class="parameter">access-method-pattern</replaceable>
12731273
is specified, only operator families associated with access methods whose
1274-
names matchthe pattern are listed.
1274+
names matchthat pattern are listed.
12751275
If <replaceable class="parameter">input-type-pattern</replaceable>
12761276
is specified, only operator families associated with input types whose
1277-
names matchthe pattern are listed.
1277+
names matchthat pattern are listed.
12781278
If <literal>+</literal> is appended to the command name, each operator
12791279
family is listed with its owner.
12801280
</para>
@@ -1292,15 +1292,15 @@ testdb=&gt;
12921292
<listitem>
12931293
<para>
12941294
Lists operators associated with operator families
1295-
(<xref linkend="catalog-pg-amop"/>).
1295+
(see<xref linkend="xindex-strategies"/>).
12961296
If <replaceable class="parameter">access-method-pattern</replaceable>
12971297
is specified, only members of operator families associated with access
1298-
methods whose names matchthe pattern are listed.
1299-
If <replaceable class="parameter">input-type-pattern</replaceable>
1300-
is specified, only members of operator families whose names matchthe
1298+
methods whose names matchthat pattern are listed.
1299+
If <replaceable class="parameter">operator-family-pattern</replaceable>
1300+
is specified, only members of operator families whose names matchthat
13011301
pattern are listed.
13021302
If <literal>+</literal> is appended to the command name, each operator
1303-
is listed with itsstrategy number, purpose and sort operator family.
1303+
is listed with itssort operator family (if it is an ordering operator).
13041304
</para>
13051305
</listitem>
13061306
</varlistentry>
@@ -1314,14 +1314,16 @@ testdb=&gt;
13141314
</term>
13151315
<listitem>
13161316
<para>
1317-
Lists functions associated with operator families
1318-
(<xref linkend="catalog-pg-amproc"/>).
1317+
Listssupportfunctions associated with operator families
1318+
(see<xref linkend="xindex-support"/>).
13191319
If <replaceable class="parameter">access-method-pattern</replaceable>
1320-
is specified, only members of operator families associated with access
1321-
methods whose names match the pattern are listed.
1322-
If <replaceable class="parameter">input-type-pattern</replaceable>
1323-
is specified, only members of operator families whose names match the
1324-
pattern are listed.
1320+
is specified, only functions of operator families associated with
1321+
access methods whose names match that pattern are listed.
1322+
If <replaceable class="parameter">operator-family-pattern</replaceable>
1323+
is specified, only functions of operator families whose names match
1324+
that pattern are listed.
1325+
If <literal>+</literal> is appended to the command name, functions are
1326+
displayed verbosely, with their actual parameter lists.
13251327
</para>
13261328
</listitem>
13271329
</varlistentry>

‎src/bin/psql/describe.c

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6050,7 +6050,7 @@ printACLColumn(PQExpBuffer buf, const char *colname)
60506050
* \dAc
60516051
* Lists operator classes
60526052
*
6053-
* Takesanoptional regexps to filter by index access method and type.
6053+
* Takes optional regexps to filter by index access method and input data type.
60546054
*/
60556055
bool
60566056
listOperatorClasses(constchar*access_method_pattern,
@@ -6104,6 +6104,7 @@ listOperatorClasses(const char *access_method_pattern,
61046104
" LEFT JOIN pg_catalog.pg_am am on am.oid = c.opcmethod\n"
61056105
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.opcnamespace\n"
61066106
" LEFT JOIN pg_catalog.pg_type t ON t.oid = c.opcintype\n"
6107+
" LEFT JOIN pg_catalog.pg_namespace tn ON tn.oid = t.typnamespace\n"
61076108
);
61086109
if (verbose)
61096110
appendPQExpBuffer(&buf,
@@ -6114,8 +6115,13 @@ listOperatorClasses(const char *access_method_pattern,
61146115
have_where=processSQLNamePattern(pset.db,&buf,access_method_pattern,
61156116
false, false,NULL,"am.amname",NULL,NULL);
61166117
if (type_pattern)
6118+
{
6119+
/* Match type name pattern against either internal or external name */
61176120
processSQLNamePattern(pset.db,&buf,type_pattern,have_where, false,
6118-
NULL,"t.typname",NULL,NULL);
6121+
"tn.nspname","t.typname",
6122+
"pg_catalog.format_type(t.oid, NULL)",
6123+
"pg_catalog.pg_type_is_visible(t.oid)");
6124+
}
61196125

61206126
appendPQExpBufferStr(&buf,"ORDER BY 1, 2, 4;");
61216127
res=PSQLexec(buf.data);
@@ -6139,7 +6145,7 @@ listOperatorClasses(const char *access_method_pattern,
61396145
* \dAf
61406146
* Lists operator families
61416147
*
6142-
* Takesanoptional regexps to filter by index access method and type.
6148+
* Takes optional regexps to filter by index access method and input data type.
61436149
*/
61446150
bool
61456151
listOperatorFamilies(constchar*access_method_pattern,
@@ -6184,15 +6190,19 @@ listOperatorFamilies(const char *access_method_pattern,
61846190
if (type_pattern)
61856191
{
61866192
appendPQExpBuffer(&buf,
6187-
"\n %s EXISTS (\n"
6193+
" %s EXISTS (\n"
61886194
" SELECT 1\n"
61896195
" FROM pg_catalog.pg_type t\n"
61906196
" JOIN pg_catalog.pg_opclass oc ON oc.opcintype = t.oid\n"
6191-
" WHERE oc.opcfamily = f.oid",
6197+
" LEFT JOIN pg_catalog.pg_namespace tn ON tn.oid = t.typnamespace\n"
6198+
" WHERE oc.opcfamily = f.oid\n",
61926199
have_where ?"AND" :"WHERE");
6200+
/* Match type name pattern against either internal or external name */
61936201
processSQLNamePattern(pset.db,&buf,type_pattern, true, false,
6194-
NULL,"t.typname",NULL,NULL);
6195-
appendPQExpBuffer(&buf,")");
6202+
"tn.nspname","t.typname",
6203+
"pg_catalog.format_type(t.oid, NULL)",
6204+
"pg_catalog.pg_type_is_visible(t.oid)");
6205+
appendPQExpBuffer(&buf," )\n");
61966206
}
61976207

61986208
appendPQExpBufferStr(&buf,"ORDER BY 1, 2;");
@@ -6217,7 +6227,7 @@ listOperatorFamilies(const char *access_method_pattern,
62176227
* \dAo
62186228
* Lists operators of operator families
62196229
*
6220-
* Takesanoptional regexps to filter by index access method and operator
6230+
* Takes optional regexps to filter by index access method and operator
62216231
* family.
62226232
*/
62236233
bool
@@ -6304,7 +6314,7 @@ listOpFamilyOperators(const char *access_method_pattern,
63046314
* \dAp
63056315
* Lists support functions of operator families
63066316
*
6307-
* Takesanoptional regexps to filter by index access method and operator
6317+
* Takes optional regexps to filter by index access method and operator
63086318
* family.
63096319
*/
63106320
bool

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp