Re: [HACKERS] [PATCHES] xlog directory at initdb time

2007-01-06 Thread Bruce Momjian

Patch applied.  Thanks.

---


Euler Taveira de Oliveira wrote:
> Peter Eisentraut wrote:
> 
> > On the name of the option, it's not actually a "data" directory, so I'd 
> > just 
> > call it --xlogdir, parallel to --datadir.
> > 
> Seems reasonable. Patch modified is attached.
> 
> 
> -- 
>   Euler Taveira de Oliveira
>   http://www.timbira.com/

[ Attachment, skipping... ]

> 
> ---(end of broadcast)---
> TIP 4: Have you searched our list archives?
> 
>http://archives.postgresql.org

-- 
  Bruce Momjian   [EMAIL PROTECTED]
  EnterpriseDBhttp://www.enterprisedb.com

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

---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


Re: [HACKERS] [PATCHES] xlog directory at initdb time

2007-01-03 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.

---

Euler Taveira de Oliveira wrote:
> Peter Eisentraut wrote:
> 
> > On the name of the option, it's not actually a "data" directory, so I'd 
> > just 
> > call it --xlogdir, parallel to --datadir.
> > 
> Seems reasonable. Patch modified is attached.
> 
> 
> -- 
>   Euler Taveira de Oliveira
>   http://www.timbira.com/

[ Attachment, skipping... ]

> 
> ---(end of broadcast)---
> TIP 4: Have you searched our list archives?
> 
>http://archives.postgresql.org

-- 
  Bruce Momjian   [EMAIL PROTECTED]
  EnterpriseDBhttp://www.enterprisedb.com

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

---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


Re: [HACKERS] [PATCHES] xlog directory at initdb time

2007-01-03 Thread Euler Taveira de Oliveira
Peter Eisentraut wrote:

> On the name of the option, it's not actually a "data" directory, so I'd just 
> call it --xlogdir, parallel to --datadir.
> 
Seems reasonable. Patch modified is attached.


-- 
  Euler Taveira de Oliveira
  http://www.timbira.com/
*** ./doc/src/sgml/ref/initdb.sgml.orig 2006-09-15 21:30:18.0 -0300
--- ./doc/src/sgml/ref/initdb.sgml  2007-01-03 23:34:13.0 -0200
***
*** 177,182 
--- 177,193 
   
  
   
+   -X directory
+   --xlogdir=directory
+   
+
+ This option specifies the directory where the transaction log
+ should be stored. This option is only supported on systems that 
support symbolic links.
+
+   
+  
+ 
+  
-U username
--username=username

*** ./src/bin/initdb/initdb.c.orig  2006-12-22 22:43:12.0 -0200
--- ./src/bin/initdb/initdb.c   2007-01-03 23:34:45.0 -0200
***
*** 95,100 
--- 95,101 
  static bool debug = false;
  static bool noclean = false;
  static bool show_setting = false;
+ static char *xlog_dir = "";
  
  
  /* internal vars */
***
*** 112,117 
--- 113,120 
  static char *system_views_file;
  static bool made_new_pgdata = false;
  static bool found_existing_pgdata = false;
+ static bool made_new_xlogdir = false;
+ static bool found_existing_xlogdir = false;
  static char infoversion[100];
  static bool caught_signal = false;
  static bool output_failed = false;
***
*** 163,169 
  static char *get_id(void);
  static char *get_encoding_id(char *encoding_name);
  static char *get_short_version(void);
! static intcheck_data_dir(void);
  static bool mkdatadir(const char *subdir);
  static void set_input(char **dest, char *filename);
  static void check_input(char *path);
--- 166,172 
  static char *get_id(void);
  static char *get_encoding_id(char *encoding_name);
  static char *get_short_version(void);
! static intcheck_data_dir(char *dir);
  static bool mkdatadir(const char *subdir);
  static void set_input(char **dest, char *filename);
  static void check_input(char *path);
