As an immediate workaround for subj., I propose to let BIGINT (and
DATEand TIME) to be passed for dialect 1 clients.

Thechanges just transform something that is currently an error into
something that may be unexpected (SQL_INT64) but will work for good clients.

Arithmetics will not be changed:

-- Create database on dialect 3

isql

create table t1 (n1 numeric(12,3));
insert into t1 values (1.23);
insert into t1 values (10.23);
insert into t1 values (3.567);
commit;
exit;


-- Change database and client to dialect 1 (with new semantics)

gfix -sql_dialect 1 zz.fdb
isql -sql_dialect 1 zz.fdb

set sqlda_display on;
select n1, n1 / 2 from t1;

OUTPUT SQLDA version: 1 sqln: 20 sqld: 2
01: sqltype: 581 INT64     Nullable sqlscale: -3 sqlsubtype: 1 sqllen: 8
  :  name: (2)N1  alias: (2)N1
  : table: (2)T1  owner: (6)SYSDBA
02: sqltype: 481 DOUBLE    Nullable sqlscale: 0 sqlsubtype: 0 sqllen: 8
  :  name: (6)DIVIDE  alias: (6)DIVIDE
  : table: (0)  owner: (0)

                   N1                  DIVIDE
===================== =======================
                1.230      0.6150000000000000
               10.230       5.115000000000000
                3.567       1.783500000000000


-- Test with current dialect 1

Statement failed, SQLSTATE = 42S22
Dynamic SQL Error
-SQL error code = -206
-Column unknown
-N1
-Client SQL dialect 1 does not support reference to BIGINT datatype


Adriano

PS: patch is attached.

diff --git a/src/dsql/ExprNodes.cpp b/src/dsql/ExprNodes.cpp
index 09c1655..04943b0 100644
--- a/src/dsql/ExprNodes.cpp
+++ b/src/dsql/ExprNodes.cpp
@@ -5012,19 +5012,6 @@ ValueExprNode* 
FieldNode::internalDsqlPass(DsqlCompilerScratch* dsqlScratch, Rec
                                                // Intercept any reference to a 
field with datatype that
                                                // did not exist prior to V6 
and post an error
 
-                                               if (dsqlScratch->clientDialect 
<= SQL_DIALECT_V5 && field &&
-                                                       (field->fld_dtype == 
dtype_sql_date ||
-                                                               
field->fld_dtype == dtype_sql_time || field->fld_dtype == dtype_int64))
-                                               {
-                                                               
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-206) <<
-                                                                               
  Arg::Gds(isc_dsql_field_err) <<
-                                                                               
  Arg::Gds(isc_random) << Arg::Str(field->fld_name) <<
-                                                                               
  Arg::Gds(isc_sql_dialect_datatype_unsupport) <<
-                                                                               
                        Arg::Num(dsqlScratch->clientDialect) <<
-                                                                               
                        
Arg::Str(DSC_dtype_tostring(static_cast<UCHAR>(field->fld_dtype))));
-                                                               return NULL;
-                                               }
-
                                                // CVC: Stop here if this is 
our second or third iteration.
                                                // Anyway, we can't report more 
than one ambiguity to the status vector.
                                                // AB: But only if we're on 
different scope level, because a
@@ -5339,28 +5326,6 @@ void FieldNode::setParameterName(dsql_par* parameter) 
const
 // Generate blr for a field - field id's are preferred but not for trigger or 
view blr.
 void FieldNode::genBlr(DsqlCompilerScratch* dsqlScratch)
 {
-       // For older clients - generate an error should they try and
-       // access data types which did not exist in the older dialect.
-       if (dsqlScratch->clientDialect <= SQL_DIALECT_V5)
-       {
-               switch (dsqlField->fld_dtype)
-               {
-                       case dtype_sql_date:
-                       case dtype_sql_time:
-                       case dtype_int64:
-                               ERRD_post(Arg::Gds(isc_sqlerr) << 
Arg::Num(-804) <<
-                                                 
Arg::Gds(isc_dsql_datatype_err) <<
-                                                 
Arg::Gds(isc_sql_dialect_datatype_unsupport) <<
-                                                               
Arg::Num(dsqlScratch->clientDialect) <<
-                                                               
Arg::Str(DSC_dtype_tostring(static_cast<UCHAR>(dsqlField->fld_dtype))));
-                               break;
-
-                       default:
-                               // No special action for other data types
-                               break;
-               }
-       }
-
        if (dsqlIndices)
                dsqlScratch->appendUChar(blr_index);
 
diff --git a/src/dsql/gen.cpp b/src/dsql/gen.cpp
index 3d88f17..8c60233 100644
--- a/src/dsql/gen.cpp
+++ b/src/dsql/gen.cpp
@@ -201,30 +201,6 @@ void GEN_port(DsqlCompilerScratch* dsqlScratch, dsql_msg* 
message)
                                parameter->par_desc.setTextType(toCharSet);
                }
 
