go.temporal.io/server/tools/sql/conn.go

110 LOC · 44 covered · 66 uncovered · 16 ranges · 55 concepts · 4 introducers · 27 tests

File neighbourhood

The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the related-file, concept, and source links on this page.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the filego.temporal.io/server/tools/sql/clitest/conn_tests.go · 96 LOCclitest/conn_tests.gogo.temporal.io/server/tools/sql/handler.go · 182 LOCsql/handler.gogo.temporal.io/server/tools/sql/main.go · 222 LOCsql/main.goTestVisibilityDryrun · 0 introduced LOCTestVisibilityDryrunTestVisibilityDryrun · 0 introduced LOCTestVisibilityDryrunquery_util.go ×3 · 6 introduced LOCquery_util.go ×3TestUpdateSchema · 0 introduced LOCTestUpdateSchemaTestUpdateSchema · 0 introduced LOCTestUpdateSchemaTestUpdateSchema · 0 introduced LOCTestUpdateSchemaTestDryrun · 0 introduced LOCTestDryrunTestVisibilityDryrun · 0 introduced LOCTestVisibilityDryrunTestDryrun · 0 introduced LOCTestDryrunTestDryrun · 0 introduced LOCTestDryrunTestVerifyCompatibleVersion · 0 introduced LOCTestVerifyCompatibleVers…update_task_tests.go ×1 · 6 introduced LOCupdate_task_tests.go ×1TestVerifyCompatibleVersion · 0 introduced LOCTestVerifyCompatibleVers…db.go ×2 · 6 introduced LOCdb.go ×2update_task_tests.go ×1 · 8 introduced LOCupdate_task_tests.go ×1TestSetupSchema · 0 introduced LOCTestSetupSchemaupdate_task_tests.go ×1 · 8 introduced LOCupdate_task_tests.go ×1TestSetupSchema · 0 introduced LOCTestSetupSchemaupdate_task_tests.go ×4 · 37 introduced LOCupdate_task_tests.go ×4TestSetupSchema · 0 introduced LOCTestSetupSchemadb.go ×2 · 6 introduced LOCdb.go ×2setuptest.go ×1 · 11 introduced LOCsetuptest.go ×1version_tests.go ×4 · 78 introduced LOCversion_tests.go ×4dbtest.go ×4 · 8 introduced LOCdbtest.go ×4handler.go ×4 · 13 introduced LOChandler.go ×4pgx.go ×1 · 4 introduced LOCpgx.go ×1pq.go ×1 · 4 introduced LOCpq.go ×1TestCreateDatabase · 0 introduced LOCTestCreateDatabaseTestCreateDatabase · 0 introduced LOCTestCreateDatabaseTestCreateDatabaseIdempotent · 0 introduced LOCTestCreateDatabaseIdempo…admin.go ×1 · 6 introduced LOCadmin.go ×1TestCreateDatabase · 0 introduced LOCTestCreateDatabaseTestSQLConn · 0 introduced LOCTestSQLConnTestParseCQLFile · 0 introduced LOCTestParseCQLFileTestSQLConn · 0 introduced LOCTestSQLConnTestSQLConn · 0 introduced LOCTestSQLConnTestParseCQLFile · 0 introduced LOCTestParseCQLFileTestParseCQLFile · 0 introduced LOCTestParseCQLFileadmin.go ×1 · 3 introduced LOCadmin.go ×1admin.go ×4 · 12 introduced LOCadmin.go ×4admin.go ×1 · 3 introduced LOCadmin.go ×1admin.go ×3 · 16 introduced LOCadmin.go ×3setup_task_tests.go ×1 · 16 introduced LOCsetup_task_tests.go ×1setup_task_tests.go ×1 · 29 introduced LOCsetup_task_tests.go ×1handler.go ×5 · 17 introduced LOChandler.go ×5session.go ×1 · 2 introduced LOCsession.go ×1conn_tests.go ×1 · 3 introduced LOCconn_tests.go ×1setup_task_tests.go ×4 · 21 introduced LOCsetup_task_tests.go ×4main.go ×1 · 4 introduced LOCmain.go ×1handler.go ×4 · 141 introduced LOChandler.go ×4conn_tests.go ×1 · 8 introduced LOCconn_tests.go ×1conn.go ×2 · 4 introduced LOCconn.go ×2conn.go ×8 · 20 introduced LOCconn.go ×8conn_tests.go ×5 · 18 introduced LOCconn_tests.go ×5conn.go ×5 · 27 introduced LOCconn.go ×5TestParseCQLFile · introduced test · go.temporal.io/server/tools/tests/TestMySQLConnTestSuite/TestParseCQLFileTestParseCQLFileTestSQLConn · introduced test · go.temporal.io/server/tools/tests/TestMySQLConnTestSuite/TestSQLConnTestSQLConnTestCreateDatabase · introduced test · go.temporal.io/server/tools/tests/TestMySQLSetupSchemaTestSuite/TestCreateDatabaseTestCreateDatabaseTestCreateDatabaseIdempotent · introduced test · go.temporal.io/server/tools/tests/TestMySQLSetupSchemaTestSuite/TestCreateDatabaseIdempotentTestCreateDatabaseIdempo…TestSetupSchema · introduced test · go.temporal.io/server/tools/tests/TestMySQLSetupSchemaTestSuite/TestSetupSchemaTestSetupSchemaTestDryrun · introduced test · go.temporal.io/server/tools/tests/TestMySQLUpdateSchemaTestSuite/TestDryrunTestDryrunTestUpdateSchema · introduced test · go.temporal.io/server/tools/tests/TestMySQLUpdateSchemaTestSuite/TestUpdateSchemaTestUpdateSchemaTestVisibilityDryrun · introduced test · go.temporal.io/server/tools/tests/TestMySQLUpdateSchemaTestSuite/TestVisibilityDryrunTestVisibilityDryrunTestVerifyCompatibleVersion · introduced test · go.temporal.io/server/tools/tests/TestMySQLVersionTestSuite/TestVerifyCompatibleVersionTestVerifyCompatibleVers…TestParseCQLFile · introduced test · go.temporal.io/server/tools/tests/TestPostgres/TestPostgreSQLConnTestSuite/TestParseCQLFileTestParseCQLFileTestSQLConn · introduced test · go.temporal.io/server/tools/tests/TestPostgres/TestPostgreSQLConnTestSuite/TestSQLConnTestSQLConnTestCreateDatabase · introduced test · go.temporal.io/server/tools/tests/TestPostgres/TestPostgreSQLSetupSchemaTestSuite/TestCreateDatabaseTestCreateDatabaseTestCreateDatabaseIdempotent · introduced test · go.temporal.io/server/tools/tests/TestPostgres/TestPostgreSQLSetupSchemaTestSuite/TestCreateDatabaseIdempotentTestCreateDatabaseIdempo…TestSetupSchema · introduced test · go.temporal.io/server/tools/tests/TestPostgres/TestPostgreSQLSetupSchemaTestSuite/TestSetupSchemaTestSetupSchemaTestDryrun · introduced test · go.temporal.io/server/tools/tests/TestPostgres/TestPostgreSQLUpdateSchemaTestSuite/TestDryrunTestDryrunTestUpdateSchema · introduced test · go.temporal.io/server/tools/tests/TestPostgres/TestPostgreSQLUpdateSchemaTestSuite/TestUpdateSchemaTestUpdateSchemaTestVisibilityDryrun · introduced test · go.temporal.io/server/tools/tests/TestPostgres/TestPostgreSQLUpdateSchemaTestSuite/TestVisibilityDryrunTestVisibilityDryrunTestVerifyCompatibleVersion · introduced test · go.temporal.io/server/tools/tests/TestPostgres/TestPostgreSQLVersionTestSuite/TestVerifyCompatibleVersionTestVerifyCompatibleVers…TestParseCQLFile · introduced test · go.temporal.io/server/tools/tests/TestPostgresPGX/TestPostgreSQLConnTestSuite/TestParseCQLFileTestParseCQLFileTestSQLConn · introduced test · go.temporal.io/server/tools/tests/TestPostgresPGX/TestPostgreSQLConnTestSuite/TestSQLConnTestSQLConnTestCreateDatabase · introduced test · go.temporal.io/server/tools/tests/TestPostgresPGX/TestPostgreSQLSetupSchemaTestSuite/TestCreateDatabaseTestCreateDatabaseTestCreateDatabaseIdempotent · introduced test · go.temporal.io/server/tools/tests/TestPostgresPGX/TestPostgreSQLSetupSchemaTestSuite/TestCreateDatabaseIdempotentTestCreateDatabaseIdempo…TestSetupSchema · introduced test · go.temporal.io/server/tools/tests/TestPostgresPGX/TestPostgreSQLSetupSchemaTestSuite/TestSetupSchemaTestSetupSchemaTestDryrun · introduced test · go.temporal.io/server/tools/tests/TestPostgresPGX/TestPostgreSQLUpdateSchemaTestSuite/TestDryrunTestDryrunTestUpdateSchema · introduced test · go.temporal.io/server/tools/tests/TestPostgresPGX/TestPostgreSQLUpdateSchemaTestSuite/TestUpdateSchemaTestUpdateSchemaTestVisibilityDryrun · introduced test · go.temporal.io/server/tools/tests/TestPostgresPGX/TestPostgreSQLUpdateSchemaTestSuite/TestVisibilityDryrunTestVisibilityDryrunTestVerifyCompatibleVersion · introduced test · go.temporal.io/server/tools/tests/TestPostgresPGX/TestPostgreSQLVersionTestSuite/TestVerifyCompatibleVersionTestVerifyCompatibleVers…Focused file · go.temporal.io/server/tools/sql/conn.go · 110 LOCsql/conn.go

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.

