[PATCHES] Command args user password

2005-08-15 Thread NosyMan
Hi there,

What about a command line switch which allow the user to send password via 
command line arg? For example:

./vacuumdb -U username -p password

This way vacuumdb can be run by cron without  trust-ing any user in 
pg_hba.conf.

I have patched PostgreSQL 8.0.3 source to allow password as arg for:
vacuumdb, pg_dump and pg_restore. If anyone interested please reply.

Thanks,
NosyMan
 

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


Re: [PATCHES] psql tab-complete and backslash patch

2005-08-15 Thread Stefan Kaltenbrunner
Tom Lane wrote:
 Stefan Kaltenbrunner [EMAIL PROTECTED] writes:
 
attached is a patch against psql that makes psql's tabcomplete code
ROLES aware, adds SET SCHEMA and basic CREATE DATABASE/TRIGGER support
as well as some other minor things.
 
 
 Applied with some changes.  I didn't see the point of making \du
 backwards compatible to older versions; we've never worried about that
 before in psql's \d commands.  Also I thought the Attributes approach
 of the old \du code was well past its usefulness, so I just changed it
 to separate columns.


thanks for applying!
While I know that we have never guaranteed backwards-compatibility for
psql's backslash commands (or for tab-complete either) I modeled this
after the \db-tablespace code. Removing it altogether is fine too :-)
Any particular reason why you dropped the SET SCHEMA tab part of my
patch ?


Stefan

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


Re: [PATCHES] Command args user password

2005-08-15 Thread Abhijit Menon-Sen
At 2005-08-15 10:09:39 +0300, [EMAIL PROTECTED] wrote:

 ./vacuumdb -U username -p password
 
 This way vacuumdb can be run by cron without  trust-ing any
 user in pg_hba.conf.

http://www.postgresql.org/docs/current/static/libpq-pgpass.html

-- ams

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

   http://archives.postgresql.org


Re: [PATCHES] psql tab-complete and backslash patch

2005-08-15 Thread Tom Lane
Stefan Kaltenbrunner [EMAIL PROTECTED] writes:
 Any particular reason why you dropped the SET SCHEMA tab part of my
 patch ?

Because we have no such command.

regards, tom lane

