Re: Bug #894: different result with the same parameterlist in function call - Mailing list pgsql-bugs

From Tom Lane
Subject Re: Bug #894: different result with the same parameterlist in function call
Date
Msg-id 1603.1044812036@sss.pgh.pa.us
Whole thread Raw
In response to Bug #894: different result with the same parameterlist in function call  (pgsql-bugs@postgresql.org)
List pgsql-bugs
pgsql-bugs@postgresql.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

pgsql-bugs by date:

Previous
From: pgsql-bugs@postgresql.org
Date:
Subject: Bug #894: different result with the same parameterlist in function call
Next
From: "Donald Fraser"
Date:
Subject: Re: Trigger function not executing