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

Commitbb03010

Browse files
committed
Remove the "opaque" pseudo-type and associated compatibility hacks.
A long time ago, it was necessary to declare datatype I/O functions,triggers, and language handler support functions in a very type-unsafeway involving a single pseudo-type "opaque". We got rid of thoseconventions in 7.3, but there was still support in various places toautomatically convert such functions to the modern declaration style,to be able to transparently re-load dumps from pre-7.3 servers.It seems unnecessary to continue to support that anymore, so take outthe hacks; whereupon the "opaque" pseudo-type itself is no longerneeded and can be dropped.This is part of a group of patches removing various server-side klugesfor transparently upgrading pre-8.0 dump files. Since we've had fewcomplaints about dropping pg_dump's support for dumping from pre-8.0servers (commit64f3524), it seems okay to now remove these kluges.Discussion:https://postgr.es/m/4110.1583255415@sss.pgh.pa.us
1 parent84eca14 commitbb03010

File tree

22 files changed

+168
-432
lines changed

22 files changed

+168
-432
lines changed

‎doc/src/sgml/datatype.sgml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4827,10 +4827,6 @@ SELECT * FROM pg_attribute
48274827
<primary>unknown</primary>
48284828
</indexterm>
48294829

4830-
<indexterm zone="datatype-pseudo">
4831-
<primary>opaque</primary>
4832-
</indexterm>
4833-
48344830
<para>
48354831
The <productname>PostgreSQL</productname> type system contains a
48364832
number of special-purpose entries that are collectively called
@@ -4953,12 +4949,6 @@ SELECT * FROM pg_attribute
49534949
<entry>Identifies a not-yet-resolved type, e.g. of an undecorated
49544950
string literal.</entry>
49554951
</row>
4956-
4957-
<row>
4958-
<entry><type>opaque</type></entry>
4959-
<entry>An obsolete type name that formerly served many of the above
4960-
purposes.</entry>
4961-
</row>
49624952
</tbody>
49634953
</tgroup>
49644954
</table>

‎doc/src/sgml/ref/create_language.sgml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -211,16 +211,6 @@ CREATE [ OR REPLACE ] [ TRUSTED ] [ PROCEDURAL ] LANGUAGE <replaceable class="pa
211211
database, which will cause it to be available automatically in
212212
all subsequently-created databases.
213213
</para>
214-
215-
<para>
216-
In <productname>PostgreSQL</productname> versions before 7.3, it was
217-
necessary to declare handler functions as returning the placeholder
218-
type <type>opaque</type>, rather than <type>language_handler</type>.
219-
To support loading
220-
of old dump files, <command>CREATE LANGUAGE</command> will accept a function
221-
declared as returning <type>opaque</type>, but it will issue a notice and
222-
change the function's declared return type to <type>language_handler</type>.
223-
</para>
224214
</refsect1>
225215

226216
<refsect1 id="sql-createlanguage-examples">

‎doc/src/sgml/ref/create_trigger.sgml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -543,15 +543,6 @@ UPDATE OF <replaceable>column_name1</replaceable> [, <replaceable>column_name2</
543543
row-level triggers with transition relations cannot be defined on
544544
partitions or inheritance child tables.
545545
</para>
546-
547-
<para>
548-
In <productname>PostgreSQL</productname> versions before 7.3, it was
549-
necessary to declare trigger functions as returning the placeholder
550-
type <type>opaque</type>, rather than <type>trigger</type>. To support loading
551-
of old dump files, <command>CREATE TRIGGER</command> will accept a function
552-
declared as returning <type>opaque</type>, but it will issue a notice and
553-
change the function's declared return type to <type>trigger</type>.
554-
</para>
555546
</refsect1>
556547

557548
<refsect1 id="sql-createtrigger-examples">

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -823,18 +823,6 @@ CREATE TYPE <replaceable class="parameter">name</replaceable>
823823
function is written in C.
824824
</para>
825825

826-
<para>
827-
In <productname>PostgreSQL</productname> versions before 7.3, it
828-
was customary to avoid creating a shell type at all, by replacing the
829-
functions' forward references to the type name with the placeholder
830-
pseudo-type <type>opaque</type>. The <type>cstring</type> arguments and
831-
results also had to be declared as <type>opaque</type> before 7.3. To
832-
support loading of old dump files, <command>CREATE TYPE</command> will
833-
accept I/O functions declared using <type>opaque</type>, but it will issue
834-
a notice and change the function declarations to use the correct
835-
types.
836-
</para>
837-
838826
</refsect1>
839827

840828
<refsect1>

‎src/backend/commands/functioncmds.c

Lines changed: 0 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,93 +1399,6 @@ AlterFunction(ParseState *pstate, AlterFunctionStmt *stmt)
13991399
returnaddress;
14001400
}
14011401

