vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Alvaro Herrera wrote: > Sent: Wednesday, May 11, 2005 10:46 PM > To: John Hansen > Cc: Bruce Momjian; Neil Conway; Dennis Bjorklund; > pgsql-patches@postgresql.org > Subject: Re: [PATCHES] lastval() > > On Wed, May 11, 2005 at 02:08:16PM +1000, John Hansen wrote: > > > Take for instance this (overly simplified) function used in > a program > > that builds the query strings dynamically: > > > > int64 runquery(char *query) { > > PQexec(query); > > result = Pqexec("SELECT lastval()"); > > return result; > > } > > > > The program expects this function to return the 'id' that was > > inserted, or 0 if the table didn't contain a sequence or it > wasn't an insert. > > > > Rewriting that would take a considerable effort. > > Actually, having it throw an error would be helpful, because > then you can find in the application which calls should be > replaced by the generic runquery() that has to return nothing > versus the one that has to return a sequence value. So > porting is a little more involved but more useful in the end. Indeed, but my point was that often it is going in the too hard basket. Not that I disagree, but how do you predetermine which queries would throw an error if they're built dynamically? > > -- > Alvaro Herrera (<alvherre[a]dcc.uchile.cl>) > > ---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match |
| ||||
| On Thu, May 12, 2005 at 04:58:54AM +1000, John Hansen wrote: > Alvaro Herrera wrote: > > Actually, having it throw an error would be helpful, because > > then you can find in the application which calls should be > > replaced by the generic runquery() that has to return nothing > > versus the one that has to return a sequence value. So > > porting is a little more involved but more useful in the end. > > Indeed, but my point was that often it is going in the too hard basket. > Not that I disagree, but how do you predetermine which queries would > throw an error if they're built dynamically? Hmm, if your app can build any of them at an arbitrary point, you have a rather serious problem, I'd say. The apps I've seen build either kind at each call site of such runquery(). -- Alvaro Herrera (<alvherre[a]surnet.cl>) "La fuerza no está en los medios físicos sino que reside en una voluntad indomable" (Gandhi) ---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq |
| Thread Tools | |
| Display Modes | |
|
|