Обсуждение: tsearch2 under win32

Поиск
Список
Период
Сортировка

tsearch2 under win32

От
"Darko Prenosil"
Дата:
    I tried to compile the package(OK, I was naive believing that there will
be no bigger problems), but first run to redefine of WORD in ts_cfg.h.
That was easy to solve, simple changed it to TSWORD in all places.
Second problem is much bigger: there is no regex library under WIN32, at
least I didn't find it in the MSDN.
There is GNU port of regex (I didn't tried it), but that means one more
package to download :-(
I think tsearch2 is great package, and would be shame not to try make it
work under WIN32.
Is there already regex code in the postgresql source (how is regex
implemented for SQL queries for WIN32 ?)  ?
I'll try to dig some more.

Any suggestions ?

Regards !


Re: tsearch2 under win32

От
"Darko Prenosil"
Дата:
OK, I got it work, but I don't think that this way would be acceptable:
I downloaded GNU regex.c and regex.h and included it into tsearch2 sources.
There are also few modifications in regex.c
Basic test is giving correct results. Should I send modifications ? Hackers
?

Here are the results:

SELECT '1'::tsvector;
SELECT '1 '::tsvector;
SELECT ' 1'::tsvector;
SELECT ' 1 '::tsvector;
SELECT '1 2'::tsvector;
SELECT '\'1 2\''::tsvector;
SELECT '\'1 \\\'2\''::tsvector;
SELECT '\'1 \\\'2\'3'::tsvector;
SELECT '\'1 \\\'2\' 3'::tsvector;
SELECT '\'1 \\\'2\' \' 3\' 4 '::tsvector;
select '\'w\':4A,3B,2C,1D,5 a:8';
select 'a:3A b:2a'::tsvector || 'ba:1234 a:1B';
select setweight('w:12B w:13* w:12,5,6 a:1,3* a:3 w asd:1dc asd
zxc:81,567,222A'::tsvector, 'c');
select strip('w:12B w:13* w:12,5,6 a:1,3* a:3 w asd:1dc asd'::tsvector);

 tsvector
----------
 '1'
(1 row)


 tsvector
----------
 '1'
(1 row)


 tsvector
----------
 '1'
(1 row)


 tsvector
----------
 '1' '2'
(1 row)


 tsvector
----------
 '1 2'
(1 row)


 tsvector
----------
 '1 \'2'
(1 row)


  tsvector
-------------
 '3' '1 \'2'
(1 row)

  tsvector
-------------
 '3' '1 \'2'
(1 row)


     tsvector
------------------
 '4' ' 3' '1 \'2'
(1 row)


       ?column?
-----------------------
 'w':4A,3B,2C,1D,5 a:8
(1 row)


          ?column?
----------------------------
 'a':3A,4B 'b':2A 'ba':1237
(1 row)


                        setweight
----------------------------------------------------------
 'a':1C,3C 'w':5C,6C,12C,13C 'asd':1C 'zxc':81C,222C,567C
(1 row)


     strip
---------------
 'a' 'w' 'asd'




Regards !


Re: tsearch2 under win32

От
Tom Lane
Дата:
"Darko Prenosil" <Darko.Prenosil@finteh.hr> writes:
> OK, I got it work, but I don't think that this way would be acceptable:
> I downloaded GNU regex.c and regex.h and included it into tsearch2 sources.

You're right.  We're not going to accept a contrib module containing its
own regex engine when there's already a perfectly good one in the
backend.  See src/backend/regex.

            regards, tom lane

Re: tsearch2 under win32

От
"Darko Prenosil"
Дата:
Thanks Tom, and I was wondering how regex works for SQL queries.
I'll try to do it with included package.

Regards !

----- Original Message -----
From: "Tom Lane" <tgl@sss.pgh.pa.us>
To: "Darko Prenosil" <Darko.Prenosil@finteh.hr>
Cc: <pgsql-hackers-win32@postgresql.org>
Sent: Tuesday, May 11, 2004 8:02 PM
Subject: Re: [pgsql-hackers-win32] tsearch2 under win32


> "Darko Prenosil" <Darko.Prenosil@finteh.hr> writes:
> > OK, I got it work, but I don't think that this way would be acceptable:
> > I downloaded GNU regex.c and regex.h and included it into tsearch2
sources.
>
> You're right.  We're not going to accept a contrib module containing its
> own regex engine when there's already a perfectly good one in the
> backend.  See src/backend/regex.
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: the planner will ignore your desire to choose an index scan if your
>       joining column's datatypes do not match
>


Re: tsearch2 under win32

От
Tom Lane
Дата:
"Darko Prenosil" <Darko.Prenosil@finteh.hr> writes:
>     is it safe to cast "const char*" to "pg_wchar*"

No.  They're not the same kind of animal at all.

You may want to look at the interface code in utils/adt/regexp.c.

            regards, tom lane

PS: it would be nicer to see your work as a patch diff, not as a pile
of replacement files.  We are not going to drop in replacement files,
since that risks losing other people's concurrent work.

Re: tsearch2 under win32

От
"Darko Prenosil"
Дата:
Here are difs for tsearch2 to make it work under win32.
Unfortunately I can't test it with today's snapshot because of build error:

gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes -Wmissing-declaratio
ns initdb.o
ec.o -L../../../src/interfaces/libpq -lpq -L../../../src/port   -lz -lwsock3
2 -lm  -lpgport -lws2_32 -o initdb.exe
../../../src/port/libpgport.a(pipe.o)(.text+0x27):pipe.c: undefined
reference to `pgwin32_socket'
../../../src/port/libpgport.a(pipe.o)(.text+0xbc):pipe.c: undefined
reference to `pgwin32_socket'
../../../src/port/libpgport.a(pipe.o)(.text+0xd3):pipe.c: undefined
reference to `pgwin32_connect'
../../../src/port/libpgport.a(pipe.o)(.text+0xe5):pipe.c: undefined
reference to `pgwin32_accept'
../../../src/port/libpgport.a(pipe.o)(.text+0x154):pipe.c: undefined
reference to `pgwin32_recv'
make[3]: *** [initdb] Error 1
make[3]: Leaving directory `/d/postgresql-snapshot-new/src/bin/initdb'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/d/postgresql-snapshot-new/src/bin'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/d/postgresql-snapshot-new/src'
make: *** [all] Error 2

There is still problem with tsearch configuration paths because configure
does not accept windows style path for --prefix, so it must be done by hand,
but that is another problem.
Actually there are only two changes in the tsearch2 sources:
    1.) WORD structure renamed to TSWORD because of conflict with win32
headers
    2.) make it use pg_reg* functions insetad of reg* functions.

I also made some changes to contrib/dbase. Is there interset at all to make
it work with win32 ?

Regards !

Вложения