Re: [PATCHES] [HACKERS] psql \h alter scrolls of screen

2003-09-11 Thread Bruce Momjian
Tom Lane wrote:
 Robert Treat [EMAIL PROTECTED] writes:
  On Thu, 2003-09-04 at 21:14, Bruce Momjian wrote:
  Should we be using the pager for \h output?
 
  in 7.3.4 we do, let me check 7.4...seems to work, though I am on beta1
  on this box.
 
 Hmm.  I do not see the pager used for \h in either version, though it
 does get used for \? ...

OK, turns out the '\h alter' code does a simple printf(), not a
PageOutput() and fprintf() to that pipe.  Various \h outputs are long,
including CREATE TABLE, GRANT, and ALTER TABLE.  ALTER itself is really
larger because it prints all the ALTER commands help.

The attached patch counts the number of newlines output by \h command,
and invokes the pager where appropriate.

This isn't a bug fix, so it will be kept for 7.5.

-- 
  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
Index: src/bin/psql/help.c
===
RCS file: /cvsroot/pgsql-server/src/bin/psql/help.c,v
retrieving revision 1.78
diff -c -c -r1.78 help.c
*** src/bin/psql/help.c 10 Sep 2003 21:35:55 -  1.78
--- src/bin/psql/help.c 10 Sep 2003 22:12:39 -
***
*** 303,322 
{
int i;
boolhelp_found = false;
size_t  len;
! 
/* don't care about trailing spaces */
len = strlen(topic);
while (topic[len - 1] == ' ')
len--;
  
for (i = 0; QL_HELP[i].cmd; i++)
{
if (strncasecmp(topic, QL_HELP[i].cmd, len) == 0 ||
strcmp(topic, *) == 0)
{
help_found = true;
!   printf(_(Command: %s\n
 Description: %s\n
 Syntax:\n%s\n\n),
 QL_HELP[i].cmd, QL_HELP[i].help, 
QL_HELP[i].syntax);
--- 303,343 
{
int i;
boolhelp_found = false;
+   FILE   *output;
size_t  len;
!   int nl_count = 0;
!   char*ch;
!   
/* don't care about trailing spaces */
len = strlen(topic);
while (topic[len - 1] == ' ')
len--;
  
+   /* Count newlines for pager */
+   for (i = 0; QL_HELP[i].cmd; i++)
+   {
+   if (strncasecmp(topic, QL_HELP[i].cmd, len) == 0 ||
+   strcmp(topic, *) == 0)
+   {
+   nl_count += 5;
+   for (ch = QL_HELP[i].syntax; *ch != '\0'; ch++)
+   if (*ch == '\n')
+   nl_count++;
+   /* If we have an exact match, exit.  Fixes \h SELECT */
+   if (strcasecmp(topic, QL_HELP[i].cmd) == 0)
+   break;
+   }
+   }
+ 
+   output = PageOutput(nl_count, pager);
+ 
for (i = 0; QL_HELP[i].cmd; i++)
{
if (strncasecmp(topic, QL_HELP[i].cmd, len) == 0 ||
strcmp(topic, *) == 0)
{
help_found = true;
!   fprintf(output, _(Command: %s\n
 Description: %s\n
 Syntax:\n%s\n\n),
 QL_HELP[i].cmd, QL_HELP[i].help, 
QL_HELP[i].syntax);
***
*** 327,333 
}
  
if (!help_found)
!   printf(_(No help available for \%-.*s\.\nTry \\h with no 
arguments to see available help.\n), (int) len, topic);
}
  }
  
--- 348,363 
}
  
if (!help_found)
!   fprintf(output, _(No help available for \%-.*s\.\nTry \\h 
with no arguments to see available help.\n), (int) len, topic);
! 
!   /* Only close if we used the pager */
!   if (output != stdout)
!   {
!   pclose(output);
! #ifndef WIN32
!   pqsignal(SIGPIPE, SIG_DFL);
! #endif
!   }
}
  }
  

---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
   

Re: [PATCHES] fix doc typo

2003-09-11 Thread Bruce Momjian

Patch applied.  Thanks.

---


Neil Conway wrote:
 This patch fixes a trivial typo in the CREATE FUNCTION ref page.
 
 -Neil
 

[ Attachment, skipping... ]

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

-- 
  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 6: Have you searched our list archives?

   http://archives.postgresql.org


[PATCHES] Regression test for stats collector

