Commit f90149e6 authored by Tom Lane's avatar Tom Lane

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

On the same reasoning as in commit 36b93121, 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
parent 1c7675a7
...@@ -133,7 +133,7 @@ static const struct typinfo TypInfo[] = { ...@@ -133,7 +133,7 @@ static const struct typinfo TypInfo[] = {
F_XIDIN, F_XIDOUT}, F_XIDIN, F_XIDOUT},
{"cid", CIDOID, 0, 4, true, TYPALIGN_INT, TYPSTORAGE_PLAIN, InvalidOid, {"cid", CIDOID, 0, 4, true, TYPALIGN_INT, TYPSTORAGE_PLAIN, InvalidOid,
F_CIDIN, F_CIDOUT}, 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}, F_PG_NODE_TREE_IN, F_PG_NODE_TREE_OUT},
{"int2vector", INT2VECTOROID, INT2OID, -1, false, TYPALIGN_INT, TYPSTORAGE_PLAIN, InvalidOid, {"int2vector", INT2VECTOROID, INT2OID, -1, false, TYPALIGN_INT, TYPSTORAGE_PLAIN, InvalidOid,
F_INT2VECTORIN, F_INT2VECTOROUT}, F_INT2VECTORIN, F_INT2VECTOROUT},
......
...@@ -588,9 +588,13 @@ EOM ...@@ -588,9 +588,13 @@ EOM
} }
# Special hack to generate OID symbols for pg_type entries # Special hack to generate OID symbols for pg_type entries
# that lack one. if ($catname eq 'pg_type')
if ($catname eq 'pg_type' and !exists $bki_values{oid_symbol})
{ {
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}); my $symbol = form_pg_type_symbol($bki_values{typname});
$bki_values{oid_symbol} = $symbol $bki_values{oid_symbol} = $symbol
if defined $symbol; if defined $symbol;
......
...@@ -177,7 +177,7 @@ CreateEventTrigger(CreateEventTrigStmt *stmt) ...@@ -177,7 +177,7 @@ CreateEventTrigger(CreateEventTrigStmt *stmt)
/* Find and validate the trigger function. */ /* Find and validate the trigger function. */
funcoid = LookupFuncName(stmt->funcname, 0, NULL, false); funcoid = LookupFuncName(stmt->funcname, 0, NULL, false);
funcrettype = get_func_rettype(funcoid); funcrettype = get_func_rettype(funcoid);
if (funcrettype != EVTTRIGGEROID) if (funcrettype != EVENT_TRIGGEROID)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION), (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("function %s must return type %s", errmsg("function %s must return type %s",
......
...@@ -94,9 +94,9 @@ pg_control_checkpoint(PG_FUNCTION_ARGS) ...@@ -94,9 +94,9 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
*/ */
tupdesc = CreateTemplateTupleDesc(18); tupdesc = CreateTemplateTupleDesc(18);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "checkpoint_lsn", TupleDescInitEntry(tupdesc, (AttrNumber) 1, "checkpoint_lsn",
LSNOID, -1, 0); PG_LSNOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "redo_lsn", TupleDescInitEntry(tupdesc, (AttrNumber) 2, "redo_lsn",
LSNOID, -1, 0); PG_LSNOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 3, "redo_wal_file", TupleDescInitEntry(tupdesc, (AttrNumber) 3, "redo_wal_file",
TEXTOID, -1, 0); TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 4, "timeline_id", TupleDescInitEntry(tupdesc, (AttrNumber) 4, "timeline_id",
...@@ -223,13 +223,13 @@ pg_control_recovery(PG_FUNCTION_ARGS) ...@@ -223,13 +223,13 @@ pg_control_recovery(PG_FUNCTION_ARGS)
*/ */
tupdesc = CreateTemplateTupleDesc(5); tupdesc = CreateTemplateTupleDesc(5);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "min_recovery_end_lsn", TupleDescInitEntry(tupdesc, (AttrNumber) 1, "min_recovery_end_lsn",
LSNOID, -1, 0); PG_LSNOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "min_recovery_end_timeline", TupleDescInitEntry(tupdesc, (AttrNumber) 2, "min_recovery_end_timeline",
INT4OID, -1, 0); INT4OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 3, "backup_start_lsn", TupleDescInitEntry(tupdesc, (AttrNumber) 3, "backup_start_lsn",
LSNOID, -1, 0); PG_LSNOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 4, "backup_end_lsn", TupleDescInitEntry(tupdesc, (AttrNumber) 4, "backup_end_lsn",
LSNOID, -1, 0); PG_LSNOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 5, "end_of_backup_record_required", TupleDescInitEntry(tupdesc, (AttrNumber) 5, "end_of_backup_record_required",
BOOLOID, -1, 0); BOOLOID, -1, 0);
tupdesc = BlessTupleDesc(tupdesc); tupdesc = BlessTupleDesc(tupdesc);
......
...@@ -3495,7 +3495,7 @@ column_type_alignment(Oid ftype) ...@@ -3495,7 +3495,7 @@ column_type_alignment(Oid ftype)
case XIDOID: case XIDOID:
case XID8OID: case XID8OID:
case CIDOID: case CIDOID:
case CASHOID: case MONEYOID:
align = 'r'; align = 'r';
break; break;
default: default:
......
...@@ -15,14 +15,10 @@ ...@@ -15,14 +15,10 @@
# For types used in the system catalogs, make sure the values here match # For types used in the system catalogs, make sure the values here match
# TypInfo[] in bootstrap.c. # TypInfo[] in bootstrap.c.
# OID symbol macro names for pg_type OIDs are generated by genbki.pl # OID symbol macro names for pg_type OIDs are not specified here because
# according to the following rule, so you don't need to specify them # they are generated by genbki.pl according to the following rule:
# here:
# foo_bar -> FOO_BAROID # foo_bar -> FOO_BAROID
# _foo_bar -> FOO_BARARRAYOID # _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 # 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. # type, which will instruct genbki.pl to generate a BKI entry for it.
...@@ -144,35 +140,30 @@ ...@@ -144,35 +140,30 @@
typname => 'xml', typlen => '-1', typbyval => 'f', typcategory => 'U', typname => 'xml', typlen => '-1', typbyval => 'f', typcategory => 'U',
typinput => 'xml_in', typoutput => 'xml_out', typreceive => 'xml_recv', typinput => 'xml_in', typoutput => 'xml_out', typreceive => 'xml_recv',
typsend => 'xml_send', typalign => 'i', typstorage => 'x' }, typsend => 'xml_send', typalign => 'i', typstorage => 'x' },
{ oid => '194', oid_symbol => 'PGNODETREEOID', { oid => '194', descr => 'string representing an internal node tree',
descr => 'string representing an internal node tree',
typname => 'pg_node_tree', typlen => '-1', typbyval => 'f', typname => 'pg_node_tree', typlen => '-1', typbyval => 'f',
typcategory => 'S', typinput => 'pg_node_tree_in', typcategory => 'S', typinput => 'pg_node_tree_in',
typoutput => 'pg_node_tree_out', typreceive => 'pg_node_tree_recv', typoutput => 'pg_node_tree_out', typreceive => 'pg_node_tree_recv',
typsend => 'pg_node_tree_send', typalign => 'i', typstorage => 'x', typsend => 'pg_node_tree_send', typalign => 'i', typstorage => 'x',
typcollation => 'default' }, typcollation => 'default' },
{ oid => '3361', oid_symbol => 'PGNDISTINCTOID', { oid => '3361', descr => 'multivariate ndistinct coefficients',
descr => 'multivariate ndistinct coefficients',
typname => 'pg_ndistinct', typlen => '-1', typbyval => 'f', typname => 'pg_ndistinct', typlen => '-1', typbyval => 'f',
typcategory => 'S', typinput => 'pg_ndistinct_in', typcategory => 'S', typinput => 'pg_ndistinct_in',
typoutput => 'pg_ndistinct_out', typreceive => 'pg_ndistinct_recv', typoutput => 'pg_ndistinct_out', typreceive => 'pg_ndistinct_recv',
typsend => 'pg_ndistinct_send', typalign => 'i', typstorage => 'x', typsend => 'pg_ndistinct_send', typalign => 'i', typstorage => 'x',
typcollation => 'default' }, typcollation => 'default' },
{ oid => '3402', oid_symbol => 'PGDEPENDENCIESOID', { oid => '3402', descr => 'multivariate dependencies',
descr => 'multivariate dependencies',
typname => 'pg_dependencies', typlen => '-1', typbyval => 'f', typname => 'pg_dependencies', typlen => '-1', typbyval => 'f',
typcategory => 'S', typinput => 'pg_dependencies_in', typcategory => 'S', typinput => 'pg_dependencies_in',
typoutput => 'pg_dependencies_out', typreceive => 'pg_dependencies_recv', typoutput => 'pg_dependencies_out', typreceive => 'pg_dependencies_recv',
typsend => 'pg_dependencies_send', typalign => 'i', typstorage => 'x', typsend => 'pg_dependencies_send', typalign => 'i', typstorage => 'x',
typcollation => 'default' }, typcollation => 'default' },
{ oid => '5017', oid_symbol => 'PGMCVLISTOID', { oid => '5017', descr => 'multivariate MCV list',
descr => 'multivariate MCV list',
typname => 'pg_mcv_list', typlen => '-1', typbyval => 'f', typcategory => 'S', typname => 'pg_mcv_list', typlen => '-1', typbyval => 'f', typcategory => 'S',
typinput => 'pg_mcv_list_in', typoutput => 'pg_mcv_list_out', typinput => 'pg_mcv_list_in', typoutput => 'pg_mcv_list_out',
typreceive => 'pg_mcv_list_recv', typsend => 'pg_mcv_list_send', typreceive => 'pg_mcv_list_recv', typsend => 'pg_mcv_list_send',
typalign => 'i', typstorage => 'x', typcollation => 'default' }, typalign => 'i', typstorage => 'x', typcollation => 'default' },
{ oid => '32', oid_symbol => 'PGDDLCOMMANDOID', { oid => '32', descr => 'internal type for passing CollectedCommand',
descr => 'internal type for passing CollectedCommand',
typname => 'pg_ddl_command', typlen => 'SIZEOF_POINTER', typbyval => 't', typname => 'pg_ddl_command', typlen => 'SIZEOF_POINTER', typbyval => 't',
typtype => 'p', typcategory => 'P', typinput => 'pg_ddl_command_in', typtype => 'p', typcategory => 'P', typinput => 'pg_ddl_command_in',
typoutput => 'pg_ddl_command_out', typreceive => 'pg_ddl_command_recv', typoutput => 'pg_ddl_command_out', typreceive => 'pg_ddl_command_recv',
...@@ -237,7 +228,7 @@ ...@@ -237,7 +228,7 @@
typname => 'circle', typlen => '24', typbyval => 'f', typcategory => 'G', typname => 'circle', typlen => '24', typbyval => 'f', typcategory => 'G',
typinput => 'circle_in', typoutput => 'circle_out', typinput => 'circle_in', typoutput => 'circle_out',
typreceive => 'circle_recv', typsend => 'circle_send', typalign => 'd' }, 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', descr => 'monetary amounts, $d,ddd.cc',
typname => 'money', typlen => '8', typbyval => 'FLOAT8PASSBYVAL', typname => 'money', typlen => '8', typbyval => 'FLOAT8PASSBYVAL',
typcategory => 'N', typinput => 'cash_in', typoutput => 'cash_out', typcategory => 'N', typinput => 'cash_in', typoutput => 'cash_out',
...@@ -409,8 +400,7 @@ ...@@ -409,8 +400,7 @@
typsend => 'uuid_send', typalign => 'c' }, typsend => 'uuid_send', typalign => 'c' },
# pg_lsn # pg_lsn
{ oid => '3220', oid_symbol => 'LSNOID', array_type_oid => '3221', { oid => '3220', array_type_oid => '3221', descr => 'PostgreSQL LSN datatype',
descr => 'PostgreSQL LSN datatype',
typname => 'pg_lsn', typlen => '8', typbyval => 'FLOAT8PASSBYVAL', typname => 'pg_lsn', typlen => '8', typbyval => 'FLOAT8PASSBYVAL',
typcategory => 'U', typinput => 'pg_lsn_in', typoutput => 'pg_lsn_out', typcategory => 'U', typinput => 'pg_lsn_in', typoutput => 'pg_lsn_out',
typreceive => 'pg_lsn_recv', typsend => 'pg_lsn_send', typalign => 'd' }, typreceive => 'pg_lsn_recv', typsend => 'pg_lsn_send', typalign => 'd' },
...@@ -542,7 +532,7 @@ ...@@ -542,7 +532,7 @@
typname => 'trigger', typlen => '4', typbyval => 't', typtype => 'p', typname => 'trigger', typlen => '4', typbyval => 't', typtype => 'p',
typcategory => 'P', typinput => 'trigger_in', typoutput => 'trigger_out', typcategory => 'P', typinput => 'trigger_in', typoutput => 'trigger_out',
typreceive => '-', typsend => '-', typalign => 'i' }, typreceive => '-', typsend => '-', typalign => 'i' },
{ oid => '3838', oid_symbol => 'EVTTRIGGEROID', { oid => '3838',
descr => 'pseudo-type for the result of an event trigger function', descr => 'pseudo-type for the result of an event trigger function',
typname => 'event_trigger', typlen => '4', typbyval => 't', typtype => 'p', typname => 'event_trigger', typlen => '4', typbyval => 't', typtype => 'p',
typcategory => 'P', typinput => 'event_trigger_in', typcategory => 'P', typinput => 'event_trigger_in',
......
...@@ -312,6 +312,13 @@ typedef FormData_pg_type *Form_pg_type; ...@@ -312,6 +312,13 @@ typedef FormData_pg_type *Form_pg_type;
(typid) == ANYCOMPATIBLENONARRAYOID || \ (typid) == ANYCOMPATIBLENONARRAYOID || \
(typid) == ANYCOMPATIBLERANGEOID) (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 */ #endif /* EXPOSE_TO_CLIENT_CODE */
......
...@@ -230,7 +230,7 @@ ecpg_is_type_an_array(int type, const struct statement *stmt, const struct varia ...@@ -230,7 +230,7 @@ ecpg_is_type_an_array(int type, const struct statement *stmt, const struct varia
return ECPG_ARRAY_ERROR; return ECPG_ARRAY_ERROR;
if (!ecpg_type_infocache_push(&(stmt->connection->cache_head), CIRCLEOID, ECPG_ARRAY_NONE, stmt->lineno)) if (!ecpg_type_infocache_push(&(stmt->connection->cache_head), CIRCLEOID, ECPG_ARRAY_NONE, stmt->lineno))
return ECPG_ARRAY_ERROR; 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; return ECPG_ARRAY_ERROR;
if (!ecpg_type_infocache_push(&(stmt->connection->cache_head), INETOID, ECPG_ARRAY_NONE, stmt->lineno)) if (!ecpg_type_infocache_push(&(stmt->connection->cache_head), INETOID, ECPG_ARRAY_NONE, stmt->lineno))
return ECPG_ARRAY_ERROR; return ECPG_ARRAY_ERROR;
......
...@@ -2002,7 +2002,7 @@ plperl_validator(PG_FUNCTION_ARGS) ...@@ -2002,7 +2002,7 @@ plperl_validator(PG_FUNCTION_ARGS)
{ {
if (proc->prorettype == TRIGGEROID) if (proc->prorettype == TRIGGEROID)
is_trigger = true; is_trigger = true;
else if (proc->prorettype == EVTTRIGGEROID) else if (proc->prorettype == EVENT_TRIGGEROID)
is_event_trigger = true; is_event_trigger = true;
else if (proc->prorettype != RECORDOID && else if (proc->prorettype != RECORDOID &&
proc->prorettype != VOIDOID) proc->prorettype != VOIDOID)
...@@ -2838,7 +2838,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger, bool is_event_trigger) ...@@ -2838,7 +2838,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger, bool is_event_trigger)
rettype == RECORDOID) rettype == RECORDOID)
/* okay */ ; /* okay */ ;
else if (rettype == TRIGGEROID || else if (rettype == TRIGGEROID ||
rettype == EVTTRIGGEROID) rettype == EVENT_TRIGGEROID)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("trigger functions can only be called " errmsg("trigger functions can only be called "
......
...@@ -551,7 +551,7 @@ do_compile(FunctionCallInfo fcinfo, ...@@ -551,7 +551,7 @@ do_compile(FunctionCallInfo fcinfo,
if (rettypeid == VOIDOID || if (rettypeid == VOIDOID ||
rettypeid == RECORDOID) rettypeid == RECORDOID)
/* okay */ ; /* okay */ ;
else if (rettypeid == TRIGGEROID || rettypeid == EVTTRIGGEROID) else if (rettypeid == TRIGGEROID || rettypeid == EVENT_TRIGGEROID)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("trigger functions can only be called as triggers"))); errmsg("trigger functions can only be called as triggers")));
......
...@@ -445,7 +445,7 @@ plpgsql_validator(PG_FUNCTION_ARGS) ...@@ -445,7 +445,7 @@ plpgsql_validator(PG_FUNCTION_ARGS)
{ {
if (proc->prorettype == TRIGGEROID) if (proc->prorettype == TRIGGEROID)
is_dml_trigger = true; is_dml_trigger = true;
else if (proc->prorettype == EVTTRIGGEROID) else if (proc->prorettype == EVENT_TRIGGEROID)
is_event_trigger = true; is_event_trigger = true;
else if (proc->prorettype != RECORDOID && else if (proc->prorettype != RECORDOID &&
proc->prorettype != VOIDOID && proc->prorettype != VOIDOID &&
......
...@@ -220,7 +220,7 @@ PLy_procedure_create(HeapTuple procTup, Oid fn_oid, bool is_trigger) ...@@ -220,7 +220,7 @@ PLy_procedure_create(HeapTuple procTup, Oid fn_oid, bool is_trigger)
if (rettype == VOIDOID || if (rettype == VOIDOID ||
rettype == RECORDOID) rettype == RECORDOID)
/* okay */ ; /* okay */ ;
else if (rettype == TRIGGEROID || rettype == EVTTRIGGEROID) else if (rettype == TRIGGEROID || rettype == EVENT_TRIGGEROID)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("trigger functions can only be called as triggers"))); errmsg("trigger functions can only be called as triggers")));
......
...@@ -1532,7 +1532,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid, ...@@ -1532,7 +1532,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid,
rettype == RECORDOID) rettype == RECORDOID)
/* okay */ ; /* okay */ ;
else if (rettype == TRIGGEROID || else if (rettype == TRIGGEROID ||
rettype == EVTTRIGGEROID) rettype == EVENT_TRIGGEROID)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("trigger functions can only be called as triggers"))); errmsg("trigger functions can only be called as triggers")));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment