[GENERAL] Position() Bug ? In PostgreSQL 9.2

2013-05-02 Thread dinesh kumar
Hello Team, I would like to know whether the following behavior is a BUG or an expected behavior. If this is a duplicated case, then kindly ignore. postgres=# SELECT version(); version - PostgreSQL 9.2.3,

Re: [GENERAL] Position() Bug ? In PostgreSQL 9.2

2013-05-02 Thread Amit Langote
This behavior is similar to strstr(3) ('needle in a haystack' substring locating C function). char *strstr(const char *haystack, const char *needle) which returns haystack (that is main string) if needle (string to be located) is empty. Assuming position() tries to do something similar, it

Re: [GENERAL] Position() Bug ? In PostgreSQL 9.2

2013-05-02 Thread Tom Lane
dinesh kumar dineshkuma...@gmail.com writes: postgres=# select position('' in 'PostgreSQL'); *// position(Substring as an empty string) is returning 1.* position -- 1 (1 row) This is correct according to the SQL standard: position expression determines the first

Re: [GENERAL] Position() Bug ? In PostgreSQL 9.2

2013-05-02 Thread dinesh kumar
Hi Tom, Thank you very much for the clarification. Let me set an empty string validation, before passing it to position() from API. Thank you once again. Regards, Dinesh manojadinesh.blogspot.com On 2 May 2013 19:19, Tom Lane t...@sss.pgh.pa.us wrote: dinesh kumar dineshkuma...@gmail.com

[GENERAL] Position() Bug ? In PostgreSQL 9.2

2013-05-02 Thread Amit Langote
This behavior is similar to strstr(3) ('needle in a haystack' substring locating C function). which is, char *strstr(const char *haystack, const char *needle) which returns haystack (that is main string) if needle (string to be located) is empty. Assuming position() tries to do something