make createlang match docs

Started by Marko Kreenover 24 years ago12 messagespatches
Jump to latest
#1Marko Kreen
markokr@gmail.com

* make createlang match docs: "createlang dbname" did not work.

--
marko

Index: src/bin/scripts/createlang.sh
===================================================================
RCS file: /opt/cvs2/pgsql/pgsql/src/bin/scripts/createlang.sh,v
retrieving revision 1.31
diff -u -c -r1.31 createlang.sh
*** src/bin/scripts/createlang.sh	30 Sep 2001 22:17:51 -0000	1.31
--- src/bin/scripts/createlang.sh	12 Dec 2001 09:16:20 -0000
***************
*** 108,118 ****
  		;;
  	 *)
   		if [ "$list" != "t" ]
! 		then	langname="$1"
  			if [ "$2" ]
  			then
  				shift
- 				dbname="$1"
  			fi
  		else	dbname="$1"
  		fi
--- 108,119 ----
  		;;
  	 *)
   		if [ "$list" != "t" ]
! 		then	dbname="$1"
  			if [ "$2" ]
  			then
+ 				langname="$1"
+ 				dbname="$2"
  				shift
  			fi
  		else	dbname="$1"
  		fi
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Marko Kreen (#1)
Re: make createlang match docs

Marko Kreen <marko@l-t.ee> writes:

* make createlang match docs: "createlang dbname" did not work.

Unless you can demonstrate that createlang changed behavior recently,
this is the wrong fix. Breaking existing scripts that use createlang
is not the way to go; fixing the documentation to match the code is
the way to go.

regards, tom lane

#3Peter Eisentraut
peter_e@gmx.net
In reply to: Marko Kreen (#1)
Re: make createlang match docs

Marko Kreen writes:

* make createlang match docs: "createlang dbname" did not work.

What is the meaning of that command?

--
Peter Eisentraut peter_e@gmx.net

#4Marko Kreen
markokr@gmail.com
In reply to: Tom Lane (#2)
Re: make createlang match docs

On Wed, Dec 12, 2001 at 03:40:30PM -0500, Tom Lane wrote:

Marko Kreen <marko@l-t.ee> writes:

* make createlang match docs: "createlang dbname" did not work.

Unless you can demonstrate that createlang changed behavior recently,
this is the wrong fix. Breaking existing scripts that use createlang
is not the way to go; fixing the documentation to match the code is
the way to go.

in app-createlang.html:
Synopsis

createlang [connection-options...] [langname] dbname

createlang [connection-options...] --list | -l dbname

---

$ createlang --help
...
Usage:
createlang [options] [langname] dbname
....
$ createlang foo
createlang: missing required argument database name
Try 'createlang -?' for help.
$

With my patch:

$ createlang foo
Language to install in database foo:

I would say 'createlang foo' has been error-message-only command
all the 7.x.x, so it should not break anything.

What way the docs should be changed?

--
marko

#5Marko Kreen
markokr@gmail.com
In reply to: Peter Eisentraut (#3)
Re: make createlang match docs

On Wed, Dec 12, 2001 at 11:27:37PM +0100, Peter Eisentraut wrote:

Marko Kreen writes:

* 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.

--
marko

#6Thomas Lockhart
lockhart@fourpalms.org
In reply to: Marko Kreen (#1)
Re: make createlang match docs

* 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?

- Thomas

#7Marko Kreen
markokr@gmail.com
In reply to: Thomas Lockhart (#6)
Re: make createlang match docs

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.

--
marko

#8Bruce Momjian
bruce@momjian.us
In reply to: Marko Kreen (#7)
Re: make createlang match docs

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

Attachments:

/bjm/difftext/plainDownload+34-41
#9Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#2)
Re: make createlang match docs

Tom Lane wrote:

Marko Kreen <marko@l-t.ee> writes:

* make createlang match docs: "createlang dbname" did not work.

Unless you can demonstrate that createlang changed behavior recently,
this is the wrong fix. Breaking existing scripts that use createlang
is not the way to go; fixing the documentation to match the code is
the way to go.

Actually, the existing code didn't work. The options part had dbname as
optional, but the later code only tested for an optional langname;
clearly a mess.

-- 
  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
#10Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#8)
Re: make createlang match docs

Bruce Momjian <pgman@candle.pha.pa.us> writes:

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.

I reserve the right to object later, but too tired to think about it
now.

Also, can someone explain why we have a createlang.sh?

The transformation used to be nontrivial. Perhaps it will be again
someday; so I'm not eager to remove this build step.

regards, tom lane

#11Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#10)
Re: make createlang match docs

Tom Lane wrote:

Bruce Momjian <pgman@candle.pha.pa.us> writes:

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.

I reserve the right to object later, but too tired to think about it
now.

I understand. I was too tired to fix it to work the wrong way, only to
fix it right for 7.3.

Also, can someone explain why we have a createlang.sh?

The transformation used to be nontrivial. Perhaps it will be again
someday; so I'm not eager to remove this build step.

Just seems strange.

-- 
  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
#12Bruce Momjian
bruce@momjian.us
In reply to: Bruce Momjian (#8)
Re: make createlang match docs

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.

OK, turns out droplang has the same problem; default are documented but
do not work. Fixed to have dbname optional, just like createlang.

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

Attachments:

/bjm/difftext/plainDownload+27-27