Permalink
Browse files

Merge branch 'hotfix/4.0.4'

  • Loading branch information...
roji committed Dec 6, 2018
2 parents f4212f7 + 107db75 commit ecfb8b2c4bc5108e40c990b83c2863c61f7ef8b4
Showing with 393 additions and 217 deletions.
  1. +2 −2 .appveyor.yml
  2. +4 −4 src/Npgsql.GeoJSON/Npgsql.GeoJSON.csproj
  3. +3 −0 src/Npgsql.Json.NET/JsonHandler.cs
  4. +3 −0 src/Npgsql.Json.NET/JsonbHandler.cs
  5. +3 −3 src/Npgsql.Json.NET/Npgsql.Json.NET.csproj
  6. +3 −3 src/Npgsql.LegacyPostgis/Npgsql.LegacyPostgis.csproj
  7. +3 −3 src/Npgsql.NetTopologySuite/Npgsql.NetTopologySuite.csproj
  8. +4 −4 src/Npgsql.NodaTime/Npgsql.NodaTime.csproj
  9. +17 −5 src/Npgsql.NodaTime/TimestampHandler.cs
  10. +3 −3 src/Npgsql.RawPostgis/Npgsql.RawPostgis.csproj
  11. +2 −4 src/Npgsql/FrontendMessages/ExecuteMessage.cs
  12. +3 −3 src/Npgsql/Npgsql.csproj
  13. +0 −2 src/Npgsql/NpgsqlCommand.cs
  14. +3 −5 src/Npgsql/NpgsqlConnection.cs
  15. +2 −2 src/Npgsql/NpgsqlConnector.Auth.cs
  16. +64 −2 src/Npgsql/NpgsqlDataReader.cs
  17. +0 −50 src/Npgsql/NpgsqlDefaultDataReader.cs
  18. +9 −11 src/Npgsql/NpgsqlReadBuffer.cs
  19. +1 −1 src/Npgsql/NpgsqlTypes/NpgsqlDateTime.cs
  20. +2 −2 src/Npgsql/NpgsqlTypes/NpgsqlRange.cs
  21. +9 −11 src/Npgsql/NpgsqlWriteBuffer.cs
  22. +53 −13 src/Npgsql/PostgresDatabaseInfo.cs
  23. +1 −2 src/Npgsql/PostgresTypes/PostgresBaseType.cs
  24. +4 −0 src/Npgsql/PreparedStatement.cs
  25. +1 −1 src/Npgsql/SqlQueryParser.cs
  26. +4 −2 src/Npgsql/TypeHandlers/ArrayHandler.cs
  27. +1 −1 src/Npgsql/TypeHandlers/BitStringHandler.cs
  28. +1 −1 src/Npgsql/TypeHandlers/InternalTypesHandlers/Int2VectorHandler.cs
  29. +1 −1 src/Npgsql/TypeHandlers/InternalTypesHandlers/OIDVectorHandler.cs
  30. +16 −4 src/Npgsql/TypeHandlers/MappedCompositeHandler.cs
  31. +114 −22 src/Npgsql/TypeHandlers/RangeHandler.cs
  32. +1 −1 src/Npgsql/TypeHandlers/UnmappedCompositeHandler.cs
  33. +2 −4 src/Npgsql/TypeHandling/NpgsqlSimpleTypeHandlerWithPsv.cs
  34. +2 −2 src/Npgsql/TypeHandling/NpgsqlTypeHandler.cs
  35. +4 −5 src/Npgsql/TypeHandling/NpgsqlTypeHandler`.cs
  36. +1 −1 src/VSIX/Properties/AssemblyInfo.cs
  37. +3 −0 src/VSIX/VSIX.csproj
  38. +1 −1 src/VSIX/source.extension.vsixmanifest
  39. +0 −1 test/Npgsql.Benchmarks/CopyExport.cs
  40. +0 −1 test/Npgsql.Benchmarks/CopyImport.cs
  41. +3 −3 test/Npgsql.Benchmarks/Npgsql.Benchmarks.csproj
  42. +1 −2 test/Npgsql.Benchmarks/Prepare.cs
  43. +0 −1 test/Npgsql.Benchmarks/ReadColumns.cs
  44. +0 −1 test/Npgsql.Benchmarks/WriteVaryingNumberOfParameters.cs
  45. +15 −3 test/Npgsql.PluginTests/NodaTimeTests.cs
  46. +5 −5 test/Npgsql.PluginTests/Npgsql.PluginTests.csproj
  47. +6 −6 test/Npgsql.Tests/CommandTests.cs
  48. +1 −1 test/Npgsql.Tests/NotificationTests.cs
  49. +4 −4 test/Npgsql.Tests/Npgsql.Tests.csproj
  50. +2 −2 test/Npgsql.Tests/ReaderNewSchemaTests.cs
  51. +6 −6 test/Npgsql.Tests/ReaderTests.cs
@@ -1,13 +1,13 @@
image: Visual Studio 2017
version: 4.0.3-{build}
version: 4.0.4-{build}
environment:
global:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: 1
NPGSQL_TEST_DB: Host=localhost;Database=postgres;Username=postgres;Password=Password12!
PGUSER: postgres
PGPASSWORD: Password12!
POSTGIS_EXE: postgis-bundle-pg10x64-setup-2.4.4-1.exe
POSTGIS_EXE: postgis-bundle-pg10x64-setup-2.5.0-1.exe
NoPackageAnalysis: true # Suppresses warning about SemVer 2.0.0 version suffixes when packing
cache:
- '%USERPROFILE%\.nuget\packages -> **\*.csproj'
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionPrefix>4.0.4</VersionPrefix>
<Description>GeoJSON plugin for Npgsql, allowing mapping of PostGIS geometry types to GeoJSON types.</Description>
<Authors>Yoh Deadfall, Shay Rojansky</Authors>
<Copyright>Copyright 2018 © The Npgsql Development Team</Copyright>
@@ -14,7 +14,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageProjectUrl>http://www.npgsql.org</PackageProjectUrl>
<PackageIconUrl>http://www.npgsql.org/img/postgresql.gif</PackageIconUrl>
<PackageLicenseUrl>https://raw.githubusercontent.com/npgsql/npgsql/develop/LICENSE.txt</PackageLicenseUrl>
<PackageLicenseExpression>PostgreSQL</PackageLicenseExpression>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>git://github.com/npgsql/npgsql</RepositoryUrl>
<Deterministic>true</Deterministic>
@@ -23,7 +23,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="GeoJSON.Net" Version="1.1.64" />
<PackageReference Include="GeoJSON.Net" Version="1.1.70" />
</ItemGroup>

<ItemGroup>
@@ -86,6 +86,9 @@ protected override int ValidateObjectAndGetLength(object value, ref NpgsqlLength

protected override Task WriteObjectWithLength(object value, NpgsqlWriteBuffer buf, NpgsqlLengthCache lengthCache, NpgsqlParameter parameter, bool async)
{
if (value == null || value is DBNull)
return base.WriteObjectWithLength(value, buf, lengthCache, parameter, async);

if (parameter?.ConvertedValue != null)
value = parameter.ConvertedValue;
var s = value as string ?? JsonConvert.SerializeObject(value, _settings);
@@ -86,6 +86,9 @@ protected override int ValidateObjectAndGetLength(object value, ref NpgsqlLength

protected override Task WriteObjectWithLength(object value, NpgsqlWriteBuffer buf, NpgsqlLengthCache lengthCache, NpgsqlParameter parameter, bool async)
{
if (value == null || value is DBNull)
return base.WriteObjectWithLength(value, buf, lengthCache, parameter, async);

if (parameter?.ConvertedValue != null)
value = parameter.ConvertedValue;
var s = value as string ?? JsonConvert.SerializeObject(value, _settings);
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionPrefix>4.0.4</VersionPrefix>
<Description>Json.NET plugin for Npgsql, allowing transparent serialization/deserialization of JSON objects directly to and from the database.</Description>
<Authors>Shay Rojansky</Authors>
<Copyright>Copyright 2018 © The Npgsql Development Team</Copyright>
@@ -15,7 +15,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageProjectUrl>http://www.npgsql.org</PackageProjectUrl>
<PackageIconUrl>http://www.npgsql.org/img/postgresql.gif</PackageIconUrl>
<PackageLicenseUrl>https://raw.githubusercontent.com/npgsql/npgsql/develop/LICENSE.txt</PackageLicenseUrl>
<PackageLicenseExpression>PostgreSQL</PackageLicenseExpression>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>git://github.com/npgsql/npgsql</RepositoryUrl>
<Deterministic>true</Deterministic>
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionPrefix>4.0.4</VersionPrefix>
<Description>PostGIS plugin for Npgsql, allowing mapping of PostGIS types to the legacy types (e.g. PostgisPoint).</Description>
<Authors>Shay Rojansky</Authors>
<Copyright>Copyright 2018 © The Npgsql Development Team</Copyright>
@@ -14,7 +14,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageProjectUrl>http://www.npgsql.org</PackageProjectUrl>
<PackageIconUrl>http://www.npgsql.org/img/postgresql.gif</PackageIconUrl>
<PackageLicenseUrl>https://raw.githubusercontent.com/npgsql/npgsql/develop/LICENSE.txt</PackageLicenseUrl>
<PackageLicenseExpression>PostgreSQL</PackageLicenseExpression>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>git://github.com/npgsql/npgsql</RepositoryUrl>
<Deterministic>true</Deterministic>
@@ -29,4 +29,4 @@
<ItemGroup>
<ProjectReference Include="..\Npgsql\Npgsql.csproj" />
</ItemGroup>
</Project>
</Project>
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<VersionPrefix>1.0.2</VersionPrefix>
<VersionPrefix>4.0.4</VersionPrefix>
<Description>NetTopologySuite plugin for Npgsql, allowing mapping of PostGIS geometry types to NetTopologySuite types.</Description>
<Authors>Yoh Deadfall, Shay Rojansky</Authors>
<Copyright>Copyright 2018 © The Npgsql Development Team</Copyright>
@@ -16,7 +16,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageProjectUrl>http://www.npgsql.org</PackageProjectUrl>
<PackageIconUrl>http://www.npgsql.org/img/postgresql.gif</PackageIconUrl>
<PackageLicenseUrl>https://raw.githubusercontent.com/npgsql/npgsql/develop/LICENSE.txt</PackageLicenseUrl>
<PackageLicenseExpression>PostgreSQL</PackageLicenseExpression>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>git://github.com/npgsql/npgsql</RepositoryUrl>
<Deterministic>true</Deterministic>
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionPrefix>4.0.4</VersionPrefix>
<Description>NodaTime plugin for Npgsql, allowing mapping of PostgreSQL date/time types to NodaTime types.</Description>
<Authors>Shay Rojansky</Authors>
<Copyright>Copyright 2018 © The Npgsql Development Team</Copyright>
@@ -15,7 +15,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageProjectUrl>http://www.npgsql.org</PackageProjectUrl>
<PackageIconUrl>http://www.npgsql.org/img/postgresql.gif</PackageIconUrl>
<PackageLicenseUrl>https://raw.githubusercontent.com/npgsql/npgsql/develop/LICENSE.txt</PackageLicenseUrl>
<PackageLicenseExpression>PostgreSQL</PackageLicenseExpression>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>git://github.com/npgsql/npgsql</RepositoryUrl>
<Deterministic>true</Deterministic>
@@ -24,7 +24,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NodaTime" Version="2.3.0" />
<PackageReference Include="NodaTime" Version="2.4.2" />
<!-- Causes issues in Appveyor and Travis
<PackageReference Include="Microsoft.CodeQuality.Analyzers" Version="2.6.0-beta2" PrivateAssets="All" />
-->
@@ -44,6 +44,11 @@ protected override NpgsqlTypeHandler<Instant> Create(NpgsqlConnection conn)

class TimestampHandler : NpgsqlSimpleTypeHandler<Instant>, INpgsqlSimpleTypeHandler<LocalDateTime>
{
static readonly Instant Instant0 = Instant.FromUtc(1, 1, 1, 0, 0, 0);
static readonly Instant Instant2000 = Instant.FromUtc(2000, 1, 1, 0, 0, 0);
static readonly Duration Plus292Years = Duration.FromDays(292 * 365);
static readonly Duration Minus292Years = -Plus292Years;

/// <summary>
/// A deprecated compile-time option of PostgreSQL switches to a floating-point representation of some date/time
/// fields. Npgsql (currently) does not support this mode.
@@ -110,16 +115,12 @@ LocalDateTime INpgsqlSimpleTypeHandler<LocalDateTime>.Read(NpgsqlReadBuffer buf,
}
}

static readonly Instant Instant2000 = Instant.FromUtc(2000, 1, 1, 0, 0, 0);

// value is the number of microseconds from 2000-01-01T00:00:00.
// Unfortunately NodaTime doesn't have Duration.FromMicroseconds(), so we decompose into milliseconds
// and nanoseconds
internal static Instant Decode(long value)
=> Instant2000 + Duration.FromMilliseconds(value / 1000) + Duration.FromNanoseconds(value % 1000 * 1000);

static readonly Instant Instant0 = Instant.FromUtc(1, 1, 1, 0, 0, 0);

// This is legacy support for PostgreSQL's old floating-point timestamp encoding - finally removed in PG 10 and not used for a long
// time. Unfortunately CrateDB seems to use this for some reason.
internal static Instant Decode(double value)
@@ -208,7 +209,18 @@ void INpgsqlSimpleTypeHandler<LocalDateTime>.Write(LocalDateTime value, NpgsqlWr

// We need to write the number of microseconds from 2000-01-01T00:00:00.
internal static void WriteInteger(Instant instant, NpgsqlWriteBuffer buf)
=> buf.WriteInt64((long)(instant - Instant2000).TotalNanoseconds / 1000);
{
var since2000 = instant - Instant2000;

// The nanoseconds may overflow, so fallback to BigInteger where necessary.
var microseconds =
since2000 >= Minus292Years &&
since2000 <= Plus292Years
? since2000.ToInt64Nanoseconds() / 1000
: (long)(since2000.ToBigIntegerNanoseconds() / 1000);

buf.WriteInt64(microseconds);
}

// This is legacy support for PostgreSQL's old floating-point timestamp encoding - finally removed in PG 10 and not used for a long
// time. Unfortunately CrateDB seems to use this for some reason.
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionPrefix>4.0.4</VersionPrefix>
<Description>PostGIS plugin for Npgsql, allowing raw byte access to PostGIS ypes.</Description>
<Authors>Shay Rojansky</Authors>
<Copyright>Copyright 2018 © The Npgsql Development Team</Copyright>
@@ -14,7 +14,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageProjectUrl>http://www.npgsql.org</PackageProjectUrl>
<PackageIconUrl>http://www.npgsql.org/img/postgresql.gif</PackageIconUrl>
<PackageLicenseUrl>https://raw.githubusercontent.com/npgsql/npgsql/develop/LICENSE.txt</PackageLicenseUrl>
<PackageLicenseExpression>PostgreSQL</PackageLicenseExpression>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>git://github.com/npgsql/npgsql</RepositoryUrl>
<Deterministic>true</Deterministic>
@@ -29,4 +29,4 @@
<ItemGroup>
<ProjectReference Include="..\Npgsql\Npgsql.csproj" />
</ItemGroup>
</Project>
</Project>
@@ -66,10 +66,8 @@ public override string ToString()
sb.Append("[Execute");
if (Portal != "" && MaxRows != 0)
{
if (Portal != "")
sb.Append("Portal=").Append(Portal);
if (MaxRows != 0)
sb.Append("MaxRows=").Append(MaxRows);
sb.Append("Portal=").Append(Portal);
sb.Append("MaxRows=").Append(MaxRows);
}
sb.Append(']');
return sb.ToString();
@@ -6,7 +6,7 @@
<Copyright>Copyright 2018 © The Npgsql Development Team</Copyright>
<Company>Npgsql</Company>
<PackageTags>npgsql postgresql postgres ado ado.net database sql</PackageTags>
<VersionPrefix>4.0.3</VersionPrefix>
<VersionPrefix>4.0.4</VersionPrefix>
<LangVersion>latest</LangVersion>
<TargetFrameworks>net45;net451;netstandard2.0</TargetFrameworks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
@@ -17,7 +17,7 @@
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<PackageProjectUrl>http://www.npgsql.org</PackageProjectUrl>
<PackageIconUrl>http://www.npgsql.org/img/postgresql.gif</PackageIconUrl>
<PackageLicenseUrl>https://raw.githubusercontent.com/npgsql/npgsql/master/LICENSE.txt</PackageLicenseUrl>
<PackageLicenseExpression>PostgreSQL</PackageLicenseExpression>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>git://github.com/npgsql/npgsql</RepositoryUrl>
<Deterministic>true</Deterministic>
@@ -32,7 +32,7 @@
<ItemGroup>
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.5.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.0" />
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.1" />
<!-- Causes issues in Appveyor and Travis
<PackageReference Include="Microsoft.CodeQuality.Analyzers" Version="2.6.0-beta2" PrivateAssets="All" />
-->
@@ -1138,8 +1138,6 @@ async ValueTask<DbDataReader> ExecuteDbDataReader(CommandBehavior behavior, bool
using (cancellationToken.Register(cmd => ((NpgsqlCommand)cmd).Cancel(), this))
{
ValidateParameters();
if ((behavior & CommandBehavior.SequentialAccess) != 0 && Parameters.HasOutputParameters)
throw new NotSupportedException("Output parameters aren't supported with SequentialAccess");

if (IsExplicitlyPrepared)
{
@@ -237,9 +237,10 @@ Task Open(bool async, CancellationToken cancellationToken)
var mapper = Connector.TypeMapper;
if (mapper.ChangeCounter != TypeMapping.GlobalTypeMapper.Instance.ChangeCounter)
{
// We always do this synchronously which isn't amazing but not very important
// We always do this synchronously which isn't amazing but not very important, because
// it's supposed to be a pretty rare event and the whole point is to keep this method
// non-async
Connector.LoadDatabaseInfo(NpgsqlTimeout.Infinite, false).GetAwaiter().GetResult();
mapper.Reset();
}

Debug.Assert(Connector.Connection != null, "Open done but connector not set on Connection");
@@ -307,10 +308,7 @@ async Task OpenLong()
// or global mappings may have changed. Bring this up to date if needed.
mapper = Connector.TypeMapper;
if (mapper.ChangeCounter != TypeMapping.GlobalTypeMapper.Instance.ChangeCounter)
{
await Connector.LoadDatabaseInfo(NpgsqlTimeout.Infinite, async);
mapper.Reset();
}
}

// We may have gotten an already enlisted pending connector above, no need to enlist in that case
@@ -144,9 +144,9 @@ async Task AuthenticateGSS(bool async)
{
var targetName = $"{KerberosServiceName}/{Host}";
if (async)
negotiateStream.AuthenticateAsClient(CredentialCache.DefaultNetworkCredentials, targetName);
await negotiateStream.AuthenticateAsClientAsync(CredentialCache.DefaultNetworkCredentials, targetName);
else
await negotiateStream.AuthenticateAsClientAsync(CredentialCache.DefaultNetworkCredentials, targetName);
negotiateStream.AuthenticateAsClient(CredentialCache.DefaultNetworkCredentials, targetName);
}
catch (AuthenticationCompleteException)
{
Oops, something went wrong.

0 comments on commit ecfb8b2

Please sign in to comment.