ESENT: fix the index creation failure #277

This commit is contained in:
Namhyeon Go 2025-06-23 17:36:03 +09:00
parent dfef7a622f
commit 0cb0f9303d
2 changed files with 9 additions and 8 deletions

View File

@ -15,7 +15,6 @@ namespace WelsonJS.Launcher
private string entryFileName; private string entryFileName;
private string scriptName; private string scriptName;
private const string timestampFormat = "yyyy-MM-dd HH:mm:ss"; private const string timestampFormat = "yyyy-MM-dd HH:mm:ss";
private static MetadataStore metadataStore;
public InstancesForm() public InstancesForm()
{ {

View File

@ -105,20 +105,22 @@ namespace WelsonJS.Launcher
Api.JetAddColumn(_session, tableid, col.Name, coldef, null, 0, out _); Api.JetAddColumn(_session, tableid, col.Name, coldef, null, 0, out _);
} }
string indexName = "primary"; string indexKey = $"+{_primaryKey.Name}\0";
string indexKey = $"+{_primaryKey}\0\0"; // Primary key ASC int keyLength = Encoding.ASCII.GetByteCount(indexKey + "\0"); // double null-terminated
string fullKeyDescription = indexKey + "\0";
Api.JetCreateIndex( Api.JetCreateIndex(
_session, _session,
tableid, tableid,
indexName, "primary",
CreateIndexGrbit.IndexPrimary | CreateIndexGrbit.IndexUnique, CreateIndexGrbit.IndexPrimary | CreateIndexGrbit.IndexUnique,
indexKey, fullKeyDescription,
indexKey.Length, keyLength,
100); 100
);
Api.JetCloseTable(_session, tableid);
Api.JetCommitTransaction(_session, CommitTransactionGrbit.None); Api.JetCommitTransaction(_session, CommitTransactionGrbit.None);
Api.JetCloseTable(_session, tableid);
} }
private void CacheColumns() private void CacheColumns()