Re: [PATCHES] log_filename_prefix -- log_filename + strftime()

2004-08-31 Thread Andreas Pflug
Tom Lane wrote:
Andreas Pflug [EMAIL PROTECTED] writes:
I don't have the time now to review the impact, but this might make 
interpreting the log filename difficult or impossible, effectively 
corrupting pg_logdir_ls.

So if you want to use that, you use a format that it can cope with.
you is the backend, which should be able to interpret what it wrote.
I don't see a problem.
Yes, you don't see a problem if the logfile can't be displayed on the 
client, I know that. My primary intention for contributing *any* logfile 
related stuff was to make it available through admin interfaces, and 
this goal seems to get obstructed in any possible way.

Anybody volunteering to fix the pg_logdir_ls code at 
http://cvs.pgadmin.org/cgi-bin/viewcvs.cgi/pgadmin-tools/support/misc.c?rev=HEAD 
 which should have been in the backend right from the start?

What about misbehaving size rotation if the filename isn't unique? And 
what's a non human readable name.epoch pattern default good for?

Regards,
Andreas
---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster


Re: [PATCHES] log_filename_prefix -- log_filename + strftime()

2004-08-31 Thread Ed L.

Should the epoch snprintf format of the int64 pg_time_t timestamp be %lld 
instead of %d?

Ed


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

   http://archives.postgresql.org


Re: [PATCHES] log_filename_prefix -- log_filename + strftime()

2004-08-31 Thread Ed L.
On Tuesday August 31 2004 8:45, Ed L. wrote:
 Should the epoch snprintf format of the int64 pg_time_t timestamp be %lld
 instead of %d?

Ah, I see you handled it.


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


[PATCHES] Timezones on localized windows

2004-08-31 Thread Magnus Hagander
This patch attempts to fix the issue with localized timezones on
Windows.

Recap: When running on a localized windows version, the timezone name
returned is also localized, and therefor does not match our lookup
table.

Solution: The registry contains both the name of the timezone in english
and the localized name. The patch adds code to scan the registry for the
localized name and gets the english name from that, and then rescans the
table.

I have tested this on a Swedish WinXP, and it works without problems.
The registry layout is the same in Win2k, but I haven't specifically
tested it. It's also the same on different languages but again only
Swedish is tested.


//Magnus


win32localtz.patch
Description: win32localtz.patch

---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster


[PATCHES] Typo in tab-complete.c

2004-08-31 Thread Greg Sabino Mullane

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
 
 
Little typo I came across:
 
src/bin/psql/tab-complete.c =~ s/CONVERSATION/CONVERSION/;
 
- --
Greg Sabino Mullane [EMAIL PROTECTED]
PGP Key: 0x14964AC8 200408311915
-BEGIN PGP SIGNATURE-
 
iD8DBQFBNQa8vJuQZxSWSsgRAtXPAJ4pLYRMPYY3kWh89X+gLgi3V+QqdACg86ya
ksNPY37s7CoGm3XwYZs/pOM=
=UlHH
-END PGP SIGNATURE-



