From ee33247518d22c7bcc62a4430fd1fcd7cc4e7f8d Mon Sep 17 00:00:00 2001 From: Yahor Yuzefovich Date: Mon, 8 Jun 2020 21:00:32 -0700 Subject: [PATCH] sql: propagate default int size to remote nodes A while ago we added support of `DEFAULT_INT_SIZE` which can be set either to 8 (default) or 4 bytes. So far that setting has been used to influence how we parse the "naked" INT in the query from the client. However, this is one other place where we're performing the parsing: during expression deserialization on the remote nodes. Previously, the setting hasn't been propagated to remote nodes, so we might have interpreted incorrectly. This commit addresses that. Release note: None --- pkg/sql/conn_executor.go | 7 +- pkg/sql/distsql/server.go | 3 +- pkg/sql/execinfra/expr.go | 5 +- pkg/sql/execinfrapb/api.go | 1 + pkg/sql/execinfrapb/api.pb.go | 209 +++++++++++++++++++--------------- pkg/sql/execinfrapb/api.proto | 3 +- pkg/sql/parser/parse.go | 47 ++++++-- 7 files changed, 163 insertions(+), 112 deletions(-) diff --git a/pkg/sql/conn_executor.go b/pkg/sql/conn_executor.go index 33bcbfbac536..183fd67d84c4 100644 --- a/pkg/sql/conn_executor.go +++ b/pkg/sql/conn_executor.go @@ -449,12 +449,7 @@ func (h ConnectionHandler) GetUnqualifiedIntSize() *types.T { // no server is actually present. size = h.ex.sessionData.DefaultIntSize } - switch size { - case 4, 32: - return types.Int4 - default: - return types.Int - } + return parser.NakedIntTypeFromDefaultIntSize(size) } // GetParamStatus retrieves the configured value of the session diff --git a/pkg/sql/distsql/server.go b/pkg/sql/distsql/server.go index 513c3912b4b1..7fe5ea54e54d 100644 --- a/pkg/sql/distsql/server.go +++ b/pkg/sql/distsql/server.go @@ -288,7 +288,8 @@ func (ds *ServerImpl) setupFlow( BytesEncodeFormat: be, ExtraFloatDigits: int(req.EvalContext.ExtraFloatDigits), }, - VectorizeMode: sessiondata.VectorizeExecMode(req.EvalContext.Vectorize), + VectorizeMode: sessiondata.VectorizeExecMode(req.EvalContext.Vectorize), + DefaultIntSize: int(req.EvalContext.DefaultIntSize), } ie := &lazyInternalExecutor{ newInternalExecutor: func() sqlutil.InternalExecutor { diff --git a/pkg/sql/execinfra/expr.go b/pkg/sql/execinfra/expr.go index bfc11fc47e9d..aafd4edb0aae 100644 --- a/pkg/sql/execinfra/expr.go +++ b/pkg/sql/execinfra/expr.go @@ -58,7 +58,10 @@ func processExpression( if exprSpec.Expr == "" { return nil, nil } - expr, err := parser.ParseExpr(exprSpec.Expr) + expr, err := parser.ParseExprWithInt( + exprSpec.Expr, + parser.NakedIntTypeFromDefaultIntSize(evalCtx.SessionData.DefaultIntSize), + ) if err != nil { return nil, err } diff --git a/pkg/sql/execinfrapb/api.go b/pkg/sql/execinfrapb/api.go index 0edb2497dd35..6badc8b2f3b0 100644 --- a/pkg/sql/execinfrapb/api.go +++ b/pkg/sql/execinfrapb/api.go @@ -55,6 +55,7 @@ func MakeEvalContext(evalCtx *tree.EvalContext) EvalContext { BytesEncodeFormat: be, ExtraFloatDigits: int32(evalCtx.SessionData.DataConversion.ExtraFloatDigits), Vectorize: int32(evalCtx.SessionData.VectorizeMode), + DefaultIntSize: int32(evalCtx.SessionData.DefaultIntSize), } // Populate the search path. Make sure not to include the implicit pg_catalog, diff --git a/pkg/sql/execinfrapb/api.pb.go b/pkg/sql/execinfrapb/api.pb.go index e6a4e7fa38be..11ac1bf3d981 100644 --- a/pkg/sql/execinfrapb/api.pb.go +++ b/pkg/sql/execinfrapb/api.pb.go @@ -75,7 +75,7 @@ func (x *BytesEncodeFormat) UnmarshalJSON(data []byte) error { return nil } func (BytesEncodeFormat) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_api_45d3d17cbc679dc1, []int{0} + return fileDescriptor_api_55ef9b2de775632b, []int{0} } type SetupFlowRequest struct { @@ -97,7 +97,7 @@ func (m *SetupFlowRequest) Reset() { *m = SetupFlowRequest{} } func (m *SetupFlowRequest) String() string { return proto.CompactTextString(m) } func (*SetupFlowRequest) ProtoMessage() {} func (*SetupFlowRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_api_45d3d17cbc679dc1, []int{0} + return fileDescriptor_api_55ef9b2de775632b, []int{0} } func (m *SetupFlowRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -135,7 +135,7 @@ func (m *FlowSpec) Reset() { *m = FlowSpec{} } func (m *FlowSpec) String() string { return proto.CompactTextString(m) } func (*FlowSpec) ProtoMessage() {} func (*FlowSpec) Descriptor() ([]byte, []int) { - return fileDescriptor_api_45d3d17cbc679dc1, []int{1} + return fileDescriptor_api_55ef9b2de775632b, []int{1} } func (m *FlowSpec) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -169,20 +169,21 @@ type EvalContext struct { Location string `protobuf:"bytes,4,opt,name=location" json:"location"` Database string `protobuf:"bytes,5,opt,name=database" json:"database"` SearchPath []string `protobuf:"bytes,6,rep,name=search_path,json=searchPath" json:"search_path,omitempty"` - TemporarySchemaName string `protobuf:"bytes,13,opt,name=temporary_schema_name,json=temporarySchemaName" json:"temporary_schema_name"` User string `protobuf:"bytes,7,opt,name=user" json:"user"` SeqState SequenceState `protobuf:"bytes,8,opt,name=seq_state,json=seqState" json:"seq_state"` ApplicationName string `protobuf:"bytes,9,opt,name=application_name,json=applicationName" json:"application_name"` BytesEncodeFormat BytesEncodeFormat `protobuf:"varint,10,opt,name=bytes_encode_format,json=bytesEncodeFormat,enum=cockroach.sql.distsqlrun.BytesEncodeFormat" json:"bytes_encode_format"` ExtraFloatDigits int32 `protobuf:"varint,11,opt,name=extra_float_digits,json=extraFloatDigits" json:"extra_float_digits"` Vectorize int32 `protobuf:"varint,12,opt,name=vectorize" json:"vectorize"` + TemporarySchemaName string `protobuf:"bytes,13,opt,name=temporary_schema_name,json=temporarySchemaName" json:"temporary_schema_name"` + DefaultIntSize int32 `protobuf:"varint,14,opt,name=default_int_size,json=defaultIntSize" json:"default_int_size"` } func (m *EvalContext) Reset() { *m = EvalContext{} } func (m *EvalContext) String() string { return proto.CompactTextString(m) } func (*EvalContext) ProtoMessage() {} func (*EvalContext) Descriptor() ([]byte, []int) { - return fileDescriptor_api_45d3d17cbc679dc1, []int{2} + return fileDescriptor_api_55ef9b2de775632b, []int{2} } func (m *EvalContext) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -219,7 +220,7 @@ func (m *SequenceState) Reset() { *m = SequenceState{} } func (m *SequenceState) String() string { return proto.CompactTextString(m) } func (*SequenceState) ProtoMessage() {} func (*SequenceState) Descriptor() ([]byte, []int) { - return fileDescriptor_api_45d3d17cbc679dc1, []int{3} + return fileDescriptor_api_55ef9b2de775632b, []int{3} } func (m *SequenceState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -254,7 +255,7 @@ func (m *SequenceState_Seq) Reset() { *m = SequenceState_Seq{} } func (m *SequenceState_Seq) String() string { return proto.CompactTextString(m) } func (*SequenceState_Seq) ProtoMessage() {} func (*SequenceState_Seq) Descriptor() ([]byte, []int) { - return fileDescriptor_api_45d3d17cbc679dc1, []int{3, 0} + return fileDescriptor_api_55ef9b2de775632b, []int{3, 0} } func (m *SequenceState_Seq) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -287,7 +288,7 @@ func (m *SimpleResponse) Reset() { *m = SimpleResponse{} } func (m *SimpleResponse) String() string { return proto.CompactTextString(m) } func (*SimpleResponse) ProtoMessage() {} func (*SimpleResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_api_45d3d17cbc679dc1, []int{4} + return fileDescriptor_api_55ef9b2de775632b, []int{4} } func (m *SimpleResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -330,7 +331,7 @@ func (m *ConsumerSignal) Reset() { *m = ConsumerSignal{} } func (m *ConsumerSignal) String() string { return proto.CompactTextString(m) } func (*ConsumerSignal) ProtoMessage() {} func (*ConsumerSignal) Descriptor() ([]byte, []int) { - return fileDescriptor_api_45d3d17cbc679dc1, []int{5} + return fileDescriptor_api_55ef9b2de775632b, []int{5} } func (m *ConsumerSignal) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -362,7 +363,7 @@ func (m *DrainRequest) Reset() { *m = DrainRequest{} } func (m *DrainRequest) String() string { return proto.CompactTextString(m) } func (*DrainRequest) ProtoMessage() {} func (*DrainRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_api_45d3d17cbc679dc1, []int{6} + return fileDescriptor_api_55ef9b2de775632b, []int{6} } func (m *DrainRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -413,7 +414,7 @@ func (m *ConsumerHandshake) Reset() { *m = ConsumerHandshake{} } func (m *ConsumerHandshake) String() string { return proto.CompactTextString(m) } func (*ConsumerHandshake) ProtoMessage() {} func (*ConsumerHandshake) Descriptor() ([]byte, []int) { - return fileDescriptor_api_45d3d17cbc679dc1, []int{7} + return fileDescriptor_api_55ef9b2de775632b, []int{7} } func (m *ConsumerHandshake) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -853,6 +854,9 @@ func (m *EvalContext) MarshalTo(dAtA []byte) (int, error) { i++ i = encodeVarintApi(dAtA, i, uint64(len(m.TemporarySchemaName))) i += copy(dAtA[i:], m.TemporarySchemaName) + dAtA[i] = 0x70 + i++ + i = encodeVarintApi(dAtA, i, uint64(m.DefaultIntSize)) return i, nil } @@ -1126,6 +1130,7 @@ func (m *EvalContext) Size() (n int) { n += 1 + sovApi(uint64(m.Vectorize)) l = len(m.TemporarySchemaName) n += 1 + l + sovApi(uint64(l)) + n += 1 + sovApi(uint64(m.DefaultIntSize)) return n } @@ -1896,6 +1901,25 @@ func (m *EvalContext) Unmarshal(dAtA []byte) error { } m.TemporarySchemaName = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 14: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field DefaultIntSize", wireType) + } + m.DefaultIntSize = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.DefaultIntSize |= (int32(b) & 0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipApi(dAtA[iNdEx:]) @@ -2634,85 +2658,86 @@ var ( ErrIntOverflowApi = fmt.Errorf("proto: integer overflow") ) -func init() { proto.RegisterFile("sql/execinfrapb/api.proto", fileDescriptor_api_45d3d17cbc679dc1) } - -var fileDescriptor_api_45d3d17cbc679dc1 = []byte{ - // 1217 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x56, 0x4f, 0x73, 0x1b, 0xc5, - 0x12, 0xd7, 0x4a, 0xb2, 0x25, 0xb5, 0x2c, 0x3f, 0x79, 0xe2, 0xf7, 0x6a, 0x9f, 0x0e, 0x92, 0x4a, - 0x2f, 0x0f, 0x44, 0x52, 0x48, 0x41, 0x09, 0x14, 0x05, 0x54, 0x51, 0x51, 0xe4, 0x10, 0x39, 0x7f, - 0xca, 0xec, 0x26, 0xa9, 0x14, 0x07, 0xb6, 0x46, 0xbb, 0x2d, 0x69, 0x2b, 0xfb, 0x4f, 0x3b, 0x23, - 0xc7, 0xe6, 0x13, 0x70, 0xcc, 0x47, 0xe0, 0xc0, 0x17, 0xe1, 0xe6, 0x63, 0x0e, 0x39, 0xa4, 0x38, - 0x18, 0xb0, 0xef, 0x7c, 0x00, 0x4e, 0xd4, 0xcc, 0xee, 0xca, 0x6b, 0x19, 0x0b, 0x73, 0x9b, 0xed, - 0xfe, 0xfd, 0x7a, 0xa6, 0xbb, 0x7f, 0x33, 0xbd, 0xf0, 0x5f, 0x36, 0x73, 0xba, 0x78, 0x80, 0xa6, - 0xed, 0x8d, 0x43, 0x1a, 0x8c, 0xba, 0x34, 0xb0, 0x3b, 0x41, 0xe8, 0x73, 0x9f, 0xa8, 0xa6, 0x6f, - 0xbe, 0x0c, 0x7d, 0x6a, 0x4e, 0x3b, 0x6c, 0xe6, 0x74, 0x2c, 0x9b, 0x71, 0x36, 0x73, 0xc2, 0xb9, - 0x57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x60, 0x8b, 0x1f, 0x78, 0x4b, 0xa4, - 0x6c, 0x8a, 0x74, 0xd1, 0x4d, 0x9a, 0x50, 0x74, 0x7c, 0x93, 0x72, 0x21, 0xb2, 0x7c, 0x53, 0x69, - 0x97, 0x62, 0xe8, 0xc2, 0x2a, 0x10, 0xe2, 0x22, 0x8c, 0x28, 0x43, 0x29, 0xc3, 0x05, 0x22, 0xb1, - 0x92, 0x06, 0x94, 0x19, 0xd2, 0xd0, 0x9c, 0x1a, 0x01, 0xe5, 0x53, 0x75, 0xbd, 0x99, 0x6b, 0x97, - 0x34, 0x88, 0x4c, 0x7b, 0x94, 0x4f, 0x89, 0x0a, 0xf9, 0x39, 0xc3, 0x50, 0xea, 0x26, 0xa1, 0x4b, - 0x0b, 0xd9, 0x85, 0x12, 0xc3, 0x59, 0x2c, 0xab, 0xa2, 0x94, 0xd5, 0x8a, 0xee, 0xe8, 0xe2, 0x5a, - 0x79, 0x26, 0x4a, 0x19, 0x25, 0xc7, 0x60, 0x38, 0x8b, 0x64, 0xd5, 0x85, 0x2a, 0x0d, 0x02, 0xc7, - 0x8e, 0xce, 0x6d, 0x78, 0xd4, 0x45, 0xb5, 0x94, 0xda, 0xf1, 0x5f, 0x29, 0xef, 0x13, 0xea, 0x22, - 0xa1, 0x70, 0x6d, 0x74, 0xc8, 0x91, 0x19, 0xe8, 0x99, 0xbe, 0x85, 0xc6, 0xd8, 0x0f, 0x5d, 0xca, - 0x55, 0x68, 0x2a, 0xed, 0xcd, 0xde, 0xcd, 0xcb, 0x8f, 0xd1, 0x17, 0xa4, 0x1d, 0xc9, 0xb9, 0x2f, - 0x29, 0x49, 0x79, 0x47, 0xcb, 0x0e, 0xd2, 0x03, 0x82, 0x07, 0x3c, 0xa4, 0xc6, 0xd8, 0xf1, 0x29, - 0x37, 0x2c, 0x7b, 0x62, 0x73, 0xa6, 0x96, 0xa5, 0x74, 0x22, 0x52, 0x55, 0xfa, 0xef, 0x0b, 0xf7, - 0x40, 0x7a, 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 0xb6, - 0x1b, 0x77, 0x60, 0xeb, 0xc2, 0x3b, 0x41, 0x0a, 0x90, 0x7b, 0xb0, 0xf3, 0xa2, 0x9a, 0x21, 0x00, - 0xeb, 0x3b, 0xfa, 0xbd, 0xbb, 0x7b, 0x3b, 0x55, 0x45, 0xac, 0xfb, 0x77, 0xf5, 0x9d, 0x4f, 0xee, - 0x54, 0xb3, 0xbd, 0x9f, 0xb2, 0x50, 0x88, 0x83, 0x93, 0x29, 0x94, 0xb5, 0xb9, 0xa7, 0x1f, 0x7a, - 0xa6, 0xe8, 0x2f, 0x69, 0xff, 0x7d, 0x17, 0x23, 0xa5, 0xd6, 0x3e, 0x58, 0x39, 0xdf, 0xac, 0xb9, - 0x89, 0xe1, 0x63, 0x64, 0x8c, 0x4e, 0xb0, 0x95, 0x69, 0x2b, 0xb7, 0x14, 0x62, 0x42, 0x69, 0xa1, - 0x2c, 0xf2, 0x0f, 0xe4, 0x57, 0x5b, 0x71, 0xa6, 0xf3, 0xf7, 0xb0, 0x95, 0x21, 0x13, 0x00, 0x39, - 0xc8, 0x79, 0x88, 0xd4, 0x25, 0x57, 0x3f, 0x63, 0xed, 0xca, 0x89, 0x47, 0xd9, 0xf4, 0x3f, 0x3c, - 0xfa, 0xad, 0x9e, 0x39, 0x3a, 0xa9, 0x2b, 0x6f, 0x4e, 0xea, 0xca, 0xbb, 0x93, 0xba, 0xf2, 0xeb, - 0x49, 0x5d, 0x79, 0x7d, 0x5a, 0xcf, 0xbc, 0x39, 0xad, 0x67, 0xde, 0x9d, 0xd6, 0x33, 0xdf, 0x94, - 0x53, 0x7f, 0x72, 0x7f, 0x06, 0x00, 0x00, 0xff, 0xff, 0xfc, 0xd4, 0x8a, 0x63, 0x77, 0x0a, 0x00, - 0x00, +func init() { proto.RegisterFile("sql/execinfrapb/api.proto", fileDescriptor_api_55ef9b2de775632b) } + +var fileDescriptor_api_55ef9b2de775632b = []byte{ + // 1237 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8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df, 0xb9, 0xbd, 0xbb, 0x5d, 0x51, 0xc4, 0x77, 0xef, 0xb6, + 0xbe, 0xfd, 0xc5, 0xad, 0x4a, 0xb6, 0xfb, 0x5b, 0x16, 0xd6, 0x62, 0xe7, 0x64, 0x02, 0x25, 0x6d, + 0xe6, 0xe9, 0x07, 0x9e, 0x29, 0xfa, 0x4b, 0x5a, 0xff, 0xdd, 0xc5, 0x68, 0x52, 0xab, 0x9f, 0x2c, + 0xdd, 0x87, 0xd6, 0xcc, 0xc4, 0xf0, 0x21, 0x32, 0x46, 0xc7, 0xd8, 0xcc, 0xb4, 0x94, 0x1b, 0x0a, + 0x31, 0xa1, 0x38, 0x9f, 0x2c, 0xf2, 0x3f, 0xc6, 0xaf, 0xba, 0xe4, 0x4c, 0x67, 0xef, 0x61, 0x33, + 0x43, 0xc6, 0x00, 0x72, 0xf1, 0xf3, 0x10, 0xa9, 0x4b, 0x2e, 0x7f, 0xc6, 0xea, 0xa5, 0x13, 0x8f, + 0xb2, 0xe9, 0x7d, 0x7a, 0xf8, 0x57, 0x2d, 0x73, 0x78, 0x5c, 0x53, 0x5e, 0x1f, 0xd7, 0x94, 0xb7, + 0xc7, 0x35, 0xe5, 0xcf, 0xe3, 0x9a, 0xf2, 0xea, 0xa4, 0x96, 0x79, 0x7d, 0x52, 0xcb, 0xbc, 0x3d, + 0xa9, 0x65, 0x7e, 0x28, 0xa5, 0xfe, 0xf9, 0xfd, 0x13, 0x00, 0x00, 0xff, 0xff, 0x50, 0xb7, 0x72, + 0x93, 0xa7, 0x0a, 0x00, 0x00, } diff --git a/pkg/sql/execinfrapb/api.proto b/pkg/sql/execinfrapb/api.proto index 943abbd746f3..608068f99e8d 100644 --- a/pkg/sql/execinfrapb/api.proto +++ b/pkg/sql/execinfrapb/api.proto @@ -69,13 +69,14 @@ message EvalContext { optional string location = 4 [(gogoproto.nullable) = false]; optional string database = 5 [(gogoproto.nullable) = false]; repeated string search_path = 6; - optional string temporary_schema_name = 13 [(gogoproto.nullable) = false]; optional string user = 7 [(gogoproto.nullable) = false]; optional SequenceState seq_state = 8 [(gogoproto.nullable) = false]; optional string application_name = 9 [(gogoproto.nullable) = false]; optional BytesEncodeFormat bytes_encode_format = 10 [(gogoproto.nullable) = false]; optional int32 extra_float_digits = 11 [(gogoproto.nullable) = false]; optional int32 vectorize = 12 [(gogoproto.nullable) = false]; + optional string temporary_schema_name = 13 [(gogoproto.nullable) = false]; + optional int32 default_int_size = 14 [(gogoproto.nullable) = false]; } // BytesEncodeFormat is the configuration for bytes to string conversions. diff --git a/pkg/sql/parser/parse.go b/pkg/sql/parser/parse.go index fbd68a3fcefa..fa78c3b51a7d 100644 --- a/pkg/sql/parser/parse.go +++ b/pkg/sql/parser/parse.go @@ -88,10 +88,22 @@ type Parser struct { // INT8 is the historical interpretation of INT. This should be left // alone in the future, since there are many sql fragments stored -// in various descriptors. Any user input that was created after +// in various descriptors. Any user input that was created after // INT := INT4 will simply use INT4 in any resulting code. var defaultNakedIntType = types.Int +// NakedIntTypeFromDefaultIntSize given the size in bits or bytes (preferred) +// of how a "naked" INT type should be parsed returns the corresponding integer +// type. +func NakedIntTypeFromDefaultIntSize(defaultIntSize int) *types.T { + switch defaultIntSize { + case 4, 32: + return types.Int4 + default: + return types.Int + } +} + // Parse parses the sql and returns a list of statements. func (p *Parser) Parse(sql string) (Statements, error) { return p.parseWithDepth(1, sql, defaultNakedIntType) @@ -103,8 +115,8 @@ func (p *Parser) ParseWithInt(sql string, nakedIntType *types.T) (Statements, er return p.parseWithDepth(1, sql, nakedIntType) } -func (p *Parser) parseOneWithDepth(depth int, sql string) (Statement, error) { - stmts, err := p.parseWithDepth(1, sql, defaultNakedIntType) +func (p *Parser) parseOneWithInt(sql string, nakedIntType *types.T) (Statement, error) { + stmts, err := p.parseWithDepth(1, sql, nakedIntType) if err != nil { return Statement{}, err } @@ -232,8 +244,14 @@ func Parse(sql string) (Statements, error) { // bits of SQL from other nodes. In general, we expect that all // user-generated SQL has been run through the ParseWithInt() function. func ParseOne(sql string) (Statement, error) { + return ParseOneWithInt(sql, defaultNakedIntType) +} + +// ParseOneWithInt is similar to ParseOne but interprets the INT and SERIAL +// types as the provided integer type. +func ParseOneWithInt(sql string, nakedIntType *types.T) (Statement, error) { var p Parser - return p.parseOneWithDepth(1, sql) + return p.parseOneWithInt(sql, nakedIntType) } // ParseQualifiedTableName parses a SQL string of the form @@ -262,9 +280,9 @@ func ParseTableName(sql string) (*tree.UnresolvedObjectName, error) { return rename.Name, nil } -// parseExprs parses one or more sql expressions. -func parseExprs(exprs []string) (tree.Exprs, error) { - stmt, err := ParseOne(fmt.Sprintf("SET ROW (%s)", strings.Join(exprs, ","))) +// parseExprsWithInt parses one or more sql expressions. +func parseExprsWithInt(exprs []string, nakedIntType *types.T) (tree.Exprs, error) { + stmt, err := ParseOneWithInt(fmt.Sprintf("SET ROW (%s)", strings.Join(exprs, ",")), nakedIntType) if err != nil { return nil, err } @@ -275,17 +293,24 @@ func parseExprs(exprs []string) (tree.Exprs, error) { return set.Values, nil } -// ParseExprs is a short-hand for parseExprs(sql) +// ParseExprs is a short-hand for parseExprs(sql). func ParseExprs(sql []string) (tree.Exprs, error) { if len(sql) == 0 { return tree.Exprs{}, nil } - return parseExprs(sql) + return parseExprsWithInt(sql, defaultNakedIntType) } -// ParseExpr is a short-hand for parseExprs([]string{sql}) +// ParseExpr is a short-hand for parseExprsWithInt([]string{sql}, +// defaultNakedIntType). func ParseExpr(sql string) (tree.Expr, error) { - exprs, err := parseExprs([]string{sql}) + return ParseExprWithInt(sql, defaultNakedIntType) +} + +// ParseExprWithInt is a short-hand for parseExprsWithInt([]string{sql}, +// nakedIntType).' +func ParseExprWithInt(sql string, nakedIntType *types.T) (tree.Expr, error) { + exprs, err := parseExprsWithInt([]string{sql}, nakedIntType) if err != nil { return nil, err }