Обсуждение: pg_attribute file in PostgreSQL 9.0

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

pg_attribute file in PostgreSQL 9.0

От
Lukasz Brodziak
Дата:
Hello,

I have a question regarding pg_attribute. In which file it is stored
because the relfilenode for it shows 0 and file 1249 isn't present in
the folder.

--
Łukasz Brodziak

Re: pg_attribute file in PostgreSQL 9.0

От
Steve Crawford
Дата:
On 03/07/2012 05:14 AM, Lukasz Brodziak wrote:
> Hello,
>
> I have a question regarding pg_attribute. In which file it is stored
> because the relfilenode for it shows 0 and file 1249 isn't present in
> the folder.
>
select pg_relation_filepath('pg_attribute');

 From the docs, relfilenode is:
"Name of the on-disk file of this relation; zero means this is a
"mapped" relation whose disk file name is determined by low-level state"

However the meaning "mapped relation" and "low-level state" are
difficult to divine from the docs. Go with the function.

Cheers,
Steve


Re: pg_attribute file in PostgreSQL 9.0

От
Tom Lane
Дата:
Steve Crawford <scrawford@pinpointresearch.com> writes:
> On 03/07/2012 05:14 AM, Lukasz Brodziak wrote:
>> I have a question regarding pg_attribute. In which file it is stored
>> because the relfilenode for it shows 0 and file 1249 isn't present in
>> the folder.

> select pg_relation_filepath('pg_attribute');

>  From the docs, relfilenode is:
> "Name of the on-disk file of this relation; zero means this is a
> "mapped" relation whose disk file name is determined by low-level state"

> However the meaning "mapped relation" and "low-level state" are
> difficult to divine from the docs. Go with the function.

Or use pg_relation_filenode() if you want the result of the mapping.

            regards, tom lane

Re: pg_attribute file in PostgreSQL 9.0

От
Lukasz Brodziak
Дата:
Thanks a lot I have found file I needed let's hope I will be able to
fix the problem now as I cannot connect to the database because I get
'catalog is missing 1 attribute for relation 2662' which I hope to be
able to repair by getting the pg_attribute file from another db.

2012/3/7 Tom Lane <tgl@sss.pgh.pa.us>:
> Steve Crawford <scrawford@pinpointresearch.com> writes:
>> On 03/07/2012 05:14 AM, Lukasz Brodziak wrote:
>>> I have a question regarding pg_attribute. In which file it is stored
>>> because the relfilenode for it shows 0 and file 1249 isn't present in
>>> the folder.
>
>> select pg_relation_filepath('pg_attribute');
>
>>  From the docs, relfilenode is:
>> "Name of the on-disk file of this relation; zero means this is a
>> "mapped" relation whose disk file name is determined by low-level state"
>
>> However the meaning "mapped relation" and "low-level state" are
>> difficult to divine from the docs. Go with the function.
>
> Or use pg_relation_filenode() if you want the result of the mapping.
>
>                        regards, tom lane



--
Łukasz Brodziak
"Do you bury me when I'm gone
Do you teach me while I'm here
Just as soon I belong
Then it's time I disappear"

Re: pg_attribute file in PostgreSQL 9.0

От
Steve Crawford
Дата:
On 03/07/2012 09:03 AM, Lukasz Brodziak wrote:
> Thanks a lot I have found file I needed let's hope I will be able to
> fix the problem now as I cannot connect to the database because I get
> 'catalog is missing 1 attribute for relation 2662' which I hope to be
> able to repair by getting the pg_attribute file from another db.
>
STOP! Don't touch anything just yet. Now we know the real reason for the
question.

Do you have an idea what may have caused this? Are there any relevant
errors in the log? What is the source of the file that you want to use
as a replacement? What version of PG? OS? Is the database able to start?
Are you attempting to connect as a superuser?

With this as a starting point you may get some valuable advice (though
from those people far more capable of answering this question than I).

Cheers,
Steve


Re: pg_attribute file in PostgreSQL 9.0

