├── project
├── build.properties
└── plugins.sbt
├── version.sbt
├── codecov.yml
├── .gitignore
├── .scalafmt.conf
├── rdbc-pgsql-core
└── src
│ ├── test
│ ├── resources
│ │ └── logback.xml
│ └── scala
│ │ └── io
│ │ └── rdbc
│ │ └── pgsql
│ │ └── core
│ │ └── RdbcPgsqlCoreSpec.scala
│ └── main
│ ├── scala
│ └── io
│ │ └── rdbc
│ │ └── pgsql
│ │ └── core
│ │ ├── Oid.scala
│ │ ├── internal
│ │ ├── protocol
│ │ │ ├── messages
│ │ │ │ ├── PgMessage.scala
│ │ │ │ ├── backend
│ │ │ │ │ ├── NoData.scala
│ │ │ │ │ ├── MsgHeader.scala
│ │ │ │ │ ├── BindComplete.scala
│ │ │ │ │ ├── CloseComplete.scala
│ │ │ │ │ ├── ParseComplete.scala
│ │ │ │ │ ├── PortalSuspended.scala
│ │ │ │ │ ├── auth
│ │ │ │ │ │ ├── AuthOk.scala
│ │ │ │ │ │ ├── AuthRequest.scala
│ │ │ │ │ │ ├── AuthRequestCleartext.scala
│ │ │ │ │ │ ├── AuthBackendMessage.scala
│ │ │ │ │ │ └── AuthRequestMd5.scala
│ │ │ │ │ ├── EmptyQueryResponse.scala
│ │ │ │ │ ├── PgBackendMessage.scala
│ │ │ │ │ ├── NotificationResponse.scala
│ │ │ │ │ ├── DataRow.scala
│ │ │ │ │ ├── ParameterDescription.scala
│ │ │ │ │ ├── ReadyForQuery.scala
│ │ │ │ │ ├── BackendKeyData.scala
│ │ │ │ │ ├── ParameterStatus.scala
│ │ │ │ │ ├── RowDescription.scala
│ │ │ │ │ ├── CommandComplete.scala
│ │ │ │ │ └── UnknownBackendMessage.scala
│ │ │ │ └── frontend
│ │ │ │ │ ├── Flush.scala
│ │ │ │ │ ├── Sync.scala
│ │ │ │ │ ├── Terminate.scala
│ │ │ │ │ ├── Query.scala
│ │ │ │ │ ├── ClosePortal.scala
│ │ │ │ │ ├── CloseStatement.scala
│ │ │ │ │ ├── PgFrontendMessage.scala
│ │ │ │ │ ├── Execute.scala
│ │ │ │ │ ├── Startup.scala
│ │ │ │ │ ├── CancelRequest.scala
│ │ │ │ │ ├── Describe.scala
│ │ │ │ │ ├── Parse.scala
│ │ │ │ │ ├── package.scala
│ │ │ │ │ └── Bind.scala
│ │ │ ├── codec
│ │ │ │ ├── DecodedMessage.scala
│ │ │ │ ├── MessageEncoder.scala
│ │ │ │ ├── sco
│ │ │ │ │ ├── ScodecMessageDecoderFactory.scala
│ │ │ │ │ └── ScodecMessageEncoderFactory.scala
│ │ │ │ ├── MessageDecoderFactory.scala
│ │ │ │ ├── MessageEncoderFactory.scala
│ │ │ │ └── MessageDecoder.scala
│ │ │ ├── ColFormat.scala
│ │ │ ├── TxStatus.scala
│ │ │ ├── ColValue.scala
│ │ │ ├── DataType.scala
│ │ │ ├── ReturnColFormats.scala
│ │ │ ├── ColDesc.scala
│ │ │ └── Argument.scala
│ │ ├── fsm
│ │ │ ├── Uninitialized.scala
│ │ │ ├── StartingRequest.scala
│ │ │ ├── WaitingForNextBatch.scala
│ │ │ ├── Idle.scala
│ │ │ ├── DefaultErrorHandling.scala
│ │ │ ├── streaming
│ │ │ │ └── StrmWaitingForSubscriber.scala
│ │ │ ├── ConnectionClosed.scala
│ │ │ ├── EmptyState.scala
│ │ │ ├── IgnoringState.scala
│ │ │ ├── NonFatalErrorsAreFatal.scala
│ │ │ └── WaitingForReady.scala
│ │ ├── FatalErrorHandler.scala
│ │ ├── WriteFailureHandler.scala
│ │ ├── typecodec
│ │ │ └── sco
│ │ │ │ ├── ScodecPgCharCodec.scala
│ │ │ │ ├── ScodecPgTextCodec.scala
│ │ │ │ ├── ScodecPgVarcharCodec.scala
│ │ │ │ ├── ScodecPgInt4Codec.scala
│ │ │ │ ├── ScodecPgInt8Codec.scala
│ │ │ │ ├── ScodecPgUuidCodec.scala
│ │ │ │ ├── ScodecPgInt2Codec.scala
│ │ │ │ ├── ScodecPgByteaCodec.scala
│ │ │ │ ├── ScodecPgFloat4Codec.scala
│ │ │ │ ├── ScodecPgFloat8Codec.scala
│ │ │ │ ├── IgnoreSessionParams.scala
│ │ │ │ ├── ScodecPgBoolCodec.scala
│ │ │ │ ├── ScodecStringLikeCodec.scala
│ │ │ │ └── package.scala
│ │ ├── typeconv
│ │ │ ├── extractors
│ │ │ │ ├── CharVal.scala
│ │ │ │ ├── ByteVal.scala
│ │ │ │ ├── UuidVal.scala
│ │ │ │ ├── InstantVal.scala
│ │ │ │ ├── ByteArrayVal.scala
│ │ │ │ ├── ZonedDateTimeVal.scala
│ │ │ │ ├── ByteVectorVal.scala
│ │ │ │ ├── LongVal.scala
│ │ │ │ ├── IntVal.scala
│ │ │ │ ├── BoolVal.scala
│ │ │ │ ├── DoubleVal.scala
│ │ │ │ ├── ShortVal.scala
│ │ │ │ ├── LocalDateTimeVal.scala
│ │ │ │ ├── OffsetDateTimeVal.scala
│ │ │ │ ├── LocalTimeVal.scala
│ │ │ │ ├── LocalDateVal.scala
│ │ │ │ └── FloatVal.scala
│ │ │ ├── StringTypeConverter.scala
│ │ │ ├── javaconv
│ │ │ │ ├── JavaByteTypeConverter.scala
│ │ │ │ ├── JavaLongTypeConverter.scala
│ │ │ │ ├── JavaDoubleTypeConverter.scala
│ │ │ │ ├── JavaFloatTypeConverter.scala
│ │ │ │ ├── JavaShortTypeConverter.scala
│ │ │ │ ├── JavaBooleanTypeConverter.scala
│ │ │ │ ├── JavaIntegerTypeConverter.scala
│ │ │ │ └── JavaBigDecimalTypeConverter.scala
│ │ │ ├── pgvalconv
│ │ │ │ ├── PgBoolTypeConverter.scala
│ │ │ │ ├── PgInt4TypeConverter.scala
│ │ │ │ ├── PgInt8TypeConverter.scala
│ │ │ │ ├── PgUuidTypeConverter.scala
│ │ │ │ ├── PgCharTypeConverter.scala
│ │ │ │ ├── PgInt2TypeConverter.scala
│ │ │ │ ├── PgTextTypeConverter.scala
│ │ │ │ ├── PgDateTypeConverter.scala
│ │ │ │ ├── PgTimeTypeConverter.scala
│ │ │ │ ├── PgByteaTypeConverter.scala
│ │ │ │ ├── PgFloat4TypeConverter.scala
│ │ │ │ ├── PgFloat8TypeConverter.scala
│ │ │ │ ├── PgVarcharTypeConverter.scala
│ │ │ │ └── PgNumericTypeConverter.scala
│ │ │ ├── UuidTypeConverter.scala
│ │ │ ├── BigDecimalTypeConverter.scala
│ │ │ ├── LocalTimeTypeConverter.scala
│ │ │ ├── ByteArrTypeConverter.scala
│ │ │ ├── LocalDateTimeTypeConverter.scala
│ │ │ ├── InstantTypeConverter.scala
│ │ │ └── FloatTypeConverter.scala
│ │ ├── cache
│ │ │ └── StmtCache.scala
│ │ ├── PortalDescData.scala
│ │ └── BatchExecutor.scala
│ │ ├── types
│ │ ├── PgVal.scala
│ │ ├── package.scala
│ │ ├── PgType.scala
│ │ ├── PgInt4.scala
│ │ ├── PgInt8.scala
│ │ ├── PgBool.scala
│ │ ├── PgChar.scala
│ │ ├── PgInt2.scala
│ │ ├── PgText.scala
│ │ ├── PgFloat4.scala
│ │ ├── PgFloat8.scala
│ │ ├── PgVarchar.scala
│ │ ├── PgUuid.scala
│ │ ├── PgDate.scala
│ │ ├── PgTime.scala
│ │ ├── PgBytea.scala
│ │ ├── PgNumeric.scala
│ │ ├── PgTimestamp.scala
│ │ ├── PgUnknown.scala
│ │ ├── PgValCodec.scala
│ │ └── PgTimestampTz.scala
│ │ ├── typeconv
│ │ ├── PartialTypeConverter.scala
│ │ ├── package.scala
│ │ ├── TypeConverter.scala
│ │ ├── TypeMapping.scala
│ │ └── TypeMappingRegistry.scala
│ │ ├── exception
│ │ ├── PgDecodeException.scala
│ │ ├── PgEncodeException.scala
│ │ ├── PgSubscriptionRejectedException.scala
│ │ ├── PgChannelException.scala
│ │ ├── PgUnsupportedTypeException.scala
│ │ ├── PgTimeoutException.scala
│ │ ├── PgAuthFailureException.scala
│ │ ├── PgUnauthorizedException.scala
│ │ ├── PgUncategorizedStatusDataException.scala
│ │ ├── PgInvalidQueryException.scala
│ │ ├── PgProtocolViolationException.scala
│ │ ├── PgInvalidConfigException.scala
│ │ ├── PgUncategorizedException.scala
│ │ ├── PgUnsupportedClassException.scala
│ │ ├── PgDriverInternalErrorException.scala
│ │ ├── PgUnsupportedCharsetException.scala
│ │ └── PgConstraintViolationException.scala
│ │ ├── config
│ │ └── sapi
│ │ │ ├── StmtCacheConfig.scala
│ │ │ └── Auth.scala
│ │ ├── PgConnectionFactory.scala
│ │ ├── package.scala
│ │ ├── PgConnectionConfig.scala
│ │ └── SessionParams.scala
│ └── java
│ └── io
│ └── rdbc
│ └── pgsql
│ └── core
│ └── config
│ └── japi
│ └── Auth.java
├── rdbc-pgsql-transport-netty
└── src
│ ├── test
│ └── resources
│ │ └── logback.xml
│ └── main
│ └── scala
│ └── io
│ └── rdbc
│ └── pgsql
│ └── transport
│ └── netty
│ ├── japi
│ └── package.scala
│ └── sapi
│ ├── internal
│ └── Compat.scala
│ ├── NioChannelFactory.scala
│ └── ChannelOptionValue.scala
├── rdbc-pgsql-doc
└── docs
│ ├── css
│ └── extra.css
│ ├── developer.md
│ ├── java
│ └── java.md
│ ├── javascripts
│ └── extra.js
│ └── privacy.md
└── README.md
/project/build.properties:
--------------------------------------------------------------------------------
1 | sbt.version = 1.1.6
2 |
--------------------------------------------------------------------------------
/version.sbt:
--------------------------------------------------------------------------------
1 | version in ThisBuild := "0.4.0.2-SNAPSHOT"
2 |
--------------------------------------------------------------------------------
/codecov.yml:
--------------------------------------------------------------------------------
1 | ignore:
2 | - "rdbc-pgsql-doc"
3 | - "rdbc-pgsql-bench"
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /target
2 | /project/target
3 | /project/project
4 | /.idea
5 | /rdbc-pgsql*/target
6 | /rdbc-pgsql*/test-output
7 | /test-output
8 |
--------------------------------------------------------------------------------
/.scalafmt.conf:
--------------------------------------------------------------------------------
1 | style = default
2 | maxColumn = 120
3 | importSelectors = binPack
4 | includeCurlyBraceInSelectChains = false
5 | rewrite.rules = [SortImports]
6 | project.git = true
7 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/test/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | %date %msg%n
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/rdbc-pgsql-transport-netty/src/test/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | %date %msg%n
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/project/plugins.sbt:
--------------------------------------------------------------------------------
1 | addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.9.3")
2 | addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.1")
3 | addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.3.4")
4 | addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.0.0")
5 | addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.8")
6 | addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0")
7 | addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.1")
8 | addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0")
9 | addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.3.4")
10 |
--------------------------------------------------------------------------------
/rdbc-pgsql-doc/docs/css/extra.css:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2017 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | .md-typeset p {
17 | text-align: justify;
18 | }
19 |
--------------------------------------------------------------------------------
/rdbc-pgsql-doc/docs/developer.md:
--------------------------------------------------------------------------------
1 |
16 |
17 | Developer documentation is not ready yet.
18 |
--------------------------------------------------------------------------------
/rdbc-pgsql-doc/docs/java/java.md:
--------------------------------------------------------------------------------
1 |
16 |
17 | Java API is ready but not yet documented.
18 |
--------------------------------------------------------------------------------
/rdbc-pgsql-doc/docs/javascripts/extra.js:
--------------------------------------------------------------------------------
1 | (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
2 | (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
3 | m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
4 | })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
5 |
6 | var gaID = 'UA-103140141-1';
7 |
8 | ga('create', gaID, 'auto');
9 | ga('set', 'anonymizeIp', true);
10 | ga('send', 'pageview');
11 |
12 | function gaOptout() {
13 | var disableStr = 'ga-disable-' + gaID;
14 | document.cookie = disableStr + '=true; domain=' + window.location.hostname + '; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';
15 | window[disableStr] = true;
16 | }
17 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/Oid.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core
18 |
19 | final case class Oid(value: Long) extends AnyVal
20 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/messages/PgMessage.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.messages
18 |
19 | trait PgMessage
20 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/fsm/Uninitialized.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.fsm
18 |
19 | private[core] object Uninitialized extends EmptyState
20 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/fsm/StartingRequest.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.fsm
18 |
19 | private[core] object StartingRequest extends EmptyState
20 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/types/PgVal.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.types
18 |
19 | trait PgVal[T] {
20 | def typ: PgType[_ <: PgVal[T]]
21 |
22 | def value: T
23 | }
24 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/messages/backend/NoData.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.messages.backend
18 |
19 | object NoData extends PgBackendMessage
20 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/messages/frontend/Flush.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.messages.frontend
18 |
19 | case object Flush extends PgFrontendMessage
20 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/messages/frontend/Sync.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.messages.frontend
18 |
19 | case object Sync extends PgFrontendMessage
20 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/messages/backend/MsgHeader.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.messages.backend
18 |
19 | final case class MsgHeader(msgLength: Int)
20 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/fsm/WaitingForNextBatch.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.fsm
18 |
19 | private[core]
20 | final class WaitingForNextBatch private[fsm]() extends EmptyState
21 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/messages/frontend/Terminate.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.messages.frontend
18 |
19 | case object Terminate extends PgFrontendMessage
20 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/messages/backend/BindComplete.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.messages.backend
18 |
19 | case object BindComplete extends PgBackendMessage
20 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/messages/backend/CloseComplete.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.messages.backend
18 |
19 | case object CloseComplete extends PgBackendMessage
20 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/messages/backend/ParseComplete.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.messages.backend
18 |
19 | case object ParseComplete extends PgBackendMessage
20 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/messages/backend/PortalSuspended.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.messages.backend
18 |
19 | object PortalSuspended extends PgBackendMessage
20 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/messages/backend/auth/AuthOk.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.messages.backend.auth
18 |
19 | case object AuthOk extends AuthBackendMessage
20 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/messages/backend/EmptyQueryResponse.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.messages.backend
18 |
19 | object EmptyQueryResponse extends PgBackendMessage
20 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/messages/frontend/Query.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.messages.frontend
18 |
19 | case class Query(query: NativeSql) extends PgFrontendMessage
20 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/test/scala/io/rdbc/pgsql/core/RdbcPgsqlCoreSpec.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core
18 |
19 | import org.scalatest.{Matchers, WordSpec}
20 |
21 | trait RdbcPgsqlCoreSpec
22 | extends WordSpec
23 | with Matchers
24 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/FatalErrorHandler.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal
18 |
19 | trait FatalErrorHandler {
20 | protected[core] def handleFatalError(msg: String, cause: Throwable): Unit
21 | }
22 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/typeconv/PartialTypeConverter.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.typeconv
18 |
19 | trait PartialTypeConverter[T] {
20 | def cls: Class[T]
21 |
22 | def convert(any: Any): Option[T]
23 | }
24 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/WriteFailureHandler.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal
18 |
19 | private[core] trait WriteFailureHandler {
20 | private[core] def handleWriteError(cause: Throwable): Unit
21 | }
22 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/types/package.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core
18 |
19 | package object types {
20 | val BuiltInCodecs: Vector[PgValCodec[_ <: PgVal[_]]] = {
21 | internal.typecodec.BuiltInCodecs
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/exception/PgDecodeException.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.exception
18 |
19 | import io.rdbc.sapi.exceptions.RdbcException
20 |
21 | class PgDecodeException(msg: String)
22 | extends RdbcException(msg)
23 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/exception/PgEncodeException.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.exception
18 |
19 | import io.rdbc.sapi.exceptions.RdbcException
20 |
21 | class PgEncodeException(msg: String)
22 | extends RdbcException(msg)
23 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/messages/frontend/ClosePortal.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.messages.frontend
18 |
19 | case class ClosePortal(optionalName: Option[PortalName]) extends PgFrontendMessage
20 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/messages/frontend/CloseStatement.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.messages.frontend
18 |
19 | case class CloseStatement(optionalName: Option[StmtName]) extends PgFrontendMessage
20 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/messages/backend/auth/AuthRequest.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.messages.backend.auth
18 |
19 | trait AuthRequest extends AuthBackendMessage {
20 | def authMechanismName: String
21 | }
22 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/fsm/Idle.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.fsm
18 |
19 | import io.rdbc.pgsql.core.internal.protocol.TxStatus
20 |
21 | private[core]
22 | final case class Idle private[fsm](txStatus: TxStatus) extends EmptyState
23 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/codec/DecodedMessage.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.codec
18 |
19 | import _root_.scodec.bits.ByteVector
20 |
21 | private[core] final case class DecodedMessage[A](msg: A, remainder: ByteVector)
22 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/exception/PgSubscriptionRejectedException.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.exception
18 |
19 | import io.rdbc.sapi.exceptions.RdbcException
20 |
21 | class PgSubscriptionRejectedException(msg: String)
22 | extends RdbcException(msg)
23 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/typeconv/package.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core
18 |
19 | package object typeconv {
20 | val BuiltInTypeConverters = internal.typeconv.BuiltInTypeConverters
21 | val BuiltInTypeMappings = internal.typeconv.BuiltInTypeMappings
22 | }
23 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/exception/PgChannelException.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.exception
18 |
19 | import io.rdbc.sapi.exceptions.RdbcException
20 |
21 | class PgChannelException(cause: Throwable)
22 | extends RdbcException(cause.getMessage, Some(cause))
23 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/messages/backend/PgBackendMessage.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.messages.backend
18 |
19 | import io.rdbc.pgsql.core.internal.protocol.messages.PgMessage
20 |
21 | trait PgBackendMessage extends PgMessage
22 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/fsm/DefaultErrorHandling.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.fsm
18 |
19 | private[core] trait DefaultErrorHandling extends NonFatalErrorsAreFatal { this: State =>
20 |
21 | protected def onError(ex: Throwable): Unit = ()
22 | }
23 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/ColFormat.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol
18 |
19 | object ColFormat {
20 | final case object Textual extends ColFormat
21 | final case object Binary extends ColFormat
22 | }
23 |
24 | sealed trait ColFormat
25 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/messages/frontend/PgFrontendMessage.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.messages.frontend
18 |
19 | import io.rdbc.pgsql.core.internal.protocol.messages.PgMessage
20 |
21 | trait PgFrontendMessage extends PgMessage
22 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/messages/backend/NotificationResponse.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.messages.backend
18 |
19 | case class NotificationResponse(pid: PgPid, channel: String, payload: Option[String])
20 | extends PgBackendMessage
21 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/types/PgType.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.types
18 |
19 | import io.rdbc.pgsql.core.Oid
20 |
21 | trait PgType[T <: PgVal[_]] {
22 | def oid: Oid
23 |
24 | def name: String
25 |
26 | type ValType = T
27 |
28 | def valCls: Class[T]
29 | }
30 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/messages/backend/auth/AuthRequestCleartext.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.messages.backend.auth
18 |
19 | case object AuthRequestCleartext extends AuthRequest {
20 | val authMechanismName: String = "cleartext"
21 | }
22 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/fsm/streaming/StrmWaitingForSubscriber.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.fsm.streaming
18 |
19 | import io.rdbc.pgsql.core.internal.fsm.EmptyState
20 |
21 | private[core] class StrmWaitingForSubscriber private[fsm]()
22 | extends EmptyState
23 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/messages/backend/DataRow.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.messages.backend
18 |
19 | import io.rdbc.pgsql.core.internal.protocol.ColValue
20 |
21 | final case class DataRow(colValues: Vector[ColValue]) extends PgBackendMessage
22 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/messages/backend/ParameterDescription.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.messages.backend
18 |
19 | import io.rdbc.pgsql.core.Oid
20 |
21 | final case class ParameterDescription(dataTypeOids: Vector[Oid]) extends PgBackendMessage
22 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/messages/backend/ReadyForQuery.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.messages.backend
18 |
19 | import io.rdbc.pgsql.core.internal.protocol.TxStatus
20 |
21 | case class ReadyForQuery(txStatus: TxStatus) extends PgBackendMessage
22 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/config/sapi/StmtCacheConfig.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.config.sapi
18 |
19 | sealed trait StmtCacheConfig
20 | object StmtCacheConfig {
21 | case object Disabled extends StmtCacheConfig
22 | case class Enabled(capacity: Int) extends StmtCacheConfig
23 | }
24 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/messages/frontend/Execute.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.messages.frontend
18 |
19 | case class Execute(optionalPortalName: Option[PortalName],
20 | optionalFetchSize: Option[Int])
21 | extends PgFrontendMessage
22 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/messages/frontend/Startup.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.messages.frontend
18 |
19 | case class Startup(
20 | user: String,
21 | database: String,
22 | options: Map[String, String] = Map()
23 | ) extends PgFrontendMessage
24 |
--------------------------------------------------------------------------------
/rdbc-pgsql-transport-netty/src/main/scala/io/rdbc/pgsql/transport/netty/japi/package.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.transport.netty
18 |
19 | import scala.util.Try
20 |
21 | package object japi {
22 |
23 | @inline
24 | private[japi] def throwOnFailure[A](block: => Try[A]): A = {
25 | block.get
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/PgConnectionFactory.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core
18 |
19 | import io.rdbc.pgsql.core.config.sapi.PgConnFactoryConfig
20 | import io.rdbc.sapi.ConnectionFactory
21 |
22 | trait PgConnectionFactory extends ConnectionFactory {
23 | def pgConfig: PgConnFactoryConfig
24 | }
25 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/fsm/ConnectionClosed.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.fsm
18 |
19 | import io.rdbc.sapi.exceptions.ConnectionClosedException
20 |
21 | private[core]
22 | final case class ConnectionClosed private[fsm](cause: ConnectionClosedException)
23 | extends IgnoringState
24 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/TxStatus.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol
18 |
19 | sealed trait TxStatus
20 | object TxStatus {
21 | final case object Idle extends TxStatus
22 | final case object Active extends TxStatus
23 | final case object Failed extends TxStatus
24 | }
25 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/messages/backend/auth/AuthBackendMessage.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.messages.backend.auth
18 |
19 | import io.rdbc.pgsql.core.internal.protocol.messages.backend.PgBackendMessage
20 |
21 | trait AuthBackendMessage extends PgBackendMessage
22 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typecodec/sco/ScodecPgCharCodec.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typecodec.sco
18 |
19 | import io.rdbc.pgsql.core.types._
20 |
21 | private[typecodec] object ScodecPgCharCodec
22 | extends ScodecStringLikeCodec[PgChar] {
23 |
24 | val typ = PgCharType
25 | }
26 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typecodec/sco/ScodecPgTextCodec.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typecodec.sco
18 |
19 | import io.rdbc.pgsql.core.types._
20 |
21 | private[typecodec] object ScodecPgTextCodec
22 | extends ScodecStringLikeCodec[PgText] {
23 |
24 | val typ = PgTextType
25 | }
26 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/fsm/EmptyState.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.fsm
18 |
19 | import io.rdbc.pgsql.core.internal.PgMsgHandler
20 |
21 | private[core] trait EmptyState extends State with DefaultErrorHandling {
22 | protected val msgHandler: PgMsgHandler = PartialFunction.empty
23 | }
24 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/ColValue.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol
18 |
19 | import scodec.bits.ByteVector
20 |
21 | object ColValue {
22 | final case class NotNull(data: ByteVector) extends ColValue
23 | final case object Null extends ColValue
24 | }
25 | sealed trait ColValue
26 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/messages/frontend/CancelRequest.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.messages.frontend
18 |
19 | import io.rdbc.pgsql.core.internal.protocol.messages.backend.{PgKey, PgPid}
20 |
21 | case class CancelRequest(pid: PgPid, key: PgKey) extends PgFrontendMessage
22 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typecodec/sco/ScodecPgVarcharCodec.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typecodec.sco
18 |
19 | import io.rdbc.pgsql.core.types._
20 |
21 | private[typecodec] object ScodecPgVarcharCodec
22 | extends ScodecStringLikeCodec[PgVarchar] {
23 |
24 | val typ = PgVarcharType
25 | }
26 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/config/sapi/Auth.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.config.sapi
18 |
19 | import io.rdbc.pgsql.core.auth.PasswordAuthenticator
20 |
21 | object Auth {
22 | def password(username: String, password: String): PasswordAuthenticator = {
23 | new PasswordAuthenticator(username, password)
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/exception/PgUnsupportedTypeException.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.exception
18 |
19 | import io.rdbc.pgsql.core.Oid
20 | import io.rdbc.sapi.exceptions.UnsupportedDbTypeException
21 |
22 | class PgUnsupportedTypeException(val oid: Oid)
23 | extends UnsupportedDbTypeException(oid.value.toString)
24 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/messages/backend/auth/AuthRequestMd5.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.messages.backend.auth
18 |
19 | import scodec.bits.ByteVector
20 |
21 | final case class AuthRequestMd5(salt: ByteVector) extends AuthRequest {
22 | val authMechanismName: String = "md5"
23 | }
24 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/messages/frontend/Describe.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.messages.frontend
18 |
19 | case class DescribePortal(optionalName: Option[PortalName]) extends PgFrontendMessage
20 | case class DescribeStatement(optionalName: Option[StmtName]) extends PgFrontendMessage
21 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/extractors/CharVal.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.extractors
18 |
19 |
20 | private[typeconv] object CharVal {
21 | def unapply(arg: Any): Option[Char] = {
22 | arg match {
23 | case c: Char => Some(c)
24 | case _ => None
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/extractors/ByteVal.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.extractors
18 |
19 |
20 |
21 | private[typeconv] object ByteVal {
22 | def unapply(arg: Any): Option[Byte] = {
23 | arg match {
24 | case b: Byte => Some(b)
25 | case _ => None
26 | }
27 | }
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/messages/backend/BackendKeyData.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.messages.backend
18 |
19 | final case class PgPid(value: Int) extends AnyVal
20 | final case class PgKey(value: Int) extends AnyVal
21 |
22 | final case class BackendKeyData(pid: PgPid, key: PgKey) extends PgBackendMessage
23 |
--------------------------------------------------------------------------------
/rdbc-pgsql-transport-netty/src/main/scala/io/rdbc/pgsql/transport/netty/sapi/internal/Compat.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.transport.netty.sapi.internal
18 |
19 | import scala.concurrent.Future
20 |
21 | private[netty] object Compat {
22 |
23 | implicit class FutureObjectCompat(underlying: Future.type) {
24 | val unit: Future[Unit] = Future.successful(())
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/messages/frontend/Parse.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.messages.frontend
18 |
19 | import io.rdbc.pgsql.core.Oid
20 |
21 | case class Parse(optionalName: Option[StmtName],
22 | query: NativeSql,
23 | paramTypes: Vector[Oid])
24 | extends PgFrontendMessage
25 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/package.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql
18 |
19 | import io.rdbc.pgsql.core.internal.protocol.messages.backend.BackendKeyData
20 |
21 | import scala.concurrent.Future
22 |
23 | package object core {
24 |
25 | type RequestCanceler = BackendKeyData => Future[Unit]
26 |
27 | final case class ConnId(value: String) extends AnyVal
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/PgConnectionConfig.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core
18 |
19 | import io.rdbc.pgsql.core.config.sapi.StmtCacheConfig
20 |
21 | final case class PgConnectionConfig(subscriberBufferCapacity: Int,
22 | subscriberMinDemandRequestSize: Int,
23 | stmtCacheConfig: StmtCacheConfig)
24 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/exception/PgTimeoutException.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.exception
18 |
19 | import io.rdbc.pgsql.core.internal.protocol.StatusData
20 | import io.rdbc.sapi.exceptions.TimeoutException
21 |
22 | class PgTimeoutException(val pgStatusData: StatusData)
23 | extends TimeoutException(pgStatusData.shortInfo)
24 | with PgStatusDataException
25 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/types/PgInt4.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.types
18 |
19 | import io.rdbc.pgsql.core.Oid
20 |
21 | case object PgInt4Type extends PgType[PgInt4] {
22 | val oid = Oid(23)
23 | val valCls = classOf[PgInt4]
24 | val name = "int4"
25 | }
26 |
27 | final case class PgInt4(value: Int) extends PgVal[Int] {
28 | val typ = PgInt4Type
29 | }
30 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/types/PgInt8.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.types
18 |
19 | import io.rdbc.pgsql.core.Oid
20 |
21 | case object PgInt8Type extends PgType[PgInt8] {
22 | val oid = Oid(20)
23 | val valCls = classOf[PgInt8]
24 | val name = "int8"
25 | }
26 |
27 | final case class PgInt8(value: Long) extends PgVal[Long] {
28 | val typ = PgInt8Type
29 | }
30 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/SessionParams.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core
18 |
19 | import java.nio.charset.Charset
20 |
21 | object SessionParams {
22 | private val DefaultCharset = Charset.forName("US-ASCII")
23 |
24 | val default = SessionParams(
25 | clientCharset = DefaultCharset
26 | )
27 | }
28 |
29 | final case class SessionParams(clientCharset: Charset)
30 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/types/PgBool.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.types
18 |
19 | import io.rdbc.pgsql.core.Oid
20 |
21 | case object PgBoolType extends PgType[PgBool] {
22 | val oid = Oid(16)
23 | val valCls = classOf[PgBool]
24 | val name = "bool"
25 | }
26 |
27 | final case class PgBool(value: Boolean) extends PgVal[Boolean] {
28 | val typ = PgBoolType
29 | }
30 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/types/PgChar.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.types
18 |
19 | import io.rdbc.pgsql.core.Oid
20 |
21 | case object PgCharType extends PgType[PgChar] {
22 | val oid = Oid(1042)
23 | val valCls = classOf[PgChar]
24 | val name = "char"
25 | }
26 |
27 | final case class PgChar(value: String) extends PgVal[String] {
28 | val typ = PgCharType
29 | }
30 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/types/PgInt2.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.types
18 |
19 | import io.rdbc.pgsql.core.Oid
20 |
21 | case object PgInt2Type extends PgType[PgInt2] {
22 | val oid = Oid(21)
23 | val valCls = classOf[PgInt2]
24 | val name = "int2"
25 | }
26 |
27 | final case class PgInt2(value: Short) extends PgVal[Short] {
28 | val typ = PgInt2Type
29 | }
30 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/types/PgText.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.types
18 |
19 | import io.rdbc.pgsql.core.Oid
20 |
21 | case object PgTextType extends PgType[PgText] {
22 | val oid = Oid(25)
23 | val valCls = classOf[PgText]
24 | val name = "text"
25 | }
26 |
27 | final case class PgText(value: String) extends PgVal[String] {
28 | val typ = PgTextType
29 | }
30 |
--------------------------------------------------------------------------------
/rdbc-pgsql-transport-netty/src/main/scala/io/rdbc/pgsql/transport/netty/sapi/NioChannelFactory.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.transport.netty.sapi
18 |
19 | import io.netty.channel.ChannelFactory
20 | import io.netty.channel.socket.nio.NioSocketChannel
21 |
22 | class NioChannelFactory extends ChannelFactory[NioSocketChannel] {
23 | def newChannel(): NioSocketChannel = new NioSocketChannel()
24 | }
25 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/messages/backend/ParameterStatus.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.messages.backend
18 |
19 | case class SessionParamKey(value: String) extends AnyVal
20 | case class SessionParamVal(value: String) extends AnyVal
21 |
22 | final case class ParameterStatus(key: SessionParamKey, value: SessionParamVal) extends PgBackendMessage
23 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/messages/backend/RowDescription.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.messages.backend
18 |
19 | import io.rdbc.pgsql.core.internal.protocol.ColDesc
20 |
21 | object RowDescription {
22 | val empty = RowDescription(Vector.empty)
23 | }
24 |
25 | final case class RowDescription(colDescs: Vector[ColDesc]) extends PgBackendMessage
26 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/exception/PgAuthFailureException.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.exception
18 |
19 | import io.rdbc.pgsql.core.internal.protocol.StatusData
20 | import io.rdbc.sapi.exceptions.AuthFailureException
21 |
22 | class PgAuthFailureException(val pgStatusData: StatusData)
23 | extends AuthFailureException(pgStatusData.shortInfo)
24 | with PgStatusDataException
25 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/exception/PgUnauthorizedException.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.exception
18 |
19 | import io.rdbc.pgsql.core.internal.protocol.StatusData
20 | import io.rdbc.sapi.exceptions.UnauthorizedException
21 |
22 | class PgUnauthorizedException(val pgStatusData: StatusData)
23 | extends UnauthorizedException(pgStatusData.shortInfo)
24 | with PgStatusDataException
25 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/DataType.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol
18 |
19 | import io.rdbc.pgsql.core.Oid
20 |
21 | object DataType {
22 | final case class Size(value: Int) extends AnyVal
23 | final case class Modifier(value: Int) extends AnyVal
24 | }
25 |
26 | final case class DataType(oid: Oid, size: DataType.Size, modifier: DataType.Modifier)
27 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/types/PgFloat4.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.types
18 |
19 | import io.rdbc.pgsql.core.Oid
20 |
21 | case object PgFloat4Type extends PgType[PgFloat4] {
22 | val oid = Oid(700)
23 | val valCls = classOf[PgFloat4]
24 | val name = "float4"
25 | }
26 |
27 | final case class PgFloat4(value: Float) extends PgVal[Float] {
28 | val typ = PgFloat4Type
29 | }
30 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/types/PgFloat8.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.types
18 |
19 | import io.rdbc.pgsql.core.Oid
20 |
21 | case object PgFloat8Type extends PgType[PgFloat8] {
22 | val oid = Oid(701)
23 | val valCls = classOf[PgFloat8]
24 | val name = "float8"
25 | }
26 |
27 | final case class PgFloat8(value: Double) extends PgVal[Double] {
28 | val typ = PgFloat8Type
29 | }
30 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/messages/backend/CommandComplete.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.messages.backend
18 |
19 | object CommandComplete {
20 | val RowCountMessages = List("SELECT", "INSERT", "DELETE", "UPDATE", "MOVE", "FETCH", "COPY")
21 | }
22 |
23 | final case class CommandComplete(message: String, rowsAffected: Option[Int]) extends PgBackendMessage
24 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/messages/backend/UnknownBackendMessage.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.messages.backend
18 |
19 | import scodec.bits.ByteVector
20 |
21 | final case class UnknownBackendMessage(head: Byte, body: ByteVector) extends PgBackendMessage {
22 | override val toString = s"UnknownPgMessage(head = ${head.toChar}, body = ${body.toHex})"
23 | }
24 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/messages/frontend/package.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.messages
18 |
19 | package object frontend {
20 | case class PortalName(value: String) extends AnyVal
21 | case class StmtName(value: String) extends AnyVal
22 | case class NativeSql(value: String) extends AnyVal
23 | case class ColName(value: String) extends AnyVal
24 | }
25 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/types/PgVarchar.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.types
18 |
19 | import io.rdbc.pgsql.core.Oid
20 |
21 | case object PgVarcharType extends PgType[PgVarchar] {
22 | val oid = Oid(1043)
23 | val valCls = classOf[PgVarchar]
24 | val name = "varchar"
25 | }
26 |
27 | final case class PgVarchar(value: String) extends PgVal[String] {
28 | val typ = PgVarcharType
29 | }
30 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/exception/PgUncategorizedStatusDataException.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.exception
18 |
19 | import io.rdbc.pgsql.core.internal.protocol.StatusData
20 | import io.rdbc.sapi.exceptions._
21 |
22 | class PgUncategorizedStatusDataException(val pgStatusData: StatusData)
23 | extends UncategorizedRdbcException(pgStatusData.shortInfo, None)
24 | with PgStatusDataException
25 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/fsm/IgnoringState.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.fsm
18 |
19 | import io.rdbc.pgsql.core.internal.PgMsgHandler
20 |
21 | private[core] trait IgnoringState extends State with DefaultErrorHandling {
22 | protected val msgHandler: PgMsgHandler = {
23 | case msg =>
24 | logger.debug(s"Message $msg ignored in state $this")
25 | stay
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/types/PgUuid.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.types
18 |
19 | import java.util.UUID
20 |
21 | import io.rdbc.pgsql.core.Oid
22 |
23 | case object PgUuidType extends PgType[PgUuid] {
24 | val oid = Oid(2950)
25 | val valCls = classOf[PgUuid]
26 | val name = "uuid"
27 | }
28 |
29 | final case class PgUuid(value: UUID) extends PgVal[UUID] {
30 | val typ = PgUuidType
31 | }
32 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://travis-ci.org/rdbc-io/rdbc-pgsql/branches)
2 | [](https://codecov.io/gh/rdbc-io/rdbc-pgsql/branch/master)
3 | [](https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22io.rdbc.pgsql%22%20)
4 | [](https://gitter.im/rdbc-io/rdbc)
5 | [](https://github.com/rdbc-io/rdbc-pgsql/blob/master/LICENSE)
6 | ## What is rdbc-pgsql?
7 |
8 | rdbc-pgsql is a netty-based PostgreSQL [rdbc](https://github.com/rdbc-io/rdbc#what-is-rdbc)
9 | driver allowing asynchronous communication with the database in Scala and Java
10 | languages.
11 |
12 | ## Documentation
13 |
14 | See the documentation at [http://docs.pgsql.rdbc.io](http://docs.pgsql.rdbc.io/).
15 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/exception/PgInvalidQueryException.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.exception
18 |
19 | import io.rdbc.pgsql.core.internal.protocol.StatusData
20 | import io.rdbc.sapi.exceptions.InvalidQueryException
21 |
22 | class PgInvalidQueryException(val pgStatusData: StatusData)
23 | extends InvalidQueryException(pgStatusData.shortInfo, pgStatusData.position)
24 | with PgStatusDataException
25 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/exception/PgProtocolViolationException.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.exception
18 |
19 | import io.rdbc.sapi.exceptions.RdbcException
20 |
21 | class PgProtocolViolationException(msg: String, cause: Option[Throwable])
22 | extends RdbcException(msg, cause) {
23 | def this(msg: String) = this(msg, None)
24 | def this(msg: String, cause: Throwable) = this(msg, Some(cause))
25 | }
26 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/types/PgDate.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.types
18 |
19 | import java.time.LocalDate
20 |
21 | import io.rdbc.pgsql.core.Oid
22 |
23 | case object PgDateType extends PgType[PgDate] {
24 | val oid = Oid(1082)
25 | val valCls = classOf[PgDate]
26 | val name = "date"
27 | }
28 |
29 | final case class PgDate(value: LocalDate) extends PgVal[LocalDate] {
30 | val typ = PgDateType
31 | }
32 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/types/PgTime.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.types
18 |
19 | import java.time.LocalTime
20 |
21 | import io.rdbc.pgsql.core.Oid
22 |
23 | case object PgTimeType extends PgType[PgTime] {
24 | val oid = Oid(1083)
25 | val valCls = classOf[PgTime]
26 | val name = "time"
27 | }
28 |
29 | final case class PgTime(value: LocalTime) extends PgVal[LocalTime] {
30 | val typ = PgTimeType
31 | }
32 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/java/io/rdbc/pgsql/core/config/japi/Auth.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.config.japi;
18 |
19 | import io.rdbc.pgsql.core.auth.PasswordAuthenticator;
20 |
21 | public final class Auth {
22 |
23 | public static PasswordAuthenticator password(String username, String password) {
24 | return io.rdbc.pgsql.core.config.sapi.Auth.password(username, password);
25 | }
26 |
27 | private Auth() {
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typecodec/sco/ScodecPgInt4Codec.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typecodec.sco
18 |
19 | import io.rdbc.pgsql.core.types.{PgInt4, PgInt4Type}
20 | import scodec.codecs._
21 |
22 | private[typecodec] object ScodecPgInt4Codec
23 | extends ScodecPgValCodec[PgInt4]
24 | with IgnoreSessionParams[PgInt4] {
25 |
26 | val typ = PgInt4Type
27 | val codec = int32.as[PgInt4]
28 | }
29 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typecodec/sco/ScodecPgInt8Codec.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typecodec.sco
18 |
19 | import io.rdbc.pgsql.core.types.{PgInt8, PgInt8Type}
20 | import scodec.codecs._
21 |
22 | private[typecodec] object ScodecPgInt8Codec
23 | extends ScodecPgValCodec[PgInt8]
24 | with IgnoreSessionParams[PgInt8] {
25 |
26 | val typ = PgInt8Type
27 | val codec = int64.as[PgInt8]
28 | }
29 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typecodec/sco/ScodecPgUuidCodec.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typecodec.sco
18 |
19 | import io.rdbc.pgsql.core.types.{PgUuid, PgUuidType}
20 | import scodec.codecs._
21 |
22 | private[typecodec] object ScodecPgUuidCodec
23 | extends ScodecPgValCodec[PgUuid]
24 | with IgnoreSessionParams[PgUuid] {
25 |
26 | val typ = PgUuidType
27 | val codec = uuid.as[PgUuid]
28 | }
29 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/ReturnColFormats.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol
18 |
19 | sealed trait ReturnColFormats
20 |
21 | object ReturnColFormats {
22 | case object None extends ReturnColFormats
23 | case object AllBinary extends ReturnColFormats
24 | case object AllTextual extends ReturnColFormats
25 | case class Specific(formats: Vector[ColFormat]) extends ReturnColFormats
26 | }
27 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typecodec/sco/ScodecPgInt2Codec.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typecodec.sco
18 |
19 | import io.rdbc.pgsql.core.types.{PgInt2, PgInt2Type}
20 | import scodec.codecs._
21 |
22 | private[typecodec] object ScodecPgInt2Codec
23 | extends ScodecPgValCodec[PgInt2]
24 | with IgnoreSessionParams[PgInt2] {
25 |
26 | val typ = PgInt2Type
27 | val codec = short16.as[PgInt2]
28 | }
29 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/types/PgBytea.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.types
18 |
19 | import _root_.scodec.bits.ByteVector
20 | import io.rdbc.pgsql.core.Oid
21 |
22 | case object PgByteaType extends PgType[PgBytea] {
23 | val oid = Oid(17)
24 | val valCls = classOf[PgBytea]
25 | val name = "bytea"
26 | }
27 |
28 | final case class PgBytea(value: ByteVector) extends PgVal[ByteVector] {
29 | val typ = PgByteaType
30 | }
31 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/exception/PgInvalidConfigException.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.exception
18 |
19 | import io.rdbc.sapi.exceptions.UncategorizedRdbcException
20 |
21 | class PgInvalidConfigException(msg: String, cause: Option[Throwable])
22 | extends UncategorizedRdbcException(msg, cause) {
23 |
24 | def this(msg: String) = this(msg, None)
25 | def this(msg: String, cause: Throwable) = this(msg, Some(cause))
26 | }
27 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/exception/PgUncategorizedException.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.exception
18 |
19 | import io.rdbc.sapi.exceptions.UncategorizedRdbcException
20 |
21 | class PgUncategorizedException(msg: String, cause: Option[Throwable])
22 | extends UncategorizedRdbcException(msg, cause) {
23 |
24 | def this(msg: String) = this(msg, None)
25 | def this(msg: String, cause: Throwable) = this(msg, Some(cause))
26 | }
27 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typecodec/sco/ScodecPgByteaCodec.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typecodec.sco
18 |
19 | import io.rdbc.pgsql.core.types.{PgBytea, PgByteaType}
20 | import scodec.codecs._
21 |
22 | private[typecodec] object ScodecPgByteaCodec
23 | extends ScodecPgValCodec[PgBytea]
24 | with IgnoreSessionParams[PgBytea] {
25 |
26 | val typ = PgByteaType
27 | val codec = bytes.as[PgBytea]
28 | }
29 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/extractors/UuidVal.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.extractors
18 |
19 | import java.util.UUID
20 |
21 | import io.rdbc.pgsql.core.types._
22 |
23 | private[typeconv] object UuidVal {
24 | def unapply(arg: Any): Option[UUID] = {
25 | arg match {
26 | case u: UUID => Some(u)
27 | case PgUuid(u) => Some(u)
28 | case _ => None
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typecodec/sco/ScodecPgFloat4Codec.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typecodec.sco
18 |
19 | import io.rdbc.pgsql.core.types.{PgFloat4, PgFloat4Type}
20 | import scodec.codecs._
21 |
22 | private[typecodec] object ScodecPgFloat4Codec
23 | extends ScodecPgValCodec[PgFloat4]
24 | with IgnoreSessionParams[PgFloat4] {
25 |
26 | val typ = PgFloat4Type
27 | val codec = float.as[PgFloat4]
28 | }
29 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/exception/PgUnsupportedClassException.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.exception
18 |
19 | import io.rdbc.sapi.exceptions.UncategorizedRdbcException
20 |
21 | class PgUnsupportedClassException(msg: String, cause: Option[Throwable])
22 | extends UncategorizedRdbcException(msg, cause) {
23 |
24 | def this(msg: String) = this(msg, None)
25 | def this(msg: String, cause: Throwable) = this(msg, Some(cause))
26 | }
27 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typecodec/sco/ScodecPgFloat8Codec.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typecodec.sco
18 |
19 | import io.rdbc.pgsql.core.types.{PgFloat8, PgFloat8Type}
20 | import scodec.codecs._
21 |
22 | private[typecodec] object ScodecPgFloat8Codec
23 | extends ScodecPgValCodec[PgFloat8]
24 | with IgnoreSessionParams[PgFloat8] {
25 |
26 | val typ = PgFloat8Type
27 | val codec = double.as[PgFloat8]
28 | }
29 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/cache/StmtCache.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.cache
18 |
19 | import io.rdbc.pgsql.core.internal.protocol.messages.frontend.{NativeSql, StmtName}
20 |
21 | trait StmtCache {
22 | type Cache <: StmtCache
23 | def get(sql: NativeSql): (Cache, Option[StmtName])
24 | def put(sql: NativeSql, stmtName: StmtName): (Cache, Set[StmtName])
25 | def evict(sql: NativeSql): Option[(Cache, StmtName)]
26 | }
27 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/types/PgNumeric.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.types
18 |
19 | import io.rdbc.pgsql.core.Oid
20 | import io.rdbc.sapi.DecimalNumber
21 |
22 | case object PgNumericType extends PgType[PgNumeric] {
23 | val oid = Oid(1700)
24 | val valCls = classOf[PgNumeric]
25 | val name = "numeric"
26 | }
27 |
28 | final case class PgNumeric(value: DecimalNumber) extends PgVal[DecimalNumber] {
29 | val typ = PgNumericType
30 | }
31 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/types/PgTimestamp.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.types
18 |
19 | import java.time.Instant
20 |
21 | import io.rdbc.pgsql.core.Oid
22 |
23 | case object PgTimestampType extends PgType[PgTimestamp] {
24 | val oid = Oid(1114)
25 | val valCls = classOf[PgTimestamp]
26 | val name = "timestamp"
27 | }
28 |
29 | final case class PgTimestamp(value: Instant) extends PgVal[Instant] {
30 | val typ = PgTimestampType
31 | }
32 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/types/PgUnknown.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.types
18 |
19 | import io.rdbc.pgsql.core.Oid
20 |
21 | case object PgUnknownType extends PgType[PgUnknown.type] {
22 | val oid = Oid(705)
23 | val valCls = PgUnknown.getClass.asInstanceOf[Class[PgUnknown.type]]
24 | val name = "unknown"
25 | }
26 |
27 | final case object PgUnknown extends PgVal[None.type] {
28 | val typ = PgUnknownType
29 | val value = None
30 | }
31 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/messages/frontend/Bind.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.messages.frontend
18 |
19 | import io.rdbc.pgsql.core.internal.protocol.{Argument, ReturnColFormats}
20 |
21 | case class Bind(portal: Option[PortalName],
22 | preparedStmt: Option[StmtName],
23 | params: Vector[Argument],
24 | returnFieldFormats: ReturnColFormats)
25 | extends PgFrontendMessage
26 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/codec/MessageEncoder.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.codec
18 |
19 | import java.nio.charset.Charset
20 |
21 | import _root_.scodec.bits.ByteVector
22 | import io.rdbc.pgsql.core.internal.protocol.messages.frontend.PgFrontendMessage
23 |
24 | import scala.util.Try
25 |
26 | trait MessageEncoder {
27 | protected def charset: Charset
28 | def encode(msg: PgFrontendMessage): Try[ByteVector]
29 | }
30 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/extractors/InstantVal.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.extractors
18 |
19 | import java.time.Instant
20 |
21 | import io.rdbc.pgsql.core.types.PgTimestamp
22 |
23 | private[typeconv] object InstantVal {
24 | def unapply(any: Any): Option[Instant] = {
25 | any match {
26 | case i: Instant => Some(i)
27 | case PgTimestamp(i) => Some(i)
28 | case _ => None
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/types/PgValCodec.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.types
18 |
19 | import _root_.scodec.bits.ByteVector
20 | import io.rdbc.pgsql.core.SessionParams
21 |
22 | import scala.util.Try
23 |
24 | trait PgValCodec[T <: PgVal[_]] {
25 | def typ: PgType[T]
26 |
27 | def toObj(binaryVal: ByteVector)(implicit sessionParams: SessionParams): Try[T]
28 |
29 | def toBinary(pgVal: T)(implicit sessionParams: SessionParams): Try[ByteVector]
30 | }
31 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/exception/PgDriverInternalErrorException.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.exception
18 |
19 | import io.rdbc.sapi.exceptions.RdbcException
20 |
21 | class PgDriverInternalErrorException(msg: String, cause: Option[Throwable])
22 | extends RdbcException(s"THIS MOST LIKELY IS A BUG OF THE DRIVER: $msg", cause) {
23 |
24 | def this(msg: String) = this(msg, None)
25 | def this(msg: String, cause: Throwable) = this(msg, Some(cause))
26 | }
27 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/PortalDescData.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal
18 |
19 | import io.rdbc.pgsql.core.internal.protocol.messages.backend.{RowDescription, StatusMessage}
20 |
21 | import scala.concurrent.Promise
22 |
23 | private[core]
24 | case class PortalDescData(rowDesc: RowDescription,
25 | warningsPromise: Promise[Vector[StatusMessage.Notice]],
26 | rowsAffectedPromise: Promise[Long])
27 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/ColDesc.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol
18 |
19 | import io.rdbc.pgsql.core.Oid
20 | import io.rdbc.pgsql.core.internal.protocol.messages.frontend.ColName
21 |
22 | final case class ColDesc(name: ColName,
23 | tableOid: Option[Oid],
24 | columnAttr: Option[Int],
25 | dataType: DataType,
26 | format: ColFormat)
27 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/codec/sco/ScodecMessageDecoderFactory.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.codec.sco
18 |
19 | import java.nio.charset.Charset
20 |
21 | import io.rdbc.pgsql.core.internal.protocol.codec.{MessageDecoder, MessageDecoderFactory}
22 |
23 | private[core] class ScodecMessageDecoderFactory extends MessageDecoderFactory {
24 | def decoder(charset: Charset): MessageDecoder = new ScodecMessageDecoder(charset)
25 | }
26 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/codec/sco/ScodecMessageEncoderFactory.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.codec.sco
18 |
19 | import java.nio.charset.Charset
20 |
21 | import io.rdbc.pgsql.core.internal.protocol.codec.{MessageEncoder, MessageEncoderFactory}
22 |
23 | private[core] class ScodecMessageEncoderFactory extends MessageEncoderFactory {
24 | def encoder(charset: Charset): MessageEncoder = new ScodecMessageEncoder(charset)
25 | }
26 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typecodec/sco/IgnoreSessionParams.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typecodec.sco
18 |
19 | import io.rdbc.pgsql.core.SessionParams
20 | import io.rdbc.pgsql.core.types.PgVal
21 | import scodec.Codec
22 |
23 | private[sco] trait IgnoreSessionParams[T <: PgVal[_]] {
24 | this: ScodecPgValCodec[T] =>
25 |
26 | def codec: Codec[T]
27 |
28 | override final def codec(sessionParams: SessionParams): Codec[T] = codec
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/types/PgTimestampTz.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.types
18 |
19 | import java.time.ZonedDateTime
20 |
21 | import io.rdbc.pgsql.core.Oid
22 |
23 | case object PgTimestampTzType extends PgType[PgTimestampTz] {
24 | val oid = Oid(1184)
25 | val valCls = classOf[PgTimestampTz]
26 | val name = "timestamptz"
27 | }
28 |
29 | final case class PgTimestampTz(value: ZonedDateTime) extends PgVal[ZonedDateTime] {
30 | val typ = PgTimestampTzType
31 | }
32 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/codec/MessageDecoderFactory.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.codec
18 |
19 | import java.nio.charset.Charset
20 |
21 | import io.rdbc.pgsql.core.internal.protocol.codec.sco.ScodecMessageDecoderFactory
22 |
23 | trait MessageDecoderFactory {
24 | def decoder(charset: Charset): MessageDecoder
25 | }
26 |
27 | object MessageDecoderFactory {
28 | val default: MessageDecoderFactory = new ScodecMessageDecoderFactory
29 | }
30 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/codec/MessageEncoderFactory.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.codec
18 |
19 | import java.nio.charset.Charset
20 |
21 | import io.rdbc.pgsql.core.internal.protocol.codec.sco.ScodecMessageEncoderFactory
22 |
23 | trait MessageEncoderFactory {
24 | def encoder(charset: Charset): MessageEncoder
25 | }
26 |
27 | object MessageEncoderFactory {
28 | val default: MessageEncoderFactory = new ScodecMessageEncoderFactory
29 | }
30 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/typeconv/TypeConverter.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.typeconv
18 |
19 | import io.rdbc.pgsql.core.internal.typeconv.CompositeTypeConverter
20 |
21 | import scala.util.Try
22 |
23 | trait TypeConverter {
24 | def convert[T](value: Any, targetType: Class[T]): Try[T]
25 | }
26 |
27 | object TypeConverter {
28 | def fromPartials(partials: Vector[PartialTypeConverter[_]]): TypeConverter = {
29 | new CompositeTypeConverter(partials)
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typecodec/sco/ScodecPgBoolCodec.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typecodec.sco
18 |
19 | import io.rdbc.pgsql.core.types.{PgBool, PgBoolType}
20 | import scodec.codecs._
21 |
22 | private[typecodec] object ScodecPgBoolCodec
23 | extends ScodecPgValCodec[PgBool]
24 | with IgnoreSessionParams[PgBool] {
25 |
26 | val typ = PgBoolType
27 | val codec = byte.xmap[Boolean](
28 | _ == 1,
29 | if (_) 1 else 0
30 | ).as[PgBool]
31 | }
32 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/Argument.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol
18 |
19 | import io.rdbc.pgsql.core.Oid
20 | import scodec.bits.ByteVector
21 |
22 | sealed trait Argument {
23 | def dataTypeOid: Oid
24 | }
25 |
26 | object Argument {
27 | case class Null(dataTypeOid: Oid) extends Argument
28 | case class Textual(value: String, dataTypeOid: Oid) extends Argument
29 | case class Binary(value: ByteVector, dataTypeOid: Oid) extends Argument
30 | }
31 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/extractors/ByteArrayVal.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.extractors
18 |
19 | import io.rdbc.japi
20 |
21 | private[typeconv] object ByteArrayVal {
22 | def unapply(any: Any): Option[Array[Byte]] = {
23 | any match {
24 | case bytes: Array[Byte] => Some(bytes)
25 | case sb: japi.SqlBlob => Some(sb.getValue)
26 | case sb: japi.SqlBinary => Some(sb.getValue)
27 | case _ => None
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/extractors/ZonedDateTimeVal.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.extractors
18 |
19 | import java.time._
20 |
21 | import io.rdbc.pgsql.core.types.PgTimestampTz
22 |
23 | private[typeconv] object ZonedDateTimeVal {
24 | def unapply(any: Any): Option[ZonedDateTime] = {
25 | any match {
26 | case zdt: ZonedDateTime => Some(zdt)
27 | case PgTimestampTz(zdt) => Some(zdt)
28 | case _ => None
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/extractors/ByteVectorVal.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.extractors
18 |
19 | import io.rdbc.pgsql.core.types.PgBytea
20 | import scodec.bits.ByteVector
21 |
22 | private[typeconv] object ByteVectorVal {
23 | def unapply(any: Any): Option[ByteVector] = {
24 | any match {
25 | case byteVector: ByteVector => Some(byteVector)
26 | case PgBytea(byteVector) => Some(byteVector)
27 | case _ => None
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/exception/PgUnsupportedCharsetException.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.exception
18 |
19 | import io.rdbc.sapi.exceptions.RdbcException
20 |
21 | class PgUnsupportedCharsetException(pgCharsetName: String, cause: Option[Throwable])
22 | extends RdbcException(s"PostgreSQL charset '$pgCharsetName' is not supported", cause) {
23 | def this(pgCharsetName: String) = this(pgCharsetName, None)
24 | def this(pgCharsetName: String, cause: Throwable) = this(pgCharsetName, Some(cause))
25 | }
26 |
--------------------------------------------------------------------------------
/rdbc-pgsql-transport-netty/src/main/scala/io/rdbc/pgsql/transport/netty/sapi/ChannelOptionValue.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.transport.netty.sapi
18 |
19 | import io.netty.channel.ChannelOption
20 |
21 | final case class ChannelOptionValue[T](option: ChannelOption[T], value: T)
22 |
23 | object ChannelOptions {
24 |
25 | implicit final class ArrowAssoc[A](private val option: ChannelOption[A])
26 | extends AnyVal {
27 | @inline def ->(value: A): ChannelOptionValue[A] = {
28 | ChannelOptionValue(option, value)
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/BatchExecutor.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal
18 |
19 | import io.rdbc.pgsql.core.internal.protocol.{Argument, TxStatus}
20 |
21 | import scala.concurrent.Future
22 |
23 | private[core]
24 | trait BatchExecutor {
25 |
26 | private[core] def executeBatch(nativeStmt: PgNativeStatement,
27 | batch: Vector[Vector[Argument]],
28 | first: Boolean): Future[TxStatus]
29 |
30 | private[core] def completeBatch(txStatus: TxStatus): Unit
31 | }
32 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/StringTypeConverter.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv
18 |
19 | import io.rdbc.pgsql.core.internal.typeconv.extractors.StringVal
20 | import io.rdbc.pgsql.core.typeconv.PartialTypeConverter
21 |
22 | private[typeconv] object StringTypeConverter
23 | extends PartialTypeConverter[String] {
24 |
25 | val cls = classOf[String]
26 |
27 | def convert(any: Any): Option[String] = {
28 | any match {
29 | case StringVal(s) => Some(s)
30 | case _ => None
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/extractors/LongVal.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.extractors
18 |
19 | import io.rdbc.japi
20 | import io.rdbc.pgsql.core.types._
21 | import io.rdbc.sapi.SqlBigInt
22 |
23 | private[typeconv] object LongVal {
24 | def unapply(arg: Any): Option[Long] = {
25 | arg match {
26 | case l: Long => Some(l)
27 | case PgInt8(l) => Some(l)
28 | case SqlBigInt(l) => Some(l)
29 | case sb: japi.SqlBigInt => Some(sb.getValue)
30 | case _ => None
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/extractors/IntVal.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.extractors
18 |
19 | import io.rdbc.japi
20 | import io.rdbc.pgsql.core.types._
21 | import io.rdbc.sapi.SqlInteger
22 |
23 |
24 | private[typeconv] object IntVal {
25 | def unapply(arg: Any): Option[Int] = {
26 | arg match {
27 | case i: Int => Some(i)
28 | case PgInt4(i) => Some(i)
29 | case SqlInteger(i) => Some(i)
30 | case si: japi.SqlInteger => Some(si.getValue)
31 | case _ => None
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/javaconv/JavaByteTypeConverter.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.javaconv
18 |
19 | import java.lang
20 |
21 | import io.rdbc.pgsql.core.internal.typeconv.ByteTypeConverter
22 | import io.rdbc.pgsql.core.typeconv.PartialTypeConverter
23 |
24 | private[typeconv] object JavaByteTypeConverter extends PartialTypeConverter[java.lang.Byte] {
25 | val cls = classOf[java.lang.Byte]
26 |
27 | def convert(any: Any): Option[lang.Byte] = {
28 | ByteTypeConverter.convert(any).map(byte2Byte)
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/pgvalconv/PgBoolTypeConverter.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.pgvalconv
18 |
19 | import io.rdbc.pgsql.core.internal.typeconv.BoolTypeConverter
20 | import io.rdbc.pgsql.core.typeconv.PartialTypeConverter
21 | import io.rdbc.pgsql.core.types.PgBool
22 |
23 | private[typeconv] object PgBoolTypeConverter
24 | extends PartialTypeConverter[PgBool] {
25 | val cls = classOf[PgBool]
26 |
27 | def convert(any: Any): Option[PgBool] = {
28 | BoolTypeConverter.convert(any).map(PgBool)
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/UuidTypeConverter.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv
18 |
19 | import java.util.UUID
20 |
21 | import io.rdbc.pgsql.core.internal.typeconv.extractors._
22 | import io.rdbc.pgsql.core.typeconv.PartialTypeConverter
23 |
24 | private[typeconv] object UuidTypeConverter
25 | extends PartialTypeConverter[UUID] {
26 |
27 | val cls = classOf[UUID]
28 |
29 | def convert(any: Any): Option[UUID] = {
30 | any match {
31 | case UuidVal(u) => Some(u)
32 | case _ => None
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/extractors/BoolVal.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.extractors
18 |
19 | import io.rdbc.japi
20 | import io.rdbc.pgsql.core.types._
21 | import io.rdbc.sapi.SqlBoolean
22 |
23 | private[typeconv] object BoolVal {
24 | def unapply(arg: Any): Option[Boolean] = {
25 | arg match {
26 | case b: Boolean => Some(b)
27 | case PgBool(b) => Some(b)
28 | case SqlBoolean(b) => Some(b)
29 | case sb: japi.SqlBoolean => Some(sb.getValue)
30 | case _ => None
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/pgvalconv/PgInt4TypeConverter.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.pgvalconv
18 |
19 | import io.rdbc.pgsql.core.internal.typeconv.IntTypeConverter
20 | import io.rdbc.pgsql.core.typeconv.PartialTypeConverter
21 | import io.rdbc.pgsql.core.types.PgInt4
22 |
23 | private[typeconv] object PgInt4TypeConverter
24 | extends PartialTypeConverter[PgInt4] {
25 |
26 | val cls = classOf[PgInt4]
27 |
28 | def convert(any: Any): Option[PgInt4] = {
29 | IntTypeConverter.convert(any).map(PgInt4)
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/pgvalconv/PgInt8TypeConverter.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.pgvalconv
18 |
19 | import io.rdbc.pgsql.core.internal.typeconv.LongTypeConverter
20 | import io.rdbc.pgsql.core.typeconv.PartialTypeConverter
21 | import io.rdbc.pgsql.core.types.PgInt8
22 |
23 | private[typeconv] object PgInt8TypeConverter
24 | extends PartialTypeConverter[PgInt8] {
25 |
26 | val cls = classOf[PgInt8]
27 |
28 | def convert(any: Any): Option[PgInt8] = {
29 | LongTypeConverter.convert(any).map(PgInt8)
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/pgvalconv/PgUuidTypeConverter.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.pgvalconv
18 |
19 | import io.rdbc.pgsql.core.internal.typeconv.UuidTypeConverter
20 | import io.rdbc.pgsql.core.typeconv.PartialTypeConverter
21 | import io.rdbc.pgsql.core.types.PgUuid
22 |
23 | private[typeconv] object PgUuidTypeConverter
24 | extends PartialTypeConverter[PgUuid] {
25 |
26 | val cls = classOf[PgUuid]
27 |
28 | def convert(any: Any): Option[PgUuid] = {
29 | UuidTypeConverter.convert(any).map(PgUuid)
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/extractors/DoubleVal.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.extractors
18 |
19 | import io.rdbc.japi
20 | import io.rdbc.pgsql.core.types._
21 | import io.rdbc.sapi.SqlDouble
22 |
23 |
24 | private[typeconv] object DoubleVal {
25 | def unapply(arg: Any): Option[Double] = {
26 | arg match {
27 | case d: Double => Some(d)
28 | case PgFloat8(d) => Some(d)
29 | case SqlDouble(d) => Some(d)
30 | case sd: japi.SqlDouble => Some(sd.getValue)
31 | case _ => None
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/extractors/ShortVal.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.extractors
18 |
19 | import io.rdbc.japi
20 | import io.rdbc.pgsql.core.types._
21 | import io.rdbc.sapi.SqlSmallInt
22 |
23 |
24 | private[typeconv] object ShortVal {
25 | def unapply(arg: Any): Option[Short] = {
26 | arg match {
27 | case s: Short => Some(s)
28 | case PgInt2(s) => Some(s)
29 | case SqlSmallInt(s) => Some(s)
30 | case ss: japi.SqlSmallInt => Some(ss.getValue)
31 | case _ => None
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/pgvalconv/PgCharTypeConverter.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.pgvalconv
18 |
19 | import io.rdbc.pgsql.core.internal.typeconv.StringTypeConverter
20 | import io.rdbc.pgsql.core.typeconv.PartialTypeConverter
21 | import io.rdbc.pgsql.core.types.PgChar
22 |
23 | private[typeconv] object PgCharTypeConverter
24 | extends PartialTypeConverter[PgChar] {
25 |
26 | val cls = classOf[PgChar]
27 |
28 | def convert(any: Any): Option[PgChar] = {
29 | StringTypeConverter.convert(any).map(PgChar)
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/pgvalconv/PgInt2TypeConverter.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.pgvalconv
18 |
19 | import io.rdbc.pgsql.core.internal.typeconv.ShortTypeConverter
20 | import io.rdbc.pgsql.core.typeconv.PartialTypeConverter
21 | import io.rdbc.pgsql.core.types.PgInt2
22 |
23 | private[typeconv] object PgInt2TypeConverter
24 | extends PartialTypeConverter[PgInt2] {
25 |
26 | val cls = classOf[PgInt2]
27 |
28 | def convert(any: Any): Option[PgInt2] = {
29 | ShortTypeConverter.convert(any).map(PgInt2)
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/pgvalconv/PgTextTypeConverter.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.pgvalconv
18 |
19 | import io.rdbc.pgsql.core.internal.typeconv.StringTypeConverter
20 | import io.rdbc.pgsql.core.typeconv.PartialTypeConverter
21 | import io.rdbc.pgsql.core.types.PgText
22 |
23 | private[typeconv] object PgTextTypeConverter
24 | extends PartialTypeConverter[PgText] {
25 |
26 | val cls = classOf[PgText]
27 |
28 | def convert(any: Any): Option[PgText] = {
29 | StringTypeConverter.convert(any).map(PgText)
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/protocol/codec/MessageDecoder.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.protocol.codec
18 |
19 | import java.nio.charset.Charset
20 |
21 | import _root_.scodec.bits.ByteVector
22 | import io.rdbc.pgsql.core.internal.protocol.messages.backend.{MsgHeader, PgBackendMessage}
23 |
24 | import scala.util.Try
25 |
26 | trait MessageDecoder {
27 | protected def charset: Charset
28 |
29 | def decodeMsg(bytes: ByteVector): Try[DecodedMessage[PgBackendMessage]]
30 |
31 | def decodeHeader(bytes: ByteVector): Try[DecodedMessage[MsgHeader]]
32 | }
33 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/extractors/LocalDateTimeVal.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.extractors
18 |
19 | import java.time.LocalDateTime
20 |
21 | import io.rdbc.japi
22 | import io.rdbc.sapi.SqlTimestamp
23 |
24 | private[typeconv] object LocalDateTimeVal {
25 | def unapply(arg: Any): Option[LocalDateTime] = {
26 | arg match {
27 | case ldt: LocalDateTime => Some(ldt)
28 | case SqlTimestamp(ldt) => Some(ldt)
29 | case st: japi.SqlTimestamp => Some(st.getValue)
30 | case _ => None
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/extractors/OffsetDateTimeVal.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.extractors
18 |
19 | import java.time._
20 |
21 | import io.rdbc.japi
22 | import io.rdbc.sapi.SqlTimestampTz
23 |
24 | private[typeconv] object OffsetDateTimeVal {
25 | def unapply(any: Any): Option[OffsetDateTime] = {
26 | any match {
27 | case odt: OffsetDateTime => Some(odt)
28 | case SqlTimestampTz(odt) => Some(odt)
29 | case stz: japi.SqlTimestampTz => Some(stz.getValue)
30 | case _ => None
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/javaconv/JavaLongTypeConverter.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.javaconv
18 |
19 | import java.lang
20 |
21 | import io.rdbc.pgsql.core.internal.typeconv.LongTypeConverter
22 | import io.rdbc.pgsql.core.typeconv.PartialTypeConverter
23 |
24 | private[typeconv] object JavaLongTypeConverter
25 | extends PartialTypeConverter[java.lang.Long] {
26 |
27 | val cls = classOf[java.lang.Long]
28 |
29 | def convert(any: Any): Option[lang.Long] = {
30 | LongTypeConverter.convert(any).map(long2Long)
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/pgvalconv/PgDateTypeConverter.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.pgvalconv
18 |
19 | import io.rdbc.pgsql.core.internal.typeconv.LocalDateTypeConverter
20 | import io.rdbc.pgsql.core.typeconv.PartialTypeConverter
21 | import io.rdbc.pgsql.core.types.PgDate
22 |
23 | private[typeconv] object PgDateTypeConverter
24 | extends PartialTypeConverter[PgDate] {
25 |
26 | val cls = classOf[PgDate]
27 |
28 | def convert(any: Any): Option[PgDate] = {
29 | LocalDateTypeConverter.convert(any).map(PgDate)
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/pgvalconv/PgTimeTypeConverter.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.pgvalconv
18 |
19 | import io.rdbc.pgsql.core.internal.typeconv.LocalTimeTypeConverter
20 | import io.rdbc.pgsql.core.typeconv.PartialTypeConverter
21 | import io.rdbc.pgsql.core.types.PgTime
22 |
23 | private[typeconv] object PgTimeTypeConverter
24 | extends PartialTypeConverter[PgTime] {
25 |
26 | val cls = classOf[PgTime]
27 |
28 | def convert(any: Any): Option[PgTime] = {
29 | LocalTimeTypeConverter.convert(any).map(PgTime)
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/pgvalconv/PgByteaTypeConverter.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.pgvalconv
18 |
19 | import io.rdbc.pgsql.core.internal.typeconv.ByteVectorTypeConverter
20 | import io.rdbc.pgsql.core.typeconv.PartialTypeConverter
21 | import io.rdbc.pgsql.core.types.PgBytea
22 |
23 | private[typeconv] object PgByteaTypeConverter
24 | extends PartialTypeConverter[PgBytea] {
25 | val cls = classOf[PgBytea]
26 |
27 | def convert(any: Any): Option[PgBytea] = {
28 | ByteVectorTypeConverter.convert(any).map(PgBytea)
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/javaconv/JavaDoubleTypeConverter.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.javaconv
18 |
19 | import java.lang
20 |
21 | import io.rdbc.pgsql.core.internal.typeconv.DoubleTypeConverter
22 | import io.rdbc.pgsql.core.typeconv.PartialTypeConverter
23 |
24 | private[typeconv] object JavaDoubleTypeConverter
25 | extends PartialTypeConverter[java.lang.Double] {
26 | val cls = classOf[java.lang.Double]
27 |
28 | def convert(any: Any): Option[lang.Double] = {
29 | DoubleTypeConverter.convert(any).map(double2Double)
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/javaconv/JavaFloatTypeConverter.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.javaconv
18 |
19 | import java.lang
20 |
21 | import io.rdbc.pgsql.core.internal.typeconv.FloatTypeConverter
22 | import io.rdbc.pgsql.core.typeconv.PartialTypeConverter
23 |
24 | private[typeconv] object JavaFloatTypeConverter
25 | extends PartialTypeConverter[java.lang.Float] {
26 |
27 | val cls = classOf[java.lang.Float]
28 |
29 | def convert(any: Any): Option[lang.Float] = {
30 | FloatTypeConverter.convert(any).map(float2Float)
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/javaconv/JavaShortTypeConverter.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.javaconv
18 |
19 | import java.lang
20 |
21 | import io.rdbc.pgsql.core.internal.typeconv.ShortTypeConverter
22 | import io.rdbc.pgsql.core.typeconv.PartialTypeConverter
23 |
24 | private[typeconv] object JavaShortTypeConverter
25 | extends PartialTypeConverter[java.lang.Short] {
26 |
27 | val cls = classOf[java.lang.Short]
28 |
29 | def convert(any: Any): Option[lang.Short] = {
30 | ShortTypeConverter.convert(any).map(short2Short)
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/pgvalconv/PgFloat4TypeConverter.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.pgvalconv
18 |
19 | import io.rdbc.pgsql.core.internal.typeconv.FloatTypeConverter
20 | import io.rdbc.pgsql.core.typeconv.PartialTypeConverter
21 | import io.rdbc.pgsql.core.types.PgFloat4
22 |
23 | private[typeconv] object PgFloat4TypeConverter
24 | extends PartialTypeConverter[PgFloat4] {
25 |
26 | val cls = classOf[PgFloat4]
27 |
28 | def convert(any: Any): Option[PgFloat4] = {
29 | FloatTypeConverter.convert(any).map(PgFloat4)
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/pgvalconv/PgFloat8TypeConverter.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.pgvalconv
18 |
19 | import io.rdbc.pgsql.core.internal.typeconv.DoubleTypeConverter
20 | import io.rdbc.pgsql.core.typeconv.PartialTypeConverter
21 | import io.rdbc.pgsql.core.types.PgFloat8
22 |
23 | private[typeconv] object PgFloat8TypeConverter
24 | extends PartialTypeConverter[PgFloat8] {
25 |
26 | val cls = classOf[PgFloat8]
27 |
28 | def convert(any: Any): Option[PgFloat8] = {
29 | DoubleTypeConverter.convert(any).map(PgFloat8)
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/rdbc-pgsql-doc/docs/privacy.md:
--------------------------------------------------------------------------------
1 |
16 |
17 | ## Data collection
18 |
19 | This site uses Google Analytics to collect information. No personally identifiable
20 | information is collected. This site uses Google Analytics IP address anonymization feature.
21 |
22 | ## Data processing
23 |
24 | The site owner uses the collected data to understand how many people visit
25 | the site pages and where they came from.
26 |
27 | ## Opt-out from tracking
28 |
29 | Click here to opt-out of the
30 | tracking. This will create a cookie to remember the opt-out for your browser.
31 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/fsm/NonFatalErrorsAreFatal.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.fsm
18 |
19 | private[core] trait NonFatalErrorsAreFatal {
20 | this: State =>
21 |
22 | protected def onError(ex: Throwable): Unit
23 |
24 | protected final def onFatalError(ex: Throwable): Unit = traced {
25 | onError(ex)
26 | }
27 |
28 | protected final def onNonFatalError(ex: Throwable): StateAction = {
29 | logger.debug(s"State '$this' does not override non-fatal error handler, treating error as fatal")
30 | fatal(ex) andThen onFatalErrorF(ex)
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/BigDecimalTypeConverter.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv
18 |
19 | import io.rdbc.pgsql.core.typeconv.PartialTypeConverter
20 | import io.rdbc.sapi.DecimalNumber
21 |
22 | private[typeconv] object BigDecimalTypeConverter
23 | extends PartialTypeConverter[BigDecimal] {
24 |
25 | val cls = classOf[BigDecimal]
26 |
27 | def convert(any: Any): Option[BigDecimal] = {
28 | DecimalNumberTypeConverter.convert(any).flatMap {
29 | case DecimalNumber.Val(bd) => Some(bd)
30 | case _ => None
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/javaconv/JavaBooleanTypeConverter.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.javaconv
18 |
19 | import java.lang
20 |
21 | import io.rdbc.pgsql.core.internal.typeconv.BoolTypeConverter
22 | import io.rdbc.pgsql.core.typeconv.PartialTypeConverter
23 |
24 | private[typeconv] object JavaBooleanTypeConverter
25 | extends PartialTypeConverter[java.lang.Boolean] {
26 | val cls = classOf[java.lang.Boolean]
27 |
28 | def convert(any: Any): Option[lang.Boolean] = {
29 | BoolTypeConverter.convert(any).map(boolean2Boolean)
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/javaconv/JavaIntegerTypeConverter.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.javaconv
18 |
19 | import java.lang
20 |
21 | import io.rdbc.pgsql.core.internal.typeconv.IntTypeConverter
22 | import io.rdbc.pgsql.core.typeconv.PartialTypeConverter
23 |
24 | private[typeconv] object JavaIntegerTypeConverter
25 | extends PartialTypeConverter[java.lang.Integer] {
26 |
27 | val cls = classOf[java.lang.Integer]
28 |
29 | def convert(any: Any): Option[lang.Integer] = {
30 | IntTypeConverter.convert(any).map(int2Integer)
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/pgvalconv/PgVarcharTypeConverter.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.pgvalconv
18 |
19 | import io.rdbc.pgsql.core.internal.typeconv.StringTypeConverter
20 | import io.rdbc.pgsql.core.typeconv.PartialTypeConverter
21 | import io.rdbc.pgsql.core.types.PgVarchar
22 |
23 | private[typeconv] object PgVarcharTypeConverter
24 | extends PartialTypeConverter[PgVarchar] {
25 |
26 | val cls = classOf[PgVarchar]
27 |
28 | def convert(any: Any): Option[PgVarchar] = {
29 | StringTypeConverter.convert(any).map(PgVarchar)
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typecodec/sco/ScodecStringLikeCodec.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typecodec.sco
18 |
19 | import io.rdbc.pgsql.core.SessionParams
20 | import io.rdbc.pgsql.core.types._
21 | import scodec.codecs._
22 | import scodec.{Codec, Transformer}
23 |
24 | private[typecodec]
25 | abstract class ScodecStringLikeCodec[T <: PgVal[String]](implicit transformer: Transformer[String, T])
26 | extends ScodecPgValCodec[T] {
27 |
28 | override def codec(sessionParams: SessionParams): Codec[T] = {
29 | string(sessionParams.clientCharset).as[T]
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/LocalTimeTypeConverter.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv
18 |
19 | import java.time._
20 |
21 | import io.rdbc.pgsql.core.internal.typeconv.extractors._
22 | import io.rdbc.pgsql.core.typeconv.PartialTypeConverter
23 |
24 | private[typeconv] object LocalTimeTypeConverter
25 | extends PartialTypeConverter[LocalTime] {
26 |
27 | val cls = classOf[LocalTime]
28 |
29 | def convert(any: Any): Option[LocalTime] = {
30 | any match {
31 | case LocalTimeVal(lt) => Some(lt)
32 | case _ => None
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/javaconv/JavaBigDecimalTypeConverter.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.javaconv
18 |
19 | import io.rdbc.pgsql.core.internal.typeconv.BigDecimalTypeConverter
20 | import io.rdbc.pgsql.core.typeconv.PartialTypeConverter
21 |
22 | private[typeconv] object JavaBigDecimalTypeConverter
23 | extends PartialTypeConverter[java.math.BigDecimal] {
24 | val cls = classOf[java.math.BigDecimal]
25 |
26 | def convert(any: Any): Option[java.math.BigDecimal] = {
27 | BigDecimalTypeConverter.convert(any).map(_.underlying())
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/exception/PgConstraintViolationException.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.exception
18 |
19 | import io.rdbc.pgsql.core.internal.protocol.StatusData
20 | import io.rdbc.sapi.exceptions.ConstraintViolationException
21 |
22 | class PgConstraintViolationException(val pgStatusData: StatusData)
23 | extends ConstraintViolationException(
24 | schema = pgStatusData.schemaName.getOrElse(""),
25 | table = pgStatusData.tableName.getOrElse(""),
26 | constraint = pgStatusData.constraintName.getOrElse(""),
27 | msg = pgStatusData.shortInfo)
28 | with PgStatusDataException
29 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/pgvalconv/PgNumericTypeConverter.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.pgvalconv
18 |
19 | import io.rdbc.pgsql.core.internal.typeconv.DecimalNumberTypeConverter
20 | import io.rdbc.pgsql.core.typeconv.PartialTypeConverter
21 | import io.rdbc.pgsql.core.types.PgNumeric
22 |
23 | private[typeconv] object PgNumericTypeConverter
24 | extends PartialTypeConverter[PgNumeric] {
25 |
26 | val cls = classOf[PgNumeric]
27 |
28 | def convert(any: Any): Option[PgNumeric] = {
29 | DecimalNumberTypeConverter.convert(any).map(PgNumeric)
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/extractors/LocalTimeVal.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.extractors
18 |
19 | import java.time._
20 |
21 | import io.rdbc.japi
22 | import io.rdbc.pgsql.core.types.PgTime
23 | import io.rdbc.sapi.SqlTime
24 |
25 | private[typeconv] object LocalTimeVal {
26 | def unapply(any: Any): Option[LocalTime] = {
27 | any match {
28 | case lt: LocalTime => Some(lt)
29 | case PgTime(lt) => Some(lt)
30 | case SqlTime(lt) => Some(lt)
31 | case st: japi.SqlTime => Some(st.getValue)
32 | case _ => None
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/extractors/LocalDateVal.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.extractors
18 |
19 | import java.time.LocalDate
20 |
21 | import io.rdbc.japi
22 | import io.rdbc.pgsql.core.types.PgDate
23 | import io.rdbc.sapi.SqlDate
24 |
25 | private[typeconv] object LocalDateVal {
26 | def unapply(any: Any): Option[LocalDate] = {
27 | any match {
28 | case ld: LocalDate => Some(ld)
29 | case PgDate(ld) => Some(ld)
30 | case SqlDate(ld) => Some(ld)
31 | case sd: japi.SqlDate => Some(sd.getValue)
32 | case _ => None
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/ByteArrTypeConverter.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv
18 |
19 | import io.rdbc.pgsql.core.internal.typeconv.extractors._
20 | import io.rdbc.pgsql.core.typeconv.PartialTypeConverter
21 |
22 | private[typeconv] object ByteArrTypeConverter
23 | extends PartialTypeConverter[Array[Byte]] {
24 |
25 | val cls = classOf[Array[Byte]]
26 |
27 | def convert(any: Any): Option[Array[Byte]] = {
28 | any match {
29 | case ByteArrayVal(arr) => Some(arr)
30 | case ByteVectorVal(bytes) => Some(bytes.toArray)
31 | case _ => None
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/LocalDateTimeTypeConverter.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv
18 |
19 | import java.time._
20 |
21 | import io.rdbc.pgsql.core.internal.typeconv.extractors.LocalDateTimeVal
22 | import io.rdbc.pgsql.core.typeconv.PartialTypeConverter
23 |
24 | private[typeconv] object LocalDateTimeTypeConverter
25 | extends PartialTypeConverter[LocalDateTime] {
26 |
27 | val cls = classOf[LocalDateTime]
28 |
29 | def convert(any: Any): Option[LocalDateTime] = {
30 | any match {
31 | case LocalDateTimeVal(ldt) => Some(ldt)
32 | case _ => None
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/typeconv/TypeMapping.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.typeconv
18 |
19 | import io.rdbc.pgsql.core.types.{PgType, PgVal}
20 |
21 | object TypeMapping {
22 |
23 | implicit final class ArrowAssoc[Jvm](val cls: Class[Jvm])
24 | extends AnyVal {
25 | @inline def ->[Pg <: PgType[_ <: PgVal[_]]](value: Pg): TypeMapping[Jvm, Pg] = {
26 | TypeMapping(cls, value)
27 | }
28 | }
29 |
30 | }
31 |
32 | final case class
33 | TypeMapping[Jvm, Pg <: PgType[_ <: PgVal[_]]](cls: Class[Jvm], pgType: Pg) {
34 | override def toString: String = {
35 | s"${cls.getCanonicalName} -> $pgType"
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typecodec/sco/package.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typecodec
18 |
19 | import java.time._
20 |
21 | package object sco {
22 |
23 | private[sco] implicit class Duration2Micros(underlying: Duration) {
24 | def toMicros: Long = {
25 | (underlying.getSeconds * 1000L * 1000L) + (underlying.getNano / 1000L)
26 | }
27 | }
28 |
29 | private[sco] val PgEpochTime = LocalTime.MIDNIGHT
30 |
31 | private[sco] val PgEpochTimestamp: Instant = {
32 | LocalDate.of(2000, Month.JANUARY, 1)
33 | .atTime(PgEpochTime)
34 | .atOffset(ZoneOffset.UTC)
35 | .toInstant
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/fsm/WaitingForReady.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.fsm
18 |
19 | import io.rdbc.pgsql.core.internal.PgMsgHandler
20 | import io.rdbc.pgsql.core.internal.protocol.messages.backend.ReadyForQuery
21 |
22 | private[core]
23 | class WaitingForReady private[fsm](onIdle: => Unit, onFailure: Throwable => Unit)
24 | extends State
25 | with NonFatalErrorsAreFatal {
26 |
27 | protected val msgHandler: PgMsgHandler = {
28 | case ReadyForQuery(txStatus) => goto(State.idle(txStatus)) andThenF onIdle
29 | }
30 |
31 | protected def onError(ex: Throwable): Unit = traced {
32 | onFailure(ex)
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/extractors/FloatVal.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv.extractors
18 |
19 | import io.rdbc.japi
20 | import io.rdbc.pgsql.core.types._
21 | import io.rdbc.sapi.{SqlFloat, SqlReal}
22 |
23 |
24 | private[typeconv] object FloatVal {
25 | def unapply(arg: Any): Option[Float] = {
26 | arg match {
27 | case f: Float => Some(f)
28 | case PgFloat4(f) => Some(f)
29 | case SqlFloat(f) => Some(f)
30 | case sf: japi.SqlFloat => Some(sf.getValue)
31 | case SqlReal(f) => Some(f)
32 | case sr: japi.SqlReal => Some(sr.getValue)
33 | case _ => None
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/typeconv/TypeMappingRegistry.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.typeconv
18 |
19 | import io.rdbc.pgsql.core.internal.typeconv.DefaultTypeMappingRegistry
20 | import io.rdbc.pgsql.core.types.{PgType, PgVal}
21 | import io.rdbc.util.Preconditions.checkNotNull
22 |
23 | import scala.util.Try
24 |
25 | trait TypeMappingRegistry {
26 | def classToPgType(cls: Class[_]): Try[PgType[_ <: PgVal[_]]]
27 | }
28 |
29 | object TypeMappingRegistry {
30 | def fromMappings(mappings: Vector[TypeMapping[_, _ <: PgType[_ <: PgVal[_]]]]): TypeMappingRegistry = {
31 | checkNotNull(mappings)
32 | new DefaultTypeMappingRegistry(mappings)
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/InstantTypeConverter.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv
18 |
19 | import java.time.Instant
20 |
21 | import io.rdbc.pgsql.core.internal.typeconv.extractors._
22 | import io.rdbc.pgsql.core.typeconv.PartialTypeConverter
23 |
24 | private[typeconv] object InstantTypeConverter
25 | extends PartialTypeConverter[Instant] {
26 |
27 | val cls = classOf[Instant]
28 |
29 | def convert(any: Any): Option[Instant] = {
30 | any match {
31 | case InstantVal(i) => Some(i)
32 | case ZonedDateTimeVal(zdt) => Some(zdt.toInstant)
33 | case OffsetDateTimeVal(odt) => Some(odt.toInstant)
34 | case _ => None
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/rdbc-pgsql-core/src/main/scala/io/rdbc/pgsql/core/internal/typeconv/FloatTypeConverter.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 rdbc contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.rdbc.pgsql.core.internal.typeconv
18 |
19 | import io.rdbc.pgsql.core.internal.typeconv.ExactNumberConversions._
20 | import io.rdbc.pgsql.core.internal.typeconv.extractors._
21 | import io.rdbc.pgsql.core.typeconv.PartialTypeConverter
22 |
23 | private[typeconv] object FloatTypeConverter
24 | extends PartialTypeConverter[Float] {
25 |
26 | val cls = classOf[Float]
27 |
28 | def convert(any: Any): Option[Float] = {
29 | any match {
30 | case FloatVal(f) => Some(f)
31 | case DoubleVal(d) => d.toFloatExact
32 | case DecimalNumberVal(dn) => dn.toFloatExact
33 | case _ => None
34 | }
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------