1402-
/*
1403-
* SetFunctionReturnType - change declared return type of a function
1404-
*
1405-
* This is presently only used for adjusting legacy functions that return
1406-
* OPAQUE to return whatever we find their correct definition should be.
1407-
* The caller should emit a suitable warning explaining what we did.
1408-
*/
1409-
void
1410-
SetFunctionReturnType(OidfuncOid,OidnewRetType)
1411-
{
1412-
Relationpg_proc_rel;
1413-
HeapTupletup;
1414-
Form_pg_procprocForm;
1415-
ObjectAddressfunc_address;
1416-
ObjectAddresstype_address;
1417-
1418-
pg_proc_rel=table_open(ProcedureRelationId,RowExclusiveLock);
1419-
1420-
tup=SearchSysCacheCopy1(PROCOID,ObjectIdGetDatum(funcOid));
1421-
if (!HeapTupleIsValid(tup))/* should not happen */
1422-
elog(ERROR,"cache lookup failed for function %u",funcOid);
1423-
procForm= (Form_pg_proc)GETSTRUCT(tup);
1424-
1425-
if (procForm->prorettype!=OPAQUEOID)/* caller messed up */
1426-
elog(ERROR,"function %u doesn't return OPAQUE",funcOid);
1427-
1428-
/* okay to overwrite copied tuple */
1429-
procForm->prorettype=newRetType;
1430-
1431-
/* update the catalog and its indexes */
1432-
CatalogTupleUpdate(pg_proc_rel,&tup->t_self,tup);
1433-
1434-
table_close(pg_proc_rel,RowExclusiveLock);
1435-
1436-
/*
1437-
* Also update the dependency to the new type. Opaque is a pinned type, so
1438-
* there is no old dependency record for it that we would need to remove.
1439-
*/
1440-
ObjectAddressSet(type_address,TypeRelationId,newRetType);
1441-
ObjectAddressSet(func_address,ProcedureRelationId,funcOid);
1442-
recordDependencyOn(&func_address,&type_address,DEPENDENCY_NORMAL);
1443-
}
1444-
1445-
1446-
/*
1447-
* SetFunctionArgType - change declared argument type of a function
1448-
*
1449-
* As above, but change an argument's type.
1450-
*/
1451-
void
1452-
SetFunctionArgType(OidfuncOid,intargIndex,OidnewArgType)
1453-
{
1454-
Relationpg_proc_rel;
1455-
HeapTupletup;
1456-
Form_pg_procprocForm;
1457-
ObjectAddressfunc_address;
1458-
ObjectAddresstype_address;
1459-
1460-
pg_proc_rel=table_open(ProcedureRelationId,RowExclusiveLock);
1461-
1462-
tup=SearchSysCacheCopy1(PROCOID,ObjectIdGetDatum(funcOid));
1463-
if (!HeapTupleIsValid(tup))/* should not happen */
1464-
elog(ERROR,"cache lookup failed for function %u",funcOid);
1465-
procForm= (Form_pg_proc)GETSTRUCT(tup);
1466-
1467-
if (argIndex<0||argIndex >=procForm->pronargs||
1468-
procForm->proargtypes.values[argIndex]!=OPAQUEOID)
1469-
elog(ERROR,"function %u doesn't take OPAQUE",funcOid);
1470-
1471-
/* okay to overwrite copied tuple */
1472-
procForm->proargtypes.values[argIndex]=newArgType;
1473-
1474-
/* update the catalog and its indexes */
1475-
CatalogTupleUpdate(pg_proc_rel,&tup->t_self,tup);
1476-
1477-
table_close(pg_proc_rel,RowExclusiveLock);
1478-
1479-
/*
1480-
* Also update the dependency to the new type. Opaque is a pinned type, so
1481-
* there is no old dependency record for it that we would need to remove.
1482-
*/
1483-
ObjectAddressSet(type_address,TypeRelationId,newArgType);
1484-
ObjectAddressSet(func_address,ProcedureRelationId,funcOid);
1485-
recordDependencyOn(&func_address,&type_address,DEPENDENCY_NORMAL);
1486-
}
1487-
1488-
14891402

14901403
/*
14911404
* CREATE CAST

‎src/backend/commands/proclang.c

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -74,27 +74,10 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
7474
handlerOid=LookupFuncName(stmt->plhandler,0,NULL, false);
7575
funcrettype=get_func_rettype(handlerOid);
7676
if (funcrettype!=LANGUAGE_HANDLEROID)
77-
{
78-
/*
79-
* We allow OPAQUE just so we can load old dump files. When we see a
80-
* handler function declared OPAQUE, change it to LANGUAGE_HANDLER.
81-
* (This is probably obsolete and removable?)
82-
*/
83-
if (funcrettype==OPAQUEOID)
84-
{
85-
ereport(WARNING,
86-
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
87-
errmsg("changing return type of function %s from %s to %s",
88-
NameListToString(stmt->plhandler),
89-
"opaque","language_handler")));
90-
SetFunctionReturnType(handlerOid,LANGUAGE_HANDLEROID);
91-
}
92-
else
93-
ereport(ERROR,
94-
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
95-
errmsg("function %s must return type %s",
96-
NameListToString(stmt->plhandler),"language_handler")));
97-
}
77+
ereport(ERROR,
78+
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
79+
errmsg("function %s must return type %s",
80+
NameListToString(stmt->plhandler),"language_handler")));
9881

9982
/* validate the inline function */
10083
if (stmt->plinline)

‎src/backend/commands/trigger.c

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -694,25 +694,10 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
694694
}
695695
funcrettype=get_func_rettype(funcoid);
696696
if (funcrettype!=TRIGGEROID)
697-
{
698-
/*
699-
* We allow OPAQUE just so we can load old dump files. When we see a
700-
* trigger function declared OPAQUE, change it to TRIGGER.
701-
*/
702-
if (funcrettype==OPAQUEOID)
703-
{
704-
ereport(WARNING,
705-
(errmsg("changing return type of function %s from %s to %s",
706-
NameListToString(stmt->funcname),
707-
"opaque","trigger")));
708-
SetFunctionReturnType(funcoid,TRIGGEROID);
709-
}
710-
else
711-
ereport(ERROR,
712-
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
713-
errmsg("function %s must return type %s",
714-
NameListToString(stmt->funcname),"trigger")));
715-
}
697+
ereport(ERROR,
698+
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
699+
errmsg("function %s must return type %s",
700+
NameListToString(stmt->funcname),"trigger")));
716701

717702
/*
718703
* If it's a user-entered CREATE CONSTRAINT TRIGGER command, make a

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp