Thread: support for POSIX 1003.1-2001 hosts
The new POSIX standard is now official (IEEE Std 1003.1-2001), and it has removed support for some obsolete utility options that PostgreSQL uses in a few places. Basically, the new POSIX has removed digit-string options (e.g., "tail -1") and options beginning with "+" (e.g., "sort +1"). It also requires 'sort -o foo foo' rather than 'sort foo -o foo'. I'm using an experimental environment that insists on the new standard, so I tend to run into these problems before other people do. Here is a proposed patch, relative to PostgreSQL 7.2. I've done this by code inspection; I haven't actually run the tests. The biggest pain is with "sort", since I assume you still want to run on ancient hosts that do not support the POSIX "sort -k" syntax; the patches below fall back on the traditional syntax if the POSIX syntax does not seem to work. 2002-02-24 Paul Eggert <eggert@twinsun.com> Port to POSIX 1003.1-2001 hosts. * doc/src/sgml/runtime.sgml, configure.in: Don't use head -1. * src/test/regress/expected/select.out, src/test/regress/expected/select_distinct.out, src/test/regress/sql/select.sql, src/test/regress/sql/select_distinct.sql, src/tools/make_keywords: Don't assume sort +N. =================================================================== RCS file: doc/src/sgml/runtime.sgml,v retrieving revision 7.2 diff -pu -r7.2 doc/src/sgml/runtime.sgml --- doc/src/sgml/runtime.sgml 2002/01/20 22:19:56 7.2 +++ doc/src/sgml/runtime.sgml 2002/02/25 06:47:43 @@ -2395,7 +2395,7 @@ default:\ <filename>postmaster.pid</filename> in the data directory. So for example, to do a fast shutdown: <screen> -$ <userinput>kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`</userinput> +$ <userinput>kill -INT `sed q /usr/local/pgsql/data/postmaster.pid`</userinput> </screen> </para> <para> =================================================================== RCS file: src/test/regress/expected/select.out,v retrieving revision 7.2 diff -pu -r7.2 src/test/regress/expected/select.out --- src/test/regress/expected/select.out 2001/07/16 05:07:00 7.2 +++ src/test/regress/expected/select.out 2002/02/25 06:49:50 @@ -2,7 +2,7 @@ -- SELECT -- -- btree index --- awk '{if($1<10){print;}else{next;}}' onek.data | sort +0n -1 +-- awk '{if($1<10){print;}else{next;}}' onek.data | (sort -k 1,1n 2>/dev/null || sort +0n -1) -- SELECT onek.* WHERE onek.unique1 < 10 ORDER BY onek.unique1; @@ -21,7 +21,7 @@ SELECT onek.* WHERE onek.unique1 < 10 (10 rows) -- --- awk '{if($1<20){print $1,$14;}else{next;}}' onek.data | sort +0nr -1 +-- awk '{if($1<20){print $1,$14;}else{next;}}' onek.data | (sort -k 1,1nr 2>/dev/null || sort +0nr -1) -- SELECT onek.unique1, onek.stringu1 WHERE onek.unique1 < 20 @@ -51,7 +51,7 @@ SELECT onek.unique1, onek.stringu1 (20 rows) -- --- awk '{if($1>980){print $1,$14;}else{next;}}' onek.data | sort +1d -2 +-- awk '{if($1>980){print $1,$14;}else{next;}}' onek.data | (sort -k 2,2d 2>/dev/null || sort +1d -2) -- SELECT onek.unique1, onek.stringu1 WHERE onek.unique1 > 980 @@ -82,7 +82,7 @@ SELECT onek.unique1, onek.stringu1 -- -- awk '{if($1>980){print $1,$16;}else{next;}}' onek.data | --- sort +1d -2 +0nr -1 +-- (sort -k 2,2d -k 1,1nr 2>/dev/null || sort +1d -2 +0nr -1) -- SELECT onek.unique1, onek.string4 WHERE onek.unique1 > 980 @@ -113,7 +113,7 @@ SELECT onek.unique1, onek.string4 -- -- awk '{if($1>980){print $1,$16;}else{next;}}' onek.data | --- sort +1dr -2 +0n -1 +-- (sort -k 2,2dr -k 1,1n 2>/dev/null || sort +1dr -2 +0n -1) -- SELECT onek.unique1, onek.string4 WHERE onek.unique1 > 980 @@ -144,7 +144,7 @@ SELECT onek.unique1, onek.string4 -- -- awk '{if($1<20){print $1,$16;}else{next;}}' onek.data | --- sort +0nr -1 +1d -2 +-- (sort -k 1,1nr -k 2,2d 2>/dev/null || sort +0nr -1 +1d -2) -- SELECT onek.unique1, onek.string4 WHERE onek.unique1 < 20 @@ -175,7 +175,7 @@ SELECT onek.unique1, onek.string4 -- -- awk '{if($1<20){print $1,$16;}else{next;}}' onek.data | --- sort +0n -1 +1dr -2 +-- (sort -k 1,1n -k 2,2dr 2>/dev/null || sort +0n -1 +1dr -2) -- SELECT onek.unique1, onek.string4 WHERE onek.unique1 < 20 @@ -212,7 +212,7 @@ SELECT onek.unique1, onek.string4 -- ANALYZE onek2; -- --- awk '{if($1<10){print $0;}else{next;}}' onek.data | sort +0n -1 +-- awk '{if($1<10){print $0;}else{next;}}' onek.data | (sort -k 1,1n 2>/dev/null || sort +0n -1) -- SELECT onek2.* WHERE onek2.unique1 < 10; unique1 | unique2 | two | four | ten | twenty | hundred | thousand | twothousand | fivethous | tenthous | odd | even |stringu1 | stringu2 | string4 @@ -230,7 +230,7 @@ SELECT onek2.* WHERE onek2.unique1 < 10; (10 rows) -- --- awk '{if($1<20){print $1,$14;}else{next;}}' onek.data | sort +0nr -1 +-- awk '{if($1<20){print $1,$14;}else{next;}}' onek.data | (sort -k 1,1nr 2>/dev/null || sort +0nr -1) -- SELECT onek2.unique1, onek2.stringu1 WHERE onek2.unique1 < 20 @@ -260,7 +260,7 @@ SELECT onek2.unique1, onek2.stringu1 (20 rows) -- --- awk '{if($1>980){print $1,$14;}else{next;}}' onek.data | sort +1d -2 +-- awk '{if($1>980){print $1,$14;}else{next;}}' onek.data | (sort -k 2,2d 2>/dev/null || sort +1d -2) -- SELECT onek2.unique1, onek2.stringu1 WHERE onek2.unique1 > 980; @@ -365,7 +365,7 @@ SELECT p.name, p.age FROM person* p; -- awk '{if(NF!=2){print $3,$2;}else{print;}}' - emp.data | -- awk '{if(NF!=2){print $3,$2;}else{print;}}' - student.data | -- awk 'BEGIN{FS=" ";}{if(NF!=1){print $4,$5;}else{print;}}' - stud_emp.data | --- sort +1nr -2 +-- (sort -k 2,2nr 2>/dev/null || sort +1nr -2) -- SELECT p.name, p.age FROM person* p ORDER BY age using >, name; name | age =================================================================== RCS file: src/test/regress/expected/select_distinct.out,v retrieving revision 7.2 diff -pu -r7.2 src/test/regress/expected/select_distinct.out --- src/test/regress/expected/select_distinct.out 2000/01/06 06:40:54 7.2 +++ src/test/regress/expected/select_distinct.out 2002/02/25 06:47:43 @@ -43,7 +43,7 @@ SELECT DISTINCT string4 FROM tmp; -- -- awk '{print $3,$16,$5;}' onek.data | sort -d | uniq | --- sort +0n -1 +1d -2 +2n -3 +-- (sort -k 1,1n -k 2,2d -k 3,3n 2>/dev/null || sort +0n -1 +1d -2 +2n -3) -- SELECT DISTINCT two, string4, ten FROM tmp =================================================================== RCS file: src/test/regress/sql/select.sql,v retrieving revision 7.2 diff -pu -r7.2 src/test/regress/sql/select.sql --- src/test/regress/sql/select.sql 2001/07/16 05:07:00 7.2 +++ src/test/regress/sql/select.sql 2002/02/25 06:47:43 @@ -3,20 +3,20 @@ -- -- btree index --- awk '{if($1<10){print;}else{next;}}' onek.data | sort +0n -1 +-- awk '{if($1<10){print;}else{next;}}' onek.data | (sort -k 1,1n 2>/dev/null || sort +0n -1) -- SELECT onek.* WHERE onek.unique1 < 10 ORDER BY onek.unique1; -- --- awk '{if($1<20){print $1,$14;}else{next;}}' onek.data | sort +0nr -1 +-- awk '{if($1<20){print $1,$14;}else{next;}}' onek.data | (sort -k 1,1nr 2>/dev/null || sort +0nr -1) -- SELECT onek.unique1, onek.stringu1 WHERE onek.unique1 < 20 ORDER BY unique1 using >; -- --- awk '{if($1>980){print $1,$14;}else{next;}}' onek.data | sort +1d -2 +-- awk '{if($1>980){print $1,$14;}else{next;}}' onek.data | (sort -k 1,1d 2>/dev/null || sort +1d -2) -- SELECT onek.unique1, onek.stringu1 WHERE onek.unique1 > 980 @@ -24,7 +24,7 @@ SELECT onek.unique1, onek.stringu1 -- -- awk '{if($1>980){print $1,$16;}else{next;}}' onek.data | --- sort +1d -2 +0nr -1 +-- (sort -k 2,2d -k 1,1nr 2>/dev/null || sort +1d -2 +0nr -1) -- SELECT onek.unique1, onek.string4 WHERE onek.unique1 > 980 @@ -32,7 +32,7 @@ SELECT onek.unique1, onek.string4 -- -- awk '{if($1>980){print $1,$16;}else{next;}}' onek.data | --- sort +1dr -2 +0n -1 +-- (sort -k 2,2dr -k 1,1n 2>/dev/null || sort +1dr -2 +0n -1) -- SELECT onek.unique1, onek.string4 WHERE onek.unique1 > 980 @@ -40,7 +40,7 @@ SELECT onek.unique1, onek.string4 -- -- awk '{if($1<20){print $1,$16;}else{next;}}' onek.data | --- sort +0nr -1 +1d -2 +-- (sort -k 1,1nr -k 2,2d 2>/dev/null || sort +0nr -1 +1d -2) -- SELECT onek.unique1, onek.string4 WHERE onek.unique1 < 20 @@ -48,7 +48,7 @@ SELECT onek.unique1, onek.string4 -- -- awk '{if($1<20){print $1,$16;}else{next;}}' onek.data | --- sort +0n -1 +1dr -2 +-- (sort -k 1,1n -k 2,2dr 2>/dev/null || sort +0n -1 +1dr -2) -- SELECT onek.unique1, onek.string4 WHERE onek.unique1 < 20 @@ -63,19 +63,19 @@ SELECT onek.unique1, onek.string4 ANALYZE onek2; -- --- awk '{if($1<10){print $0;}else{next;}}' onek.data | sort +0n -1 +-- awk '{if($1<10){print $0;}else{next;}}' onek.data | (sort -k 1,1n 2>/dev/null || sort +0n -1) -- SELECT onek2.* WHERE onek2.unique1 < 10; -- --- awk '{if($1<20){print $1,$14;}else{next;}}' onek.data | sort +0nr -1 +-- awk '{if($1<20){print $1,$14;}else{next;}}' onek.data | (sort -k 1,1nr 2>/dev/null || sort +0nr -1) -- SELECT onek2.unique1, onek2.stringu1 WHERE onek2.unique1 < 20 ORDER BY unique1 using >; -- --- awk '{if($1>980){print $1,$14;}else{next;}}' onek.data | sort +1d -2 +-- awk '{if($1>980){print $1,$14;}else{next;}}' onek.data | (sort -k 2,2d 2>/dev/null || sort +1d -2) -- SELECT onek2.unique1, onek2.stringu1 WHERE onek2.unique1 > 980; @@ -99,7 +99,7 @@ SELECT p.name, p.age FROM person* p; -- awk '{if(NF!=2){print $3,$2;}else{print;}}' - emp.data | -- awk '{if(NF!=2){print $3,$2;}else{print;}}' - student.data | -- awk 'BEGIN{FS=" ";}{if(NF!=1){print $4,$5;}else{print;}}' - stud_emp.data | --- sort +1nr -2 +-- (sort -k 2,2nr 2>/dev/null || sort +1nr -2) -- SELECT p.name, p.age FROM person* p ORDER BY age using >, name; =================================================================== RCS file: src/test/regress/sql/select_distinct.sql,v retrieving revision 7.2 diff -pu -r7.2 src/test/regress/sql/select_distinct.sql --- src/test/regress/sql/select_distinct.sql 2000/01/06 06:41:55 7.2 +++ src/test/regress/sql/select_distinct.sql 2002/02/25 06:47:43 @@ -19,7 +19,7 @@ SELECT DISTINCT string4 FROM tmp; -- -- awk '{print $3,$16,$5;}' onek.data | sort -d | uniq | --- sort +0n -1 +1d -2 +2n -3 +-- (sort -k 1,1n -k 2,2d -k 3,3n 2>/dev/null || sort +0n -1 +1d -2 +2n -3) -- SELECT DISTINCT two, string4, ten FROM tmp =================================================================== RCS file: src/tools/make_keywords,v retrieving revision 7.2 diff -pu -r7.2 src/tools/make_keywords --- src/tools/make_keywords 2001/11/26 22:41:58 7.2 +++ src/tools/make_keywords 2002/02/25 06:47:43 @@ -9,5 +9,6 @@ keywords. Here is what I used: sdif /tmp/pgkeywords tools/SQL_keywords |\ sed 's/</ /' | sed 's/>/ /'|sed 's/|/\ - /' | sort -b +0 + /' |\ +(sort -b -k 1 2>/dev/null || sort -b +0) END =================================================================== RCS file: configure.in,v retrieving revision 7.2 diff -pu -r7.2 configure.in --- configure.in 2002/02/03 21:04:12 7.2 +++ configure.in 2002/02/25 06:47:43 @@ -297,7 +297,7 @@ AC_SUBST(GCC) # Create compiler version string if test x"$GCC" = x"yes" ; then - cc_string="GCC `${CC} --version | head -1`" + cc_string="GCC `${CC} --version | sed q`" else cc_string=$CC fi
This is an interesting patch, but have not heard anyone else have this problem and am hesitant to add more cost to fix something that may not be broken. Sorry. --------------------------------------------------------------------------- Paul Eggert wrote: > The new POSIX standard is now official (IEEE Std 1003.1-2001), and it > has removed support for some obsolete utility options that PostgreSQL > uses in a few places. Basically, the new POSIX has removed > digit-string options (e.g., "tail -1") and options beginning with "+" > (e.g., "sort +1"). It also requires 'sort -o foo foo' rather than > 'sort foo -o foo'. I'm using an experimental environment that insists > on the new standard, so I tend to run into these problems before other > people do. > > Here is a proposed patch, relative to PostgreSQL 7.2. I've done this > by code inspection; I haven't actually run the tests. The biggest > pain is with "sort", since I assume you still want to run on ancient > hosts that do not support the POSIX "sort -k" syntax; the patches > below fall back on the traditional syntax if the POSIX syntax does > not seem to work. > > 2002-02-24 Paul Eggert <eggert@twinsun.com> > > Port to POSIX 1003.1-2001 hosts. > > * doc/src/sgml/runtime.sgml, configure.in: Don't use head -1. > > * src/test/regress/expected/select.out, > src/test/regress/expected/select_distinct.out, > src/test/regress/sql/select.sql, > src/test/regress/sql/select_distinct.sql, > src/tools/make_keywords: Don't assume sort +N. > > =================================================================== > RCS file: doc/src/sgml/runtime.sgml,v > retrieving revision 7.2 > diff -pu -r7.2 doc/src/sgml/runtime.sgml > --- doc/src/sgml/runtime.sgml 2002/01/20 22:19:56 7.2 > +++ doc/src/sgml/runtime.sgml 2002/02/25 06:47:43 > @@ -2395,7 +2395,7 @@ default:\ > <filename>postmaster.pid</filename> in the data directory. So for > example, to do a fast shutdown: > <screen> > -$ <userinput>kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`</userinput> > +$ <userinput>kill -INT `sed q /usr/local/pgsql/data/postmaster.pid`</userinput> > </screen> > </para> > <para> > =================================================================== > RCS file: src/test/regress/expected/select.out,v > retrieving revision 7.2 > diff -pu -r7.2 src/test/regress/expected/select.out > --- src/test/regress/expected/select.out 2001/07/16 05:07:00 7.2 > +++ src/test/regress/expected/select.out 2002/02/25 06:49:50 > @@ -2,7 +2,7 @@ > -- SELECT > -- > -- btree index > --- awk '{if($1<10){print;}else{next;}}' onek.data | sort +0n -1 > +-- awk '{if($1<10){print;}else{next;}}' onek.data | (sort -k 1,1n 2>/dev/null || sort +0n -1) > -- > SELECT onek.* WHERE onek.unique1 < 10 > ORDER BY onek.unique1; > @@ -21,7 +21,7 @@ SELECT onek.* WHERE onek.unique1 < 10 > (10 rows) > > -- > --- awk '{if($1<20){print $1,$14;}else{next;}}' onek.data | sort +0nr -1 > +-- awk '{if($1<20){print $1,$14;}else{next;}}' onek.data | (sort -k 1,1nr 2>/dev/null || sort +0nr -1) > -- > SELECT onek.unique1, onek.stringu1 > WHERE onek.unique1 < 20 > @@ -51,7 +51,7 @@ SELECT onek.unique1, onek.stringu1 > (20 rows) > > -- > --- awk '{if($1>980){print $1,$14;}else{next;}}' onek.data | sort +1d -2 > +-- awk '{if($1>980){print $1,$14;}else{next;}}' onek.data | (sort -k 2,2d 2>/dev/null || sort +1d -2) > -- > SELECT onek.unique1, onek.stringu1 > WHERE onek.unique1 > 980 > @@ -82,7 +82,7 @@ SELECT onek.unique1, onek.stringu1 > > -- > -- awk '{if($1>980){print $1,$16;}else{next;}}' onek.data | > --- sort +1d -2 +0nr -1 > +-- (sort -k 2,2d -k 1,1nr 2>/dev/null || sort +1d -2 +0nr -1) > -- > SELECT onek.unique1, onek.string4 > WHERE onek.unique1 > 980 > @@ -113,7 +113,7 @@ SELECT onek.unique1, onek.string4 > > -- > -- awk '{if($1>980){print $1,$16;}else{next;}}' onek.data | > --- sort +1dr -2 +0n -1 > +-- (sort -k 2,2dr -k 1,1n 2>/dev/null || sort +1dr -2 +0n -1) > -- > SELECT onek.unique1, onek.string4 > WHERE onek.unique1 > 980 > @@ -144,7 +144,7 @@ SELECT onek.unique1, onek.string4 > > -- > -- awk '{if($1<20){print $1,$16;}else{next;}}' onek.data | > --- sort +0nr -1 +1d -2 > +-- (sort -k 1,1nr -k 2,2d 2>/dev/null || sort +0nr -1 +1d -2) > -- > SELECT onek.unique1, onek.string4 > WHERE onek.unique1 < 20 > @@ -175,7 +175,7 @@ SELECT onek.unique1, onek.string4 > > -- > -- awk '{if($1<20){print $1,$16;}else{next;}}' onek.data | > --- sort +0n -1 +1dr -2 > +-- (sort -k 1,1n -k 2,2dr 2>/dev/null || sort +0n -1 +1dr -2) > -- > SELECT onek.unique1, onek.string4 > WHERE onek.unique1 < 20 > @@ -212,7 +212,7 @@ SELECT onek.unique1, onek.string4 > -- > ANALYZE onek2; > -- > --- awk '{if($1<10){print $0;}else{next;}}' onek.data | sort +0n -1 > +-- awk '{if($1<10){print $0;}else{next;}}' onek.data | (sort -k 1,1n 2>/dev/null || sort +0n -1) > -- > SELECT onek2.* WHERE onek2.unique1 < 10; > unique1 | unique2 | two | four | ten | twenty | hundred | thousand | twothousand | fivethous | tenthous | odd | even| stringu1 | stringu2 | string4 > @@ -230,7 +230,7 @@ SELECT onek2.* WHERE onek2.unique1 < 10; > (10 rows) > > -- > --- awk '{if($1<20){print $1,$14;}else{next;}}' onek.data | sort +0nr -1 > +-- awk '{if($1<20){print $1,$14;}else{next;}}' onek.data | (sort -k 1,1nr 2>/dev/null || sort +0nr -1) > -- > SELECT onek2.unique1, onek2.stringu1 > WHERE onek2.unique1 < 20 > @@ -260,7 +260,7 @@ SELECT onek2.unique1, onek2.stringu1 > (20 rows) > > -- > --- awk '{if($1>980){print $1,$14;}else{next;}}' onek.data | sort +1d -2 > +-- awk '{if($1>980){print $1,$14;}else{next;}}' onek.data | (sort -k 2,2d 2>/dev/null || sort +1d -2) > -- > SELECT onek2.unique1, onek2.stringu1 > WHERE onek2.unique1 > 980; > @@ -365,7 +365,7 @@ SELECT p.name, p.age FROM person* p; > -- awk '{if(NF!=2){print $3,$2;}else{print;}}' - emp.data | > -- awk '{if(NF!=2){print $3,$2;}else{print;}}' - student.data | > -- awk 'BEGIN{FS=" ";}{if(NF!=1){print $4,$5;}else{print;}}' - stud_emp.data | > --- sort +1nr -2 > +-- (sort -k 2,2nr 2>/dev/null || sort +1nr -2) > -- > SELECT p.name, p.age FROM person* p ORDER BY age using >, name; > name | age > =================================================================== > RCS file: src/test/regress/expected/select_distinct.out,v > retrieving revision 7.2 > diff -pu -r7.2 src/test/regress/expected/select_distinct.out > --- src/test/regress/expected/select_distinct.out 2000/01/06 06:40:54 7.2 > +++ src/test/regress/expected/select_distinct.out 2002/02/25 06:47:43 > @@ -43,7 +43,7 @@ SELECT DISTINCT string4 FROM tmp; > > -- > -- awk '{print $3,$16,$5;}' onek.data | sort -d | uniq | > --- sort +0n -1 +1d -2 +2n -3 > +-- (sort -k 1,1n -k 2,2d -k 3,3n 2>/dev/null || sort +0n -1 +1d -2 +2n -3) > -- > SELECT DISTINCT two, string4, ten > FROM tmp > =================================================================== > RCS file: src/test/regress/sql/select.sql,v > retrieving revision 7.2 > diff -pu -r7.2 src/test/regress/sql/select.sql > --- src/test/regress/sql/select.sql 2001/07/16 05:07:00 7.2 > +++ src/test/regress/sql/select.sql 2002/02/25 06:47:43 > @@ -3,20 +3,20 @@ > -- > > -- btree index > --- awk '{if($1<10){print;}else{next;}}' onek.data | sort +0n -1 > +-- awk '{if($1<10){print;}else{next;}}' onek.data | (sort -k 1,1n 2>/dev/null || sort +0n -1) > -- > SELECT onek.* WHERE onek.unique1 < 10 > ORDER BY onek.unique1; > > -- > --- awk '{if($1<20){print $1,$14;}else{next;}}' onek.data | sort +0nr -1 > +-- awk '{if($1<20){print $1,$14;}else{next;}}' onek.data | (sort -k 1,1nr 2>/dev/null || sort +0nr -1) > -- > SELECT onek.unique1, onek.stringu1 > WHERE onek.unique1 < 20 > ORDER BY unique1 using >; > > -- > --- awk '{if($1>980){print $1,$14;}else{next;}}' onek.data | sort +1d -2 > +-- awk '{if($1>980){print $1,$14;}else{next;}}' onek.data | (sort -k 1,1d 2>/dev/null || sort +1d -2) > -- > SELECT onek.unique1, onek.stringu1 > WHERE onek.unique1 > 980 > @@ -24,7 +24,7 @@ SELECT onek.unique1, onek.stringu1 > > -- > -- awk '{if($1>980){print $1,$16;}else{next;}}' onek.data | > --- sort +1d -2 +0nr -1 > +-- (sort -k 2,2d -k 1,1nr 2>/dev/null || sort +1d -2 +0nr -1) > -- > SELECT onek.unique1, onek.string4 > WHERE onek.unique1 > 980 > @@ -32,7 +32,7 @@ SELECT onek.unique1, onek.string4 > > -- > -- awk '{if($1>980){print $1,$16;}else{next;}}' onek.data | > --- sort +1dr -2 +0n -1 > +-- (sort -k 2,2dr -k 1,1n 2>/dev/null || sort +1dr -2 +0n -1) > -- > SELECT onek.unique1, onek.string4 > WHERE onek.unique1 > 980 > @@ -40,7 +40,7 @@ SELECT onek.unique1, onek.string4 > > -- > -- awk '{if($1<20){print $1,$16;}else{next;}}' onek.data | > --- sort +0nr -1 +1d -2 > +-- (sort -k 1,1nr -k 2,2d 2>/dev/null || sort +0nr -1 +1d -2) > -- > SELECT onek.unique1, onek.string4 > WHERE onek.unique1 < 20 > @@ -48,7 +48,7 @@ SELECT onek.unique1, onek.string4 > > -- > -- awk '{if($1<20){print $1,$16;}else{next;}}' onek.data | > --- sort +0n -1 +1dr -2 > +-- (sort -k 1,1n -k 2,2dr 2>/dev/null || sort +0n -1 +1dr -2) > -- > SELECT onek.unique1, onek.string4 > WHERE onek.unique1 < 20 > @@ -63,19 +63,19 @@ SELECT onek.unique1, onek.string4 > ANALYZE onek2; > > -- > --- awk '{if($1<10){print $0;}else{next;}}' onek.data | sort +0n -1 > +-- awk '{if($1<10){print $0;}else{next;}}' onek.data | (sort -k 1,1n 2>/dev/null || sort +0n -1) > -- > SELECT onek2.* WHERE onek2.unique1 < 10; > > -- > --- awk '{if($1<20){print $1,$14;}else{next;}}' onek.data | sort +0nr -1 > +-- awk '{if($1<20){print $1,$14;}else{next;}}' onek.data | (sort -k 1,1nr 2>/dev/null || sort +0nr -1) > -- > SELECT onek2.unique1, onek2.stringu1 > WHERE onek2.unique1 < 20 > ORDER BY unique1 using >; > > -- > --- awk '{if($1>980){print $1,$14;}else{next;}}' onek.data | sort +1d -2 > +-- awk '{if($1>980){print $1,$14;}else{next;}}' onek.data | (sort -k 2,2d 2>/dev/null || sort +1d -2) > -- > SELECT onek2.unique1, onek2.stringu1 > WHERE onek2.unique1 > 980; > @@ -99,7 +99,7 @@ SELECT p.name, p.age FROM person* p; > -- awk '{if(NF!=2){print $3,$2;}else{print;}}' - emp.data | > -- awk '{if(NF!=2){print $3,$2;}else{print;}}' - student.data | > -- awk 'BEGIN{FS=" ";}{if(NF!=1){print $4,$5;}else{print;}}' - stud_emp.data | > --- sort +1nr -2 > +-- (sort -k 2,2nr 2>/dev/null || sort +1nr -2) > -- > SELECT p.name, p.age FROM person* p ORDER BY age using >, name; > > =================================================================== > RCS file: src/test/regress/sql/select_distinct.sql,v > retrieving revision 7.2 > diff -pu -r7.2 src/test/regress/sql/select_distinct.sql > --- src/test/regress/sql/select_distinct.sql 2000/01/06 06:41:55 7.2 > +++ src/test/regress/sql/select_distinct.sql 2002/02/25 06:47:43 > @@ -19,7 +19,7 @@ SELECT DISTINCT string4 FROM tmp; > > -- > -- awk '{print $3,$16,$5;}' onek.data | sort -d | uniq | > --- sort +0n -1 +1d -2 +2n -3 > +-- (sort -k 1,1n -k 2,2d -k 3,3n 2>/dev/null || sort +0n -1 +1d -2 +2n -3) > -- > SELECT DISTINCT two, string4, ten > FROM tmp > =================================================================== > RCS file: src/tools/make_keywords,v > retrieving revision 7.2 > diff -pu -r7.2 src/tools/make_keywords > --- src/tools/make_keywords 2001/11/26 22:41:58 7.2 > +++ src/tools/make_keywords 2002/02/25 06:47:43 > @@ -9,5 +9,6 @@ keywords. Here is what I used: > > sdif /tmp/pgkeywords tools/SQL_keywords |\ > sed 's/</ /' | sed 's/>/ /'|sed 's/|/\ > - /' | sort -b +0 > + /' |\ > +(sort -b -k 1 2>/dev/null || sort -b +0) > END > =================================================================== > RCS file: configure.in,v > retrieving revision 7.2 > diff -pu -r7.2 configure.in > --- configure.in 2002/02/03 21:04:12 7.2 > +++ configure.in 2002/02/25 06:47:43 > @@ -297,7 +297,7 @@ AC_SUBST(GCC) > > # Create compiler version string > if test x"$GCC" = x"yes" ; then > - cc_string="GCC `${CC} --version | head -1`" > + cc_string="GCC `${CC} --version | sed q`" > else > cc_string=$CC > fi > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
> From: Bruce Momjian <pgman@candle.pha.pa.us> > Date: Mon, 11 Mar 2002 12:05:17 -0500 (EST) > > This is an interesting patch, but have not heard anyone else have this > problem That's not surprising, since I am purposely running a bleeding-edge system to test PostgreSQL portability. Nobody is shipping POSIX 1003.1-2001 systems yet (the standard was only approved in December by the IEEE, and it will not be an official ISO standard for a few more weeks yet). But when they do, you will run into this problem. > and am hesitant to add more cost to fix something that may not be > broken. Sorry. There is no cost to PostgreSQL in normal operation, since that part of the source isn't affected at all. All that is affected is some of the test scripts and documentation. I see little risk to incorporating the patch, but of course it's your decision.
Paul Eggert wrote: > > From: Bruce Momjian <pgman@candle.pha.pa.us> > > Date: Mon, 11 Mar 2002 12:05:17 -0500 (EST) > > > > This is an interesting patch, but have not heard anyone else have this > > problem > > That's not surprising, since I am purposely running a bleeding-edge > system to test PostgreSQL portability. Nobody is shipping POSIX > 1003.1-2001 systems yet (the standard was only approved in December by > the IEEE, and it will not be an official ISO standard for a few more > weeks yet). But when they do, you will run into this problem. > > > > and am hesitant to add more cost to fix something that may not be > > broken. Sorry. > > There is no cost to PostgreSQL in normal operation, since that part of > the source isn't affected at all. All that is affected is some of the > test scripts and documentation. I see little risk to incorporating > the patch, but of course it's your decision. We are kind of picky about adding complexity when it isn't required. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
On Mon, 11 Mar 2002, Bruce Momjian wrote: > Paul Eggert wrote: > > > From: Bruce Momjian <pgman@candle.pha.pa.us> > > > Date: Mon, 11 Mar 2002 12:05:17 -0500 (EST) > > > > > > This is an interesting patch, but have not heard anyone else have this > > > problem > > > > That's not surprising, since I am purposely running a bleeding-edge > > system to test PostgreSQL portability. Nobody is shipping POSIX > > 1003.1-2001 systems yet (the standard was only approved in December by > > the IEEE, and it will not be an official ISO standard for a few more > > weeks yet). But when they do, you will run into this problem. > > > > > > > and am hesitant to add more cost to fix something that may not be > > > broken. Sorry. Apparently it _is_ broken - Paul wouldn't be submitting a patch if it wasn't. Duh. > > There is no cost to PostgreSQL in normal operation, since that part of > > the source isn't affected at all. All that is affected is some of the > > test scripts and documentation. I see little risk to incorporating > > the patch, but of course it's your decision. > > We are kind of picky about adding complexity when it isn't required. s/isn't/isn't yet ^^^ So you'd prefer to just wait 'till POSIX 1003.1-2001 systems ship? <sarcasm> Paul, I guess you should set up an at(1) job to resubmit the patch in a couple-3 years, or something... </sarcasm> -- Dominic J. Eidson "Baruk Khazad! Khazad ai-menu!" - Gimli ------------------------------------------------------------------------------- http://www.the-infinite.org/ http://www.the-infinite.org/~dominic/
I am just guessing what people will think about the patch. If people want it is a good idea, I can apply it. The patch basically takes: sort +1 -0 and changes it to and makes it: sort +1 -0 || sort -k 1,0 or something like that. --------------------------------------------------------------------------- Dominic J. Eidson wrote: > On Mon, 11 Mar 2002, Bruce Momjian wrote: > > > Paul Eggert wrote: > > > > From: Bruce Momjian <pgman@candle.pha.pa.us> > > > > Date: Mon, 11 Mar 2002 12:05:17 -0500 (EST) > > > > > > > > This is an interesting patch, but have not heard anyone else have this > > > > problem > > > > > > That's not surprising, since I am purposely running a bleeding-edge > > > system to test PostgreSQL portability. Nobody is shipping POSIX > > > 1003.1-2001 systems yet (the standard was only approved in December by > > > the IEEE, and it will not be an official ISO standard for a few more > > > weeks yet). But when they do, you will run into this problem. > > > > > > > > > > and am hesitant to add more cost to fix something that may not be > > > > broken. Sorry. > > Apparently it _is_ broken - Paul wouldn't be submitting a patch if it > wasn't. Duh. > > > > There is no cost to PostgreSQL in normal operation, since that part of > > > the source isn't affected at all. All that is affected is some of the > > > test scripts and documentation. I see little risk to incorporating > > > the patch, but of course it's your decision. > > > > We are kind of picky about adding complexity when it isn't required. > > s/isn't/isn't yet > ^^^ > So you'd prefer to just wait 'till POSIX 1003.1-2001 systems ship? > > <sarcasm> > Paul, I guess you should set up an at(1) job to resubmit the patch in a > couple-3 years, or something... > </sarcasm> > > > -- > Dominic J. Eidson > "Baruk Khazad! Khazad ai-menu!" - Gimli > ------------------------------------------------------------------------------- > http://www.the-infinite.org/ http://www.the-infinite.org/~dominic/ > > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
On Mon, 2002-03-11 at 17:58, Bruce Momjian wrote: > > There is no cost to PostgreSQL in normal operation, since that part of > > the source isn't affected at all. All that is affected is some of the > > test scripts and documentation. I see little risk to incorporating > > the patch, but of course it's your decision. > > We are kind of picky about adding complexity when it isn't required. I wouldn't describe "standards compliance" as "complexity". I haven't look at the patch extensively, but are there any areas where the new behavior is not functionally identical to the old code, just more standards compliant? Cheers, Neil -- Neil Conway <neilconway@rogers.com> PGP Key ID: DB3C29FC
Bruce Momjian writes: > We are kind of picky about adding complexity when it isn't required. But the parts that are replacing 'head -1' by 'sed q' should definitely be applied. Although I'd prefer 'sed 1q'. -- Peter Eisentraut peter_e@gmx.net
> From: Bruce Momjian <pgman@candle.pha.pa.us> > Date: Mon, 11 Mar 2002 19:04:24 -0500 (EST) > > The patch basically takes: > > sort +1 -0 and changes it to > > and makes it: > > sort +1 -0 || sort -k 1,0 > > or something like that. Here is a bit more detail about what the patch does. * It transforms `head -1 FOO' to `sed q FOO'. This is portable to all hosts that I know of. As it happens, `head -1' didn't work in Unix Version 7, but `sed q' did, so this transformation improves portability to some ancient hosts too. * It transforms `sort +0n -1' to `(sort -k 1,1n 2>/dev/null || sort +0n -1)', and similarly for all other uses of `sort +FOO'. The basic idea is to try POSIX standard syntax (standard since the first version of POSIX, anyway, more than a dozen years ago), and to fall back on the traditional Unix Version 7 syntax if the POSIX standard syntax is not supported. The former transformation is perfectly safe. The latter transformation is a bit tricky, since the first `sort' can fail for reasons other than "I don't know what -k is", and in that case the second `sort' will be invoked even though it should not be. I don't think this will be a real problem in practice, but if you're worried about it I could change the second transform to look like this: if sort -k 1,1n /dev/null >/dev/null 2>&1 then sort -k 1,1n else sort +0n -1 fi I can submit a revised patch along those lines if you like.
Peter Eisentraut wrote: > Bruce Momjian writes: > > > We are kind of picky about adding complexity when it isn't required. > > But the parts that are replacing 'head -1' by 'sed q' should definitely be > applied. Although I'd prefer 'sed 1q'. Yes, that part did look good but I wasn't sure it was worth the change. Feel free to do it. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
> But the parts that are replacing 'head -1' by 'sed q' should definitely be > applied. Although I'd prefer 'sed 1q'. What's wrong with "head -n 1"?? Surely that's compliant if -num params aren't allowed any more? Chris
> From: "Christopher Kings-Lynne" <chriskl@familyhealth.com.au> > Date: Tue, 12 Mar 2002 10:35:35 +0800 > Importance: Normal > > What's wrong with "head -n 1"? Nothing's wrong with it from a standards-compliance point of view. But I worry that "head -n 1" may not work on some older (pre-POSIX) hosts, as it did not work on Unix Version 7 hosts. In contrast, "sed q" did work on those ancient hosts, so I figure "sed q" should be safer. "sed 1q" should be equally good from a portability viewpoint, if you prefer.
Paul Eggert wrote: > > From: "Christopher Kings-Lynne" <chriskl@familyhealth.com.au> > > Date: Tue, 12 Mar 2002 10:35:35 +0800 > > Importance: Normal > > > > What's wrong with "head -n 1"? > > Nothing's wrong with it from a standards-compliance point of view. > > But I worry that "head -n 1" may not work on some older (pre-POSIX) > hosts, as it did not work on Unix Version 7 hosts. In contrast, "sed > q" did work on those ancient hosts, so I figure "sed q" should be > safer. "sed 1q" should be equally good from a portability viewpoint, > if you prefer. I have made the 'sed 1q' change you suggested in configure.in, but not in the docs because I thought it would be too confusing. The sort changes, however, were not embraced, as I suspected. Certainly when we hit a platform that doesn't understand sort +/-, we will need to make that change. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026 Index: configure.in =================================================================== RCS file: /cvsroot/pgsql/configure.in,v retrieving revision 1.168 diff -c -r1.168 configure.in *** configure.in 5 Mar 2002 17:55:21 -0000 1.168 --- configure.in 12 Mar 2002 21:23:15 -0000 *************** *** 297,303 **** # Create compiler version string if test x"$GCC" = x"yes" ; then ! cc_string="GCC `${CC} --version | head -1`" else cc_string=$CC fi --- 297,303 ---- # Create compiler version string if test x"$GCC" = x"yes" ; then ! cc_string="GCC `${CC} --version | sed q`" else cc_string=$CC fi