[PATCHES] patch to have configure check if CC is intel C compiler

2006-04-01 Thread Jeremy Drake
If configure sees that the compiler specified by $CC looks like gcc
(defines __GNUC__), then it puts some extra command line options into the
CFLAGS (mostly -W*).  The intel C compiler for linux emulates gcc by
default, which means it defines that and looks very much like gcc to
configure.  However, it does not get along with the added -W flags very
well.  They don't seem to kill it, but some of them give warnings about
unsupported command line options and others produce insane amounts of
output from the compiler.

This patch makes configure check for the __INTEL_COMPILER define (which is
the recommended way to detect the intel compiler) before adding the extra
CFLAGS if it thinks the compiler is GCC.  I am not an autoconf hacker, so
I may have done it wrong or something, but it appears to work for me (ICC
9.0.032 on gentoo i686 with latest packages).

The patch is against the HEAD but I think it should be similar for other
branches (I have been compiling 8.0 and 8.1 for some time with the intel
compiler by manually massaging the makefiles after configure ran).


-- 
We the unwilling, led by the ungrateful, are doing the impossible.
We've done so much, for so long, with so little,
that we are now qualified to do something with nothing.Index: configure.in
===
RCS file: /home/jeremyd/local/postgres/cvsuproot/pgsql/configure.in,v
retrieving revision 1.455
diff -c -r1.455 configure.in
*** configure.in6 Mar 2006 17:41:43 -   1.455
--- configure.in1 Apr 2006 17:43:19 -
***
*** 249,260 
  fi
  
  if test $GCC = yes; then
!   CFLAGS=$CFLAGS -Wall -Wmissing-prototypes -Wpointer-arith -Winline
! 
!   # Some versions of GCC support some additional useful warning flags.
!   # Check whether they are supported, and add them to CFLAGS if so.
!   PGAC_PROG_CC_CFLAGS_OPT([-Wdeclaration-after-statement])
!   PGAC_PROG_CC_CFLAGS_OPT([-Wendif-labels])
  
# Disable strict-aliasing rules; needed for gcc 3.3+
PGAC_PROG_CC_CFLAGS_OPT([-fno-strict-aliasing])
--- 249,265 
  fi
  
  if test $GCC = yes; then
! AC_TRY_COMPILE([], [EMAIL PROTECTED]:@ifndef __INTEL_COMPILER
! choke me
! @%:@endif], [ICC=[yes]], [ICC=[no]])
!   if test $ICC = no; then
! CFLAGS=$CFLAGS -Wall -Wmissing-prototypes -Wpointer-arith -Winline
! 
! # Some versions of GCC support some additional useful warning flags.
! # Check whether they are supported, and add them to CFLAGS if so.
! PGAC_PROG_CC_CFLAGS_OPT([-Wdeclaration-after-statement])
! PGAC_PROG_CC_CFLAGS_OPT([-Wendif-labels])
!   fi
  
# Disable strict-aliasing rules; needed for gcc 3.3+
PGAC_PROG_CC_CFLAGS_OPT([-fno-strict-aliasing])

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

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


Re: [PATCHES] patch to have configure check if CC is intel C compiler

2006-04-01 Thread Peter Eisentraut
Jeremy Drake wrote:
 The intel C compiler for linux emulates gcc
 by default, which means it defines that and looks very much like gcc
 to configure.  However, it does not get along with the added -W flags
 very well.  They don't seem to kill it, but some of them give
 warnings about unsupported command line options and others produce
 insane amounts of output from the compiler.

Details please.  Which options are unsupported and what happens if you 
use them?

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

