Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/2024 09 added connection test #299

Merged
merged 33 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
deb67a8
Fixed getProcedures function
takapi327 Sep 21, 2024
ba01bbd
Fixed getSchema function
takapi327 Sep 21, 2024
0d57abc
Change databaseTerm default value
takapi327 Sep 21, 2024
6150a2a
Update comment
takapi327 Sep 21, 2024
2e1849d
Update StringHelper
takapi327 Sep 23, 2024
7b503cf
Create StringInspector util class
takapi327 Sep 23, 2024
1596f9e
Create SearchMode Enum
takapi327 Sep 23, 2024
e132286
Added split function in StringHelper
takapi327 Sep 23, 2024
18ce5c1
Change use boundary in StringInspector incrementPosition
takapi327 Sep 23, 2024
43cb3a3
Bug fix StringHelper infinite loop
takapi327 Sep 23, 2024
7b16ad7
Change getProcedureColumns function logic
takapi327 Sep 23, 2024
2374a1f
Added Vector type
takapi327 Sep 25, 2024
040e765
Fixed bug DatabaseMetaDataImpl
takapi327 Sep 25, 2024
35f10ad
Create DatabaseMetaDataTest
takapi327 Sep 25, 2024
abf596f
Delete unused
takapi327 Sep 25, 2024
9ace7d0
Action sbt scalafmtAll
takapi327 Sep 25, 2024
5a55f3d
Delete unused
takapi327 Sep 25, 2024
6dec83e
Fixed connector ConnectionTest
takapi327 Sep 25, 2024
016b349
Delete unused
takapi327 Sep 25, 2024
6458bdb
Fixed get{Schema|Catalog} function logic
takapi327 Sep 25, 2024
5bcfa8f
Fixed connector ConnectionTest
takapi327 Sep 25, 2024
18b8f0b
Fixed DatabaseMetaDataTest
takapi327 Sep 25, 2024
242fdf5
Fixed DatabaseMetaDataTest
takapi327 Sep 25, 2024
12b2e5e
Added VECTOR match case
takapi327 Sep 26, 2024
ab13af7
Fixed getTypeInfo
takapi327 Sep 26, 2024
6ba8ee6
Fixed getTablePrivileges function logic
takapi327 Sep 26, 2024
ba118dd
Added hasWildcards function
takapi327 Sep 26, 2024
9f20a2d
Fixed getColumns
takapi327 Sep 26, 2024
bbfbedc
Create ConnectionTest
takapi327 Sep 26, 2024
1576fb4
Action sbt scalafmtAll
takapi327 Sep 26, 2024
831b129
Fixed connector ConnectionTest
takapi327 Sep 26, 2024
daad311
Action sbt scalafmtAll
takapi327 Sep 26, 2024
f4b624c
Change use StringHelper
takapi327 Sep 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ object Connection:
socketOptions: List[SocketOption] = defaultSocketOptions,
readTimeout: Duration = Duration.Inf,
allowPublicKeyRetrieval: Boolean = false,
databaseTerm: Option[DatabaseMetaData.DatabaseTerm] = None
databaseTerm: Option[DatabaseMetaData.DatabaseTerm] = Some(DatabaseMetaData.DatabaseTerm.CATALOG)
): Tracer[F] ?=> Resource[F, LdbcConnection[F]] =

val logger: String => F[Unit] = s => Console[F].println(s"TLS: $s")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private[ldbc] case class ConnectionImpl[F[_]: Temporal: Tracer: Console: Exchang
readOnly: Ref[F, Boolean],
isAutoCommit: Ref[F, Boolean],
connectionClosed: Ref[F, Boolean],
databaseTerm: Option[DatabaseMetaData.DatabaseTerm] = None
databaseTerm: Option[DatabaseMetaData.DatabaseTerm] = Some(DatabaseMetaData.DatabaseTerm.CATALOG)
)(using ev: MonadError[F, Throwable])
extends LdbcConnection[F]:

