[freetds] idea: eliminate port/instance

Frediano Ziglio freddy77 at gmail.com
Tue Apr 7 03:11:18 EDT 2009


2009/4/7 James K. Lowden <jklowden at freetds.org>:
> Frediano Ziglio wrote:
>> 2009/4/4 James K. Lowden <jklowden at freetds.org>:
>> > 1. If port is numeric, it's a port.
>> > 2. If port is non-numeric, try looking up the port with
>> > getservbyname(3).
>> >
>> > 3. If getservbyname(3) fails, look up the port using the UDP instance
>> > protocol.
>>
>> I personally don't like this way cause you can't specify a named
>> instance if this instance correspond to a service entry.
>
> Well, I doubt that's a very likely conflict.  But I guess you're right.
> We'll continue to ignore /etc/services.
>
>> Perhaps it would be useful to always return error if port and instance
>> are both specified.
>
> Yeah, but how?  tds_read_config_info() returns TDSCONNECTION*.  We'd have
> to stuff an error code in the structure.
>

I think is sufficient to test if port and instance_name is set in
login.c, just before following lines:

        if (!IS_TDS50(tds) && !tds_dstr_isempty(&connection->instance_name))
                connection->port =
tds7_get_instance_port(tds_dstr_cstr(&connection->ip_addr),
tds_dstr_cstr(&connection->instance_name));

> OK, maybe not fprintf(stderr...).  Maybe tdserror() instead.  At least
> tsql would print the message, as would any other properly written
> application.  We'll have to invent a few new error codes, though.
>

Mmm... I personally though of removing TDS_FAIL and replace with
errrors. I like linux kernel way where:
- >0 means success and result
- 0 means no error
- <0 means error
(something like tds_convert)

freddy77



More information about the FreeTDS mailing list