Saturday, August 2, 2008

Re: [HACKERS] Re: [Pljava-dev] Should creating a new base type require superuser status?

Tom Lane wrote:
>
>> This is a non-issue in PL/Java. An integer parameter is never passed by
>> reference and there's no way the PL/Java user can get direct access to
>> backend memory.
>>
>
> So what exactly does happen when the user deliberately specifies wrong
> typlen/typbyval/typalign info when creating a type based on PL/Java
> functions?
>
>
Everything is converted into instances of Java classes such as String,
byte[], etc.

>> I think that assumption is without ground. Java doesn't permit you to
>> access memory unless you use Java classes (java.nio stuff) that is
>> explicitly designed to do that and you need native code to set such
>> things up. A PL/Java user can not do that unless he is able to link in
>> other shared objects or dll's to the backend process.
>>
>
> PL/Java itself must be doing "unsafe" things in order to interface with
> PG at all. So what your argument really is is that you have managed to
> securely sandbox the user-written code you are calling. That might or
> might not be true, but I don't think that worrying about it is without
> foundation.
>
>
I would be presumptuous to claim that I provide the sandbox. All PL/Java
does is to provide the type mapping. The sandbox as such is implicit in
Java, much in the same way that it does it for web-browsers etc.

Regardless of that, I think there's some difference in expressing a
worry that might or might not have a foundation versus claiming that
there indeed must be a security hole a mile wide ;-)

- thomas


--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Re: [GENERAL] Fresh install on Mac OS 10.5.4

Thanks guys!

Yes, 8.3.3 binaries got installed in /usr/local/pgsql/bin and so the
7.3 version that I had previously didn't get overwritten. Binaries for
7.3 were in /usr/local/bin

Works now.

Regards,
Manoj Patwardhan

On Aug 3, 2008, at 12:17 AM, Tom Lane wrote:

> John DeSoi <desoi@pgedit.com> writes:
>> On Aug 2, 2008, at 7:13 PM, Manoj Patwardhan wrote:
>>> bash-3.2$ initdb -D /usr/local/pgsql/data
>>> dyld: Library not loaded: /usr/local/pgsql/lib/libpq.4.dylib
>>> Referenced from: /usr/local/bin/initdb
>
>> Could be a path problem. Try
>
> Yeah ... the reference to libpq major version 4 suggests *very*
> strongly that this copy of initdb is from PG version 8.0 or 8.1.
>
> regards, tom lane


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[COMMITTERS] pgsql: Fix copy-and-pasteo that's causing pg_regress to lie about which

Log Message:
-----------
Fix copy-and-pasteo that's causing pg_regress to lie about which file it can't
read when the --temp-config argument is bad. Noted while wondering why
buildfarm member dungbeetle is failing ... this isn't why, but it is why
the error report isn't very helpful ...

Tags:
----
REL8_3_STABLE

Modified Files:
--------------
pgsql/src/test/regress:
pg_regress.c (r1.41.2.2 -> r1.41.2.3)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/pg_regress.c?r1=1.41.2.2&r2=1.41.2.3)

--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers

[COMMITTERS] pgsql: Fix copy-and-pasteo that's causing pg_regress to lie about which

Log Message:
-----------
Fix copy-and-pasteo that's causing pg_regress to lie about which file it can't
read when the --temp-config argument is bad. Noted while wondering why
buildfarm member dungbeetle is failing ... this isn't why, but it is why
the error report isn't very helpful ...

Modified Files:
--------------
pgsql/src/test/regress:
pg_regress.c (r1.45 -> r1.46)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/pg_regress.c?r1=1.45&r2=1.46)

--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers

[pgsql-es-ayuda] mygeneration

hola a todos, alguien a hecho plantillas para MyGeneration + PostgreSql con utilizacion de esquemas?, cuando quiero realizar procedimiento en mygeneration no puedo ver los esquemas y solo veo las tablas que estan en el esquema public, no se como hacer para ver los esquemas y las tablas de los esquemas.

mygeneration es un generador de codigo muy util. mas referencia aca
http://www.mygenerationsoftware.com/portal/default.aspx

saludos
gracias a todos por su ayuda


--
Ing. Aguilar Pereda Luis
Claro: 044-9383387
Telefonica: 044-8937129
Fijo: 044-421957
http://monossystemsnet.6te.net

Re: [HACKERS] Parsing of pg_hba.conf and authentication inconsistencies

Robert Treat <xzilla@users.sourceforge.net> writes:
> Certainly there isn't any reason to allow a reload of a file that is just
> going to break things when the first connection happens. For that matter,
> why would we ever not want to parse it at HUP time rather than connect time?

Two or three reasons why not were already mentioned upthread, but for
the stubborn, here's another one: are you volunteering to write the code
that backs out the config-file reload after the checks have determined
it was bad? Given the amount of pain we suffered trying to make GUC do
something similar, any sane person would run screaming from the
prospect.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Re: [GENERAL] issues with java driver setDate() on function call

"Ismael ...." <ismaelpsp@hotmail.com> writes:
> I have a function declared as follows
> CREATE OR REPLACE FUNCTION insertaegreso(usuario1 integer, importepago1 numeric, fechapago1 DATE, concepto1 character varying, tipopagonomina1 character varying, comentarios1 character varying)
> RETURNS integer AS....implementation....

> but when I try to call it using java's PreparedStatement pst;
> I get this error, (note: "no existe la función" means "the function .... doesn't exists")
> org.postgresql.util.PSQLException: ERROR: no existe la función insertaegreso(integer, double precision, unknown, character varying, character varying, character varying)

Actually I think your problem is with the *second* parameter. There is
no implicit cast from double precision to numeric.

regards, tom lane

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Fresh install on Mac OS 10.5.4

John DeSoi <desoi@pgedit.com> writes:
> On Aug 2, 2008, at 7:13 PM, Manoj Patwardhan wrote:
>> bash-3.2$ initdb -D /usr/local/pgsql/data
>> dyld: Library not loaded: /usr/local/pgsql/lib/libpq.4.dylib
>> Referenced from: /usr/local/bin/initdb

> Could be a path problem. Try

Yeah ... the reference to libpq major version 4 suggests *very*
strongly that this copy of initdb is from PG version 8.0 or 8.1.

regards, tom lane

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: [HACKERS] Parsing of pg_hba.conf and authentication inconsistencies

"Joshua D. Drake" <jd@commandprompt.com> writes:
> True enough but perhaps that is a problem in itself. IMO, we should be
> encouraging people to never touch the postgres binary.

I don't buy that at all. pg_ctl is useful for some people and not so
useful for others; in particular, from the perspective of a system
startup script it tends to get in the way more than it helps.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Re: [HACKERS] Parsing of pg_hba.conf and authentication inconsistencies

Tom Lane wrote:
> Magnus Hagander <magnus@hagander.net> writes:
>> Is there any actual gain by not doing the parsing in the postmaster,
>
> Define "parsing". There's quite a lot of possible errors in pg_hba
> that it would be totally unreasonable for the postmaster to detect.

Parsing as in turning into a struct with clearly defined parts. Like
what type it is (host/local/hostssl), CIDR mask, auth method and parameters.


> We could catch some simple problems at file load time, perhaps,
> but those usually aren't the ones that cause trouble for people.

It would catch things like typos, invalid CIDR address/mask and
specifying an auth method that doesn't exist. This is the far most
common errors I've seen - which ones are you referring to?

> On the whole, I am against putting any more functionality into the
> main postmaster process than absolutely has to be there. Every
> new function you put onto it is another potential source of
> service-outage-inducing bugs.

True.

But as a counterexample, we have a whole lot of code in there to do the
same for GUC. Which can even call user code (custom variables), no? Are
you also proposing we should look at getting rid of that?


>> I've also noticed that authentication methods error out in different
>> ways when they are not supported.
>
> Yeah, that's something that should be made more consistent.
>
>
> Idle thought: maybe what would really make sense here is a "lint"
> for PG config files, which you'd run as a standalone program and
> which would look for not only clear errors but questionable things
> to warn about. For instance it might notice multiple pg_hba.conf
> entries for the same IP addresses, check whether an LDAP server
> can be connected to, check that all user/group/database names
> used in the file actually exist, etc. These are things that we'd
> certainly not put into any load- or reload-time tests.

That would also be a valuable tool, but IMHO for a slightly different
purpose. To me that sounds more in the line of the tool to "tune/suggest
certain postgresql.conf parameters" that has been discussed earlier.

It would have to be implemented as a SQL callable function or so in
order to make it usable for people doing remote admin, but that could
certainly be done.

