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

Commite9c013f

Browse files
committed
Add unique index on pg_cast.oid, and document pg_cast table.
1 parenta7ffd69 commite9c013f

File tree

4 files changed

+86
-15
lines changed

4 files changed

+86
-15
lines changed

‎doc/src/sgml/catalogs.sgml

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!--
22
Documentation of the system catalogs, directed toward PostgreSQL developers
3-
$Header: /cvsroot/pgsql/doc/src/sgml/catalogs.sgml,v 2.45 2002/07/12 18:43:12 tgl Exp $
3+
$Header: /cvsroot/pgsql/doc/src/sgml/catalogs.sgml,v 2.46 2002/07/22 20:23:19 petere Exp $
44
-->
55

66
<chapter id="catalogs">
@@ -66,6 +66,11 @@
6666
<entry>table columns (<quote>attributes</quote>, <quote>fields</quote>)</entry>
6767
</row>
6868

69+
<row>
70+
<entry>pg_cast</entry>
71+
<entry>casts (data type conversions)</entry>
72+
</row>
73+
6974
<row>
7075
<entry>pg_class</entry>
7176
<entry>tables, indexes, sequences (<quote>relations</quote>)</entry>
@@ -519,6 +524,65 @@
519524
</sect1>
520525

521526

527+
<sect1 id="catalog-pg-cast">
528+
<title>pg_cast</title>
529+
530+
<para>
531+
<structname>pg_cast</structname> stores data type conversion paths
532+
defined with <command>CREATE CAST</command> plus the built-in
533+
conversions.
534+
</para>
535+
536+
<table>
537+
<title>pg_cast Columns</title>
538+
539+
<tgroup cols=4>
540+
<thead>
541+
<row>
542+
<entry>Name</entry>
543+
<entry>Type</entry>
544+
<entry>References</entry>
545+
<entry>Description</entry>
546+
</row>
547+
</thead>
548+
549+
<tbody>
550+
<row>
551+
<entry>castsource</entry>
552+
<entry><type>oid</type></entry>
553+
<entry>pg_type.oid</entry>
554+
<entry>OID of the source data type</entry>
555+
</row>
556+
557+
<row>
558+
<entry>casttarget</entry>
559+
<entry><type>oid</type></entry>
560+
<entry>pg_type.oid</entry>
561+
<entry>OID of the target data type</entry>
562+
</row>
563+
564+
<row>
565+
<entry>castfunc</entry>
566+
<entry><type>oid</type></entry>
567+
<entry>pg_proc.oid</entry>
568+
<entry>
569+
The OID of the function to use to perform this cast. A 0 is
570+
stored if the data types are binary compatible (that is, no
571+
function is needed to perform the cast).
572+
</entry>
573+
</row>
574+
575+
<row>
576+
<entry>castimplicit</entry>
577+
<entry><type>bool</type></entry>
578+
<entry></entry>
579+
<entry>Indication whether this cast can be invoked implicitly</entry>
580+
</row>
581+
</tbody>
582+
</tgroup>
583+
</table>
584+
</sect1>
585+
522586
<sect1 id="catalog-pg-class">
523587
<title>pg_class</title>
524588

‎src/backend/catalog/indexing.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.98 2002/07/1823:11:27 petere Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.99 2002/07/22 20:23:19 petere Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -44,7 +44,7 @@ char *Name_pg_attr_indices[Num_pg_attr_indices] =
4444
char*Name_pg_attrdef_indices[Num_pg_attrdef_indices]=
4545
{AttrDefaultIndex,AttrDefaultOidIndex};
4646
char*Name_pg_cast_indices[Num_pg_cast_indices]=
47-
{CastSourceTargetIndex};
47+
{CastOidIndex,CastSourceTargetIndex};
4848
char*Name_pg_class_indices[Num_pg_class_indices]=
4949
{ClassNameNspIndex,ClassOidIndex};
5050
char*Name_pg_constraint_indices[Num_pg_constraint_indices]=

‎src/backend/commands/functioncmds.c

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/commands/functioncmds.c,v 1.11 2002/07/20 05:37:45 momjian Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/commands/functioncmds.c,v 1.12 2002/07/22 20:23:19 petere Exp $
1313
*
1414
* DESCRIPTION
1515
* These routines take the parse tree and pick out the
@@ -31,6 +31,7 @@
3131
*/
3232
#include"postgres.h"
3333

34+
#include"access/genam.h"
3435
#include"access/heapam.h"
3536
#include"catalog/catname.h"
3637
#include"catalog/dependency.h"
@@ -693,7 +694,7 @@ CreateCast(CreateCastStmt *stmt)
693694
if (procstruct->proisagg)
694695
elog(ERROR,"cast function must not be an aggregate function");
695696
if (procstruct->proretset)
696-
elog(ERROR,"cast function mustbenot return a set");
697+
elog(ERROR,"cast function must not return a set");
697698

