[HACKERS] How to deal with order by, group by, distinct for user-defined types
Hi, I implemented a user-defined type, say X, and when I want to do the following queries, Postgresql will complain CREATE TABLE Table1 ( id integer, object X ); SELECT X, count(*) from Table1 GROUP BY X; ERROR: could not identify an ordering operator for type X HINT: Use an explicit ordering operator or modify the query. My question is: how do I find or define ordering operators for my user-defined type? Thanks. Ruey-Lung Hsiao ---(end of broadcast)--- TIP 7: don't forget to increase your free space map settings
[HACKERS] How to check the postgresql version
Hi, Sorry if this problem seems stupid but I would appreciate it if someone helps. I've been implementing several user-defined types and their corresponding GiST index in postgresql 7.4.3. They worked well. However, I have noticed there are several changes in SPI functions and their parameters in 8.0beta. I want to be able to compile my codes in Postgresql 7.4.X and 8.0.X, so the only way to do that is to use the C preprocessor directives to check PG_VERSION (defined in pg_config.h). My problem is: I can't find a way to compare strings in C preprocessor directive since PG_VERSION is defined as something like "7.4.3" or "7.4.6". I ultimately want to do the following things: #if PG_VERSION starts with "8.X" ... call 8.0 compatible functions #else ... call 7.4.x compatible functions #endif Could anyone tell me how to do this kind of version check task? Thank you very much. Ruey-Lung Hsiao ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])
[HACKERS] "no snapshot has been set" error
Hi all, I encountered a problem when I'm implementing my user-defined type. My user-defined type is defined as CREATE TYPE X ( INTERNALLENGTH = 10 INPUT = X_in, OUTPUT = X_out ); In my X_in() function, I want to access other table to do some bookkeeping stuff. this table keeps track of the number of calls to X_in(). However, while SPI_connect() returns SPI_OK_CONNECT, whenever I execute SPI_exec( "SELECT count FROM XTABLE", 0), postgres stops executing and issues "Error: no snapshot has been set". Does anyone here knows what happens? Am I not allowed to use SPI functions in this situation? Thank you for your advice and suggestions in advance. Ruey-Lung Hsiao ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly