Re: I think that my data is saved correctly, but when printing again,other data appears - Mailing list pgsql-general

From Yessica Brinkmann
Subject Re: I think that my data is saved correctly, but when printing again,other data appears
Date
Msg-id CABrYqSM8hWYsmA=a1OCiu4uu7HxOTbws42w_++Pvg=F1gWJyOQ@mail.gmail.com
Whole thread Raw
In response to Re: I think that my data is saved correctly, but when printing again,other data appears  (Yessica Brinkmann <yessica.brinkmann@gmail.com>)
Responses Re: I think that my data is saved correctly, but when printing again,other data appears  (Joe Conway <mail@joeconway.com>)
List pgsql-general
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@gmail.com>) escribió:
Thank you very much for the answer.
Best regards,
Yessica Brinkmann

El lun., 28 oct. 2019 a las 8:03, Joe Conway (<mail@joeconway.com>) 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

pgsql-general by date:

Previous
From: Pavel Suderevsky
Date:
Subject: [11.6] WALs recovery ordering with Restore Command - timelines
Next
From: Игорь Выскорко
Date:
Subject: Weird seqscan node plan