1 package sql
2
3 import (
4 "go.temporal.io/server/common/config"
5 "go.temporal.io/server/common/log"
6 "go.temporal.io/server/common/metrics"
7 "go.temporal.io/server/common/persistence/sql"
8 "go.temporal.io/server/common/persistence/sql/sqlplugin"
9 "go.temporal.io/server/common/resolver"
10 "go.temporal.io/server/tools/common/schema"
11 )
12
13 type (
14 // Connection is the connection to database
15 Connection struct {
16 dbName string
17 adminDb sqlplugin.AdminDB
18 }
19 )
20
21 const dbType = "sql"
22
23 var _ schema.DB = (*Connection)(nil)
24
25 // NewConnection creates a new connection to database
26 > func NewConnection(cfg *config.SQL, logger log.Logger) (*Connection, error) { conn.go ×5
27 > db, err := sql.NewSQLAdminDB(sqlplugin.DbKindUnknown, cfg, resolver.NewNoopResolver(), logger, metrics.NoopMetricsHandler)
28 > if err != nil {
29 return nil, err
30 }
31
32 > return &Connection{ conn.go ×5
33 > adminDb: db,
34 > dbName: cfg.DatabaseName,
35 > }, nil
36 }
37
38 // CreateSchemaVersionTables sets up the schema version tables
39 > func (c *Connection) CreateSchemaVersionTables() error { conn.go ×8
40 > return c.adminDb.CreateSchemaVersionTables()
41 > }
42
43 // ReadSchemaVersion returns the current schema version for the keyspace
44 > func (c *Connection) ReadSchemaVersion() (string, error) { conn.go ×8
45 > return c.adminDb.ReadSchemaVersion(c.dbName)
46 > }
47
48 // UpdateSchemaVersion updates the schema version for the keyspace
49 > func (c *Connection) UpdateSchemaVersion(newVersion string, minCompatibleVersion string) error { conn.go ×8
50 > return c.adminDb.UpdateSchemaVersion(c.dbName, newVersion, minCompatibleVersion)
51 > }
52
53 // WriteSchemaUpdateLog adds an entry to the schema update history table
54 > func (c *Connection) WriteSchemaUpdateLog(oldVersion string, newVersion string, manifestMD5 string, desc string) error { conn.go ×8
55 > return c.adminDb.WriteSchemaUpdateLog(oldVersion, newVersion, manifestMD5, desc)
56 > }
57
58 // Exec executes a sql statement
59 > func (c *Connection) Exec(stmt string, args ...any) error { handler.go ×4
60 > return c.adminDb.Exec(stmt, args...)
61 > }
62
63 // ListTables returns a list of tables in this database
64 > func (c *Connection) ListTables() ([]string, error) { conn.go ×8
65 > return c.adminDb.ListTables(c.dbName)
66 > }
67
68 // DropTable drops a given table from the database
69 > func (c *Connection) DropTable(name string) error { conn.go ×2
70 > return c.adminDb.DropTable(name)
71 > }
72
73 // DropAllTables drops all tables from this database
74 > func (c *Connection) DropAllTables() error { conn.go ×8
75 > tables, err := c.ListTables()
76 > if err != nil {
77 return err
78 }
79 > for _, tab := range tables { conn.go ×8
80 > if err := c.DropTable(tab); err != nil { conn.go ×2
81 return err
82 }
83 }
84 > return nil conn.go ×8
85 }
86
87 // CreateDatabase creates a database if it doesn't exist
88 > func (c *Connection) CreateDatabase(name string) error { conn.go ×5
89 > return c.adminDb.CreateDatabase(name)
90 > }
91
92 // DropDatabase drops a database
93 > func (c *Connection) DropDatabase(name string) error { conn.go ×5
94 > return c.adminDb.DropDatabase(name)
95 > }
96
97 // Close closes the sql client
98 > func (c *Connection) Close() { conn.go ×5
99 > if c.adminDb != nil {
100 > err := c.adminDb.Close()
101 > if err != nil {
102 panic("cannot close connection")
103 }
104 }
105 }
106
107 // Type gives the type of db
108 func (c *Connection) Type() string {
109 return dbType
110 }