Re: bug in PG_VERSION_NUM patch

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: bug in PG_VERSION_NUM patch
Date: 2006-02-28 22:33:45
Message-ID: 200602282233.k1SMXje06870@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > OK, I reread the manual page:
>
> > As each input record is read, gawk splits the record into
> > fields, using the value of the FS variable as the field
> > separator. If FS is a single character, fields are sepa-
> > rated by that character. If FS is the null string, then
> > each individual character becomes a separate field. Oth-
> > erwise, FS is expected to be a full regular expression.
>
> Hpmh. The HPUX man page for plain awk says
>
> -F fs Specify regular expression used to separate
> fields. The default is to recognize space and tab
> characters, and to discard leading spaces and
> tabs. If the -F option is used, leading input
> field separators are no longer discarded.
>
> which makes me think we are treading on mighty thin ice here --- there
> are lots of different versions of awk around, and some of them are
> probably going to treat -F '.' as a regexp.
>
> I'd suggest splitting the input with something more standardized.
> Perhaps
>
> sed 's/\./ /g' | $AWK '{printf ...

Good idea, new code applied:

# Supply a numeric version string for use by 3rd party add-ons
# awk -F is a regex on some platforms, and not on others, so make "." a tab
PG_VERSION_NUM="`echo "$PACKAGE_VERSION" | sed 's/[A-Za-z].*$//' |
tr '.' ' ' |
$AWK '{printf \"%d%02d%02d\", $1, $2, (NF >= 3) ? $3 : 0}'`"
AC_DEFINE_UNQUOTED(PG_VERSION_NUM, $PG_VERSION_NUM, [PostgreSQL version as a number])

--
Bruce Momjian http://candle.pha.pa.us
SRA OSS, Inc. http://www.sraoss.com

+ If your life is a hard drive, Christ can be your backup. +

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Mark Kirkwood 2006-02-28 22:42:37 Re: pg_config, pg_service.conf, postgresql.conf ....
Previous Message Tom Lane 2006-02-28 22:29:08 Re: bug in PG_VERSION_NUM patch