Subject Re: [firebird-support] * - ?
Author Ann W. Harrison
Ivan Prenosil wrote:
>
> When application reads selected data, there is a secret (:-) structure
> called xsqlda, that among pointers to data itself contains description of types
> of data and fieldnames!

You're right that most interface components are built to avoid problems
with select *. The real basis of my argument is that you shouldn't send
stuff over the wire unless you want it, meaning that it's a value that
your care about in your application. The fact that the interface
component avoids access violations and invalid assignments is nice, but
asking for exactly what you want is nicer.
>
> If somebody drops the field, than it is dropped, and you do not retrieve
> its data regardless your using "select deletedfield, ..." or "select *" query.

You get different results, especially if you're using the API. In the
first case, using the API, your query gets a compilation time error.
Not nice, but an immediate and well directed indication of the nature of
the problem.

>
> Here is another exampe how using "*" can avoid troubles with inconsitent
> database - I have several views that are used to restrict access
> to just subsets of rows...

OK, I'll grant you that those views are easier to maintain with "select *.

> The fact that some feature can be misused is not enugh
> to say that it should "never be used ...", if that feature
> can be both safe and useful when used correctly.
> Otherwise, I would recommend to never use pointers
> (you can forget to initialize them, or free the memory, ...),

Not at all the same. The ability to add, drop, and rearrange fields is
a strength of relational databases. Compilers don't casually rearrange
things so your pointer is sometimes a pointer to char, sometimes a
pointer to char* and sometimes a pointer to a function. If they did,
I'd be very reluctant to use an untyped, unnamed pointer.

>
> Strangely, nobody mentioned "Insert Into Table Values (...)",
> i.e. without list of fieldnames, which, unlike "select *", do not pass
> names of fields in xsqlda (why?), so there I would fully agree with
> "should never be used outside casual, hand-typed, one time inserts".

There we are in strong agreement.


Regards,


Ann