Обсуждение: Another quick question...

Поиск
Список
Период
Сортировка

Another quick question...

От
"Christopher Kings-Lynne"
Дата:
If you have RelationGetRelationName(rel) to get the name of a relation, how
do you get it's fully qualified schema name?  Or how do I get the schema
name for the relation?

Chris



Re: Another quick question...

От
Tom Lane
Дата:
"Christopher Kings-Lynne" <chriskl@familyhealth.com.au> writes:
> If you have RelationGetRelationName(rel) to get the name of a relation, how
> do you get it's fully qualified schema name?  Or how do I get the schema
> name for the relation?

Well, you can do get_namespace_name(rel->rd_rel->relnamespace), but
I don't really agree with changing error messages to *always* quote
the schema name.  I think that'd be overly verbose.  An appropriate
solution is to mention the schema name only when it's necessary to
identify the relation (ie, the rel would not be found in your current
search path).

generate_relation_name() in backend/utils/adt/ruleutils.c illustrates
how to do this.  Maybe that code ought to be promoted into some more
widely useful location.  See also the recently added format_procedure()
and format_operator() in regproc.c.
        regards, tom lane


Re: Another quick question...

От
"Christopher Kings-Lynne"
Дата:
> "Christopher Kings-Lynne" <chriskl@familyhealth.com.au> writes:
> > If you have RelationGetRelationName(rel) to get the name of a
> relation, how
> > do you get it's fully qualified schema name?  Or how do I get the schema
> > name for the relation?
>
> Well, you can do get_namespace_name(rel->rd_rel->relnamespace), but
> I don't really agree with changing error messages to *always* quote
> the schema name.  I think that'd be overly verbose.  An appropriate
> solution is to mention the schema name only when it's necessary to
> identify the relation (ie, the rel would not be found in your current
> search path).

The problem I see is that imagine you're browsing your logs.  If you see an
error message (or a notice) that refers just to a table, you have no idea
which schema the table is in...

Chris



Re: Another quick question...

От
Tom Lane
Дата:
"Christopher Kings-Lynne" <chriskl@familyhealth.com.au> writes:
>> Well, you can do get_namespace_name(rel->rd_rel->relnamespace), but
>> I don't really agree with changing error messages to *always* quote
>> the schema name.  I think that'd be overly verbose.

> The problem I see is that imagine you're browsing your logs.  If you see an
> error message (or a notice) that refers just to a table, you have no idea
> which schema the table is in...

Well, yeah, you may need to do a little bit of detective work to
interpret a logged error message.  Perhaps the table name in question
was dropped (and even recreated) since the logged event.  Perhaps it's
in another database than you thought.  Or perhaps it's a long-dead temp
table.  Then we could move to the same set of issues with respect to
the types, functions, operators, etc that might impinge on the error
condition.

I tend to think that error messages should be written for the
convenience of the interactive user, who has some chance of knowing
the context.  Being verbose "for the log" just makes the log bigger
(note recent complaints about volume of log output...)
        regards, tom lane