***
*** 610,615 
--- 613,636 
fprintf(stderr, _("%s: failed to remove 
contents of data directory\n"),
progname);
}
+ 
+   if (made_new_xlogdir)
+   {
+   fprintf(stderr, _("%s: removing transaction log 
directory \"%s\"\n"),
+   progname, xlog_dir);
+   if (!rmtree(xlog_dir, true))
+   fprintf(stderr, _("%s: failed to remove 
transaction log directory\n"),
+   progname);
+   }
+   else if (found_existing_xlogdir)
+   {
+   fprintf(stderr,
+   _("%s: removing contents of transaction 
log directory \"%s\"\n"),
+   progname, xlog_dir);
+   if (!rmtree(xlog_dir, false))
+   fprintf(stderr, _("%s: failed to remove 
contents of transaction log directory\n"),
+   progname);
+   }
/* otherwise died during startup, do nothing! */
}
else
***
*** 618,623 
--- 639,649 
fprintf(stderr,
  _("%s: data directory \"%s\" not removed at user's 
request\n"),
progname, pg_data);
+ 
+   if (made_new_xlogdir || found_existing_xlogdir)
+   fprintf(stderr,
+ _("%s: transaction log directory \"%s\" not removed 
at user's request\n"),
+   progname, xlog_dir);
}
  
exit(1);
***
*** 919,931 
  }
  
  /*
!  * make sure the data directory either doesn't exist or is empty
   *
   * Returns 0 if nonexistent, 1 if exists and empty, 2 if not empty,
   * or -1 if trouble accessing directory
   */
  static int
! check_data_dir(void)
  {
DIR*chkdir;
struct dirent *file;
--- 945,957 
  }
  
  /*
!  * make sure the directory either doesn't exist or is empty
   *
   * Returns 0 if nonexistent, 1 if exists and empty, 2 if not empty,
   * or -1 if trouble accessing directory
   */
  static int
! check_data_dir(char *dir)
  {
DIR*chkdir;
struct dirent *file;
***
*** 933,939 
  
errno = 0;
  
!   chkdir = opendir(pg_data);
  
if (!chkdir)
return (errno == ENOENT) ? 0 : -1;
--- 959,965 
  
errno = 0;
  
!   chkdir = opendir(dir);
  
if (!chkdir)
return (errno == ENOENT) ? 0 : -1;
***
*

Re: [HACKERS] [PATCHES] xlog directory at initdb time

2007-01-03 Thread Peter Eisentraut
Am Mittwoch, 27. Dezember 2006 02:56 schrieb Euler Taveira de Oliveira:
> This simple patch lets someone specifies the xlog directory at initdb
> time. It uses symlinks to do it, and create and/or set permissions at
> the directory as appropriate.

On the name of the option, it's not actually a "data" directory, so I'd just 
call it --xlogdir, parallel to --datadir.

-- 
Peter Eisentraut
http://developer.postgresql.org/~petere/

---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


Re: [HACKERS] [PATCHES] xlog directory at initdb time

2007-01-02 Thread Alvaro Herrera
Tom Lane wrote:
> Casey Duncan <[EMAIL PROTECTED]> writes:
> > I guess the downside there is that it won't work on platforms that  
> > don't support symlinks, whereas the postmaster switch would. Not that  
> > I condone using such platforms ;^)
> 
> Well, we already bit that bullet with respect to tablespaces, and
> haven't gotten much of any pushback.  So I don't see it as a problem
> here.

Note that if Casey is thinking that Win32 does not support symlinks, he
is wrong (we do support tablespaces there).

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

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


Re: [HACKERS] [PATCHES] xlog directory at initdb time

2007-01-02 Thread Tom Lane
Casey Duncan <[EMAIL PROTECTED]> writes:
> I guess the downside there is that it won't work on platforms that  
> don't support symlinks, whereas the postmaster switch would. Not that  
> I condone using such platforms ;^)

Well, we already bit that bullet with respect to tablespaces, and
haven't gotten much of any pushback.  So I don't see it as a problem
here.

regards, tom lane

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


Re: [HACKERS] [PATCHES] xlog directory at initdb time

2007-01-02 Thread Casey Duncan


