Re: Bug #894: different result with the same parameterlist in function call

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: balazs(dot)kovacs(at)jonapot(dot)hu, pgsql-bugs(at)postgresql(dot)org
Subject: Re: Bug #894: different result with the same parameterlist in function call
Date: 2003-02-09 17:33:56
Message-ID: 1603.1044812036@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

pgsql-bugs(at)postgresql(dot)org writes:
> text *pattern = (text*)PG_GETARG_TEXT_P(0);
> text *sample = (text*)PG_GETARG_TEXT_P(1);
> char *char_pattern = (char*)VARDATA(pattern);
> char *char_sample = (char*)VARDATA(sample);

You can't convert text* to char* with just a cast. The result won't
(usually) be null-terminated where it should be; so you end up with
strings that have garbage on the end. Use textout() like all the
existing code does when it wants a null-terminated string.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Donald Fraser 2003-02-10 09:43:11 Re: Trigger function not executing
Previous Message pgsql-bugs 2003-02-09 15:44:24 Bug #894: different result with the same parameterlist in function call