pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedpgbash-1.1.1 release
9+ messages / 7 participants
[nested] [flat]
* pgbash-1.1.1 release
@ 1999-10-01 08:24 SAKAIDA <sakaida@psn.co.jp>
0 siblings, 2 replies; 9+ messages in thread
From: SAKAIDA @ 1999-10-01 08:24 UTC (permalink / raw)
To: hackers@postgreSQL.org; +Cc: pgsql-interfaces
Hi,
With many cooperators, I have made a *bash built-in command* for
PostgreSQL called "pgbash".
The pgbash is the system which offers the 'direct SQL'/'embedded
SQL' interface for PostgreSQL by being included in the bash-2.x
shell.
Features of pgbash
-------------------
1.The pgbash has a function which is equivalent to psql except for
the interactive input processing function.
2.It is possible that pgbash carries out the interactive input
processing using the hysteresis editing function ( history, !,
fc command ) of bash.
3.An output of retrieval result and database information of pgbash
uses PSprint() which improved PQprint(). By PSprint(), it is
possible to output by plain table type, plain table + outer frame
type and HTML table type. And, it is possible to display NULL
value string(like '-NULL-') and bit zero string(like '-0-').
4.It is possible that pgbash manipulates multiple databases using
CONNECT, DISCONNECT and SET CONNECTION (or -d option ).
5.The pgbash has a function which substitutes the retrieval result
for the shell variable using FETCH INTO statement.
6.It is possible to set CGI mode. In CGI mode, the pgbash switches
the output to HTML, and read the datat by GET/POST method, and
read the data of HTTP_COOKIE.
7.The pgbash sets "error code", "error message", "number of tuples",
etc to the shell variable. Therefore, it is possible to know the
condition after the SQL execution.
Details is as follows.
http://www.psn.co.jp/PostgreSQL/pgbash/index-e.html
# I am very glad, if many people will use the pgbash.
--
Regards.
SAKAIDA Masaaki -- Osaka, Japan
# Sorry, I am not good at English.
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: [HACKERS] pgbash-1.1.1 release
@ 1999-10-01 11:38 Oleg Bartunov <oleg@sai.msu.su>
parent: SAKAIDA <sakaida@psn.co.jp>
1 sibling, 2 replies; 9+ messages in thread
From: Oleg Bartunov @ 1999-10-01 11:38 UTC (permalink / raw)
To: SAKAIDA <sakaida@psn.co.jp>; +Cc: hackers@postgreSQL.org; pgsql-interfaces
That's really cool !
I just install and played a little bit.
I found a minor problem :
I have to connect to any database to issue
exec_sql -l database
I have no my personal database
Here is a log:
bash-2.03$ exec_sql -l database
(-402)FATAL 1: Database megera does not exist in pg_database
bash-2.03$ exec_sql "connect to discovery"
# PostgreSQL 6.5.2 on i586-pc-linux-gnulibc1, compiled by gcc 2.95.1
# CONNECT TO discovery:5432 AS discovery USER megera
bash-2.03$ exec_sql -l database
# Databases list
datname |datdba|encoding|datpath
---------+------+--------+---------
template1| 505| 16|template1
apod | 11| 16|apod
I don't understand this requirements just to list all databases
Regards,
Oleg
On Fri, 1 Oct 1999, SAKAIDA wrote:
> Date: Fri, 01 Oct 1999 17:24:57 +0900
> From: SAKAIDA <sakaida@psn.co.jp>
> To: hackers@postgreSQL.org
> Cc: pgsql-interfaces@postgreSQL.org
> Subject: [HACKERS] pgbash-1.1.1 release
>
> Hi,
>
> With many cooperators, I have made a *bash built-in command* for
> PostgreSQL called "pgbash".
>
> The pgbash is the system which offers the 'direct SQL'/'embedded
> SQL' interface for PostgreSQL by being included in the bash-2.x
> shell.
>
>
> Features of pgbash
> -------------------
>
> 1.The pgbash has a function which is equivalent to psql except for
> the interactive input processing function.
>
> 2.It is possible that pgbash carries out the interactive input
> processing using the hysteresis editing function ( history, !,
> fc command ) of bash.
>
> 3.An output of retrieval result and database information of pgbash
> uses PSprint() which improved PQprint(). By PSprint(), it is
> possible to output by plain table type, plain table + outer frame
> type and HTML table type. And, it is possible to display NULL
> value string(like '-NULL-') and bit zero string(like '-0-').
>
> 4.It is possible that pgbash manipulates multiple databases using
> CONNECT, DISCONNECT and SET CONNECTION (or -d option ).
>
> 5.The pgbash has a function which substitutes the retrieval result
> for the shell variable using FETCH INTO statement.
>
> 6.It is possible to set CGI mode. In CGI mode, the pgbash switches
> the output to HTML, and read the datat by GET/POST method, and
> read the data of HTTP_COOKIE.
>
> 7.The pgbash sets "error code", "error message", "number of tuples",
> etc to the shell variable. Therefore, it is possible to know the
> condition after the SQL execution.
>
>
> Details is as follows.
> http://www.psn.co.jp/PostgreSQL/pgbash/index-e.html
>
> # I am very glad, if many people will use the pgbash.
>
> --
> Regards.
>
> SAKAIDA Masaaki -- Osaka, Japan
> # Sorry, I am not good at English.
>
>
> ************
>
_____________________________________________________________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: [HACKERS] pgbash-1.1.1 release
@ 1999-10-01 14:08 SAKAIDA Masaaki <sakaida@psn.co.jp>
parent: Oleg Bartunov <oleg@sai.msu.su>
1 sibling, 2 replies; 9+ messages in thread
From: SAKAIDA Masaaki @ 1999-10-01 14:08 UTC (permalink / raw)
To: hackers@postgreSQL.org
Oleg Bartunov <oleg@sai.msu.su> wrote:
> That's really cool !
Thank you.
> I just install and played a little bit.
> I found a minor problem :
> I have to connect to any database to issue
> exec_sql -l database
> I have no my personal database
> Here is a log:
>
> bash-2.03$ exec_sql -l database
> (-402)FATAL 1: Database megera does not exist in pg_database
If CONNECT have not been executed yet, "CONNECT TO DEFAULT"
will be automatically issued when -l option is executed.
If user name is "megera", then "CONNECT TO DEFAULT" is equal
to "CONNECT TO megera USER megera".
> bash-2.03$ exec_sql "connect to discovery"
> # PostgreSQL 6.5.2 on i586-pc-linux-gnulibc1, compiled by gcc 2.95.1
> # CONNECT TO discovery:5432 AS discovery USER megera
>
> bash-2.03$ exec_sql -l database
> # Databases list
>
> datname |datdba|encoding|datpath
> ---------+------+--------+---------
> template1| 505| 16|template1
> apod | 11| 16|apod
>
> I don't understand this requirements just to list all databases
This approach is equal to psql.
# However, I consider that "CONNECT TO template1" may be better
than "CONNECT TO <User_naame>" in the case of "-l database".
--
Regard.
SAKAIDA Masaaki -- Osaka, Japan
# Sorry, I am not good at English.
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: [HACKERS] pgbash-1.1.1 release
@ 1999-10-02 03:39 SAKAIDA <sakaida@psn.co.jp>
parent: SAKAIDA Masaaki <sakaida@psn.co.jp>
1 sibling, 0 replies; 9+ messages in thread
From: SAKAIDA @ 1999-10-02 03:39 UTC (permalink / raw)
To: Oleg Bartunov <oleg@sai.msu.su>; pgsql-hackers@postgreSQL.org
Oleg Bartunov <oleg@sai.msu.su> wrote:
> Sakaida,
>
> sorry for bothering you but I didn't find
> TODO file and wondering what new features (if any)
> you plan to implement to pgbash.
Please give me your opinion. My plan is not yet the concrete,
but a few of my new plan are:
1. Improvement of function of an HTML output.
exec_sql -H -O "<TABLE option>"
-O "*:<TH option1>" -O "name:<TH option2>"
-O "*:<TD option3>" -O "addr:<TD option4>"
-F "name:<font color='0000ff' size=4>%-7.7s</font>"
-F "addr:<fonr color='ff0000'>%s</font>"
"select * from test where ..."
2. Snapshot cursor operation.
exec_sql -c cur "select * from test where ..."
exec_sql "open cur"
exec_sql "fetch in cur into :r1, :r2"
echo "r1=$r1 r2=$r2"
exec_sql "close cur"
# Declare cursor operation is already implemented.
> I'm a little boried to enclose SQL statements
> into double quotes. Is't really need ?
I think that it is necessary, because in the inside of the
double quotes, it can be used $variable and it is possible to
describe the SQL statement in the multiple line.
ex) exec_sql "select * from test
where name='$DATA' and
addr='$ADATA'"
> I'm doubt it's possible, because
> SQL statement must begins from valid SQL word.
>
> If it's impossible to avoid probably pgbash
> might have a possibility to redefine quote character,
> so user could use
> exec_sql [select * from test]
> Notice, no need to press shift key !
> I think with a little more effort this could be
> achieved without explicit redefining of
> quote character. But this is not a big problem,
> I could use alias to define [] as a quote characters
> just as an example:
> alias sql='exec_sql -Q "[]"'
> and then use sql instead of exec_sql.
>
I use alias too, but I do not know the method for aliasing
double quotes.
ex)
alias E='exec_sql'
(Shell program)
-----------------------------------------------------
#!/usr/local/bin/bash
function E { exec_sql "$@" }
-----------------------------------------------------
(KUBO Takehiro taught me this method.)
> Anyway, I'm just speculating about enhancement
> after playing for several hours with pgbash.
> I like it !
I hope a new idea.
--
Regards.
SAKAIDA Masaaki -- Osaka, Japan
# Sorry, I am not good at English.
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: [HACKERS] pgbash-1.1.1 release
@ 1999-10-02 04:00 SAKAIDA <sakaida@psn.co.jp>
parent: SAKAIDA Masaaki <sakaida@psn.co.jp>
1 sibling, 0 replies; 9+ messages in thread
From: SAKAIDA @ 1999-10-02 04:00 UTC (permalink / raw)
To: hackers@postgreSQL.org
Oleg Bartunov <oleg@sai.msu.su> wrote:
> Sakaida,
>
> sorry for bothering you but I didn't find
> TODO file and wondering what new features (if any)
> you plan to implement to pgbash.
Please give me your opinion. My plan is not yet the concrete,
but a few of my new plan are:
1. Improvement of function of an HTML output.
exec_sql -H -O "<TABLE option>"
-O "*:<TH option1>" -O "name:<TH option2>"
-O "*:<TD option3>" -O "addr:<TD option4>"
-F "name:<font color='0000ff' size=4>%-7.7s</font>"
-F "addr:<fonr color='ff0000'>%s</font>"
"select * from test where ..."
2. Snapshot cursor operation.
exec_sql -c cur "select * from test where ..."
exec_sql "open cur"
exec_sql "fetch in cur into :r1, :r2"
echo "r1=$r1 r2=$r2"
exec_sql "close cur"
# Declare cursor operation is already implemented.
> I'm a little boried to enclose SQL statements
> into double quotes. Is't really need ?
I think that it is necessary, because in the inside of the
double quotes, it can be used $variable and it is possible to
describe the SQL statement in the multiple line.
ex) exec_sql "select * from test
where name='$DATA' and
addr='$ADATA'"
> I'm doubt it's possible, because
> SQL statement must begins from valid SQL word.
>
> If it's impossible to avoid probably pgbash
> might have a possibility to redefine quote character,
> so user could use
> exec_sql [select * from test]
> Notice, no need to press shift key !
> I think with a little more effort this could be
> achieved without explicit redefining of
> quote character. But this is not a big problem,
> I could use alias to define [] as a quote characters
> just as an example:
> alias sql='exec_sql -Q "[]"'
> and then use sql instead of exec_sql.
>
I use alias too, but I do not know the method for aliasing
double quotes.
ex)
alias E='exec_sql'
(Shell program)
-----------------------------------------------------
#!/usr/local/bin/bash
function E { exec_sql "$@" }
-----------------------------------------------------
(KUBO Takehiro taught me this method.)
> Anyway, I'm just speculating about enhancement
> after playing for several hours with pgbash.
> I like it !
I hope a new idea.
--
Regards.
SAKAIDA Masaaki -- Osaka, Japan
# Sorry, I am not good at English.
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: [INTERFACES] Re: [HACKERS] pgbash-1.1.1 release
@ 1999-10-02 04:51 Gene Selkov Jr. <selkovjr@xnet.com>
parent: Oleg Bartunov <oleg@sai.msu.su>
1 sibling, 0 replies; 9+ messages in thread
From: Gene Selkov Jr. @ 1999-10-02 04:51 UTC (permalink / raw)
To: Oleg Bartunov <oleg@sai.msu.su>; pgsql-interfaces
> I have to connect to any database to issue
> exec_sql -l database
A database name is required to connect (by libpq? protocol?). This
can be cured by using template1 as a default. However, the issue
naturally develops into a more serious concern: are we going to have
inter-database queries in any plausible future?
Thanks,
--Gene
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The idea of adding a database interface to sh, although I can
immediately see its usefulness, srikes me funny. We are apparently
looking to have an elisp interface soon (thanks to Eric Marsden);
sooner or later, one will be finding the SQL code stashed everywhere
throughout the system. Would it then be wrong to expect the whole
backend embedded into the unix kernel? That would definitely swallow a
share of IBM's server market ;-> Now think about this: after wrapping
it up into the kernel, what will prevent you from building a Prolog on
top of it? Next thing that comes to mind would be a neural network
interface to the postgres-enabled prolog-backtracking unix kernel.
The chances of winnning a Rube Godberg contest are already high and
rising ...
http://www.anl.gov/OPA/rube/rubeolive.html
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: [INTERFACES] Re: [HACKERS] pgbash-1.1.1 release
@ 1999-10-02 05:02 Gene Selkov, Jr. <selkovjr@mcs.anl.gov>
0 siblings, 1 reply; 9+ messages in thread
From: Gene Selkov, Jr. @ 1999-10-02 05:02 UTC (permalink / raw)
To: pgsql-interfaces
> I have to connect to any database to issue
> exec_sql -l database
A database name is required to connect (by libpq? protocol?). This
can be cured by using template1 as a default. However, the issue
naturally develops into a more serious concern: are we going to have
inter-database queries in any plausible future?
Thanks,
--Gene
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The idea of adding a database interface to sh, although I can
immediately see its usefulness, srikes me funny. We are apparently
looking to have an elisp interface soon (thanks to Eric Marsden);
sooner or later, one will be finding the SQL code stashed everywhere
throughout the system. Would it then be wrong to expect the whole
backend embedded into the unix kernel? That would definitely swallow a
share of IBM's server market ;-> Now think about this: after wrapping
it up into the kernel, what will prevent you from building a Prolog on
top of it? Next thing that comes to mind would be a neural network
interface to the postgres-enabled prolog-backtracking unix kernel.
The chances of winnning a Rube Godberg contest are already high and
rising ...
http://www.anl.gov/OPA/rube/rubeolive.html
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: [INTERFACES] Re: [HACKERS] pgbash-1.1.1 release
@ 1999-10-02 15:24 Tom Lane <tgl@sss.pgh.pa.us>
parent: Gene Selkov, Jr. <selkovjr@mcs.anl.gov>
0 siblings, 0 replies; 9+ messages in thread
From: Tom Lane @ 1999-10-02 15:24 UTC (permalink / raw)
To: Gene Selkov, Jr. <selkovjr@mcs.anl.gov>; +Cc: pgsql-interfaces
"Gene Selkov, Jr." <selkovjr@mcs.anl.gov> writes:
>> I have to connect to any database to issue
>> exec_sql -l database
> A database name is required to connect (by libpq? protocol?).
It's a security issue: Postgres' authentication model is that you are
allowed to connect if your hostaddress + username + databasename match
any of the entries in the pg_hba.conf file (and, depending on the
authentication method, you may also have to supply a password or
something). Although people often leave the database name as a
wildcard, it's possible to have tighter security on some databases
than others, and I'm sure you can see that that is a useful feature.
So, you cannot do anything, not even list the databases, without having
authenticated yourself, and that means specifying a database name that
you have the right to connect to.
> This can be cured by using template1 as a default.
This raises an interesting problem: we do recommend that in the docs,
and several of the Postgres shell scripts connect to template1 for lack
of a better idea. But if I were running a secure installation I'd sure
as heck have template1 locked up tighter than a drum, with *no* access
to anyone but the DB admin. So, how could we allow someone to list
databases without requiring access to template1 and without making any
assumptions about the names of other databases in the system? I don't
see a way to do it in the current system design. A possible approach is
to invent a second standard database name, maybe "template0", which
allows nothing but selects from pg_database and perhaps one or two other
operations we deem safe.
> However, the issue naturally develops into a more serious concern: are
> we going to have inter-database queries in any plausible future?
There has been some talk of that, and I'm sure that if it ever happened
you'd be required to authenticate yourself for each database.
regards, tom lane
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: [INTERFACES] pgbash-1.1.1 release
@ 1999-10-15 01:48 Clark C. Evans <clark.evans@manhattanproject.com>
parent: SAKAIDA <sakaida@psn.co.jp>
1 sibling, 0 replies; 9+ messages in thread
From: Clark C. Evans @ 1999-10-15 01:48 UTC (permalink / raw)
To: SAKAIDA <sakaida@psn.co.jp>; +Cc: hackers@postgreSQL.org; pgsql-interfaces
This works like a charm. Thanks tons!
;) Clark
On Fri, 1 Oct 1999, SAKAIDA wrote:
> Hi,
>
> With many cooperators, I have made a *bash built-in command* for
> PostgreSQL called "pgbash".
>
> The pgbash is the system which offers the 'direct SQL'/'embedded
> SQL' interface for PostgreSQL by being included in the bash-2.x
> shell.
>
>
> Features of pgbash
> -------------------
>
> 1.The pgbash has a function which is equivalent to psql except for
> the interactive input processing function.
>
> 2.It is possible that pgbash carries out the interactive input
> processing using the hysteresis editing function ( history, !,
> fc command ) of bash.
>
> 3.An output of retrieval result and database information of pgbash
> uses PSprint() which improved PQprint(). By PSprint(), it is
> possible to output by plain table type, plain table + outer frame
> type and HTML table type. And, it is possible to display NULL
> value string(like '-NULL-') and bit zero string(like '-0-').
>
> 4.It is possible that pgbash manipulates multiple databases using
> CONNECT, DISCONNECT and SET CONNECTION (or -d option ).
>
> 5.The pgbash has a function which substitutes the retrieval result
> for the shell variable using FETCH INTO statement.
>
> 6.It is possible to set CGI mode. In CGI mode, the pgbash switches
> the output to HTML, and read the datat by GET/POST method, and
> read the data of HTTP_COOKIE.
>
> 7.The pgbash sets "error code", "error message", "number of tuples",
> etc to the shell variable. Therefore, it is possible to know the
> condition after the SQL execution.
>
>
> Details is as follows.
> http://www.psn.co.jp/PostgreSQL/pgbash/index-e.html
>
> # I am very glad, if many people will use the pgbash.
>
> --
> Regards.
>
> SAKAIDA Masaaki -- Osaka, Japan
> # Sorry, I am not good at English.
>
>
> ************
>
^ permalink raw reply [nested|flat] 9+ messages in thread
end of thread, other threads:[~1999-10-15 01:48 UTC | newest]
Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-10-01 08:24 pgbash-1.1.1 release SAKAIDA <sakaida@psn.co.jp>
1999-10-01 11:38 ` Oleg Bartunov <oleg@sai.msu.su>
1999-10-01 14:08 ` SAKAIDA Masaaki <sakaida@psn.co.jp>
1999-10-02 03:39 ` SAKAIDA <sakaida@psn.co.jp>
1999-10-02 04:00 ` SAKAIDA <sakaida@psn.co.jp>
1999-10-02 04:51 ` Gene Selkov Jr. <selkovjr@xnet.com>
1999-10-15 01:48 ` Clark C. Evans <clark.evans@manhattanproject.com>
1999-10-02 05:02 Re: [INTERFACES] Re: [HACKERS] pgbash-1.1.1 release Gene Selkov, Jr. <selkovjr@mcs.anl.gov>
1999-10-02 15:24 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox