Re: [PATCHES] [pgsql-hackers-win32] Repleacement for src/port/snprintf.c

2005-03-11 Thread Bruce Momjian

I have reviewed this patch, and I already added these changes myself in
CVS.

Thanks.

---

Nicolai Tufar wrote:
  On Mon, Feb 21, 2005 at 10:53:08PM -0500, Bruce Momjian wrote:
 
  Applied.
 
 Thanks a lot. The patch attached solves the tread
 safety problem. Please review it before applying, 
 I am not sure I am doing the right thing
 
 
 On Tue, 22 Feb 2005 19:57:15 +0100, Kurt Roeckx [EMAIL PROTECTED] wrote:
  The configure test is a little broken.  It needs to quote the
  $'s.
  
  I've rewritten the test a little.
 
 This one needs applying too. $'s do get scrambled.
 
 Best regards, 
 Nicolai.

[ Attachment, skipping... ]

 
 ---(end of broadcast)---
 TIP 7: don't forget to increase your free space map settings

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  pgman@candle.pha.pa.us   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073

---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings


Re: [PATCHES] [pgsql-hackers-win32] Repleacement for src/port/snprintf.c

2005-03-10 Thread Bruce Momjian

Would you please check current CVS?  I think I addressed most of these
issues already.

---

Nicolai Tufar wrote:
  On Mon, Feb 21, 2005 at 10:53:08PM -0500, Bruce Momjian wrote:
 
  Applied.
 
 Thanks a lot. The patch attached solves the tread
 safety problem. Please review it before applying, 
 I am not sure I am doing the right thing
 
 
 On Tue, 22 Feb 2005 19:57:15 +0100, Kurt Roeckx [EMAIL PROTECTED] wrote:
  The configure test is a little broken.  It needs to quote the
  $'s.
  
  I've rewritten the test a little.
 
 This one needs applying too. $'s do get scrambled.
 
 Best regards, 
 Nicolai.

[ Attachment, skipping... ]

 
 ---(end of broadcast)---
 TIP 7: don't forget to increase your free space map settings

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  pgman@candle.pha.pa.us   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073

---(end of broadcast)---
TIP 8: explain analyze is your friend


Re: [PATCHES] [pgsql-hackers-win32] Repleacement for src/port/snprintf.c

2005-02-25 Thread Nicolai Tufar
On Thu, 24 Feb 2005 22:18:11 -0500, Tom Lane [EMAIL PROTECTED] wrote:
 Didn't we do that already?

No :(   I promised to do it a couple of weeks ago but could not get to do it.
Now with Magnus's help I finaly did it. The last patch should be fine.

 regards, tom lane
Nicolai

---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings


Re: [PATCHES] [pgsql-hackers-win32] Repleacement for src/port/snprintf.c

2005-02-24 Thread Bruce Momjian

Oh, thanks.  That is a great fix.  Applied.  Glad you could test it on a
machine that supports positional parameters.

---

Kurt Roeckx wrote:
 On Mon, Feb 21, 2005 at 10:53:08PM -0500, Bruce Momjian wrote:
  
  Applied.
 
 The configure test is a little broken.  It needs to quote the
 $'s.
 
 I've rewritten the test a little.
 
 
 Kurt
 

[ Attachment, skipping... ]

 
 ---(end of broadcast)---
 TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  pgman@candle.pha.pa.us   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073

---(end of broadcast)---
TIP 9: the planner will ignore your desire to choose an index scan if your
  joining column's datatypes do not match


Re: [PATCHES] [pgsql-hackers-win32] Repleacement for src/port/snprintf.c

2005-02-24 Thread Bruce Momjian
Tom Lane wrote:
 Kurt Roeckx [EMAIL PROTECTED] writes:
  The configure test is a little broken.  It needs to quote the
  $'s.
 
  I've rewritten the test a little.
 
 Applied, thanks.

Oops, Tom got to it first.  (Darn!)  :-)

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  pgman@candle.pha.pa.us   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073

---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send unregister YourEmailAddressHere to [EMAIL PROTECTED])


Re: [PATCHES] [pgsql-hackers-win32] Repleacement for src/port/snprintf.c

2005-02-24 Thread Bruce Momjian

Your patch has been added to the PostgreSQL unapplied patches list at:

http://momjian.postgresql.org/cgi-bin/pgpatches

It will be applied as soon as one of the PostgreSQL committers reviews
and approves it.

---


