Add backwards compatibility for Calcite <= 1.9.0 and Phoenix <= 4.10.0


Project: http://git-wip-us.apache.org/repos/asf/calcite-avatica-go/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/calcite-avatica-go/commit/dbf1ecc6
Tree: http://git-wip-us.apache.org/repos/asf/calcite-avatica-go/tree/dbf1ecc6
Diff: http://git-wip-us.apache.org/repos/asf/calcite-avatica-go/diff/dbf1ecc6

Branch: refs/heads/master
Commit: dbf1ecc604c9a0a1bf2216743d89458e2a5d0c6e
Parents: e2abf94
Author: Francis Chuang <francis.chu...@boostport.com>
Authored: Thu Jul 20 09:54:02 2017 +1000
Committer: Julian Hyde <jh...@apache.org>
Committed: Thu Aug 10 18:47:12 2017 -0700

----------------------------------------------------------------------
 README.md    |  4 ++--
 statement.go | 26 ++++++++++++++++++++++----
 2 files changed, 24 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/calcite-avatica-go/blob/dbf1ecc6/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index d0c26fe..886c66f 100644
--- a/README.md
+++ b/README.md
@@ -133,8 +133,8 @@ We recommend using `UTC`, which is the default value of 
`location`.
 ## Version compatibility
 | Driver Version  | Phoenix Version   | Calcite-Avatica Version |
 | --------------- | ----------------- | ----------------------- |
-| 1.x.x           | >= 4.8.x, <= 4.10 | >= 1.8.0, <=1.9.0       |
-| 2.x.x           | >= 4.8.11         | >= 1.10.0               |
+| 1.x.x           | >= 4.8.0          | >= 1.8.0                |
+| 2.x.x           | >= 4.8.0          | >= 1.8.0                |
 
 ## Development
 

http://git-wip-us.apache.org/repos/asf/calcite-avatica-go/blob/dbf1ecc6/statement.go
----------------------------------------------------------------------
diff --git a/statement.go b/statement.go
index 68d5a04..8b1c558 100644
--- a/statement.go
+++ b/statement.go
@@ -4,6 +4,8 @@ import (
        "database/sql/driver"
        "time"
 
+       "math"
+
        "github.com/Boostport/avatica/message"
        "golang.org/x/net/context"
 )
@@ -56,12 +58,20 @@ func (s *stmt) exec(ctx context.Context, args []namedValue) 
(driver.Result, erro
                return nil, driver.ErrBadConn
        }
 
-       res, err := s.conn.httpClient.post(ctx, &message.ExecuteRequest{
+       msg := &message.ExecuteRequest{
                StatementHandle:    &s.handle,
                ParameterValues:    s.parametersToTypedValues(args),
                FirstFrameMaxSize:  s.conn.config.frameMaxSize,
                HasParameterValues: true,
-       })
+       }
+
+       if s.conn.config.frameMaxSize <= -1 {
+               msg.DeprecatedFirstFrameMaxSize = math.MaxInt64
+       } else {
+               msg.DeprecatedFirstFrameMaxSize = 
uint64(s.conn.config.frameMaxSize)
+       }
+
+       res, err := s.conn.httpClient.post(ctx, msg)
 
        if err != nil {
                return nil, err
@@ -87,12 +97,20 @@ func (s *stmt) query(ctx context.Context, args 
[]namedValue) (driver.Rows, error
                return nil, driver.ErrBadConn
        }
 
-       res, err := s.conn.httpClient.post(ctx, &message.ExecuteRequest{
+       msg := &message.ExecuteRequest{
                StatementHandle:    &s.handle,
                ParameterValues:    s.parametersToTypedValues(args),
                FirstFrameMaxSize:  s.conn.config.frameMaxSize,
                HasParameterValues: true,
-       })
+       }
+
+       if s.conn.config.frameMaxSize <= -1 {
+               msg.DeprecatedFirstFrameMaxSize = math.MaxInt64
+       } else {
+               msg.DeprecatedFirstFrameMaxSize = 
uint64(s.conn.config.frameMaxSize)
+       }
+
+       res, err := s.conn.httpClient.post(ctx, msg)
 
        if err != nil {
                return nil, err

Reply via email to