---(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


[PATCHES] psql tab-completion improvements

2004-08-31 Thread Greg Sabino Mullane

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
NotDashEscaped: You need GnuPG to verify this message


Some improvements for the tab-completion of psql. This should 
address all of the items in the todo list and adds some new 
things as well. Specifically:

* Add support for ALTER SEQUENCE ...
* Add RENAME TO for ALTER TRIGGER xx ON yy
* Pick proper table for ALTER TRIGGER xx ON ...
* Support for ALTER USER xxx ...
* Fix ALTER GROUP xxx DROP ...
* Fix ALTER DOMAIN xxx DROP ...
* Remove OWNER TO from ALTER DOMAIN xx DROP ...
* Fix ALTER DOMAIN xx SET DEFAULT ..
* Prevent ALTER INDEX xxx SET TABLESPACE from using TO
* Support for ALTER LANGUAGE xxx (RENAME TO)
* More support for ALTER TABLE xxx ALTER COLUMN xxx ...
* More support for COPY

--
Greg Sabino Mullane [EMAIL PROTECTED]
PGP Key: 0x14964AC8 200408311930




Index: tab-complete.c
===
RCS file: /projects/cvsroot/pgsql-server/src/bin/psql/tab-complete.c,v
retrieving revision 1.114
diff -c -r1.114 tab-complete.c
*** tab-complete.c  29 Aug 2004 05:06:54 -  1.114
--- tab-complete.c  31 Aug 2004 23:25:07 -
***
*** 386,391 
--- 386,400 
 and pg_catalog.quote_ident(c1.relname)='%s'\
 and pg_catalog.pg_table_is_visible(c2.oid)
  
+ /* the silly-looking length condition is just to eat up the current word */
+ #define Query_for_list_of_tables_for_trigger \
+ SELECT pg_catalog.quote_ident(relname) \
+   FROM pg_catalog.pg_class\
+  WHERE (%d = length('%s'))\
+AND oid IN \
+(SELECT tgrelid FROM pg_catalog.pg_trigger \
+  WHERE pg_catalog.quote_ident(tgname)='%s')
+ 
  /*
   * This is a list of all things in Pgsql, which can show up after CREATE or
   * DROP; and there is also a query to get a list of them.
***
*** 637,647 
else if (!prev_wd)
COMPLETE_WITH_LIST(sql_commands);
  
! /* CREATE or DROP but not ALTER TABLE sth DROP */
/* complete with something you can create or drop */
else if (pg_strcasecmp(prev_wd, CREATE) == 0 ||
 (pg_strcasecmp(prev_wd, DROP) == 0 
! pg_strcasecmp(prev3_wd, TABLE) != 0))
matches = completion_matches(text, create_command_generator);
  
  /* ALTER */
--- 646,658 
else if (!prev_wd)
COMPLETE_WITH_LIST(sql_commands);
  
! /* CREATE or DROP but not ALTER (TABLE|DOMAIN|GROUP) sth DROP */
/* complete with something you can create or drop */
else if (pg_strcasecmp(prev_wd, CREATE) == 0 ||
 (pg_strcasecmp(prev_wd, DROP) == 0 
! pg_strcasecmp(prev3_wd, TABLE) != 0 
! pg_strcasecmp(prev3_wd, DOMAIN) != 0 
! pg_strcasecmp(prev3_wd, GROUP) != 0))
matches = completion_matches(text, create_command_generator);
  
  /* ALTER */
***
*** 694,699 
--- 705,726 
COMPLETE_WITH_LIST(list_ALTERINDEX);
}
  
+   /* ALTER LANGUAGE name */
+   else if (pg_strcasecmp(prev3_wd, ALTER) == 0 
+pg_strcasecmp(prev2_wd, LANGUAGE) == 0)
+   COMPLETE_WITH_CONST(RENAME TO);
+ 
+   /* ALTER USER name */
+   else if (pg_strcasecmp(prev3_wd, ALTER) == 0 
+pg_strcasecmp(prev2_wd, USER) == 0)
+   {
+   static const char *const list_ALTERUSER[] =
+   {ENCRYPTED, UNENCRYPTED, CREATEDB, NOCREATEDB, CREATEUSER,
+NOCREATEUSER, VALID UNTIL, RENAME TO, SET, RESET, NULL};
+ 
+   COMPLETE_WITH_LIST(list_ALTERUSER);
+   }
+ 
/* ALTER DOMAIN name */
else if (pg_strcasecmp(prev3_wd, ALTER) == 0 
 pg_strcasecmp(prev2_wd, DOMAIN) == 0)
***
*** 709,715 
 pg_strcasecmp(prev_wd, DROP) == 0)
{
static const char *const list_ALTERDOMAIN2[] =
!   {CONSTRAINT, DEFAULT, NOT NULL, OWNER TO, NULL};
  
COMPLETE_WITH_LIST(list_ALTERDOMAIN2);
}
--- 736,742 
 pg_strcasecmp(prev_wd, DROP) == 0)
{
static const char *const list_ALTERDOMAIN2[] =
!   {CONSTRAINT, DEFAULT, NOT NULL, NULL};
  
COMPLETE_WITH_LIST(list_ALTERDOMAIN2);
}
***
*** 723,733 
  
COMPLETE_WITH_LIST(list_ALTERDOMAIN3);
}
/* ALTER TRIGGER name, add ON */
else if (pg_strcasecmp(prev3_wd, ALTER) == 0 
!pg_strcasecmp(prev2_wd, TRIGGER) == 0 
!pg_strcasecmp(prev_wd, ON) != 0)
!   COMPLETE_WITH_CONST(ON);
  
/*
 * If we have ALTER TRIGGER sth ON, then add the correct tablename
--- 750,785 
  
COMPLETE_WITH_LIST(list_ALTERDOMAIN3);
}
+   /* ALTER 

Re: [PATCHES] Typo in tab-complete.c

2004-08-31 Thread Bruce Momjian

Fixed.  Thanks.

---

Greg Sabino Mullane wrote:
[ There is text before PGP section. ]
 
[ PGP not available, raw data follows ]
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
  
  
 Little typo I came across:
  
 src/bin/psql/tab-complete.c =~ s/CONVERSATION/CONVERSION/;
  
 - --
 Greg Sabino Mullane [EMAIL PROTECTED]
 PGP Key: 0x14964AC8 200408311915
 -BEGIN PGP SIGNATURE-
  
 iD8DBQFBNQa8vJuQZxSWSsgRAtXPAJ4pLYRMPYY3kWh89X+gLgi3V+QqdACg86ya
 ksNPY37s7CoGm3XwYZs/pOM=
 =UlHH
 -END PGP SIGNATURE-
 
 
 
 ---(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
 
[ Decrypting message... End of raw data. ]

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  [EMAIL PROTECTED]   |  (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 4: Don't 'kill -9' the postmaster


Re: [PATCHES] cygwin 8.0.0beta1 postmaster/syslogger.c, port/dirmod.c,

2004-08-31 Thread Bruce Momjian

OK, patch attached and applied that casts _timezone to (int) on Cygwin.

---

Reini Urban wrote:
 Bruce Momjian schrieb:
  Should I apply this change?
  
   #define TIMEZONE_GLOBAL ((int)_timezone)
 
 yes, please.
 I have no time yet, to come up with the better patch. It's already  monday.
 
  ---
  
  Reini Urban wrote:
  
 Bruce Momjian schrieb:
 
 Your patch highlighted several bugs in our code.  First, I wasn't
 testing for CYGWIN in the backend pgport_palloc code.  Second, I added
 an #undef to prevent compiler warnings.  Third I added your Cygwin
 includes with an #ifdef.  These will appear in beta2.
 
 On the timezone issue, I see this in dt.h:

/* Global variable holding time zone information. */
#if !defined(__CYGWIN__)  !defined(WIN32)
#define TIMEZONE_GLOBAL timezone
#else
#define TIMEZONE_GLOBAL _timezone
#define tzname _tzname  /* should be in time.h? */
#endif
 
 so are you saying your _timezone is time_t and not an int?  Sometimes it
 is just a short because it is only minutes west of GMT, not an actually
 seconds since 1970 or anything.  Making it time_t actually sounds like
 overkill, but we can work around that in dt.h if indeed that is how your
 OS defines it.  The easiest fix would probably be to add the cast to int
 right in dt.h and only for Cygwin:
 
#define TIMEZONE_GLOBAL ((int)_timezone)
 
 Does that work for you?
 
 yes, that's better.
 
 FYI /usr/include/time.h:
 /* defines for the opengroup specifications Derived from Issue 1 of the 
 SVID.  */
 extern __IMPORT time_t _timezone;
 ...
 
 BTW: I see that CYGWIN also has a struct timezone in sys/time.h, but 
 configure didn't check for that.
 I'll come with better patches after beta2.
 
 
 
 ---
 
 Reini Urban wrote:
 
 
 Attached patches are required for cygwin:
 
 2004-08-24 21:23:53 [EMAIL PROTECTED]
   * (postmaster/syslogger.c) struct timeval is
   declared in sys/time.h, not in time.h
 
 2004-08-24 20:20:54 rurban:
   * (port/dirmod.c) cygwin needs different header locations,
   and unlink is a macro. There are no pgport_palloc
   versions yet
 
 
 timezone/pgtz.c:
 Pending is a patch against postgresql-8.0.0beta1/config/c-library.m4:
 PGAC_VAR_INT_TIMEZONE
 
 In the meantime I've hacked it with a cast from time_t to (int) in
 timezone/pgtz.c: get_timezone_offset
 
 but timezone really is of time_t, not int. I don't know what you are 
 trying to do here.
 
 
 There's on remaining issue for the cygwin build:
 ../../src/port/libpgport.a(dirmod.o)(.text+0x5ee):dirmod.c: undefined 
 reference to `__imp__CurrentMemoryContext'
 ../../src/port/libpgport.a(dirmod.o)(.text+0x64b):dirmod.c: undefined 
 reference to `__imp__CurrentMemoryContext'
 
 which explains the pgport_palloc problem.
 -- 
 Reini Urban
 http://xarch.tu-graz.ac.at/home/rurban/
 
 
 
 2004-08-24 20:20:54 rurban: 
   * cygwin needs different header locations, and unlink is a macro
   * There are no pgport_palloc versions yet
 
 --- postgresql-8.0.0beta1/src/port/dirmod.c.orig  2004-08-08 07:44:36.0 
 +0100
 +++ postgresql-8.0.0beta1/src/port/dirmod.c   2004-08-24 19:20:56.557435000 
 +0100
 @@ -33,16 +33,28 @@
 
 
 #include miscadmin.h
 +
 +#ifdef __CYGWIN__
 +#include windows.h
 +#include w32api/winioctl.h
 +#else
 #include winioctl.h
 +#undef unlink
 +#endif
 
 #undef rename
 -#undef unlink
 
 +/* 2004-08-24 20:20:54 rurban: There are no pgport_palloc versions yet */
 +#if 0 
 #ifndef FRONTEND
 +#undef palloc
 +#undef pstrdup
 +#undef pfree
 #define palloc(sz)pgport_palloc(sz)
 #define pstrdup(str)  pgport_pstrdup(str)
 #define pfree(pointer)pgport_pfree(pointer)
 #endif
 +#endif
 
 
 /*
 
 
 2004-08-24 21:23:53 [EMAIL PROTECTED]
   * struct timeval is declared in sys/time.h, not in time.h
 
 --- postgresql-8.0.0beta1/src/backend/postmaster/syslogger.c.orig 2004-08-06 
 20:17:31.0 +0100
 +++ postgresql-8.0.0beta1/src/backend/postmaster/syslogger.c  2004-08-24 
 20:21:26.057851800 +0100
 @@ -28,6 +28,7 @@
 #include signal.h
 #include time.h
 #include unistd.h
 +#include sys/time.h
 #include sys/stat.h
 
 #include libpq/pqsignal.h
 
 
 --- postgresql-8.0.0beta1/src/timezone/pgtz.c.orig2004-07-31 
 20:12:15.0 +0100
 +++ postgresql-8.0.0beta1/src/timezone/pgtz.c 2004-08-24 19:56:30.686367800 
 +0100
 @@ -97,9 +97,9 @@
   return tm-tm_gmtoff;
 #elif defined(HAVE_INT_TIMEZONE)
 #ifdef HAVE_UNDERSCORE_TIMEZONE
 - return -_timezone;
 + return -(int)_timezone;
 #else
 - return -timezone;
 + return -(int)timezone;
 #endif
 #else
 #error No way to determine TZ? Can this happen?
 
 
 ---(end of broadcast)---
 TIP 9: the planner will ignore your desire to choose an index scan if your

Re: [PATCHES] time_t timezone

2004-08-31 Thread Reini Urban
Now I've found time to test beta2 and came up
with the attached better patch:
Added configure time_t timezone check for the SUSV definition.
Not only cygwin, all newlib installations without struct tm timezone.
Casted to (int) timezone.
(configure should really be re-created by autoconf. I patched it just 
for completeness in the forthcoming cygwin package.)

Bruce Momjian schrieb:
OK, patch attached and applied that casts _timezone to (int) on Cygwin.
---
Reini Urban wrote:
Bruce Momjian schrieb:
Should I apply this change?
#define TIMEZONE_GLOBAL ((int)_timezone)
yes, please.
I have no time yet, to come up with the better patch. It's already  monday.

---
Reini Urban wrote:

Bruce Momjian schrieb:

Your patch highlighted several bugs in our code.  First, I wasn't
testing for CYGWIN in the backend pgport_palloc code.  Second, I added
an #undef to prevent compiler warnings.  Third I added your Cygwin
includes with an #ifdef.  These will appear in beta2.
On the timezone issue, I see this in dt.h:

/* Global variable holding time zone information. */
#if !defined(__CYGWIN__)  !defined(WIN32)
#define TIMEZONE_GLOBAL timezone
#else
#define TIMEZONE_GLOBAL _timezone
#define tzname _tzname  /* should be in time.h? */
#endif
so are you saying your _timezone is time_t and not an int?  Sometimes it
is just a short because it is only minutes west of GMT, not an actually
seconds since 1970 or anything.  Making it time_t actually sounds like
overkill, but we can work around that in dt.h if indeed that is how your
OS defines it.  The easiest fix would probably be to add the cast to int
right in dt.h and only for Cygwin:
#define TIMEZONE_GLOBAL ((int)_timezone)
Does that work for you?
yes, that's better.
FYI /usr/include/time.h:
/* defines for the opengroup specifications Derived from Issue 1 of the 
SVID.  */
extern __IMPORT time_t _timezone;
...

