duckdb 0.4.1-dev1019.0 → 0.4.1-dev1025.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "duckdb",
3
3
  "main": "./lib/duckdb.js",
4
- "version": "0.4.1-dev1019.0",
4
+ "version": "0.4.1-dev1025.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -116657,6 +116657,16 @@ void duckdb_function_set_error(duckdb_function_info info, const char *error) {
116657
116657
 
116658
116658
  using duckdb::DatabaseData;
116659
116659
 
116660
+ struct CAPITaskState {
116661
+ CAPITaskState(duckdb::DatabaseInstance &db)
116662
+ : db(db), marker(duckdb::make_unique<duckdb::atomic<bool>>(true)), execute_count(0) {
116663
+ }
116664
+
116665
+ duckdb::DatabaseInstance &db;
116666
+ duckdb::unique_ptr<duckdb::atomic<bool>> marker;
116667
+ duckdb::atomic<idx_t> execute_count;
116668
+ };
116669
+
116660
116670
  void duckdb_execute_tasks(duckdb_database database, idx_t max_tasks) {
116661
116671
  if (!database) {
116662
116672
  return;
@@ -116666,6 +116676,46 @@ void duckdb_execute_tasks(duckdb_database database, idx_t max_tasks) {
116666
116676
  scheduler.ExecuteTasks(max_tasks);
116667
116677
  }
116668
116678
 
116679
+ duckdb_task_state duckdb_create_task_state(duckdb_database database) {
116680
+ if (!database) {
116681
+ return nullptr;
116682
+ }
116683
+ auto wrapper = (DatabaseData *)database;
116684
+ auto state = new CAPITaskState(*wrapper->database->instance);
116685
+ return state;
116686
+ }
116687
+
116688
+ void duckdb_execute_tasks_state(duckdb_task_state state_p) {
116689
+ if (!state_p) {
116690
+ return;
116691
+ }
116692
+ auto state = (CAPITaskState *)state_p;
116693
+ auto &scheduler = duckdb::TaskScheduler::GetScheduler(state->db);
116694
+ state->execute_count++;
116695
+ scheduler.ExecuteForever(state->marker.get());
116696
+ }
116697
+
116698
+ void duckdb_finish_execution(duckdb_task_state state_p) {
116699
+ if (!state_p) {
116700
+ return;
116701
+ }
116702
+ auto state = (CAPITaskState *)state_p;
116703
+ *state->marker = false;
116704
+ if (state->execute_count > 0) {
116705
+ // signal to the threads to wake up
116706
+ auto &scheduler = duckdb::TaskScheduler::GetScheduler(state->db);
116707
+ scheduler.Signal(state->execute_count);
116708
+ }
116709
+ }
116710
+
116711
+ void duckdb_destroy_task_state(duckdb_task_state state_p) {
116712
+ if (!state_p) {
116713
+ return;
116714
+ }
116715
+ auto state = (CAPITaskState *)state_p;
116716
+ delete state;
116717
+ }
116718
+
116669
116719
 
116670
116720
 
116671
116721
 
@@ -149327,7 +149377,7 @@ void TaskScheduler::ExecuteForever(atomic<bool> *marker) {
149327
149377
  unique_ptr<Task> task;
149328
149378
  // loop until the marker is set to false
149329
149379
  while (*marker) {
149330
- // wait for a signal with a timeout; the timeout allows us to periodically check
149380
+ // wait for a signal with a timeout
149331
149381
  queue->semaphore.wait();
149332
149382
  if (queue->q.try_dequeue(task)) {
149333
149383
  task->Execute(TaskExecutionMode::PROCESS_ALL);
@@ -149383,6 +149433,12 @@ void TaskScheduler::SetThreads(int32_t n) {
149383
149433
  #endif
149384
149434
  }
149385
149435
 
149436
+ void TaskScheduler::Signal(idx_t n) {
149437
+ #ifndef DUCKDB_NO_THREADS
149438
+ queue->semaphore.signal(n);
149439
+ #endif
149440
+ }
149441
+
149386
149442
  void TaskScheduler::SetThreadsInternal(int32_t n) {
149387
149443
  #ifndef DUCKDB_NO_THREADS
149388
149444
  if (threads.size() == idx_t(n - 1)) {
@@ -149394,7 +149450,7 @@ void TaskScheduler::SetThreadsInternal(int32_t n) {
149394
149450
  for (idx_t i = 0; i < threads.size(); i++) {
149395
149451
  *markers[i] = false;
149396
149452
  }
149397
- queue->semaphore.signal(threads.size());
149453
+ Signal(threads.size());
149398
149454
  // now join the threads to ensure they are fully stopped before erasing them
149399
149455
  for (idx_t i = 0; i < threads.size(); i++) {
149400
149456
  threads[i]->internal_thread->join();
@@ -162817,6 +162873,7 @@ unique_ptr<AlterStatement> Transformer::TransformAlterSequence(duckdb_libpgquery
162817
162873
  throw NotImplementedException("ALTER SEQUENCE option not supported yet!");
162818
162874
  }
162819
162875
  }
162876
+ result->info->if_exists = stmt->missing_ok;
162820
162877
  return result;
162821
162878
  }
162822
162879
  } // namespace duckdb
package/src/duckdb.hpp CHANGED
@@ -11,8 +11,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
11
11
  #pragma once
12
12
  #define DUCKDB_AMALGAMATION 1
13
13
  #define DUCKDB_AMALGAMATION_EXTENDED 1
14
- #define DUCKDB_SOURCE_ID "dd29735fe"
15
- #define DUCKDB_VERSION "v0.4.1-dev1019"
14
+ #define DUCKDB_SOURCE_ID "f614f426a"
15
+ #define DUCKDB_VERSION "v0.4.1-dev1025"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //
@@ -11189,6 +11189,9 @@ public:
11189
11189
  //! Returns the number of threads
11190
11190
  int32_t NumberOfThreads();
11191
11191
 
11192
+ //! Send signals to n threads, signalling for them to wake up and attempt to execute a task
11193
+ void Signal(idx_t n);
11194
+
11192
11195
  private:
11193
11196
  void SetThreadsInternal(int32_t n);
11194
11197
 
@@ -17761,6 +17764,8 @@ DUCKDB_API void duckdb_destroy_arrow(duckdb_arrow *result);
17761
17764
  //===--------------------------------------------------------------------===//
17762
17765
  // Threading Information
17763
17766
  //===--------------------------------------------------------------------===//
17767
+ typedef void *duckdb_task_state;
17768
+
17764
17769
  /*!
17765
17770
  Execute DuckDB tasks on this thread.
17766
17771
 
@@ -17771,6 +17776,44 @@ Will return after `max_tasks` have been executed, or if there are no more tasks
17771
17776
  */
17772
17777
  DUCKDB_API void duckdb_execute_tasks(duckdb_database database, idx_t max_tasks);
17773
17778
 
17779
+ /*!
17780
+ Creates a task state that can be used with duckdb_execute_tasks_state to execute tasks until
17781
+ duckdb_finish_execution is called on the state.
17782
+
17783
+ duckdb_destroy_state should be called on the result in order to free memory.
17784
+
17785
+ * database: The database object to create the task state for
17786
+ * returns: The task state that can be used with duckdb_execute_tasks_state.
17787
+ */
17788
+ DUCKDB_API duckdb_task_state duckdb_create_task_state(duckdb_database database);
17789
+
17790
+ /*!
17791
+ Execute DuckDB tasks on this thread.
17792
+
17793
+ The thread will keep on executing tasks forever, until duckdb_finish_execution is called on the state.
17794
+ Multiple threads can share the same duckdb_task_state.
17795
+
17796
+ * state: The task state of the executor
17797
+ */
17798
+ DUCKDB_API void duckdb_execute_tasks_state(duckdb_task_state state);
17799
+
17800
+ /*!
17801
+ Finish execution on a specific task.
17802
+
17803
+ * state: The task state to finish execution
17804
+ */
17805
+ DUCKDB_API void duckdb_finish_execution(duckdb_task_state state);
17806
+
17807
+ /*!
17808
+ Destroys the task state returned from duckdb_create_task_state.
17809
+
17810
+ Note that this should not be called while there is an active duckdb_execute_tasks_state running
17811
+ on the task state.
17812
+
17813
+ * state: The task state to clean up
17814
+ */
17815
+ DUCKDB_API void duckdb_destroy_task_state(duckdb_task_state state);
17816
+
17774
17817
  #ifdef __cplusplus
17775
17818
  }
17776
17819
  #endif