It would still leave a fairly large hole open for anybody editing the
config file and just HUPing the postmaster (which a whole lot of people
do, since they're used to doing that to their daemon processes)

//Magnus


--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Re: [HACKERS] Parsing of pg_hba.conf and authentication inconsistencies

Magnus,

> However it would be nice to throw an error or at least a warning when parsing
> the file instead of pretending everything's ok. Perhaps authentication methods
> should have a function to check whether the method is supported which is
> called when the file is parsed.
>

The good way to solve this would be to have independant command line
utilities which check pg_hba.conf, pg_ident.conf and postgresql.conf for
errors. Then DBAs could run a check *before* restarting the server.

--Josh


--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Re: [HACKERS] Re: [Pljava-dev] Should creating a new base type require superuser status?

Thomas Hallgren <thomas@tada.se> writes:
> Tom Lane wrote:
>> The problem that we've seen in the past shows up when the user lies in
>> the CREATE TYPE command, specifying type representation properties that
>> are different from what the underlying functions expect.

> This is a non-issue in PL/Java. An integer parameter is never passed by
> reference and there's no way the PL/Java user can get direct access to
> backend memory.

So what exactly does happen when the user deliberately specifies wrong
typlen/typbyval/typalign info when creating a type based on PL/Java
functions?

> I think that assumption is without ground. Java doesn't permit you to
> access memory unless you use Java classes (java.nio stuff) that is
> explicitly designed to do that and you need native code to set such
> things up. A PL/Java user can not do that unless he is able to link in
> other shared objects or dll's to the backend process.

PL/Java itself must be doing "unsafe" things in order to interface with
PG at all. So what your argument really is is that you have managed to
securely sandbox the user-written code you are calling. That might or
might not be true, but I don't think that worrying about it is without
foundation.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Re: [HACKERS] [GENERAL] Fragments in tsearch2 headline

Index: src/include/tsearch/ts_public.h
===================================================================
RCS file: /home/postgres/devel/pgsql-cvs/pgsql/src/include/tsearch/ts_public.h,v
retrieving revision 1.10
diff -c -r1.10 ts_public.h
*** src/include/tsearch/ts_public.h 18 Jun 2008 18:42:54 -0000 1.10
--- src/include/tsearch/ts_public.h 2 Aug 2008 02:40:27 -0000
***************
*** 52,59 ****
--- 52,61 ----
int4 curwords;
char *startsel;
char *stopsel;
+ char *fragdelim;
int2 startsellen;
int2 stopsellen;
+ int2 fragdelimlen;
} HeadlineParsedText;

/*
Index: src/backend/tsearch/wparser_def.c
===================================================================
RCS file: /home/postgres/devel/pgsql-cvs/pgsql/src/backend/tsearch/wparser_def.c,v
retrieving revision 1.15
diff -c -r1.15 wparser_def.c
*** src/backend/tsearch/wparser_def.c 17 Jun 2008 16:09:06 -0000 1.15
--- src/backend/tsearch/wparser_def.c 2 Aug 2008 15:25:46 -0000
***************
*** 1684,1701 ****
return false;
}

! Datum
! prsd_headline(PG_FUNCTION_ARGS)
{
! HeadlineParsedText *prs = (HeadlineParsedText *) PG_GETARG_POINTER(0);
! List *prsoptions = (List *) PG_GETARG_POINTER(1);
! TSQuery query = PG_GETARG_TSQUERY(2);

! /* from opt + start and and tag */
! int min_words = 15;
! int max_words = 35;
! int shortword = 3;

int p = 0,
q = 0;
int bestb = -1,
--- 1684,1930 ----
return false;
}

! static void
! mark_fragment(HeadlineParsedText *prs, int highlight, int startpos, int endpos)
{
! int i;

! for (i = startpos; i <= endpos; i++)
! {
! if (prs->words[i].item)
! prs->words[i].selected = 1;
! if (highlight == 0)
! {
! if (HLIDIGNORE(prs->words[i].type))
! prs->words[i].replace = 1;
! }
! else
! {
! if (XMLHLIDIGNORE(prs->words[i].type))
! prs->words[i].replace = 1;
! }
!
! prs->words[i].in = (prs->words[i].repeated) ? 0 : 1;
! }
! }
!
! typedef struct
! {
! int4 startpos;
! int4 endpos;
! int4 poslen;
! int4 curlen;
! int2 in;
! int2 excluded;
! } CoverPos;
!
! static void
! get_next_fragment(HeadlineParsedText *prs, int *startpos, int *endpos,
! int *curlen, int *poslen, int max_words)
! {
! int i;
! /* Objective: Generate a fragment of words between startpos and endpos
! * such that it has at most max_words and both ends has query words.
! * If the startpos and endpos are the endpoints of the cover and the
! * cover has fewer words than max_words, then this function should
! * just return the cover
! */
! /* first move startpos to an item */
! for(i = *startpos; i <= *endpos; i++)
! {
! *startpos = i;
! if (prs->words[i].item && !prs->words[i].repeated)
! break;
! }
! /* cut endpos to have only max_words */
! *curlen = 0;
! *poslen = 0;
! for(i = *startpos; i <= *endpos && *curlen < max_words; i++)
! {
! if (!NONWORDTOKEN(prs->words[i].type))
! *curlen += 1;
! if (prs->words[i].item && !prs->words[i].repeated)
! *poslen += 1;
! }
! /* if the cover was cut then move back endpos to a query item */
! if (*endpos > i)
! {
! *endpos = i;
! for(i = *endpos; i >= *startpos; i --)
! {
! *endpos = i;
! if (prs->words[i].item && !prs->words[i].repeated)
! break;
! if (!NONWORDTOKEN(prs->words[i].type))
! *curlen -= 1;
! }
! }
! }
!
! static void
! mark_hl_fragments(HeadlineParsedText *prs, TSQuery query, int highlight,
! int shortword, int min_words,
! int max_words, int max_fragments)
! {
! int4 poslen, curlen, i, f, num_f = 0;
! int4 stretch, maxstretch, posmarker;
!
! int4 startpos = 0,
! endpos = 0,
! p = 0,
! q = 0;
!
! int4 numcovers = 0,
! maxcovers = 32;
!
! int4 minI, minwords, maxitems;
! CoverPos *covers;
!
! covers = palloc(maxcovers * sizeof(CoverPos));
!
! /* get all covers */
! while (hlCover(prs, query, &p, &q))
! {
! startpos = p;
! endpos = q;
!
! /* Break the cover into smaller fragments such that each fragment
! * has at most max_words. Also ensure that each end of the fragment
! * is a query word. This will allow us to stretch the fragment in
! * either direction
! */
!
! while (startpos <= endpos)
! {
! get_next_fragment(prs, &startpos, &endpos, &curlen, &poslen, max_words);
! if (numcovers >= maxcovers)
! {
! maxcovers *= 2;
! covers = repalloc(covers, sizeof(CoverPos) * maxcovers);
! }
! covers[numcovers].startpos = startpos;
! covers[numcovers].endpos = endpos;
! covers[numcovers].curlen = curlen;
! covers[numcovers].poslen = poslen;
! covers[numcovers].in = 0;
! covers[numcovers].excluded = 0;
! numcovers ++;
! startpos = endpos + 1;
! endpos = q;
! }
! /* move p to generate the next cover */
! p++;
! }
!
! /* choose best covers */
! for (f = 0; f < max_fragments; f++)
! {
! maxitems = 0;
! minwords = 0x7fffffff;
! minI = -1;
! /* Choose the cover that contains max items.
! * In case of tie choose the one with smaller
! * number of words.
! */
! for (i = 0; i < numcovers; i ++)
! {
! if (!covers[i].in && !covers[i].excluded &&
! (maxitems < covers[i].poslen || (maxitems == covers[i].poslen
! && minwords > covers[i].curlen)))
! {
! maxitems = covers[i].poslen;
! minwords = covers[i].curlen;
! minI = i;
! }
! }
! /* if a cover was found mark it */
! if (minI >= 0)
! {
! covers[minI].in = 1;
! /* adjust the size of cover */
! startpos = covers[minI].startpos;
! endpos = covers[minI].endpos;
! curlen = covers[minI].curlen;
! /* stretch the cover if cover size is lower than max_words */
! if (curlen < max_words)
! {
! /* divide the stretch on both sides of cover */
! maxstretch = (max_words - curlen)/2;
! /* first stretch the startpos
! * stop stretching if
! * 1. we hit the beginning of document
! * 2. exceed maxstretch
! * 3. we hit an already marked fragment
! */
! stretch = 0;
! posmarker = startpos;
! for (i = startpos - 1; i >= 0 && stretch < maxstretch && !prs->words[i].in; i--)
! {
! if (!NONWORDTOKEN(prs->words[i].type))
! {
! curlen ++;
! stretch ++;
! }
! posmarker = i;
! }
! /* cut back startpos till we find a non short token */
! for (i = posmarker; i < startpos && (NOENDTOKEN(prs->words[i].type) || prs->words[i].len <= shortword); i++)
! {
! if (!NONWORDTOKEN(prs->words[i].type))
! curlen --;
! }
! startpos = i;
! /* now stretch the endpos as much as possible*/
! posmarker = endpos;
! for (i = endpos + 1; i < prs->curwords && curlen < max_words && !prs->words[i].in; i++)
! {
! if (!NONWORDTOKEN(prs->words[i].type))
! curlen ++;
! posmarker = i;
! }
! /* cut back endpos till we find a non-short token */
! for ( i = posmarker; i > endpos && (NOENDTOKEN(prs->words[i].type) || prs->words[i].len <= shortword); i--)
! {
! if (!NONWORDTOKEN(prs->words[i].type))
! curlen --;
! }
! endpos = i;
! }
! covers[minI].startpos = startpos;
! covers[minI].endpos = endpos;
! covers[minI].curlen = curlen;
! /* Mark the chosen fragments (covers) */
! mark_fragment(prs, highlight, startpos, endpos);
! num_f ++;
! /* exclude overlapping covers */
! for (i = 0; i < numcovers; i ++)
! {
! if (i != minI && ( (covers[i].startpos >= covers[minI].startpos && covers[i].startpos <= covers[minI].endpos) || (covers[i].endpos >= covers[minI].startpos && covers[i].endpos <= covers[minI].endpos)))
! covers[i].excluded = 1;
! }
! }
! else
! break;
! }

+ /* show at least min_words we have not marked anything*/
+ if (num_f <= 0)
+ {
+ startpos = endpos = curlen = 0;
+ for (i = 0; i < prs->curwords && curlen < min_words; i++)
+ {
+ if (!NONWORDTOKEN(prs->words[i].type))
+ curlen++;
+ endpos = i;
+ }
+ mark_fragment(prs, highlight, startpos, endpos);
+ }
+ pfree(covers);
+ }
+ static void
+ mark_hl_words(HeadlineParsedText *prs, TSQuery query, int highlight,
+ int shortword, int min_words, int max_words)
+ {
int p = 0,
q = 0;
int bestb = -1,
***************
*** 1707,1762 ****
curlen;

int i;
- int highlight = 0;
- ListCell *l;
-
- /* config */
- prs->startsel = NULL;
- prs->stopsel = NULL;
- foreach(l, prsoptions)
- {
- DefElem *defel = (DefElem *) lfirst(l);
- char *val = defGetString(defel);
-
- if (pg_strcasecmp(defel->defname, "MaxWords") == 0)
- max_words = pg_atoi(val, sizeof(int32), 0);
- else if (pg_strcasecmp(defel->defname, "MinWords") == 0)
- min_words = pg_atoi(val, sizeof(int32), 0);
- else if (pg_strcasecmp(defel->defname, "ShortWord") == 0)
- shortword = pg_atoi(val, sizeof(int32), 0);
- else if (pg_strcasecmp(defel->defname, "StartSel") == 0)
- prs->startsel = pstrdup(val);
- else if (pg_strcasecmp(defel->defname, "StopSel") == 0)
- prs->stopsel = pstrdup(val);
- else if (pg_strcasecmp(defel->defname, "HighlightAll") == 0)
- highlight = (pg_strcasecmp(val, "1") == 0 ||
- pg_strcasecmp(val, "on") == 0 ||
- pg_strcasecmp(val, "true") == 0 ||
- pg_strcasecmp(val, "t") == 0 ||
- pg_strcasecmp(val, "y") == 0 ||
- pg_strcasecmp(val, "yes") == 0);
- else
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("unrecognized headline parameter: \"%s\"",
- defel->defname)));
- }

