Thread: psql
What i am trying to do is to maintain a linked list of all the relations in a database. When i create a db then i want it to insert into the linked list the relation ids. As it stands now, i can create a db fine and i see the relation id's in the linked list. BUT, as soon as i psql into the db then they all disappear. I maintain an array that stores the linked lists which i initialized in buf_init. I don't understand this. Can someone explain why? Is it wiping out the array i initialized before. signed please shed some light
On Thu, Jun 19, 2003 at 17:07:43 -0400, Nailah Ogeer <ogeer@cs.queensu.ca> wrote: Please don't respond to other messages to start a new thread. > What i am trying to do is to maintain a linked list of all the relations > in a database. When i create a db then i want it to insert into the linked > list the relation ids. As it stands now, i can create a db fine and i see > the relation id's in the linked list. BUT, as soon as i psql into the db > then they all disappear. I maintain an array that stores the linked lists > which i initialized in buf_init. > I don't understand this. Can someone explain why? Is it wiping out the > array i initialized before. You might be better off explaining to us what you are really trying to do. Information about relations is already in the system catalogs. Using a linked list in a relation database doesn't work very well.
what i was trying to do was maintain an array of Buffer pool clusters. What i did previously was change the pointers around in the freelist so instead of one i have 4. Now each buffer pool is called a BP cluster. Within this BP cluster i have things like cluster id, freelist descriptor etc, and a linked list that holds all the relation id's belonging to that cluster (right now it does this randomly but we will change this to grouping according to access patterns). Every time i call RelationBuildDesc from relcache.c, i randomly assign a cluster id and put the relation id in the cluster. And every time i want to remove the relation from the BP i will have to remove it from the linked list of relation ids. I know that this implementation will not work well for multi database systems, but this is just the first step of this work. So what is happening is that i enter the relation ids into the BP cluster linked list fine and every time i call psql, it automatically deletes. hope i gave u a better explanation On Thu, 19 Jun 2003, Bruno Wolff III wrote: > On Thu, Jun 19, 2003 at 17:07:43 -0400, > Nailah Ogeer <ogeer@cs.queensu.ca> wrote: > > Please don't respond to other messages to start a new thread. > > > What i am trying to do is to maintain a linked list of all the relations > > in a database. When i create a db then i want it to insert into the linked > > list the relation ids. As it stands now, i can create a db fine and i see > > the relation id's in the linked list. BUT, as soon as i psql into the db > > then they all disappear. I maintain an array that stores the linked lists > > which i initialized in buf_init. > > I don't understand this. Can someone explain why? Is it wiping out the > > array i initialized before. > > You might be better off explaining to us what you are really trying to > do. Information about relations is already in the system catalogs. > Using a linked list in a relation database doesn't work very well. >
Nailah Ogeer <ogeer@cs.queensu.ca> writes: > So what is happening is that i enter the relation ids into the BP cluster > linked list fine and every time i call psql, it automatically deletes. Sounds to me like you are trying to keep stuff in backend-local memory that needs to be in shared memory. regards, tom lane
Well here's the thing. Before i was trying to use ShmemInitStruct in buf_init.c. The problem with this is that you can't shrink or grow shared memory. That is why i switched over and just used malloc. So i seem to be in a big dilemma, on one hand, if i use malloc, i can't keep this info i need; and on the other if i use shmeminitstruct then i can't shrink or grow the BP clusters. But i will try to test your hypothesis to see if shared memory will take care of this. On Fri, 20 Jun 2003, Tom Lane wrote: > Nailah Ogeer <ogeer@cs.queensu.ca> writes: > > So what is happening is that i enter the relation ids into the BP cluster > > linked list fine and every time i call psql, it automatically deletes. > > Sounds to me like you are trying to keep stuff in backend-local memory > that needs to be in shared memory. > > regards, tom lane > > ---------------------------(end of broadcast)--------------------------- > TIP 8: explain analyze is your friend >
>>>>> "Nailah" == Nailah Ogeer <ogeer@cs.queensu.ca> writes: Nailah> Well here's the thing. Before i was trying to use Nailah> ShmemInitStruct in buf_init.c. The problem with this is Nailah> that you can't shrink or grow shared memory. That is why i Nailah> switched over and just used malloc. So i seem to be in a We've implemented a Shared Memory MemoryContext in TelegraphCQ. We used the opensource libmm from the Apache project. Maybe you can try using it - it's fairly easy to use. The current version in the web is based off of 7.2 code, but I hope to refresh with a beta based on 7.3 code in the next few weeks. http://telegraph.cs.berkeley.edu/telegraphcq -- Pip-pip Sailesh http://www.cs.berkeley.edu/~sailesh