Don't use custom OID symbols in pg_type.dat, either.

On the same reasoning as in commit 36b931214, forbid using custom
oid_symbol macros in pg_type as well as pg_proc, so that we always
rely on the predictable macro names generated by genbki.pl.

We do continue to grant grandfather status to the names CASHOID and
LSNOID, although those are now considered deprecated aliases for the
preferred names MONEYOID and PG_LSNOID.  This is because there's
likely to be client-side code using the old names, and this bout of
neatnik-ism doesn't quite seem worth breaking client code.

There might be a case for grandfathering EVTTRIGGEROID, too, since
externally-maintained PLs may reference that symbol.  But renaming
such references to EVENT_TRIGGEROID doesn't seem like a particularly
heavy lift --- we make far more significant backend API changes in
every major release.  For now I didn't add that, but we could
reconsider if there's pushback.

The other names changed here seem pretty unlikely to have any outside
uses.  Again, we could add alias macros if there are complaints, but
for now I didn't.

As before, no need for a catversion bump.

John Naylor

Discussion: https://postgr.es/m/CAFBsxsHpCbjfoddNGpnnnY5pHwckWfiYkMYSF74PmP1su0+ZOw@mail.gmail.com
This commit is contained in:
Tom Lane 2020-10-29 13:33:38 -04:00
parent 1c7675a7a4
commit f90149e628
13 changed files with 38 additions and 37 deletions

View File

@ -133,7 +133,7 @@ static const struct typinfo TypInfo[] = {
F_XIDIN, F_XIDOUT},
{"cid", CIDOID, 0, 4, true, TYPALIGN_INT, TYPSTORAGE_PLAIN, InvalidOid,
F_CIDIN, F_CIDOUT},
{"pg_node_tree", PGNODETREEOID, 0, -1, false, TYPALIGN_INT, TYPSTORAGE_EXTENDED, DEFAULT_COLLATION_OID,
{"pg_node_tree", PG_NODE_TREEOID, 0, -1, false, TYPALIGN_INT, TYPSTORAGE_EXTENDED, DEFAULT_COLLATION_OID,
F_PG_NODE_TREE_IN, F_PG_NODE_TREE_OUT},
{"int2vector", INT2VECTOROID, INT2OID, -1, false, TYPALIGN_INT, TYPSTORAGE_PLAIN, InvalidOid,
F_INT2VECTORIN, F_INT2VECTOROUT},

View File

@ -588,9 +588,13 @@ EOM
}
# Special hack to generate OID symbols for pg_type entries
# that lack one.
if ($catname eq 'pg_type' and !exists $bki_values{oid_symbol})
if ($catname eq 'pg_type')
{
die sprintf
"custom OID symbols are not allowed for pg_type entries: '%s'",
$bki_values{oid_symbol}
if defined $bki_values{oid_symbol};
my $symbol = form_pg_type_symbol($bki_values{typname});
$bki_values{oid_symbol} = $symbol
if defined $symbol;

View File

@ -177,7 +177,7 @@ CreateEventTrigger(CreateEventTrigStmt *stmt)
/* Find and validate the trigger function. */
funcoid = LookupFuncName(stmt->funcname, 0, NULL, false);
funcrettype = get_func_rettype(funcoid);
if (funcrettype != EVTTRIGGEROID)
if (funcrettype != EVENT_TRIGGEROID)
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("function %s must return type %s",

View File

@ -94,9 +94,9 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
*/
tupdesc = CreateTemplateTupleDesc(18);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "checkpoint_lsn",
LSNOID, -1, 0);
PG_LSNOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "redo_lsn",
LSNOID, -1, 0);
PG_LSNOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 3, "redo_wal_file",
TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 4, "timeline_id",
@ -223,13 +223,13 @@ pg_control_recovery(PG_FUNCTION_ARGS)
*/
tupdesc = CreateTemplateTupleDesc(5);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "min_recovery_end_lsn",
LSNOID, -1, 0);
PG_LSNOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "min_recovery_end_timeline",
INT4OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 3, "backup_start_lsn",
LSNOID, -1, 0);
PG_LSNOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 4, "backup_end_lsn",
LSNOID, -1, 0);
PG_LSNOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 5, "end_of_backup_record_required",
BOOLOID, -1, 0);
tupdesc = BlessTupleDesc(tupdesc);

View File

@ -3495,7 +3495,7 @@ column_type_alignment(Oid ftype)
case XIDOID:
case XID8OID:
case CIDOID:
case CASHOID:
case MONEYOID:
align = 'r';
break;
default:

View File