Nicolai Tufar wrote:
  On Mon, Feb 21, 2005 at 10:53:08PM -0500, Bruce Momjian wrote:
 
  Applied.
 
 Thanks a lot. The patch attached solves the tread
 safety problem. Please review it before applying, 
 I am not sure I am doing the right thing
 
 
 On Tue, 22 Feb 2005 19:57:15 +0100, Kurt Roeckx [EMAIL PROTECTED] wrote:
  The configure test is a little broken.  It needs to quote the
  $'s.
  
  I've rewritten the test a little.
 
 This one needs applying too. $'s do get scrambled.
 
 Best regards, 
 Nicolai.

[ Attachment, skipping... ]

 
 ---(end of broadcast)---
 TIP 7: don't forget to increase your free space map settings

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  pgman@candle.pha.pa.us   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073

---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send unregister YourEmailAddressHere to [EMAIL PROTECTED])


Re: [PATCHES] [pgsql-hackers-win32] Repleacement for src/port/snprintf.c

2005-02-24 Thread Tom Lane
Bruce Momjian pgman@candle.pha.pa.us writes:
 Your patch has been added to the PostgreSQL unapplied patches list at:

Didn't we do that already?

regards, tom lane

---(end of broadcast)---
TIP 6: Have you searched our list archives?

   http://archives.postgresql.org


Re: [PATCHES] [pgsql-hackers-win32] Repleacement for src/port/snprintf.c

2005-02-24 Thread Bruce Momjian
Tom Lane wrote:
 Bruce Momjian pgman@candle.pha.pa.us writes:
  Your patch has been added to the PostgreSQL unapplied patches list at:
 
 Didn't we do that already?

This patch is for thread safety:

 Thanks a lot. The patch attached solves the tread
 safety problem. Please review it before applying,
 I am not sure I am doing the right thing

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  pgman@candle.pha.pa.us   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073

---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings


Re: [PATCHES] [pgsql-hackers-win32] Repleacement for src/port/snprintf.c

2005-02-23 Thread Tom Lane
Kurt Roeckx [EMAIL PROTECTED] writes:
 The configure test is a little broken.  It needs to quote the
 $'s.

 I've rewritten the test a little.

Applied, thanks.

regards, tom lane

---(end of broadcast)---
TIP 8: explain analyze is your friend


Re: [PATCHES] [pgsql-hackers-win32] Repleacement for src/port/snprintf.c

2005-02-22 Thread Kurt Roeckx
On Mon, Feb 21, 2005 at 10:53:08PM -0500, Bruce Momjian wrote:
 
 Applied.

The configure test is a little broken.  It needs to quote the
$'s.

I've rewritten the test a little.


Kurt

