Search Postgresql Archives

Re: I think that my data is saved correctly, but when printing again, other data appears

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Good afternoon,
Well, I spent some time without implementing my thesis for a topic of mental fatigue, I had to go for a while.
A few days ago I came back and was trying to implement the context change.
But I really believe that, although I read the explanations and source codes that you indicated, and others that I found, I didn't quite understand what I should do.
Well, as I was told that I should save the CurrentMemoryContext before starting the SPI,
Let's say it would be before doing SPI_connect (). Is this correct?
And then I must use MemoryContextStrdup. As you told me the MemoryContextStrdup It is used to create a copy of a string in a specific memory context.
Well, where in the source code should I use MemoryContextStrdup? After doing the SPI_connect () or where? I would use it from MemoryContextStrdup to copy the data variable as I understand it, But in what context would I have to create the copy? In a new context or what would the theme be like?
Should I use AllocSetContextCreate to create the new context or what would the theme be like?
And if I have to create the new context with AllocSetContextCreate, where in the source code will I have to create it? After doing SPI_connect () or where?
The truth is that I also read the source code of https://github.com/cohenjo/pg_idx_advisor but I don't see that The MemoryContextStrdup that they told me to use has been used there.
Sorry for the inconvenience and see the same thing again. But as I indicated, I also read the explanations they told me to read (which were explanations about the memory contexts in Postgresql mainly) but there were no examples of source code.
And since there is nothing on the Internet of examples that will help me to use, I am asking again.
And the truth is that I didn't find examples of this in the Postgres source code, just definitions, That is the source code where MemoryContextStrdup is defined.
It may be very easy for you and you will see it very clearly, but for me it really is not, and there are no examples of use on the Internet.
I really searched a lot and found nothing.
I would greatly appreciate a help please.
Regards,
Yessica Brinkmann

El lun., 28 oct. 2019 a las 12:39, Yessica Brinkmann (<yessica.brinkmann@xxxxxxxxx>) escribió:
Thank you very much for the answer.
Best regards,
Yessica Brinkmann

El lun., 28 oct. 2019 a las 8:03, Joe Conway (<mail@xxxxxxxxxxxxx>) escribió:
On 10/27/19 8:01 PM, Yessica Brinkmann wrote:
> Thank you so much for the answers.
> By telling me this: "MemoryContextStrdup enables you to create a copy of
> a string in an explicitly specified memory context." I better understood
> the function of MemoryContextStrdup.
> And thank you very much to Mr. Jony Cohen for giving me the reference of
> his work. I really was already researching about his work, and I
> included it in the state of the art of my thesis, but I didn't look at
> the source code.
> I will be looking at the source code for a help, and especially in this
> case to see for the moment, the maintenance of the context for its
> subsequent restoration.

For better understanding of how Postgres manages memory, you might want
to also read this:

https://github.com/postgres/postgres/blob/master/src/backend/utils/mmgr/README

and possibly browse through this:

https://github.com/postgres/postgres/blob/master/src/backend/utils/mmgr/mcxt.c

HTH,

Joe
--
Crunchy Data - http://crunchydata.com
PostgreSQL Support for Secure Enterprises
Consulting, Training, & Open Source Development


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux