Skip to content
Permalink
Browse files

Merge branch 'hotfix/4.1.3'

  • Loading branch information
roji committed Jan 31, 2020
2 parents fff8af0 + e096a8b commit dd5fd7d2add694c3a9b38482ea55713a6d911458
Showing with 581 additions and 333 deletions.
  1. +1 −1 .appveyor.yml
  2. +1 −1 Directory.Build.props
  3. +1 −1 src/Npgsql/BackendMessages/ParameterDescriptionMessage.cs
  4. +5 −3 src/Npgsql/ConnectorPool.cs
  5. +4 −4 src/Npgsql/NameTranslation/NpgsqlSnakeCaseNameTranslator.cs
  6. +22 −5 src/Npgsql/NpgsqlCommand.cs
  7. +4 −4 src/Npgsql/NpgsqlConnector.FrontendMessages.cs
  8. +175 −151 src/Npgsql/NpgsqlDataReader.cs
  9. +2 −2 src/Npgsql/NpgsqlException.cs
  10. +1 −1 src/Npgsql/NpgsqlParameterCollection.cs
  11. +57 −46 src/Npgsql/PostgresDatabaseInfo.cs
  12. +25 −43 src/Npgsql/PostgresException.cs
  13. +23 −22 src/Npgsql/Schema/DbColumnSchemaGenerator.cs
  14. +15 −0 src/Npgsql/ThrowHelper.cs
  15. +2 −3 src/Npgsql/TypeHandlers/ArrayHandler.cs
  16. +16 −4 src/Npgsql/TypeHandlers/BitStringHandler.cs
  17. +5 −13 src/Npgsql/TypeHandlers/JsonHandler.cs
  18. +7 −3 src/Npgsql/TypeHandling/NpgsqlTypeHandler`.cs
  19. +2 −2 src/Npgsql/TypeMapping/ConnectorTypeMapper.cs
  20. +3 −0 src/Npgsql/Util/DbDataReaderExtensions.cs
  21. +1 −1 src/VSIX/Properties/AssemblyInfo.cs
  22. +1 −1 src/VSIX/source.extension.vsixmanifest
  23. +30 −0 test/Npgsql.Tests/AutoPrepareTests.cs
  24. +53 −15 test/Npgsql.Tests/CommandTests.cs
  25. +1 −0 test/Npgsql.Tests/ExceptionTests.cs
  26. +17 −0 test/Npgsql.Tests/PrepareTests.cs
  27. +1 −1 test/Npgsql.Tests/ReaderOldSchemaTests.cs
  28. +33 −5 test/Npgsql.Tests/ReaderTests.cs
  29. +2 −1 test/Npgsql.Tests/SnakeCaseNameTranslatorTests.cs
  30. +12 −0 test/Npgsql.Tests/TestUtil.cs
  31. +14 −0 test/Npgsql.Tests/Types/BitStringTests.cs
  32. +19 −0 test/Npgsql.Tests/Types/CompositeTests.cs
  33. +26 −0 test/Npgsql.Tests/Types/JsonTests.cs
@@ -1,5 +1,5 @@
image: Visual Studio 2019 Preview
version: 4.1.2-{build}
version: 4.1.3-{build}
environment:
global:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
@@ -3,7 +3,7 @@
<PropertyGroup>
<Copyright>Copyright 2019 © The Npgsql Development Team</Copyright>
<Company>Npgsql</Company>
<VersionPrefix>4.1.2</VersionPrefix>
<VersionPrefix>4.1.3</VersionPrefix>

<RepositoryType>git</RepositoryType>
<RepositoryUrl>git://github.com/npgsql/npgsql</RepositoryUrl>
@@ -14,7 +14,7 @@ internal ParameterDescriptionMessage()

internal ParameterDescriptionMessage Load(NpgsqlReadBuffer buf)
{
var numParams = buf.ReadInt16();
var numParams = buf.ReadUInt16();
TypeOIDs.Clear();
for (var i = 0; i < numParams; i++)
TypeOIDs.Add(buf.ReadUInt32());
@@ -129,7 +129,7 @@ internal ConnectorPool(NpgsqlConnectionStringBuilder settings, string connString
throw new ArgumentException($"Connection can't have ConnectionIdleLifetime {connectionIdleLifetime} under ConnectionPruningInterval {_pruningSamplingInterval}");

_pruningTimer = new Timer(PruningTimerCallback, this, Timeout.Infinite, Timeout.Infinite);
_pruningSampleSize = DivideRoundingUp(connectionIdleLifetime.Seconds, pruningSamplingInterval.Seconds);
_pruningSampleSize = DivideRoundingUp(settings.ConnectionIdleLifetime, settings.ConnectionPruningInterval);
_pruningMedianIndex = DivideRoundingUp(_pruningSampleSize, 2) - 1; // - 1 to go from length to index
_pruningSamplingInterval = pruningSamplingInterval;
_pruningSamples = new int[_pruningSampleSize];
@@ -520,11 +520,13 @@ static void PruneIdleConnectors(object? state)
return;

var sampleIndex = pool._pruningSampleIndex;
if (sampleIndex < pool._pruningSampleSize)
samples[sampleIndex] = pool.State.Idle;

if (sampleIndex != pool._pruningSampleSize - 1)
{
samples[sampleIndex] = pool.State.Idle;
pool._pruningSampleIndex = sampleIndex + 1;
pool._pruningTimer.Change(pool._pruningSamplingInterval, Timeout.InfiniteTimeSpan);

return;
}

@@ -51,18 +51,17 @@ public string TranslateMemberName(string clrName)
public static string ConvertToSnakeCase(string value)
{
const char underscore = '_';
const UnicodeCategory noneCategory = UnicodeCategory.Control;

var builder = new StringBuilder();
var previousCategory = noneCategory;
var previousCategory = default(UnicodeCategory?);

for (var currentIndex = 0; currentIndex< value.Length; currentIndex++)
{
var currentChar = value[currentIndex];
if (currentChar == underscore)
{
builder.Append(underscore);
previousCategory = noneCategory;
previousCategory = null;
continue;
}

@@ -74,6 +73,7 @@ public static string ConvertToSnakeCase(string value)
if (previousCategory == UnicodeCategory.SpaceSeparator ||
previousCategory == UnicodeCategory.LowercaseLetter ||
previousCategory != UnicodeCategory.DecimalDigitNumber &&
previousCategory != null &&
currentIndex > 0 &&
currentIndex + 1 < value.Length &&
char.IsLower(value[currentIndex + 1]))
@@ -91,7 +91,7 @@ public static string ConvertToSnakeCase(string value)
break;

default:
if (previousCategory != noneCategory)
if (previousCategory != null)
previousCategory = UnicodeCategory.SpaceSeparator;
continue;
}
@@ -594,11 +594,15 @@ async Task PrepareLong()

// Loop over statements, skipping those that are already prepared (because they were persisted)
var isFirst = true;
foreach (var statement in _statements)
for (var i = 0; i < _statements.Count; i++)
{
if (statement.PreparedStatement?.State == PreparedState.BeingPrepared)
var statement = _statements[i];
var pStatement = statement.PreparedStatement;
if (pStatement?.State != PreparedState.BeingPrepared)
continue;

try
{
var pStatement = statement.PreparedStatement;
if (pStatement.StatementBeingReplaced != null)
{
Expect<CloseCompletedMessage>(await connector.ReadMessage(async), connector);
@@ -628,6 +632,19 @@ async Task PrepareLong()
pStatement.CompletePrepare();
isFirst = false;
}
catch
{
// The statement wasn't prepared successfully, update the bookkeeping for it and
// all following statements
for (; i < _statements.Count; i++)
{
pStatement = _statements[i].PreparedStatement;
if (pStatement?.State == PreparedState.BeingPrepared)
pStatement.CompleteUnprepare();
}

throw;
}
}

Expect<ReadyForQueryMessage>(await connector.ReadMessage(async), connector);
@@ -747,8 +764,8 @@ void ProcessRawQuery(bool deriveParameters = false)
}

foreach (var s in _statements)
if (s.InputParameters.Count > short.MaxValue)
throw new NpgsqlException($"A statement cannot have more than {short.MaxValue} parameters");
if (s.InputParameters.Count > ushort.MaxValue)
throw new NpgsqlException($"A statement cannot have more than {ushort.MaxValue} parameters");
}

#endregion
@@ -111,7 +111,7 @@ internal async Task WriteParse(string sql, string statementName, List<NpgsqlPara
statementName.Length + // Statement name
sizeof(byte) + // Null terminator for the statement name
queryByteLen + sizeof(byte) + // SQL query length plus null terminator
sizeof(short) + // Number of parameters
sizeof(ushort) + // Number of parameters
inputParameters.Count * sizeof(int); // Parameter OIDs

WriteBuffer.WriteByte(FrontendMessageCode.Parse);
@@ -123,7 +123,7 @@ internal async Task WriteParse(string sql, string statementName, List<NpgsqlPara
if (WriteBuffer.WriteSpaceLeft < 1 + 2)
await Flush(async);
WriteBuffer.WriteByte(0); // Null terminator for the query
WriteBuffer.WriteInt16((short)inputParameters.Count);
WriteBuffer.WriteUInt16((ushort)inputParameters.Count);

foreach (var p in inputParameters)
{
@@ -150,7 +150,7 @@ internal async Task WriteParse(string sql, string statementName, List<NpgsqlPara
sizeof(int) + // Message length
sizeof(byte) + // Portal is always empty (only a null terminator)
statement.Length + sizeof(byte) + // Statement name plus null terminator
sizeof(short); // Number of parameter format codes that follow
sizeof(ushort); // Number of parameter format codes that follow

if (WriteBuffer.WriteSpaceLeft < headerLength)
{
@@ -205,7 +205,7 @@ internal async Task WriteParse(string sql, string statementName, List<NpgsqlPara
if (WriteBuffer.WriteSpaceLeft < 2)
await Flush(async);

WriteBuffer.WriteInt16(inputParameters.Count);
WriteBuffer.WriteUInt16((ushort)inputParameters.Count);

foreach (var param in inputParameters)
{

0 comments on commit dd5fd7d

Please sign in to comment.
You can’t perform that action at this time.