On Jan 2, 2007, at 7:18 AM, Tom Lane wrote:


Peter Eisentraut <[EMAIL PROTECTED]> writes:
Am Mittwoch, 27. Dezember 2006 02:56 schrieb Euler Taveira de  
Oliveira:
This simple patch lets someone specifies the xlog directory at  
initdb
time. It uses symlinks to do it, and create and/or set  
permissions at

the directory as appropriate.


We already had this functionality in initdb a few versions ago.   
Did you

review why it was removed?


The discussion thread seems to start here:

http://archives.postgresql.org/pgsql-hackers/2002-08/msg00306.php

As best I can tell the objections came from the fact that Thomas had
implemented it as a postmaster-start-time switch, which made it a
foot-gun because you could mistakenly start the postmaster with a
different XLOG than you were using before.  That would not apply to a
symlink-made-by-initdb approach.  All this is doing is formalizing
something we already suggest people do by hand...


I guess the downside there is that it won't work on platforms that  
don't support symlinks, whereas the postmaster switch would. Not that  
I condone using such platforms ;^)


-Casey

---(end of broadcast)---
TIP 1: 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: [HACKERS] [PATCHES] xlog directory at initdb time

2007-01-02 Thread Bruce Momjian
Tom Lane wrote:
> Peter Eisentraut <[EMAIL PROTECTED]> writes:
> > Am Mittwoch, 27. Dezember 2006 02:56 schrieb Euler Taveira de Oliveira:
> >> This simple patch lets someone specifies the xlog directory at initdb
> >> time. It uses symlinks to do it, and create and/or set permissions at
> >> the directory as appropriate.
> 
> > We already had this functionality in initdb a few versions ago.  Did you 
> > review why it was removed?
> 
> The discussion thread seems to start here:
> 
> http://archives.postgresql.org/pgsql-hackers/2002-08/msg00306.php
> 
> As best I can tell the objections came from the fact that Thomas had
> implemented it as a postmaster-start-time switch, which made it a
> foot-gun because you could mistakenly start the postmaster with a
> different XLOG than you were using before.  That would not apply to a
> symlink-made-by-initdb approach.  All this is doing is formalizing
> something we already suggest people do by hand...

Right.  Thomas decided he didn't want to adjust the patch based on
community input, so the patch was removed.  It was one of the few cases
where I had to back out someone else's patch against their will.

-- 
  Bruce Momjian   [EMAIL PROTECTED]
  EnterpriseDBhttp://www.enterprisedb.com

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

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

   http://archives.postgresql.org


Re: [HACKERS] [PATCHES] xlog directory at initdb time

2007-01-02 Thread Tom Lane
Peter Eisentraut <[EMAIL PROTECTED]> writes:
> Am Mittwoch, 27. Dezember 2006 02:56 schrieb Euler Taveira de Oliveira:
>> This simple patch lets someone specifies the xlog directory at initdb
>> time. It uses symlinks to do it, and create and/or set permissions at
>> the directory as appropriate.

> We already had this functionality in initdb a few versions ago.  Did you 
> review why it was removed?

The discussion thread seems to start here:

http://archives.postgresql.org/pgsql-hackers/2002-08/msg00306.php

As best I can tell the objections came from the fact that Thomas had
implemented it as a postmaster-start-time switch, which made it a
foot-gun because you could mistakenly start the postmaster with a
different XLOG than you were using before.  That would not apply to a
symlink-made-by-initdb approach.  All this is doing is formalizing
something we already suggest people do by hand...

regards, tom lane

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


Re: [HACKERS] [PATCHES] xlog directory at initdb time

2007-01-02 Thread Peter Eisentraut
Am Mittwoch, 27. Dezember 2006 02:56 schrieb Euler Taveira de Oliveira:
> This simple patch lets someone specifies the xlog directory at initdb
> time. It uses symlinks to do it, and create and/or set permissions at
> the directory as appropriate.

We already had this functionality in initdb a few versions ago.  Did you 
review why it was removed?
-- 
Peter Eisentraut
http://developer.postgresql.org/~petere/

---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq