You've already forked linux-packaging-mono
Imported Upstream version 6.6.0.152
Former-commit-id: 86ad01d4d9648b8b15a92915cfbc25f843234e8e
This commit is contained in:
parent
3a44987f03
commit
179dd0da4b
@@ -1257,15 +1257,30 @@ int32_t SystemNative_CopyFile(intptr_t sourceFd, intptr_t destinationFd)
|
||||
int ret;
|
||||
struct stat_ sourceStat;
|
||||
bool copied = false;
|
||||
#if HAVE_SENDFILE_4
|
||||
// If sendfile is available (Linux), try to use it, as the whole copy
|
||||
// can be performed in the kernel, without lots of unnecessary copying.
|
||||
|
||||
// First, stat the source file.
|
||||
while ((ret = fstat_(inFd, &sourceStat)) < 0 && errno == EINTR);
|
||||
if (ret != 0)
|
||||
{
|
||||
// If we can't stat() it, then we likely don't have permission to read it.
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Copy permissions. This fchmod() needs to happen prior to writing anything into
|
||||
// the file to avoid possibly leaking any private data.
|
||||
while ((ret = fchmod(outFd, sourceStat.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO))) < 0 && errno == EINTR);
|
||||
#if !TARGET_ANDROID
|
||||
// On Android, we are not allowed to modify permissions, but the copy should still succeed;
|
||||
// see https://github.com/mono/mono/issues/17133 for details.
|
||||
if (ret != 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if HAVE_SENDFILE_4
|
||||
// If sendfile is available (Linux), try to use it, as the whole copy
|
||||
// can be performed in the kernel, without lots of unnecessary copying.
|
||||
|
||||
// On 32-bit, if you use 64-bit offsets, the last argument of `sendfile' will be a
|
||||
// `size_t' a 32-bit integer while the `st_size' field of the stat structure will be off64_t.
|
||||
@@ -1313,37 +1328,30 @@ int32_t SystemNative_CopyFile(intptr_t sourceFd, intptr_t destinationFd)
|
||||
// from the source file. First copy the file times.
|
||||
// If futimes nor futimes are available on this platform, file times will
|
||||
// not be copied over.
|
||||
while ((ret = fstat_(inFd, &sourceStat)) < 0 && errno == EINTR);
|
||||
if (ret == 0)
|
||||
{
|
||||
#if HAVE_FUTIMENS
|
||||
// futimens is prefered because it has a higher resolution.
|
||||
struct timespec origTimes[2];
|
||||
origTimes[0].tv_sec = (time_t)sourceStat.st_atime;
|
||||
origTimes[0].tv_nsec = ST_ATIME_NSEC(&sourceStat);
|
||||
origTimes[1].tv_sec = (time_t)sourceStat.st_mtime;
|
||||
origTimes[1].tv_nsec = ST_MTIME_NSEC(&sourceStat);
|
||||
while ((ret = futimens(outFd, origTimes)) < 0 && errno == EINTR);
|
||||
// futimens is prefered because it has a higher resolution.
|
||||
struct timespec origTimes[2];
|
||||
origTimes[0].tv_sec = (time_t)sourceStat.st_atime;
|
||||
origTimes[0].tv_nsec = ST_ATIME_NSEC(&sourceStat);
|
||||
origTimes[1].tv_sec = (time_t)sourceStat.st_mtime;
|
||||
origTimes[1].tv_nsec = ST_MTIME_NSEC(&sourceStat);
|
||||
while ((ret = futimens(outFd, origTimes)) < 0 && errno == EINTR);
|
||||
#elif HAVE_FUTIMES
|
||||
struct timeval origTimes[2];
|
||||
origTimes[0].tv_sec = sourceStat.st_atime;
|
||||
origTimes[0].tv_usec = ST_ATIME_NSEC(&sourceStat) / 1000;
|
||||
origTimes[1].tv_sec = sourceStat.st_mtime;
|
||||
origTimes[1].tv_usec = ST_MTIME_NSEC(&sourceStat) / 1000;
|
||||
while ((ret = futimes(outFd, origTimes)) < 0 && errno == EINTR);
|
||||
struct timeval origTimes[2];
|
||||
origTimes[0].tv_sec = sourceStat.st_atime;
|
||||
origTimes[0].tv_usec = ST_ATIME_NSEC(&sourceStat) / 1000;
|
||||
origTimes[1].tv_sec = sourceStat.st_mtime;
|
||||
origTimes[1].tv_usec = ST_MTIME_NSEC(&sourceStat) / 1000;
|
||||
while ((ret = futimes(outFd, origTimes)) < 0 && errno == EINTR);
|
||||
#endif
|
||||
}
|
||||
if (ret != 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Then copy permissions.
|
||||
while ((ret = fchmod(outFd, sourceStat.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO))) < 0 && errno == EINTR);
|
||||
#if !TARGET_ANDROID
|
||||
// On Android, the copy should still succeed even if copying the file times didn't.
|
||||
if (ret != 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
#endif // HAVE_FCOPYFILE
|
||||
|
||||
@@ -1 +1 @@
|
||||
40a20092f6a571ef9598fc7477ff948b5b60cc32
|
||||
ed356e5ce8184cee9ce5336998ed241a0cc2e6eb
|
||||
@@ -231,6 +231,8 @@ namespace System.Data.SqlClient
|
||||
destination._sourceVersion = _sourceVersion;
|
||||
destination._sourceColumnNullMapping = _sourceColumnNullMapping;
|
||||
destination._isNullable = _isNullable;
|
||||
destination._parameterName = _parameterName;
|
||||
destination._isNull = _isNull;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Xunit;
|
||||
|
||||
namespace System.Data.SqlClient.ManualTesting.Tests
|
||||
{
|
||||
public class SqlAdapterUpdateBatch
|
||||
{
|
||||
[CheckConnStrSetupFact]
|
||||
public void SqlAdapterTest()
|
||||
{
|
||||
string tableName = "BatchDemoTable";
|
||||
try
|
||||
{
|
||||
var createTableQuery = "IF NOT EXISTS (SELECT * FROM sysobjects WHERE name='BatchDemoTable' AND xtype='U')" +
|
||||
" CREATE TABLE [dbo].[" + tableName + "]([TransactionNumber][int] IDENTITY(1, 1) NOT NULL,[Level] [nvarchar] (50) NOT NULL," +
|
||||
"[Message] [nvarchar] (500) NOT NULL,[EventTime] [datetime]NOT NULL,CONSTRAINT[PK_BatchDemoTable] " +
|
||||
"PRIMARY KEY CLUSTERED([TransactionNumber] ASC)WITH(PAD_INDEX = OFF,STATISTICS_NORECOMPUTE = OFF, " +
|
||||
"IGNORE_DUP_KEY = OFF,ALLOW_ROW_LOCKS = ON,ALLOW_PAGE_LOCKS = ON,FILLFACTOR = 90) ON[PRIMARY]) ON[PRIMARY]";
|
||||
|
||||
using (var connection = new SqlConnection(DataTestUtility.TcpConnStr))
|
||||
using (var cmd = new SqlCommand(createTableQuery, connection))
|
||||
{
|
||||
connection.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
ExecuteNonQueries();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
Console.WriteLine(ex.StackTrace);
|
||||
}
|
||||
finally
|
||||
{
|
||||
var dropTableQuery = "DROP TABLE IF EXISTS " + tableName;
|
||||
using (var connection = new SqlConnection(DataTestUtility.TcpConnStr))
|
||||
using (var cmd = new SqlCommand(dropTableQuery, connection))
|
||||
{
|
||||
connection.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class EventInfo
|
||||
{
|
||||
public string Level { get; set; }
|
||||
public string Message { get; set; }
|
||||
public DateTime EventTime { get; set; }
|
||||
|
||||
public EventInfo()
|
||||
{
|
||||
EventTime = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
public static void ExecuteNonQueries()
|
||||
{
|
||||
List<EventInfo> entities = new List<EventInfo>
|
||||
{
|
||||
new EventInfo {Level = "L1", Message = "Message 1"},
|
||||
new EventInfo {Level = "L2", Message = "Message 2"},
|
||||
new EventInfo {Level = "L3", Message = "Message 3"},
|
||||
new EventInfo {Level = "L4", Message = "Message 4"},
|
||||
};
|
||||
|
||||
var sql = "INSERT INTO BatchDemoTable(Level, Message, EventTime) VALUES(@Level, @Message, @EventTime)";
|
||||
using (var connection = new SqlConnection(DataTestUtility.TcpConnStr))
|
||||
using (var adapter = new SqlDataAdapter())
|
||||
using (var cmd = new SqlCommand(sql, connection))
|
||||
{
|
||||
cmd.Parameters.Add(new SqlParameter("@Level", System.Data.SqlDbType.NVarChar, 50, "Level"));
|
||||
cmd.Parameters.Add(new SqlParameter("@Message", SqlDbType.NVarChar, 500, "Message"));
|
||||
cmd.Parameters.Add(new SqlParameter("@EventTime", SqlDbType.DateTime, 0, "EventTime"));
|
||||
cmd.UpdatedRowSource = UpdateRowSource.None;
|
||||
|
||||
adapter.InsertCommand = cmd;
|
||||
adapter.UpdateBatchSize = 2;
|
||||
|
||||
adapter.Update(ConvertToTable(entities));
|
||||
}
|
||||
}
|
||||
private static DataTable ConvertToTable(List<EventInfo> entities)
|
||||
{
|
||||
var table = new DataTable(typeof(EventInfo).Name);
|
||||
|
||||
table.Columns.Add("Level", typeof(string));
|
||||
table.Columns.Add("Message", typeof(string));
|
||||
table.Columns.Add("EventTime", typeof(DateTime));
|
||||
|
||||
foreach (var entity in entities)
|
||||
{
|
||||
var row = table.NewRow();
|
||||
row["Level"] = entity.Level;
|
||||
row["Message"] = entity.Message;
|
||||
row["EventTime"] = entity.EventTime;
|
||||
table.Rows.Add(row);
|
||||
}
|
||||
return table;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,7 @@
|
||||
<Compile Include="SQL\ParameterTest\DateTimeVariantTest.cs" />
|
||||
<Compile Include="SQL\ParameterTest\OutputParameter.cs" />
|
||||
<Compile Include="SQL\ParameterTest\ParametersTest.cs" />
|
||||
<Compile Include="SQL\ParameterTest\SqlAdapterUpdateBatch.cs" />
|
||||
<Compile Include="SQL\ParameterTest\SqlVariantParam.cs" />
|
||||
<Compile Include="SQL\ParameterTest\SteAttribute.cs" />
|
||||
<Compile Include="SQL\ParameterTest\SteParam.cs" />
|
||||
|
||||
Reference in New Issue
Block a user