2003-09-11 Thread Manfred Koizar
With pg_autovacuum becoming increasingly popular it's important to
have a working stats collector.  This test is able to discover the
problem that was present in 7.4 Beta 2.

Servus
 Manfred
diff -ruN ../base/src/test/regress/expected/stats.out 
src/test/regress/expected/stats.out
--- ../base/src/test/regress/expected/stats.out 1970-01-01 01:00:00.0 +0100
+++ src/test/regress/expected/stats.out 2003-09-10 21:01:49.0 +0200
@@ -0,0 +1,79 @@
+--
+-- Test Statistics Collector
+--
+-- Must be run after tenk2 has been created (by create_table),
+-- populated (by create_misc) and indexed (by create_index).
+--
+-- conditio sine qua non
+SHOW stats_start_collector;  -- must be on
+ stats_start_collector
+---
+ on
+(1 row)
+
+-- save counters
+CREATE TEMP TABLE prevstats AS
+SELECT t.seq_scan, t.seq_tup_read, t.idx_scan, t.idx_tup_fetch,
+   (b.heap_blks_read + b.heap_blks_hit) AS heap_blks,
+   (b.idx_blks_read + b.idx_blks_hit) AS idx_blks
+  FROM pg_catalog.pg_stat_user_tables AS t,
+   pg_catalog.pg_statio_user_tables AS b
+ WHERE t.relname='tenk2' AND b.relname='tenk2';
+-- enable statistics
+SET stats_block_level = on;
+SET stats_row_level = on;
+-- helper function
+CREATE FUNCTION sleep(interval) RETURNS integer AS '
+DECLARE
+  endtime timestamp;
+BEGIN
+  endtime := timeofday()::timestamp + $1;
+  WHILE timeofday()::timestamp  endtime LOOP
+  END LOOP;
+  RETURN 0;
+END;
+' LANGUAGE 'plpgsql';
+-- do something
+SELECT count(*) FROM tenk2;
+ count
+---
+ 1
+(1 row)
+
+SELECT count(*) FROM tenk2 WHERE unique1 = 1;
+ count
+---
+ 1
+(1 row)
+
+-- let stats collector catch up
+SELECT sleep('0:0:2'::interval);
+ sleep
+---
+ 0
+(1 row)
+
+-- check effects
+SELECT st.seq_scan = pr.seq_scan + 1,
+   st.seq_tup_read = pr.seq_tup_read + cl.reltuples,
+   st.idx_scan = pr.idx_scan + 1,
+   st.idx_tup_fetch = pr.idx_tup_fetch + 1
+  FROM pg_stat_user_tables AS st, pg_class AS cl, prevstats AS pr
+ WHERE st.relname='tenk2' AND cl.relname='tenk2';
+ ?column? | ?column? | ?column? | ?column?
+--+--+--+--
+ t| t| t| t
+(1 row)
+
+SELECT st.heap_blks_read + st.heap_blks_hit = pr.heap_blks + cl.relpages,
+   st.idx_blks_read + st.idx_blks_hit = pr.idx_blks + 1
+  FROM pg_statio_user_tables AS st, pg_class AS cl, prevstats AS pr
+ WHERE st.relname='tenk2' AND cl.relname='tenk2';
+ ?column? | ?column?
+--+--
+ t| t
+(1 row)
+
+-- clean up
+DROP FUNCTION sleep(interval);
+-- End of Stats Test
diff -ruN ../base/src/test/regress/parallel_schedule src/test/regress/parallel_schedule
--- ../base/src/test/regress/parallel_schedule  2003-09-02 20:48:55.0 +0200
+++ src/test/regress/parallel_schedule  2003-09-10 21:02:40.0 +0200
@@ -74,4 +74,4 @@
 # The sixth group of parallel test
 # --
 # plpgsql cannot run concurrently with rules
-test: limit plpgsql copy2 temp domain rangefuncs prepare without_oid conversion 
truncate alter_table sequence polymorphism
+test: limit plpgsql copy2 temp domain rangefuncs prepare without_oid conversion 
truncate alter_table sequence polymorphism stats
diff -ruN ../base/src/test/regress/serial_schedule src/test/regress/serial_schedule
--- ../base/src/test/regress/serial_schedule2003-09-02 20:48:55.0 +0200
+++ src/test/regress/serial_schedule2003-09-10 21:03:16.0 +0200
@@ -94,3 +94,4 @@
 test: alter_table
 test: sequence
 test: polymorphism