@ -15,14 +15,10 @@
# For types used in the system catalogs, make sure the values here match
# TypInfo[] in bootstrap.c.
# OID symbol macro names for pg_type OIDs are generated by genbki.pl
# according to the following rule, so you don't need to specify them
# here:
# OID symbol macro names for pg_type OIDs are not specified here because
# they are generated by genbki.pl according to the following rule:
# foo_bar -> FOO_BAROID
# _foo_bar -> FOO_BARARRAYOID
#
# The only oid_symbol entries in this file are for names that don't match
# this rule, and are grandfathered in.
# To autogenerate an array type, add 'array_type_oid => 'nnnn' to the element
# type, which will instruct genbki.pl to generate a BKI entry for it.
@ -144,35 +140,30 @@
typname => 'xml', typlen => '-1', typbyval => 'f', typcategory => 'U',
typinput => 'xml_in', typoutput => 'xml_out', typreceive => 'xml_recv',
typsend => 'xml_send', typalign => 'i', typstorage => 'x' },
{ oid => '194', oid_symbol => 'PGNODETREEOID',
descr => 'string representing an internal node tree',
{ oid => '194', descr => 'string representing an internal node tree',
typname => 'pg_node_tree', typlen => '-1', typbyval => 'f',
typcategory => 'S', typinput => 'pg_node_tree_in',
typoutput => 'pg_node_tree_out', typreceive => 'pg_node_tree_recv',
typsend => 'pg_node_tree_send', typalign => 'i', typstorage => 'x',
typcollation => 'default' },
{ oid => '3361', oid_symbol => 'PGNDISTINCTOID',
descr => 'multivariate ndistinct coefficients',
{ oid => '3361', descr => 'multivariate ndistinct coefficients',
typname => 'pg_ndistinct', typlen => '-1', typbyval => 'f',
typcategory => 'S', typinput => 'pg_ndistinct_in',
typoutput => 'pg_ndistinct_out', typreceive => 'pg_ndistinct_recv',
typsend => 'pg_ndistinct_send', typalign => 'i', typstorage => 'x',
typcollation => 'default' },
{ oid => '3402', oid_symbol => 'PGDEPENDENCIESOID',
descr => 'multivariate dependencies',
{ oid => '3402', descr => 'multivariate dependencies',
typname => 'pg_dependencies', typlen => '-1', typbyval => 'f',
typcategory => 'S', typinput => 'pg_dependencies_in',
typoutput => 'pg_dependencies_out', typreceive => 'pg_dependencies_recv',
typsend => 'pg_dependencies_send', typalign => 'i', typstorage => 'x',
typcollation => 'default' },
{ oid => '5017', oid_symbol => 'PGMCVLISTOID',
descr => 'multivariate MCV list',
{ oid => '5017', descr => 'multivariate MCV list',
typname => 'pg_mcv_list', typlen => '-1', typbyval => 'f', typcategory => 'S',
typinput => 'pg_mcv_list_in', typoutput => 'pg_mcv_list_out',
typreceive => 'pg_mcv_list_recv', typsend => 'pg_mcv_list_send',
typalign => 'i', typstorage => 'x', typcollation => 'default' },
{ oid => '32', oid_symbol => 'PGDDLCOMMANDOID',
descr => 'internal type for passing CollectedCommand',
{ oid => '32', descr => 'internal type for passing CollectedCommand',
typname => 'pg_ddl_command', typlen => 'SIZEOF_POINTER', typbyval => 't',
typtype => 'p', typcategory => 'P', typinput => 'pg_ddl_command_in',
typoutput => 'pg_ddl_command_out', typreceive => 'pg_ddl_command_recv',
@ -237,7 +228,7 @@
typname => 'circle', typlen => '24', typbyval => 'f', typcategory => 'G',
typinput => 'circle_in', typoutput => 'circle_out',
typreceive => 'circle_recv', typsend => 'circle_send', typalign => 'd' },
{ oid => '790', oid_symbol => 'CASHOID', array_type_oid => '791',
{ oid => '790', array_type_oid => '791',
descr => 'monetary amounts, $d,ddd.cc',
typname => 'money', typlen => '8', typbyval => 'FLOAT8PASSBYVAL',
typcategory => 'N', typinput => 'cash_in', typoutput => 'cash_out',
@ -409,8 +400,7 @@
typsend => 'uuid_send', typalign => 'c' },
# pg_lsn
{ oid => '3220', oid_symbol => 'LSNOID', array_type_oid => '3221',
descr => 'PostgreSQL LSN datatype',
{ oid => '3220', array_type_oid => '3221', descr => 'PostgreSQL LSN datatype',
typname => 'pg_lsn', typlen => '8', typbyval => 'FLOAT8PASSBYVAL',
typcategory => 'U', typinput => 'pg_lsn_in', typoutput => 'pg_lsn_out',
typreceive => 'pg_lsn_recv', typsend => 'pg_lsn_send', typalign => 'd' },
@ -542,7 +532,7 @@
typname => 'trigger', typlen => '4', typbyval => 't', typtype => 'p',
typcategory => 'P', typinput => 'trigger_in', typoutput => 'trigger_out',
typreceive => '-', typsend => '-', typalign => 'i' },
{ oid => '3838', oid_symbol => 'EVTTRIGGEROID',
{ oid => '3838',
descr => 'pseudo-type for the result of an event trigger function',
typname => 'event_trigger', typlen => '4', typbyval => 't', typtype => 'p',
typcategory => 'P', typinput => 'event_trigger_in',

View File

@ -312,6 +312,13 @@ typedef FormData_pg_type *Form_pg_type;
(typid) == ANYCOMPATIBLENONARRAYOID || \
(typid) == ANYCOMPATIBLERANGEOID)
/*
* Backwards compatibility for ancient random spellings of pg_type OID macros.
* Don't use these names in new code.
*/
#define CASHOID MONEYOID
#define LSNOID PG_LSNOID
#endif /* EXPOSE_TO_CLIENT_CODE */

View File

@ -230,7 +230,7 @@ ecpg_is_type_an_array(int type, const struct statement *stmt, const struct varia
return ECPG_ARRAY_ERROR;
if (!ecpg_type_infocache_push(&(stmt->connection->cache_head), CIRCLEOID, ECPG_ARRAY_NONE, stmt->lineno))
return ECPG_ARRAY_ERROR;
if (!ecpg_type_infocache_push(&(stmt->connection->cache_head), CASHOID, ECPG_ARRAY_NONE, stmt->lineno))
if (!ecpg_type_infocache_push(&(stmt->connection->cache_head), MONEYOID, ECPG_ARRAY_NONE, stmt->lineno))
return ECPG_ARRAY_ERROR;
if (!ecpg_type_infocache_push(&(stmt->connection->cache_head), INETOID, ECPG_ARRAY_NONE, stmt->lineno))
return ECPG_ARRAY_ERROR;

View File

@ -2002,7 +2002,7 @@ plperl_validator(PG_FUNCTION_ARGS)
{
if (proc->prorettype == TRIGGEROID)
is_trigger = true;
else if (proc->prorettype == EVTTRIGGEROID)
else if (proc->prorettype == EVENT_TRIGGEROID)
is_event_trigger = true;
else if (proc->prorettype != RECORDOID &&
proc->prorettype != VOIDOID)
@ -2838,7 +2838,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger, bool is_event_trigger)
rettype == RECORDOID)
/* okay */ ;
else if (rettype == TRIGGEROID ||
rettype == EVTTRIGGEROID)
rettype == EVENT_TRIGGEROID)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("trigger functions can only be called "

View File

@ -551,7 +551,7 @@ do_compile(FunctionCallInfo fcinfo,
if (rettypeid == VOIDOID ||
rettypeid == RECORDOID)
/* okay */ ;
else if (rettypeid == TRIGGEROID || rettypeid == EVTTRIGGEROID)
else if (rettypeid == TRIGGEROID || rettypeid == EVENT_TRIGGEROID)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("trigger functions can only be called as triggers")));

View File

@ -445,7 +445,7 @@ plpgsql_validator(PG_FUNCTION_ARGS)
{
if (proc->prorettype == TRIGGEROID)
is_dml_trigger = true;
else if (proc->prorettype == EVTTRIGGEROID)
else if (proc->prorettype == EVENT_TRIGGEROID)
is_event_trigger = true;
else if (proc->prorettype != RECORDOID &&
proc->prorettype != VOIDOID &&

View File

@ -220,7 +220,7 @@ PLy_procedure_create(HeapTuple procTup, Oid fn_oid, bool is_trigger)
if (rettype == VOIDOID ||
rettype == RECORDOID)
/* okay */ ;
else if (rettype == TRIGGEROID || rettype == EVTTRIGGEROID)
else if (rettype == TRIGGEROID || rettype == EVENT_TRIGGEROID)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("trigger functions can only be called as triggers")));

View File

@ -1532,7 +1532,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid,
rettype == RECORDOID)
/* okay */ ;
else if (rettype == TRIGGEROID ||
rettype == EVTTRIGGEROID)
rettype == EVENT_TRIGGEROID)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("trigger functions can only be called as triggers")));