---(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: [PATCHES] Command args user password

2005-08-15 Thread Tom Lane
NosyMan [EMAIL PROTECTED] writes:
 What about a command line switch which allow the user to send password via 
 command line arg?

You do realize that such a password could be seen by every other user on
the machine, using ps?

regards, tom lane

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


Re: [PATCHES] PL/pgSQL: SELECT INTO EXACT

2005-08-15 Thread Matt Miller
On Fri, 2005-08-12 at 21:53 -0400, Bruce Momjian wrote:
 This has been saved for the 8.2 release:

Just to clarify: the SELECT INTO EXACT patch was abandoned in favor of
the #option select_into_1_row patch.  I submitted both patches as part
of the same -patches thread, but the latter solution, the #option
select_into_1_row patch, superseded the SELECT INTO EXACT idea.

The correct patch is at
http://archives.postgresql.org/pgsql-patches/2005-08/msg00070.php  This
should be the only patch that gets applied.

---(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: [PATCHES] [HACKERS] pg_stat_file() and length/size

2005-08-15 Thread Bruce Momjian
Bruce Momjian wrote:
 I am thinking the proper term for the first column of pg_stat_file() is
 size, not length.
 
   test= select * from pg_stat_file('.');
length | atime  | mtime  | 
 ctime  | isdir
   
 ++++---
   
   512 | 2005-08-13 23:06:38-04 | 2005-08-13 23:06:54-04 | 2005-08-13 
 23:06:54-04 | t
   (1 row)

I have renamed the column from length to size.  I also renamed the
timestamp columns to be more meaningful:

test= select (pg_stat_file('.')).*;
 size | access |  modification  | 
change | creation | isdir

--++++--+---
  512 | 2005-08-15 18:10:10-04 | 2005-08-15 17:30:28-04 | 2005-08-15 
17:30:28-04 |  | t
(1 row)

(Anyone have a better name for change?)

In doing this I also realized the ctime on Unix is change time (file
contents or inode), while on Win32 ctime is file creation time.  I split
the ctime column into change and creation, and one is null on each
platform.  Above is the Unix output.  I have also updated the catalog
version.

-- 
  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: doc/src/sgml/func.sgml
===
RCS file: /cvsroot/pgsql/doc/src/sgml/func.sgml,v
retrieving revision 1.280
diff -c -c -r1.280 func.sgml
*** doc/src/sgml/func.sgml  13 Aug 2005 19:02:32 -  1.280
--- doc/src/sgml/func.sgml  15 Aug 2005 22:35:59 -
***
*** 9414,9425 
 /indexterm
 para
  functionpg_stat_file()/ returns a record containing the file
! length, last accessed timestamp, last modified timestamp, 
! creation timestamp, and a boolean indicating if it is a directory.
! Typical usages include:
  programlisting
  SELECT * FROM pg_stat_file('filename');
! SELECT (pg_stat_file('filename')).mtime;
  /programlisting
 /para
  
--- 9414,9426 
 /indexterm
 para
  functionpg_stat_file()/ returns a record containing the file
! size, last accessed timestamp, last modified timestamp, 
! last file status change timestamp (Unix platforms only), 
! file creation timestamp (Win32 only), and a boolean indicating 
! if it is a directory.  Typical usages include:
  programlisting
  SELECT * FROM pg_stat_file('filename');
! SELECT (pg_stat_file('filename')).modification;
  /programlisting
 /para
  
Index: src/backend/catalog/system_views.sql
===
RCS file: /cvsroot/pgsql/src/backend/catalog/system_views.sql,v
retrieving revision 1.20
diff -c -c -r1.20 system_views.sql
*** src/backend/catalog/system_views.sql15 Aug 2005 16:25:17 -  
1.20
--- src/backend/catalog/system_views.sql15 Aug 2005 22:35:59 -
***
*** 346,353 
   'timestamptz',
   'timestamptz',
   'timestamptz',
   'bool'],
!   proargmodes = ARRAY['i'::char, 'o', 'o', 'o', 'o', 'o'],
!   proargnames = ARRAY['filename'::text,
!   'length', 'atime', 'mtime', 'ctime','isdir']
  WHERE oid = 'pg_stat_file(text)'::regprocedure;
--- 346,354 
   'timestamptz',
   'timestamptz',
   'timestamptz',
+  'timestamptz',
   'bool'],
!   proargmodes = ARRAY['i'::char, 'o', 'o', 'o', 'o', 'o', 'o'],
!   proargnames = ARRAY['filename'::text, 'size', 'access', 'modification',
! 'change', 'creation', 'isdir']
  WHERE oid = 'pg_stat_file(text)'::regprocedure;
Index: src/backend/utils/adt/genfile.c
===
RCS file: /cvsroot/pgsql/src/backend/utils/adt/genfile.c,v
retrieving revision 1.4
diff -c -c -r1.4 genfile.c
*** src/backend/utils/adt/genfile.c 13 Aug 2005 19:02:34 -  1.4
--- src/backend/utils/adt/genfile.c 15 Aug 2005 22:36:00 -
***
*** 154,161 
text   *filename_t = PG_GETARG_TEXT_P(0);
char*filename;
struct stat fst;
!   Datum   values[5];
!   boolisnull[5];
HeapTuple   tuple;
TupleDesc   tupdesc;
  
--- 154,161 
text   *filename_t = PG_GETARG_TEXT_P(0);
char*filename;
struct stat fst;
!   Datum   values[6];
!   boolisnull[6];
HeapTuple   tuple;

Re: [PATCHES] enable/disable trigger (Re: Fwd: [HACKERS] Open items)

2005-08-15 Thread Satoshi Nagayasu
The message format for elog() report is cleaned up.

-- 
NAGAYASU Satoshi [EMAIL PROTECTED]
diff -cr pgsql.orig/src/backend/commands/tablecmds.c 
pgsql/src/backend/commands/tablecmds.c
*** pgsql.orig/src/backend/commands/tablecmds.c 2005-06-28 14:08:54.0 
+0900
--- pgsql/src/backend/commands/tablecmds.c  2005-08-08 13:46:44.0 
+0900
***
*** 236,241 
--- 236,243 

  Oid newOwnerId);
  static void ATExecClusterOn(Relation rel, const char *indexName);
  static void ATExecDropCluster(Relation rel);
+ static void ATExecEnableDisableTrigger(Relation rel, char *trigname,
+  bool 
enable);
  static void ATPrepSetTableSpace(AlteredTableInfo *tab, Relation rel,
char *tablespacename);
  static void ATExecSetTableSpace(Oid tableOid, Oid newTableSpace);
***
*** 1993,1998 
--- 1995,2005 
}
pass = AT_PASS_DROP;
break;
+   case AT_EnableTrig: /* ENABLE TRIGGER */
+   case AT_DisableTrig:/* DISABLE TRIGGER */
+   ATSimplePermissions(rel, false);
+   pass = AT_PASS_MISC;
+   break;
case AT_SetTableSpace:  /* SET TABLESPACE */
/* This command never recurses */
ATPrepSetTableSpace(tab, rel, cmd-name);
***
*** 2155,2160 
--- 2162,2173 
 * Nothing to do here; Phase 3 does the work
 */
break;
+   case AT_EnableTrig: /* ENABLE TRIGGER */
+   ATExecEnableDisableTrigger(rel, cmd-name, true);
+   break;
+   case AT_DisableTrig:/* DISABLE TRIGGER */
+   ATExecEnableDisableTrigger(rel, cmd-name, false);
+   break;
default:/* oops */
elog(ERROR, unrecognized alter table type: %d,
 (int) cmd-subtype);
***
*** 5465,5470 
--- 5478,5492 
  }
  
  /*
+  * ALTER TABLE ENABLE/DISABLE TRIGGER
+  */
+ static void
+ ATExecEnableDisableTrigger(Relation rel, char *trigname, bool enable)
+ {
+   EnableDisableTrigger(rel, trigname, enable);
+ }
+ 
+ /*
   * ALTER TABLE SET TABLESPACE
   */
  static void
diff -cr pgsql.orig/src/backend/commands/trigger.c 
pgsql/src/backend/commands/trigger.c
*** pgsql.orig/src/backend/commands/trigger.c   2005-05-30 16:20:58.0 
+0900
--- pgsql/src/backend/commands/trigger.c2005-08-16 11:23:47.0 
+0900
***
*** 3063,3065 
--- 3063,3174 
afterTriggerAddEvent(new_event);
}
  }
+ 
+ /* --
+  * EnableDisableTrigger()
+  *
+  *Called by ALTER TABLE ENABLE/DISABLE TRIGGER
+  *  to change 'tgenabled' flag in the pg_trigger.
+  * --
+  */
+ void
+ EnableDisableTrigger(Relation rel, const char *tgname, bool enable)
+ {
+   Relation tgrel;
+   SysScanDesc tgscan;
+   ScanKeyData keys[2];
+   HeapTuple tuple;
+   int nkeys;
+   int changed;
+ 
+   /* Permissions checks */
+   if (!pg_class_ownercheck(RelationGetRelid(rel), GetUserId()))
+   aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_CLASS,
+  RelationGetRelationName(rel));
+ 
+   if (!allowSystemTableMods  IsSystemRelation(rel))
+   ereport(ERROR,
+   (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
+errmsg(permission denied: \%s\ is a system 
catalog,
+   RelationGetRelationName(rel;
+ 
+   tgrel = heap_open(TriggerRelationId, RowExclusiveLock);
+ 
+   nkeys = 2;
+   changed = 0;
+   if ( strcmp(tgname, *)==0 )
+   {
+   if ( !superuser() )
+   ereport(ERROR,
+   
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
+errmsg(ENABLE/DISABLE TRIGGER ALL is 
allowed superuser only.)));
+ 
+   nkeys = 1;
+   }
+ 
+   ScanKeyInit(keys[0],
+   Anum_pg_trigger_tgrelid,
+   BTEqualStrategyNumber, F_OIDEQ,
+   ObjectIdGetDatum(RelationGetRelid(rel)));
+   ScanKeyInit(keys[1],
+   Anum_pg_trigger_tgname,
+   BTEqualStrategyNumber, F_NAMEEQ,
+   CStringGetDatum(tgname));
+ 
+   tgscan = systable_beginscan(tgrel, TriggerRelidNameIndexId, true,
+