---(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: [PATCHES] patch to have configure check if CC is intel C compiler

2006-04-01 Thread Jeremy Drake
On Sun, 2 Apr 2006, Peter Eisentraut wrote:

 Jeremy Drake wrote:
  The intel C compiler for linux emulates gcc
  by default, which means it defines that and looks very much like gcc
  to configure.  However, it does not get along with the added -W flags
  very well.  They don't seem to kill it, but some of them give
  warnings about unsupported command line options and others produce
  insane amounts of output from the compiler.

 Details please.  Which options are unsupported and what happens if you
 use them?

For an example I grabbed the output from compiling nbtsearch.c using
this configure line:
CC=icc CFLAGS=-O3 -ip -parallel -xN ./configure --with-perl --with-python 
--with-openssl

As you can tell, these make a lot of output.  I only include the line(s)
with each option which are added when the option is given.  So, with the
old configure, all of the warnings were concatenated (two instances of the
argument required warning plus the inlining report and the collection of
remark messages).




-Wmissing-prototypes and -Wpointer-arith do not appear to make any
difference, at least on this file.




-Wendif-labels:
iccbin: Command line warning: ignoring option '-W'; no argument required




-Wdeclaration-after-statement:
iccbin: Command line warning: ignoring option '-W'; no argument required




-Winline:
INLINING REPORT: (_bt_moveright)

  - elog_finish(EXTERN)
  - elog_start(EXTERN)
  - _bt_relandgetbuf(EXTERN)
  - ARGS_IN_REGS: _bt_compare.(3) (isz = 249) (sz = 269 (77+192))

INLINING REPORT: (_bt_binsrch)

  - ARGS_IN_REGS: _bt_compare.(3) (isz = 249) (sz = 269 (77+192))

INLINING REPORT: (_bt_next)

  - _bt_relbuf(EXTERN)
  - _bt_checkkeys(EXTERN)
  - ARGS_IN_REGS: _bt_step.(6) (isz = 486) (sz = 502 (171+331))

INLINING REPORT: (_bt_first)

  - ARGS_IN_REGS: _bt_endpoint(9) (isz = 475) (sz = 489 (176+313))
  - INLINE: _bt_next(11) (isz = 59) (sz = 73 (27+46))
- ARGS_IN_REGS: _bt_step.(6) (isz = 486) (sz = 502 (171+331))
- _bt_checkkeys(EXTERN)
- _bt_relbuf(EXTERN)
  - _bt_relbuf(EXTERN)
  - _bt_checkkeys(EXTERN)
  - ARGS_IN_REGS: _bt_step.(6) (isz = 486) (sz = 502 (171+331))
  - ARGS_IN_REGS: _bt_step.(6) (isz = 486) (sz = 502 (171+331))
  - BufferGetBlockNumber(EXTERN)
  - INLINE: _bt_binsrch(15) (isz = 104) (sz = 127 (41+86))
- ARGS_IN_REGS: _bt_compare.(3) (isz = 249) (sz = 269 (77+192))
  - _bt_freestack(EXTERN)
  - ARGS_IN_REGS: _bt_search.(0) (isz = 315) (sz = 335 (113+222))
  - elog_finish(EXTERN)
  - elog_start(EXTERN)
  - memcpy(EXTERN)
  - memcpy(EXTERN)
  - ScanKeyEntryInitializeWithInfo(EXTERN)
  - index_getprocinfo(EXTERN)
  - ScanKeyEntryInitialize(EXTERN)
  - get_opclass_proc(EXTERN)
  - _bt_preprocess_keys(EXTERN)

INLINING REPORT: (_bt_step)

  - BufferGetBlockNumber(EXTERN)
  - _bt_relbuf(EXTERN)
  - _bt_relandgetbuf(EXTERN)
  - INLINE: _bt_walk_left(10) (isz = 210) (sz = 222 (77+145))
- BufferGetBlockNumber(EXTERN)
- _bt_relandgetbuf(EXTERN)
- _bt_relandgetbuf(EXTERN)
- _bt_relandgetbuf(EXTERN)
- elog_start(EXTERN)
- elog_finish(EXTERN)
- elog_start(EXTERN)
- elog_finish(EXTERN)
- _bt_relandgetbuf(EXTERN)
- _bt_relbuf(EXTERN)

INLINING REPORT: (_bt_search)

  - _bt_relandgetbuf(EXTERN)
  - memcpy(EXTERN)
  - MemoryContextAlloc(EXTERN)
  - BufferGetBlockNumber(EXTERN)
  - INLINE: _bt_binsrch(14) (isz = 104) (sz = 127 (41+86))
- ARGS_IN_REGS: _bt_compare.(3) (isz = 249) (sz = 269 (77+192))
  - INLINE: _bt_moveright(16) (isz = 92) (sz = 110 (37+73))
- ARGS_IN_REGS: _bt_compare.(3) (isz = 249) (sz = 269 (77+192))
- _bt_relandgetbuf(EXTERN)
- elog_start(EXTERN)
- elog_finish(EXTERN)
  - _bt_getroot(EXTERN)

INLINING REPORT: (_bt_compare)

  - FunctionCall2(EXTERN)
  - nocache_index_getattr(EXTERN)
  - nocache_index_getattr(EXTERN)

INLINING REPORT: (_bt_endpoint)

  - INLINE: _bt_next(12) (isz = 59) (sz = 73 (27+46))
- ARGS_IN_REGS: _bt_step.(6) (isz = 486) (sz = 502 (171+331))
- _bt_checkkeys(EXTERN)
- _bt_relbuf(EXTERN)
  - _bt_relbuf(EXTERN)
  - _bt_checkkeys(EXTERN)
  - ARGS_IN_REGS: _bt_step.(6) (isz = 486) (sz = 502 (171+331))
  - elog_finish(EXTERN)
  - elog_start(EXTERN)
  - BufferGetBlockNumber(EXTERN)
  - INLINE: _bt_get_endpoint(13) (isz = 199) (sz = 213 (76+137))
- _bt_gettrueroot(EXTERN)
- _bt_getroot(EXTERN)
- elog_start(EXTERN)
- elog_finish(EXTERN)
- _bt_relandgetbuf(EXTERN)
- elog_start(EXTERN)
- elog_finish(EXTERN)
- _bt_relandgetbuf(EXTERN)

INLINING REPORT: (_bt_get_endpoint)

  - _bt_relandgetbuf(EXTERN)
  - elog_finish(EXTERN)
  - elog_start(EXTERN)
  - _bt_relandgetbuf(EXTERN)
  - elog_finish(EXTERN)
  - elog_start(EXTERN)
  - _bt_getroot(EXTERN)
  - _bt_gettrueroot(EXTERN)




-Wall:
../../../../src/include/access/relscan.h(45): remark #1684: conversion
from pointer to same-sized integral type (potential portability problem)
OffsetNumber rs_vistuples[MaxHeapTuplesPerPage];/* their
offsets */
 

Re: [PATCHES] psql patch: new host/port without leaving session

2006-04-01 Thread Neil Conway
On Sun, 2006-03-12 at 19:59 +0200, Volkan YAZICI wrote:
 I've written do_connect() and \c handling part from scratch in the
 attached patch.

Attached is a revised version of this patch. I rewrote most of the code,
because the existing stuff was in pretty bad style IMHO. I haven't
updated the documentation yet, but I'll do that if no one objects to
this version of the patch.

One question about behavior: in the attached patch, omitting an argument
to \connect or specifying - are treated equivalently -- the value for
that parameter from the previous connection is used, otherwise NULL (for
the libpq default). Is this what people want? (One possible complaint is
that once you specify a parameter, you can't get back to the libpq
default without specifying it explicitly.)

-Neil


*** src/bin/psql/command.c	b1305764d53ec9138de3c55ec3475a4d8a3190d9
--- src/bin/psql/command.c	e570b6eb0b6ade25461b88aca5bbef2e75d27c00
***
*** 55,61 
  			 PsqlScanState scan_state,
  			 PQExpBuffer query_buf);
  static bool do_edit(const char *filename_arg, PQExpBuffer query_buf);
