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

Commit42ce74b

Browse files
committed
COMMENT ON casts, conversions, languages, operator classes, and
large objects. Dump all these in pg_dump; also add code to pg_dumpuser-defined conversions. Make psql's large object code rely onthe backend for inserting/deleting LOB comments, instead of trying tohack pg_description directly. Documentation and regression tests added.Christopher Kings-Lynne, code reviewed by Tom
1 parent0a97cb3 commit42ce74b

37 files changed

+879
-55
lines changed

‎doc/src/sgml/ref/comment.sgml

Lines changed: 68 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/comment.sgml,v 1.23 2003/09/09 18:28:52 tgl Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/comment.sgml,v 1.24 2003/11/21 22:32:48 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -25,12 +25,17 @@ COMMENT ON
2525
TABLE <replaceable class="PARAMETER">object_name</replaceable> |
2626
COLUMN <replaceable class="PARAMETER">table_name</replaceable>.<replaceable class="PARAMETER">column_name</replaceable> |
2727
AGGREGATE <replaceable class="PARAMETER">agg_name</replaceable> (<replaceable class="PARAMETER">agg_type</replaceable>) |
28+
CAST (<replaceable>sourcetype</replaceable> AS <replaceable>targettype</replaceable>) |
2829
CONSTRAINT <replaceable class="PARAMETER">constraint_name</replaceable> ON <replaceable class="PARAMETER">table_name</replaceable> |
30+
CONVERSION <replaceable class="PARAMETER">object_name</replaceable> |
2931
DATABASE <replaceable class="PARAMETER">object_name</replaceable> |
3032
DOMAIN <replaceable class="PARAMETER">object_name</replaceable> |
3133
FUNCTION <replaceable class="PARAMETER">func_name</replaceable> (<replaceable class="PARAMETER">arg1_type</replaceable>, <replaceable class="PARAMETER">arg2_type</replaceable>, ...) |
3234
INDEX <replaceable class="PARAMETER">object_name</replaceable> |
35+
LARGE OBJECT <replaceable class="PARAMETER">large_object_oid</replaceable> |
3336
OPERATOR <replaceable class="PARAMETER">op</replaceable> (<replaceable class="PARAMETER">leftoperand_type</replaceable>, <replaceable class="PARAMETER">rightoperand_type</replaceable>) |
37+
OPERATOR CLASS <replaceable class="PARAMETER">object_name</replaceable> USING <replaceable class="parameter">index_method</replaceable> |
38+
[ PROCEDURAL ] LANGUAGE <replaceable class="PARAMETER">object_name</replaceable> |
3439
RULE <replaceable class="PARAMETER">rule_name</replaceable> ON <replaceable class="PARAMETER">table_name</replaceable> |
3540
SCHEMA <replaceable class="PARAMETER">object_name</replaceable> |
3641
SEQUENCE <replaceable class="PARAMETER">object_name</replaceable> |
@@ -70,21 +75,68 @@ COMMENT ON
7075
<varlistentry>
7176
<term><replaceable class="parameter">object_name</replaceable></term>
7277
<term><replaceable class="parameter">table_name.column_name</replaceable></term>
73-
<term><replaceable class="parameter">aggname</replaceable></term>
78+
<term><replaceable class="parameter">agg_name</replaceable></term>
7479
<term><replaceable class="parameter">constraint_name</replaceable></term>
7580
<term><replaceable class="parameter">func_name</replaceable></term>
7681
<term><replaceable class="parameter">op</replaceable></term>
7782
<term><replaceable class="parameter">rule_name</replaceable></term>
7883
<term><replaceable class="parameter">trigger_name</replaceable></term>
7984
<listitem>
8085
<para>
81-
The name of the object to bebecommented. Names of tables,
82-
aggregates, domains, functions, indexes, operators,sequences,
83-
types, and views may be schema-qualified.
86+
The name of the object to be commented. Names of tables,
87+
aggregates, domains, functions, indexes, operators,operator classes,
88+
sequences,types, and views may be schema-qualified.
8489
</para>
8590
</listitem>
8691
</varlistentry>
8792

93+
<varlistentry>
94+
<term><replaceable class="parameter">agg_type</replaceable></term>
95+
<listitem>
96+
<para>
97+
The argument data type of the aggregate function, or
98+
<literal>*</literal> if the function accepts any data type.
99+
</para>
100+
</listitem>
101+
</varlistentry>
102+
103+
<varlistentry>
104+
<term><replaceable class="parameter">large_object_oid</replaceable></term>
105+
<listitem>
106+
<para>
107+
The OID of the large object.
108+
</para>
109+
</listitem>
110+
</varlistentry>
111+
112+
<varlistentry>
113+
<term><literal>PROCEDURAL</literal></term>
114+
115+
<listitem>
116+
<para>
117+
This is a noise word.
118+
</para>
119+
</listitem>
120+
</varlistentry>
121+
122+
<varlistentry>
123+
<term><replaceable>sourcetype</replaceable></term>
124+
<listitem>
125+
<para>
126+
The name of the source data type of the cast.
127+
</para>
128+
</listitem>
129+
</varlistentry>
130+
131+
<varlistentry>
132+
<term><replaceable>targettype</replaceable></term>
133+
<listitem>
134+
<para>
135+
The name of the target data type of the cast.
136+
</para>
137+
</listitem>
138+
</varlistentry>
139+
88140
<varlistentry>
89141
<term><replaceable class="parameter">text</replaceable></term>
90142
<listitem>
@@ -93,12 +145,18 @@ COMMENT ON
93145
</para>
94146
</listitem>
95147
</varlistentry>
148+
96149
</variablelist>
97150
</refsect1>
98151

99152
<refsect1>
100153
<title>Notes</title>
101154

155+
<para>
156+
A comment for a database can only be created in that database,
157+
and will only be visible in that database, not in other databases.
158+
</para>
159+
102160
<para>
103161
There is presently no security mechanism for comments: any user
104162
connected to a database can see all the comments for objects in
@@ -130,13 +188,18 @@ COMMENT ON TABLE mytable IS NULL;
130188

131189
<programlisting>
132190
COMMENT ON AGGREGATE my_aggregate (double precision) IS 'Computes sample variance';
191+
COMMENT ON CAST (text AS int4) IS 'Allow casts from text to int4';
133192
COMMENT ON COLUMN my_table.my_column IS 'Employee ID number';
193+
COMMENT ON CONVERSION my_conv IS 'Conversion to Unicode';
134194
COMMENT ON DATABASE my_database IS 'Development Database';
135195
COMMENT ON DOMAIN my_domain IS 'Email Address Domain';
136196
COMMENT ON FUNCTION my_function (timestamp) IS 'Returns Roman Numeral';
137197
COMMENT ON INDEX my_index IS 'Enforces uniqueness on employee ID';
198+
COMMENT ON LANGUAGE plpython IS 'Python support for stored procedures';
199+
COMMENT ON LARGE OBJECT 346344 IS 'Planning document';
138200
COMMENT ON OPERATOR ^ (text, text) IS 'Performs intersection of two texts';
139201
COMMENT ON OPERATOR ^ (NONE, text) IS 'This is a prefix operator on text';
202+
COMMENT ON OPERATOR CLASS int4ops USING btree IS '4 byte integer operators for btrees';
140203
COMMENT ON RULE my_rule ON my_table IS 'Logs updates of employee records';
141204
COMMENT ON SCHEMA my_schema IS 'Departmental data';
142205
COMMENT ON SEQUENCE my_sequence IS 'Used to generate primary keys';

‎src/backend/catalog/aclchk.c

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.93 2003/11/12 21:15:48 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.94 2003/11/21 22:32:48 tgl Exp $
1212
*
1313
* NOTES
1414
* See acl.h.
@@ -22,6 +22,7 @@
2222
#include"catalog/catname.h"
2323
#include"catalog/indexing.h"
2424
#include"catalog/namespace.h"
25+
#include"catalog/pg_conversion.h"
2526
#include"catalog/pg_database.h"
2627
#include"catalog/pg_group.h"
2728
#include"catalog/pg_language.h"
@@ -1551,3 +1552,31 @@ pg_database_ownercheck(Oid db_oid, AclId userid)
15511552

15521553
returnuserid==dba;
15531554
}
1555+
1556+
/*
1557+
* Ownership check for a conversion (specified by OID).
1558+
*/
1559+
bool
1560+
pg_conversion_ownercheck(Oidconv_oid,AclIduserid)
1561+
{
1562+
HeapTupletuple;
1563+
AclIdowner_id;
1564+
1565+
/* Superusers bypass all permission checking. */
1566+
if (superuser_arg(userid))
1567+
return true;
1568+
1569+
tuple=SearchSysCache(CONOID,
1570+
ObjectIdGetDatum(conv_oid),
1571+
0,0,0);
1572+
if (!HeapTupleIsValid(tuple))
1573+
ereport(ERROR,
1574+
(errcode(ERRCODE_UNDEFINED_OBJECT),
1575+
errmsg("conversion with OID %u does not exist",conv_oid)));
1576+
1577+
owner_id= ((Form_pg_conversion)GETSTRUCT(tuple))->conowner;
1578+
1579+
ReleaseSysCache(tuple);
1580+
1581+
returnuserid==owner_id;
1582+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp