Thread: psql Week 4.142857

psql Week 4.142857

From
Peter Eisentraut
Date:
Oops, the stuff I posted yesterday contained a few pretty funky bugs. I
have put up a new tarball.

Also, I have written updated DocBook documentation. It's not a great work
of literature yet but it's for those that want to get started. I will
update it several times during the next few days.

Again, those URLs are:
http://www.pathwaynet.com/~peter/psql-final.tar.gz (49k)
http://www.pathwaynet.com/~peter/psql-ref.sgml.gz (16k)

And for those who don't want to rebuild the whole documentation:
http://www.pathwaynet.com/~peter/psql-ref.html
-Peter

-- 
Peter Eisentraut                  Sernanders vaeg 10:115
peter_e@gmx.net                   75262 Uppsala
http://yi.org/peter-e/            Sweden



Re: [HACKERS] psql Week 4.142857

From
Bruce Momjian
Date:
Let me know when you want these applied to the main tree.

> Oops, the stuff I posted yesterday contained a few pretty funky bugs. I
> have put up a new tarball.
> 
> Also, I have written updated DocBook documentation. It's not a great work
> of literature yet but it's for those that want to get started. I will
> update it several times during the next few days.
> 
> Again, those URLs are:
> http://www.pathwaynet.com/~peter/psql-final.tar.gz (49k)
> http://www.pathwaynet.com/~peter/psql-ref.sgml.gz (16k)
> 
> And for those who don't want to rebuild the whole documentation:
> http://www.pathwaynet.com/~peter/psql-ref.html
> 
>     -Peter
> 
> -- 
> Peter Eisentraut                  Sernanders vaeg 10:115
> peter_e@gmx.net                   75262 Uppsala
> http://yi.org/peter-e/            Sweden
> 
> 
> ************
> 


--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


Re: [HACKERS] psql Week 4.142857

From
Tatsuo Ishii
Date:
> Let me know when you want these applied to the main tree.

Does his work replace psql? Or will it be placed under contrib/?
I just want to know how 7.0 would be look like.
---
Tatsuo Ishii


Re: [HACKERS] psql Week 4.142857

From
Bruce Momjian
Date:
> > Let me know when you want these applied to the main tree.
> 
> Does his work replace psql? Or will it be placed under contrib/?
> I just want to know how 7.0 would be look like.

This is going into the main tree.  psql will still be there, but will be
improved.

--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


Re: [HACKERS] psql Week 4.142857

From
Peter Eisentraut
Date:
On Wed, 27 Oct 1999, Bruce Momjian wrote:

> Let me know when you want these applied to the main tree.

(At the risk of turning this into a C mailing list . . .)

As soon as I have this problem fixed:

gcc -o psql -L../../interfaces/libpq command.o common.o help.o input.o
stringutils.o mainloop.o copy.o startup.o prompt.o variables.o large_obj.o
print.o describe.o  -lpq -L/usr/sup/gnu/lib -lgen -lcrypt -lnsl -lsocket
-ldl -lm -lreadline -ltermcap -lcurses 
ld: fatal: symbol `xmalloc' is multiply defined:       (file common.o and file
/usr/sup/gnu/lib/libreadline.a(xmalloc.o));
ld: fatal: File processing errors. No output written to psql
make: *** [psql] Error 1

This happens on a (particular) Solaris box but not on a (particular) Linux
box. Beats the heck out of me. ;(

Sorry for OT.
-Peter

-- 
Peter Eisentraut                  Sernanders vaeg 10:115
peter_e@gmx.net                   75262 Uppsala
http://yi.org/peter-e/            Sweden



Re: [HACKERS] psql Week 4.142857

From
Bruce Momjian
Date:
> On Wed, 27 Oct 1999, Bruce Momjian wrote:
> 
> > Let me know when you want these applied to the main tree.
> 
> (At the risk of turning this into a C mailing list . . .)
> 
> As soon as I have this problem fixed:
> 
> gcc -o psql -L../../interfaces/libpq command.o common.o help.o input.o
> stringutils.o mainloop.o copy.o startup.o prompt.o variables.o large_obj.o
> print.o describe.o  -lpq -L/usr/sup/gnu/lib -lgen -lcrypt -lnsl -lsocket
> -ldl -lm -lreadline -ltermcap -lcurses 
> ld: fatal: symbol `xmalloc' is multiply defined:
>         (file common.o and file /usr/sup/gnu/lib/libreadline.a(xmalloc.o));
> ld: fatal: File processing errors. No output written to psql
> make: *** [psql] Error 1
> 
> This happens on a (particular) Solaris box but not on a (particular) Linux
> box. Beats the heck out of me. ;(

I can't find xmalloc in the source, and can't figure out how it could be
_defined_ in common.o.  Strange.

--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


Re: [HACKERS] psql Week 4.142857

From
Peter Eisentraut
Date:
On Oct 28, Bruce Momjian mentioned:

> > gcc -o psql -L../../interfaces/libpq command.o common.o help.o input.o
> > stringutils.o mainloop.o copy.o startup.o prompt.o variables.o large_obj.o
> > print.o describe.o  -lpq -L/usr/sup/gnu/lib -lgen -lcrypt -lnsl -lsocket
> > -ldl -lm -lreadline -ltermcap -lcurses 
> > ld: fatal: symbol `xmalloc' is multiply defined:
> >         (file common.o and file /usr/sup/gnu/lib/libreadline.a(xmalloc.o));
> > ld: fatal: File processing errors. No output written to psql
> > make: *** [psql] Error 1
> > 
> > This happens on a (particular) Solaris box but not on a (particular) Linux
> > box. Beats the heck out of me. ;(
> 
> I can't find xmalloc in the source, and can't figure out how it could be
> _defined_ in common.o.  Strange.

Oh, I defined it in that file, it's used in psql. Unfortunately, it seems
to be used internally in readline as well. In now figured out that this
causes problems only with static linking, but not dynamic. I'm no expert
on linking, does anyone have an idea or do I have to make up a different
name?

-- 
Peter Eisentraut                  Sernanders vaeg 10:115
peter_e@gmx.net                   75262 Uppsala
http://yi.org/peter-e/            Sweden



Re: [HACKERS] psql Week 4.142857

From
Tom Lane
Date:
Peter Eisentraut <peter_e@gmx.net> writes:
> Oh, I defined it in that file, it's used in psql. Unfortunately, it seems
> to be used internally in readline as well. In now figured out that this
> causes problems only with static linking, but not dynamic. I'm no expert
> on linking, does anyone have an idea or do I have to make up a different
> name?

Pick another name --- you're just *asking* for trouble with that one.
People tend to invent macros with names like that...
        regards, tom lane


Re: [HACKERS] psql Week 4.142857

From
Bruce Momjian
Date:
> Oh, I defined it in that file, it's used in psql. Unfortunately, it seems
> to be used internally in readline as well. In now figured out that this
> causes problems only with static linking, but not dynamic. I'm no expert
> on linking, does anyone have an idea or do I have to make up a different
> name?

Yes, very different name.  We are supporting tons of platforms.  You
need something very unique.

--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


Re: [HACKERS] psql Week 4.142857

From
Bruce Momjian
Date:
> Oops, the stuff I posted yesterday contained a few pretty funky bugs. I
> have put up a new tarball.
> 
> Also, I have written updated DocBook documentation. It's not a great work
> of literature yet but it's for those that want to get started. I will
> update it several times during the next few days.
> 
> Again, those URLs are:
> http://www.pathwaynet.com/~peter/psql-final.tar.gz (49k)
> http://www.pathwaynet.com/~peter/psql-ref.sgml.gz (16k)
> 
> And for those who don't want to rebuild the whole documentation:
> http://www.pathwaynet.com/~peter/psql-ref.html
> 
>     -Peter

Applied.  Configure changes also applied.

--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


New version of psql

From
Bruce Momjian
Date:
OK, new version of psql installed.  Only problem I see is that \h shows
TRUNCATE as the first help item.  I assume the directory contents are
not being sorted.  Peter?

Second, the new psql prompt is #, so it shows as:
test-#

Not sure I like that.  I liked the > better, I think, unless # grows on
me.

Comments?


--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


Re: [HACKERS] New version of psql

From
Michael Simms
Date:
> 
> OK, new version of psql installed.  Only problem I see is that \h shows
> TRUNCATE as the first help item.  I assume the directory contents are
> not being sorted.  Peter?
> 
> Second, the new psql prompt is #, so it shows as:
> 
>     test-#
> 
> Not sure I like that.  I liked the > better, I think, unless # grows on
> me.
> 
> Comments?
> 

Surely make it # if the user is a postgres superuser or > if not

Makes it consistent and functional.
                    ~Michael


Re: [HACKERS] New version of psql

From
Bruce Momjian
Date:
> > 
> > OK, new version of psql installed.  Only problem I see is that \h shows
> > TRUNCATE as the first help item.  I assume the directory contents are
> > not being sorted.  Peter?
> > 
> > Second, the new psql prompt is #, so it shows as:
> > 
> >     test-#
> > 
> > Not sure I like that.  I liked the > better, I think, unless # grows on
> > me.
> > 
> > Comments?
> > 
> 
> Surely make it # if the user is a postgres superuser or > if not
> 
> Makes it consistent and functional.

I see now. Thanks.  Makes sense.

--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


Re: [HACKERS] New version of psql

From
Bruce Momjian
Date:
> > Surely make it # if the user is a postgres superuser or > if not
> > 
> > Makes it consistent and functional.
> 
> I see now. Thanks.  Makes sense.

Peter, are you working on libpq as well?

--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


Re: [HACKERS] New version of psql

From
Don Baccus
Date:
At 05:22 PM 11/4/99 -0500, Bruce Momjian wrote:
>OK, new version of psql installed.  Only problem I see is that \h shows
>TRUNCATE as the first help item.  I assume the directory contents are
>not being sorted.  Peter?
>
>Second, the new psql prompt is #, so it shows as:
>
>    test-#
>
>Not sure I like that.  I liked the > better, I think, unless # grows on
>me.
>
>Comments?

Was there a reason for changing it?

I guess I'm from the old school, why make changes needlessly?



- Don Baccus, Portland OR <dhogaza@pacifier.com> Nature photos, on-line guides, Pacific Northwest Rare Bird Alert
Serviceand other goodies at http://donb.photo.net.
 


Re: [HACKERS] New version of psql

From
Bruce Momjian
Date:
> OK, new version of psql installed.  Only problem I see is that \h shows
> TRUNCATE as the first help item.  I assume the directory contents are
> not being sorted.  Peter?
> 
> Second, the new psql prompt is #, so it shows as:
> 
>     test-#
> 
> Not sure I like that.  I liked the > better, I think, unless # grows on
> me.
> 
> Comments?
> 

It appears the PAGER is not working.  If I do a SELECT, the result
scrolls off my screen.

--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


Re: [HACKERS] New version of psql

From
Bruce Momjian
Date:
> > OK, new version of psql installed.  Only problem I see is that \h shows
> > TRUNCATE as the first help item.  I assume the directory contents are
> > not being sorted.  Peter?
> > 
> > Second, the new psql prompt is #, so it shows as:
> > 
> >     test-#
> > 
> > Not sure I like that.  I liked the > better, I think, unless # grows on
> > me.
> > 
> > Comments?
> > 
> 
> It appears the PAGER is not working.  If I do a SELECT, the result
> scrolls off my screen.

Seems pager is off by default.  Enable with \pset pager.  Any reason we
don't enable it by default, Peter?

--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


Re: [HACKERS] New version of psql

From
Bruce Momjian
Date:
> OK, new version of psql installed.  Only problem I see is that \h shows
> TRUNCATE as the first help item.  I assume the directory contents are
> not being sorted.  Peter?
> 
> Second, the new psql prompt is #, so it shows as:
> 
>     test-#
> 
> Not sure I like that.  I liked the > better, I think, unless # grows on
> me.

I have changed psql so the pager is in by default.  Very easy to do with
the new code.

--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


Re: [HACKERS] New version of psql

From
Peter Eisentraut
Date:
On 1999-11-04, Bruce Momjian mentioned:

> > It appears the PAGER is not working.  If I do a SELECT, the result
> > scrolls off my screen.
> 
> Seems pager is off by default.  Enable with \pset pager.  Any reason we
> don't enable it by default, Peter?

No.

Perhaps I'm too used to using scrollbars on the {x|k}terms. Or perhaps it
was some "everything is off by default" idea. No reason really though.

-- 
Peter Eisentraut                  Sernanders vaeg 10:115
peter_e@gmx.net                   75262 Uppsala
http://yi.org/peter-e/            Sweden



Re: New version of psql

From
Peter Eisentraut
Date:
On 1999-11-04, Bruce Momjian mentioned:

> OK, new version of psql installed.  Only problem I see is that \h shows
> TRUNCATE as the first help item.  I assume the directory contents are
> not being sorted.  Peter?
> 
> Second, the new psql prompt is #, so it shows as:
> 
>     test-#
> 
> Not sure I like that.  I liked the > better, I think, unless # grows on
> me.

The new prompt is the same as the the old one. *** Scratches head ***

The '>' is replaced by a '#' if you are the superuser. (Correction: if the
username is "postgres". I'm still thinking about ways to make this a
little more elegant though. Ideas welcome.)

The '-' shouldn't be there unless you're in continue mode, as usual. Works
for me:

testdb=> select *
testdb-> from foo;
ERROR:  foo: Table does not exist.
testdb=> \c - postgres
You are now connected as new user postgres.
testdb=# select *
testdb-# from foo;
ERROR:  foo: Table does not exist.

Of course you can also completely customize your prompt. See the docs for
that.
-Peter

-- 
Peter Eisentraut                  Sernanders vaeg 10:115
peter_e@gmx.net                   75262 Uppsala
http://yi.org/peter-e/            Sweden



Re: New version of psql

From
Peter Eisentraut
Date:
On 1999-11-04, Bruce Momjian mentioned:

> OK, new version of psql installed.  Only problem I see is that \h shows
> TRUNCATE as the first help item.  I assume the directory contents are
> not being sorted.  Peter?

Try attached patch. Perhaps this is a file system thing. On my box they
are are sorted beautifully.
-Peter

-- 
Peter Eisentraut                  Sernanders vaeg 10:115
peter_e@gmx.net                   75262 Uppsala
http://yi.org/peter-e/            Sweden

Re: New version of psql

From
Peter Eisentraut
Date:
On 1999-11-04, Bruce Momjian mentioned:

> OK, new version of psql installed.

This takes care of these TODO items:
* Allow psql \copy to allow delimiters
* Allow psql to print nulls as distinct from ""(see TODO.detail/null)

Also this is already taken care of but it's still in my TODO:
* Make configure --enable-debug add -g on compile line

In unrelated news, I found out the other day that there is actually a Lisp
binding for Pgsql. It says for version 6.4.2 on it. I'm going to see if I
can track down who wrote it.

-- 
Peter Eisentraut                  Sernanders vaeg 10:115
peter_e@gmx.net                   75262 Uppsala
http://yi.org/peter-e/            Sweden



Re: [HACKERS] New version of psql

From
Peter Eisentraut
Date:
On 1999-11-04, Bruce Momjian mentioned:

> > > Surely make it # if the user is a postgres superuser or > if not
> > > 
> > > Makes it consistent and functional.
> > 
> > I see now. Thanks.  Makes sense.
> 
> Peter, are you working on libpq as well?

Nope.

My next projects where to put in the tab completion I have lying around
here, to implement some sort if \if \else \endif so you can write *really*
cool scripts, and to adjust the createdb etc. scripts a little.

Then I would be available for doing a little libpq stuff, but I'm not even
sure what needs to be done. Bring it on . . .

-- 
Peter Eisentraut                  Sernanders vaeg 10:115
peter_e@gmx.net                   75262 Uppsala
http://yi.org/peter-e/            Sweden



Re: [HACKERS] New version of psql

From
Bruce Momjian
Date:
> On 1999-11-04, Bruce Momjian mentioned:
> 
> > > It appears the PAGER is not working.  If I do a SELECT, the result
> > > scrolls off my screen.
> > 
> > Seems pager is off by default.  Enable with \pset pager.  Any reason we
> > don't enable it by default, Peter?
> 
> No.
> 
> Perhaps I'm too used to using scrollbars on the {x|k}terms. Or perhaps it
> was some "everything is off by default" idea. No reason really though.

I have made the change to enable pager by default.  Thanks.

--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


Re: New version of psql

From
Bruce Momjian
Date:
> On 1999-11-04, Bruce Momjian mentioned:
> 
> > OK, new version of psql installed.  Only problem I see is that \h shows
> > TRUNCATE as the first help item.  I assume the directory contents are
> > not being sorted.  Peter?
> > 
> > Second, the new psql prompt is #, so it shows as:
> > 
> >     test-#
> > 
> > Not sure I like that.  I liked the > better, I think, unless # grows on
> > me.
> 
> The new prompt is the same as the the old one. *** Scratches head ***
> 
> The '>' is replaced by a '#' if you are the superuser. (Correction: if the
> username is "postgres". I'm still thinking about ways to make this a
> little more elegant though. Ideas welcome.)

Thanks.  Yes, nice new feature.

--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


Re: New version of psql

From
Bruce Momjian
Date:
> On 1999-11-04, Bruce Momjian mentioned:
> 
> > OK, new version of psql installed.  Only problem I see is that \h shows
> > TRUNCATE as the first help item.  I assume the directory contents are
> > not being sorted.  Peter?
> 
> Try attached patch. Perhaps this is a file system thing. On my box they
> are are sorted beautifully.

Thanks.  Patch applied.  That did the trick.

--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


Re: [HACKERS] New version of psql

From
Bruce Momjian
Date:
> On 1999-11-04, Bruce Momjian mentioned:
> 
> > > > Surely make it # if the user is a postgres superuser or > if not
> > > > 
> > > > Makes it consistent and functional.
> > > 
> > > I see now. Thanks.  Makes sense.
> > 
> > Peter, are you working on libpq as well?
> 
> Nope.

I just asked because you were mentioning a lot of old stuff, and I
thought you meant in libpq.  Now I see you meant old stuff in the psql
code about our old 'monitor' program and stuff.

One amazing trick is your ability to pull the help right out of the sgml
sources.  I never expected that would be possible.  Makes maintaining
things a lot easier.

> 
> My next projects where to put in the tab completion I have lying around
> here, to implement some sort if \if \else \endif so you can write *really*
> cool scripts, and to adjust the createdb etc. scripts a little.

Sounds good.


--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


Re: New version of psql

From
Bruce Momjian
Date:
> On 1999-11-04, Bruce Momjian mentioned:
> 
> > OK, new version of psql installed.
> 
> This takes care of these TODO items:
> * Allow psql \copy to allow delimiters
> * Allow psql to print nulls as distinct from ""(see TODO.detail/null)

Thanks.  That helps.  TODO updated.

--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


Re: [HACKERS] Re: New version of psql

From
Tom Lane
Date:
Peter Eisentraut <peter_e@gmx.net> writes:
> The '>' is replaced by a '#' if you are the superuser. (Correction: if the
> username is "postgres". I'm still thinking about ways to make this a
> little more elegant though. Ideas welcome.)

You should be looking at the usesuper column from pg_user if you really
want a correct indication of whether the user has superuser privs.
        regards, tom lane