Re: Call pstrdup() of palloc.h will change source string, please help!

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: mengfanjun <meng_fan_jun(at)foxmail(dot)com>
Cc: pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Call pstrdup() of palloc.h will change source string, please help!
Date: 2022-06-04 17:05:29
Message-ID: 574740.1654362329@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"=?ISO-8859-1?B?bWVuZ2Zhbmp1bg==?=" <meng_fan_jun(at)foxmail(dot)com> writes:
> pstrdup() will change source "system_time( stt , ett )" to "system_time( stt " and return&nbsp;"system_time( stt "&nbsp;when it is called in&nbsp;ValidateForeignTableOptions() and CStoreGetOptions().

That claim is not very credible. I'm not sure where the bug is in this
code, but the chance that it's in pstrdup is frankly zero.

According to the man page for strsep(), that function modifies the string
pointed to by its first argument. I suspect you're failing to account
for that. I'm also suspicious of the "// trim" code, which will misbehave
for a zero-length token.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message John W Higgins 2022-06-04 17:06:51 Re: Window function?
Previous Message David G. Johnston 2022-06-04 16:25:55 Re: Window function?