698699
ReleaseSysCache(tuple);
699700
}
@@ -727,7 +728,7 @@ CreateCast(CreateCastStmt *stmt)
727728
CatalogCloseIndices(Num_pg_cast_indices,idescs);
728729
}
729730

730-
myself.classId=get_system_catalog_relid(CastRelationName);
731+
myself.classId=RelationGetRelid(relation);
731732
myself.objectId=HeapTupleGetOid(tuple);
732733
myself.objectSubId=0;
733734

@@ -819,21 +820,25 @@ DropCast(DropCastStmt *stmt)
819820
void
820821
DropCastById(OidcastOid)
821822
{
822-
Relationrelation;
823+
Relationrelation,
824+
index;
823825
ScanKeyDatascankey;
824-
HeapScanDescscan;
826+
IndexScanDescscan;
825827
HeapTupletuple;
826828

827829
relation=heap_openr(CastRelationName,RowExclusiveLock);
830+
index=index_openr(CastOidIndex);
831+
828832
ScanKeyEntryInitialize(&scankey,0x0,
829-
ObjectIdAttributeNumber,F_OIDEQ,
830-
ObjectIdGetDatum(castOid));
831-
scan=heap_beginscan(relation,SnapshotNow,1,&scankey);
832-
tuple=heap_getnext(scan,ForwardScanDirection);
833+
1,F_OIDEQ,ObjectIdGetDatum(castOid));
834+
scan=index_beginscan(relation,index,SnapshotNow,1,&scankey);
835+
tuple=index_getnext(scan,ForwardScanDirection);
833836
if (HeapTupleIsValid(tuple))
834837
simple_heap_delete(relation,&tuple->t_self);
835838
else
836839
elog(ERROR,"could not find tuple for cast %u",castOid);
837-
heap_endscan(scan);
840+
index_endscan(scan);
841+
842+
index_close(index);
838843
heap_close(relation,RowExclusiveLock);
839844
}

‎src/include/catalog/indexing.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
99
* Portions Copyright (c) 1994, Regents of the University of California
1010
*
11-
* $Id: indexing.h,v 1.71 2002/07/1823:11:30 petere Exp $
11+
* $Id: indexing.h,v 1.72 2002/07/22 20:23:19 petere Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -26,7 +26,7 @@
2626
#defineNum_pg_amproc_indices1
2727
#defineNum_pg_attr_indices2
2828
#defineNum_pg_attrdef_indices2
29-
#defineNum_pg_cast_indices1
29+
#defineNum_pg_cast_indices2
3030
#defineNum_pg_class_indices2
3131
#defineNum_pg_constraint_indices3
3232
#defineNum_pg_conversion_indices3
@@ -61,6 +61,7 @@
6161
#defineAttrDefaultOidIndex"pg_attrdef_oid_index"
6262
#defineAttributeRelidNameIndex"pg_attribute_relid_attnam_index"
6363
#defineAttributeRelidNumIndex"pg_attribute_relid_attnum_index"
64+
#defineCastOidIndex"pg_cast_oid_index"
6465
#defineCastSourceTargetIndex"pg_cast_source_target_index"
6566
#defineClassNameNspIndex"pg_class_relname_nsp_index"
6667
#defineClassOidIndex"pg_class_oid_index"
@@ -169,6 +170,7 @@ DECLARE_UNIQUE_INDEX(pg_attrdef_adrelid_adnum_index on pg_attrdef using btree(ad
169170
DECLARE_UNIQUE_INDEX(pg_attrdef_oid_indexonpg_attrdefusingbtree(oidoid_ops));
170171
DECLARE_UNIQUE_INDEX(pg_attribute_relid_attnam_indexonpg_attributeusingbtree(attrelidoid_ops,attnamename_ops));
171172
DECLARE_UNIQUE_INDEX(pg_attribute_relid_attnum_indexonpg_attributeusingbtree(attrelidoid_ops,attnumint2_ops));
173+
DECLARE_UNIQUE_INDEX(pg_cast_oid_indexonpg_castusingbtree(oidoid_ops));
172174
DECLARE_UNIQUE_INDEX(pg_cast_source_target_indexonpg_castusingbtree(castsourceoid_ops,casttargetoid_ops));
173175
DECLARE_UNIQUE_INDEX(pg_class_oid_indexonpg_classusingbtree(oidoid_ops));
174176
DECLARE_UNIQUE_INDEX(pg_class_relname_nsp_indexonpg_classusingbtree(relnamename_ops,relnamespaceoid_ops));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp