Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b86b7bf

Browse files
committed
Improve English wording of some other getObjectDescription() messages.
Print columns as "column C of <relation>" rather than "<relation> column C". This seems to read noticeably better in English, as evidenced by the regression test output changes, and the code change also makes it possible for translators to adjust the phrase order in other languages. Also change the output for OCLASS_DEFAULT from "default for %s" to "default value for %s". This seems to read better and is also more consistent with the output of, for instance, getObjectTypeDescription(). Kyotaro Horiguchi, per a complaint from me Discussion: https://postgr.es/m/20180522.182020.114074746.horiguchi.kyotaro@lab.ntt.co.jp
1 parent 7c89eb7 commit b86b7bf

File tree

8 files changed

+36
-24
lines changed

8 files changed

+36
-24
lines changed

contrib/earthdistance/expected/earthdistance.out

+4-4
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ HINT: You can drop extension cube instead.
985985
create table foo (f1 cube, f2 int);
986986
drop extension cube; -- fail, foo.f1 requires it
987987
ERROR: cannot drop extension cube because other objects depend on it
988-
DETAIL: table foo column f1 depends on type cube
988+
DETAIL: column f1 of table foo depends on type cube
989989
HINT: Use DROP ... CASCADE to drop the dependent objects too.
990990
drop table foo;
991991
drop extension cube;
@@ -1039,15 +1039,15 @@ create extension cube with schema c;
10391039
create table foo (f1 c.cube, f2 int);
10401040
drop extension cube; -- fail, foo.f1 requires it
10411041
ERROR: cannot drop extension cube because other objects depend on it
1042-
DETAIL: table foo column f1 depends on type c.cube
1042+
DETAIL: column f1 of table foo depends on type c.cube
10431043
HINT: Use DROP ... CASCADE to drop the dependent objects too.
10441044
drop schema c; -- fail, cube requires it
10451045
ERROR: cannot drop schema c because other objects depend on it
10461046
DETAIL: extension cube depends on schema c
1047-
table foo column f1 depends on type c.cube
1047+
column f1 of table foo depends on type c.cube
10481048
HINT: Use DROP ... CASCADE to drop the dependent objects too.
10491049
drop extension cube cascade;
1050-
NOTICE: drop cascades to table foo column f1
1050+
NOTICE: drop cascades to column f1 of table foo
10511051
\d foo
10521052
Table "public.foo"
10531053
Column | Type | Collation | Nullable | Default

contrib/postgres_fdw/expected/postgres_fdw.out

+1-1
Original file line numberDiff line numberDiff line change
@@ -8116,7 +8116,7 @@ CREATE TABLE import_source.t5 (c1 int, c2 text collate "C", "Col" "Colors");
81168116
CREATE SCHEMA import_dest5;
81178117
BEGIN;
81188118
DROP TYPE "Colors" CASCADE;
8119-
NOTICE: drop cascades to table import_source.t5 column Col
8119+
NOTICE: drop cascades to column Col of table import_source.t5
81208120
IMPORT FOREIGN SCHEMA import_source LIMIT TO (t5)
81218121
FROM SERVER loopback INTO import_dest5; -- ERROR
81228122
ERROR: type "public.Colors" does not exist

src/backend/catalog/objectaddress.c

+17-5
Original file line numberDiff line numberDiff line change
@@ -2681,12 +2681,23 @@ getObjectDescription(const ObjectAddress *object)
26812681
switch (getObjectClass(object))
26822682
{
26832683
case OCLASS_CLASS:
2684-
getRelationDescription(&buffer, object->objectId);
2685-
if (object->objectSubId != 0)
2686-
appendStringInfo(&buffer, _(" column %s"),
2684+
if (object->objectSubId == 0)
2685+
getRelationDescription(&buffer, object->objectId);
2686+
else
2687+
{
2688+
/* column, not whole relation */
2689+
StringInfoData rel;
2690+
2691+
initStringInfo(&rel);
2692+
getRelationDescription(&rel, object->objectId);
2693+
/* translator: second %s is, e.g., "table %s" */
2694+
appendStringInfo(&buffer, _("column %s of %s"),
26872695
get_attname(object->objectId,
26882696
object->objectSubId,
2689-
false));
2697+
false),
2698+
rel.data);
2699+
pfree(rel.data);
2700+
}
26902701
break;
26912702

26922703
case OCLASS_PROC:
@@ -2850,7 +2861,8 @@ getObjectDescription(const ObjectAddress *object)
28502861
colobject.objectId = attrdef->adrelid;
28512862
colobject.objectSubId = attrdef->adnum;
28522863

2853-
appendStringInfo(&buffer, _("default for %s"),
2864+
/* translator: %s is typically "column %s of table %s" */
2865+
appendStringInfo(&buffer, _("default value for %s"),
28542866
getObjectDescription(&colobject));
28552867

28562868
systable_endscan(adscan);

src/test/regress/expected/alter_table.out

+3-3
Original file line numberDiff line numberDiff line change
@@ -1844,7 +1844,7 @@ select * from foo;
18441844
(1 row)
18451845

18461846
drop domain mytype cascade;
1847-
NOTICE: drop cascades to table foo column f2
1847+
NOTICE: drop cascades to column f2 of table foo
18481848
select * from foo;
18491849
f1 | f3
18501850
----+----
@@ -2870,8 +2870,8 @@ DROP TABLE test_tbl2_subclass;
28702870
CREATE TYPE test_typex AS (a int, b text);
28712871
CREATE TABLE test_tblx (x int, y test_typex check ((y).a > 0));
28722872
ALTER TYPE test_typex DROP ATTRIBUTE a; -- fails
2873-
ERROR: cannot drop composite type test_typex column a because other objects depend on it
2874-
DETAIL: constraint test_tblx_y_check on table test_tblx depends on composite type test_typex column a
2873+
ERROR: cannot drop column a of composite type test_typex because other objects depend on it
2874+
DETAIL: constraint test_tblx_y_check on table test_tblx depends on column a of composite type test_typex
28752875
HINT: Use DROP ... CASCADE to drop the dependent objects too.
28762876
ALTER TYPE test_typex DROP ATTRIBUTE a CASCADE;
28772877
NOTICE: drop cascades to constraint test_tblx_y_check on table test_tblx

src/test/regress/expected/collate.out

+1-1
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ DROP COLLATION mycoll1;
631631
CREATE TABLE collate_test23 (f1 text collate mycoll2);
632632
DROP COLLATION mycoll2; -- fail
633633
ERROR: cannot drop collation mycoll2 because other objects depend on it
634-
DETAIL: table collate_test23 column f1 depends on collation mycoll2
634+
DETAIL: column f1 of table collate_test23 depends on collation mycoll2
635635
HINT: Use DROP ... CASCADE to drop the dependent objects too.
636636
-- invalid: non-lowercase quoted identifiers
637637
CREATE COLLATION case_coll ("Lc_Collate" = "POSIX", "Lc_Ctype" = "POSIX");

src/test/regress/expected/domain.out

+4-4
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,8 @@ ERROR: operator does not exist: character varying > double precision
298298
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
299299
alter type comptype alter attribute r type bigint;
300300
alter type comptype drop attribute r; -- fail
301-
ERROR: cannot drop composite type comptype column r because other objects depend on it
302-
DETAIL: constraint c1 depends on composite type comptype column r
301+
ERROR: cannot drop column r of composite type comptype because other objects depend on it
302+
DETAIL: constraint c1 depends on column r of composite type comptype
303303
HINT: Use DROP ... CASCADE to drop the dependent objects too.
304304
alter type comptype drop attribute i;
305305
select conname, obj_description(oid, 'pg_constraint') from pg_constraint
@@ -645,8 +645,8 @@ alter domain dnotnulltest drop not null;
645645
update domnotnull set col1 = null;
646646
drop domain dnotnulltest cascade;
647647
NOTICE: drop cascades to 2 other objects
648-
DETAIL: drop cascades to table domnotnull column col1
649-
drop cascades to table domnotnull column col2
648+
DETAIL: drop cascades to column col1 of table domnotnull
649+
drop cascades to column col2 of table domnotnull
650650
-- Test ALTER DOMAIN .. DEFAULT ..
651651
create table domdeftest (col1 ddef1);
652652
insert into domdeftest default values;

src/test/regress/expected/sequence.out

+2-2
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,11 @@ CREATE TEMP TABLE t1 (
293293
-- Both drops should fail, but with different error messages:
294294
DROP SEQUENCE t1_f1_seq;
295295
ERROR: cannot drop sequence t1_f1_seq because other objects depend on it
296-
DETAIL: default for table t1 column f1 depends on sequence t1_f1_seq
296+
DETAIL: default value for column f1 of table t1 depends on sequence t1_f1_seq
297297
HINT: Use DROP ... CASCADE to drop the dependent objects too.
298298
DROP SEQUENCE myseq2;
299299
ERROR: cannot drop sequence myseq2 because other objects depend on it
300-
DETAIL: default for table t1 column f2 depends on sequence myseq2
300+
DETAIL: default value for column f2 of table t1 depends on sequence myseq2
301301
HINT: Use DROP ... CASCADE to drop the dependent objects too.
302302
-- This however will work:
303303
DROP SEQUENCE myseq3;

src/test/regress/expected/triggers.out

+4-4
Original file line numberDiff line numberDiff line change
@@ -557,10 +557,10 @@ LINE 2: FOR EACH STATEMENT WHEN (OLD.* IS DISTINCT FROM NEW.*)
557557
^
558558
-- check dependency restrictions
559559
ALTER TABLE main_table DROP COLUMN b;
560-
ERROR: cannot drop table main_table column b because other objects depend on it
561-
DETAIL: trigger after_upd_b_row_trig on table main_table depends on table main_table column b
562-
trigger after_upd_a_b_row_trig on table main_table depends on table main_table column b
563-
trigger after_upd_b_stmt_trig on table main_table depends on table main_table column b
560+
ERROR: cannot drop column b of table main_table because other objects depend on it
561+
DETAIL: trigger after_upd_b_row_trig on table main_table depends on column b of table main_table
562+
trigger after_upd_a_b_row_trig on table main_table depends on column b of table main_table
563+
trigger after_upd_b_stmt_trig on table main_table depends on column b of table main_table
564564
HINT: Use DROP ... CASCADE to drop the dependent objects too.
565565
-- this should succeed, but we'll roll it back to keep the triggers around
566566
begin;

0 commit comments

Comments
 (0)