On Wed, Nov 20, 2002 at 07:09:34PM -0800, David Wheeler wrote: > > PostgreSQL folks, can the same statement return a different number of > fields on different executes? I'm guessing yes for something like this, > though: > > CREATE TABLE foo ( bar int, bat, text); > > SELECT * FROM foo; -- Returns two fields. > > ALTER TABLE foo ADD COLUMN fat int; > > SELECT * FROM foo; -- Returns three fields.
I suspect there are quite a few drivers that wouldn't do the right thing in that situation (schema change between two executes of a prepared statement). You could either arrange the code to ignore an extra column (on the right), or make it re-describe if the column count changes. But they'll always be ways to cause problems - such as changing the type of a column. Increasing paranoia yields decreasing performance. I doubt it's worth worrying about. In general people should avoid "select *" if there's a risk that the schema will change. Tim.
