Skip to content

Commit

Permalink
Merge pull request #182 from dolthub/daylon/init-order
Browse files Browse the repository at this point in the history
Added explicit initialization order to packages
  • Loading branch information
Hydrocharged authored Apr 23, 2024
2 parents e041d64 + 23cfb13 commit b7f4ff1
Show file tree
Hide file tree
Showing 109 changed files with 414 additions and 207 deletions.
4 changes: 2 additions & 2 deletions server/cast/bool.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (
pgtypes "github.com/dolthub/doltgresql/server/types"
)

// init handles all explicit and implicit casts that are built-in. This comprises only the "From" types.
func init() {
// initBool handles all explicit and implicit casts that are built-in. This comprises only the "From" types.
func initBool() {
boolExplicit()
boolImplicit()
}
Expand Down
4 changes: 2 additions & 2 deletions server/cast/bytea.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
pgtypes "github.com/dolthub/doltgresql/server/types"
)

// init handles all explicit and implicit casts that are built-in. This comprises only the "From" types.
func init() {
// initBytea handles all explicit and implicit casts that are built-in. This comprises only the "From" types.
func initBytea() {
// TODO: handle the different output formats?
byteaExplicit()
byteaImplicit()
Expand Down
4 changes: 2 additions & 2 deletions server/cast/char.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
pgtypes "github.com/dolthub/doltgresql/server/types"
)

// init handles all explicit and implicit casts that are built-in. This comprises only the "From" types.
func init() {
// initChar handles all explicit and implicit casts that are built-in. This comprises only the "From" types.
func initChar() {
charExplicit()
charImplicit()
}
Expand Down
4 changes: 2 additions & 2 deletions server/cast/float32.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (
pgtypes "github.com/dolthub/doltgresql/server/types"
)

// init handles all explicit and implicit casts that are built-in. This comprises only the "From" types.
func init() {
// initFloat32 handles all explicit and implicit casts that are built-in. This comprises only the "From" types.
func initFloat32() {
float32Explicit()
float32Implicit()
}
Expand Down
4 changes: 2 additions & 2 deletions server/cast/float64.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (
pgtypes "github.com/dolthub/doltgresql/server/types"
)

// init handles all explicit and implicit casts that are built-in. This comprises only the "From" types.
func init() {
// initFloat64 handles all explicit and implicit casts that are built-in. This comprises only the "From" types.
func initFloat64() {
float64Explicit()
float64Implicit()
}
Expand Down
31 changes: 31 additions & 0 deletions server/cast/init.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright 2024 Dolthub, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package cast

// Init initializes all casts in this package.
func Init() {
initBool()
initBytea()
initChar()
initFloat32()
initFloat64()
initInt16()
initInt32()
initInt64()
initNumeric()
initText()
initUuid()
initVarChar()
}
4 changes: 2 additions & 2 deletions server/cast/int16.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
pgtypes "github.com/dolthub/doltgresql/server/types"
)

// init handles all explicit and implicit casts that are built-in. This comprises only the "From" types.
func init() {
// initInt16 handles all explicit and implicit casts that are built-in. This comprises only the "From" types.
func initInt16() {
int16Explicit()
int16Implicit()
}
Expand Down
4 changes: 2 additions & 2 deletions server/cast/int32.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
pgtypes "github.com/dolthub/doltgresql/server/types"
)

// init handles all explicit and implicit casts that are built-in. This comprises only the "From" types.
func init() {
// initInt32 handles all explicit and implicit casts that are built-in. This comprises only the "From" types.
func initInt32() {
int32Explicit()
int32Implicit()
}
Expand Down
4 changes: 2 additions & 2 deletions server/cast/int64.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
pgtypes "github.com/dolthub/doltgresql/server/types"
)

// init handles all explicit and implicit casts that are built-in. This comprises only the "From" types.
func init() {
// initInt64 handles all explicit and implicit casts that are built-in. This comprises only the "From" types.
func initInt64() {
int64Explicit()
int64Implicit()
}
Expand Down
4 changes: 2 additions & 2 deletions server/cast/numeric.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
pgtypes "github.com/dolthub/doltgresql/server/types"
)

// init handles all explicit and implicit casts that are built-in. This comprises only the "From" types.
func init() {
// initNumeric handles all explicit and implicit casts that are built-in. This comprises only the "From" types.
func initNumeric() {
numericExplicit()
numericImplicit()
}
Expand Down
4 changes: 2 additions & 2 deletions server/cast/text.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
pgtypes "github.com/dolthub/doltgresql/server/types"
)

// init handles all explicit and implicit casts that are built-in. This comprises only the "From" types.
func init() {
// initText handles all explicit and implicit casts that are built-in. This comprises only the "From" types.
func initText() {
textExplicit()
textImplicit()
}
Expand Down
4 changes: 2 additions & 2 deletions server/cast/uuid.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
pgtypes "github.com/dolthub/doltgresql/server/types"
)

// init handles all explicit and implicit casts that are built-in. This comprises only the "From" types.
func init() {
// initUuid handles all explicit and implicit casts that are built-in. This comprises only the "From" types.
func initUuid() {
uuidExplicit()
uuidImplicit()
}
Expand Down
4 changes: 2 additions & 2 deletions server/cast/varchar.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
pgtypes "github.com/dolthub/doltgresql/server/types"
)

// init handles all explicit and implicit casts that are built-in. This comprises only the "From" types.
func init() {
// initVarChar handles all explicit and implicit casts that are built-in. This comprises only the "From" types.
func initVarChar() {
varcharExplicit()
varcharImplicit()
}
Expand Down
4 changes: 2 additions & 2 deletions server/config/parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ import (
"github.com/dolthub/go-mysql-server/sql/variables"
)

// init initializes or appends to SystemVariables as it functions as a global variable.
// Init initializes or appends to SystemVariables as it functions as a global variable.
// Currently, we append all of postgres configuration parameters to sql.SystemVariables.
// This means that all of mysql system variables and postgres config parameters will be stored together.
// TODO: get rid of me, use an integration point to define new sysvars
func init() {
func Init() {
// There are two postgres parameters have the same name as mysql variables
// TODO: issue with this approach is that those parameters will override the mysql variables.
if sql.SystemVariables == nil {
Expand Down
1 change: 0 additions & 1 deletion server/expression/binary_operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"github.com/dolthub/go-mysql-server/sql/expression"
vitess "github.com/dolthub/vitess/go/vt/sqlparser"

_ "github.com/dolthub/doltgresql/server/functions/binary"
"github.com/dolthub/doltgresql/server/functions/framework"
)

Expand Down
1 change: 0 additions & 1 deletion server/expression/cast.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"github.com/dolthub/vitess/go/vt/proto/query"
vitess "github.com/dolthub/vitess/go/vt/sqlparser"

_ "github.com/dolthub/doltgresql/server/cast"
"github.com/dolthub/doltgresql/server/functions/framework"
pgtypes "github.com/dolthub/doltgresql/server/types"
)
Expand Down
1 change: 0 additions & 1 deletion server/expression/unary_operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
vitess "github.com/dolthub/vitess/go/vt/sqlparser"

"github.com/dolthub/doltgresql/server/functions/framework"
_ "github.com/dolthub/doltgresql/server/functions/unary"
)

// UnaryOperator represents a VALUE OPERATOR VALUE expression.
Expand Down
4 changes: 2 additions & 2 deletions server/functions/abs.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"github.com/dolthub/doltgresql/utils"
)

// init registers the functions to the catalog.
func init() {
// initAbs registers the functions to the catalog.
func initAbs() {
framework.RegisterFunction(abs_int16)
framework.RegisterFunction(abs_int32)
framework.RegisterFunction(abs_int64)
Expand Down
4 changes: 2 additions & 2 deletions server/functions/acos.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
pgtypes "github.com/dolthub/doltgresql/server/types"
)

// init registers the functions to the catalog.
func init() {
// initAcos registers the functions to the catalog.
func initAcos() {
framework.RegisterFunction(acos_float64)
}

Expand Down
4 changes: 2 additions & 2 deletions server/functions/acosd.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
pgtypes "github.com/dolthub/doltgresql/server/types"
)

// init registers the functions to the catalog.
func init() {
// initAcosd registers the functions to the catalog.
func initAcosd() {
framework.RegisterFunction(acosd_float64)
}

Expand Down
4 changes: 2 additions & 2 deletions server/functions/acosh.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
pgtypes "github.com/dolthub/doltgresql/server/types"
)

// init registers the functions to the catalog.
func init() {
// initAcosh registers the functions to the catalog.
func initAcosh() {
framework.RegisterFunction(acosh_float64)
}

Expand Down
4 changes: 2 additions & 2 deletions server/functions/ascii.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (
pgtypes "github.com/dolthub/doltgresql/server/types"
)

// init registers the functions to the catalog.
func init() {
// initAscii registers the functions to the catalog.
func initAscii() {
framework.RegisterFunction(ascii_varchar)
}

Expand Down
4 changes: 2 additions & 2 deletions server/functions/asin.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
pgtypes "github.com/dolthub/doltgresql/server/types"
)

// init registers the functions to the catalog.
func init() {
// initAsin registers the functions to the catalog.
func initAsin() {
framework.RegisterFunction(asin_float64)
}

Expand Down
4 changes: 2 additions & 2 deletions server/functions/asind.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
pgtypes "github.com/dolthub/doltgresql/server/types"
)

// init registers the functions to the catalog.
func init() {
// initAsind registers the functions to the catalog.
func initAsind() {
framework.RegisterFunction(asind_float64)
}

Expand Down
4 changes: 2 additions & 2 deletions server/functions/asinh.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
pgtypes "github.com/dolthub/doltgresql/server/types"
)

// init registers the functions to the catalog.
func init() {
// initAsinh registers the functions to the catalog.
func initAsinh() {
framework.RegisterFunction(asinh_float64)
}

Expand Down
4 changes: 2 additions & 2 deletions server/functions/atan.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
pgtypes "github.com/dolthub/doltgresql/server/types"
)

// init registers the functions to the catalog.
func init() {
// initAtan registers the functions to the catalog.
func initAtan() {
framework.RegisterFunction(atan_float64)
}

Expand Down
4 changes: 2 additions & 2 deletions server/functions/atan2.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
pgtypes "github.com/dolthub/doltgresql/server/types"
)

// init registers the functions to the catalog.
func init() {
// initAtan2 registers the functions to the catalog.
func initAtan2() {
framework.RegisterFunction(atan2_float64)
}

Expand Down
4 changes: 2 additions & 2 deletions server/functions/atan2d.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
pgtypes "github.com/dolthub/doltgresql/server/types"
)

// init registers the functions to the catalog.
func init() {
// initAtan2d registers the functions to the catalog.
func initAtan2d() {
framework.RegisterFunction(atan2d_float64)
}

Expand Down
4 changes: 2 additions & 2 deletions server/functions/atand.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
pgtypes "github.com/dolthub/doltgresql/server/types"
)

// init registers the functions to the catalog.
func init() {
// initAtand registers the functions to the catalog.
func initAtand() {
framework.RegisterFunction(atand_float64)
}

Expand Down
4 changes: 2 additions & 2 deletions server/functions/atanh.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
pgtypes "github.com/dolthub/doltgresql/server/types"
)

// init registers the functions to the catalog.
func init() {
// initAtanh registers the functions to the catalog.
func initAtanh() {
framework.RegisterFunction(atanh_float64)
}

Expand Down
4 changes: 2 additions & 2 deletions server/functions/binary/bit_and.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
// These functions can be gathered using the following query from a Postgres 15 instance:
// SELECT * FROM pg_operator o WHERE o.oprname = '&' ORDER BY o.oprcode::varchar;

// init registers the functions to the catalog.
func init() {
// InitBinaryBitAnd registers the functions to the catalog.
func InitBinaryBitAnd() {
framework.RegisterBinaryFunction(framework.Operator_BinaryBitAnd, int2and)
framework.RegisterBinaryFunction(framework.Operator_BinaryBitAnd, int4and)
framework.RegisterBinaryFunction(framework.Operator_BinaryBitAnd, int8and)
Expand Down
4 changes: 2 additions & 2 deletions server/functions/binary/bit_or.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
// These functions can be gathered using the following query from a Postgres 15 instance:
// SELECT * FROM pg_operator o WHERE o.oprname = '|' ORDER BY o.oprcode::varchar;

// init registers the functions to the catalog.
func init() {
// initBinaryBitOr registers the functions to the catalog.
func initBinaryBitOr() {
framework.RegisterBinaryFunction(framework.Operator_BinaryBitOr, int2or)
framework.RegisterBinaryFunction(framework.Operator_BinaryBitOr, int4or)
framework.RegisterBinaryFunction(framework.Operator_BinaryBitOr, int8or)
Expand Down
4 changes: 2 additions & 2 deletions server/functions/binary/bit_xor.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
// These functions can be gathered using the following query from a Postgres 15 instance:
// SELECT * FROM pg_operator o WHERE o.oprname = '#' ORDER BY o.oprcode::varchar;

// init registers the functions to the catalog.
func init() {
// initBinaryBitXor registers the functions to the catalog.
func initBinaryBitXor() {
framework.RegisterBinaryFunction(framework.Operator_BinaryBitXor, int2xor)
framework.RegisterBinaryFunction(framework.Operator_BinaryBitXor, int4xor)
framework.RegisterBinaryFunction(framework.Operator_BinaryBitXor, int8xor)
Expand Down
4 changes: 2 additions & 2 deletions server/functions/binary/divide.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
// These functions can be gathered using the following query from a Postgres 15 instance:
// SELECT * FROM pg_operator o WHERE o.oprname = '/' ORDER BY o.oprcode::varchar;

// init registers the functions to the catalog.
func init() {
// initBinaryDivide registers the functions to the catalog.
func initBinaryDivide() {
framework.RegisterBinaryFunction(framework.Operator_BinaryDivide, float4div)
framework.RegisterBinaryFunction(framework.Operator_BinaryDivide, float48div)
framework.RegisterBinaryFunction(framework.Operator_BinaryDivide, float8div)
Expand Down
Loading

0 comments on commit b7f4ff1

Please sign in to comment.