Thread: How to add column in pg_class

How to add column in pg_class

From
Rafaqat Ali
Date:
<pre><font size="4"><span style="font-family: times new roman,serif;">Hello <br />     can any one tell me how can I
adda new cloumn in pg_class<br /><br style="font-family: times new roman,serif;" /></span><span style="font-family:
timesnew roman,serif;"> 
Currently I am doing :<br />   In pg_class.h<br /><br />    * In CATALOG(pg_class) BOOTSTRAP define the variable
[var-name]<br/>    * define a variable for [var-name] as<br />        #define Anum_pg_class_[var-name]
[value]<br/>    * And pass default value to DATA macro for that variable. 
<br />    * Change the value of <br />        Natts_pg_class_fixed from 25 to 26<br />        Natts_pg_class from 26 to
27.<br/><br /><br />   In pg_attribute<br />    * in  #define Schema_pg_class added proper values for that
[var-name].<br/>    * Then provided value to DATA macro for [var-name]. 
<br /><br />    In heapam.c<br />         I add 0 in pg_class for that variable and perform simple heap_update for
relatedtuple in pg_class..<br />       In this way<br />                1. when I add variable after relacl in
pg_class,it adds null for [var-nam] for tuples added in initdb. 
<br />                2. when I creates a new table, it does not add the values I specified.<br /><br />      When I
placeit before relacl, initdb exits with a segmentation fault.<br />      Is there any other file in which I have to
makechange ????? 
<br /><br />        Regards<br />                   Rafaqat Ali<br /></span></font></pre>

Re: How to add column in pg_class

From
Tom Lane
Date:
Rafaqat Ali <smoken0@gmail.com> writes:
>       Is there any other file in which I have to make change ?????

Fooling with any of the bootstrapped catalogs is pretty messy.
You might grab this patch from the CVS server for comparison:

2005-03-29 14:44  tgl
* doc/src/sgml/bki.sgml, doc/src/sgml/catalogs.sgml,src/backend/bootstrap/bootstrap.c,
src/backend/catalog/pg_proc.c,src/include/catalog/catversion.h,src/include/catalog/pg_attribute.h,
src/include/catalog/pg_class.h,src/include/catalog/pg_proc.h:Add proallargtypes and proargmodescolumns to pg_proc, as
permy earlier proposal for OUT parametersupport.  The columns don't actually *do* anything yet, they arejust left
NULLs. But I thought I'd commit this part separately asa fairly pure example of the tasks needed when adding a column
topg_procor one of the other core system tables.
 

Whatever you're doing in heapam.c is probably wrong, too.  There is no
reason for that file to be involved in a system catalog extension ---
it operates at too low a level.
        regards, tom lane