Skip to content

Commit f90149e

Browse files
committed
Don't use custom OID symbols in pg_type.dat, either.
On the same reasoning as in commit 36b9312, 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
1 parent 1c7675a commit f90149e

File tree

13 files changed

+38
-37
lines changed

13 files changed

+38
-37
lines changed

src/backend/bootstrap/bootstrap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ static const struct typinfo TypInfo[] = {
133133
F_XIDIN, F_XIDOUT},
134134
{"cid", CIDOID, 0, 4, true, TYPALIGN_INT, TYPSTORAGE_PLAIN, InvalidOid,
135135
F_CIDIN, F_CIDOUT},
136-
{"pg_node_tree", PGNODETREEOID, 0, -1, false, TYPALIGN_INT, TYPSTORAGE_EXTENDED, DEFAULT_COLLATION_OID,
136+
{"pg_node_tree", PG_NODE_TREEOID, 0, -1, false, TYPALIGN_INT, TYPSTORAGE_EXTENDED, DEFAULT_COLLATION_OID,
137137
F_PG_NODE_TREE_IN, F_PG_NODE_TREE_OUT},
138138
{"int2vector", INT2VECTOROID, INT2OID, -1, false, TYPALIGN_INT, TYPSTORAGE_PLAIN, InvalidOid,
139139
F_INT2VECTORIN, F_INT2VECTOROUT},

src/backend/catalog/genbki.pl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -588,9 +588,13 @@
588588
}
589589

590590
# Special hack to generate OID symbols for pg_type entries
591-
# that lack one.
592-
if ($catname eq 'pg_type' and !exists $bki_values{oid_symbol})
591+
if ($catname eq 'pg_type')
593592
{
593+
die sprintf
594+
"custom OID symbols are not allowed for pg_type entries: '%s'",
595+
$bki_values{oid_symbol}
596+
if defined $bki_values{oid_symbol};
597+
594598
my $symbol = form_pg_type_symbol($bki_values{typname});
595599
$bki_values{oid_symbol} = $symbol
596600
if defined $symbol;

src/backend/commands/event_trigger.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ CreateEventTrigger(CreateEventTrigStmt *stmt)
177177
/* Find and validate the trigger function. */
178178
funcoid = LookupFuncName(stmt->funcname, 0, NULL, false);
179179
funcrettype = get_func_rettype(funcoid);
180-
if (funcrettype != EVTTRIGGEROID)
180+
if (funcrettype != EVENT_TRIGGEROID)
181181
ereport(ERROR,
182182
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
183183
errmsg("function %s must return type %s",

src/backend/utils/misc/pg_controldata.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
9494
*/
9595
tupdesc = CreateTemplateTupleDesc(18);
9696
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "checkpoint_lsn",
97-
LSNOID, -1, 0);
97+
PG_LSNOID, -1, 0);
9898
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "redo_lsn",
99-
LSNOID, -1, 0);
99+
PG_LSNOID, -1, 0);
100100
TupleDescInitEntry(tupdesc, (AttrNumber) 3, "redo_wal_file",
101101
TEXTOID, -1, 0);
102102
TupleDescInitEntry(tupdesc, (AttrNumber) 4, "timeline_id",
@@ -223,13 +223,13 @@ pg_control_recovery(PG_FUNCTION_ARGS)
223223
*/
224224
tupdesc = CreateTemplateTupleDesc(5);
225225
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "min_recovery_end_lsn",
226-
LSNOID, -1, 0);
226+
PG_LSNOID, -1, 0);
227227
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "min_recovery_end_timeline",
228228
INT4OID, -1, 0);
229229
TupleDescInitEntry(tupdesc, (AttrNumber) 3, "backup_start_lsn",
230-
LSNOID, -1, 0);
230+
PG_LSNOID, -1, 0);
231231
TupleDescInitEntry(tupdesc, (AttrNumber) 4, "backup_end_lsn",
232-
LSNOID, -1, 0);
232+
PG_LSNOID, -1, 0);
233233
TupleDescInitEntry(tupdesc, (AttrNumber) 5, "end_of_backup_record_required",
234234
BOOLOID, -1, 0);
235235
tupdesc = BlessTupleDesc(tupdesc);

src/fe_utils/print.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3495,7 +3495,7 @@ column_type_alignment(Oid ftype)
34953495
case XIDOID:
34963496
case XID8OID:
34973497
case CIDOID:
3498-
case CASHOID:
3498+
case MONEYOID:
34993499
align = 'r';
35003500
break;
35013501
default:

src/include/catalog/pg_type.dat

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,10 @@
1515
# For types used in the system catalogs, make sure the values here match
1616
# TypInfo[] in bootstrap.c.
1717

18-
# OID symbol macro names for pg_type OIDs are generated by genbki.pl
19-
# according to the following rule, so you don't need to specify them
20-
# here:
18+
# OID symbol macro names for pg_type OIDs are not specified here because
19+
# they are generated by genbki.pl according to the following rule:
2120
# foo_bar -> FOO_BAROID
2221
# _foo_bar -> FOO_BARARRAYOID
23-
#
24-
# The only oid_symbol entries in this file are for names that don't match
25-
# this rule, and are grandfathered in.
2622

2723
# To autogenerate an array type, add 'array_type_oid => 'nnnn' to the element
2824
# type, which will instruct genbki.pl to generate a BKI entry for it.
@@ -144,35 +140,30 @@
144140
typname => 'xml', typlen => '-1', typbyval => 'f', typcategory => 'U',
145141
typinput => 'xml_in', typoutput => 'xml_out', typreceive => 'xml_recv',
146142
typsend => 'xml_send', typalign => 'i', typstorage => 'x' },
147-
{ oid => '194', oid_symbol => 'PGNODETREEOID',
148-
descr => 'string representing an internal node tree',
143+
{ oid => '194', descr => 'string representing an internal node tree',
149144
typname => 'pg_node_tree', typlen => '-1', typbyval => 'f',
150145
typcategory => 'S', typinput => 'pg_node_tree_in',
151146
typoutput => 'pg_node_tree_out', typreceive => 'pg_node_tree_recv',
152147
typsend => 'pg_node_tree_send', typalign => 'i', typstorage => 'x',
153148
typcollation => 'default' },
154-
{ oid => '3361', oid_symbol => 'PGNDISTINCTOID',
155-
descr => 'multivariate ndistinct coefficients',
149+
{ oid => '3361', descr => 'multivariate ndistinct coefficients',
156150
typname => 'pg_ndistinct', typlen => '-1', typbyval => 'f',
157151
typcategory => 'S', typinput => 'pg_ndistinct_in',
158152
typoutput => 'pg_ndistinct_out', typreceive => 'pg_ndistinct_recv',
159153
typsend => 'pg_ndistinct_send', typalign => 'i', typstorage => 'x',
160154
typcollation => 'default' },
161-
{ oid => '3402', oid_symbol => 'PGDEPENDENCIESOID',
162-
descr => 'multivariate dependencies',
155+
{ oid => '3402', descr => 'multivariate dependencies',
163156
typname => 'pg_dependencies', typlen => '-1', typbyval => 'f',
164157
typcategory => 'S', typinput => 'pg_dependencies_in',
165158
typoutput => 'pg_dependencies_out', typreceive => 'pg_dependencies_recv',
166159
typsend => 'pg_dependencies_send', typalign => 'i', typstorage => 'x',
167160
typcollation => 'default' },
168-
{ oid => '5017', oid_symbol => 'PGMCVLISTOID',
169-
descr => 'multivariate MCV list',
161+
{ oid => '5017', descr => 'multivariate MCV list',
170162
typname => 'pg_mcv_list', typlen => '-1', typbyval => 'f', typcategory => 'S',
171163
typinput => 'pg_mcv_list_in', typoutput => 'pg_mcv_list_out',
172164
typreceive => 'pg_mcv_list_recv', typsend => 'pg_mcv_list_send',
173165
typalign => 'i', typstorage => 'x', typcollation => 'default' },
174-
{ oid => '32', oid_symbol => 'PGDDLCOMMANDOID',
175-
descr => 'internal type for passing CollectedCommand',
166+
{ oid => '32', descr => 'internal type for passing CollectedCommand',
176167
typname => 'pg_ddl_command', typlen => 'SIZEOF_POINTER', typbyval => 't',
177168
typtype => 'p', typcategory => 'P', typinput => 'pg_ddl_command_in',
178169
typoutput => 'pg_ddl_command_out', typreceive => 'pg_ddl_command_recv',
@@ -237,7 +228,7 @@
237228
typname => 'circle', typlen => '24', typbyval => 'f', typcategory => 'G',
238229
typinput => 'circle_in', typoutput => 'circle_out',
239230
typreceive => 'circle_recv', typsend => 'circle_send', typalign => 'd' },
240-
{ oid => '790', oid_symbol => 'CASHOID', array_type_oid => '791',
231+
{ oid => '790', array_type_oid => '791',
241232
descr => 'monetary amounts, $d,ddd.cc',
242233
typname => 'money', typlen => '8', typbyval => 'FLOAT8PASSBYVAL',
243234
typcategory => 'N', typinput => 'cash_in', typoutput => 'cash_out',
@@ -409,8 +400,7 @@
409400
typsend => 'uuid_send', typalign => 'c' },
410401

411402
# pg_lsn
412-
{ oid => '3220', oid_symbol => 'LSNOID', array_type_oid => '3221',
413-
descr => 'PostgreSQL LSN datatype',
403+
{ oid => '3220', array_type_oid => '3221', descr => 'PostgreSQL LSN datatype',
414404
typname => 'pg_lsn', typlen => '8', typbyval => 'FLOAT8PASSBYVAL',
415405
typcategory => 'U', typinput => 'pg_lsn_in', typoutput => 'pg_lsn_out',
416406
typreceive => 'pg_lsn_recv', typsend => 'pg_lsn_send', typalign => 'd' },
@@ -542,7 +532,7 @@
542532
typname => 'trigger', typlen => '4', typbyval => 't', typtype => 'p',
543533
typcategory => 'P', typinput => 'trigger_in', typoutput => 'trigger_out',
544534
typreceive => '-', typsend => '-', typalign => 'i' },
545-
{ oid => '3838', oid_symbol => 'EVTTRIGGEROID',
535+
{ oid => '3838',
546536
descr => 'pseudo-type for the result of an event trigger function',
547537
typname => 'event_trigger', typlen => '4', typbyval => 't', typtype => 'p',
548538
typcategory => 'P', typinput => 'event_trigger_in',

src/include/catalog/pg_type.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,13 @@ typedef FormData_pg_type *Form_pg_type;
312312
(typid) == ANYCOMPATIBLENONARRAYOID || \
313313
(typid) == ANYCOMPATIBLERANGEOID)
314314

315+
/*
316+
* Backwards compatibility for ancient random spellings of pg_type OID macros.
317+
* Don't use these names in new code.
318+
*/
319+
#define CASHOID MONEYOID
320+
#define LSNOID PG_LSNOID
321+
315322
#endif /* EXPOSE_TO_CLIENT_CODE */
316323

317324

src/interfaces/ecpg/ecpglib/execute.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ ecpg_is_type_an_array(int type, const struct statement *stmt, const struct varia
230230
return ECPG_ARRAY_ERROR;
231231
if (!ecpg_type_infocache_push(&(stmt->connection->cache_head), CIRCLEOID, ECPG_ARRAY_NONE, stmt->lineno))
232232
return ECPG_ARRAY_ERROR;
233-
if (!ecpg_type_infocache_push(&(stmt->connection->cache_head), CASHOID, ECPG_ARRAY_NONE, stmt->lineno))
233+
if (!ecpg_type_infocache_push(&(stmt->connection->cache_head), MONEYOID, ECPG_ARRAY_NONE, stmt->lineno))
234234
return ECPG_ARRAY_ERROR;
235235
if (!ecpg_type_infocache_push(&(stmt->connection->cache_head), INETOID, ECPG_ARRAY_NONE, stmt->lineno))
236236
return ECPG_ARRAY_ERROR;

src/pl/plperl/plperl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2002,7 +2002,7 @@ plperl_validator(PG_FUNCTION_ARGS)
20022002
{
20032003
if (proc->prorettype == TRIGGEROID)
20042004
is_trigger = true;
2005-
else if (proc->prorettype == EVTTRIGGEROID)
2005+
else if (proc->prorettype == EVENT_TRIGGEROID)
20062006
is_event_trigger = true;
20072007
else if (proc->prorettype != RECORDOID &&
20082008
proc->prorettype != VOIDOID)
@@ -2838,7 +2838,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger, bool is_event_trigger)
28382838
rettype == RECORDOID)
28392839
/* okay */ ;
28402840
else if (rettype == TRIGGEROID ||
2841-
rettype == EVTTRIGGEROID)
2841+
rettype == EVENT_TRIGGEROID)
28422842
ereport(ERROR,
28432843
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
28442844
errmsg("trigger functions can only be called "

src/pl/plpgsql/src/pl_comp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ do_compile(FunctionCallInfo fcinfo,
551551
if (rettypeid == VOIDOID ||
552552
rettypeid == RECORDOID)
553553
/* okay */ ;
554-
else if (rettypeid == TRIGGEROID || rettypeid == EVTTRIGGEROID)
554+
else if (rettypeid == TRIGGEROID || rettypeid == EVENT_TRIGGEROID)
555555
ereport(ERROR,
556556
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
557557
errmsg("trigger functions can only be called as triggers")));

src/pl/plpgsql/src/pl_handler.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ plpgsql_validator(PG_FUNCTION_ARGS)
445445
{
446446
if (proc->prorettype == TRIGGEROID)
447447
is_dml_trigger = true;
448-
else if (proc->prorettype == EVTTRIGGEROID)
448+
else if (proc->prorettype == EVENT_TRIGGEROID)
449449
is_event_trigger = true;
450450
else if (proc->prorettype != RECORDOID &&
451451
proc->prorettype != VOIDOID &&

src/pl/plpython/plpy_procedure.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ PLy_procedure_create(HeapTuple procTup, Oid fn_oid, bool is_trigger)
220220
if (rettype == VOIDOID ||
221221
rettype == RECORDOID)
222222
/* okay */ ;
223-
else if (rettype == TRIGGEROID || rettype == EVTTRIGGEROID)
223+
else if (rettype == TRIGGEROID || rettype == EVENT_TRIGGEROID)
224224
ereport(ERROR,
225225
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
226226
errmsg("trigger functions can only be called as triggers")));

src/pl/tcl/pltcl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1532,7 +1532,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid,
15321532
rettype == RECORDOID)
15331533
/* okay */ ;
15341534
else if (rettype == TRIGGEROID ||
1535-
rettype == EVTTRIGGEROID)
1535+
rettype == EVENT_TRIGGEROID)
15361536
ereport(ERROR,
15371537
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
15381538
errmsg("trigger functions can only be called as triggers")));

0 commit comments

Comments
 (0)