未验证 提交 717accb2 编写于 作者: O Omar Tawfik 提交者: GitHub

Revert "Merge pull request #25047 from Therzok/sqlite-blob" (#27484)

上级 d3a28d45
......@@ -230,7 +230,7 @@
<SystemXmlXmlDocumentVersion>4.3.0</SystemXmlXmlDocumentVersion>
<SystemXmlXmlSerializerVersion>4.3.0</SystemXmlXmlSerializerVersion>
<SystemXmlXPathXDocumentVersion>4.3.0</SystemXmlXPathXDocumentVersion>
<SQLitePCLRawbundle_greenVersion>1.1.11</SQLitePCLRawbundle_greenVersion>
<SQLitePCLRawbundle_greenVersion>1.1.2</SQLitePCLRawbundle_greenVersion>
<UIAComWrapperVersion>1.1.0.14</UIAComWrapperVersion>
<MicrosoftVSSDKBuildToolsVersion>15.8.68-develop-g109a00ff</MicrosoftVSSDKBuildToolsVersion>
<VSExternalAPIsCodingConventionsVersion>1.0.60704.2</VSExternalAPIsCodingConventionsVersion>
......
......@@ -80,11 +80,11 @@
<PackageReference Include="Microsoft.VisualStudio.Validation" Version="$(MicrosoftVisualStudioValidationVersion)" />
</ItemGroup>
<ItemGroup>
<Content Include="$(NuGetPackageRoot)\sqlitepclraw.lib.e_sqlite3.v110_xp\$(SQLitePCLRawbundle_greenVersion)\runtimes\win-x86\native\e_sqlite3.dll">
<Content Include="$(NuGetPackageRoot)\sqlitepclraw.lib.e_sqlite3.v110_xp\1.1.2\runtimes\win7-x86\native\e_sqlite3.dll">
<Link>x86\e_sqlite3.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(NuGetPackageRoot)\sqlitepclraw.lib.e_sqlite3.v110_xp\$(SQLitePCLRawbundle_greenVersion)\runtimes\win-x64\native\e_sqlite3.dll">
<Content Include="$(NuGetPackageRoot)\sqlitepclraw.lib.e_sqlite3.v110_xp\1.1.2\runtimes\win7-x64\native\e_sqlite3.dll">
<Link>x64\e_sqlite3.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
......
......@@ -241,16 +241,16 @@
<NuGetPackageToIncludeInVsix Include="Mono.Cecil" />
</ItemGroup>
<ItemGroup>
<VSIXSourceItem Include="$(NuGetPackageRoot)\SQLitePCLRaw.bundle_green\$(SQLitePCLRawbundle_greenVersion)\lib\net45\SQLitePCLRaw.batteries_green.dll" />
<VSIXSourceItem Include="$(NuGetPackageRoot)\SQLitePCLRaw.bundle_green\$(SQLitePCLRawbundle_greenVersion)\lib\net45\SQLitePCLRaw.batteries_v2.dll" />
<VSIXSourceItem Include="$(NuGetPackageRoot)\SQLitePCLRaw.provider.e_sqlite3.net45\$(SQLitePCLRawbundle_greenVersion)\lib\net45\SQLitePCLRaw.provider.e_sqlite3.dll" />
<VSIXSourceItem Include="$(NuGetPackageRoot)\SQLitePCLRaw.core\$(SQLitePCLRawbundle_greenVersion)\lib\net45\SQLitePCLRaw.core.dll" />
<Content Include="$(NuGetPackageRoot)\sqlitepclraw.lib.e_sqlite3.v110_xp\$(SQLitePCLRawbundle_greenVersion)\runtimes\win-x86\native\e_sqlite3.dll">
<VSIXSourceItem Include="$(NuGetPackageRoot)\SQLitePCLRaw.bundle_green\1.1.2\lib\net45\SQLitePCLRaw.batteries_green.dll" />
<VSIXSourceItem Include="$(NuGetPackageRoot)\SQLitePCLRaw.bundle_green\1.1.2\lib\net45\SQLitePCLRaw.batteries_v2.dll" />
<VSIXSourceItem Include="$(NuGetPackageRoot)\SQLitePCLRaw.provider.e_sqlite3.net45\1.1.2\lib\net45\SQLitePCLRaw.provider.e_sqlite3.dll" />
<VSIXSourceItem Include="$(NuGetPackageRoot)\SQLitePCLRaw.core\1.1.2\lib\net45\SQLitePCLRaw.core.dll" />
<Content Include="$(NuGetPackageRoot)\sqlitepclraw.lib.e_sqlite3.v110_xp\1.1.2\runtimes\win7-x86\native\e_sqlite3.dll">
<Link>x86\e_sqlite3.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Content Include="$(NuGetPackageRoot)\sqlitepclraw.lib.e_sqlite3.v110_xp\$(SQLitePCLRawbundle_greenVersion)\runtimes\win-x64\native\e_sqlite3.dll">
<Content Include="$(NuGetPackageRoot)\sqlitepclraw.lib.e_sqlite3.v110_xp\1.1.2\runtimes\win7-x64\native\e_sqlite3.dll">
<Link>x64\e_sqlite3.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
......
......@@ -184,7 +184,7 @@ private void Rollback(bool throwOnError)
public int LastInsertRowId()
=> (int)raw.sqlite3_last_insert_rowid(_handle);
public Stream ReadBlob(byte[] dataTableName, byte[] dataColumnName, long rowId)
public Stream ReadBlob(string dataTableName, string dataColumnName, long rowId)
{
// NOTE: we do need to do the blob reading in a transaction because of the
// following: https://www.sqlite.org/c3ref/blob_open.html
......@@ -204,12 +204,10 @@ public Stream ReadBlob(byte[] dataTableName, byte[] dataColumnName, long rowId)
return stream;
}
private static readonly byte[] mainPtr = Util.ToUtf8WithNullTerminator("main");
private Stream ReadBlob_InTransaction(byte[] tableName, byte[] columnName, long rowId)
private Stream ReadBlob_InTransaction(string tableName, string columnName, long rowId)
{
const int ReadOnlyFlags = 0;
var result = raw.sqlite3_blob_open(_handle, mainPtr, tableName, columnName, rowId, ReadOnlyFlags, out var blob);
var result = raw.sqlite3_blob_open(_handle, "main", tableName, columnName, rowId, ReadOnlyFlags, out var blob);
if (result == raw.SQLITE_ERROR)
{
// can happen when rowId points to a row that hasn't been written to yet.
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Text;
namespace Microsoft.CodeAnalysis.SQLite
{
internal static class Util
{
internal static byte[] ToUtf8WithNullTerminator(string text)
{
if (text == null)
{
return null;
}
// SQLite expects null terminated UTF8, so append an extra null terminator
return Encoding.UTF8.GetBytes(text + "\0");
}
}
}
......@@ -45,7 +45,6 @@ public Accessor(SQLitePersistentStorage storage)
}
protected abstract string DataTableName { get; }
protected abstract byte[] DataTableNamePtr { get; }
protected abstract bool TryGetDatabaseId(SqlConnection connection, TKey key, out TDatabaseId dataId);
protected abstract void BindFirstParameter(SqlStatement statement, TDatabaseId dataId);
......@@ -147,7 +146,7 @@ private Stream ReadBlob(SqlConnection connection, TDatabaseId dataId)
// data for a row in our system can change, the ID will always stay the
// same, and the data will always be valid for our ID. So there is no
// safety issue here.
return connection.ReadBlob(DataTableNamePtr, DataColumnNamePtr, rowId);
return connection.ReadBlob(DataTableName, DataColumnName, rowId);
}
return null;
......
......@@ -54,7 +54,6 @@ internal partial class SQLitePersistentStorage : AbstractPersistentStorage
/// -----------------------------------------------
/// </summary>
private const string SolutionDataTableName = "SolutionData" + Version;
private static readonly byte[] SolutionDataTableNamePtr = Util.ToUtf8WithNullTerminator(SolutionDataTableName);
/// <summary>
/// Inside the DB we have a table for data that we want associated with a <see cref="Project"/>.
......@@ -72,7 +71,6 @@ internal partial class SQLitePersistentStorage : AbstractPersistentStorage
/// -----------------------------------------------
/// </summary>
private const string ProjectDataTableName = "ProjectData" + Version;
private static readonly byte[] ProjectDataTableNamePtr = Util.ToUtf8WithNullTerminator(ProjectDataTableName);
/// <summary>
/// Inside the DB we have a table for data that we want associated with a <see cref="Document"/>.
......@@ -90,11 +88,9 @@ internal partial class SQLitePersistentStorage : AbstractPersistentStorage
/// ----------------------------------------------
/// </summary>
private const string DocumentDataTableName = "DocumentData" + Version;
private static readonly byte[] DocumentDataTableNamePtr = Util.ToUtf8WithNullTerminator(DocumentDataTableName);
private const string DataIdColumnName = "DataId";
private const string DataColumnName = "Data";
private static readonly byte[] DataColumnNamePtr = Util.ToUtf8WithNullTerminator(DataColumnName);
private readonly CancellationTokenSource _shutdownTokenSource = new CancellationTokenSource();
......
......@@ -29,7 +29,6 @@ public DocumentAccessor(SQLitePersistentStorage storage) : base(storage)
}
protected override string DataTableName => DocumentDataTableName;
protected override byte[] DataTableNamePtr => DocumentDataTableNamePtr;
protected override (DocumentId, string) GetWriteQueueKey((Document document, string name) key)
=> (key.document.Id, key.name);
......
......@@ -29,7 +29,6 @@ public ProjectAccessor(SQLitePersistentStorage storage) : base(storage)
}
protected override string DataTableName => ProjectDataTableName;
protected override byte[] DataTableNamePtr => ProjectDataTableNamePtr;
protected override (ProjectId projectId, string name) GetWriteQueueKey((Project project, string name) key)
=> (key.project.Id, key.name);
......
......@@ -27,7 +27,6 @@ public SolutionAccessor(SQLitePersistentStorage storage) : base(storage)
}
protected override string DataTableName => SolutionDataTableName;
protected override byte[] DataTableNamePtr => SolutionDataTableNamePtr;
protected override string GetWriteQueueKey(string key)
=> key;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册