Cast of string values to VARCHAR(8191) results in "Implementation limit 
exceeded"
---------------------------------------------------------------------------------

                 Key: DNET-934
                 URL: http://tracker.firebirdsql.org/browse/DNET-934
             Project: .NET Data provider
          Issue Type: Bug
          Components: Entity Framework
    Affects Versions: 7.5.0.0
            Reporter: Daniel Richter
            Assignee: Jiri Cincura


For string values in queries, the generated SQL results in CASTs to 
VARCHAR(8191)
   dataContext.Articles.Select(_ => new { A1 = "1A", A2 = "2A" })
generates SQL such as
   SELECT CAST(_UTF8'1A' AS VARCHAR(8191)) AS "A1", CAST(_UTF8'2A' AS 
VARCHAR(8191)) AS "A2" FROM "ARTICLE"
   
In case the string value is used in multiple* columns, the SQL command 
execution results in an error "SQL error code = -204, Implementation limit 
exceeded, block size exceeds implementation restriction".

*) With charset UTF8 the query fails with 2+ columns using string values. The 
amount of string values used in the column does not seem to affect the outcome 
(50+ string values in one column still work).
   With charset WIN1252 the query fails with 8+ columns using one string value. 
Using multiple string values in a column shows different results; in some 
cases, 8+ string values used in the entire query fails, in some cases not.

It does not matter whether the string value is used inline or as a captured 
variable (the cast is also inserted for those).

Because of the following code in SqlGenerator.cs, Visit(DbConstantExpression)
   // constant is always considered Unicode
   isUnicode = true;
   var length = 
MetadataHelpers.GetFacetValueOrDefault<int?>(e.ResultType,MetadataHelpers.MaxLengthFacetName,null)
           ?? (isUnicode ? FbProviderManifest.UnicodeVarcharMaxSize : 
FbProviderManifest.AsciiVarcharMaxSize);
The length will result in FbProviderManifest.UnicodeVarcharMaxSize (8191).


Is the CAST to VARCHAR(n) really necessary? The following two solutions will 
work without problems (so far) for my use-case:

1) Don't pass the explicitLength parameter to FormatString (SqlGenerator.cs), 
so the length of the string value will be used:
   SELECT CAST(_UTF8'ABC' AS VARCHAR(3)) AS "A1", CAST(_UTF8'DEFGH' AS 
VARCHAR(5)) AS "A2" FROM "ARTICLE"
   
2) Omit the CAST entirely.
   SELECT _UTF8'ABC' AS "A1", _UTF8'DEFGH' AS "A2" FROM "ARTICLE"

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://tracker.firebirdsql.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


_______________________________________________
Firebird-net-provider mailing list
Firebird-net-provider@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider

Reply via email to