php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35115 MSSQL query fails when retrieving date field
Submitted: 2005-11-05 19:19 UTC Modified: 2005-11-06 18:03 UTC
From: freetds228 at lewenberg dot com Assigned: fmk (profile)
Status: Closed Package: MSSQL related
PHP Version: 5CVS, 4CVS (2005-11-06) (snap) OS: RedHat Enterprise Linux 3
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: freetds228 at lewenberg dot com
New email:
PHP Version: OS:

 

 [2005-11-05 19:19 UTC] freetds228 at lewenberg dot com
Description:
------------
When running a simple SELECT select query against an MS SQL server, if the result set has a field with a non-NULL date, we are getting the following error (with --enable-debug flag on): 

[Sat Nov  5 11:26:07 2005]  Script:  '/www-s/testfreetds.php'
---------------------------------------
/root/tmp/php-4.4.1/ext/mssql/php_mssql.c(191) : Block 0x093CA2E0 status:
/root/tmp/php-4.4.1/Zend/zend_variables.c(44) : Actual location 
(location was relayed)
Beginning:      OK (allocated on 
/root/tmp/php-4.4.1/ext/mssql/php_mssql.c:904, 19 bytes)
       End:      Overflown (magic=0x31383A34 instead of 0x2A8FCC84)
                 At least 4 bytes overflown
---------------------------------------

The query returns only a single row and field (a date). Note that Perl running the same query using the same freetds libraries has no errors.


We have compiled 4.4.1 against freetds 0.63 using the --with-mssql option. 

Reproduce code:
---------------
$db = mssql_connect('mssqlserver', 'user', 'secret') ;

$rs = mssql_query('SELECT DateLastModified FROM Table WHERE rid = 1', $db) ;



Expected result:
----------------
The date should be accessible in the result set. 

Actual result:
--------------
[Sat Nov  5 11:26:07 2005]  Script:  '/www-s/testfreetds.php'
---------------------------------------
/root/tmp/php-4.4.1/ext/mssql/php_mssql.c(191) : Block 0x093CA2E0 status:
/root/tmp/php-4.4.1/Zend/zend_variables.c(44) : Actual location 
(location was relayed)
Beginning:      OK (allocated on 
/root/tmp/php-4.4.1/ext/mssql/php_mssql.c:904, 19 bytes)
       End:      Overflown (magic=0x31383A34 instead of 0x2A8FCC84)
                 At least 4 bytes overflown
---------------------------------------

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-11-05 20:01 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip


 [2005-11-06 03:03 UTC] freetds228 at lewenberg dot com
I tried to compile the snapshot but got this error: 

/root/tmp/php5-200511052330/ext/mssql/php_mssql.c:2312:2: #endif without #if
make: *** [ext/mssql/php_mssql.lo] Error 1

I noticed I got this when I tried to compile the stable version of php5, also.
 [2005-11-06 03:59 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip

I fixed the compile error, so please try again.
 [2005-11-06 15:09 UTC] freetds228 at lewenberg dot com
I downloaded the newest version of the snapshot and it compiled, but I am still getting this error: 

[Sun Nov  6 08:07:02 2005]  Script:  'testfreetds.php'
---------------------------------------
/root/tmp/php5-200511061330/Zend/zend_variables.h(35) : Block 0x09CC6D78 status:
/root/tmp/php5-200511061330/Zend/zend_variables.c(36) : Actual location (locatio
n was relayed)
Beginning:      OK (allocated on /root/tmp/php5-200511061330/ext/mssql/php_mssql
.c:907, 19 bytes)
      End:      Overflown (magic=0x2A8FCC00 instead of 0x2A8FCC84)
                1 byte(s) overflown
---------------------------------------

Maybe it is a problem with some low-level library on my system. Is there a way to tell which system call is dying?
 [2005-11-06 15:42 UTC] sniper@php.net
Frank, check this out please.
 [2005-11-06 15:54 UTC] freetds228 at lewenberg dot com
I changed the number of bytes to be allocated for some of the column types in line 889 in ext/mssql/php_mssql.c at the suggestion of a user on the freetds list (just to experiment); see below for the change. 

This made the problem go away. However, this begs the question: why are the memory amounts normally specified (10 and 14) failing to work? Maybe there is some library that is being called having to do with dates that is corrupted.


 switch (column_type) {
                                                case SQLDATETIM4 :
                                                        res_length += 140;
                                                        break;
                                                case SQLDATETIME :
                                                        res_length += 100;
                                                        break;
                                                case SQLMONEY :
                                                case SQLMONEY4 :
                                                case SQLMONEYN :
                                                case SQLDECIMAL :
                                                case SQLNUMERIC :
 [2005-11-06 18:03 UTC] freetds228 at lewenberg dot com
It looks like the problem stemmed from an incomplete install of freetds on our system from a month ago. I guess a new php install triggered the problem, but things seem to be back to normal.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 08:01:30 2024 UTC