Re: [HACKERS] URL Managment - C Function help

2009-10-21 Thread Samuel ROZE
It is solved. I'll propose my work the next weeks. :-) Regards, Samuel. Le mercredi 21 octobre 2009 à 17:31 +0200, Samuel ROZE a écrit : > Hi, > > I'm writing two functions "parse_url_key" and "parse_url_record" which > will have one text argument and will return a record or a specific > column

Re: [HACKERS] URL Managment - C Function help

2009-10-21 Thread Andrew Dunstan
Samuel ROZE wrote: Le mercredi 21 octobre 2009 à 12:59 -0400, Andrew Dunstan a écrit : On 8.3 you might need to put a #define for it directly in your C file. I can't: cstring_to_text isn't defined. I'll develop on 8.4. or try: #define CStringGetTextP(c) DatumGetTextP(DirectFun

Re: [HACKERS] URL Managment - C Function help

2009-10-21 Thread Samuel ROZE
Le mercredi 21 octobre 2009 à 12:59 -0400, Andrew Dunstan a écrit : > On 8.3 you might need to put a #define for it directly in your C file. I can't: cstring_to_text isn't defined. I'll develop on 8.4. -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to you

Re: [HACKERS] URL Managment - C Function help

2009-10-21 Thread Andrew Dunstan
Samuel ROZE wrote: I've done it but I had no results... strange. I've a 8.3 version and this lines are NOT in the file: You neglected to tell us you were in 8.3 before, I think. On 8.3 you might need to put a #define for it directly in your C file. cheers andrew -- Sent via pgsql

Re: [HACKERS] URL Managment - C Function help

2009-10-21 Thread Tom Lane
Samuel ROZE writes: > I've done it but I had no results... strange. > I've a 8.3 version and this lines are NOT in the file: Oh, it was changed in 8.4 IIRC. If you are thinking of submitting code to the project you should not be developing against a back release anyway ...

Re: [HACKERS] URL Managment - C Function help

2009-10-21 Thread Samuel ROZE
I'm now using C strings. I don't need to use CStringGetTextDatum, but it still don't works. There's the code: --- PG_FUNCTION_INFO_V1(parse_url_record); Datum parse_url_record (PG_FUNCTION_ARGS) { // Vars about the params

Re: [HACKERS] URL Managment - C Function help

2009-10-21 Thread Samuel ROZE
I've done it but I had no results... strange. I've a 8.3 version and this lines are NOT in the file: 00668 /* varlena.c */ 00669 extern text *cstring_to_text(const char *s); 00670 extern text *cstring_to_text_with_len(const char *s, int len); 00671 extern char *text_to_cstring(const text *t); 0067

Re: [HACKERS] URL Managment - C Function help

2009-10-21 Thread Andrew Dunstan
Samuel ROZE wrote: Le mercredi 21 octobre 2009 à 11:42 -0400, Tom Lane a écrit : CStringGetTextDatum Can you give me more precisions ? I'm creating a "user C function", with shared library and CStringGetTextDatum is in "varlena.h" file which is not in the "src/include" dir... How ca

Re: [HACKERS] URL Managment - C Function help

2009-10-21 Thread Samuel ROZE
Le mercredi 21 octobre 2009 à 11:42 -0400, Tom Lane a écrit : > CStringGetTextDatum Can you give me more precisions ? I'm creating a "user C function", with shared library and CStringGetTextDatum is in "varlena.h" file which is not in the "src/include" dir... How can I include it ? Thanks. Samue

Re: [HACKERS] URL Managment - C Function help

2009-10-21 Thread Samuel ROZE
Thanks for your reply. PG_FUNCTION_INFO_V1(parse_url_record); Datum parse_url_record (PG_FUNCTION_ARGS) { // Vars about the params //text *str2 = PG_GETARG_TEXT_P(0); char str[] = "http://www.ovh.com/intenal.html";;

Re: [HACKERS] URL Managment - C Function help

2009-10-21 Thread Heikki Linnakangas
Samuel ROZE wrote: > PG_FUNCTION_INFO_V1(parse_url_record); > Datum parse_url_record (PG_FUNCTION_ARGS) > { > // Vars about the params > //text *str2 = PG_GETARG_TEXT_P(0); > char str[] = "http://www.ovh.com/intenal.html";; > > // Some vars which will used to create the com

Re: [HACKERS] URL Managment - C Function help

2009-10-21 Thread Tom Lane
Samuel ROZE writes: > The problem is that they don't work fine... :/ I think the problem is that you are passing C strings to code that expects pointers to text datums --- which are not the same thing at all. (text has a length word, not a null terminator byte.) It's pure accident that your firs

[HACKERS] URL Managment - C Function help

2009-10-21 Thread Samuel ROZE
Hi, I'm writing two functions "parse_url_key" and "parse_url_record" which will have one text argument and will return a record or a specific column of it. Theses functions are calling "parse_url_exec" which parse the URL. When theses function will works, i'll purpose them to PostgreSQL community.