Unix Technical Forum

Modification to the postgres catalog

This is a discussion on Modification to the postgres catalog within the pgsql Hackers forums, part of the PostgreSQL category; --> HI... im trying to modify the pg_class table by adding a new attribute. To accomplish that, i modify the ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-12-2008, 05:15 AM
Carlos Chacon
 
Posts: n/a
Default Modification to the postgres catalog

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.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-12-2008, 05:15 AM
Tom Lane
 
Posts: n/a
Default 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

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-12-2008, 05:15 AM
Carlos Chacon
 
Posts: n/a
Default 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.

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
>


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-12-2008, 05:15 AM
Tom Lane
 
Posts: n/a
Default 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

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-12-2008, 05:17 AM
Carlos Chacon
 
Posts: n/a
Default 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...

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
>


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:01 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com