View Issue Details

IDProjectCategoryView StatusLast Update
0024635FPCDatabasepublic2014-03-04 16:58
ReporterLudo BrandsAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version2.7.1Product Build24588 
Target Version3.0.0Fixed in Version2.6.4 
Summary0024635: [Patch]Corrected dbsetlname consts for FreeTDS. Added ApplicationName parameter to mssqlconn.
DescriptionDBSETAPP is defined wrongly for Freetds. Other constants for dbsetlname don't exist in FreeTDS or are missing.
Added "ApplicationParameter" to the TMSSQLConnection parameters. This is used to specify the client application name in the SQL Server connection.
TagsNo tags attached.
Fixed in Revision25111
FPCOldBugId0
FPCTarget
Attached Files
  • mssql.diff (2,561 bytes)
    Index: packages/dblib/src/dblib.pp
    ===================================================================
    --- packages/dblib/src/dblib.pp	(revision 24588)
    +++ packages/dblib/src/dblib.pp	(working copy)
    @@ -69,19 +69,32 @@
       DBTDS_72     = 10; // Microsoft SQL Server 2005
       DBTDS_73     = 11; // Microsoft SQL Server 2008
     
    -  //from sqlfront.h:
    +  //from sqlfront.h ,   sybdb.h for freetds
       DBSETHOST=1;
       DBSETUSER=2;
       DBSETPWD=3;
    -  DBSETAPP=4;
    +  DBSETAPP={$IFDEF freetds}5{$ELSE}4{$ENDIF};
    +  {$IFDEF freetds}
    +  DBSETHID=     4;
    +  DBSETBCP=	6;
    +  DBSETNATLANG=	7;
    +  DBSETNOSHORT=	8;
    +  DBSETHIER=	9;
    +  DBSETCHARSET=	10;
    +  DBSETPACKET=	11;
    +  DBSETENCRYPT=	12;
    +  DBSETLABELED=	13;
    +  DBSETDBNAME=	14;
    +   {$ELSE}
       DBSETID=5;
       DBSETLANG=6;
       DBSETSECURE=7;
    +  DBSET_LOGINTIME=10;
    +  DBSETFALLBACK=12;
    +  {$ENDIF}
       //These two are defined by Microsoft for dbsetlversion():
       DBVER42={$IFDEF freetds}DBVERSION_42{$ELSE}8{$ENDIF};
       DBVER60={$IFDEF freetds}DBVERSION_71{$ELSE}9{$ENDIF};
    -  DBSET_LOGINTIME=10;
    -  DBSETFALLBACK=12;
       //dboptions:
       DBNOAUTOFREE = {$IFDEF freetds}15{$ELSE}8{$ENDIF};
       DBTEXTLIMIT  = {$IFDEF freetds}7{$ELSE}4{$ENDIF};
    Index: packages/fcl-db/src/sqldb/mssql/mssqlconn.pp
    ===================================================================
    --- packages/fcl-db/src/sqldb/mssql/mssqlconn.pp	(revision 24588)
    +++ packages/fcl-db/src/sqldb/mssql/mssqlconn.pp	(working copy)
    @@ -30,7 +30,8 @@
           CharSet - if you use Microsoft DB-Lib and set to 'UTF-8' then char/varchar fields will be UTF8Encoded/Decoded
                     if you use FreeTDS DB-Lib then you must compile with iconv support (requires libiconv2.dll) or cast char/varchar to nchar/nvarchar in SELECTs
           Params - "AutoCommit=true" - if you don't want explicitly commit/rollback transactions
    -               "TextSize=16777216 - set maximum size of text/image data returned
    +               "TextSize=16777216" - set maximum size of text/image data returned
    +               "ApplicationName=YourAppName" Set the app name for the connection. MSSQL 2000 and higher only
     }
     unit mssqlconn;
     
    @@ -193,6 +194,7 @@
       SBeginTransaction = 'BEGIN TRANSACTION';
       SAutoCommit = 'AUTOCOMMIT';
       STextSize   = 'TEXTSIZE';
    +  SAppName   = 'APPLICATIONNAME';
     
     
     var
    @@ -428,6 +430,9 @@
       else
         dbsetlcharset(FDBLogin, PChar(CharSet));
     
    +  if Params.IndexOfName(SAppName) <> -1 then
    +    dbsetlname(FDBLogin, PChar(Params.Values[SAppName]), DBSETAPP);
    +
       //dbsetlname(FDBLogin, PChar(TIMEOUT_IGNORE), DBSET_LOGINTIME);
       dbsetlogintime(10);
     
    
    mssql.diff (2,561 bytes)

Activities

Ludo Brands

2013-06-22 15:37

developer  

mssql.diff (2,561 bytes)
Index: packages/dblib/src/dblib.pp
===================================================================
--- packages/dblib/src/dblib.pp	(revision 24588)
+++ packages/dblib/src/dblib.pp	(working copy)
@@ -69,19 +69,32 @@
   DBTDS_72     = 10; // Microsoft SQL Server 2005
   DBTDS_73     = 11; // Microsoft SQL Server 2008
 
-  //from sqlfront.h:
+  //from sqlfront.h ,   sybdb.h for freetds
   DBSETHOST=1;
   DBSETUSER=2;
   DBSETPWD=3;
-  DBSETAPP=4;
+  DBSETAPP={$IFDEF freetds}5{$ELSE}4{$ENDIF};
+  {$IFDEF freetds}
+  DBSETHID=     4;
+  DBSETBCP=	6;
+  DBSETNATLANG=	7;
+  DBSETNOSHORT=	8;
+  DBSETHIER=	9;
+  DBSETCHARSET=	10;
+  DBSETPACKET=	11;
+  DBSETENCRYPT=	12;
+  DBSETLABELED=	13;
+  DBSETDBNAME=	14;
+   {$ELSE}
   DBSETID=5;
   DBSETLANG=6;
   DBSETSECURE=7;
+  DBSET_LOGINTIME=10;
+  DBSETFALLBACK=12;
+  {$ENDIF}
   //These two are defined by Microsoft for dbsetlversion():
   DBVER42={$IFDEF freetds}DBVERSION_42{$ELSE}8{$ENDIF};
   DBVER60={$IFDEF freetds}DBVERSION_71{$ELSE}9{$ENDIF};
-  DBSET_LOGINTIME=10;
-  DBSETFALLBACK=12;
   //dboptions:
   DBNOAUTOFREE = {$IFDEF freetds}15{$ELSE}8{$ENDIF};
   DBTEXTLIMIT  = {$IFDEF freetds}7{$ELSE}4{$ENDIF};
Index: packages/fcl-db/src/sqldb/mssql/mssqlconn.pp
===================================================================
--- packages/fcl-db/src/sqldb/mssql/mssqlconn.pp	(revision 24588)
+++ packages/fcl-db/src/sqldb/mssql/mssqlconn.pp	(working copy)
@@ -30,7 +30,8 @@
       CharSet - if you use Microsoft DB-Lib and set to 'UTF-8' then char/varchar fields will be UTF8Encoded/Decoded
                 if you use FreeTDS DB-Lib then you must compile with iconv support (requires libiconv2.dll) or cast char/varchar to nchar/nvarchar in SELECTs
       Params - "AutoCommit=true" - if you don't want explicitly commit/rollback transactions
-               "TextSize=16777216 - set maximum size of text/image data returned
+               "TextSize=16777216" - set maximum size of text/image data returned
+               "ApplicationName=YourAppName" Set the app name for the connection. MSSQL 2000 and higher only
 }
 unit mssqlconn;
 
@@ -193,6 +194,7 @@
   SBeginTransaction = 'BEGIN TRANSACTION';
   SAutoCommit = 'AUTOCOMMIT';
   STextSize   = 'TEXTSIZE';
+  SAppName   = 'APPLICATIONNAME';
 
 
 var
@@ -428,6 +430,9 @@
   else
     dbsetlcharset(FDBLogin, PChar(CharSet));
 
+  if Params.IndexOfName(SAppName) <> -1 then
+    dbsetlname(FDBLogin, PChar(Params.Values[SAppName]), DBSETAPP);
+
   //dbsetlname(FDBLogin, PChar(TIMEOUT_IGNORE), DBSET_LOGINTIME);
   dbsetlogintime(10);
 
mssql.diff (2,561 bytes)

Michael Van Canneyt

2013-06-22 15:51

administrator   ~0068433

Applied, thank you.

Jonas Maebe

2014-03-04 16:58

manager   ~0073434

Merged to 2.6.4 in spite of 2.8.0 target version

Issue History

Date Modified Username Field Change
2013-06-22 15:37 Ludo Brands New Issue
2013-06-22 15:37 Ludo Brands Status new => assigned
2013-06-22 15:37 Ludo Brands Assigned To => Joost van der Sluis
2013-06-22 15:37 Ludo Brands File Added: mssql.diff
2013-06-22 15:46 Michael Van Canneyt Assigned To Joost van der Sluis => Michael Van Canneyt
2013-06-22 15:51 Michael Van Canneyt Fixed in Revision => 24932
2013-06-22 15:51 Michael Van Canneyt Note Added: 0068433
2013-06-22 15:51 Michael Van Canneyt Status assigned => resolved
2013-06-22 15:51 Michael Van Canneyt Fixed in Version => 2.7.1
2013-06-22 15:51 Michael Van Canneyt Resolution open => fixed
2013-06-22 15:51 Michael Van Canneyt Target Version => 2.8.0
2013-06-22 16:16 Ludo Brands Status resolved => closed
2014-03-04 16:58 Jonas Maebe Fixed in Revision 24932 => 25111
2014-03-04 16:58 Jonas Maebe Note Added: 0073434
2014-03-04 16:58 Jonas Maebe Fixed in Version 2.7.1 => 2.6.4