Обсуждение: Gist Index: Problem getting data in GiST Support Functions "penalty".
Hi,
I have a user defined data type and a GiST index on this type. My GiST index is not working because I am not getting
datain one of the GiST Support Functions "penalty".
Here is the simplified example my type "MY_TYPE"
1- User Defined Data Type
typedef struct
{
long id;
long x;
long y;
.......
BYTEA mydata[1];
} MY_TYPE;
typedef struct
{
long mnx;
long mny;
long mxx;
long mxy;
long m1;
long m2;
} MY_SUB_TYPE;
Create TYPE my_data_type (INPUT = MY_Type_In, OUTPUT = MY_Type_Out,
INTERNALLENGTH=VARIABLE, analyze = my_type_analyze, STORAGE = MAIN);
Create TYPE my_sub_data_type (INPUT=MY_Sub_Type_In, OUTPUT=MY_Sub_Type_Out, INTERNALLENGTH=24);
CREATE OPERATOR CLASS my_type_data_ops
DEFAULT FOR TYPE my_data_type USING gist AS
OPERATOR 1 =<< ,
............
FUNCTION 1 my_type_gist_consistent (internal, my_data_type, int4),
FUNCTION 2 my_type_gist_union (internal, internal),
FUNCTION 3 my_type_gist_compress (internal),
FUNCTION 4 my_type_gist_decompress (internal),
FUNCTION 5 my_type_gist_penalty (internal, internal, internal),
FUNCTION 6 my_type_gist_picksplit(internal, internal),
FUNCTION 7 my_type_gist_equal(my_sub_data_type, my_sub_data_type, internal);
2- Problem
Create GiST index not returning expected values.
CREATE INDEX my_test_spx ON my_test USING gist (b);
.......
NOTICE: In my_type_gist_penalty: origentry : ENV <minx= 0, miny = 0, maxx = 0, maxy = 0: m1 = 0 m2 = 0 >
However, when I remove 'm1' and 'm2' from my type "MY_SUB_TYPE", I am getting expected results.
typedef struct
{
long mnx;
long mny;
long mxx;
long mxy;
} MY_SUB_TYPE;
Create TYPE stt_envelope (INPUT=STT_ENVELOPE_In, OUTPUT=STT_ENVELOPE_Out, INTERNALLENGTH=16);
Expected results:
CREATE INDEX my_test_spx ON my_test USING gist (b);
......
NOTICE: In my_type_gist_penalty: origentry : ENV <minx= 6234067, miny = 2034619, maxx = 6341951, maxy = 2044797 >
CREATE INDEX
3- GiST Function "penalty".
Datum my_type_gist_penalty(PG_FUNCTION_ARGS)
{
GISTENTRY *origentry = (GISTENTRY *) PG_GETARG_POINTER(0);
GISTENTRY *newentry = (GISTENTRY *) PG_GETARG_POINTER(1);
float *result = (float *) PG_GETARG_POINTER(2);
Datum ud;
if (DatumGetPointer(origentry->key) == NULL && DatumGetPointer(newentry->key) == NULL)
*result = 0;
else
{
S_print("In my_type_gist_penalty: origentry " , (MY_SUB_TYPE *) PointerGetDatum(origentry->key));
ud = DirectFunctionCall2(my_type_union, origentry->key, newentry->key);
..................
}
PG_RETURN_POINTER(result);
}
Can anyone explain why I am seeing this difference? Is there any limitation of GiST Support Functions "penalty"?
I can provide more information if needed.
Thanks.
Ale Raza.
I am running 9.0.4 and I'm running it on Windows 7 Ultimate which is my development machine. I can't even create a server. When I try I get a message The server doesn't accept connections: the connection library reports could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "192.168.1.150" and accepting TCP/IP connections on port 5432? PostGres has been given access through the firewall on port 5432. My pg_hba.config file has the following line # TYPE DATABASE USER CIDR-ADDRESS METHOD # IPv4 local connections: host all all 0.0.0.0/0 trust I am just trying to get logged in at this point so I'm basically not trying to use any security. This is becoming a huge problem for me. I need to have the schema imported into the database by Thursday of this week when we are supposed to show off a new module in our product. We've not had any problems in other customer locations trying to get in. Any ideas? Best Regards Michael Gould
On Monday, June 27, 2011 5:13:04 pm Michael Gould wrote: > I am running 9.0.4 and I'm running it on Windows 7 Ultimate which is my > development machine. > > I can't even create a server. When I try I get a message > > > The server doesn't accept connections: the connection library reports > could not connect to server: Connection refused (0x0000274D/10061) Is the > server running on host "192.168.1.150" and accepting TCP/IP connections on > port 5432? > > PostGres has been given access through the firewall on port 5432. > > My pg_hba.config file has the following line > > > # TYPE DATABASE USER CIDR-ADDRESS METHOD > > # IPv4 local connections: > host all all 0.0.0.0/0 trust > > > I am just trying to get logged in at this point so I'm basically not trying > to use any security. > > This is becoming a huge problem for me. I need to have the schema imported > into the database by Thursday of this week when we are supposed to show off > a new module in our product. We've not had any problems in other customer > locations trying to get in. > > Any ideas? What is listen_addresses in postgresql.conf set to? If it is the default localhost then the above line should probably be: host all all 127.0.0.1/32 trust What is the connection string you are using to make the connection? > > Best Regards > > Michael Gould -- Adrian Klaver adrian.klaver@gmail.com