if (highlight == 0)
{
- if (min_words >= max_words)
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("MinWords should be less than MaxWords")));
- if (min_words <= 0)
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("MinWords should be positive")));
- if (shortword < 0)
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("ShortWord should be >= 0")));
-
while (hlCover(prs, query, &p, &q))
{
/* find cover len in words */
--- 1936,1944 ----
***************
*** 1877,1888 ****
--- 2059,2153 ----
prs->words[i].in = (prs->words[i].repeated) ? 0 : 1;
}

+ }
+
+ Datum
+ prsd_headline(PG_FUNCTION_ARGS)
+ {
+ HeadlineParsedText *prs = (HeadlineParsedText *) PG_GETARG_POINTER(0);
+ List *prsoptions = (List *) PG_GETARG_POINTER(1);
+ TSQuery query = PG_GETARG_TSQUERY(2);
+
+ /* from opt + start and and tag */
+ int min_words = 15;
+ int max_words = 35;
+ int shortword = 3;
+ int max_fragments = 0;
+ int highlight = 0;
+ ListCell *l;
+
+ /* config */
+ prs->startsel = NULL;
+ prs->stopsel = NULL;
+ foreach(l, prsoptions)
+ {
+ DefElem *defel = (DefElem *) lfirst(l);
+ char *val = defGetString(defel);
+
+ if (pg_strcasecmp(defel->defname, "MaxWords") == 0)
+ max_words = pg_atoi(val, sizeof(int32), 0);
+ else if (pg_strcasecmp(defel->defname, "MinWords") == 0)
+ min_words = pg_atoi(val, sizeof(int32), 0);
+ else if (pg_strcasecmp(defel->defname, "ShortWord") == 0)
+ shortword = pg_atoi(val, sizeof(int32), 0);
+ else if (pg_strcasecmp(defel->defname, "MaxFragments") == 0)
+ max_fragments = pg_atoi(val, sizeof(int32), 0);
+ else if (pg_strcasecmp(defel->defname, "StartSel") == 0)
+ prs->startsel = pstrdup(val);
+ else if (pg_strcasecmp(defel->defname, "StopSel") == 0)
+ prs->stopsel = pstrdup(val);
+ else if (pg_strcasecmp(defel->defname, "FragmentDelimiter") == 0)
+ prs->fragdelim = pstrdup(val);
+ else if (pg_strcasecmp(defel->defname, "HighlightAll") == 0)
+ highlight = (pg_strcasecmp(val, "1") == 0 ||
+ pg_strcasecmp(val, "on") == 0 ||
+ pg_strcasecmp(val, "true") == 0 ||
+ pg_strcasecmp(val, "t") == 0 ||
+ pg_strcasecmp(val, "y") == 0 ||
+ pg_strcasecmp(val, "yes") == 0);
+ else
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("unrecognized headline parameter: \"%s\"",
+ defel->defname)));
+ }
+
+ if (highlight == 0)
+ {
+ if (min_words >= max_words)
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("MinWords should be less than MaxWords")));
+ if (min_words <= 0)
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("MinWords should be positive")));
+ if (shortword < 0)
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("ShortWord should be >= 0")));
+ if (max_fragments < 0)
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("MaxFragments should be >= 0")));
+ }
+
+ if (max_fragments == 0)
+ /* call the default headline generator */
+ mark_hl_words(prs, query, highlight, shortword, min_words, max_words);
+ else
+ mark_hl_fragments(prs, query, highlight, shortword, min_words, max_words, max_fragments);
+
if (!prs->startsel)
prs->startsel = pstrdup("<b>");
if (!prs->stopsel)
prs->stopsel = pstrdup("</b>");
+ if (!prs->fragdelim)
+ prs->fragdelim = pstrdup(" ... ");
prs->startsellen = strlen(prs->startsel);
prs->stopsellen = strlen(prs->stopsel);
+ prs->fragdelimlen = strlen(prs->fragdelim);

