Обсуждение: Modification to the postgres catalog

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

Modification to the postgres catalog

От
"Carlos Chacon"
Дата:
HI... im trying to modify the pg_class table by adding a new attribute. To accomplish that, i modify the next
archives:<br/><br />- include/pg_class.h: in this file, i modfify:<br /><div style="margin-left: 40px;"> 
FormData_pg_classstruct: i add the new attribute, example a boolean... <br />       .....<br />       bool
myNewAttribute;  /*my new attribute */<br />       aclitem        relacl[1];        /* we declare this just for the
catalog*/<br />  }<br /></div><br /> then, i modify the macro "CLASS_TUPLE_SIZE": <br /><div style="margin-left:
40px;">   #define CLASS_TUPLE_SIZE \<br />     (offsetof(FormData_pg_class,relhassubclass) + sizeof(bool) +
sizeof(bool))  /* the last bool is my bool */<br /></div><br />and then, i modify the DATA(insert ..)) of this file by
addinga "t" just before the "_null_" value... <br /><br />- include/pg_attribute.h: i add to the macros and data the
newattribute of the pg_class table:<br /><div style="margin-left: 80px;">...<br />{ 1259, {"myNewAttribute"},16, -1,   
1,25, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0 }, \ <br />{ 1259, {"relacl"},         1034, -1, -1, 26,
1,-1, -1, false, 'x', 'i', false, false, false, true, 0 } /* this is the macro */<br /><br />....<br />DATA(insert (
1259relhassubclass    16 -1 1  24 0 -1 -1 t p c t f f t 0)); <br />DATA(insert ( 1259 myNewAttribute        16 -1 1  25
0-1 -1 t p c t f f t 0));<br />DATA(insert ( 1259 relacl          1034 -1 -1 26 1 -1 -1 f x i f f f t 0)); /* el data
insert*/<br /></div><br />- utils/cache/relcache.c: in here, when the tables are initialized... i add the next line of
code:<br /><div style="margin-left: 40px;">rel->rd_rel->myNewAttribute = true;<br /></div><br />then, i
compile....i everything goes well.... but when i execute the comand "initdb -D ..." i always get next message:<br
/><divstyle="margin-left: 40px;">initializing pg_authid ... ok<br />enabling unlimited row size for system tables ...
ok<br/>initializing dependencies ... ok<br />creating system views ... ok<br />loading pg_description ... ok<br />
creatingconversions ... ok<br />setting privileges on built-in objects ... FATAL:  column "relacl" does not exist<br
/>childprocess exited with exit code 1<br /><br /></div>I don't know what's going on???? Can anyone help me please? <br
/><br/>thanks.<br /><br /> 

Re: Modification to the postgres catalog

От
Tom Lane
Дата:
"Carlos Chacon" <cdcarloschacon@gmail.com> writes:
> HI... im trying to modify the pg_class table by adding a new
> attribute.

> - include/pg_class.h: in this file, i modfify:

Did you remember to update Natts_pg_class and the Anum_ macros?

>  then, i modify the macro "CLASS_TUPLE_SIZE":
>     #define CLASS_TUPLE_SIZE \
>      (offsetof(FormData_pg_class,relhassubclass) + sizeof(bool) +
> sizeof(bool))   /* the last bool is my bool */

Seriously ugly, should use offsetof the last attribute, ie, yours.

Also, look at the uses of Natts_pg_class_fixed --- there was some
cruftiness involved there in existing releases (it's gone in HEAD
and I'm too lazy to look back at exactly what it was...)
        regards, tom lane


Re: Modification to the postgres catalog

От
"Carlos Chacon"
Дата:
Thanks for you help...
But i modify too Natts_pg_class and the Anum macro...Only  I forgot mentionated it in the last mail. i put:
#define Natts_pg_class_fixed            25
#define Natts_pg_class                    26
....
#define Anum_pg_class_myNewAttribute        25
#define Anum_pg_class_relacl            26


I really don't understand you when you said: "there was some
cruftiness involved there in existing releases (it's gone in HEAD
and I'm too lazy to look back at exactly what it was...)"...

Anyway, thanks for trying to help me....

P.D: For anyone, i still need help.... Bye.

On 10/11/06, Tom Lane <tgl@sss.pgh.pa.us> wrote:
"Carlos Chacon" < cdcarloschacon@gmail.com> writes:
> HI... im trying to modify the pg_class table by adding a new
> attribute.

> - include/pg_class.h: in this file, i modfify:

Did you remember to update Natts_pg_class and the Anum_ macros?

>  then, i modify the macro "CLASS_TUPLE_SIZE":
>     #define CLASS_TUPLE_SIZE \
>      (offsetof(FormData_pg_class,relhassubclass) + sizeof(bool) +
> sizeof(bool))   /* the last bool is my bool */

Seriously ugly, should use offsetof the last attribute, ie, yours.

Also, look at the uses of Natts_pg_class_fixed --- there was some
cruftiness involved there in existing releases (it's gone in HEAD
and I'm too lazy to look back at exactly what it was...)

                        regards, tom lane

Re: Modification to the postgres catalog

От
Tom Lane
Дата:
"Carlos Chacon" <cdcarloschacon@gmail.com> writes:
> But i modify too Natts_pg_class and the Anum macro...Only  I forgot
> mentionated it in the last mail. i put:

OK ... did you add a suitable initial value to each of the DATA lines in
pg_class.h?  Did you remember to adjust pg_class's own relnatts field
appearing in the DATA line for it?

You could try looking at one of the past commits that has added a column
to pg_class, and make sure you touched all the places it did.
        regards, tom lane


Re: Modification to the postgres catalog

От
"Carlos Chacon"
Дата:
Tom, Hi. Sorry that i can't response your message soon... i lost my internet connection...

But you were right... I forgot to modify the relnatts of the pg_class table in DATA line for it... that was crashing the "initdb" command....

Thanks... if you don't remind me of that, i would never see it...

Bye. Thanks, again...

On 10/11/06, Tom Lane < tgl@sss.pgh.pa.us> wrote:
"Carlos Chacon" < cdcarloschacon@gmail.com> writes:
> But i modify too Natts_pg_class and the Anum macro...Only  I forgot
> mentionated it in the last mail. i put:

OK ... did you add a suitable initial value to each of the DATA lines in
pg_class.h?  Did you remember to adjust pg_class's own relnatts field
appearing in the DATA line for it?

You could try looking at one of the past commits that has added a column
to pg_class, and make sure you touched all the places it did.

                        regards, tom lane