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

Commit533020d

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 parent6ee3b5f commit533020d

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
@@ -6056,7 +6056,7 @@ printACLColumn(PQExpBuffer buf, const char *colname)
60566056
* \dAc
60576057
* Lists operator classes
60586058
*
6059-
* Takesanoptional regexps to filter by index access method and type.
6059+
* Takes optional regexps to filter by index access method and input data type.
60606060
*/
60616061
bool
60626062
listOperatorClasses(constchar*access_method_pattern,
@@ -6110,6 +6110,7 @@ listOperatorClasses(const char *access_method_pattern,
61106110
" LEFT JOIN pg_catalog.pg_am am on am.oid = c.opcmethod\n"
61116111
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.opcnamespace\n"
61126112
" LEFT JOIN pg_catalog.pg_type t ON t.oid = c.opcintype\n"
6113+
" LEFT JOIN pg_catalog.pg_namespace tn ON tn.oid = t.typnamespace\n"
61136114
);
61146115
if (verbose)
61156116
appendPQExpBuffer(&buf,
@@ -6120,8 +6121,13 @@ listOperatorClasses(const char *access_method_pattern,
61206121
have_where=processSQLNamePattern(pset.db,&buf,access_method_pattern,
61216122
false, false,NULL,"am.amname",NULL,NULL);
61226123
if (type_pattern)
6124+
{
6125+
/* Match type name pattern against either internal or external name */
61236126
processSQLNamePattern(pset.db,&buf,type_pattern,have_where, false,
6124-
NULL,"t.typname",NULL,NULL);
6127+
"tn.nspname","t.typname",
6128+
"pg_catalog.format_type(t.oid, NULL)",
6129+
"pg_catalog.pg_type_is_visible(t.oid)");
6130+
}
61256131

61266132
appendPQExpBufferStr(&buf,"ORDER BY 1, 2, 4;");
61276133
res=PSQLexec(buf.data);
@@ -6145,7 +6151,7 @@ listOperatorClasses(const char *access_method_pattern,
61456151
* \dAf
61466152
* Lists operator families
61476153
*
6148-
* Takesanoptional regexps to filter by index access method and type.
6154+
* Takes optional regexps to filter by index access method and input data type.
61496155
*/
61506156
bool
61516157
listOperatorFamilies(constchar*access_method_pattern,
@@ -6190,15 +6196,19 @@ listOperatorFamilies(const char *access_method_pattern,
61906196
if (type_pattern)
61916197
{
61926198
appendPQExpBuffer(&buf,
6193-
"\n %s EXISTS (\n"
6199+
" %s EXISTS (\n"
61946200
" SELECT 1\n"
61956201
" FROM pg_catalog.pg_type t\n"
61966202
" JOIN pg_catalog.pg_opclass oc ON oc.opcintype = t.oid\n"
6197-
" WHERE oc.opcfamily = f.oid",
6203+
" LEFT JOIN pg_catalog.pg_namespace tn ON tn.oid = t.typnamespace\n"
6204+
" WHERE oc.opcfamily = f.oid\n",
61986205
have_where ?"AND" :"WHERE");
6206+
/* Match type name pattern against either internal or external name */
61996207
processSQLNamePattern(pset.db,&buf,type_pattern, true, false,
6200-
NULL,"t.typname",NULL,NULL);
6201-
appendPQExpBuffer(&buf,")");
6208+
"tn.nspname","t.typname",
6209+
"pg_catalog.format_type(t.oid, NULL)",
6210+
"pg_catalog.pg_type_is_visible(t.oid)");
6211+
appendPQExpBuffer(&buf," )\n");
62026212
}
62036213

62046214
appendPQExpBufferStr(&buf,"ORDER BY 1, 2;");
@@ -6223,7 +6233,7 @@ listOperatorFamilies(const char *access_method_pattern,
62236233
* \dAo
62246234
* Lists operators of operator families
62256235
*
6226-
* Takesanoptional regexps to filter by index access method and operator
6236+
* Takes optional regexps to filter by index access method and operator
62276237
* family.
62286238
*/
62296239
bool
@@ -6310,7 +6320,7 @@ listOpFamilyOperators(const char *access_method_pattern,
63106320
* \dAp
63116321
* Lists support functions of operator families
63126322
*
6313-
* Takesanoptional regexps to filter by index access method and operator
6323+
* Takes optional regexps to filter by index access method and operator
63146324
* family.
63156325
*/
63166326
bool

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp