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

From: Yessica Brinkmann <yessica(dot)brinkmann(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: I think that my data is saved correctly, but when printing again, other data appears
Date: 2019-10-25 15:24:08
Message-ID: 6cn43v-kpk6i5gmroah-8s3fxj-obuf01-7gthsn-w01z6b-lpzvej-661z71jmpmi8-1npytb57lzgg-2cagvflpw1wnfjg834kpo46kpvh3rt-d709lq-mzqirq-vv9lx095h9fk-83gie7-rgk77o-xjfd1r.1572017048567@email.android.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thank you so much for your answer. I will be testing the indicated and then I give you return.<br>Best regards,<br><br>Yessica Brinkmann<br><div class="quote" style="line-height: 1.5"><br><br>-------- Mensaje original --------<br>Asunto: Re: I think that my data is saved correctly, but when printing again, other data appears<br>De: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us><br>Para: Yessica Brinkmann <yessica(dot)brinkmann(at)gmail(dot)com><br>CC: pgsql-general(at)lists(dot)postgresql(dot)org<br><br><br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Yessica Brinkmann <yessica(dot)brinkmann(at)gmail(dot)com> writes:<br>> I have a function called get_columnnames, which runs on a Postgresql server<br>> and returns the names of the columns of a table in a Postgresql database.<br>> In the first foreach, in the statement: idxcd-> varattnames [cont] = data;<br>> column names are saved. Those column names are saved correctly. I could<br>> verify this by printing some values.<br>> But later, in the following foreach, when I reprint the values of the names<br>> of the columns that had been saved in the idxcd-> varattnames [cont] = data<br>> statement; They appear to me with errors.<br><br>Yeah, because the "data" value is just a pointer into the tupdesc<br>associated with the SPI result, and that disappears the moment you<br>do SPI_finish(). You'd need to do something to copy the strings<br>into a longer-lived context. A plain pstrdup() won't suffice<br>because you're in a short-lived SPI context already inside that<br>loop; but you could save CurrentMemoryContext before starting up<br>SPI and then use MemoryContextStrdup.<br><br> regards, tom lane<br></blockquote></div>

Attachment Content-Type Size
unknown_filename text/html 1.7 KB

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jehan-Guillaume de Rorthais 2019-10-25 15:38:21 Re: logical replication - negative bitmapset member not allowed
Previous Message Alexander Farber 2019-10-25 15:12:27 Trying to fetch records only if preceded by at least another one