-               // For older clients - generate an error should they try and
-               // access data types which did not exist in the older dialect
-               if (dsqlScratch->clientDialect <= SQL_DIALECT_V5)
-               {
-                       switch (parameter->par_desc.dsc_dtype)
-                       {
-                               // In V6.0 - older clients, which we 
distinguish by
-                               // their use of SQL DIALECT 0 or 1, are 
forbidden
-                               // from selecting values of new datatypes
-                               case dtype_sql_date:
-                               case dtype_sql_time:
-                               case dtype_int64:
-                                       ERRD_post(Arg::Gds(isc_sqlerr) << 
Arg::Num(-804) <<
-                                                         
Arg::Gds(isc_dsql_datatype_err) <<
-                                                         
Arg::Gds(isc_sql_dialect_datatype_unsupport) <<
-                                                                       
Arg::Num(dsqlScratch->clientDialect) <<
-                                                                       
Arg::Str(DSC_dtype_tostring(parameter->par_desc.dsc_dtype)));
-                                       break;
-                               default:
-                                       // No special action for other data 
types
-                                       break;
-                       }
-               }
-
                if (parameter->par_desc.dsc_dtype == dtype_text && 
parameter->par_index != 0)
                {
                        // We should convert par_desc from text to varying so 
the user can receive it with
diff --git a/src/jrd/ini.epp b/src/jrd/ini.epp
index 7e7c0fa..f6f6d37 100644
--- a/src/jrd/ini.epp
+++ b/src/jrd/ini.epp
@@ -598,9 +598,6 @@ void INI_init(thread_db* tdbb)
 
                        desc->dsc_dtype = gfield->gfld_dtype;
 
-                       if (desc->dsc_dtype == dtype_int64 && !(dbb->dbb_flags 
& DBB_DB_SQL_dialect_3))
-                               desc->dsc_dtype = dtype_double;
-
                        if (desc->isText())
                        {
                                if (gfield->gfld_sub_type & 
dsc_text_type_metadata)
@@ -744,9 +741,6 @@ void INI_init_dsql(thread_db* tdbb, dsql_dbb* database)
 
                        field->fld_dtype = gfield->gfld_dtype;
 
-                       if (field->fld_dtype == dtype_int64 && !(dbb->dbb_flags 
& DBB_DB_SQL_dialect_3))
-                               field->fld_dtype = dtype_double;
-
                        if (field->fld_dtype == dtype_varying)
                                field->fld_length += sizeof(USHORT);
                        else if (field->fld_dtype == dtype_blob)
@@ -1254,14 +1248,8 @@ static void store_global_field(thread_db* tdbb, const 
gfld* gfield, AutoRequest&
                        else if (gfield->gfld_dtype == dtype_long)
                                X.RDB$FIELD_TYPE = (int) blr_long;
                        else
-                       {
-                               // Workaround to allow fld_counter domain
-                               // in dialect 1 databases
-                               if (dbb->dbb_flags & DBB_DB_SQL_dialect_3)
-                                       X.RDB$FIELD_TYPE = (int) blr_int64;
-                               else
-                                       X.RDB$FIELD_TYPE = (int) blr_double;
-                       }
+                               X.RDB$FIELD_TYPE = (int) blr_int64;
+
                        if ((gfield->gfld_sub_type == dsc_num_type_numeric) ||
                                (gfield->gfld_sub_type == dsc_num_type_decimal))
                        {
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to