+test: stats
diff -ruN ../base/src/test/regress/sql/stats.sql src/test/regress/sql/stats.sql
--- ../base/src/test/regress/sql/stats.sql  1970-01-01 01:00:00.0 +0100
+++ src/test/regress/sql/stats.sql  2003-09-10 21:01:49.0 +0200
@@ -0,0 +1,58 @@
+--
+-- Test Statistics Collector
+--
+-- Must be run after tenk2 has been created (by create_table),
+-- populated (by create_misc) and indexed (by create_index).
+--
+
+-- conditio sine qua non
+SHOW stats_start_collector;  -- must be on
+
+-- save counters
+CREATE TEMP TABLE prevstats AS
+SELECT t.seq_scan, t.seq_tup_read, t.idx_scan, t.idx_tup_fetch,
+   (b.heap_blks_read + b.heap_blks_hit) AS heap_blks,
+   (b.idx_blks_read + b.idx_blks_hit) AS idx_blks
+  FROM pg_catalog.pg_stat_user_tables AS t,
+   pg_catalog.pg_statio_user_tables AS b
+ WHERE t.relname='tenk2' AND b.relname='tenk2';
+
+-- enable statistics
+SET stats_block_level = on;
+SET stats_row_level = on;
+
+-- helper function
+CREATE FUNCTION sleep(interval) RETURNS integer AS '
+DECLARE
+  endtime timestamp;
+BEGIN
+  endtime := timeofday()::timestamp + $1;
+  WHILE timeofday()::timestamp  endtime LOOP
+  END LOOP;
+  RETURN 0;
+END;
+' LANGUAGE 'plpgsql';
+
+-- do something
+SELECT count(*) FROM tenk2;
+SELECT count(*) FROM tenk2 WHERE unique1 = 1;
+
+-- let stats collector catch up
+SELECT sleep('0:0:2'::interval);
+
+-- check effects
+SELECT st.seq_scan = pr.seq_scan + 1,
+   st.seq_tup_read = 

Re: [PATCHES] timetravel.c

2003-09-11 Thread Bruce Momjian

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

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

I will try to apply it within the next 48 hours.

---


Böjthe Zoltán wrote:
 Bruce Momjian ?rta:
 
 Patch applied.  Thanks.
 
 ---
   
 
 Hi!
 
 on my timetravel.c I find a bug: after the
 ALTER TABLE mytable drop column last_column_of_table;
 
 the timetravel trigger say on UPDATE/DELETE:
 
 ERROR:  parser: parse error at end of input
 
 
 Here is the patch for this bug
 
 B?jthe Zolt?n

 --- timetravel.c.prev 2003-06-27 19:56:40.0 +0200
 +++ timetravel.c  2003-09-02 14:53:21.0 +0200
 @@ -306,7 +306,7 @@
   void*pplan;
   Oid *ctypes;
   charsql[8192];
 - int j;
 + charsepar=' ';
  
   /* allocate ctypes for preparation */
   ctypes = (Oid *) palloc(natts * sizeof(Oid));
 @@ -319,11 +319,12 @@
   {
   ctypes[i - 1] = SPI_gettypeid(tupdesc, i);
   if(!(tupdesc-attrs[i - 1]-attisdropped))  /* skip 
 dropped columns */
 - snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), 
 $%d%s,
 - i, (i  natts) ? ,  : ) );
 -//   snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), 
 $%d /* %d */ %s,
 -//   i, ctypes[i-1], (i  natts) ? ,  : ) );
 + {
 + snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), 
 %c$%d, separ,i);
 + separ = ',';
 + }
   }
 + snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), ));
  
  //   elog(NOTICE, timetravel (%s) update: sql: %s, relname, sql);
  

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

-- 
  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 9: the planner will ignore your desire to choose an index scan if your
  joining column's datatypes do not match


[PATCHES] Chinese NLS patch for 7.4

2003-09-11 Thread Weiping He
download from the link below:

http://www.pgsqldb.org/pgsql-po-zh_CN.tar.gz

sorry for the inconvenience, for I'm afraid of filled
out by anti-spam system.
Thanks

Laser



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


[PATCHES] message not following the guidelines

2003-09-11 Thread Alvaro Herrera
This message seems to be breaking the message guidelines.

