The connection to the server was lost. Attempting reset: Failed.
Good afternoon, I am doing a thesis from the University. My thesis is the modification of the Gurjeet Index Adviser, to add some features. At the moment I am modifying one of the .c files and adding a function called get_columnames that returns the names of the columns of a table, passing it the numbers of the attributes. I really thought a lot, but I don't understand why but the function fails after the expression is executed: appendStringInfo (& cols, "% s a.attnum =% d", (i> 0? "OR": ""), idxcd-> varattno [i]); The error appears only to me when entering the cycle: foreach (cell, candidates) / * foreach cell in candidates * / more than once, that is, when you have more than one candidate index. If the cycle is entered only once, the function works correctly. The error that appears to me is that the connection to the PostgreSQL server is directly lost. I proved that the error occurs in that statement, printing some values. The error that appears to me is the following: The connection to the server was lost. Attempting reset: Failed. I attach the source code of the function (function.c) and the log file with the output of the last executions. I clarify that the foreach cycle for the c language is defined in #include "nodes / pg_list.h" I am using Postgresql 8.3.23. I clarify that I use that version because it is compatible with the Index Adviser, which I am modifying for my University thesis. I was analyzing and researching on the compilation without optimizations, with symbols and also on the use of gbd. Very interesting everything. My query is now if all this can be applied the same if a Makefile is used. Because the Index Adviser comes with a Makefile that runs for compilation. That is, as I read it is more or less easy to apply all this if I'm going to compile from the command line but having the Makefile, the truth is that I don't know how to apply it. I am new with Linux. The Linux distribution I use is Debian 9.x 64-bit. And the version of C (gcc) that I use is 6.3.0 I will greatly appreciate an answer please, I also attach the Index Adviser Makefile. I would greatly appreciate a help please. I really am not knowing how to move forward. As I commented, my function works for the case in which the foreach is entered only once. But when you enter more than once, it doesn't work. That is, when you have more than one candidate index, it gives me that error. This means that, for example, for a simple Select type statement or that has an AND it works for me. But for the case where the Select statement has an OR for example, it doesn't work. Because you already have more than one candidate index and enter the foreach more than once. I will be very grateful if anyone can help me please. I already thought a lot why the mistake could happen but I can't really find a reason. Best regards, Yessica Brinkmann FATAL: the database system is in recovery mode LOG: database system is ready to accept connections LOG: autovacuum launcher started LOG: database system was shut down at 2019-10-04 00:58:21 CEST LOG: database system is ready to accept connections LOG: autovacuum launcher started LOG: server process (PID 1245) was terminated by signal 11: Segmentation fault LOG: terminating any other active server processes LOG: all server processes terminated; reinitializing LOG: database system was interrupted; last known up at 2019-10-04 02:08:57 CEST LOG: database system was not properly shut down; automatic recovery in progress FATAL: the database system is in recovery mode LOG: redo starts at 0/BEE6A00 LOG: record with zero length at 0/BEFA848 LOG: redo done at 0/BEFA818 LOG: last completed transaction was at log time 2019-10-04 02:11:33.931119+02 LOG: database system is ready to accept connections LOG: autovacuum launcher started LOG: server process (PID 1388) was terminated by signal 11: Segmentation fault LOG: terminating any other active server processes LOG: all server processes terminated; reinitializing LOG: database system was interrupted; last known up at 2019-10-04 02:11:44 CEST LOG: database system was not properly shut down; automatic recovery in progress LOG: redo starts at 0/BEFA890 LOG: record with zero length at 0/BF0F940 LOG: redo done at 0/BF0F910 LOG: last completed transaction was at log time 2019-10-04 02:17:13.560035+02 FATAL: the database system is in recovery mode LOG: database system is ready to accept connections LOG: autovacuum launcher started LOG: received smart shutdown request LOG: received SIGHUP, reloading configuration files LOG: autovacuum launcher shutting down LOG: shutting down LOG: database system is shut down LOG: database system was shut down at 2019-10-04 02:36:09 CEST LOG: database system is ready to accept connections LOG: autovacuum launcher started LOG: server process (PID 1271) was terminated by signal 11: Segmentation fault LOG: terminating any other a
Re: The connection to the server was lost. Attempting reset: Failed.
Thank you so much for your answer. I will be testing the indicated and then I give you return. Best regards, Yessica Brinkmann El jue., 10 oct. 2019 a las 13:14, Tom Lane () escribió: > Yessica Brinkmann writes: > > I really thought a lot, but I don't understand why but the function fails > > after the expression is executed: > > appendStringInfo (& cols, "% s a.attnum =% d", (i> 0? "OR": ""), idxcd-> > > varattno [i]); > > I think you're probably shooting yourself in the foot here: > > /* pfree() the memory allocated for the previous candidate. > FIXME: Avoid > * meddling with the internals of a StringInfo, and try to use > an API. > */ > if( cols.len > 0 ) > { > pfree( cols.data ); > cols.data = NULL; > } /*IF col.len>0*/ > > Don't do that, use resetStringInfo() instead. > > regards, tom lane >
Re: The connection to the server was lost. Attempting reset: Failed.
Thank you so much for your answer. I will be testing the indicated and then I give you return. Best regards, Yessica Brinkmann El jue., 10 oct. 2019 a las 13:15, Alban Hertroys () escribió: > > > On 10 Oct 2019, at 17:55, Yessica Brinkmann > wrote: > > > > I really thought a lot, but I don't understand why but the function > fails after the expression is executed: > > appendStringInfo (& cols, "% s a.attnum =% d", (i> 0? "OR": ""), idxcd-> > varattno [i]); > > The error appears only to me when entering the cycle: > > foreach (cell, candidates) / * foreach cell in candidates * / > > more than once, that is, when you have more than one candidate index. If > the cycle is entered only once, the function works correctly. > > The error that appears to me is that the connection to the PostgreSQL > server is directly lost. I proved that the error occurs in that statement, > printing some values. > > There is probably an error in the Postgres log-file providing you more > info. > > That said, at least the below bit in your code is dangerous: > > foreach( cell, candidates ) /* foreach cell in candidates */ > { > > idxcd = (IndexCandidate*)lfirst( cell ); > > if( !idxcd->idxused ) > continue; > > if (idxcd!=NULL) > { > > > You should at least check for NULL before referencing an attribute of that > structure. Personally, I would invert the test like so (and then move it > before the idxused test: > > if (idxcd == NULL) { > elog( INFO, "idxcd IS NULL" ); > continue; /* Or is that fatal enough to break instead? */ > ) > > if (!idxcd->idxused) > continue; > > > > Alban Hertroys > -- > There is always an exception to always. > > > > >
Re: The connection to the server was lost. Attempting reset: Failed.
Thank you very much for the reply. Well, really, resetStringInfo () is a function of the StringInfo data structure. What I used at the end was initStringInfo, which is a function of the data structure StringInfoData, which is what I am using, although I don't know if they are equivalent. The code remained as follows: if (cols.len> 0) { initStringInfo (& cols); } / * IF col.len> 0 * / But it continues giving me the same error. Best regards, Yessica Brinkmann El jue., 10 oct. 2019 a las 13:33, Yessica Brinkmann (< yessica.brinkm...@gmail.com>) escribió: > Thank you so much for your answer. I will be testing the indicated and > then I give you return. > Best regards, > Yessica Brinkmann > > El jue., 10 oct. 2019 a las 13:14, Tom Lane () > escribió: > >> Yessica Brinkmann writes: >> > I really thought a lot, but I don't understand why but the function >> fails >> > after the expression is executed: >> > appendStringInfo (& cols, "% s a.attnum =% d", (i> 0? "OR": ""), idxcd-> >> > varattno [i]); >> >> I think you're probably shooting yourself in the foot here: >> >> /* pfree() the memory allocated for the previous candidate. >> FIXME: Avoid >> * meddling with the internals of a StringInfo, and try to use >> an API. >> */ >> if( cols.len > 0 ) >> { >> pfree( cols.data ); >> cols.data = NULL; >> } /*IF col.len>0*/ >> >> Don't do that, use resetStringInfo() instead. >> >> regards, tom lane >> >
Re: The connection to the server was lost. Attempting reset: Failed.
Thank you so much for your answer. I will be testing the indicated and then I give you return. Best regards, Yessica Brinkmann El jue., 10 oct. 2019 a las 15:25, Jaime Soler () escribió: > Why don't have a try to gdb ? > https://wiki.postgresql.org/wiki/Developer_FAQ#What_debugging_features_are_available.3F > > It might be a extra free memory executions or null pointer accesses .. , > gdb could help you. > > Regards > > El jue., 10 oct. 2019 a las 20:01, Yessica Brinkmann (< > yessica.brinkm...@gmail.com>) escribió: > >> Thank you very much for the reply. >> Well, really, resetStringInfo () is a function of the StringInfo data >> structure. >> What I used at the end was initStringInfo, which is a function of the >> data structure StringInfoData, which is what I am using, although I don't >> know if they are equivalent. >> The code remained as follows: >>if (cols.len> 0) >> { >>initStringInfo (& cols); >> } / * IF col.len> 0 * / >> But it continues giving me the same error. >> Best regards, >> Yessica Brinkmann >> >> El jue., 10 oct. 2019 a las 13:33, Yessica Brinkmann (< >> yessica.brinkm...@gmail.com>) escribió: >> >>> Thank you so much for your answer. I will be testing the indicated and >>> then I give you return. >>> Best regards, >>> Yessica Brinkmann >>> >>> El jue., 10 oct. 2019 a las 13:14, Tom Lane () >>> escribió: >>> >>>> Yessica Brinkmann writes: >>>> > I really thought a lot, but I don't understand why but the function >>>> fails >>>> > after the expression is executed: >>>> > appendStringInfo (& cols, "% s a.attnum =% d", (i> 0? "OR": ""), >>>> idxcd-> >>>> > varattno [i]); >>>> >>>> I think you're probably shooting yourself in the foot here: >>>> >>>> /* pfree() the memory allocated for the previous candidate. >>>> FIXME: Avoid >>>> * meddling with the internals of a StringInfo, and try to >>>> use an API. >>>> */ >>>> if( cols.len > 0 ) >>>> { >>>> pfree( cols.data ); >>>> cols.data = NULL; >>>> } /*IF col.len>0*/ >>>> >>>> Don't do that, use resetStringInfo() instead. >>>> >>>> regards, tom lane >>>> >>>
Re: The connection to the server was lost. Attempting reset: Failed.
Thank you very much for your answer. It helped me. Really now the get_columnnames function is already working and ends cleanly. I have an error in the following function to be executed that generates the same error: The connection to the server was lost. Attempting reset: Failed. I will try to solve it alone and if I cannot write another new mail thread. Because this problem of get_columnnames is already solved. Many thanks, Best regards, Yessica Brinkmann El jue., 10 oct. 2019 a las 13:15, Alban Hertroys () escribió: > > > On 10 Oct 2019, at 17:55, Yessica Brinkmann > wrote: > > > > I really thought a lot, but I don't understand why but the function > fails after the expression is executed: > > appendStringInfo (& cols, "% s a.attnum =% d", (i> 0? "OR": ""), idxcd-> > varattno [i]); > > The error appears only to me when entering the cycle: > > foreach (cell, candidates) / * foreach cell in candidates * / > > more than once, that is, when you have more than one candidate index. If > the cycle is entered only once, the function works correctly. > > The error that appears to me is that the connection to the PostgreSQL > server is directly lost. I proved that the error occurs in that statement, > printing some values. > > There is probably an error in the Postgres log-file providing you more > info. > > That said, at least the below bit in your code is dangerous: > > foreach( cell, candidates ) /* foreach cell in candidates */ > { > > idxcd = (IndexCandidate*)lfirst( cell ); > > if( !idxcd->idxused ) > continue; > > if (idxcd!=NULL) > { > > > You should at least check for NULL before referencing an attribute of that > structure. Personally, I would invert the test like so (and then move it > before the idxused test: > > if (idxcd == NULL) { > elog( INFO, "idxcd IS NULL" ); > continue; /* Or is that fatal enough to break instead? */ > ) > > if (!idxcd->idxused) > continue; > > > > Alban Hertroys > -- > There is always an exception to always. > > > > >
Re: The connection to the server was lost. Attempting reset: Failed.
That is, It worked by changing the code to: if (idxcd == NULL) { elog( INFO, "idxcd IS NULL" ); continue; /* Or is that fatal enough to break instead? */ } if (!idxcd->idxused) continue; Very thanks, Yessica Brinkmann El jue., 10 oct. 2019 a las 16:43, Yessica Brinkmann (< yessica.brinkm...@gmail.com>) escribió: > Thank you very much for your answer. > It helped me. > Really now the get_columnnames function is already working and ends > cleanly. > I have an error in the following function to be executed that generates > the same error: The connection to the server was lost. Attempting reset: > Failed. I will try to solve it alone and if I cannot write another new mail > thread. > Because this problem of get_columnnames is already solved. > Many thanks, > Best regards, > Yessica Brinkmann > > El jue., 10 oct. 2019 a las 13:15, Alban Hertroys () > escribió: > >> >> > On 10 Oct 2019, at 17:55, Yessica Brinkmann < >> yessica.brinkm...@gmail.com> wrote: >> > >> > I really thought a lot, but I don't understand why but the function >> fails after the expression is executed: >> > appendStringInfo (& cols, "% s a.attnum =% d", (i> 0? "OR": ""), >> idxcd-> varattno [i]); >> > The error appears only to me when entering the cycle: >> > foreach (cell, candidates) / * foreach cell in candidates * / >> > more than once, that is, when you have more than one candidate index. >> If the cycle is entered only once, the function works correctly. >> > The error that appears to me is that the connection to the PostgreSQL >> server is directly lost. I proved that the error occurs in that statement, >> printing some values. >> >> There is probably an error in the Postgres log-file providing you more >> info. >> >> That said, at least the below bit in your code is dangerous: >> >> foreach( cell, candidates ) /* foreach cell in candidates */ >> { >> >> idxcd = (IndexCandidate*)lfirst( cell ); >> >> if( !idxcd->idxused ) >> continue; >> >> if (idxcd!=NULL) >> { >> >> >> You should at least check for NULL before referencing an attribute of >> that structure. Personally, I would invert the test like so (and then move >> it before the idxused test: >> >> if (idxcd == NULL) { >> elog( INFO, "idxcd IS NULL" ); >> continue; /* Or is that fatal enough to break instead? */ >> ) >> >> if (!idxcd->idxused) >> continue; >> >> >> >> Alban Hertroys >> -- >> There is always an exception to always. >> >> >> >> >>
I think that my data is saved correctly, but when printing again, other data appears
Good day, I am doing a thesis from the University. My thesis is the modification of the Gurjeet Index Adviser, to add some features. I have a function called get_columnnames, which runs on a Postgresql server and returns the names of the columns of a table in a Postgresql database. In the first foreach, in the statement: idxcd-> varattnames [cont] = data; column names are saved. Those column names are saved correctly. I could verify this by printing some values. But later, in the following foreach, when I reprint the values of the names of the columns that had been saved in the idxcd-> varattnames [cont] = data statement; They appear to me with errors. That is, for example: if a and b were saved, then print me b and b. This occurs only when foreach is entered more than once, that is, when there is more than one candidate index. The truth is that I thought a lot why this can happen but I can't find an answer. I will greatly appreciate an answer please. The line with emphasis (* *) is the one that produces the wrong result. I clarify that the foreach cycle for the c language is defined in #include "nodes / pg_list.h" I am using Postgresql 8.3.23. I clarify that I use that version because it is compatible with the Index Adviser, which I am modifying for my University thesis. The Linux distribution I use is Debian 9.x 64-bit. And the version of C (gcc) that I use is 6.3.0 I attach my source code. Best regards, Yessica Brinkmann funcion.c Description: Binary data
Re: I think that my data is saved correctly, but when printing again, other data appears
Thank you so much for your answer. I will be testing the indicated and then I give you return.Best regards,Yessica Brinkmann Mensaje original Asunto: Re: I think that my data is saved correctly, but when printing again, other data appearsDe: Tom Lane Para: Yessica Brinkmann CC: pgsql-general@lists.postgresql.orgYessica Brinkmann writes:> I have a function called get_columnnames, which runs on a Postgresql server> and returns the names of the columns of a table in a Postgresql database.> In the first foreach, in the statement: idxcd-> varattnames [cont] = data;> column names are saved. Those column names are saved correctly. I could> verify this by printing some values.> But later, in the following foreach, when I reprint the values of the names> of the columns that had been saved in the idxcd-> varattnames [cont] = data> statement; They appear to me with errors.Yeah, because the "data" value is just a pointer into the tupdescassociated with the SPI result, and that disappears the moment youdo SPI_finish(). You'd need to do something to copy the stringsinto a longer-lived context. A plain pstrdup() won't sufficebecause you're in a short-lived SPI context already inside thatloop; but you could save CurrentMemoryContext before starting upSPI and then use MemoryContextStrdup. regards, tom lane
Re: I think that my data is saved correctly, but when printing again, other data appears
Good evening, sorry for the delay in answering. I have a part-time job and I was at it. I understand what you tell me about the "data" value is just a pointer into the tupdesc associated with the SPI result, and that disappears the moment I do SPI_finish (). What I do not understand well is how to use CurrentMemoryContext and MemoryContextStrdup, since there are not many examples of using them on the Internet (most are only definitions) and it is the first time I have heard of this, although I already understand this part now of contexts, because I was reading on the subject. Could you please give me an example of use? Best Regards, Yessica Brinkmann El vie., 25 oct. 2019 a las 12:24, Yessica Brinkmann (< yessica.brinkm...@gmail.com>) escribió: > Thank you so much for your answer. I will be testing the indicated and > then I give you return. > Best regards, > > Yessica Brinkmann > > > Mensaje original > Asunto: Re: I think that my data is saved correctly, but when printing > again, other data appears > De: Tom Lane > Para: Yessica Brinkmann > CC: pgsql-general@lists.postgresql.org > > > Yessica Brinkmann writes: > > I have a function called get_columnnames, which runs on a Postgresql > server > > and returns the names of the columns of a table in a Postgresql database. > > In the first foreach, in the statement: idxcd-> varattnames [cont] = > data; > > column names are saved. Those column names are saved correctly. I could > > verify this by printing some values. > > But later, in the following foreach, when I reprint the values of the > names > > of the columns that had been saved in the idxcd-> varattnames [cont] = > data > > statement; They appear to me with errors. > > Yeah, because the "data" value is just a pointer into the tupdesc > associated with the SPI result, and that disappears the moment you > do SPI_finish(). You'd need to do something to copy the strings > into a longer-lived context. A plain pstrdup() won't suffice > because you're in a short-lived SPI context already inside that > loop; but you could save CurrentMemoryContext before starting up > SPI and then use MemoryContextStrdup. > > regards, tom lane > >
Re: I think that my data is saved correctly, but when printing again, other data appears
Or if you know any link to a website where to find an example of this, I will thank you very much, please. Best regards, Yessica Brinkmann El vie., 25 oct. 2019 a las 22:06, Yessica Brinkmann (< yessica.brinkm...@gmail.com>) escribió: > Good evening, sorry for the delay in answering. I have a part-time job and > I was at it. > I understand what you tell me about the "data" value is just a pointer > into the tupdesc associated with the SPI result, and that disappears the > moment I do SPI_finish (). > What I do not understand well is how to use CurrentMemoryContext and > MemoryContextStrdup, since there are not many examples of using them on the > Internet (most are only definitions) and it is the first time I have heard > of this, although I already understand this part now of contexts, because I > was reading on the subject. > Could you please give me an example of use? > Best Regards, > Yessica Brinkmann > > El vie., 25 oct. 2019 a las 12:24, Yessica Brinkmann (< > yessica.brinkm...@gmail.com>) escribió: > >> Thank you so much for your answer. I will be testing the indicated and >> then I give you return. >> Best regards, >> >> Yessica Brinkmann >> >> >> Mensaje original >> Asunto: Re: I think that my data is saved correctly, but when printing >> again, other data appears >> De: Tom Lane >> Para: Yessica Brinkmann >> CC: pgsql-general@lists.postgresql.org >> >> >> Yessica Brinkmann writes: >> > I have a function called get_columnnames, which runs on a Postgresql >> server >> > and returns the names of the columns of a table in a Postgresql >> database. >> > In the first foreach, in the statement: idxcd-> varattnames [cont] = >> data; >> > column names are saved. Those column names are saved correctly. I could >> > verify this by printing some values. >> > But later, in the following foreach, when I reprint the values of the >> names >> > of the columns that had been saved in the idxcd-> varattnames [cont] = >> data >> > statement; They appear to me with errors. >> >> Yeah, because the "data" value is just a pointer into the tupdesc >> associated with the SPI result, and that disappears the moment you >> do SPI_finish(). You'd need to do something to copy the strings >> into a longer-lived context. A plain pstrdup() won't suffice >> because you're in a short-lived SPI context already inside that >> loop; but you could save CurrentMemoryContext before starting up >> SPI and then use MemoryContextStrdup. >> >> regards, tom lane >> >>
Re: I think that my data is saved correctly, but when printing again, other data appears
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. Regards, Yessica Brinkmann El dom., 27 oct. 2019 a las 19:42, Jony Cohen () escribió: > Hi, > Worked on something similar a few years back, have a look - it might give > you a few pointers :) > It's on similar lines to what you are looking at (I kept it updated up to > PG version 9.4/9.5) > https://github.com/cohenjo/pg_idx_advisor > > My main focus was to add support for more index types: partial, > functional, CTE, composites etc... > (I also had to keep the original context to restore it - so I think you > will find a sample to what you are looking for... ) > > there's also https://github.com/HypoPG/hypopg which is > actively maintained. > I think you will find code samples even up to the latest versions here... > > Regards, > - Jony > > On Sat, Oct 26, 2019 at 4:06 AM Yessica Brinkmann < > yessica.brinkm...@gmail.com> wrote: > >> Good evening, sorry for the delay in answering. I have a part-time job >> and I was at it. >> I understand what you tell me about the "data" value is just a pointer >> into the tupdesc associated with the SPI result, and that disappears the >> moment I do SPI_finish (). >> What I do not understand well is how to use CurrentMemoryContext and >> MemoryContextStrdup, since there are not many examples of using them on the >> Internet (most are only definitions) and it is the first time I have heard >> of this, although I already understand this part now of contexts, because I >> was reading on the subject. >> Could you please give me an example of use? >> Best Regards, >> Yessica Brinkmann >> >> El vie., 25 oct. 2019 a las 12:24, Yessica Brinkmann (< >> yessica.brinkm...@gmail.com>) escribió: >> >>> Thank you so much for your answer. I will be testing the indicated and >>> then I give you return. >>> Best regards, >>> >>> Yessica Brinkmann >>> >>> >>> Mensaje original >>> Asunto: Re: I think that my data is saved correctly, but when printing >>> again, other data appears >>> De: Tom Lane >>> Para: Yessica Brinkmann >>> CC: pgsql-general@lists.postgresql.org >>> >>> >>> Yessica Brinkmann writes: >>> > I have a function called get_columnnames, which runs on a Postgresql >>> server >>> > and returns the names of the columns of a table in a Postgresql >>> database. >>> > In the first foreach, in the statement: idxcd-> varattnames [cont] = >>> data; >>> > column names are saved. Those column names are saved correctly. I could >>> > verify this by printing some values. >>> > But later, in the following foreach, when I reprint the values of the >>> names >>> > of the columns that had been saved in the idxcd-> varattnames [cont] = >>> data >>> > statement; They appear to me with errors. >>> >>> Yeah, because the "data" value is just a pointer into the tupdesc >>> associated with the SPI result, and that disappears the moment you >>> do SPI_finish(). You'd need to do something to copy the strings >>> into a longer-lived context. A plain pstrdup() won't suffice >>> because you're in a short-lived SPI context already inside that >>> loop; but you could save CurrentMemoryContext before starting up >>> SPI and then use MemoryContextStrdup. >>> >>> regards, tom lane >>> >>>
Re: I think that my data is saved correctly, but when printing again, other data appears
Thank you very much for the answer. Best regards, Yessica Brinkmann El lun., 28 oct. 2019 a las 8:03, Joe Conway () 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 > >
Re: I think that my data is saved correctly, but when printing again, other data appears
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.brinkm...@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 () > 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 >> >>
Re: I think that my data is saved correctly, but when printing again, other data appears
I understand. Thank you very much for clearing things up. It helps me a lot, especially point 3. "3. When you run SPI_connect () the memory context is switched transparently for you to a special SPI memory context. When you run SPI_finish () the original memory context (the one in effect before SPI_connect) is restored. " Best regards, Yessica Brinkmann El mar., 26 nov. 2019 a las 15:25, Joe Conway () escribió: > On 11/25/19 4:38 PM, Yessica Brinkmann wrote: > > 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. > Sorry but I am not going to try to address that wall of text ;-) > But here is some general information about how that stuff works: > - > 1. The most common pattern is something like this: > >MemoryContext oldcontext; > >oldcontext = MemoryContextSwitchTo(); > >/* do stuff that allocates memory > * using PostgreSQL allocation functions > * e.g. palloc, pstrdup, other exported > * backend functions, etc > */ > >MemoryContextSwitchTo(oldcontext); > > 2. MemoryContextStrdup() is similar to the above, except in that case >you do not need MemoryContextSwitchTo(). It directly allocates into >the specified memory context without all the switching back and >forth. If you are simply copying one string and need it in a context >other than what is current, it is more convenient. But either method >could be used. > > 3. When you run SPI_connect() the memory context is switched >transparently for you to a special SPI memory context. When you run >SPI_finish() the original memory context (the one in effect before >SPI_connect) is restored. > > 4. Depending on what you are trying to do, use method #1 or method #2 if >needed, including while doing SPI related things (in between >SPI_connect and SPI_finish) > > Joe > > -- > Crunchy Data - http://crunchydata.com > PostgreSQL Support for Secure Enterprises > Consulting, Training, & Open Source Development > >
Problems with MemoryContextSwitchTo ()
Hello. I think several of you will already remember me. I'm the one with the IndexAdviser topic. Only that I changed my email address. As you may recall, I am doing my thesis on the subject of IndexAdviser modifications. I really appreciate the help they have given me in various Postgresql groups. Well, I was really nearing the end of the programming part of the thesis, when I had a problem to be able to compile my program in a moment, and by accident some lines of source code were moved. And for this reason, I think I have problems again with the context switch issue, since at some point my context switch stopped working for me, I think because of the issue that some lines of source code were moved. Well, the fact is that I have a function called get_columnnames, which in the second foreach, is printing the values of idxcd-> varattnnames [i] the null value. This second foreach, I only do it to test if the data is really saved well and if I can recover it properly. And since the data is not retrieved properly, or is not saved properly, in the following functions of my program, the value of idxcd-> varattnnames [i] continues to appear as null. I will appreciate a lot please help, if you can tell me please why the function prints null in the values of idxcd-> varattnnames [i], in the second foreach, if it is due to an error in the context switch, or why it could be . I send my function as an attachment. Best regards, Yessica Brinkmann. static List* get_columnnames( List* candidates ) { int proc; int ret; StringInfoData query; /* string for Query */ StringInfoData cols; /* string for Columns */ MemoryContext outerContext; ListCell*cell; IndexCandidate* idxcd; elog( DEBUG3, "IND ADV: get_column_names: ENTER" ); initStringInfo( &query ); initStringInfo( &cols ); foreach( cell, candidates ) /* foreach cell in candidates */ { int i; /*elog (INFO, "Ingresando a foreach");*/ idxcd = (IndexCandidate*)lfirst( cell ); if (idxcd == NULL) { elog( INFO, "idxcd IS NULL" ); continue; /* Or is that fatal enough to break instead? */ } if (!idxcd->idxused) continue; /* pfree() the memory allocated for the previous candidate. FIXME: Avoid * meddling with the internals of a StringInfo, and try to use an API. */ if( cols.len > 0 ) { initStringInfo(&cols); } /*IF col.len>0*/ if( query.len > 0 ) { initStringInfo(&query); } /*IF col.len>0*/ elog(INFO,"reloid:%d", idxcd->reloid); appendStringInfo( &query, "select a.attname from pg_class c,pg_attribute a where c.oid=%d AND a.attrelid = c.oid AND (", idxcd->reloid); /*elog(INFO,"QUERY:%s", query.data);*/ /*elog(INFO,"ncols:%d", idxcd->ncols);*/ for (i = 0; i < idxcd->ncols; ++i) { /*elog(INFO,"i:%d", i);*/ /*elog(INFO,"var attno i:%d", idxcd->varattno[i]);*/ /*elog(INFO,"cols:%s", cols.data);*/ appendStringInfo( &cols, "%s a.attnum=%d", (i>0 ? " OR" : ""), idxcd->varattno[i]); /*elog(INFO,"cols:%s", cols.data);*/ /*elog(INFO,"i:%d", i);*/ elog(INFO,"varattno i:%d", idxcd->varattno[i]); }/* foreach col in varattno*/ /*elog(INFO,"PASA EL FOR");*/ appendStringInfo( &cols, "%s", ")"); /* FIXME: Mention the column names explicitly after the table name. */ appendStringInfo( &query, "%s;", cols.data); elog(INFO,"QUERY:%s", query.data); /*elog(INFO,"LONGITUD:%d", query.le
Re: Problems with MemoryContextSwitchTo ()
Good Morning. I will greatly appreciate a help please on this subject. I actually did several tests already and tried a lot to fix it myself. But I am not able to. And I really need to know this in order to finish my university thesis. If someone can help me please. Best regards, Yessica Brinkmann El mié., 16 sept. 2020 a las 0:42, Yessica Brinkmann (< brinkmann.yess...@gmail.com>) escribió: > > > Hello. > I think several of you will already remember me. I'm the one with the > IndexAdviser topic. Only that I changed my email address. > As you may recall, I am doing my thesis on the subject of IndexAdviser > modifications. > I really appreciate the help they have given me in various Postgresql > groups. > Well, I was really nearing the end of the programming part of the thesis, > when I had a problem to be able to compile my program in a moment, and by > accident some lines of source code were moved. > And for this reason, I think I have problems again with the context switch > issue, since at some point my context switch stopped working for me, I > think because of the issue that some lines of source code were moved. > Well, the fact is that I have a function called get_columnnames, which in > the second foreach, is printing the values of idxcd-> varattnnames [i] the > null value. > This second foreach, I only do it to test if the data is really saved well > and if I can recover it properly. > And since the data is not retrieved properly, or is not saved properly, in > the following functions of my program, the value of idxcd-> varattnnames > [i] continues to appear as null. > I will appreciate a lot please help, if you can tell me please why the > function prints null in the values of idxcd-> varattnnames [i], in the > second foreach, if it is due to an error in the context switch, or why it > could be . > > I send my function as an attachment. > > > Best regards, > Yessica Brinkmann. >
Re: Problems with MemoryContextSwitchTo ()
Good Morning.I will greatly appreciate a help please on this subject.I actually did several tests already and tried a lot to fix it myself. But I am not able to. And I really need to know this in order to finish my university thesis. If someone can help me please.Best regards,Yessica Brinkmann Mensaje original Asunto: Problems with MemoryContextSwitchTo ()De: Yessica Brinkmann Para: pgsql-general@lists.postgresql.orgCC: Hello. I think several of you will already remember me. I'm the one with the IndexAdviser topic. Only that I changed my email address. As you may recall, I am doing my thesis on the subject of IndexAdviser modifications. I really appreciate the help they have given me in various Postgresql groups. Well, I was really nearing the end of the programming part of the thesis, when I had a problem to be able to compile my program in a moment, and by accident some lines of source code were moved. And for this reason, I think I have problems again with the context switch issue, since at some point my context switch stopped working for me, I think because of the issue that some lines of source code were moved. Well, the fact is that I have a function called get_columnnames, which in the second foreach, is printing the values of idxcd-> varattnnames [i] the null value. This second foreach, I only do it to test if the data is really saved well and if I can recover it properly. And since the data is not retrieved properly, or is not saved properly, in the following functions of my program, the value of idxcd-> varattnnames [i] continues to appear as null. I will appreciate a lot please help, if you can tell me please why the function prints null in the values of idxcd-> varattnnames [i], in the second foreach, if it is due to an error in the context switch, or why it could be . I send my function as an attachment. Best regards, Yessica Brinkmann.
Re: Problems with MemoryContextSwitchTo ()
Well, the fact is that I have a function called get_columnnames, which in the second foreach, is printing the values of idxcd-> varattnnames [i] the null value. This is the error. Mensaje original Asunto: Re: Problems with MemoryContextSwitchTo ()De: Pavel Stehule Para: Yessica Brinkmann CC: pgsql-general st 16. 9. 2020 v 13:32 odesílatel Yessica Brinkmann <brinkmann.yess...@gmail.com> napsal: Good Morning.I will greatly appreciate a help please on this subject. I actually did several tests already and tried a lot to fix it myself. But I am not able to. And I really need to know this in order to finish my university thesis. If someone can help me please.Best regards,Yessica Brinkmannplease, can you attach your code, and can you show the error message? It is hard to say what is the problem from your mail?RegardsPavel El mié., 16 sept. 2020 a las 0:42, Yessica Brinkmann (<brinkmann.yess...@gmail.com>) escribió: Hello. I think several of you will already remember me. I'm the one with the IndexAdviser topic. Only that I changed my email address. As you may recall, I am doing my thesis on the subject of IndexAdviser modifications. I really appreciate the help they have given me in various Postgresql groups. Well, I was really nearing the end of the programming part of the thesis, when I had a problem to be able to compile my program in a moment, and by accident some lines of source code were moved. And for this reason, I think I have problems again with the context switch issue, since at some point my context switch stopped working for me, I think because of the issue that some lines of source code were moved. Well, the fact is that I have a function called get_columnnames, which in the second foreach, is printing the values of idxcd-> varattnnames [i] the null value. This second foreach, I only do it to test if the data is really saved well and if I can recover it properly. And since the data is not retrieved properly, or is not saved properly, in the following functions of my program, the value of idxcd-> varattnnames [i] continues to appear as null. I will appreciate a lot please help, if you can tell me please why the function prints null in the values of idxcd-> varattnnames [i], in the second foreach, if it is due to an error in the context switch, or why it could be . I send my function as an attachment. Best regards, Yessica Brinkmann. static List* get_columnnames( List* candidates ) { int proc; int ret; StringInfoData query; /* string for Query */ StringInfoData cols; /* string for Columns */ MemoryContext outerContext; ListCell*cell; IndexCandidate* idxcd; elog( DEBUG3, "IND ADV: get_column_names: ENTER" ); initStringInfo( &query ); initStringInfo( &cols ); foreach( cell, candidates ) /* foreach cell in candidates */ { int i; /*elog (INFO, "Ingresando a foreach");*/ idxcd = (IndexCandidate*)lfirst( cell ); if (idxcd == NULL) { elog( INFO, "idxcd IS NULL" ); continue; /* Or is that fatal enough to break instead? */ } if (!idxcd->idxused) continue; /* pfree() the memory allocated for the previous candidate. FIXME: Avoid * meddling with the internals of a StringInfo, and try to use an API. */ if( cols.len > 0 ) { initStringInfo(&cols); } /*IF col.len>0*/ if( query.len > 0 ) { initStringInfo(&query); } /*IF col.len>0*/ elog(INFO,"reloid:%d", idxcd->reloid); appendStringInfo( &query, "select a.attname from pg_class c,pg_attribute a where c.oid=%d AND a.attrelid = c.oid AND (", idxcd->reloid); /*elog(INFO,"QUERY:%s", query.data);*/ /*elog(INFO,"ncols:%d", idxcd->ncols);*/ for (i = 0; i < idxcd->ncols; ++i) { /*elog(INFO,"i:%d", i);*/ /*elog(INFO,"var attno i:%d", idxcd->varattno[i]);*/
Re: Problems with MemoryContextSwitchTo ()
Good night, Thank you very much for the answer. Excuse me please just answered, I was at my job. And yes, I get the results of the list with SPI_exec. And I am also using SPI_finish (). But I save the results of the previous query in the array idxcd-> varattnnames. And in the second foreach it should print me the values that I got in the query, since I print the values of idxcd-> varattnnames, but it is printing null. And I think the memory context switch is fine too, so I really don't know why it prints null to me. I will greatly appreciate a help please. I can't really understand why it prints null in the second foreach, even though I already tried various changes. Best regards, Yessica Brinkmann El mié., 16 sept. 2020 a las 9:16, Pavel Stehule () escribió: > > > st 16. 9. 2020 v 15:09 odesílatel Yessica Brinkmann < > brinkmann.yess...@gmail.com> napsal: > >> Well, the fact is that I have a function called get_columnnames, which in >> the second foreach, is printing the values of idxcd-> varattnnames [i] the >> null value. This is the error. > > > How you get this list? It is result of SPI_exec*** ? > > There is SPI_finish(), that cleaning a memory used by SPI interface, and > theoretically it can clean result of previous query. > > Regards > > Pavel > > >> >> Mensaje original >> Asunto: Re: Problems with MemoryContextSwitchTo () >> De: Pavel Stehule >> Para: Yessica Brinkmann >> CC: pgsql-general >> >> >> >> >> st 16. 9. 2020 v 13:32 odesílatel Yessica Brinkmann < >> brinkmann.yess...@gmail.com> napsal: >> >>> Good Morning. >>> I will greatly appreciate a help please on this subject. I actually did >>> several tests already and tried a lot to fix it myself. But I am not >>> able to. And I really need to know this in order to finish my >>> university thesis. If someone can help me please. >>> Best regards, >>> Yessica Brinkmann >>> >> >> please, can you attach your code, and can you show the error message? >> >> It is hard to say what is the problem from your mail? >> >> Regards >> >> Pavel >> >> >> >>> >>> El mié., 16 sept. 2020 a las 0:42, Yessica Brinkmann (< >>> brinkmann.yess...@gmail.com>) escribió: >>> >>>> >>>> >>>> Hello. >>>> I think several of you will already remember me. I'm the one with the >>>> IndexAdviser topic. Only that I changed my email address. >>>> As you may recall, I am doing my thesis on the subject of IndexAdviser >>>> modifications. >>>> I really appreciate the help they have given me in various Postgresql >>>> groups. >>>> Well, I was really nearing the end of the programming part of the >>>> thesis, when I had a problem to be able to compile my program in a moment, >>>> and by accident some lines of source code were moved. >>>> And for this reason, I think I have problems again with the context >>>> switch issue, since at some point my context switch stopped working for me, >>>> I think because of the issue that some lines of source code were moved. >>>> Well, the fact is that I have a function called get_columnnames, which >>>> in the second foreach, is printing the values of idxcd-> varattnnames [i] >>>> the null value. >>>> This second foreach, I only do it to test if the data is really saved >>>> well and if I can recover it properly. >>>> And since the data is not retrieved properly, or is not saved properly, >>>> in the following functions of my program, the value of idxcd-> varattnnames >>>> [i] continues to appear as null. >>>> I will appreciate a lot please help, if you can tell me please why the >>>> function prints null in the values of idxcd-> varattnnames [i], in the >>>> second foreach, if it is due to an error in the context switch, or why it >>>> could be . >>>> >>>> I send my function as an attachment. >>>> >>>> >>>> Best regards, >>>> Yessica Brinkmann. >>>> >>>
Re: Problems with MemoryContextSwitchTo ()
Good Morning. Thank you so much for the answers. Now I have to go to work, but when I come back I will be looking at the answers in detail, and I will answer. Unfortunately I have to work and study as well, so right now I can't see the answers in detail.Best regards,Yessica Brinkmann. Mensaje original Asunto: Re: Problems with MemoryContextSwitchTo ()De: Pavel Stehule Para: Yessica Brinkmann CC: pgsql-general čt 17. 9. 2020 v 6:09 odesílatel Pavel Stehule <pavel.steh...@gmail.com> napsal:čt 17. 9. 2020 v 3:16 odesílatel Yessica Brinkmann <brinkmann.yess...@gmail.com> napsal: Good night,Thank you very much for the answer.Excuse me please just answered, I was at my job.And yes, I get the results of the list with SPI_exec.And I am also using SPI_finish (). But I save the results of the previous query in the array idxcd-> varattnnames.And in the second foreach it should print me the values that I got in the query, since I print the values of idxcd-> varattnnames, but it is printing null.And I think the memory context switch is fine too, so I really don't know why it prints null to me.I will greatly appreciate a help please. I can't really understand why it prints null in the second foreach, even though I already tried various changes.do you use Postgres with active assertions ?postgres=# show debug_assertions ;┌──┐│ debug_assertions │╞══╡│ on │└──┘(1 row)maybe you somewhere allocate less memory then it is necessary and some memset rewrites memory with your data. When you have a problem with memory, then you should to very carefully check a) if memory is allocated in good context, b) if memory was allocated enough (sometimes I just allocated x + 10 for testing).Can you write a reproducer ? code that I can check at my home. Postgres is pretty complex system, and it is hard to fix some issue without access to codeThis is some messy in your codeMemoryContext oldContext = MemoryContextSwitchTo( outerContext ); MemoryContextSwitchTo( oldContext ); Unfortunately, your code is not well structured - it is hard to read it. One hint - if you find an issue - try to reduce lines of your code which is possible until you reproduce this issue or until you understand this issue.The sequence of statements is a little bit obscure :)initStringInfo( &query ); */ if( cols.len > 0 ) {initStringInfo(&cols); } /*IF col.len>0*/Instead foreach( cell, candidates ) /* foreach cell in candidates */ {int i; /*elog (INFO, "Ingresando a foreach");*/ idxcd = (IndexCandidate*)lfirst( cell );if (idxcd == NULL) { elog( INFO, "idxcd IS NULL" ); continue; /* Or is that fatal enough to break instead? */ }you can writeidxcd = (IndexCandidate *) linitial(candidates);The problem in your example is fact so it is a mix of copy/paste fragments. I wrote similar code, and almost everyone I know (when I started). But it is not possible to fix this code - start from scratch. The code must be readable (every time). And when I write code inside some complex environment (like Postgres is), I write code in very small fragments, in very small steps, and every time I try to compile, restart and check the result. Then I know what line, or what statement is the problem. RegardsPavelBest regards,Yessica Brinkmann El mié., 16 sept. 2020 a las 9:16, Pavel Stehule (<pavel.steh...@gmail.com>) escribió:st 16. 9. 2020 v 15:09 odesílatel Yessica Brinkmann <brinkmann.yess...@gmail.com> napsal:Well, the fact is that I have a function called get_columnnames, which in the second foreach, is printing the values of idxcd-> varattnnames [i] the null value. This is the error. How you get this list? It is result of SPI_exec*** ?There is SPI_finish(), that cleaning a memory used by SPI interface, and theoretically it can clean result of previous query.RegardsPavel Mensaje original ----Asunto: Re: Problems with MemoryContextSwitchTo ()De: Pavel Stehule Para: Yessica Brinkmann CC: pgsql-general st 16. 9. 2020 v 13:32 odesílatel Yessica Brinkmann <brinkmann.yess...@gmail.com> napsal: Good Morning.I will greatly appreciate a help please on this subject. I actually did several tests already and tried a lot to fix it myself. But I am not able to. And I really need to know this in order to finish my university thesis. If someone can help me please.Best regards,Yessica Brinkmannplease, can you attach your code, and can you show the error message? It is hard to say what is the problem from your mail?RegardsPavel El mié., 16 sept. 2020 a las 0:42, Yessica Brinkmann (<brinkmann.yess...@gmail.com>) escribió: Hello. I think several of you will already remember me. I'm the one with the IndexAdviser topic. Only that I changed my email address. As you may recall, I am doing my thesis on the subject of IndexAdviser modifications.
Re: Problems with MemoryContextSwitchTo ()
Thank you very much for the answers, and for the advice given. I will try to put them into practice. Best regards, Yessica Brinkmann El jue., 17 sept. 2020 a las 6:46, Yessica Brinkmann (< brinkmann.yess...@gmail.com>) escribió: > > > Good Morning. Thank you so much for the answers. Now I have to go to work, > but when I come back I will be looking at the answers in detail, and I will > answer. Unfortunately I have to work and study as well, so right now I > can't see the answers in detail. > Best regards, > Yessica Brinkmann. > > > Mensaje original > Asunto: Re: Problems with MemoryContextSwitchTo () > De: Pavel Stehule > Para: Yessica Brinkmann > CC: pgsql-general > > > > > čt 17. 9. 2020 v 6:09 odesílatel Pavel Stehule > napsal: > >> >> >> čt 17. 9. 2020 v 3:16 odesílatel Yessica Brinkmann < >> brinkmann.yess...@gmail.com> napsal: >> >>> Good night, >>> Thank you very much for the answer. >>> Excuse me please just answered, I was at my job. >>> And yes, I get the results of the list with SPI_exec. >>> And I am also using SPI_finish (). But I save the results of the >>> previous query in the array idxcd-> varattnnames. >>> And in the second foreach it should print me the values that I got in >>> the query, since I print the values of idxcd-> varattnnames, but it is >>> printing null. >>> And I think the memory context switch is fine too, so I really don't >>> know why it prints null to me. >>> I will greatly appreciate a help please. I can't really understand why >>> it prints null in the second foreach, even though I already tried various >>> changes. >>> >> >> do you use Postgres with active assertions ? >> >> postgres=# show debug_assertions ; >> ┌──┐ >> │ debug_assertions │ >> ╞══╡ >> │ on │ >> └──┘ >> (1 row) >> >> maybe you somewhere allocate less memory then it is necessary and some >> memset rewrites memory with your data. When you have a problem with memory, >> then you should to very carefully check a) if memory is allocated in good >> context, b) if memory was allocated enough (sometimes I just allocated x + >> 10 for testing). >> >> Can you write a reproducer ? code that I can check at my home. Postgres >> is pretty complex system, and it is hard to fix some issue without access >> to code >> >> > This is some messy in your code > > MemoryContext oldContext = MemoryContextSwitchTo( outerContext ); > MemoryContextSwitchTo( oldContext ); > > Unfortunately, your code is not well structured - it is hard to read it. > One hint - if you find an issue - try to reduce lines of your code which is > possible until you reproduce this issue or until you understand this issue. > > The sequence of statements is a little bit obscure :) > > initStringInfo( &query ); > > */ > if( cols.len > 0 ) > { > initStringInfo(&cols); > } /*IF col.len>0*/ > > Instead > > foreach( cell, candidates ) /* foreach cell in candidates */ > { > > int i; > > > >/*elog (INFO, "Ingresando a foreach");*/ > idxcd = (IndexCandidate*)lfirst( cell ); > > if (idxcd == NULL) { > elog( INFO, "idxcd IS NULL" ); > continue; /* Or is that fatal enough to break instead? */ > } > > > you can write > > idxcd = (IndexCandidate *) linitial(candidates); > > The problem in your example is fact so it is a mix of copy/paste > fragments. I wrote similar code, and almost everyone I know (when I > started). But it is not possible to fix this code - start from scratch. The > code must be readable (every time). And when I write code inside some > complex environment (like Postgres is), I write code in very small > fragments, in very small steps, and every time I try to compile, restart > and check the result. Then I know what line, or what statement is the > problem. > > Regards > > Pavel > > > > > > >> >> >> >> >> >> >> Best regards, >>> Yessica Brinkmann >>> >>> El mié., 16 sept. 2020 a las 9:16, Pavel Stehule (< >>> pavel.steh...@gmail.com>) escribió: >>> >>>> >>>> >>>> st 16. 9. 2020 v 15:09 odesílatel Yessica Brinkmann < >>>> brinkmann.yess...@gmail.com> napsal: >>>> >>>>> Well, the fact is that I have a function called get_columnnames, which >>>&g
Re: Problems with MemoryContextSwitchTo ()
I already discovered the problem, it was only a counter initialization issue, it had nothing to do with memory contexts, that part was fine. Thank God I could already understand the problem and solve it. Anyway thank you very much. Best regards, Yessica Brinkmann El jue., 17 sept. 2020 a las 22:26, Yessica Brinkmann (< brinkmann.yess...@gmail.com>) escribió: > Thank you very much for the answers, and for the advice given. I will try > to put them into practice. > Best regards, > Yessica Brinkmann > > > El jue., 17 sept. 2020 a las 6:46, Yessica Brinkmann (< > brinkmann.yess...@gmail.com>) escribió: > >> >> >> Good Morning. Thank you so much for the answers. Now I have to go to >> work, but when I come back I will be looking at the answers in detail, and >> I will answer. Unfortunately I have to work and study as well, so right now >> I can't see the answers in detail. >> Best regards, >> Yessica Brinkmann. >> >> >> Mensaje original >> Asunto: Re: Problems with MemoryContextSwitchTo () >> De: Pavel Stehule >> Para: Yessica Brinkmann >> CC: pgsql-general >> >> >> >> >> čt 17. 9. 2020 v 6:09 odesílatel Pavel Stehule >> napsal: >> >>> >>> >>> čt 17. 9. 2020 v 3:16 odesílatel Yessica Brinkmann < >>> brinkmann.yess...@gmail.com> napsal: >>> >>>> Good night, >>>> Thank you very much for the answer. >>>> Excuse me please just answered, I was at my job. >>>> And yes, I get the results of the list with SPI_exec. >>>> And I am also using SPI_finish (). But I save the results of the >>>> previous query in the array idxcd-> varattnnames. >>>> And in the second foreach it should print me the values that I got in >>>> the query, since I print the values of idxcd-> varattnnames, but it is >>>> printing null. >>>> And I think the memory context switch is fine too, so I really don't >>>> know why it prints null to me. >>>> I will greatly appreciate a help please. I can't really understand why >>>> it prints null in the second foreach, even though I already tried various >>>> changes. >>>> >>> >>> do you use Postgres with active assertions ? >>> >>> postgres=# show debug_assertions ; >>> ┌──┐ >>> │ debug_assertions │ >>> ╞══╡ >>> │ on │ >>> └──┘ >>> (1 row) >>> >>> maybe you somewhere allocate less memory then it is necessary and some >>> memset rewrites memory with your data. When you have a problem with memory, >>> then you should to very carefully check a) if memory is allocated in good >>> context, b) if memory was allocated enough (sometimes I just allocated x + >>> 10 for testing). >>> >>> Can you write a reproducer ? code that I can check at my home. Postgres >>> is pretty complex system, and it is hard to fix some issue without access >>> to code >>> >>> >> This is some messy in your code >> >> MemoryContext oldContext = MemoryContextSwitchTo( outerContext ); >> MemoryContextSwitchTo( oldContext ); >> >> Unfortunately, your code is not well structured - it is hard to read it. >> One hint - if you find an issue - try to reduce lines of your code which is >> possible until you reproduce this issue or until you understand this issue. >> >> The sequence of statements is a little bit obscure :) >> >> initStringInfo( &query ); >> >> */ >> if( cols.len > 0 ) >> { >> initStringInfo(&cols); >> } /*IF col.len>0*/ >> >> Instead >> >> foreach( cell, candidates ) /* foreach cell in candidates */ >> { >> >> int i; >> >> >> >>/*elog (INFO, "Ingresando a foreach");*/ >> idxcd = (IndexCandidate*)lfirst( cell ); >> >> if (idxcd == NULL) { >> elog( INFO, "idxcd IS NULL" ); >> continue; /* Or is that fatal enough to break instead? */ >> } >> >> >> you can write >> >> idxcd = (IndexCandidate *) linitial(candidates); >> >> The problem in your example is fact so it is a mix of copy/paste >> fragments. I wrote similar code, and almost everyone I know (when I >> started). But it is not possible to fix this code - start from scratch. The >> code must be readable (every time). And when I write code inside some >
Gurjeet Singh Index Adviser User Interface
Goodnight, I would like to ask the following question: As some of you may recall, I was doing my university thesis as a modification of Gurjeet Singh's Index Adviser. Now I have finished the programming part. But I have the following problem: Gurjeet Singh's Index Adviser readme describes how to use an Index Adviser interface called pg_advise_index tool. The readme mentions the following: i) pg_advise_index tool. - Create a file that contains all the queries (semicolon terminated; may be multi-line) that are expected to be executed by the application; and feed this file to the pg_advise_index tool with appropriate options. pg_advise_index -d DB -h host -U user -s 10M -o advisory.sql workload.sql pg_advise_index will open a connection with the PostgreSQL server by setting appropriate session level options that will force the backend to load the pg_index_adviser plugin. It will then prepend the keywords EXPLAIN to each of the queries found in the workload file, and execute them against the backend. For each query EXPLAINed, the backend will generate advice for each index that might have been beneficial in executing these queries. At the end, pg_advise_index will enumerate all the indexes suggested for the current session, and output the CREATE INDEX statements for each of them. Optinally, if the -size option was specified, pg_advise_index will output suggestions for only those indexes, that fit into that size. -- To test my thesis, I need to use this interface pg_advise_index tool, but unfortunately I have not been able to use it yet. I would like to know if any of you have any experience testing or using this interface, or if you understand what the readme says anyway. In that case, please, can you help me. Now to test my thesis. I've actually already tried to run this interface pg_advise_index tool in various ways but haven't been able to. What I don't understand specifically is from which directory should I run the command pg_advise_index -d DB -h host -U user -s 10M -o advisory.sql workload.sql I will greatly appreciate any help, please. The Index Adviser readme link is as follows: https://github.com/gurjeet/pg_adviser/blob/master/index_adviser/README.index_adviser Best regards, Yessica Brinkmann
Re: Gurjeet Singh Index Adviser User Interface
I will greatly appreciate a help with this topic please. I really need to use that interface to be able to test my thesis. And I am not being able to use.Best regards,Yessica Brinkmann Mensaje original Asunto: Gurjeet Singh Index Adviser User InterfaceDe: Yessica Brinkmann Para: pgsql-general CC: Goodnight,I would like to ask the following question:As some of you may recall, I was doing my university thesis as a modification of Gurjeet Singh's Index Adviser.Now I have finished the programming part.But I have the following problem:Gurjeet Singh's Index Adviser readme describes how to use an Index Adviser interface called pg_advise_index tool.The readme mentions the following:i) pg_advise_index tool. -Create a file that contains all the queries (semicolon terminated; maybe multi-line) that are expected to be executed by the application; andfeed this file to the pg_advise_index tool with appropriate options.pg_advise_index -d DB -h host -U user -s 10M -o advisory.sql workload.sqlpg_advise_index will open a connection with the PostgreSQL server bysetting appropriate session level options that will force the backend to loadthe pg_index_adviser plugin. It will then prepend the keywords EXPLAIN to eachof the queries found in the workload file, and execute them against the backend.For each query EXPLAINed, the backend will generate advice for each index thatmight have been beneficial in executing these queries.At the end, pg_advise_index will enumerate all the indexes suggested forthe current session, and output the CREATE INDEX statements for each of them.Optinally, if the -size option was specified, pg_advise_index will output suggestionsfor only those indexes, that fit into that size.-- To test my thesis, I need to use this interface pg_advise_index tool, but unfortunately I have not been able to use it yet.I would like to know if any of you have any experience testing or using this interface, or if you understand what the readme says anyway.In that case, please, can you help me. Now to test my thesis.I've actually already tried to run this interface pg_advise_index tool in various ways but haven't been able to.What I don't understand specifically is from which directory should I run the commandpg_advise_index -d DB -h host -U user -s 10M -o advisory.sql workload.sqlI will greatly appreciate any help, please. The Index Adviser readme link is as follows: https://github.com/gurjeet/pg_adviser/blob/master/index_adviser/README.index_adviserBest regards, Yessica Brinkmann
Re: Gurjeet Singh Index Adviser User Interface
Goodnight, Thank you very much for the answer. I followed all the installation instructions: apply patch, compile install postgres, etc. I just tried everything with the UI ii) Manually (through psql session), which is also mentioned in the readme, and everything works for me. But to better test my thesis, I would also need to use the other user interface mentioned in the readme and that is precisely i) pg_advise_index tool. I understand what you are telling me about the directory. I will be testing this way. Many thanks. Best regards, Yessica brinkmann El mar., 29 sept. 2020 a las 18:21, Rob Sargent () escribió: > > > On 9/29/20 3:46 PM, Yessica Brinkmann wrote: > > I will greatly appreciate a help with this topic please. I really need > > to use that interface to be able to test my thesis. And I am not being > > able to use. > > Best regards, > > Yessica Brinkmann > > I didn't see any reported error messages in your post. > > And you followed all the installation instructions: apply patch, compile > install postgres, etc? Not for the faint of heart, to be sure. > > As presented > > pg_advise_index -d DB -h host -U user -s 10M -o advisory.sql workload.sql > > would need to be run in the directory containing advisory.sql and your > PATH would need to include the directory containing the > 'pg_advise_index' executable. > > > > > <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Libre de virus. www.avg.com <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
Re: Gurjeet Singh Index Adviser User Interface
Goodnight, I apologize please that today I was able to test the directory, since I had a health problem in recent days. Well, I actually found the files corresponding to the pg_advise_index interface. But I was surprised that the executable is not present, but apparently this interface must be compiled by another part of the index adviser, to be able to execute it. It has a Makefile. I tried to compile as follows, and I get the following errors: root@debian:/home/yessica/Descargas/postgresql-8.3.23/contrib/pg_adviser_master/pg_advise# USE_PGXS = 1 make You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application. make: *** There are no targets. High. root@debian:/home/yessica/Descargas/postgresql-8.3.23/contrib/pg_adviser_master/pg_advise# make install make: Nothing is done for 'install'. I will greatly appreciate a help please, regarding these errors that I got. The truth is that I honestly don't have much experience using Linux. Best regards, Yessica brinkmann <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Libre de virus. www.avg.com <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> El mar., 29 sept. 2020 a las 18:55, Yessica Brinkmann (< brinkmann.yess...@gmail.com>) escribió: > Goodnight, > Thank you very much for the answer. > I followed all the installation instructions: apply patch, compile > install postgres, etc. > I just tried everything with the UI ii) Manually (through psql session), > which is also mentioned in the readme, and everything works for me. But > to better test my thesis, I would also need to use the other user interface > mentioned in the readme and that is precisely i) pg_advise_index tool. > I understand what you are telling me about the directory. I will be > testing this way. > Many thanks. > Best regards, > Yessica brinkmann > > El mar., 29 sept. 2020 a las 18:21, Rob Sargent () > escribió: > >> >> >> On 9/29/20 3:46 PM, Yessica Brinkmann wrote: >> > I will greatly appreciate a help with this topic please. I really need >> > to use that interface to be able to test my thesis. And I am not being >> > able to use. >> > Best regards, >> > Yessica Brinkmann >> >> I didn't see any reported error messages in your post. >> >> And you followed all the installation instructions: apply patch, compile >> install postgres, etc? Not for the faint of heart, to be sure. >> >> As presented >> >> pg_advise_index -d DB -h host -U user -s 10M -o advisory.sql workload.sql >> >> would need to be run in the directory containing advisory.sql and your >> PATH would need to include the directory containing the >> 'pg_advise_index' executable. >> >> >> >> >> > > <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> > Libre > de virus. www.avg.com > <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> > <#m_-6212125912420465024_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> >
Re: Gurjeet Singh Index Adviser User Interface
I also clarify that I tried to install the libpq-dev package already but could not install it because it depends on a non-installable package called libss10.9.8. And I had to apply apt --fix-broken install to fix the problem. <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Libre de virus. www.avg.com <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> El jue., 8 oct. 2020 a las 22:08, Yessica Brinkmann (< brinkmann.yess...@gmail.com>) escribió: > Goodnight, > I apologize please that today I was able to test the directory, since I > had a health problem in recent days. > Well, I actually found the files corresponding to the pg_advise_index > interface. But I was surprised that the executable is not present, but > apparently this interface must be compiled by another part of the index > adviser, to be able to execute it. It has a Makefile. > I tried to compile as follows, and I get the following errors: > root@debian:/home/yessica/Descargas/postgresql-8.3.23/contrib/pg_adviser_master/pg_advise# > USE_PGXS = 1 make > You need to install postgresql-server-dev-X.Y for building a server-side > extension or libpq-dev for building a client-side application. > make: *** There are no targets. High. > root@debian:/home/yessica/Descargas/postgresql-8.3.23/contrib/pg_adviser_master/pg_advise# > make install > make: Nothing is done for 'install'. > I will greatly appreciate a help please, regarding these errors that I > got. The truth is that I honestly don't have much experience using Linux. > Best regards, > Yessica brinkmann > > > <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> > Libre > de virus. www.avg.com > <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> > <#m_-2818491497838977803_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> > > El mar., 29 sept. 2020 a las 18:55, Yessica Brinkmann (< > brinkmann.yess...@gmail.com>) escribió: > >> Goodnight, >> Thank you very much for the answer. >> I followed all the installation instructions: apply patch, compile >> install postgres, etc. >> I just tried everything with the UI ii) Manually (through psql session), >> which is also mentioned in the readme, and everything works for me. But >> to better test my thesis, I would also need to use the other user interface >> mentioned in the readme and that is precisely i) pg_advise_index tool. >> I understand what you are telling me about the directory. I will be >> testing this way. >> Many thanks. >> Best regards, >> Yessica brinkmann >> >> El mar., 29 sept. 2020 a las 18:21, Rob Sargent () >> escribió: >> >>> >>> >>> On 9/29/20 3:46 PM, Yessica Brinkmann wrote: >>> > I will greatly appreciate a help with this topic please. I really need >>> > to use that interface to be able to test my thesis. And I am not being >>> > able to use. >>> > Best regards, >>> > Yessica Brinkmann >>> >>> I didn't see any reported error messages in your post. >>> >>> And you followed all the installation instructions: apply patch, compile >>> install postgres, etc? Not for the faint of heart, to be sure. >>> >>> As presented >>> >>> pg_advise_index -d DB -h host -U user -s 10M -o advisory.sql workload.sql >>> >>> would need to be run in the directory containing advisory.sql and your >>> PATH would need to include the directory containing the >>> 'pg_advise_index' executable. >>> >>> >>> >>> >>> >> >> <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> >> Libre >> de virus. www.avg.com >> <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> >> <#m_-2818491497838977803_m_-6212125912420465024_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> >> >
Re: Gurjeet Singh Index Adviser User Interface
I will greatly appreciate a help please with this topic. I really need a lot to be able to use this interface to be able to test my thesis well. I really don't quite understand what installing postgresql-server-dev-X.Y refers to. And I really don't really know how to install it too. If you can give me a guide at least about this please? And in which version should I install it? I am using Postgresql 8.3.23, I really use this version because the Index Adviser only works with this version of Postgresql. And also I do not understand well if installing that already solves everything or should I install an additional package? Best regards, Yessica Brinkmann. <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Libre de virus. www.avg.com <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> El jue., 8 oct. 2020 a las 22:21, Yessica Brinkmann (< brinkmann.yess...@gmail.com>) escribió: > I also clarify that I tried to install the libpq-dev package already but > could not install it because it depends on a non-installable package called > libss10.9.8. And I had to apply apt --fix-broken install to fix the > problem. > > > <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> > Libre > de virus. www.avg.com > <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> > <#m_-9019273329787422367_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> > > El jue., 8 oct. 2020 a las 22:08, Yessica Brinkmann (< > brinkmann.yess...@gmail.com>) escribió: > >> Goodnight, >> I apologize please that today I was able to test the directory, since I >> had a health problem in recent days. >> Well, I actually found the files corresponding to the pg_advise_index >> interface. But I was surprised that the executable is not present, but >> apparently this interface must be compiled by another part of the index >> adviser, to be able to execute it. It has a Makefile. >> I tried to compile as follows, and I get the following errors: >> root@debian:/home/yessica/Descargas/postgresql-8.3.23/contrib/pg_adviser_master/pg_advise# >> USE_PGXS = 1 make >> You need to install postgresql-server-dev-X.Y for building a server-side >> extension or libpq-dev for building a client-side application. >> make: *** There are no targets. High. >> root@debian:/home/yessica/Descargas/postgresql-8.3.23/contrib/pg_adviser_master/pg_advise# >> make install >> make: Nothing is done for 'install'. >> I will greatly appreciate a help please, regarding these errors that I >> got. The truth is that I honestly don't have much experience using >> Linux. >> Best regards, >> Yessica brinkmann >> >> >> <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> >> Libre >> de virus. www.avg.com >> <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> >> <#m_-9019273329787422367_m_-2818491497838977803_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> >> >> El mar., 29 sept. 2020 a las 18:55, Yessica Brinkmann (< >> brinkmann.yess...@gmail.com>) escribió: >> >>> Goodnight, >>> Thank you very much for the answer. >>> I followed all the installation instructions: apply patch, compile >>> install postgres, etc. >>> I just tried everything with the UI ii) Manually (through psql session), >>> which is also mentioned in the readme, and everything works for me. But >>> to better test my thesis, I would also need to use the other user interface >>> mentioned in the readme and that is precisely i) pg_advise_index tool. >>> I understand what you are telling me about the directory. I will be >>> testing this way. >>> Many thanks. >>> Best regards, >>> Yessica brinkmann >>> >>> El mar., 29 sept. 2020 a las 18:21, Rob Sargent () >>> escribió: >>> >>>> >>>> >>>> On 9/29/20 3:46 PM, Yessica Brinkmann wrote: >>>> > I will greatly appreciate a help with this topic please. I really >>>> need >>>> > to use that interface to be able to test my thesis. And I am not >>>> being >>>> > able to use. >>>> > Best regards, >>>> > Yessica Brinkmann >>&
Re: Gurjeet Singh Index Adviser User Interface
Thank you very much for the answer. I will be trying to understand and test the indicated. Best regards, Yessica Brinkmann. <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Libre de virus. www.avg.com <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> El vie., 9 oct. 2020 a las 23:02, David G. Johnston (< david.g.johns...@gmail.com>) escribió: > On Fri, Oct 9, 2020 at 5:20 PM Yessica Brinkmann < > brinkmann.yess...@gmail.com> wrote: > >> I am using Postgresql 8.3.23, I really use this version because the Index >> Adviser only works with this version of Postgresql. >> > > I suggest first figuring out whether you are able to successfully install > the current PostgreSQL Server (git master branch) on a current Linux > release (if you really want to go Windows feel free but there is less help > to be had there.) Until you can get that to work you should not proceed > any further on attempting to modify PostgreSQL server. > > Then, instead of trying to get ancient PostgreSQL server code running on > modern hardware, you should focus your attention on getting ancient > third-party modifications to the PostgreSQL server code to work on the > modern PostgreSQL server. > > As an aside, I noticed the "USE_PGXS = 1", it didn't exist back in the 8.3 > days. > > As far as I can see, in a limited read of the readme summary, all of the > relevant code needs to exist within the PostgreSQL server source tree, the > pg_advise_index being placed in the contrib section just like, for example, > hstore or pg_prewarm (which I think has a command line interface). Then > you modify, build and install the server and the modifications are fully > incorporated as core+contrib code. This seems all quite straight-forward, > with plenty of examples to copy from, for dealing with the overall > structural aspects of the codebase and build/install processes. Which > brings me back to first understanding how the unaltered system works before > trying to make alterations. You may choose to learn that using an 8.3 > server but you will probably find little help if you go that route. > > David J. > > > > > > > David J. > >
Pg_hba.conf problem after unexpected IP change
Hello. I write for the following reason: I had configured a pg_hba.conf file, which I am using with some debian virtual machines, to be able to communicate between two different virtual machines. Well, it turns out that at one point when I was using my virtual machines, suddenly and unexpectedly, the IP of one of the virtual machines changed. I was trying to find out why the commands that I was executing between one virtual machine and the other did not work for me, until finally I came to the conclusion that the IP of one of my virtual machines had changed. Well, then, I went to modify my pg_hba.conf file so that it reflected the new IP that I did not know why it changed, and to continue communicating between the two virtual machines, but it turns out that when I change my pg_hba.conf file, the connection still does not work for me . The new line in my pg_hba.conf file is as follows: host ds2 postgres 192.168.52.153/32 trust and the line above was: host ds2 postgres 192.168.52.150/32 trust I clarify that right now when doing ip addr in the virtual machine whose IP changed unexpectedly, the following IP address appears: 192.168.52.153/24. I will greatly appreciate a help please. Regards, Yessica Brinkmann <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Libre de virus. www.avg.com <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
Re: Pg_hba.conf problem after unexpected IP change
Hello. Thank you very much for your answer. Yes, I restart the server after making the changes. Regards, Yessica Brinkmann <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Libre de virus. www.avg.com <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> El jue, 11 nov 2021 a las 22:41, Adrian Klaver () escribió: > On 11/11/21 17:14, Yessica Brinkmann wrote: > > Hello. I write for the following reason: I had configured a pg_hba.conf > > file, which I am using with some debian virtual machines, to be able to > > communicate between two different virtual machines. > > > Well, then, I went to modify my pg_hba.conf file so that it reflected > > the new IP that I did not know why it changed, and to continue > > communicating between the two virtual machines, but it turns out that > > when I change my pg_hba.conf file, the connection still does not work > > for me . > > Did you reload or restart the server after making the change? > > > I clarify that right now when doing ip addr in the virtual machine whose > > IP changed unexpectedly, the following IP address appears: > > 192.168.52.153/24 <http://192.168.52.153/24>. > > I will greatly appreciate a help please. > > Regards, > > Yessica Brinkmann > > > > > -- > Adrian Klaver > adrian.kla...@aklaver.com >
Re: Pg_hba.conf problem after unexpected IP change
Thank you very much for your answer. Regards, Yessica Brinkmann El vie, 12 nov 2021 a las 9:22, Dave Cramer () escribió: > > > > On Fri, 12 Nov 2021 at 06:12, Yessica Brinkmann < > brinkmann.yess...@gmail.com> wrote: > >> Hello. >> Thank you very much for your answer. >> Yes, I restart the server after making the changes. >> Regards, >> Yessica Brinkmann >> > > Check the logs for postgres to make sure there were no errors in your new > configuration. > > Dave Cramer > www.postgres.rocks > >> >>>
Re: Pg_hba.conf problem after unexpected IP change
Hello. Thank you very much for your answer. The configuration actually works for me. After restarting my computer, I went to test again and it was already working. I assume that perhaps because they are virtual machines it was not only enough to restart the server, I think you also had to restart the computer. It's what I think, or I don't know what else could have happened, but now it's working for me. Thank you very much and greetings, Yessica Brinkmann <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Libre de virus. www.avg.com <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> El vie, 12 nov 2021 a las 15:37, Adrian Klaver () escribió: > On 11/12/21 10:34 AM, Yessica Brinkmann wrote: > > Thank you very much for your answer. > > Did you find the problem? > > If not have you investigated whether whatever changed the IP also > enabled a firewall rule that blocks port(5432 I'm assuming)? > > > Regards, > > Yessica Brinkmann > > > > > > El vie, 12 nov 2021 a las 9:22, Dave Cramer > > () escribió: > > > > > > > > > > On Fri, 12 Nov 2021 at 06:12, Yessica Brinkmann > > mailto:brinkmann.yess...@gmail.com>> > > wrote: > > > > Hello. > > Thank you very much for your answer. > > Yes, I restart the server after making the changes. > > Regards, > > Yessica Brinkmann > > > > > > Check the logs for postgres to make sure there were no errors in > > your new configuration. > > > > Dave Cramer > > www.postgres.rocks > > > > > > > -- > Adrian Klaver > adrian.kla...@aklaver.com >