Skip site navigation (1) Skip section navigation (2)

Re: [HACKERS] Re: [INTERFACES] retrieving varchar size

From: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
To: tgl(at)sss(dot)pgh(dot)pa(dot)us (Tom Lane)
Cc: byronn(at)insightdist(dot)com, pgsql-hackers(at)postgreSQL(dot)org, pgsql-interfaces(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Re: [INTERFACES] retrieving varchar size
Date: 1998-04-26 03:26:15
Message-ID: 199804260326.XAA18519@candle.pha.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-interfaces
> 
> Byron Nikolaidis <byronn(at)insightdist(dot)com> writes:
> > Yes, it rings a bell alright, When you execute a multiple query
> > (denoted by semicolans) like "set geqo to 'off'; show datestyle;
> > select * from table", you get that multiple returns and MUST read
> > until you get the 'I'.  If you don't, your screwed the next time you
> > try and read anything cause all that stuff is still in the pipe.
> 
> That seems pretty bogus.  What happens if you do
> 	select * from table1; select * from table2
> ?  The way the code in libpq looks, I think the response from the
> first select would get lost entirely (probably even cause a memory
> leak).  It's not set up to handle receipt of more than one command
> response in any clean fashion.  We'd need to revise the application
> API to make that work right.

> 
> Playing around with psql, it seems that you can't actually get psql
> to submit a multi-command line as a single query; it seems to break
> it up into separate queries.  Which is what libpq can cope with.

Yep, you figured it out.  (See earlier posting.)

I have now thought about the problem some more, and I think an even
better solution would be that if the backend receives multiple commands
in a single query, it just returns the first or last result.  There is
no mechanism in libpq to send a query and get multiple results back, so
why not just return one result.

No need to cound the number of queries sent, and no reason to send empty
queries to the backend looking for the last result.

If you want me to do this for the backend, let me know and I will do it.

First or last result?  What do we return now?

> 
> I think we should either forbid multiple commands per PQexec call,
> or fix libpq to handle them properly (and hence be able to return
> a series of PGresults, not just one).
> 
> > Question though, I didnt think my request would have caused a major
> > protocol change.  I though that the '-1' would simply be replaced by
> > the correct size?
> 
> I assumed we'd want to add the restypmod as a new field in PGresult
> and in the protocol.  But I'm just a newbie.

restypmod may not be available at the time of returning the result, but
the TupleDesc is, and it has the proper atttypmod.

-- 
Bruce Momjian                          |  830 Blythe Avenue
maillist(at)candle(dot)pha(dot)pa(dot)us              |  Drexel Hill, Pennsylvania 19026
  +  If your life is a hard drive,     |  (610) 353-9879(w)
  +  Christ can be your backup.        |  (610) 853-3000(h)

In response to

pgsql-hackers by date

Next:From: Bruce MomjianDate: 1998-04-26 04:01:24
Subject: PG-version
Previous:From: Bruce MomjianDate: 1998-04-26 02:30:25
Subject: Re: [HACKERS] Re: [INTERFACES] retrieving varchar size

pgsql-interfaces by date

Next:From: Peter T MountDate: 1998-04-26 10:25:23
Subject: Re: [HACKERS] Re: [INTERFACES] retrieving varchar size
Previous:From: Bruce MomjianDate: 1998-04-26 02:30:25
Subject: Re: [HACKERS] Re: [INTERFACES] retrieving varchar size

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group