-- 
Alvaro Herrera (alvherre[a]dcc.uchile.cl)
Porque francamente, si para saber manejarse a uno mismo hubiera que
rendir examen... ¿Quién es el machito que tendría carnet?  (Mafalda)
Index: opclasscmds.c
===
RCS file: /respaldo/alvherre/cvs/pgsql-server/src/backend/commands/opclasscmds.c,v
retrieving revision 1.18
diff -c -r1.18 opclasscmds.c
*** opclasscmds.c   17 Aug 2003 19:58:04 -  1.18
--- opclasscmds.c   11 Sep 2003 02:08:19 -
***
*** 195,201 
if (procedures[item-number - 1] != InvalidOid)
ereport(ERROR,

(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
!errmsg(DefineOpClass: 
procedure number %d appears more than once,

item-number)));
funcOid = LookupFuncNameTypeNames(item-name, 
item-args,
   
   false);
--- 195,201 
if (procedures[item-number - 1] != InvalidOid)
ereport(ERROR,

(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
!errmsg(procedure number %d 
appears more than once,

item-number)));
funcOid = LookupFuncNameTypeNames(item-name, 
item-args,
   
   false);

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


[PATCHES] pg_hba.conf patch for hostnossl

2003-09-11 Thread Jon Jensen
Hello.

When I sent in the sslmode patch I forgot to update the comments/examples
in pg_hba.conf. This patch remedies that, adds a brief explanation of the
connection types, and adds a missing period in the docs.

JonIndex: doc/src/sgml/client-auth.sgml
===
RCS file: /projects/cvsroot/pgsql-server/doc/src/sgml/client-auth.sgml,v
retrieving revision 1.57
diff -c -r1.57 client-auth.sgml
*** doc/src/sgml/client-auth.sgml   5 Sep 2003 20:31:35 -   1.57
--- doc/src/sgml/client-auth.sgml   11 Sep 2003 00:20:48 -
***
*** 102,108 
para
 This record matches connection attempts using Unix-domain
 sockets.  Without a record of this type, Unix-domain socket
!connections are disallowed
/para
   /listitem
  /varlistentry
--- 102,108 
para
 This record matches connection attempts using Unix-domain
 sockets.  Without a record of this type, Unix-domain socket
!connections are disallowed.
/para
   /listitem
  /varlistentry
Index: src/backend/libpq/pg_hba.conf.sample
===
RCS file: /projects/cvsroot/pgsql-server/src/backend/libpq/pg_hba.conf.sample,v
retrieving revision 1.46
diff -c -r1.46 pg_hba.conf.sample
*** src/backend/libpq/pg_hba.conf.sample7 Sep 2003 03:36:03 -   1.46
--- src/backend/libpq/pg_hba.conf.sample11 Sep 2003 00:20:48 -
***
*** 7,21 
  #
  # This file controls: which hosts are allowed to connect, how clients
  # are authenticated, which PostgreSQL user names they can use, which
! # databases they can access.  Records take one of five forms:
  #
! # localDATABASE  USER  METHOD  [OPTION]
! # host DATABASE  USER  IP-ADDRESS  IP-MASK   METHOD  [OPTION]
! # hostssl  DATABASE  USER  IP-ADDRESS  IP-MASK   METHOD  [OPTION]
! # host DATABASE  USER  IP-ADDRESS/CIDR-MASK  METHOD  [OPTION]
! # hostssl  DATABASE  USER  IP-ADDRESS/CIDR-MASK  METHOD  [OPTION]
  #
  # (The uppercase quantities should be replaced by actual values.)
  # DATABASE can be all, sameuser, samegroup, a database name (or
  # a comma-separated list thereof), or a file name prefixed with @.
  # USER can be all, an actual user name or a group name prefixed with
--- 7,26 
  #
  # This file controls: which hosts are allowed to connect, how clients
  # are authenticated, which PostgreSQL user names they can use, which
! # databases they can access.  Records take one of seven forms:
  #
! # local  DATABASE  USER  METHOD  [OPTION]
! # host   DATABASE  USER  IP-ADDRESS  IP-MASK   METHOD  [OPTION]
! # hostsslDATABASE  USER  IP-ADDRESS  IP-MASK   METHOD  [OPTION]
! # hostnossl  DATABASE  USER  IP-ADDRESS  IP-MASK   METHOD  [OPTION]
! # host   DATABASE  USER  IP-ADDRESS/CIDR-MASK  METHOD  [OPTION]
! # hostsslDATABASE  USER  IP-ADDRESS/CIDR-MASK  METHOD  [OPTION]
! # hostnossl  DATABASE  USER  IP-ADDRESS/CIDR-MASK  METHOD  [OPTION]
  #
  # (The uppercase quantities should be replaced by actual values.)
