pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedImplementation of gtrgm_out for gevel
4+ messages / 2 participants
[nested] [flat]
* Implementation of gtrgm_out for gevel
@ 2017-11-23 17:52 Dmitry Lazurkin <dilaz03@gmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Lazurkin @ 2017-11-23 17:52 UTC (permalink / raw)
To: pgsql-general
Hello.
I want use gevel (http://www.sai.msu.su/~megera/wiki/Gevel) for investigation of pg_trgm gist. But for gist_print i need implement gtrgm_out for pg_trgm gist node. And i have a problem here.
-----
My version:
PostgreSQL 9.6.6 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 5.4.0-6ubuntu1~16.04.5) 5.4.0 20160609, 64-bit
-----
Function:
Datum
gtrgm_out(PG_FUNCTION_ARGS)
{
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); /* I think entry is pointer to bad memory */
char *result;
char buf[1024];
if (entry->leafkey) /* Why leafkey is always true and has strange value? */
{
/* This is from gtrgm_compress */
/* text *val = DatumGetTextPP(entry->key); <-- Segfault here */
/* result = strndup(VARDATA_ANY(val), VARSIZE_ANY_EXHDR(val)); */
sprintf(buf, "leafkey %c", entry->leafkey);
}
else
{
sprintf(buf, "leafkey %c", entry->leafkey);
}
result = pstrdup(buf);
PG_RETURN_CSTRING(result);
}
-----
Call gtrgm_out:
select * from gist_print('test1_trgm') as t(level int, valid bool, a gtrgm);
level | valid | a
-------+-------+--------------
1 | t | leafkey \x7F
2 | t | leafkey \x7F
...
2 | t | leafkey v
...
2 | t | leafkey \x7F
...
2 | t | leafkey v
2 | t | leafkey \x7F
...
Can anyone give me some advice?
Thanks.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Implementation of gtrgm_out for gevel
@ 2017-11-23 18:58 Tom Lane <tgl@sss.pgh.pa.us>
parent: Dmitry Lazurkin <dilaz03@gmail.com>
0 siblings, 2 replies; 4+ messages in thread
From: Tom Lane @ 2017-11-23 18:58 UTC (permalink / raw)
To: Dmitry Lazurkin <dilaz03@gmail.com>; +Cc: pgsql-general
Dmitry Lazurkin <dilaz03@gmail.com> writes:
> I want use gevel (http://www.sai.msu.su/~megera/wiki/Gevel) for investigation of pg_trgm gist. But for gist_print i need implement gtrgm_out for pg_trgm gist node. And i have a problem here.
> Datum
> gtrgm_out(PG_FUNCTION_ARGS)
> {
> GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); /* I think entry is pointer to bad memory */
The argument is TRGM *, I think ... certainly not GISTENTRY *.
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Implementation of gtrgm_out for gevel
@ 2017-11-23 19:12 Dmitry Lazurkin <dilaz03@gmail.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 4+ messages in thread
From: Dmitry Lazurkin @ 2017-11-23 19:12 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-general
On 23.11.2017 21:58, Tom Lane wrote:
> Dmitry Lazurkin <dilaz03@gmail.com> writes:
>> Datum
>> gtrgm_out(PG_FUNCTION_ARGS)
>> {
>> GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); /* I think entry is pointer to bad memory */
> The argument is TRGM *, I think ... certainly not GISTENTRY *.
>
> regards, tom lane
Hmm. I will try to debug gist_print.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Implementation of gtrgm_out for gevel
@ 2017-11-24 13:06 Dmitry Lazurkin <dilaz03@gmail.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 4+ messages in thread
From: Dmitry Lazurkin @ 2017-11-24 13:06 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-general
On 11/23/2017 09:58 PM, Tom Lane wrote:
> Dmitry Lazurkin <dilaz03@gmail.com> writes:
>> Datum
>> gtrgm_out(PG_FUNCTION_ARGS)
>> {
>> GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); /* I think entry is pointer to bad memory */
> The argument is TRGM *, I think ... certainly not GISTENTRY *.
>
> regards, tom lane
You are right. Thank you.
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2017-11-24 13:06 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-11-23 17:52 Implementation of gtrgm_out for gevel Dmitry Lazurkin <dilaz03@gmail.com>
2017-11-23 18:58 ` Tom Lane <tgl@sss.pgh.pa.us>
2017-11-23 19:12 ` Dmitry Lazurkin <dilaz03@gmail.com>
2017-11-24 13:06 ` Dmitry Lazurkin <dilaz03@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox