\copy in Current CVS

Started by Teodor Sigaevabout 23 years ago57 messageshackers
Jump to latest
#1Teodor Sigaev
teodor@sigaev.ru

Simple script:
CREATE TABLE test(a int);
\copy test from '/tmp/wow'
select * from test;

now produce error:
\copy: COPY state must be terminated first

I missed something?

--
Teodor Sigaev
teodor@stack.net

#2Dave Cramer
pg@fastcrypt.com
In reply to: Teodor Sigaev (#1)
request for sql3 compliance for the update command

I have a large customer who is converting from informix to postgres and
they have made extensive use of

update table set (col...) = ( val...)

as a first pass would it be possible to translate this in the parser to

update table set col=val

It would appear that this is SQL3 compliant

<set clause> ::=
<update target> <equals operator> <row value designator>

<update target> ::=
<object column>
| <left paren> <object column list> <right paren>

or can someone think of another way?
--
Dave Cramer <dave@fastcrypt.com>
Cramer Consulting

#3Dave Cramer
pg@fastcrypt.com
In reply to: Teodor Sigaev (#1)
request for sql3 compliance for the update command

Bruce,

Can you chime in with your support here?

Dave

I have a large customer who is converting from informix to postgres and
they have made extensive use of

update table set (col...) = ( val...)

as a first pass would it be possible to translate this in the parser to

update table set col=val

It would appear that this is SQL3 compliant

<set clause> ::=
<update target> <equals operator> <row value designator>

<update target> ::=
<object column>
| <left paren> <object column list> <right paren>

or can someone think of another way?
--
Dave Cramer <dave@fastcrypt.com>
Cramer Consulting

#4Peter Eisentraut
peter_e@gmx.net
In reply to: Dave Cramer (#2)
Re: request for sql3 compliance for the update command

Dave Cramer writes:

update table set (col...) = ( val...)

It would appear that this is SQL3 compliant

<set clause> ::=
<update target> <equals operator> <row value designator>

<update target> ::=
<object column>
| <left paren> <object column list> <right paren>

That's not what my copy says.

<set clause list> ::=
<set clause> [ { <comma> <set clause> }... ]

<set clause> ::=
<update target> <equals operator> <update source>
| <mutated set clause> <equals operator> <update source>

<update target> ::=
<object column>
| ROW
| <object column>
<left bracket or trigraph> <simple value specification> <right bracket or trigraph>

<object column> ::= <column name>

<mutated set clause> ::=
<mutated target> <period> <method name>

<mutated target> ::=
<object column>
| <mutated set clause>

<update source> ::=
<value expression>
| <contextually typed value specification>

(And I'm pretty sure I have the right version of the standard.)

--
Peter Eisentraut peter_e@gmx.net

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Dave Cramer (#2)
Re: request for sql3 compliance for the update command

Dave Cramer <dave@fastcrypt.com> writes:

It would appear that this is SQL3 compliant

<set clause> ::=
<update target> <equals operator> <row value designator>

<update target> ::=
<object column>
| <left paren> <object column list> <right paren>

I see no parentheses allowed there in the SQL99 spec. Encourage your
customer to use standard syntax.

regards, tom lane

#6Dave Cramer
pg@fastcrypt.com
In reply to: Peter Eisentraut (#4)
Re: request for sql3 compliance for the update command

Peter,

Referring to

http://src.doc.ic.ac.uk/packages/dbperl/refinfo/sql3/sql3bnf.sep93.txt

the following grammar exists

is the reference above valid?

as for tom's reply there are left paren, and right paren.

Dave
On Wed, 2003-02-19 at 10:37, Peter Eisentraut wrote:

Dave Cramer writes:

update table set (col...) = ( val...)

It would appear that this is SQL3 compliant

<set clause> ::=
<update target> <equals operator> <row value designator>

<update target> ::=
<object column>
| <left paren> <object column list> <right paren>

That's not what my copy says.

<set clause list> ::=
<set clause> [ { <comma> <set clause> }... ]

<set clause> ::=
<update target> <equals operator> <update source>
| <mutated set clause> <equals operator> <update source>

<update target> ::=
<object column>
| ROW
| <object column>
<left bracket or trigraph> <simple value specification> <right bracket or trigraph>

<object column> ::= <column name>

<mutated set clause> ::=
<mutated target> <period> <method name>

<mutated target> ::=
<object column>
| <mutated set clause>

<update source> ::=
<value expression>
| <contextually typed value specification>

(And I'm pretty sure I have the right version of the standard.)

--
Dave Cramer <dave@fastcrypt.com>
Cramer Consulting

#7Tom Lane
tgl@sss.pgh.pa.us
In reply to: Dave Cramer (#6)
Re: request for sql3 compliance for the update command

Dave Cramer <dave@fastcrypt.com> writes:

Referring to
http://src.doc.ic.ac.uk/packages/dbperl/refinfo/sql3/sql3bnf.sep93.txt
the following grammar exists
is the reference above valid?

Sep 93? That would be an extremely early draft of what eventually became
SQL99. Looks like the parens got lost again by the time of the final
spec.

Given that there's no visible functionality gain from allowing parens
here, I'm not surprised that the spec authors decided it wasn't such
a hot idea after all... too bad Informix didn't get the word :-(

regards, tom lane

#8Dave Cramer
pg@fastcrypt.com
In reply to: Tom Lane (#7)
Re: request for sql3 compliance for the update command

Ok, if a patch were submitted to the parser to allow the syntax in
question would it be considered?

Dave
On Wed, 2003-02-19 at 12:29, Tom Lane wrote:

Dave Cramer <dave@fastcrypt.com> writes:

Referring to
http://src.doc.ic.ac.uk/packages/dbperl/refinfo/sql3/sql3bnf.sep93.txt
the following grammar exists
is the reference above valid?

Sep 93? That would be an extremely early draft of what eventually became
SQL99. Looks like the parens got lost again by the time of the final
spec.

Given that there's no visible functionality gain from allowing parens
here, I'm not surprised that the spec authors decided it wasn't such
a hot idea after all... too bad Informix didn't get the word :-(

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

--
Dave Cramer <dave@fastcrypt.com>
Cramer Consulting

#9Tom Lane
tgl@sss.pgh.pa.us
In reply to: Dave Cramer (#8)
Re: request for sql3 compliance for the update command

Dave Cramer <dave@fastcrypt.com> writes:

Ok, if a patch were submitted to the parser to allow the syntax in
question would it be considered?

I would vote against it ... but that's only one vote.

regards, tom lane

#10Patrick Welche
prlw1@newn.cam.ac.uk
In reply to: Dave Cramer (#3)
Re: request for sql3 compliance for the update command

On Wed, Feb 19, 2003 at 07:31:35AM -0500, Dave Cramer wrote:

Bruce,

Can you chime in with your support here?

Dave

I have a large customer who is converting from informix to postgres and
they have made extensive use of

update table set (col...) = ( val...)

as a first pass would it be possible to translate this in the parser to

update table set col=val

It would appear that this is SQL3 compliant

<set clause> ::=
<update target> <equals operator> <row value designator>

<update target> ::=
<object column>
| <left paren> <object column list> <right paren>

or can someone think of another way?

I don't understand the original problem. What does informix give you? A
text file full of "update table set ()=()" which you then try to feed
into postgres? In that case, why not pass said text file through a sed or
perl script first?

Cheers,

Patrick

#11Dave Cramer
pg@fastcrypt.com
In reply to: Patrick Welche (#10)
Re: request for sql3 compliance for the update command

Patrick,

No, they support the syntax:

update table set (col1, col2, col3) = ( val1, val2, val3 )

I have a customer with a rather large application which uses this
syntax, because they were using informix. There is also a rather
interesting 4GL project called aubit which is on sourceforge. They would
also like to see this supported for the same reasons.

Dave

On Wed, 2003-02-19 at 15:02, Patrick Welche wrote:

I have a large customer who is converting from informix to postgres and
they have made extensive use of

update table set (col...) = ( val...)

as a first pass would it be possible to translate this in the parser to

update table set col=val

It would appear that this is SQL3 compliant

<set clause> ::=
<update target> <equals operator> <row value designator>

<update target> ::=
<object column>
| <left paren> <object column list> <right paren>

or can someone think of another way?

I don't understand the original problem. What does informix give you? A
text file full of "update table set ()=()" which you then try to feed
into postgres? In that case, why not pass said text file through a sed or
perl script first?

Cheers,

Patrick

--
Dave Cramer <dave@fastcrypt.com>
Cramer Consulting

#12Bruce Momjian
bruce@momjian.us
In reply to: Dave Cramer (#11)
Re: request for sql3 compliance for the update command

While I don't see the syntax of:

update table set (col...) = ( val...)

as valuable compared to separate col=val assignments, I do see a value
in allowing subqueries in such assignments:

update table set (col...) = ( select val ..)

Without it, you have to do separate subquery statements, and if they are
complex, that is a waste. I assume that was the motivation for the
feature.

---------------------------------------------------------------------------

Dave Cramer wrote:

Patrick,

No, they support the syntax:

update table set (col1, col2, col3) = ( val1, val2, val3 )

I have a customer with a rather large application which uses this
syntax, because they were using informix. There is also a rather
interesting 4GL project called aubit which is on sourceforge. They would
also like to see this supported for the same reasons.

Dave

On Wed, 2003-02-19 at 15:02, Patrick Welche wrote:

I have a large customer who is converting from informix to postgres and
they have made extensive use of

update table set (col...) = ( val...)

as a first pass would it be possible to translate this in the parser to

update table set col=val

It would appear that this is SQL3 compliant

<set clause> ::=
<update target> <equals operator> <row value designator>

<update target> ::=
<object column>
| <left paren> <object column list> <right paren>

or can someone think of another way?

I don't understand the original problem. What does informix give you? A
text file full of "update table set ()=()" which you then try to feed
into postgres? In that case, why not pass said text file through a sed or
perl script first?

Cheers,

Patrick

--
Dave Cramer <dave@fastcrypt.com>
Cramer Consulting

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

http://www.postgresql.org/users-lounge/docs/faq.html

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#13Mike Aubury
mike@aubit.com
In reply to: Dave Cramer (#11)
Re: request for sql3 compliance for the update command

On Wednesday 19 February 2003 8:18 pm, Dave Cramer wrote:

I have a customer with a rather large application which uses this
syntax, because they were using informix. There is also a rather
interesting 4GL project called aubit which is on sourceforge. They would
also like to see this supported for the same reasons.

Hey - I was going to say that...

For the curious:
Quick URL - http://aubit4gl.sourceforge.net/

Its a 'clone' of the Informix 4GL tool, a nice 'clean' language specifically
designed for writing database applications, with both curses & GTK, support
for multiple database types and a bunch of other things...

We're about to release version 0.30 - and I was going to wait until then....

#14Tatsuo Ishii
t-ishii@sra.co.jp
In reply to: Tom Lane (#9)
Re: request for sql3 compliance for the update command

Dave Cramer <dave@fastcrypt.com> writes:

Ok, if a patch were submitted to the parser to allow the syntax in
question would it be considered?

I would vote against it ... but that's only one vote.

I would vote against it too. Please don't add a none-standard syntax
any more (I think we got enough lesson from "foo = NULL compatibilty"
with MS products).
--
Tatsuo Ishii

#15Justin Clift
justin@postgresql.org
In reply to: Tom Lane (#9)
Re: request for sql3 compliance for the update command

Tom Lane wrote:

Dave Cramer <dave@fastcrypt.com> writes:

Ok, if a patch were submitted to the parser to allow the syntax in
question would it be considered?

I would vote against it ... but that's only one vote.

As a thought, will it add significant maintenance penalties or be
detrimental?

There seem to be quite a lot of Informix people moving to PostgreSQL
these days, moreso than Oracle shops. Might have been brought on by
IBM's purchase of Informix.

Wondering if this one change be a significant improvement in regards to
making it easier to migrate, or just a minor thing?

Regards and best wishes,

Justin Clift

regards, tom lane

--
"My grandfather once told me that there are two kinds of people: those
who work and those who take the credit. He told me to try to be in the
first group; there was less competition there."
- Indira Gandhi

#16Christopher Kings-Lynne
chriskl@familyhealth.com.au
In reply to: Bruce Momjian (#12)
Re: request for sql3 compliance for the update command

While I don't see the syntax of:

update table set (col...) = ( val...)

as valuable compared to separate col=val assignments, I do see a value
in allowing subqueries in such assignments:

update table set (col...) = ( select val ..)

Without it, you have to do separate subquery statements, and if they are
complex, that is a waste. I assume that was the motivation for the
feature.

The number of times I've needed this feature... :)

Chris

#17Chris Browne
cbbrowne@acm.org
In reply to: Mike Aubury (#13)
Re: request for sql3 compliance for the update command

After a long battle with technology,mike@aubit.com (Mike Aubury), an earthling, wrote:

On Wednesday 19 February 2003 8:18 pm, Dave Cramer wrote:

I have a customer with a rather large application which uses this
syntax, because they were using informix. There is also a rather
interesting 4GL project called aubit which is on sourceforge. They would
also like to see this supported for the same reasons.

Hey - I was going to say that...

For the curious:
Quick URL - http://aubit4gl.sourceforge.net/

Its a 'clone' of the Informix 4GL tool, a nice 'clean' language
specifically designed for writing database applications, with both
curses & GTK, support for multiple database types and a bunch of
other things...

We're about to release version 0.30 - and I was going to wait until
then....

I tried it out a while back; couldn't get it to compile, probably due
to there being a bit too much 'bleeding' to the 'bleeding edge.'

It looks as though it could be pretty interesting, if PG support
matures (which can certainly be a two way street!).

How's the cross-platform support? Aubit would be an easier sell, to
be sure, if it is readily deployable on Those Other Platforms, too...
--
(concatenate 'string "cbbrowne" "@acm.org")
http://www.ntlug.org/~cbbrowne/multiplexor.html
"MSDOS didn't get as bad as it is overnight -- it took over ten years
of careful development." -- <dmeggins@aix1.uottawa.ca>

#18Dave Cramer
pg@fastcrypt.com
In reply to: Justin Clift (#15)
Re: request for sql3 compliance for the update command

Justin,

This is certainly the case here. I think IBM is deprecating informix,
and many informix users are being forced to make a change, and they are
seriously considering postgres as an alternative.

It behooves us to look at aubit http://aubit4gl.sourceforge.net/ before
making this decision as well.

I believe the aubit project has the potential to move postgres forward
considerably as well.

Dave

On Wed, 2003-02-19 at 21:08, Justin Clift wrote:

Tom Lane wrote:

Dave Cramer <dave@fastcrypt.com> writes:

Ok, if a patch were submitted to the parser to allow the syntax in
question would it be considered?

I would vote against it ... but that's only one vote.

As a thought, will it add significant maintenance penalties or be
detrimental?

There seem to be quite a lot of Informix people moving to PostgreSQL
these days, moreso than Oracle shops. Might have been brought on by
IBM's purchase of Informix.

Wondering if this one change be a significant improvement in regards to
making it easier to migrate, or just a minor thing?

Regards and best wishes,

Justin Clift

regards, tom lane

--
Dave Cramer <dave@fastcrypt.com>
Cramer Consulting

#19Gavin Sherry
swm@linuxworld.com.au
In reply to: Dave Cramer (#18)
Re: request for sql3 compliance for the update command

On 19 Feb 2003, Dave Cramer wrote:

Justin,

This is certainly the case here. I think IBM is deprecating informix,
and many informix users are being forced to make a change, and they are
seriously considering postgres as an alternative.

Do you have any evidence that they are evaluating it?

Gavin

#20Jordan Henderson
jordan_henders@yahoo.com
In reply to: Peter Eisentraut (#4)
Re: request for sql3 compliance for the update command

Dave, Justin,

I have several Informix clients who will be moving to a Postgresql/Aubit4gl
solution at some point. The Informix line is, for them, a dead end. One
way or another the backend will become Postgresql. Because of the number of
SQL statements, I would encourage support where possible and reasonable.

Jordan

----- Original Message -----
From: "Dave Cramer" <dave@fastcrypt.com>
To: "Justin Clift" <justin@postgresql.org>
Cc: "Tom Lane" <tgl@sss.pgh.pa.us>; "Peter Eisentraut" <peter_e@gmx.net>;
"Pgsql Hackers" <pgsql-hackers@postgresql.org>
Sent: Wednesday, February 19, 2003 10:18 PM
Subject: Re: [HACKERS] request for sql3 compliance for the update command

Show quoted text

Justin,

This is certainly the case here. I think IBM is deprecating informix,
and many informix users are being forced to make a change, and they are
seriously considering postgres as an alternative.

It behooves us to look at aubit http://aubit4gl.sourceforge.net/ before
making this decision as well.

I believe the aubit project has the potential to move postgres forward
considerably as well.

Dave

On Wed, 2003-02-19 at 21:08, Justin Clift wrote:

Tom Lane wrote:

Dave Cramer <dave@fastcrypt.com> writes:

Ok, if a patch were submitted to the parser to allow the syntax in
question would it be considered?

I would vote against it ... but that's only one vote.

As a thought, will it add significant maintenance penalties or be
detrimental?

There seem to be quite a lot of Informix people moving to PostgreSQL
these days, moreso than Oracle shops. Might have been brought on by
IBM's purchase of Informix.

Wondering if this one change be a significant improvement in regards to
making it easier to migrate, or just a minor thing?

Regards and best wishes,

Justin Clift

regards, tom lane

--
Dave Cramer <dave@fastcrypt.com>
Cramer Consulting

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

#21Dave Cramer
pg@fastcrypt.com
In reply to: Gavin Sherry (#19)
#22Tom Lane
tgl@sss.pgh.pa.us
In reply to: Justin Clift (#15)
#23Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#22)
#24Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#12)
#25Gavin Sherry
swm@linuxworld.com.au
In reply to: Dave Cramer (#21)
#26Christopher Kings-Lynne
chriskl@familyhealth.com.au
In reply to: Bruce Momjian (#12)
#27Bruce Momjian
bruce@momjian.us
In reply to: Christopher Kings-Lynne (#26)
#28Michael Meskes
meskes@postgresql.org
In reply to: Peter Eisentraut (#4)
#29Michael Meskes
meskes@postgresql.org
In reply to: Tom Lane (#7)
#30Hannu Krosing
hannu@tm.ee
In reply to: Tom Lane (#9)
#31Hannu Krosing
hannu@tm.ee
In reply to: Bruce Momjian (#23)
#32Hannu Krosing
hannu@tm.ee
In reply to: Bruce Momjian (#23)
#33Tom Lane
tgl@sss.pgh.pa.us
In reply to: Hannu Krosing (#30)
#34Tom Lane
tgl@sss.pgh.pa.us
In reply to: Hannu Krosing (#31)
#35Dave Page
dpage@pgadmin.org
In reply to: Tom Lane (#34)
#36scott.marlowe
scott.marlowe@ihs.com
In reply to: Tom Lane (#33)
#37Michael Meskes
meskes@postgresql.org
In reply to: Tom Lane (#33)
#38Dave Cramer
pg@fastcrypt.com
In reply to: scott.marlowe (#36)
#39Dave Cramer
pg@fastcrypt.com
In reply to: scott.marlowe (#36)
#40scott.marlowe
scott.marlowe@ihs.com
In reply to: Dave Cramer (#38)
#41Mike Aubury
mike@aubit.com
In reply to: Dave Page (#35)
#42scott.marlowe
scott.marlowe@ihs.com
In reply to: Dave Cramer (#39)
#43Josh Berkus
josh@agliodbs.com
In reply to: scott.marlowe (#42)
#44Kevin Brown
kevin@sysexperts.com
In reply to: Tom Lane (#34)
#45Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#34)
#46Dave Page
dpage@pgadmin.org
In reply to: Bruce Momjian (#45)
#47scott.marlowe
scott.marlowe@ihs.com
In reply to: Kevin Brown (#44)
#48Dave Cramer
pg@fastcrypt.com
In reply to: Dave Cramer (#38)
#49Bruce Momjian
bruce@momjian.us
In reply to: Dave Cramer (#48)
#50Bruce Momjian
bruce@momjian.us
In reply to: Bruce Momjian (#49)
#51Hannu Krosing
hannu@tm.ee
In reply to: Bruce Momjian (#50)
#52Bruce Momjian
bruce@momjian.us
In reply to: Hannu Krosing (#51)
#53Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#52)
#54Hannu Krosing
hannu@tm.ee
In reply to: Tom Lane (#53)
#55Bruce Momjian
bruce@momjian.us
In reply to: Hannu Krosing (#54)
#56Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#34)
#57Bruce Momjian
bruce@momjian.us
In reply to: Bruce Momjian (#56)