+ # The first field is the connection type: local is a Unix-domain socket,
+ # host is either a plain or SSL-encrypted TCP/IP socket, hostssl is an
+ # SSL-encrypted TCP/IP socket, and hostnossl is a plain TCP/IP socket.
  # DATABASE can be all, sameuser, samegroup, a database name (or
  # a comma-separated list thereof), or a file name prefixed with @.
  # USER can be all, an actual user name or a group name prefixed with

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


Re: [PATCHES] timetravel.c

2003-09-11 Thread Bruce Momjian

I had to modify your patch sligthly to fit more recent code
changes --- updated version attached and applied.

---

Böjthe Zoltán wrote:
 Bruce Momjian ?rta:
 
 Patch applied.  Thanks.
 
 ---
   
 
 Hi!
 
 on my timetravel.c I find a bug: after the
 ALTER TABLE mytable drop column last_column_of_table;
 
 the timetravel trigger say on UPDATE/DELETE:
 
 ERROR:  parser: parse error at end of input
 
 
 Here is the patch for this bug
 
 B?jthe Zolt?n

 --- timetravel.c.prev 2003-06-27 19:56:40.0 +0200
 +++ timetravel.c  2003-09-02 14:53:21.0 +0200
 @@ -306,7 +306,7 @@
   void*pplan;
   Oid *ctypes;
   charsql[8192];
 - int j;
 + charsepar=' ';
  
   /* allocate ctypes for preparation */
   ctypes = (Oid *) palloc(natts * sizeof(Oid));
 @@ -319,11 +319,12 @@
   {
   ctypes[i - 1] = SPI_gettypeid(tupdesc, i);
   if(!(tupdesc-attrs[i - 1]-attisdropped))  /* skip 
 dropped columns */
 - snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), 
 $%d%s,
 - i, (i  natts) ? ,  : ) );
 -//   snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), 
 $%d /* %d */ %s,
 -//   i, ctypes[i-1], (i  natts) ? ,  : ) );
 + {
 + snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), 
 %c$%d, separ,i);
 + separ = ',';
 + }
   }
 + snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), ));
  
  //   elog(NOTICE, timetravel (%s) update: sql: %s, relname, sql);
  

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

-- 
  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
Index: contrib/spi/timetravel.c
===
RCS file: /cvsroot/pgsql-server/contrib/spi/timetravel.c,v
retrieving revision 1.18
diff -c -c -r1.18 timetravel.c
*** contrib/spi/timetravel.c4 Aug 2003 00:43:11 -   1.18
--- contrib/spi/timetravel.c11 Sep 2003 17:20:08 -
***
*** 309,314 
--- 309,315 
void   *pplan;
Oid*ctypes;
charsql[8192];
+   charsepar=' ';
  
/* allocate ctypes for preparation */
ctypes = (Oid *) palloc(natts * sizeof(Oid));
***
*** 321,333 
{
ctypes[i - 1] = SPI_gettypeid(tupdesc, i);
if (!(tupdesc-attrs[i - 1]-attisdropped)) /* skip dropped 
columns */
!   snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), 
$%d%s,
!i, (i  natts) ? ,  : ));
! #if 0
!   snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), $%d /* 
%d */ %s,
!i, ctypes[i - 1], (i  natts) ? ,  : ));
! #endif
}
  
elog(DEBUG4, timetravel (%s) update: sql: %s, relname, sql);
  
--- 322,333 
{
ctypes[i - 1] = SPI_gettypeid(tupdesc, i);
if (!(tupdesc-attrs[i - 1]-attisdropped)) /* skip dropped 
columns */
!   {
!   snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), 
%c$%d, separ,i);
!   separ = ',';
!   }
}
+   snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), ));
  
elog(DEBUG4, timetravel (%s) update: sql: %s, relname, sql);
  

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


Re: [PATCHES] minor documentation improvements

2003-09-11 Thread Bruce Momjian

Patch applied.  I will now go through and lowercase all the GUC
variable names, as agreed upon.

---

Neil Conway wrote:
 This patch makes a few minor improvements to the docs: make the
 varname conventions more consistent, and improve the ANALYZE ref page.
 
 -Neil
 

[ Attachment, skipping... ]

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

-- 
  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 8: explain analyze is your friend


Re: [PATCHES] WIN32_CONSOLE usage

2003-09-11 Thread Manfred Spraul
Christoph Dalitz wrote:

On Thu, 11 Sep 2003 20:51:24 +0200
Manfred Spraul [EMAIL PROTECTED] wrote:
 

- OemToChar() and CharToOem() convert all console input/output. In the 
long run this might be the better solution, if it works entirely without 
user intervention. I'm not sure if it's possible to get all corner cases 
right.

   

I do not think that it is possible to handle all cases automatically.
Even restricting the conversion to input/output on stdin/stdout will fail in
some circumstances; eg. with the command psql  script.sql when the
script has been written with a windows editor (notepad, emacs or whatever).
It would be very hard to get right. Perhaps something like isatty(), 
except that it's probably called GetHandleIsConsoleFlag() or something 
like that, followed by a check of the code page. But I didn't find a 
suitable function yet.

--
   Manfred


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


[PATCHES] Reorganization of spinlock defines

2003-09-11 Thread Bruce Momjian
Prompted by confusion over Itanium/Opterion, I have written a patch to
improve the way we define spinlocks for platforms and cpu's.  It
basically decouples the OS from the CPU spinlock code.  In almost all
cases, the spinlock code cares only about the compiler and CPU, not the
OS.

The patch:

o defines HAS_TEST_AND_SET inside each spinlock routine, not in
  platform-specific files
o moves slock_t defines into the spinlock routines
o remove NEED_{CPU}_TAS_ASM define because it is no longer needed
o reports a compile error if spinlocks are not defined
o adds a configure option --without-spinlocks to allow
  non-spinlock compiles

Looking at the patch, I realize this is how we should have done it all
along.

It would be nice to report the lack of spinlocks in configure, rather
than during the compile, but I can't compile s_lock.h and test for
HAS_TEST_AND_SET until configure completes.

I plan to apply this to 7.4.

-- 
  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
Index: configure
===
RCS file: /cvsroot/pgsql-server/configure,v
retrieving revision 1.295
diff -c -c -r1.295 configure
*** configure   7 Sep 2003 16:49:41 -   1.295
--- configure   12 Sep 2003 01:36:28 -
***
*** 869,874 
--- 869,875 
--with-rendezvous   build with Rendezvous support
--with-openssl[=DIR]build with OpenSSL support [/usr/local/ssl]
--without-readline  do not use Readline
+   --without-spinlocks  do not use Spinlocks
--without-zlib  do not use Zlib
--with-gnu-ld   assume the C compiler uses GNU ld default=no
  
***
*** 3494,3499 
--- 3495,3530 
  
  
  #
+ # Spinlocks
+ #
+ 
+ 
+ 
+ # Check whether --with-spinlocks or --without-spinlocks was given.
+ if test ${with_spinlocks+set} = set; then
+   withval=$with_spinlocks
+ 
+   case $withval in
+ yes)
+   :
+   ;;
+ no)
+   :
+   ;;
+ *)
+   { { echo $as_me:$LINENO: error: no argument expected for --with-spinlocks 
option 5
+ echo $as_me: error: no argument expected for --with-spinlocks option 2;}
+{ (exit 1); exit 1; }; }
+   ;;
+   esac
+ 
+ else
+   with_spinlocks=yes
+ 
+ fi;
+ 
+ 
+ #
  # Zlib
  #
  
***
*** 3523,3529 
  fi;
  
  
- 
  #
  # Elf
  #
--- 3554,3559 
***
*** 6060,6065 
--- 6090,6108 
 { (exit 1); exit 1; }; }
  fi
  
+ fi
+ 
+ if test $with_spinlocks = yes; then
+ 
+ cat confdefs.h \_ACEOF
+ #define HAVE_SPINLOCKS 1
+ _ACEOF
+ 
+ else
+   { echo $as_me:$LINENO: WARNING:
+ *** Not using spinlocks will cause poor performance. 5
+ echo $as_me: WARNING:
+ *** Not using spinlocks will cause poor performance. 2;}
  fi
  
  if test $with_krb4 = yes ; then