! static bool do_connect(const char *new_dbname, const char *new_user, const char *new_host, const char *new_port);
  static bool do_shell(const char *command);
  
  
--- 55,61 
  			 PsqlScanState scan_state,
  			 PQExpBuffer query_buf);
  static bool do_edit(const char *filename_arg, PQExpBuffer query_buf);
! static bool do_connect(char *dbname, char *user, char *host, char *port);
  static bool do_shell(const char *command);
  
  
***
*** 154,159 
--- 154,192 
  }
  
  /*
+  * Read and interpret an argument to the \connect slash command.
+  */
+ static char *
+ read_connect_arg(PsqlScanState scan_state)
+ {
+ 	char *result;
+ 	char  quote;
+ 
+ 	/*
+ 	 * Ideally we should treat the arguments as SQL identifiers.  But
+ 	 * for backwards compatibility with 7.2 and older pg_dump files,
+ 	 * we have to take unquoted arguments verbatim (don't downcase
+ 	 * them). For now, double-quoted arguments may be stripped of
+ 	 * double quotes (as if SQL identifiers).  By 7.4 or so, pg_dump
+ 	 * files can be expected to double-quote all mixed-case \connect
+ 	 * arguments, and then we can get rid of OT_SQLIDHACK.
+ 	 */
+ 	result = psql_scan_slash_option(scan_state, OT_SQLIDHACK, quote, true);
+ 
+ 	if (!result)
+ 		return NULL;
+ 
+ 	if (quote)
+ 		return result;
+ 
+ 	if (*result == '\0' || strcmp(result, -) == 0)
+ 		return NULL;
+ 
+ 	return result;
+ }
+ 	
+ 
+ /*
   * Subroutine to actually try to execute a backslash command.
   */
  static backslashResult