BTW: I see that CYGWIN also has a struct timezone in sys/time.h, but 
configure didn't check for that.
I'll come with better patches after beta2.



---
Reini Urban wrote:

Attached patches are required for cygwin:
2004-08-24 21:23:53 [EMAIL PROTECTED]
* (postmaster/syslogger.c) struct timeval is
declared in sys/time.h, not in time.h
2004-08-24 20:20:54 rurban:
* (port/dirmod.c) cygwin needs different header locations,
and unlink is a macro. There are no pgport_palloc
versions yet
timezone/pgtz.c:
Pending is a patch against postgresql-8.0.0beta1/config/c-library.m4:
PGAC_VAR_INT_TIMEZONE
In the meantime I've hacked it with a cast from time_t to (int) in
timezone/pgtz.c: get_timezone_offset
but timezone really is of time_t, not int. I don't know what you are 
trying to do here.

There's on remaining issue for the cygwin build:
../../src/port/libpgport.a(dirmod.o)(.text+0x5ee):dirmod.c: undefined 
reference to `__imp__CurrentMemoryContext'
../../src/port/libpgport.a(dirmod.o)(.text+0x64b):dirmod.c: undefined 
reference to `__imp__CurrentMemoryContext'

which explains the pgport_palloc problem.
--
Reini Urban
http://xarch.tu-graz.ac.at/home/rurban/

2004-08-24 20:20:54 rurban: 
	* cygwin needs different header locations, and unlink is a macro
	* There are no pgport_palloc versions yet

--- postgresql-8.0.0beta1/src/port/dirmod.c.orig2004-08-08 07:44:36.0 
+0100
+++ postgresql-8.0.0beta1/src/port/dirmod.c 2004-08-24 19:20:56.557435000 +0100
@@ -33,16 +33,28 @@
#include miscadmin.h
+
+#ifdef __CYGWIN__
+#include windows.h
+#include w32api/winioctl.h
+#else
#include winioctl.h
+#undef unlink
+#endif
#undef rename
-#undef unlink
+/* 2004-08-24 20:20:54 rurban: There are no pgport_palloc versions yet */
+#if 0 
#ifndef FRONTEND
+#undef palloc
+#undef pstrdup
+#undef pfree
#define palloc(sz)	pgport_palloc(sz)
#define pstrdup(str)	pgport_pstrdup(str)
#define pfree(pointer)	pgport_pfree(pointer)
#endif
+#endif

/*

2004-08-24 21:23:53 [EMAIL PROTECTED]
* struct timeval is declared in sys/time.h, not in time.h
--- postgresql-8.0.0beta1/src/backend/postmaster/syslogger.c.orig   2004-08-06 
20:17:31.0 +0100
+++ postgresql-8.0.0beta1/src/backend/postmaster/syslogger.c2004-08-24 
20:21:26.057851800 +0100
@@ -28,6 +28,7 @@
#include signal.h
#include time.h
#include unistd.h
+#include sys/time.h
#include sys/stat.h
#include libpq/pqsignal.h

--- postgresql-8.0.0beta1/src/timezone/pgtz.c.orig  2004-07-31 20:12:15.0 
+0100
+++ postgresql-8.0.0beta1/src/timezone/pgtz.c   2004-08-24 19:56:30.686367800 +0100
@@ -97,9 +97,9 @@
return tm-tm_gmtoff;
#elif defined(HAVE_INT_TIMEZONE)
#ifdef HAVE_UNDERSCORE_TIMEZONE
-   return -_timezone;
+   return -(int)_timezone;
#else
-   return -timezone;
+ 

Re: [PATCHES] time_t timezone

2004-08-31 Thread Tom Lane
Reini Urban [EMAIL PROTECTED] writes:
 Added configure time_t timezone check for the SUSV definition.

Kindly do not claim that this is per SUS spec.

http://www.opengroup.org/onlinepubs/007908799/xsh/timezone.html

regards, tom lane

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