Index: configure.in
===
RCS file: /cvsroot/pgsql-server/configure.in,v
retrieving revision 1.286
diff -c -c -r1.286 configure.in
*** configure.in7 Sep 2003 16:38:05 -   1.286
--- configure.in12 Sep 2003 01:36:31 -
***
*** 522,533 
[  --without-readline  do not use Readline])
  
  #
  # Zlib
  #
  PGAC_ARG_BOOL(with, zlib, yes,
[  --without-zlib  do not use Zlib])
  
- 
  #
  # Elf
  #
--- 522,538 
[  --without-readline  do not use Readline])
  
  #
+ # Spinlocks
+ #
+ PGAC_ARG_BOOL(with, spinlocks, yes,
+   [  --without-spinlocks  do not use Spinlocks])
+ 
+ #
  # Zlib
  #
  PGAC_ARG_BOOL(with, zlib, yes,
[  --without-zlib  do not use Zlib])
  
  #
  # Elf
  #
***
*** 676,681 
--- 681,693 
  If you have zlib already installed, see config.log for details on the
  failure.  It is possible the compiler isn't looking in the proper directory.
  Use --without-zlib to disable zlib support.])])
+ fi
+ 
+ if test $with_spinlocks = yes; then
+   AC_DEFINE(HAVE_SPINLOCKS, 1, [Define to 1 if you have spinlocks.])
+ else
+   AC_MSG_WARN([
+ *** Not using spinlocks will cause poor performance.])
  fi
  
  if test $with_krb4 = yes ; then
Index: doc/src/sgml/installation.sgml
===
RCS file: /cvsroot/pgsql-server/doc/src/sgml/installation.sgml,v
retrieving revision 1.141
diff -c -c -r1.141 installation.sgml
*** doc/src/sgml/installation.sgml  11 Sep 2003 21:42:20 -  1.141
--- doc/src/sgml/installation.sgml  12 Sep 2003 01:36:34 -
***
*** 900,905 
--- 900,915 
/varlistentry
  
varlistentry
+termoption--without-spinlocks/option/term
+listitem
+ para
+  

Re: [PATCHES] [HACKERS] psql \h alter scrolls of screen

2003-09-11 Thread Peter Eisentraut
Bruce Momjian writes:

 OK, turns out the '\h alter' code does a simple printf(), not a
 PageOutput() and fprintf() to that pipe.  Various \h outputs are long,
 including CREATE TABLE, GRANT, and ALTER TABLE.  ALTER itself is really
 larger because it prints all the ALTER commands help.

They are long, but not not longer than a few pages, in which case it's
more convenient to use your terminals scrolling functionality.  It's a
different story when query output is thousands of lines long, in which
case you usually cannot scroll anymore.

-- 
Peter Eisentraut   [EMAIL PROTECTED]


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


Re: [PATCHES] Regression test for stats collector

2003-09-11 Thread Neil Conway
On Thu, 2003-09-11 at 11:58, Bruce Momjian wrote:
 Uh, how do you force the  stats collector to 'on' before the test is
 run?

The stats collector is on by default (of course, that doesn't apply to
make installcheck...)

But this reminds me: I think it would be cool to extend the language we
use for writing regression tests to be more than mere SQL. We could do
with boolean expressions (IF stats_collector_is_on THEN run_test ELSE
skip_test), better control over parallel regression tests (Run all
possible interleavings of tests X, Y, and Z; Run X and Y
simultaneously; etc.), and more.

-Neil



---(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] WIN32_CONSOLE usage

2003-09-11 Thread Bruce Momjian
Christoph Dalitz wrote:
  Please send in a patch.  Else, someone else is going to try to fix it with
  less guarantees that it will work afterwards.
  
 Ok. I can do the following:
 
  a) Write documentation how the win32 console needs to be set up so that
 psql can handle 8-bit characters.
 Where should it be added? The Section Installation on Windows in the
 Administrator's Guide seems natural to me.
 
  b) Add code to psql that prints a warning on startup of psql when the
 console codepage differs from the windows codepage, something like
 
   Warning: Console codepage (850) differs from windows codepage (1252)
8-bit characters will not work correctly. See PostgreSQL
documentation Installation on Windows for details.
 
 Unfortunately there seems to be no automatic solution to the console codepage 
 problem,
 because the windows codepage does not work with the default console font.
 Thus the user must tweak his console settings in any case and I think a warning
 is the best to remind the user of this issue.
 
 Please let me know whether this solution would be ok. Then I can do it on Monday.