От
Tom Lane
Дата:
Steve Crawford <scrawford@pinpointresearch.com> writes:
> On 03/07/2012 09:03 AM, Lukasz Brodziak wrote:
>> Thanks a lot I have found file I needed let's hope I will be able to
>> fix the problem now as I cannot connect to the database because I get
>> 'catalog is missing 1 attribute for relation 2662' which I hope to be
>> able to repair by getting the pg_attribute file from another db.

> STOP! Don't touch anything just yet. Now we know the real reason for the
> question.

... yeah, and this is the wrong answer.  It's *exceedingly* unlikely
that plopping in the pg_attribute file from a different database will
accomplish anything except to make matters far worse.  Even if the other
DB has exactly the same tables and exactly the same columns in those
tables, it likely doesn't have the same OID assignments.

            regards, tom lane

Re: pg_attribute file in PostgreSQL 9.0

От
Lukasz Brodziak
Дата:
Ok, so the case is that I don't have the exact cause of the problem as
it occured on one of our clients dbs. The PG version is 9.0.0 and the
OS is windows XP. The DB is able to start (I have the data folder) but
when I connect to the db from our application (or pgAdmin) I come
across the above mentioned error. I have managed to get into the
database after replacing the pg_attribute from another DB (clean db
created with our installer) but then I read Your mail so I stopped at
this point. Pg_log has only this one information on the error.

2012/3/7 Tom Lane <tgl@sss.pgh.pa.us>:
> Steve Crawford <scrawford@pinpointresearch.com> writes:
>> On 03/07/2012 09:03 AM, Lukasz Brodziak wrote:
>>> Thanks a lot I have found file I needed let's hope I will be able to
>>> fix the problem now as I cannot connect to the database because I get
>>> 'catalog is missing 1 attribute for relation 2662' which I hope to be
>>> able to repair by getting the pg_attribute file from another db.
>
>> STOP! Don't touch anything just yet. Now we know the real reason for the
>> question.
>
> ... yeah, and this is the wrong answer.  It's *exceedingly* unlikely
> that plopping in the pg_attribute file from a different database will
> accomplish anything except to make matters far worse.  Even if the other
> DB has exactly the same tables and exactly the same columns in those
> tables, it likely doesn't have the same OID assignments.
>
>                        regards, tom lane



--
Łukasz Brodziak
"Do you bury me when I'm gone
Do you teach me while I'm here
Just as soon I belong
Then it's time I disappear"

Re: pg_attribute file in PostgreSQL 9.0

От
"Kevin Grittner"
Дата:
Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Steve Crawford <scrawford@pinpointresearch.com> writes:
>> On 03/07/2012 09:03 AM, Lukasz Brodziak wrote:
>>> Thanks a lot I have found file I needed let's hope I will be
>>> able to fix the problem now as I cannot connect to the database
>>> because I get 'catalog is missing 1 attribute for relation 2662'
>>> which I hope to be able to repair by getting the pg_attribute
>>> file from another db.
>
>> STOP! Don't touch anything just yet. Now we know the real reason
>> for the question.
>
> ... yeah, and this is the wrong answer.  It's *exceedingly*
> unlikely that plopping in the pg_attribute file from a different
> database will accomplish anything except to make matters far
> worse.  Even if the other DB has exactly the same tables and
> exactly the same columns in those tables, it likely doesn't have
> the same OID assignments.

http://wiki.postgresql.org/wiki/Corruption

-Kevin

Re: pg_attribute file in PostgreSQL 9.0

От
Achilleas Mantzios
Дата:
On Τετ 07 Μαρ 2012 15:14:33 Lukasz Brodziak wrote:
> Hello,
>
> I have a question regarding pg_attribute. In which file it is stored
> because the relfilenode for it shows 0 and file 1249 isn't present in
> the folder.

in my system:

dynacom=# SELECT pg_relation_filepath('public.vessels'::regclass);
 pg_relation_filepath
----------------------
 base/539545/63242177
(1 row)

for system catalog tables you will have this relfilenode = 0

--
Achilleas Mantzios
IT DEPT