***
*** 188,204 
  		free(opt);
  	}
  
! 	/*--
! 	 * \c or \connect -- connect to new database or as different user,
! 	 * and/or new host and/or port
  	 *
! 	 * \c foo bar [-]  [-]connect to db foo as user bar on current host and port
! 	 * \c foo [-]  [-]  [-]   connect to db foo as current user on current host and port
! 	 * \c - bar  [-]  [-] connect to current db as user bar on current host and port
! 	 * \c - - host.domain.tld [-] connect to default db as default user on host.domain.tld on default port
! 	 * \c - - -   connect to default db as default user on default host at port 
! 	 * \c		   connect to default db as default user
! 	 *--
  	 */
  	else if (strcmp(cmd, c) == 0 || strcmp(cmd, connect) == 0)
  	{
--- 221,242 
  		free(opt);
  	}
  
! 	/*
! 	 * \c or \connect -- connect to database using the specified parameters.
  	 *
! 	 * \c dbname user host port
! 	 *
! 	 * If any of these parameters are omitted or specified as '-', the
! 	 * current value of the parameter will be used instead. If the
! 	 * parameter has no current value, the default value for that
! 	 * parameter will be used. Some examples:
! 	 *
! 	 * \c - - hst		Connect to current database on current port of
! 	 *	host hst as current user.
! 	 * \c - usr - prt	Connect to current database on prt port of current
! 	 *	host as user usr.
! 	 * \c dbs			Connect to dbs database on current port of current
! 	 *	host as current user.
  	 */
  	else if (strcmp(cmd, c) == 0 || strcmp(cmd, connect) == 0)
  	{
***
*** 206,233 
     *opt2,
     *opt3,
     *opt4;
- 		char		opt1q,
- 	opt2q,
- 	opt3q,
- 	opt4q;
  
! 		/*
! 		 * Ideally we should treat the arguments as SQL identifiers.  But for
! 		 * backwards compatibility with 7.2 and older pg_dump files, we have
! 		 * to take unquoted arguments verbatim (don't downcase them). For now,
! 		 * double-quoted arguments may be stripped of double quotes (as if SQL
! 		 * identifiers).  By 7.4 or so, pg_dump files can be expected to
! 		 * double-quote all mixed-case \connect arguments, and then we can get
! 		 * rid of OT_SQLIDHACK.
! 		 */
! 		opt1 = psql_scan_slash_option(scan_state,
! 	  OT_SQLIDHACK, opt1q, true);
! 		opt2 =