Sounds good.

 @Bruce:
 ---
 
 Could you please already remove the WIN32_CONSOLE and OemToChar/CharToOem stuff
 from psql? Sorry for the inconvenience generated by my ignorance.

OK.

-- 
  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 8: explain analyze is your friend


Re: [PATCHES] WIN32_CONSOLE usage

2003-09-11 Thread Manfred Spraul
Peter Eisentraut wrote:

If you can detect that they are different, why can't you adjust the code
page in that case only?
 

What should we do if we detect that they differ:
- set the console code page to the ansi code page. This has two 
drawbacks: It doesn't work with Indic, because Indic doesn't have an 
ansi code page. And the user must still switch the console font. But: if 
the user must change the configuration, then he can as easily change 
both the font and the code page. Which means: SetConsoleCP is the wrong 
approach.
- OemToChar() and CharToOem() convert all console input/output. In the 
long run this might be the better solution, if it works entirely without 
user intervention. I'm not sure if it's possible to get all corner cases 
right.

--
   Manfred


---(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] Reorganization of spinlock defines

2003-09-11 Thread Bruce Momjian
Marc G. Fournier wrote:
  But it seems to me that this is mostly a cosmetic cleanup and therefore
  not the kind of thing to be doing late in beta.  Couldn't we do
  something that affects only Opteron/Itanium and doesn't take a chance
  on breaking everything else?
 
 I just went through the whole patch myself, and as much as I like the
 overall simplification, I tend to agree with Tom here on questioning the
 requirement to do suck a massive change so late in the end cycle ... is
 there no smaller bandaid that can be applied to handle the Opteron/Itanium
 issue for v7.4, with the cleanup patch being applied right away after
 v7.4?

Well, the problem was that we defined HAS_TEST_AND_SET inside the ports.
I guess we could splatter a test for Itanium and Opterion in every port
that could possibly use it, but then again, if we fall back to not
finding it for some reason, we don't get a report because we silently
fall back to semaphores.  That's what has me worried, that if we don't
do it, we will not know what platforms really aren't working properly.

Take FreeBSD for example, that couldn't find Opteron. It lists every
cpu like this:

#if defined(__i386__)
#define NEED_I386_TAS_ASM
#define HAS_TEST_AND_SET
typedef unsigned char slock_t;
#endif

#if defined(__sparc__)
#define NEED_SPARC_TAS_ASM
#define HAS_TEST_AND_SET
typedef unsigned char slock_t;
#endif

We would have to add an opteron/itanium to port that does this, but if
we miss some opteron/itanium define, we might never know because of the
silent fallback.

I don't care if we save it for 7.5 --- I just don't know how we will be
sure we have things working properly without it.

We could apply it tomorrow and see how things look on Monday.


-- 
  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 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


Re: [PATCHES] Reorganization of spinlock defines

2003-09-11 Thread Larry Rosenman


--On Thursday, September 11, 2003 23:46:56 -0300 Marc G. Fournier 
[EMAIL PROTECTED] wrote:



On Thu, 11 Sep 2003, Tom Lane wrote:

Bruce Momjian [EMAIL PROTECTED] writes:
 The problem with waiting for 7.5 is that we will have no error
 reporting when our non-spinlock code is being executed, and with
 Opteron/Itanium, it seems like a good time to get it working.
Well, as long as you're prepared to reduce the list of known supported
platforms to zero as of 7.4beta3, and issue a fresh call for port
reports.
I didn't think we had done that yet ... had we?  called for port reports,
that is ... ?
But it seems to me that this is mostly a cosmetic cleanup and therefore
not the kind of thing to be doing late in beta.  Couldn't we do
something that affects only Opteron/Itanium and doesn't take a chance
on breaking everything else?
I just went through the whole patch myself, and as much as I like the
overall simplification, I tend to agree with Tom here on questioning the
requirement to do suck a massive change so late in the end cycle ... is
there no smaller bandaid that can be applied to handle the Opteron/Itanium
issue for v7.4, with the cleanup patch being applied right away after
v7.4?
Bruce sent me a copy of the patch, and it BREAKS UnixWare (If y'all 
care).

LER

--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 972-414-9812 E-Mail: [EMAIL PROTECTED]
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749


pgp0.pgp
Description: PGP signature