Re: [HACKERS] InitPostgres and flatfiles question

2007-01-10 Thread Bruce Momjian
Tom Lane wrote: > Markus Schiltknecht <[EMAIL PROTECTED]> writes: > > I've just found the stumbling block: the -c option of psql wraps all in > > a transaction, as man psql says: > > ... > > Thank you for clarification, I wouldn't have expected that (especially > > because CREATE DATABASE itself

Re: [HACKERS] InitPostgres and flatfiles question

2007-01-06 Thread Tom Lane
Bruce Momjian <[EMAIL PROTECTED]> writes: > We aren't going to disable that --- we are considering disabling the > backend from treating it as a single transaction. Or even more specifically, making sure that that only happens if you explicitly put begin/commit into the -c string. One thing I thi

Re: [HACKERS] InitPostgres and flatfiles question

2007-01-06 Thread Tom Lane
Bruce Momjian <[EMAIL PROTECTED]> writes: > Do we need a TODO for this? Well, if we *don't* change the backend to disallow multi statements per PQexec, then we'd probably better do something about this. If we do make that change then it's not a problem anymore. >> Hm, that's an interesting point

Re: [HACKERS] InitPostgres and flatfiles question

2007-01-06 Thread Bruce Momjian
elein wrote: > On Fri, Jan 05, 2007 at 08:45:51PM -0500, Tom Lane wrote: > > Ron Mayer <[EMAIL PROTECTED]> writes: > > > Tom Lane wrote: > > >> Bruce Momjian <[EMAIL PROTECTED]> writes: > > >>> What value is allowing multiple queies via PQexec() > > >> > > >> The only argument I can think of is th

Re: [HACKERS] InitPostgres and flatfiles question

2007-01-06 Thread elein
On Fri, Jan 05, 2007 at 08:45:51PM -0500, Tom Lane wrote: > Ron Mayer <[EMAIL PROTECTED]> writes: > > Tom Lane wrote: > >> Bruce Momjian <[EMAIL PROTECTED]> writes: > >>> What value is allowing multiple queies via PQexec() > >> > >> The only argument I can think of is that it allows applications t

Re: [HACKERS] InitPostgres and flatfiles question

2007-01-06 Thread Bruce Momjian
Do we need a TODO for this? --- Tom Lane wrote: > Markus Schiltknecht <[EMAIL PROTECTED]> writes: > > I've just found the stumbling block: the -c option of psql wraps all in > > a transaction, as man psql says: > > ... > >

Re: [HACKERS] InitPostgres and flatfiles question

2007-01-06 Thread Bruce Momjian
Ron Mayer wrote: > Tom Lane wrote: > > Bruce Momjian <[EMAIL PROTECTED]> writes: > >> What value is allowing multiple queies via PQexec() > > > > The only argument I can think of is that it allows applications to be > > sloppy about parsing a SQL script into individual commands before they > > sen

Re: [HACKERS] InitPostgres and flatfiles question

2007-01-05 Thread Andrew Dunstan
>> Tom Lane wrote: >>> Bruce Momjian <[EMAIL PROTECTED]> writes: What value is allowing multiple queies via PQexec() >>> >>> The only argument I can think of is that it allows applications to be >>> sloppy about parsing a SQL script into individual commands before they >>> send it. (I think

Re: [HACKERS] InitPostgres and flatfiles question

2007-01-05 Thread Jim Nasby
On Jan 4, 2007, at 11:30 PM, Bruce Momjian wrote: No, psql isn't the point: we can certainly make its behavior match the backend's. What I'm wondering about is the effect on random PG-using applications: should we forbid them from sending multiple SQL commands per PQexec (or equivalent in o

Re: [HACKERS] InitPostgres and flatfiles question

2007-01-05 Thread Tom Lane
Ron Mayer <[EMAIL PROTECTED]> writes: > Tom Lane wrote: >> Bruce Momjian <[EMAIL PROTECTED]> writes: >>> What value is allowing multiple queies via PQexec() >> >> The only argument I can think of is that it allows applications to be >> sloppy about parsing a SQL script into individual commands bef

Re: [HACKERS] InitPostgres and flatfiles question

2007-01-05 Thread Ron Mayer
Tom Lane wrote: > Bruce Momjian <[EMAIL PROTECTED]> writes: >> What value is allowing multiple queies via PQexec() > > The only argument I can think of is that it allows applications to be > sloppy about parsing a SQL script into individual commands before they > send it. (I think initdb may be g

Re: [HACKERS] InitPostgres and flatfiles question

2007-01-04 Thread Bruce Momjian
Tom Lane wrote: > Bruce Momjian <[EMAIL PROTECTED]> writes: > > Tom Lane wrote: > >> The only argument I can think of is that it allows applications to be > >> sloppy about parsing a SQL script into individual commands before they > >> send it. (I think initdb may be guilty of exactly that BTW...)

Re: [HACKERS] InitPostgres and flatfiles question

2007-01-04 Thread Tom Lane
Bruce Momjian <[EMAIL PROTECTED]> writes: > Tom Lane wrote: >> The only argument I can think of is that it allows applications to be >> sloppy about parsing a SQL script into individual commands before they >> send it. (I think initdb may be guilty of exactly that BTW...) At the >> same time you

Re: [HACKERS] InitPostgres and flatfiles question

2007-01-04 Thread Bruce Momjian
Tom Lane wrote: > Bruce Momjian <[EMAIL PROTECTED]> writes: > > What value is allowing multiple queries via PQexec() > > The only argument I can think of is that it allows applications to be > sloppy about parsing a SQL script into individual commands before they > send it. (I think initdb may be

Re: [HACKERS] InitPostgres and flatfiles question

2007-01-04 Thread Tom Lane
Bruce Momjian <[EMAIL PROTECTED]> writes: > What value is allowing multiple queies via PQexec() The only argument I can think of is that it allows applications to be sloppy about parsing a SQL script into individual commands before they send it. (I think initdb may be guilty of exactly that BTW..

Re: [HACKERS] InitPostgres and flatfiles question

2007-01-04 Thread Bruce Momjian
Tom Lane wrote: > Bruce Momjian <[EMAIL PROTECTED]> writes: > > Tom Lane wrote: > >> Markus Schiltknecht <[EMAIL PROTECTED]> writes: > >>> Is there a good reason to not let psql -c behave exactly like psql from > >>> STDIN? > >> > >> Backwards compatibility, mostly --- there seems to be a conside

Re: [HACKERS] InitPostgres and flatfiles question

2007-01-04 Thread Tom Lane
Bruce Momjian <[EMAIL PROTECTED]> writes: > Tom Lane wrote: >> Markus Schiltknecht <[EMAIL PROTECTED]> writes: >>> Is there a good reason to not let psql -c behave exactly like psql from >>> STDIN? >> >> Backwards compatibility, mostly --- there seems to be a considerable >> risk of subtly breaki

Re: [HACKERS] InitPostgres and flatfiles question

2007-01-04 Thread Bruce Momjian
Tom Lane wrote: > Markus Schiltknecht <[EMAIL PROTECTED]> writes: > > Tom Lane wrote: > >> Hm, that's an interesting point. psql's -c just shoves its whole > >> argument string at the backend in one PQexec(), instead of dividing > >> at semicolons as psql does with normal input. > > > Is there a

Re: [HACKERS] InitPostgres and flatfiles question

2007-01-04 Thread Tom Lane
Markus Schiltknecht <[EMAIL PROTECTED]> writes: > Tom Lane wrote: >> Hm, that's an interesting point. psql's -c just shoves its whole >> argument string at the backend in one PQexec(), instead of dividing >> at semicolons as psql does with normal input. > Is there a good reason to not let psql -c

Re: [HACKERS] InitPostgres and flatfiles question

2007-01-04 Thread Markus Schiltknecht
Hi, Tom Lane wrote: Hm, that's an interesting point. psql's -c just shoves its whole argument string at the backend in one PQexec(), instead of dividing at semicolons as psql does with normal input. And so it winds up as a single transaction because postgres.c doesn't force a transaction commi

Re: [HACKERS] InitPostgres and flatfiles question

2007-01-04 Thread Mario Weilguni
Am Donnerstag, 4. Januar 2007 16:36 schrieb Tom Lane: > Markus Schiltknecht <[EMAIL PROTECTED]> writes: > Hm, that's an interesting point. psql's -c just shoves its whole > argument string at the backend in one PQexec(), instead of dividing > at semicolons as psql does with normal input. And so i

Re: [HACKERS] InitPostgres and flatfiles question

2007-01-04 Thread Tom Lane
Markus Schiltknecht <[EMAIL PROTECTED]> writes: > I've just found the stumbling block: the -c option of psql wraps all in > a transaction, as man psql says: > ... > Thank you for clarification, I wouldn't have expected that (especially > because CREATE DATABASE itself says, it cannot be run insid

Re: [HACKERS] InitPostgres and flatfiles question

2007-01-04 Thread Markus Schiltknecht
Hi, Tom Lane wrote: It should happen automatically at commit of the CREATE DATABASE ... and you'd not be able to see the pg_database row before that anyway. So I'm not clear on what you're worried about. I've just found the stumbling block: the -c option of psql wraps all in a transaction, a

Re: [HACKERS] InitPostgres and flatfiles question

2007-01-03 Thread Markus Schiltknecht
Tom Lane wrote: It should happen automatically at commit of the CREATE DATABASE ... and you'd not be able to see the pg_database row before that anyway. So I'm not clear on what you're worried about. Okay, thanks. I'll have to investigate on why exactly I still get the error, then. That's unc

Re: [HACKERS] InitPostgres and flatfiles question

2007-01-03 Thread Tom Lane
Markus Schiltknecht <[EMAIL PROTECTED]> writes: > Most probably I better go another way, than fiddling with postgres > startup internals. Is there a way to be sure the flatfile has been > written to disk after a CREATE DATABASE? I would like to ensure I can > connect to a newly created database.

Re: [HACKERS] InitPostgres and flatfiles question

2007-01-03 Thread Markus Schiltknecht
Hello Tom, Tom Lane wrote: In what PG version? Postgres-R 8.3devel ;-) Because the postmaster doesn't have direct database access. If it did, any corruption of shared memory would risk crashing the postmaster along with the backends. Understood, thanks. Most probably I better go another

Re: [HACKERS] InitPostgres and flatfiles question

2007-01-03 Thread Tom Lane
Markus Schiltknecht <[EMAIL PROTECTED]> writes: > I've just run into a race condition with creating a database and > connecting to it immediately afterwards. I'm getting a "database %s not > found" error just after the first flatfiles check in InitPostgres(). In what PG version? > What that Fin

[HACKERS] InitPostgres and flatfiles question

2007-01-03 Thread Markus Schiltknecht
Hi, I've just run into a race condition with creating a database and connecting to it immediately afterwards. I'm getting a "database %s not found" error just after the first flatfiles check in InitPostgres(). What that FindMyDatabase() there does, besides checking if the database exists, is