Re: make createlang match docs

Поиск
Список
Период
Сортировка
Искать
От
Bruce Momjian
Тема
Re: make createlang match docs
Дата
Msg-id
200201030529.g035TRs09996@candle.pha.pa.us
Ответ на
Список
Дерево обсуждения
Re: make createlang match docs Thomas Lockhart <lockhart@fourpalms.org>
Re: make createlang match docs Marko Kreen <marko@l-t.ee>
Re: make createlang match docs Bruce Momjian <pgman@candle.pha.pa.us>
Re: make createlang match docs Tom Lane <tgl@sss.pgh.pa.us>
Re: make createlang match docs Bruce Momjian <pgman@candle.pha.pa.us>
Re: make createlang match docs Bruce Momjian <pgman@candle.pha.pa.us>
Marko Kreen wrote:
> On Thu, Dec 13, 2001 at 05:47:37AM +0000, Thomas Lockhart wrote:
> > > > > * make createlang match docs: "createlang dbname" did not work.
> > > > What is the meaning of that command?
> > > You give a database to act on, like to other scripts, then it
> > > asks what language to install.
> > 
> > But since it respects PGHOST and should use a database name the same as
> > your user name, that usage is degenerate with "createlang newlanguage".
> > Isn't it? Or shouldn't it be?
> 
> Well, it does not respect PGDATABASE nor uses username as
> default - and making it do so changes the current behaviour...
> 
> Although I think too 'createlang langname' would be saner.

I was going to add this to TODO:

	Change 'createlang [langname] dbname' to 'createlang langname [dbname]' 

However, when I started to look at the createlang script, I saw:

                if [ "$list" != "t" ]
                then    langname="$1"
                        if [ "$2" ]
                        then
                                shift
                                dbname="$1"
                        fi
                else    dbname="$1"
                fi

which said that dbname was already behaving as optional, even though
there was code to handle a missing langname.

Rather than change the script to make langname optional, I have fixed
the script to work the way everyone wants it to work, namely dbname is
now optional.  I grabbed the dbname default code from createdb.

Applied to CVS with doc updates.  Patch attached.

Also, can someone explain why we have a createlang.sh?  Makefile shows:
	
	createlang: createlang.sh
	        cp $< $@
	        chmod a+x $@

Not much doing there.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
Index: doc/src/sgml/ref/createlang.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/ref/createlang.sgml,v
retrieving revision 1.21
diff -c -r1.21 createlang.sgml
*** doc/src/sgml/ref/createlang.sgml	2001/12/08 03:24:35	1.21
--- doc/src/sgml/ref/createlang.sgml	2002/01/03 05:27:34
***************
*** 23,30 ****
    
     createlang
     connection-options
!    langname
!    dbname
     
     createlang
     connection-options
--- 23,30 ----
    
     createlang
     connection-options
!    langname
!    dbname
     
     createlang
     connection-options
***************
*** 46,54 ****
         
  	Specifies the name of the procedural programming language to be
  	defined.
- 	createlang will prompt for
- 	langname
- 	if it is not specified on the command line.
         
        
       
--- 46,51 ----
***************
*** 58,63 ****
--- 55,62 ----
        
         
  	Specifies to which database the language should be added.
+         The default is to create a database with the same name as the
+         current system user.
         
        
       
Index: src/bin/scripts/createlang.sh
===================================================================
RCS file: /cvsroot/pgsql/src/bin/scripts/createlang.sh,v
retrieving revision 1.31
diff -c -r1.31 createlang.sh
*** src/bin/scripts/createlang.sh	2001/09/30 22:17:51	1.31
--- src/bin/scripts/createlang.sh	2002/01/03 05:27:35
***************
*** 125,131 ****
          echo "$CMDNAME installs a procedural language into a PostgreSQL database."
  	echo
  	echo "Usage:"
!         echo "  $CMDNAME [options] [langname] dbname"
          echo
  	echo "Options:"
  	echo "  -h, --host=HOSTNAME             Database server host"
--- 125,131 ----
          echo "$CMDNAME installs a procedural language into a PostgreSQL database."
  	echo
  	echo "Usage:"
!         echo "  $CMDNAME [options] langname [dbname]"
          echo
  	echo "Options:"
  	echo "  -h, --host=HOSTNAME             Database server host"
***************
*** 136,161 ****
  	echo "  -L, --pglib=DIRECTORY           Find language interpreter file in DIRECTORY"
  	echo "  -l, --list                      Show a list of currently installed languages"
          echo
-         echo "If 'langname' is not specified, you will be prompted interactively."
-         echo "A database name must be specified."
-         echo
  	echo "Report bugs to ."
  	exit 0
  fi
  
  
- # ----------
- # Check that we have a database
- # ----------
  if [ -z "$dbname" ]; then
! 	echo "$CMDNAME: missing required argument database name" 1>&2
!         echo "Try '$CMDNAME --help' for help." 1>&2
! 	exit 1
  fi
  
  
  # ----------
! # List option
  # ----------
  if [ "$list" ]; then
  	sqlcmd="SELECT lanname as \"Name\", lanpltrusted as \"Trusted?\" FROM pg_language WHERE lanispl = TRUE;"
--- 136,158 ----
  	echo "  -L, --pglib=DIRECTORY           Find language interpreter file in DIRECTORY"
  	echo "  -l, --list                      Show a list of currently installed languages"
          echo
  	echo "Report bugs to ."
  	exit 0
  fi
  
  
  if [ -z "$dbname" ]; then
!         if [ "$PGUSER" ]; then
!                 dbname="$PGUSER"
!         else
!                 dbname=`${PATHNAME}pg_id -u -n`
!         fi
!         [ "$?" -ne 0 ] && exit 1
  fi
  
  
  # ----------
! # List option, doesn't need langname
  # ----------
  if [ "$list" ]; then
  	sqlcmd="SELECT lanname as \"Name\", lanpltrusted as \"Trusted?\" FROM pg_language WHERE lanispl = TRUE;"
***************
*** 168,185 ****
  
  
  # ----------
! # Check that we have PGLIB
  # ----------
! if [ -z "$PGLIB" ]; then
! 	PGLIB='$libdir'
  fi
  
  # ----------
! # If not given on the command line, ask for the language
  # ----------
! if [ -z "$langname" ]; then
! 	$ECHO_N "Language to install in database $dbname: "$ECHO_C
! 	read langname
  fi
  
  # ----------
--- 165,183 ----
  
  
  # ----------
! # We can't go any farther without a langname
  # ----------
! if [ -z "$langname" ]; then
! 	echo "$CMDNAME: missing required argument language name" 1>&2
!         echo "Try '$CMDNAME --help' for help." 1>&2
! 	exit 1
  fi
  
  # ----------
! # Check that we have PGLIB
  # ----------
! if [ -z "$PGLIB" ]; then
! 	PGLIB='$libdir'
  fi
  
  # ----------
В списке pgsql-patches по дате отправления
От: Tom Lane
Дата:
От: Bruce Momjian
Дата:
Сообщение: Re: make createlang match docs
FAQ