Files
2026-07-13 12:32:25 +08:00

76 lines
2.6 KiB
Go

// 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 initialization
import (
"sync"
"github.com/dolthub/dolt/go/libraries/doltcore/env"
"github.com/dolthub/dolt/go/libraries/doltcore/servercfg"
"github.com/dolthub/go-mysql-server/sql"
"github.com/dolthub/doltgresql/core"
"github.com/dolthub/doltgresql/core/casts"
"github.com/dolthub/doltgresql/core/rootobject"
"github.com/dolthub/doltgresql/server/analyzer"
"github.com/dolthub/doltgresql/server/ast"
"github.com/dolthub/doltgresql/server/auth"
"github.com/dolthub/doltgresql/server/cast"
"github.com/dolthub/doltgresql/server/config"
"github.com/dolthub/doltgresql/server/functions"
"github.com/dolthub/doltgresql/server/functions/aggregate"
"github.com/dolthub/doltgresql/server/functions/binary"
"github.com/dolthub/doltgresql/server/functions/framework"
"github.com/dolthub/doltgresql/server/functions/unary"
"github.com/dolthub/doltgresql/server/tables"
"github.com/dolthub/doltgresql/server/tables/dtables"
"github.com/dolthub/doltgresql/server/tables/information_schema"
"github.com/dolthub/doltgresql/server/tables/pgcatalog"
pgtypes "github.com/dolthub/doltgresql/server/types"
doltgresservercfg "github.com/dolthub/doltgresql/servercfg"
"github.com/dolthub/doltgresql/servercfg/cfgdetails"
)
var once = &sync.Once{}
// Initialize initializes each package across the project. This function should be used instead of an init() function.
func Initialize(dEnv *env.DoltEnv, cfg *doltgresservercfg.DoltgresConfig) {
once.Do(func() {
core.Init()
rootobject.Init()
auth.Init(dEnv, cfg)
pgtypes.Init()
analyzer.Init()
config.Init()
binary.Init()
unary.Init()
functions.Init()
aggregate.Init()
builtInCasts := casts.Init(core.GetRunnerFromContext, func(f sql.Expression) bool {
if cf, ok := f.(*framework.CompiledFunction); ok {
return cf.IsStrict()
}
return false
}, &framework.FunctionProvider{})
cast.Init(builtInCasts)
framework.Initialize(ast.Convert)
servercfg.DefaultUnixSocketFilePath = cfgdetails.DefaultPostgresUnixSocketFilePath
tables.Init()
pgcatalog.Init()
information_schema.Init()
dtables.Init()
})
}