Modification to the postgres catalog

Started by Carlos Chaconover 19 years ago5 messages
#1Carlos Chacon
cdcarloschacon@gmail.com

HI... im trying to modify the pg_class table by adding a new attribute. To
accomplish that, i modify the next archives:

- include/pg_class.h: in this file, i modfify:
FormData_pg_class struct: i add the new attribute, example a boolean...
.....
bool myNewAttribute; /*my new attribute */
aclitem relacl[1]; /* we declare this just for the
catalog */
}

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 */

and then, i modify the DATA(insert ..)) of this file by adding a "t" just
before the "_null_" value...

- include/pg_attribute.h: i add to the macros and data the new attribute of
the pg_class table:
...
{ 1259, {"myNewAttribute"},16, -1, 1, 25, 0, -1, -1, true, 'p', 'c',
true, false, false, true, 0 }, \
{ 1259, {"relacl"}, 1034, -1, -1, 26, 1, -1, -1, false, 'x', 'i',
false, false, false, true, 0 } /* this is the macro */

....
DATA(insert ( 1259 relhassubclass 16 -1 1 24 0 -1 -1 t p c t f f t 0));
DATA(insert ( 1259 myNewAttribute 16 -1 1 25 0 -1 -1 t p c t f f t
0));
DATA(insert ( 1259 relacl 1034 -1 -1 26 1 -1 -1 f x i f f f t 0));
/* el data insert */

- utils/cache/relcache.c: in here, when the tables are initialized... i add
the next line of code:
rel->rd_rel->myNewAttribute = true;

then, i compile.... i everything goes well.... but when i execute the comand
"initdb -D ..." i always get next message:
initializing pg_authid ... ok
enabling unlimited row size for system tables ... ok
initializing dependencies ... ok
creating system views ... ok
loading pg_description ... ok
creating conversions ... ok
setting privileges on built-in objects ... FATAL: column "relacl" does not
exist
child process exited with exit code 1

I don't know what's going on???? Can anyone help me please?

thanks.

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Carlos Chacon (#1)
Re: Modification to the postgres catalog

"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

#3Carlos Chacon
cdcarloschacon@gmail.com
In reply to: Tom Lane (#2)
Re: Modification to the postgres catalog

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.

Show quoted text

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

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Carlos Chacon (#3)
Re: Modification to the postgres catalog

"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

#5Carlos Chacon
cdcarloschacon@gmail.com
In reply to: Tom Lane (#4)
Re: Modification to the postgres catalog

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...

Show quoted text

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