3

I am trying out this esent example for c++ developers.I have the latest Windows SDK installed and i am using Dec C++.I have my includes at C:\Dev-Cpp\include.I have tried copying esent.h to my includes directory but i still get very many errors.This is the whole code.

#undef   JET_VERSION 
#define  JET_VERSION 0x0501 
#include <stdio.h> 
#include <string.h> 
#include <esent.h>

int main(int argc, char * argv[]) {
       JET_INSTANCE instance; 
       JET_SESID sesid;
       JET_DBID dbid;
       JET_TABLEID tableid;

       JET_COLUMNDEF columndef = {0};
       JET_COLUMNID columnid;

       // Initialize ESENT. Setting JET_paramCircularLog to 1 means ESENT will automatically
       // delete unneeded logfiles. JetInit will inspect the logfiles to see if the last
       // shutdown was clean. If it wasn't (e.g. the application crashed) recovery will be
       // run automatically bringing the database to a consistent state.
       Call(JetCreateInstance(&instance, "instance"));
       Call(JetSetSystemParameter(&instance, JET_sesidNil, JET_paramCircularLog, 1, NULL));
       Call(JetInit(&instance));
       Call(JetBeginSession(instance, &sesid, 0, 0));

       // Create the database. To open an existing database use the JetAttachDatabase 
       // and JetOpenDatabase APIs
       Call(JetCreateDatabase(sesid, "edbtest.db", 0, &dbid, JET_bitDbOverwriteExisting));

       // Create the table. Meta-data operations are transacted and can be performed concurrently.
       // For example, one session can add a column to a table while another session is reading
       // or updating records in the same table.
       // This table has no indexes defined, so it will use the default sequential index. Indexes
       // can be defined with the JetCreateIndex API.
       Call(JetBeginTransaction(sesid));
       Call(JetCreateTable(sesid, dbid, "table", 0, 100, &tableid));
       columndef.cbStruct = sizeof(columndef);
       columndef.coltyp = JET_coltypLongText;
       columndef.cp = 1252;
       Call(JetAddColumn(sesid, tableid, "column1", &columndef, NULL, 0, &columnid));
       Call(JetCommitTransaction(sesid, JET_bitCommitLazyFlush));

       // Insert a record. This table only has one column but a table can have slightly over 64,000
       // columns defined. Unless a column is declared as fixed or variable it won't take any space
       // in the record unless set. An individual record can have several hundred columns set at one
       // time, the exact number depends on the database page size and the contents of the columns.
       Call(JetBeginTransaction(sesid));
       Call(JetPrepareUpdate(sesid, tableid, JET_prepInsert));
       char * message = "Hello world";
       Call(JetSetColumn(sesid, tableid, columnid, message, strlen(message)+1, 0, NULL));
       Call(JetUpdate(sesid, tableid, NULL, 0, NULL));
       Call(JetCommitTransaction(sesid, 0));    // Use JetRollback() to abort the transaction

       // Retrieve a column from the record. Here we move to the first record with JetMove. By using
       // JetMoveNext it is possible to iterate through all records in a table. Use JetMakeKey and
       // JetSeek to move to a particular record.
       Call(JetMove(sesid, tableid, JET_MoveFirst, 0));
       char buffer[1024];
       Call(JetRetrieveColumn(sesid, tableid, columnid, buffer, sizeof(buffer), NULL, 0, NULL));
       printf("%s", buffer);

       // Terminate ESENT. This performs a clean shutdown.
       JetCloseTable(sesid, tableid);
       JetEndSession(sesid, 0);
       JetTerm(instance);
       return 0;
}

What do i need to do for my code to compile successfully?.

Here are some of the compiler errors:

g++.exe "C:\dev\esent-example.cpp" -o "C:\dev\esent-example.exe" -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Dev-Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
In file included from C:/Dev-Cpp/include/specstrings.h:11,
 from C:/Dev-Cpp/include/esent.h:27,
 from C:\dev\esent-example.cpp:5:
C:/Dev-Cpp/include/sal.h:23:28: linux/spinlock.h: No such file or directory
C:/Dev-Cpp/include/sal.h:25:21: asm/pal.h: No such file or directory 
Mat
  • 202,337
  • 40
  • 393
  • 406
Gandalf
  • 1
  • 29
  • 94
  • 165
  • Please post the exact errors you're getting, or at least the first 10-20 lines - we can't really guess. – Mat Mar 15 '11 at 11:53
  • Please edit your question next time, this is completely unreadable in the comments. – Mat Mar 15 '11 at 12:02
  • On MSDN http://blogs.msdn.com/b/windowssdk/archive/2008/10/23/esent-extensible-storage-engine-api-in-the-windows-sdk.aspx its said you only need to link esent.lib and esent.h,it appears to me i will need more than the two.Its like one file requires a bunch of others. – Gandalf Mar 15 '11 at 12:13

1 Answers1

0

The Extensible Storage Engine api is quite old. The docs for it have been retired, it think it was deprecated back in 2001. The header file is still available in the SDK only to support legacy code.

I can get your code built with Visual Studio. If you really want to pursue this then you'd be wise to use an MSVC compiler and the MSFT version of the Windows SDK. You can download the C++ Express edition of Visual Studio for free, it should have everything you need to build this. Investing time into this isn't a very good idea.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • I will try to compile it using Visual studio.Does it mean when the api is retired the ese technoly is retired?.I have been reading Laurion's blog and answered my last ese question.There is a blog dedicated to ESE on the msdn http://blogs.msdn.com/b/laurionb/ . Please explain why i shouldn't invest time in ESE while it offers all those great features. – Gandalf Mar 15 '11 at 14:53
  • That blog indeed does suggest that it is alive and well. It also mentions how nobody is aware of that :) That doesn't exactly explain why the documentation is retired though, maybe that's why nobody is aware. I dunno, I do have the 64-bit esent.lib link library, that's usually a good sign. Visual Studio will get it built, good luck with it. – Hans Passant Mar 15 '11 at 15:02
  • Thanks for your insights."It also mentions how nobody is aware of that :)" ,Laurion likes this. – Gandalf Mar 15 '11 at 15:43
  • 3
    The ESE was _introduced_ in Windows 2000, certainly not deprecated in 2001. Indeed still alive and well in Windows 10 (with evolutions) and the documentation is available on MSDN: https://msdn.microsoft.com/en-us/library/gg269259(v=exchg.10).aspx – Axel Rietschin Aug 30 '15 at 10:12
  • ESE is alive and well. Both the documentation and the source code itself are now also up on GitHub: https://github.com/MicrosoftDocs/win32/tree/docs/desktop-src/extensible-storage-engine and https://github.com/microsoft/Extensible-Storage-Engine – Tatiana Racheva Apr 05 '21 at 23:52