Skip to Content.
Sympa Menu

freetds - Re: [freetds] FreeTDS creating all fields as not null

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Eloy Lafuente <stronk7 AT moodle.org>
  • To: Constantin Vasilyev <vasilyev AT ncbi.nlm.nih.gov>
  • Cc: freetds AT lists.ibiblio.org
  • Subject: Re: [freetds] FreeTDS creating all fields as not null
  • Date: Thu, 21 Sep 2006 21:00:11 +0200

Hi Constantin,

I'm not specifying the null clause (because it's supposed that, if you don't specify it, the field is NULLable). If NULL is specified (like in your example, everything seems to work fine).

But this sentence:

create table foo(id int)

seems to work properly from the tsql command line interpreter with the field being created as nullable
but, if I execute the same sql statement from PHP (using the FreeTDS PHP module), I got the table created with the field
set to NOT NULL.

The exact PHP code I'm using is:

if (!$res = mssql_connect(.....)) {
error ('bad conn');
}
mssql_query('create table foo(id int)', $res);

Having the profile enabled at server side I see how the sentence arrives (batch starting) and how it's completed. The sentence is correct but the generated table has the id
field set to NOT NULL. and this only happens from PHP.

Does this clarify anything? Ciao, Eloy :-)

> Constantin Vasilyev escribió:
That doesn't seem to be the case for me.

[106] MSSQL0.testdb.1> create table foo(id int null);
[107] MSSQL0.testdb.1> sp_help foo; -mvert | grep Nullable
Nullable: yes
[108] MSSQL0.testdb.1> select @@version;
Microsoft SQL Server 2005 - 9.00.2047.00 (Intel X86)
Apr 14 2006 01:12:25
Copyright (c) 1988-2005 Microsoft Corporation
Standard Edition on Windows NT 5.2 (Build 3790: Service Pack 1)|

Would you please provide an example of what you're doing (you may catch
what's actually comes to the server using Profiler).

Constantin Vasilyev

On Thu, 21 Sep 2006, Eloy Lafuente wrote:

Hi,

I'm using FreeTDS to handle one MSSQL 2005 server with PHP
running the "replacement" php_mssql extension with this
freetds.conf file:

[global]
host = 10.0.2.2
port = 1433
client charset = UTF-8
tds version = 7.0

Everytime I create one table having NULL fields, they become
NOT NULL in the target DB.

Curiously, executing the same CREATE TABLE statement from
the "tsql" command line interface, the table is created
properly (with NULL fields being NULL).

Any idea about how this could be solved?

TIA and ciao, Eloy :-)

_______________________________________________
FreeTDS mailing list
FreeTDS AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds







Archive powered by MHonArc 2.6.24.

Top of Page