Index: config/c-library.m4
===
RCS file: /projects/cvsroot/pgsql/config/c-library.m4,v
retrieving revision 1.30
diff -u -r1.30 c-library.m4
--- config/c-library.m4 22 Feb 2005 03:55:50 -  1.30
+++ config/c-library.m4 22 Feb 2005 18:53:23 -
@@ -279,19 +279,17 @@
 [AC_MSG_CHECKING([printf supports argument control])
 AC_CACHE_VAL(pgac_cv_printf_arg_control,
 [AC_TRY_RUN([#include stdio.h
+#include string.h
 
-int does_printf_have_arg_control()
+int main()
 {
   char buf[100];
 
   /* can it swap arguments? */
-  snprintf(buf, 100, %2$d|%1$d, 3, 4);
-  if (strcmp(buf, 4|3) != 0)
-return 0;
-  return 1;
-}
-main() {
-  exit(! does_printf_have_arg_control());
+  snprintf(buf, 100, %2\$d %1\$d, 3, 4);
+  if (strcmp(buf, 4 3) != 0)
+return 1;
+  return 0;
 }],
 [pgac_cv_printf_arg_control=yes],
 [pgac_cv_printf_arg_control=no],

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly


Re: [PATCHES] [pgsql-hackers-win32] Repleacement for src/port/snprintf.c

2005-02-15 Thread Nicolai Tufar
On Sun, 13 Feb 2005 19:06:34 -0500 (EST), Bruce Momjian
pgman@candle.pha.pa.us wrote:
 Anyway, this is too large to put into 8.0, but I am attaching a patch
 for 8.1 that has the proper configure tests to check if the C library
 supports this behavior.  If it does not, the build will use our
 port/snprintf.c.
 One problem with that is that our snprintf.c is not thread-safe.  Seems
 the increases use of it will require us to fix this soon.  I have added
 to TODO:
 
 * Make src/port/snprintf.c thread-safe

Okay, I am applying your patch to CVS HEAD and 
getting hands on making snprintf.c thread-safe. I will
submit a roll up pathch in a day or two.

Regards,
Nicolai

---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings


Re: [PATCHES] [pgsql-hackers-win32] Repleacement for src/port/snprintf.c

2005-02-13 Thread Bruce Momjian
Nicolai Tufar wrote:
 Hello all,
 
 I would like to submit my changes to src/port/snprintf.c to
 enable %n$ format placeholder replacement in snprintf() and
 vsnprintf(). Additionally I implemented a trivial printf().
 
 I also attach a diff for configure.in to include snprintf.o
 in pgport but I am sure it is not the right thing to do.
 Could someone give a hint on where I need to place such a
 definition.
 
 Please review my patch. as Tom Lane pointed out there
 are 150 messages in the following files that do not print
 properly:

It took me a while to understand this but I get it now.  This is the
best explanation I have seen, from Linux 2.6:

One can also specify explicitly which argument is taken, at each place
where an argument is required, by writing '%m$' instead of '%' and '*m$'
instead of '*', where the decimal integer m denotes the position in the
argument list of the desired argument, indexed starting from 1. Thus,

printf(%*d, width, num);

and

printf(%2$*1$d, width, num);

are  equivalent.  The  second style allows repeated references to the
same argument. The C99 standard does not include the style using '$',
which comes from the Single Unix Specification.  If the style using '$'
is used, it must be  used throughout for all conversions taking an
argument and all width and precision arguments, but it may be mixed with
'%%' formats which do not consume an argument.  There may be no gaps in
the numbers of arguments specified using  '$';  for example, if
arguments 1 and 3 are specified, argument 2 must also be specified
somewhere in the format string.

I can see why this would be useful for translations because it uncouples
the order of the printf arguments from the printf string.  However, I
have learned that Win32, HP-UX, NetBSD 2.0, and BSD/OS do not support
this.  This is probably because it is not in C99 but in SUS (see above).

Anyway, this is too large to put into 8.0, but I am attaching a patch
for 8.1 that has the proper configure tests to check if the C library
supports this behavior.  If it does not, the build will use our
port/snprintf.c.

One problem with that is that our snprintf.c is not thread-safe.  Seems
the increases use of it will require us to fix this soon.  I have added
to TODO:

* Make src/port/snprintf.c thread-safe

One change to the original port is that there was a define of a union
with no name:

+   union{
+   void*   value;
+   long_long   numvalue;
+   double  fvalue;
+   int charvalue;
+   };

As far as I know a union with no name is illegal.  I just removed the
union { and the closing brace.

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  pgman@candle.pha.pa.us   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073
Index: configure
===
RCS file: /cvsroot/pgsql/configure,v
retrieving revision 1.425
diff -c -c -r1.425 configure
*** configure   18 Jan 2005 05:23:35 -  1.425
--- configure   13 Feb 2005 23:50:46 -
***
*** 12162,12167 
--- 12162,12224 
  done
  
  
+ echo $as_me:$LINENO: checking printf supports argument control 5
+ echo $ECHO_N checking printf supports argument control... $ECHO_C 6
+ if test ${pgac_cv_printf_arg_control+set} = set; then
+   echo $ECHO_N (cached) $ECHO_C 6
+ else
+   if test $cross_compiling = yes; then
+   pgac_cv_printf_arg_control=cross
+ else
+   cat conftest.$ac_ext _ACEOF
+ #line $LINENO configure
+ #include confdefs.h
+ #include stdio.h
+ 
+ int does_printf_have_arg_control()
+ {
+   char buf[100];
+ 
+   /* can it swap arguments? */
+   snprintf(buf, 100, %2$d|%1$d, 3, 4);
+   if (strcmp(buf, 4|3) != 0)
+ return 0;
+   return 1;
+ }
+ main() {
+   exit(! does_printf_have_arg_control());
+ }
+ _ACEOF
+ rm -f conftest$ac_exeext
+ if { (eval echo $as_me:$LINENO: \$ac_link\) 5
+   (eval $ac_link) 25
+   ac_status=$?
+   echo $as_me:$LINENO: \$? = $ac_status 5
+   (exit $ac_status); }  { ac_try='./conftest$ac_exeext'
+   { (eval echo $as_me:$LINENO: \$ac_try\) 5
+   (eval $ac_try) 25
+   ac_status=$?
+   echo $as_me:$LINENO: \$? = $ac_status 5
+   (exit $ac_status); }; }; then
+   pgac_cv_printf_arg_control=yes
+ else
+   echo $as_me: program exited with status $ac_status 5
+ echo $as_me: failed program was: 5
+ cat conftest.$ac_ext 5
+ ( exit $ac_status )
+ pgac_cv_printf_arg_control=no
+ fi
+ rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext 
conftest.$ac_ext
+ fi
+ 
+ fi
+ echo $as_me:$LINENO: result: $pgac_cv_printf_arg_control 5
+ echo ${ECHO_T}$pgac_cv_printf_arg_control