Expand Down Expand Up @@ -115,8 +115,12 @@ private[ldbc] case class ConnectionImpl[F[_]: Temporal: Tracer: Console: Exchang
else ev.unit

override def getCatalog(): F[String] =
if databaseTerm.contains(DatabaseMetaData.DatabaseTerm.CATALOG) then getSchema()
else ev.pure("")
if databaseTerm.contains(DatabaseMetaData.DatabaseTerm.CATALOG) then
for
statement <- createStatement()
result <- statement.executeQuery("SELECT DATABASE()")
yield Option(result.getString(1)).getOrElse("")
else ev.pure(null)

override def setTransactionIsolation(level: Int): F[Unit] =
level match
Expand Down Expand Up @@ -484,10 +488,12 @@ private[ldbc] case class ConnectionImpl[F[_]: Temporal: Tracer: Console: Exchang
override def setSchema(schema: String): F[Unit] = protocol.resetSequenceId *> protocol.comInitDB(schema)

override def getSchema(): F[String] =
for
statement <- createStatement()
result <- statement.executeQuery("SELECT DATABASE()")
yield Option(result.getString(1)).getOrElse("")
if databaseTerm.contains(DatabaseMetaData.DatabaseTerm.SCHEMA) then
for
statement <- createStatement()
result <- statement.executeQuery("SELECT DATABASE()")
yield Option(result.getString(1)).getOrElse("")
else ev.pure(null)

override def getStatistics: F[StatisticsPacket] = protocol.resetSequenceId *> protocol.comStatistics()

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,15 @@ enum MysqlType(
*/
case GEOMETRY extends MysqlType("GEOMETRY", Types.BINARY, 0, MysqlTypeVariables.IS_NOT_DECIMAL, 65535L, "")

/**
* VECTOR[(M)]
* A VECTOR column with a maximum length of 65,532 (16383 x 4) bytes. An optional length M can be given for this type to indicate the maximum number of
* entries in a VECTOR. M cannot exceed 16383. Each entry is a 4 Byte (single-precision) floating-point value.
*
* Protocol: FIELD_TYPE_VECTOR = 242
*/
case VECTOR extends MysqlType("VECTOR", Types.LONGVARBINARY, 0, MysqlTypeVariables.IS_NOT_DECIMAL, 65532L, "[(M)]")

/**
* Fall-back type for those MySQL data types which c/J can't recognize.
* Handled the same as BLOB.
Expand Down Expand Up @@ -689,6 +698,7 @@ object MysqlType:
case name if name.contains("BLOB") => MysqlType.BLOB
case name if name.contains("TEXT") => MysqlType.TEXT
case name if name.contains("GEOM") | name.contains("POINT") | name.contains("POLYGON") => MysqlType.GEOMETRY
case name if name.contains("VECTOR") => MysqlType.VECTOR
case _ => MysqlType.UNKNOWN

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,14 @@ object StringHelper:
def getUniqueSavepointId: String =
val uuid = UUID.randomUUID().toString
uuid.replaceAll("-", "_")

/**
* Does the string contain wildcard symbols ('%' or '_'). Used in DatabaseMetaData.
*
* @param src
* string
* @return
* true if src contains wildcard symbols
*/
def hasWildcards(src: String): Boolean =
indexOfIgnoreCase(0, src, "%") != -1 || indexOfIgnoreCase(0, src, "_") != -1

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,7 @@ trait DatabaseMetaData[F[_]]:
* Only procedure descriptions matching the schema and
* procedure name criteria are returned. They are ordered by
* <code>PROCEDURE_CAT</code>, <code>PROCEDURE_SCHEM</code>,
* <code>PROCEDURE_NAME</code> and <code>SPECIFIC_ NAME</code>.
* <code>PROCEDURE_NAME</code> and <code>SPECIFIC_NAME</code>.
*
* <P>Each procedure description has the following columns:
* <OL>
Expand Down
Loading