PG_RETURN_POINTER(prs);
}
+
Index: src/backend/tsearch/ts_parse.c
===================================================================
RCS file: /home/postgres/devel/pgsql-cvs/pgsql/src/backend/tsearch/ts_parse.c,v
retrieving revision 1.8
diff -c -r1.8 ts_parse.c
*** src/backend/tsearch/ts_parse.c 16 May 2008 16:31:01 -0000 1.8
--- src/backend/tsearch/ts_parse.c 2 Aug 2008 04:22:51 -0000
***************
*** 583,590 ****
generateHeadline(HeadlineParsedText *prs)
{
text *out;
- int len = 128;
char *ptr;
HeadlineWordEntry *wrd = prs->words;

out = (text *) palloc(len);
--- 583,593 ----
generateHeadline(HeadlineParsedText *prs)
{
text *out;
char *ptr;
+ int len = 128;
+ int numfragments = 0;
+ int2 infrag = 0;
+
HeadlineWordEntry *wrd = prs->words;

out = (text *) palloc(len);
***************
*** 592,598 ****

while (wrd - prs->words < prs->curwords)
{
! while (wrd->len + prs->stopsellen + prs->startsellen + (ptr - ((char *) out)) >= len)
{
int dist = ptr - ((char *) out);

--- 595,601 ----

while (wrd - prs->words < prs->curwords)
{
! while (wrd->len + prs->stopsellen + prs->startsellen + prs->fragdelimlen + (ptr - ((char *) out)) >= len)
{
int dist = ptr - ((char *) out);

***************
*** 603,608 ****
--- 606,625 ----

if (wrd->in && !wrd->repeated)
{
+ if (!infrag)
+ {
+
+ /* start of a new fragment */
+ infrag = 1;
+ numfragments ++;
+ /* add a fragment delimitor if this is after the first one */
+ if (numfragments > 1)
+ {
+ memcpy(ptr, prs->fragdelim, prs->fragdelimlen);
+ ptr += prs->fragdelimlen;
+ }
+
+ }
if (wrd->replace)
{
*ptr = ' ';
***************
*** 625,631 ****
--- 642,652 ----
}
}
else if (!wrd->repeated)
+ {
+ if (infrag)
+ infrag = 0;
pfree(wrd->word);
+ }

wrd++;
}
Index: src/test/regress/sql/tsearch.sql
===================================================================
RCS file: /home/postgres/devel/pgsql-cvs/pgsql/src/test/regress/sql/tsearch.sql,v
retrieving revision 1.9
diff -c -r1.9 tsearch.sql
*** src/test/regress/sql/tsearch.sql 16 May 2008 16:31:02 -0000 1.9
--- src/test/regress/sql/tsearch.sql 2 Aug 2008 15:19:39 -0000
***************
*** 208,213 ****
--- 208,265 ----
</html>',
to_tsquery('english', 'sea&foo'), 'HighlightAll=true');

+ --Check if headline fragments work
+ SELECT ts_headline('english', '
+ Day after day, day after day,
+ We stuck, nor breath nor motion,
+ As idle as a painted Ship
+ Upon a painted Ocean.
+ Water, water, every where
+ And all the boards did shrink;
+ Water, water, every where,
+ Nor any drop to drink.
+ S. T. Coleridge (1772-1834)
+ ', to_tsquery('english', 'ocean'), 'MaxFragments=1');
+
+ --Check if more than one fragments are displayed
+ SELECT ts_headline('english', '
+ Day after day, day after day,
+ We stuck, nor breath nor motion,
+ As idle as a painted Ship
+ Upon a painted Ocean.
+ Water, water, every where
+ And all the boards did shrink;
+ Water, water, every where,
+ Nor any drop to drink.
+ S. T. Coleridge (1772-1834)
+ ', to_tsquery('english', 'Coleridge & stuck'), 'MaxFragments=2');
+
+ --Fragments when there all query words are not in the document
+ SELECT ts_headline('english', '
+ Day after day, day after day,
+ We stuck, nor breath nor motion,
+ As idle as a painted Ship
+ Upon a painted Ocean.
+ Water, water, every where
+ And all the boards did shrink;
+ Water, water, every where,
+ Nor any drop to drink.
+ S. T. Coleridge (1772-1834)
+ ', to_tsquery('english', 'ocean & seahorse'), 'MaxFragments=1');
+
+ --FragmentDelimiter option
+ SELECT ts_headline('english', '
+ Day after day, day after day,
+ We stuck, nor breath nor motion,
+ As idle as a painted Ship
+ Upon a painted Ocean.
+ Water, water, every where
+ And all the boards did shrink;
+ Water, water, every where,
+ Nor any drop to drink.
+ S. T. Coleridge (1772-1834)
+ ', to_tsquery('english', 'Coleridge & stuck'), 'MaxFragments=2,FragmentDelimiter=***');
+
--Rewrite sub system

CREATE TABLE test_tsquery (txtkeyword TEXT, txtsample TEXT);
Index: src/test/regress/expected/tsearch.out
===================================================================
RCS file: /home/postgres/devel/pgsql-cvs/pgsql/src/test/regress/expected/tsearch.out,v
retrieving revision 1.14
diff -c -r1.14 tsearch.out
*** src/test/regress/expected/tsearch.out 16 May 2008 16:31:02 -0000 1.14
--- src/test/regress/expected/tsearch.out 2 Aug 2008 15:27:21 -0000
***************
*** 632,637 ****
--- 632,729 ----
</html>
(1 row)

+ --Check if headline fragments work
+ SELECT ts_headline('english', '
+ Day after day, day after day,
+ We stuck, nor breath nor motion,
+ As idle as a painted Ship
+ Upon a painted Ocean.
+ Water, water, every where
+ And all the boards did shrink;
+ Water, water, every where,
+ Nor any drop to drink.
+ S. T. Coleridge (1772-1834)
+ ', to_tsquery('english', 'ocean'), 'MaxFragments=1');
+ ts_headline
+ ------------------------------------
+ after day,
+ We stuck, nor breath nor motion,
+ As idle as a painted Ship
+ Upon a painted <b>Ocean</b>.
+ Water, water, every where
+ And all the boards did shrink;
+ Water, water, every where,
+ Nor any drop
+ (1 row)
+
+ --Check if more than one fragments are displayed
+ SELECT ts_headline('english', '
+ Day after day, day after day,
+ We stuck, nor breath nor motion,
+ As idle as a painted Ship
+ Upon a painted Ocean.
+ Water, water, every where
+ And all the boards did shrink;
+ Water, water, every where,
+ Nor any drop to drink.
+ S. T. Coleridge (1772-1834)
+ ', to_tsquery('english', 'Coleridge & stuck'), 'MaxFragments=2');
+ ts_headline
+ ----------------------------------------------
+ after day, day after day,
+ We <b>stuck</b>, nor breath nor motion,
+ As idle as a painted Ship
+ Upon a painted Ocean.
+ Water, water, every where
+ And all the boards did shrink;
+ Water, water, every where ... drop to drink.
+ S. T. <b>Coleridge</b>
+ (1 row)
+
+ --Fragments when there all query words are not in the document
+ SELECT ts_headline('english', '
+ Day after day, day after day,
+ We stuck, nor breath nor motion,
+ As idle as a painted Ship
+ Upon a painted Ocean.
+ Water, water, every where
+ And all the boards did shrink;
+ Water, water, every where,
+ Nor any drop to drink.
+ S. T. Coleridge (1772-1834)
+ ', to_tsquery('english', 'ocean & seahorse'), 'MaxFragments=1');
+ ts_headline
+ ------------------------------------
+
+ Day after day, day after day,
+ We stuck, nor breath nor motion,
+ As idle as
+ (1 row)
+
+ --FragmentDelimiter option
+ SELECT ts_headline('english', '
+ Day after day, day after day,
+ We stuck, nor breath nor motion,
+ As idle as a painted Ship
+ Upon a painted Ocean.
+ Water, water, every where
+ And all the boards did shrink;
+ Water, water, every where,
+ Nor any drop to drink.
+ S. T. Coleridge (1772-1834)
+ ', to_tsquery('english', 'Coleridge & stuck'), 'MaxFragments=2,FragmentDelimiter=***');
+ ts_headline
+ --------------------------------------------
+ after day, day after day,
+ We <b>stuck</b>, nor breath nor motion,
+ As idle as a painted Ship
+ Upon a painted Ocean.
+ Water, water, every where
+ And all the boards did shrink;
+ Water, water, every where***drop to drink.
+ S. T. <b>Coleridge</b>
+ (1 row)
+
--Rewrite sub system
CREATE TABLE test_tsquery (txtkeyword TEXT, txtsample TEXT);
\set ECHO none
Index: doc/src/sgml/textsearch.sgml
===================================================================
RCS file: /home/postgres/devel/pgsql-cvs/pgsql/doc/src/sgml/textsearch.sgml,v
retrieving revision 1.44
diff -c -r1.44 textsearch.sgml
*** doc/src/sgml/textsearch.sgml 16 May 2008 16:31:01 -0000 1.44
--- doc/src/sgml/textsearch.sgml 2 Aug 2008 15:12:10 -0000
***************
*** 1100,1105 ****
--- 1100,1128 ----
</listitem>
<listitem>
<para>
+ <literal>MaxFragments</literal>: maximum number of text excerpts
+ or fragments that matches the query words. It also triggers a
+ different headline generation function than the default one. This
+ function finds text fragments with as many query words as possible and
+ stretches those fragments around the query words. As a result
+ query words are close to the middle of each fragment and have words on
+ each side. Each fragment will be of at most MaxWords and will not
+ have words of size less than or equal to ShortWord at the start or
+ end of a fragment. If all query words are not found in the document,
+ then a single fragment of MinWords will be displayed.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>FragmentDelimiter</literal>: When more than one fragments are
+ displayed, then the fragments will be separated by this delimiter. This
+ option is effective only if MaxFragments is greater than 1 and there are
+ more than one fragments to be diplayed. This option has no effect on the
+ default headline generation function.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
<literal>HighlightAll</literal>: Boolean flag; if
<literal>true</literal> the whole document will be highlighted.
</para>
***************
*** 1109,1115 ****
Any unspecified options receive these defaults:

<programlisting>
! StartSel=&lt;b&gt;, StopSel=&lt;/b&gt;, MaxWords=35, MinWords=15, ShortWord=3, HighlightAll=FALSE
</programlisting>
</para>

--- 1132,1138 ----
Any unspecified options receive these defaults:

<programlisting>
! StartSel=&lt;b&gt;, StopSel=&lt;/b&gt;, MaxFragments=0, FragmentDelimiter=" ... ", MaxWords=35, MinWords=15, ShortWord=3, HighlightAll=FALSE
</programlisting>
</para>

-- does it work

testdb=# select ts_headline('The purpose of FTS is to find documents, which satisfy
query and optionally return them in some order. Most common case: Find
documents containing all query terms and return them in order of their
similarity to the query.', to_tsquery('english', 'documents'),
'MaxFragments=1');
ts_headline
-------------------------------------------------------------------------------
purpose of FTS is to find <b>documents</b>, which satisfy
query and optionally return them in some order. Most common case: Find
<b>documents</b> containing all query terms and return them in order of their
similarity
(1 row)

-- does it respect MinWords

testdb=# select ts_headline('The purpose of FTS is to find documents, which satisfy query and optionally return them in some order. Most common case: Find documents containing all query terms and return them in order of their similarity to the query.', to_tsquery('english', 'nosuchterm'), 'MaxFragments=1,MinWords=5');
ts_headline
-----------------------
The purpose of FTS is

-- does it respect MaxWords

testdb=# select ts_headline('The purpose of FTS is to find documents, which satisfy query and optionally return them in some order. Most common case: Find documents containing all query terms and return them in order of their similarity to the query.', to_tsquery('english', 'document'), 'MaxFragments=1,MinWords=5,MaxWords=8');
ts_headline
------------------------------------------------------------------
find <b>documents</b>, which satisfy query and optionally return

-- does it exclude ShortWord in the end ( "in" is excluded)

testdb=# select ts_headline('The purpose of FTS is to find documents, which satisfy query and optionally return them in some order. Most common case: Find documents containing all query terms and return them in order of their similarity to the query.', to_tsquery('english', 'document'), 'MaxFragments=1,MinWords=5,MaxWords=10');
ts_headline
-----------------------------------------------------------------------
find <b>documents</b>, which satisfy query and optionally return them
(1 row)

-- does it exclude ShortWord in the front ( "The" is excluded)

testdb=# select ts_headline('The purpose of FTS is to find documents, which satisfy query and optionally return them in some order. Most common case: Find documents containing all query terms and return them in order of their similarity to the query.', to_tsquery('english', 'document'), 'MaxFragments=1,MinWords=5,MaxWords=13');
ts_headline
---------------------------------------------------------------------------------------
purpose of FTS is to find <b>documents</b>, which satisfy query and optionally return

-- when multiple words are used, the cover is shown in middle of the fragment (cover size <= MaxWords)

testdb=# select ts_headline('The purpose of FTS is to find documents, which satisfy query and optionally return them in some order. Most common case: Find documents containing all query terms and return them in order of their similarity to the query.', to_tsquery('english', 'optional & order'), 'MaxFragments=1,MinWords=5,MaxWords=10');
ts_headline
---------------------------------------------------------------------------
query and <b>optionally</b> return them in some <b>order</b>. Most common

-- does it choose the smallest cover (there are three covers between positions (7,17), (17, 22), and (22, 31). The chosen one is (17, 22))

testdb=# select ts_headline('The purpose of FTS is to find documents, which satisfy query and optionally return them in some order. Most common case: Find documents containing all query terms and return them in order of their similarity to the query.', to_tsquery('english', 'order & documents'), 'MaxFragments=1,MinWords=5,MaxWords=10');
ts_headline
---------------------------------------------------------------------------------
some <b>order</b>. Most common case: Find <b>documents</b> containing all query


-- does it show multiple fragments

testdb=# select ts_headline('The purpose of FTS is to find documents, which satisfy query and optionally return them in some order. Most common case: Find documents containing all query terms and return them in order of their similarity to the query.', to_tsquery('english', 'query & documents'), 'MaxFragments=2,MinWords=5,MaxWords=10');
ts_headline
------------------------------------------------------------------------------------------------------------------------------------------------------------------
find <b>documents</b>, which satisfy <b>query</b> and optionally return them ... common case: Find <b>documents</b> containing all <b>query</b> terms and return
(1 row)

-- does it exclude overlapping covers (even when MaxFragments = 2, the overlapping covers are excluded)

testdb=# select ts_headline('The purpose of FTS is to find documents, which satisfy query and optionally return them in some order. Most common case: Find documents containing all query terms and return them in order of their similarity to the query.', to_tsquery('english', 'query & order & documents'), 'MaxFragments=2,MinWords=5,MaxWords=15');
ts_headline
-----------------------------------------------------------------------------------------------------------------
them in some <b>order</b>. Most common case: Find <b>documents</b> containing all <b>query</b> terms and return
(1 row)


-- when cover size is greater than MaxWords, does it break covers into fragments (first with MaxFragments = 1 and then with maxFragments = 2)

testdb=# select ts_headline('The purpose of FTS is to find documents, which satisfy query and optionally return them in some order. Most common case: Find documents containing all query terms and return them in order of their similarity to the query.', to_tsquery('english', 'purpose & similarity'), 'MaxFragments=1,MinWords=5,MaxWords=10');
ts_headline
-----------------------------------------------------------------
<b>purpose</b> of FTS is to find documents, which satisfy query
(1 row)

testdb=# select ts_headline('The purpose of FTS is to find documents, which satisfy query and optionally return them in some order. Most common case: Find documents containing all query terms and return them in order of their similarity to the query.', to_tsquery('english', 'purpose & similarity'), 'MaxFragments=2,MinWords=5,MaxWords=10');
ts_headline
-------------------------------------------------------------------------------------------------------------------
<b>purpose</b> of FTS is to find documents, which satisfy query ... order of their <b>similarity</b> to the query

-- using Oleg suggestions for testing some boundry cases

testdb=# select ts_headline('1 2 3 4 5 1 2 3 1','1&3'::tsquery, 'MaxFragments=1');
ts_headline
-------------------
<b>3</b> <b>1</b>

testdb=# select ts_headline('1 2 3 4 5 1 2 3 1','1&3'::tsquery, 'MaxFragments=2');
ts_headline
-------------------------------------------
<b>1</b> 2 <b>3</b> ... <b>3</b> <b>1</b>

testdb=# select ts_headline('1 2 3 4 5 1 2 3 1','1&2'::tsquery, 'MaxFragments=2');
ts_headline
-----------------------------------------
<b>1</b> <b>2</b> ... <b>1</b> <b>2</b>

testdb=# select ts_headline('1 2 3 4 5 1 2 3 1','2'::tsquery, 'MaxFragments=2');
ts_headline
-----------------------
<b>2</b> ... <b>2</b>

testdb=# select ts_headline('1 2 3 4 5 1 2 3 1','1&4'::tsquery, 'MaxFragments=2');
ts_headline
---------------------
<b>4</b> 5 <b>1</b>

-- Checking FragmentDelimiter

testdb=# select ts_headline('1 2 3 4 5 1 2 3 1','2'::tsquery, 'MaxFragments=2,FragmentDelimiter=***');
ts_headline
---------------------
<b>2</b>***<b>2</b>
(1 row)

Sorry for the delay. Here is the patch with FragmentDelimiter option.
It requires an extra option in HeadlineParsedText and uses that option
during generateHeadline.

Implementing notion of fragments in HeadlineParsedText and a separate
function to join them seems more complicated. So for the time being I
just dump a FragmentDelimiter whenever a new fragment (other than the
first one) starts.

The patch also contains the updated regression tests/results and also a
new test for FragmentDelimiter option. It also contains the
documentation for the new options.

I have also attached a separate file that tests different aspects of the
new headline generation function.

Let me know if anything else is needed.

-Sushant.

On Thu, 2008-07-24 at 00:28 +0400, Oleg Bartunov wrote:
> On Wed, 23 Jul 2008, Sushant Sinha wrote:
>
> > I guess it is more readable to add cover separator at the end of a fragment
> > than in the front. Let me know what you think and I can update it.
>
> FragmentsDelimiter should *separate* fragments and that says all.
> Not very difficult algorithmic problem, it's like perl's
> join(FragmentsDelimiter, @array)
>
> >
> > I think the right place for cover separator is in the structure
> > HeadlineParsedText just like startsel and stopsel. This will enable users to
> > specify their own cover separators. But this will require changes to the
> > structure as well as to the generateHeadline function. This option will not
> > also play well with the default headline generation function.
>
> As soon as we introduce FragmentsDelimiter we should make it
> configurable.
>
> >
> > The default MaxWords = 35 seems a bit high for this headline generation
> > function and 20 seems to be more reasonable. Any thoughts?
>
> I think we should not change default value because it could change
> behaviour of existing applications. I'm not sure if it'd be useful and
> possible to define default values in CREATE TEXT SEARCH PARSER
>
> >
> > -Sushant.
> >
> > On Wed, Jul 23, 2008 at 7:44 AM, Oleg Bartunov <oleg@sai.msu.su> wrote:
> >
> >> btw, is it intentional to have '....' in headline ?
> >>
> >> =# select ts_headline('1 2 3 4 5 1 2 3 1','1&4'::tsquery,'MaxFragments=1');
> >> ts_headline
> >> -------------------------
> >> ... <b>4</b> 5 <b>1</b>
> >>
> >>
> >>
> >> Oleg
> >>
> >> On Wed, 23 Jul 2008, Teodor Sigaev wrote:
> >>
> >> Let me know of any other changes that are needed.
> >>>>
> >>>
> >>> Looks like ready to commit, but documentation is needed.
> >>>
> >>>
> >>>
> >> Regards,
> >> Oleg
> >> _____________________________________________________________
> >> Oleg Bartunov, Research Scientist, Head of AstroNet (www.astronet.ru),
> >> Sternberg Astronomical Institute, Moscow University, Russia
> >> Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/<http://www.sai.msu.su/%7Emegera/>
> >> phone: +007(495)939-16-83, +007(495)939-23-83
> >>
> >
>
> Regards,
> Oleg
> _____________________________________________________________
> Oleg Bartunov, Research Scientist, Head of AstroNet (www.astronet.ru),
> Sternberg Astronomical Institute, Moscow University, Russia
> Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/
> phone: +007(495)939-16-83, +007(495)939-23-83

Re: [HACKERS] Parsing of pg_hba.conf and authentication inconsistencies

Tom Lane wrote:

> Idle thought: maybe what would really make sense here is a "lint"
> for PG config files, which you'd run as a standalone program and
> which would look for not only clear errors but questionable things
> to warn about. For instance it might notice multiple pg_hba.conf
> entries for the same IP addresses, check whether an LDAP server
> can be connected to, check that all user/group/database names
> used in the file actually exist, etc. These are things that we'd
> certainly not put into any load- or reload-time tests.

I like this idea.

postgres --check-hba-file /path/to/hba.conf
postgres --check-conf-file /path/to/postgresql.conf

(I think it's better to reuse the same postmaster executable, because
that way it's easier to have the same parsing routines.)

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Re: [HACKERS] Parsing of pg_hba.conf and authentication inconsistencies

Magnus Hagander <magnus@hagander.net> writes:
> Is there any actual gain by not doing the parsing in the postmaster,

Define "parsing". There's quite a lot of possible errors in pg_hba
that it would be totally unreasonable for the postmaster to detect.
We could catch some simple problems at file load time, perhaps,
but those usually aren't the ones that cause trouble for people.

On the whole, I am against putting any more functionality into the
main postmaster process than absolutely has to be there. Every
new function you put onto it is another potential source of
service-outage-inducing bugs.

> I've also noticed that authentication methods error out in different
> ways when they are not supported.

Yeah, that's something that should be made more consistent.


Idle thought: maybe what would really make sense here is a "lint"
for PG config files, which you'd run as a standalone program and
which would look for not only clear errors but questionable things
to warn about. For instance it might notice multiple pg_hba.conf
entries for the same IP addresses, check whether an LDAP server
can be connected to, check that all user/group/database names
used in the file actually exist, etc. These are things that we'd
certainly not put into any load- or reload-time tests.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Re: [ADMIN] fuzzy search

giuseppe.derossi@email.it writes:
> I'd like to know if there is a way to retrieve similar results by a fuzzy
> search.

There's some functions in contrib/fuzzystrmatch that might help ...

regards, tom lane

--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin

Re: [PATCHES] pg_dump additional options for performance

chris <cbbrowne@ca.afilias.info> writes:
> Do we need to wait until a fully-parallelizing pg_restore is
> implemented before adding this functionality to pg_dump?

They're independent problems ... and I would venture that parallel
dump is harder.

> Further, it's actually not obvious that we *necessarily* care about
> parallelizing loading data. The thing that happens every day is
> backups.

Maybe so, but I would say that routine backups shouldn't be designed
to eat 100% of your disk bandwidth anyway --- they'd be more like
background tasks.

regards, tom lane

--
Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-patches

Re: [pgsql-de-allgemein] Erlaubte Zeichen in Datenbanknamen

Hallo Andreas,

A. Kretschmer schrieb:
>> Gibt es noch weitere erlaubte Zeichen oder andere Sachen die ich bei
>> der Prüfung beachten muss?
> IIRC nicht, aber ich versteh nicht ganz, warum Du den Namen einer DB als
> Benutzereingabe prüfen willst/mußt. Der DB-Name ist doch eher, ähm,
> statisch.
Ja, bei der Software handelt es sich um ein ERP (Enterprice Resource
Planning) Tool für kleine und mittelgroße Unternehmen.
Wenn man eine neue einzelne Firma anlegt, dann werden alle Daten in
eine Postgresdatenbank eingefügt. Deren Name muss der Administrator
angeben um sie neu erstellen zu lassen. Wir haben diesen Dialog in
das GUI gelegt, um die Konfiguration zu vereinfachen.
Bei der Eingabe des Datenbank-Namens wird gleich auf Validität
geprüft. (Also es sind nur alpha-nummerische Zeichen erlaubt und
Unterstrich, das erste Zeichen muss ein Buchstabe sein, die Anzahl
der eingegebenen Zeichen ist auf 63 begrenzt.) Quasi
Fehlervermeidung, statt Fehlermeldung...

Viele Grüße
Udo Spallek

--
Sent via pgsql-de-allgemein mailing list (pgsql-de-allgemein@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-de-allgemein

Re: [BUGS] BUG #4338: Order by seems to trim some characters before sort

"Domingo Alvarez Duarte" <mingodad@gmail.com> writes:
> It seems that postgresql is issuing a kind of trim on the column value
> before sort/compare, because it's ignoring spaces and '-' wich I use
> propositally to move some values to front.

> Why postgresql is behaving this way ?

Because the LC_COLLATE setting is telling it to. If you try sorting
the same data with sort(1) I'll bet you get the same result. This
is standard behavior for quite a lot of locale settings.

If you don't like the result then you need to switch to a different
locale setting, probably "C". Unfortunately, that requires dump,
re-initdb with the correct locale option, reload :-(

regards, tom lane

--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Re: [GENERAL] Advice on implementing counters in postgreSQL

On Sat, Aug 02, 2008 at 09:23:31AM +0200, Marco Bizzarri wrote:
> Hi all.
>
> I need to keep a numer of counters in my application; my counters
> are currently stored in a table:
>
> name | next_value | year
>
> The counters must be progressive numbers with no holes in between
> them, and they must restart from 1 every year.

Here's a backward-compatible way to do this:

http://www.varlena.com/GeneralBits/130.php

Cheers,
David.
--
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david.fetter@gmail.com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: [pgsql-es-ayuda] conectar desde Java

Estimado,
 
Tengo algo de experiencia con J2EE,Postgresql y AJAX cualquier duda sobre como aplicar esta tecnologia me escribes a mi correo gs.salinas@gmail.com y si puedo ayudarte lo hare con todo gusto.
 
Hago extensiva esta invitacion a cualquier hermano del OPEN SOURCE.
 
Un saludo,
German Salinas

El 2 de agosto de 2008 7:29, Fernando Aguada<fernandoaguada@yahoo.com.ar>escribió:
Hola
      JPA, Hibernate son framework de persistencia, lo que hacen es proveer una capa que conecta con un motor de bases de datos cualquiera, de esta manera, podrias cambiar de un motor de datos a otro sin que te veas en la necesidad de cambiar nada en tu aplicacion.
Al menos asi lo entiendo yo.

Saludos Cordiales.


----- Original Message ----- From: "Edgar Enriquez" <edgarpostgres@yahoo.es>
To: "Marco Castillo" <mabcastillo@gmail.com>; "lista postgres" <pgsql-es-ayuda@postgresql.org>
Sent: Saturday, August 02, 2008 6:39 AM
Subject: Re: [pgsql-es-ayuda] conectar desde Java





yo también nececito crear una aplicación java para conectarme a una BDD postgres, actualmente tengo todo sobre JDBC, pero para utilizar crear un servidor me digeron que nececito instalar Glassfish y crear allí las conexiones pero luego se habla de JPA, Hibernate y toplink (que aparentementa hacen lo mismo) pero al final la conexión la termina haciento el JDBC de postgres, alguien sabe cual es la diferencia? porque además parece que glassfish maneja la concurrencia (algo que tradicionalmente se hace en Postgres)

Saludos a todos y gracia por sus respuestas



----- Mensaje original ----
De: Marco Castillo <mabcastillo@gmail.com>
Para: "pgsql-es-ayuda@postgresql.org" <pgsql-es-ayuda@postgresql.org>
Enviado: viernes, 1 de agosto, 2008 21:04:54
Asunto: Re: [pgsql-es-ayuda] conectar desde Java


Pues la idea del foro es aprender y ayudarnos mutuamente (mi percepción personal). Aca habemos varios que trabajamos en Java y en PostgreSQL. Haz tus preguntas aca y te echamos una mano.

Saludos

Marco


2008/8/1 Fabio Arias <fharias@gmail.com>

Cualquier cosa que necesitas sobre java+postgresql me escribes con mucho gusto te ayudaré

Bye


El 1 de agosto de 2008 9:50, Gabriel Ferro<gabrielrferro@yahoo.com.ar>escribió:

ok, mil gracias a todo. logre hacerlo, aunque me cuesta, considerando que no se nada de java y soy de la vieja escuela donde objetos y clases no existian.
¿alguien conoce una lista buena de java+postgre en español?


________________________________

¡Buscá desde tu celular!
Yahoo! oneSEARCH ahora está en Claro
http://ar.mobile.yahoo.com/onesearch


--
Fabio Hernando Arias Vera
Cel. 314 411 7776


    ______________________________________________
Enviado desde Correo Yahoo! La bandeja de entrada más inteligente.
--
TIP 3: Si encontraste la respuesta a tu problema, publícala, otros te lo agradecerán

Re: [HACKERS][PATCHES] odd output in restore mode

Simon Riggs wrote:
> Well, this is a strange conclusion, leaving me slightly bemused.
>
> The discussion between Andrew and I at PGcon concluded that we would
> * document which other tools to use
> * remove the delay
>
> Now we have rejected the patch which does that, but then re-requested
> the exact same thing again.
>
> The patch interprets "remove the delay" as "remove the delay in a way
> which will not screw up existing users of pg_standby when they upgrade".
> Doing that requires us to have a configurable delay, which defaults to
> the current behaviour, but that can be set to zero (the recommended
> way). Which is what the patch implements.
>
> Andrew, Heikki: ISTM its time to just make the changes yourselves. This
> is just going round and round to no benefit. This doesn't warrant such a
> long discussion and review process.
>

You ought to know by now that the length and ferocity of the discussion
bears no relation at all to the importance of the subject ;-)

Personally, I think it's reasonable to provide the delay as long as it's
switchable, although I would have preferred zero to be the default. If
we remove it altogether then we force bigger changes on people who are
currently using Windows copy. But I can live with that since changing
their archive_command is the better path by far anyway, either to use
Gnu cp or the copy / rename trick.

cheers

andrew

--
Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-patches

Re: [GENERAL] Is there any reason why "edit PostgreSQL.conf should be on my menu"

On Saturday 02 August 2008 01:12:35 am Craig Ringer wrote:
> John Meyer wrote:
> > Especially when I haven't edited anything yet?
>
> You might want to tell the readers here just a *little* bit more about
> your problem.
>
> Start with "what menu?!?".
>
> More seriously:
>
> - What is your operating system
> - What is the version of your operating system
> - What version of PostgreSQL do you have
> - How and from where did you obtain and install that version
>
> ... and what menu, exactly, are you talking about? Given your post I
> have to randomly guess "the Start menu in Windows XP or Vista" ... but
> that's very much a guess.
>
> Remember, nobody (except perhaps Tom Lane) around here is psychic. They
> don't know what you don't tell them, so you need to provide full and
> detailed explanations in your posts.
>
> --
> Craig Ringer

I wonder if he talking about pgadmin3? It's on the menu.

--
John Fabiani

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: [HACKERS] [WIP] patch - Collation at database level

On Sat, Aug 02, 2008 at 03:39:18PM +0200, Radek Strnad wrote:
> > I also think that the clauses you have attached to your CREATE
> > COLLATION statement (case-insensitive, accent-insensitive) are an
> > oversimplification of reality. I suggest you look up the Unicode
> > collation algorithm to learn about who collations work in practice.
>
> I already did in the very beginning of the development. The reason why I'm
> not implementing the whole Unicode collation algorithm is that this patch
> shold be sort of framework. You'll be able to use different collation
> functions not only POSIX locales so further development towards full Unicode
> collation algorithm is possible.

Agreed. Ofcourse it's a simplification of reality. POSIX locales are a
simplification of reality, but its the only form of collation currently
available to us. And quite frankly, I don't beleive postgresql should
be in the business of writing collation algorithms, we don't have the
expertese.

FWIW, I think case-insensitive and accent-insensitive are useful modifiers
that we should aim to support in the future.

> At the end of the next week I'll publish my bachelor thesis concerning this
> topic where everything will be explained in details so stay tuned.

Good luck!

Have a nice day,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.

Re: [HACKERS] [WIP] patch - Collation at database level

Hello,

the main reason why I've submitted the patch was to start a discussion and know other people's opinion on this problem.

On Tue, Jul 29, 2008 at 10:41 AM, Peter Eisentraut <peter_e@gmx.net> wrote:

Where are the collations going to come from?  

There will be two new catalogs - pg_collate and pg_charset. Each of them will be filled with ANSI standard collations and charsets (ISO8BIT, LATIN1, UTF-8..) and alternatively with default collation set when creating. For instance if you create database cluster with initdb and specify en_US.utf8 there will be standard rows (ISO8BIT, LATIN1, UTF-8..) + one row with en_US.utf8 in template0. Then you can connect to template0 and create other collations if your POSIX locales support them and use them one per each database.

Have the various build and distributions issues been thought about?

Yes. Since POSIX locales doesn't guarantee any collation there will be hard-coded collations implemented regarding ANSI collation standard. Others can be set by command CREATE COLLATION.

 How are they going to be configured (not the SQL syntax, but how will the configuration be applied)?

pg_type, pg_attribute, pg_namespace of each database will be extended with collation oid column that will be specifying collation.

 How are the collations going to be applied at run-time?
 
Collation will be set when connecting to the database with setlocale(LC_COLLATION, XXX) and setlocale(LC_CTYPE, XXX)
 
 How are you going to handle locale and encoding conflicts?

Since I'm currently implementing collation support per database I don't think this is an issue. (It will be in the future I know.)
 
 I also think that the clauses you have attached to your CREATE COLLATION statement (case-insensitive,
accent-insensitive) are an oversimplification of reality.  I suggest you look
up the Unicode collation algorithm to learn about who collations work in
practice.

I already did in the very beginning of the development. The reason why I'm not implementing the whole Unicode collation algorithm is that this patch shold be sort of framework. You'll be able to use different collation functions not only POSIX locales so further development towards full Unicode collation algorithm is possible.

At the end of the next week I'll publish my bachelor thesis concerning this topic where everything will be explained in details so stay tuned.
 
Regards

Radek Strnad

Re: [HACKERS] Parsing of pg_hba.conf and authentication inconsistencies

"Magnus Hagander" <magnus@hagander.net> writes:

> I've also noticed that authentication methods error out in different
> ways when they are not supported. For example, if I try to use Kerberos
> without having it compiled in, I get an error when a client tries to
> connect (because we compile in stub functions for the authentication
> that just throw an error). But if I use pam, I get an "missing or
> erroneous pg_hba.conf file" error (because we #ifdef out the entire
> option all over the place). I'd like to make these consistent - but
> which one of them do people prefer?

Generally I prefer having stub functions which error out because it means
other code doesn't need lots of ifdef's around the call sites.

However it would be nice to throw an error or at least a warning when parsing
the file instead of pretending everything's ok. Perhaps authentication methods
should have a function to check whether the method is supported which is
called when the file is parsed.

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Ask me about EnterpriseDB's PostGIS support!

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Re: [GENERAL] Advice on implementing counters in postgreSQL

On Sat, Aug 2, 2008 at 11:04 AM, Craig Ringer
<craig@postnewspapers.com.au> wrote:
> Marco Bizzarri wrote:
>> Thanks for the advice, Craig.
>>
>> I'm on a number of different PostgreSQL versions, ranging from 7.4 to
>> 8.3, so I've to retain, where possible, compatibility with older
>> versions.
>>
>> Is this better on a transaction/serialization point of view?
>
> As far as I know it's not significantly different, though I expect it'd
> be somewhat more efficient. However, support for UPDATE ... RETURNING
> was only added in 8.2 (or somewhere around there) anyway, so if you need
> to work with old versions like 7.4 it's no good to you anyway.
>
> I take it there's no way you can present the gapless identifiers at the
> application level, leaving the actual tables with nice SEQUENCE
> numbering? Or, alternately, insert them by timestamp/sequence (leaving
> the user-visible ID null) then have another transaction come back and
> assign them their gapless numeric identifiers in a single simple pass later?


> You're really going to suffer on concurrency if you have to acquire
> values from a gapless sequence as part of a transaction that does much
> other work.

Well, the sequence must be gapless, because it is an implementation of
a law regarding how documents must be recorded when they are received
or sent in a public administration.

I can accept a "degraded" performance in this topic, considering that
usually, I've between 200 and 1000 documents recorded (i.e. numbered)
in a day, which is not such a great number.


However, I would avoid as much as possible serialization errors, which
would force me to repeat the transaction.

I'm experimenting with LOCK counters IN EXCLUSIVE MODE; it seems it is
able to rip me of thos serialization errors. Do you see any problems
in this?

Regards
Marco

--
Marco Bizzarri
http://iliveinpisa.blogspot.com/

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: [NOVICE] OIDS question

Tom Lane wrote:
> Frank Bax <fbax@sympatico.ca> writes:
>> While playing with this I noticed that using the -c -o options of
>> pg_dump together; I get OIDS in COPY statements, but not in the CREATE
>> commands. Either this is a bug; or I'm missing something here...
>
> Please provide some details ... AFAICS the COPY and CREATE TABLE cases
> are testing the same conditions.

Never mind; I was missing something. It seems that pg_dump puts out SET
commands instead of using "WITH OIDS" option on "CREATE TABLE"; as in:

SET default_with_oids = true;
SET default_with_oids = false;

Sorry for the noise.

--
Sent via pgsql-novice mailing list (pgsql-novice@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice

Re: [GENERAL] why so many error when I load the data to database from a script which generated by pg_dump.

On 02/08/2008 07:22, Yi Zhao wrote:

> CONTEXT: COPY htmlcontent, line 312807: "1207327 <!DOCTYPE HTML PUBLIC
> "-//W3C//DTD
> HTML 4.0 Transitional//EN">\n<html>\n<head>\n<meta http-e..."

Would there perchance be tabs embedded in the HTML that might confuse COPY?

Ray.

------------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod@iol.ie
Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
------------------------------------------------------------------

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: [pgsql-es-ayuda] conectar desde Java

Hola
JPA, Hibernate son framework de persistencia, lo que hacen es
proveer una capa que conecta con un motor de bases de datos cualquiera, de
esta manera, podrias cambiar de un motor de datos a otro sin que te veas en
la necesidad de cambiar nada en tu aplicacion.
Al menos asi lo entiendo yo.

Saludos Cordiales.


----- Original Message -----
From: "Edgar Enriquez" <edgarpostgres@yahoo.es>
To: "Marco Castillo" <mabcastillo@gmail.com>; "lista postgres"
<pgsql-es-ayuda@postgresql.org>
Sent: Saturday, August 02, 2008 6:39 AM
Subject: Re: [pgsql-es-ayuda] conectar desde Java


yo también nececito crear una aplicación java para conectarme a una BDD
postgres, actualmente tengo todo sobre JDBC, pero para utilizar crear un
servidor me digeron que nececito instalar Glassfish y crear allí las
conexiones pero luego se habla de JPA, Hibernate y toplink (que
aparentementa hacen lo mismo) pero al final la conexión la termina haciento
el JDBC de postgres, alguien sabe cual es la diferencia? porque además
parece que glassfish maneja la concurrencia (algo que tradicionalmente se
hace en Postgres)

Saludos a todos y gracia por sus respuestas

----- Mensaje original ----
De: Marco Castillo <mabcastillo@gmail.com>
Para: "pgsql-es-ayuda@postgresql.org" <pgsql-es-ayuda@postgresql.org>
Enviado: viernes, 1 de agosto, 2008 21:04:54
Asunto: Re: [pgsql-es-ayuda] conectar desde Java


Pues la idea del foro es aprender y ayudarnos mutuamente (mi percepción
personal). Aca habemos varios que trabajamos en Java y en PostgreSQL. Haz
tus preguntas aca y te echamos una mano.

Saludos

Marco


2008/8/1 Fabio Arias <fharias@gmail.com>

Cualquier cosa que necesitas sobre java+postgresql me escribes con mucho
gusto te ayudaré

Bye


El 1 de agosto de 2008 9:50, Gabriel
Ferro<gabrielrferro@yahoo.com.ar>escribió:

ok, mil gracias a todo. logre hacerlo, aunque me cuesta, considerando que no
se nada de java y soy de la vieja escuela donde objetos y clases no
existian.
¿alguien conoce una lista buena de java+postgre en español?


________________________________

¡Buscá desde tu celular!
Yahoo! oneSEARCH ahora está en Claro
http://ar.mobile.yahoo.com/onesearch


--
Fabio Hernando Arias Vera
Cel. 314 411 7776


______________________________________________
Enviado desde Correo Yahoo! La bandeja de entrada más inteligente.

--
TIP 3: Si encontraste la respuesta a tu problema, publ�cala, otros te lo agradecer�n

Re: [GENERAL] Is there any reason why "edit PostgreSQL.conf should be on my menu"

> Especially when I haven't edited anything yet?

Because you might want to.
--
GMX startet ShortView.de. Hier findest Du Leute mit Deinen Interessen!
Jetzt dabei sein: http://www.shortview.de/wasistshortview.php?mc=sv_ext_mf@gmx

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[ADMIN] functions

Dear Friends,
I have written a function as follows. Here I need to get the sum of balance before the user provided date. The below function works well, but returns records as a set of values, rather I need individual columns. What to do?
CREATE OR REPLACE FUNCTION aa(date)
  RETURNS SETOF record AS
$BODY$SELECT docacctransactions.accgroupid, Sum(docacctransactions.credit) AS OSC, Sum(docacctransactions.debit) AS OSD
FROM docs INNER JOIN docacctransactions ON docs.docid = docacctransactions.docid
WHERE docs.includeinbalcalc=-1 AND docs.transactiontype<>1 AND docs.docdate<=$1
GROUP BY docacctransactions.accgroupid;
$BODY$
  LANGUAGE 'sql' VOLATILE
  COST 100
  ROWS 1000;
ALTER FUNCTION aa(date) OWNER TO sa;

I am using WinXP SP 2 with PostgreSQL 8.3 with ODBC
Please help.
CPK
--
Keep your Environment clean and green.



--
Keep your Environment clean and green.

[HACKERS] Parsing of pg_hba.conf and authentication inconsistencies

The way pg_hba.conf is set up to be loaded/parsed now, we have:

postmaster: open and tokenize file (load_hba(), tokenize_file()).
backend: parse lines (parse_hba) and check for matches
(check_hba/hba_getauthmethod)

This means that the code in the postmaster is very simple, and it's
shared with the caching of the role and ident files.

It also means that we don't catch any syntax errors in the hba file
until a client connects. For example, if I misspell "local" on the first
line of the file (or just leave a bogus character on a line by mistake),
no client will be able to connect. But I can still do a pg_ctl reload
loading the broken file into the backend, thus making it impossible for
anybody to connect to the database. (when there's a broken line, we
won't continue to look at further lines in the file, obviously)

Is there any actual gain by not doing the parsing in the postmaster,
other than the fact that it's slightly less shared code with the other
two files? If not, then I'd like to move that parsing there for above
reasons.


I've also noticed that authentication methods error out in different
ways when they are not supported. For example, if I try to use Kerberos
without having it compiled in, I get an error when a client tries to
connect (because we compile in stub functions for the authentication
that just throw an error). But if I use pam, I get an "missing or
erroneous pg_hba.conf file" error (because we #ifdef out the entire
option all over the place). I'd like to make these consistent - but
which one of them do people prefer?

//Magnus

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Re: [COMMITTERS] pgsql: Flip the default typispreferred setting from true to false.

On Wed, 2008-07-30 at 19:35 +0000, Tom Lane wrote:
> type categories

This whole area makes a lot more sense now.

It was so difficult to explain before...

--
Simon Riggs www.2ndQuadrant.com
PostgreSQL Training, Services and Support


--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers

[ADMIN] fuzzy search

Hi,
I've to retrieve some addresses from a "dirty" database, sometimes the same
address is written in such a different way for axample:

george washington avenue n 44

I can find:

g. washington avenue
washington avenue
g. washington av.
wHashington avAnue ( in case of error)
etc.

I'd like to know if there is a way to retrieve similar results by a fuzzy
search.

Thanks in advance

Giu
--
Email.it, the professional e-mail, gratis per te: http://www.email.it/f

Sponsor:
Impazzisci per Vasco? Scarica ora il mondo che vorrei sul cellulare
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=7750&d=20080802

--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin

Re: [ADMIN] Nls sorting in Postgresql-8.3.3

Hi!

NLS stands for "Native Language Support" and it's used for display
error/information messages in different languages.

For sorting data you need to look at LC_COLLATE (http://www.postgresql.org/docs/8.3/interactive/locale.html
)

You also need to check that you operation system support collation for
your charset/encoding as PostgreSQL relies on the underling operation-
systems collation support. FreeBSD for example does not support UTF-8
collation. On FreeBSD you need the supplied ICU (http://www.icu-project.org/
) patch supplied by portage to get working UTF-8 collation.

Best regards,
Mathias Stjernstrom

--------------------------------------
http://www.globalinn.com/


On 1 aug 2008, at 10.35, Praveen wrote:

> Hello,
> I installed postgresql-8.3.3 in our local server with option --
> enable-nls . After successful installion , I create database and
> import data.But I am not aware how to use nls sort in this
> postgresql-8.3.3 .
> Please tell me syntax how to use nls sort in query , if some one
> know.
> Thanks in advance.
> Praveen Malik.

Re: [HACKERS][PATCHES] odd output in restore mode

On Thu, 2008-07-31 at 12:32 -0400, Tom Lane wrote:
> "Heikki Linnakangas" <heikki@enterprisedb.com> writes:
> > Martin Zaun wrote:
> >> With these avenues to be explored, can the pg_standby patch on the
> >> CommitFest wiki be moved to the "Returned with Feedback" section?
>
> > Yes, I think we can conclude that we don't want this patch as it is.
> > Instead, we want a documentation patch that describes the problem,
> > mentioning that GNU cp is safe, or you can use the copy+rename trick.
>
> Right, after which we remove the presently hacked-in delay.
>
> I've updated the commitfest page accordingly.

Well, this is a strange conclusion, leaving me slightly bemused.

The discussion between Andrew and I at PGcon concluded that we would
* document which other tools to use
* remove the delay

Now we have rejected the patch which does that, but then re-requested
the exact same thing again.

The patch interprets "remove the delay" as "remove the delay in a way
which will not screw up existing users of pg_standby when they upgrade".
Doing that requires us to have a configurable delay, which defaults to
the current behaviour, but that can be set to zero (the recommended
way). Which is what the patch implements.

Andrew, Heikki: ISTM its time to just make the changes yourselves. This
is just going round and round to no benefit. This doesn't warrant such a
long discussion and review process.

--
Simon Riggs www.2ndQuadrant.com
PostgreSQL Training, Services and Support


--
Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-patches

[BUGS] BUG #4338: Order by seems to trim some characters before sort

The following bug has been logged online:

Bug reference: 4338
Logged by: Domingo Alvarez Duarte
Email address: mingodad@gmail.com
PostgreSQL version: 8.2.9
Operating system: linux
Description: Order by seems to trim some characters before sort
Details:

I have a test table:
CREATE TABLE test
(
id serial NOT NULL,
t character varying,
CONSTRAINT test_pkey PRIMARY KEY (id)
)
with tis data retrieved by: select * from test order by 2

4;"---abacate"
3;"arpa"
5;"--- bacate"
1;"dad"
2;"--dad"

I expect the result to be :

5;"--- bacate"
4;"---abacate"
2;"--dad"
3;"arpa"
1;"dad"

It seems that postgresql is issuing a kind of trim on the column value
before sort/compare, because it's ignoring spaces and '-' wich I use
propositally to move some values to front.

Why postgresql is behaving this way ?
I couldn't find an expalanation in the documentation.

--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Re: [HACKERS] Should creating a new base type require superuser status?

On Thu, 2008-07-31 at 09:39 +0100, Andrew Sullivan wrote:
> On Wed, Jul 30, 2008 at 06:07:53PM -0400, Alvaro Herrera wrote:
>
> > I do agree that creating base types should require a superuser though.
> > It too seems dangerous just on principle, even if today there's no
> > actual hole (that we already know of).
>
> I agree.

+1

--
Simon Riggs www.2ndQuadrant.com
PostgreSQL Training, Services and Support


--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Re: [pgsql-es-ayuda] conectar desde Java



yo también nececito crear una aplicación java para conectarme a una BDD postgres, actualmente tengo todo sobre JDBC, pero para utilizar crear un servidor me digeron que nececito instalar Glassfish y crear allí las conexiones pero luego se habla de JPA, Hibernate y toplink (que aparentementa hacen lo mismo) pero al final la conexión la termina haciento el JDBC de postgres, alguien sabe cual es la diferencia? porque además parece que glassfish maneja la concurrencia (algo que tradicionalmente se hace en Postgres)

Saludos a todos y gracia por sus respuestas

----- Mensaje original ----
De: Marco Castillo <mabcastillo@gmail.com>
Para: "pgsql-es-ayuda@postgresql..org" <pgsql-es-ayuda@postgresql.org>
Enviado: viernes, 1 de agosto, 2008 21:04:54
Asunto: Re: [pgsql-es-ayuda] conectar desde Java

Pues la idea del foro es aprender y ayudarnos mutuamente (mi percepción personal). Aca habemos varios que trabajamos en Java y en PostgreSQL. Haz tus preguntas aca y te echamos una mano.

Saludos

Marco

2008/8/1 Fabio Arias <fharias@gmail.com>
Cualquier cosa que necesitas sobre java+postgresql me escribes con mucho gusto te ayudaré

Bye

El 1 de agosto de 2008 9:50, Gabriel Ferro<gabrielrferro@yahoo.com.ar>escribió:
ok, mil gracias a todo. logre hacerlo, aunque me cuesta, considerando que no se nada de java y soy de la vieja escuela donde objetos y clases no existian.
¿alguien conoce una lista buena de java+postgre en español?



¡Buscá desde tu celular! Yahoo! oneSEARCH ahora está en Claro
http://ar.mobile.yahoo.com/onesearch



--
Fabio Hernando Arias Vera
Cel. 314 411 7776




Enviado desde Correo Yahoo!
La bandeja de entrada más inteligente.