DuckDB.AppenderType

An appender object that can be used to append rows to an existing table.

  • DateTime objects in Julia are stored in milliseconds since the Unix epoch but are converted to microseconds when stored in duckdb.
  • Time objects in Julia are stored in nanoseconds since midnight but are converted to microseconds when stored in duckdb.
  • Missing and Nothing are stored as NULL in duckdb, but will be converted to Missing when the data is queried back.

Example

using DuckDB, DataFrames, Dates
db = DuckDB.DB()

# create a table
DBInterface.execute(db, "CREATE OR REPLACE TABLE data(id INT PRIMARY KEY, value FLOAT, timestamp TIMESTAMP, date DATE)")

# data to insert 
len = 100
df = DataFrames.DataFrame(id=collect(1:len),
    value=rand(len),
    timestamp=Dates.now() + Dates.Second.(1:len),
    date=Dates.today() + Dates.Day.(1:len))

# append data by row
appender = DuckDB.Appender(db, "data")
for i in eachrow(df)
    for j in i
        DuckDB.append(appender, j)
    end
    DuckDB.end_row(appender)
end
# flush the appender after all rows
DuckDB.flush(appender)
DuckDB.close(appender)
DuckDB.ConnectionType

A connection object to a DuckDB database.

Transaction contexts are local to a single connection.

A connection can only run a single query concurrently. It is possible to open multiple connections to a single DuckDB database instance. Multiple connections can run multiple queries concurrently.

DuckDB.DBType

A DuckDB database object.

By default a DuckDB database object has an open connection object (db.mainconnection). When the database object is used directly in queries, it is actually the underlying mainconnection that is used.

It is possible to open new connections to a single database instance using DBInterface.connect(db).

DuckDB.duckdb_dateType

Days are stored as days since 1970-01-01

Use the duckdbfromdate/duckdbtodate function to extract individual information

DuckDB.duckdb_hugeintType

Hugeints are composed in a (lower, upper) component

The value of the hugeint is upper * 2^64 + lower

For easy usage, the functions duckdbhugeinttodouble/duckdbdoubletohugeint are recommended

DuckDB.duckdb_timeType

Time is stored as microseconds since 00:00:00

Use the duckdbfromtime/duckdbtotime function to extract individual information

DuckDB.duckdb_timestampType

Timestamps are stored as microseconds since 1970-01-01

Use the duckdbfromtimestamp/duckdbtotimestamp function to extract individual information

DBInterface.executeMethod
DBInterface.execute(db::DuckDB.DB, sql::String, [params])
DBInterface.execute(stmt::SQLite.Stmt, [params])

Bind any positional (params as Vector or Tuple) or named (params as NamedTuple or Dict) parameters to an SQL statement, given by db and sql or as an already prepared statement stmt, execute the query and return an iterator of result rows.

Note that the returned result row iterator only supports a single-pass, forward-only iteration of the result rows. Calling SQLite.reset!(result) will re-execute the query and reset the iterator back to the beginning.

The resultset iterator supports the Tables.jl interface, so results can be collected in any Tables.jl-compatible sink, like DataFrame(results), CSV.write("results.csv", results), etc.

DBInterface.prepareMethod
DBInterface.prepare(db::DuckDB.DB, sql::AbstractString)

Prepare an SQL statement given as a string in the DuckDB database; returns a DuckDB.Stmt object. See DBInterface.execute(@ref) for information on executing a prepared statement and passing parameters to bind. A DuckDB.Stmt object can be closed (resources freed) using DBInterface.close!(@ref).

DuckDB.duckdb_add_replacement_scanMethod

Add a replacement scan definition to the specified database

  • db: The database object to add the replacement scan to
  • replacement: The replacement scan callback
  • extra_data: Extra data that is passed back into the specified callback
  • delete_callback: The delete callback to call on the extra data, if any
DuckDB.duckdb_append_blobMethod

Append a blob value to the appender. DUCKDBAPI duckdbstate duckdbappendblob(duckdbappender appender, const void *data, idxt length);

DuckDB.duckdb_append_boolMethod

Append a bool value to the appender. DUCKDBAPI duckdbstate duckdbappendbool(duckdb_appender appender, bool value);

DuckDB.duckdb_append_dateMethod

Append a duckdbdate value to the appender. DUCKDBAPI duckdbstate duckdbappenddate(duckdbappender appender, duckdb_date value);

DuckDB.duckdb_append_doubleMethod

Append a double value to the appender. DUCKDBAPI duckdbstate duckdbappenddouble(duckdb_appender appender, double value);

DuckDB.duckdb_append_floatMethod

Append a float value to the appender. DUCKDBAPI duckdbstate duckdbappendfloat(duckdb_appender appender, float value);

DuckDB.duckdb_append_hugeintMethod

Append a duckdbhugeint value to the appender. DUCKDBAPI duckdbstate duckdbappendhugeint(duckdbappender appender, duckdb_hugeint value);

DuckDB.duckdb_append_int16Method

Append an int16t value to the appender. DUCKDBAPI duckdbstate duckdbappendint16(duckdbappender appender, int16_t value);

DuckDB.duckdb_append_int32Method

Append an int32t value to the appender. DUCKDBAPI duckdbstate duckdbappendint32(duckdbappender appender, int32_t value);

DuckDB.duckdb_append_int64Method

Append an int64t value to the appender. DUCKDBAPI duckdbstate duckdbappendint64(duckdbappender appender, int64_t value);

DuckDB.duckdb_append_int8Method

Append an int8t value to the appender. DUCKDBAPI duckdbstate duckdbappendint8(duckdbappender appender, int8_t value);

DuckDB.duckdb_append_intervalMethod

Append a duckdbinterval value to the appender. DUCKDBAPI duckdbstate duckdbappendinterval(duckdbappender appender, duckdb_interval value);

DuckDB.duckdb_append_nullMethod

Append a NULL value to the appender (of any type). DUCKDBAPI duckdbstate duckdbappendnull(duckdb_appender appender);

DuckDB.duckdb_append_timeMethod

Append a duckdbtime value to the appender. DUCKDBAPI duckdbstate duckdbappendtime(duckdbappender appender, duckdb_time value);

DuckDB.duckdb_append_timestampMethod

Append a duckdbtimestamp value to the appender. DUCKDBAPI duckdbstate duckdbappendtimestamp(duckdbappender appender, duckdb_timestamp value);

DuckDB.duckdb_append_uhugeintMethod

Append a duckdbuhugeint value to the appender. DUCKDBAPI duckdbstate duckdbappenduhugeint(duckdbappender appender, duckdb_uhugeint value);

DuckDB.duckdb_append_uint16Method

Append a uint16t value to the appender. DUCKDBAPI duckdbstate duckdbappenduint16(duckdbappender appender, uint16_t value);

DuckDB.duckdb_append_uint32Method

Append a uint32t value to the appender. DUCKDBAPI duckdbstate duckdbappenduint32(duckdbappender appender, uint32_t value);

DuckDB.duckdb_append_uint64Method

Append a uint64t value to the appender. DUCKDBAPI duckdbstate duckdbappenduint64(duckdbappender appender, uint64_t value);

DuckDB.duckdb_append_uint8Method

Append a uint8t value to the appender. DUCKDBAPI duckdbstate duckdbappenduint8(duckdbappender appender, uint8_t value);

DuckDB.duckdb_append_varcharMethod

Append a varchar value to the appender. DUCKDBAPI duckdbstate duckdbappendvarchar(duckdb_appender appender, const char *val);

DuckDB.duckdb_append_varchar_lengthMethod

Append a varchar value to the appender. DUCKDBAPI duckdbstate duckdbappendvarcharlength(duckdbappender appender, const char *val, idx_t length);

DuckDB.duckdb_appender_begin_rowMethod

A nop function, provided for backwards compatibility reasons. Does nothing. Only duckdb_appender_end_row is required. DUCKDBAPI duckdbstate duckdbappenderbeginrow(duckdbappender appender);

DuckDB.duckdb_appender_closeMethod

Close the appender, flushing all intermediate state in the appender to the table and closing it for further appends. This is generally not necessary. Call duckdb_appender_destroy instead.

  • appender: The appender to flush and close.
  • returns: DuckDBSuccess on success or DuckDBError on failure.

DUCKDBAPI duckdbstate duckdbappenderclose(duckdb_appender appender);

DuckDB.duckdb_appender_createMethod

Creates an appender object.

  • connection: The connection context to create the appender in.
  • schema: The schema of the table to append to, or nullptr for the default schema.
  • table: The table name to append to.
  • out_appender: The resulting appender object.
  • returns: DuckDBSuccess on success or DuckDBError on failure.

DUCKDBAPI duckdbstate duckdbappendercreate(duckdbconnection connection, const char *schema, const char *table, duckdbappender *out_appender);

DuckDB.duckdb_appender_destroyMethod

Close the appender and destroy it. Flushing all intermediate state in the appender to the table, and de-allocating all memory associated with the appender.

  • appender: The appender to flush, close and destroy.
  • returns: DuckDBSuccess on success or DuckDBError on failure.

DUCKDBAPI duckdbstate duckdbappenderdestroy(duckdb_appender *appender);

DuckDB.duckdb_appender_end_rowMethod

Finish the current row of appends. After end_row is called, the next row can be appended.

  • appender: The appender.
  • returns: DuckDBSuccess on success or DuckDBError on failure.

DUCKDBAPI duckdbstate duckdbappenderendrow(duckdbappender appender);

DuckDB.duckdb_appender_errorMethod

Returns the error message associated with the given appender. If the appender has no error message, this returns nullptr instead. The error message should not be freed. It will be de-allocated when duckdb_appender_destroy is called.

  • appender: The appender to get the error from.
  • returns: The error message, or nullptr if there is none.

DUCKDBAPI const char *duckdbappendererror(duckdbappender appender);

DuckDB.duckdb_appender_flushMethod

Flush the appender to the table, forcing the cache of the appender to be cleared and the data to be appended to the base table. This should generally not be used unless you know what you are doing. Instead, call duckdb_appender_destroy when you are done with the appender.

  • appender: The appender to flush.
  • returns: DuckDBSuccess on success or DuckDBError on failure.

DUCKDBAPI duckdbstate duckdbappenderflush(duckdb_appender appender);

DuckDB.duckdb_bind_add_result_columnMethod

Adds a result column to the output of the table function.

  • info: The info object
  • name: The name of the column
  • type: The logical type of the column
DuckDB.duckdb_bind_blobMethod

Binds a blob value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbindblob(duckdbpreparedstatement preparedstatement, idxt paramidx, const void *data, idxt length);

DuckDB.duckdb_bind_booleanMethod

Binds a bool value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbindboolean(duckdbpreparedstatement preparedstatement, idxt param_idx, bool val);

DuckDB.duckdb_bind_dateMethod

Binds a duckdbdate value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbinddate(duckdbpreparedstatement preparedstatement, idxt paramidx, duckdb_date val);

DuckDB.duckdb_bind_doubleMethod

Binds a double value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbinddouble(duckdbpreparedstatement preparedstatement, idxt param_idx, double val);

DuckDB.duckdb_bind_floatMethod

Binds a float value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbindfloat(duckdbpreparedstatement preparedstatement, idxt param_idx, float val);

DuckDB.duckdb_bind_get_extra_infoMethod

Retrieves the extra info of the function as set in duckdb_table_function_set_extra_info

  • info: The info object
  • returns: The extra info
DuckDB.duckdb_bind_get_parameterMethod

Retrieves the parameter at the given index.

The result must be destroyed with duckdb_destroy_value.

  • info: The info object
  • index: The index of the parameter to get
  • returns: The value of the parameter. Must be destroyed with duckdb_destroy_value.
DuckDB.duckdb_bind_hugeintMethod

Binds a duckdbhugeint value to the prepared statement at the specified index. */ DUCKDBAPI duckdbstate duckdbbindhugeint(duckdbpreparedstatement preparedstatement, idxt paramidx, duckdb_hugeint val);

DuckDB.duckdb_bind_int16Method

Binds an int16t value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbindint16(duckdbpreparedstatement preparedstatement, idxt paramidx, int16_t val);

DuckDB.duckdb_bind_int32Method

Binds an int32t value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbindint32(duckdbpreparedstatement preparedstatement, idxt paramidx, int32_t val);

DuckDB.duckdb_bind_int64Method

Binds an int64t value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbindint64(duckdbpreparedstatement preparedstatement, idxt paramidx, int64_t val);

DuckDB.duckdb_bind_int8Method

Binds an int8t value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbindint8(duckdbpreparedstatement preparedstatement, idxt paramidx, int8_t val);

DuckDB.duckdb_bind_intervalMethod

Binds a duckdbinterval value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbindinterval(duckdbpreparedstatement preparedstatement, idxt paramidx, duckdb_interval val);

DuckDB.duckdb_bind_nullMethod

Binds a NULL value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbindnull(duckdbpreparedstatement preparedstatement, idxt param_idx);

DuckDB.duckdb_bind_set_bind_dataMethod

Retrieves the parameter at the given index.

The result must be destroyed with duckdb_destroy_value.

  • info: The info object
  • index: The index of the parameter to get
  • returns: The value of the parameter. Must be destroyed with duckdb_destroy_value.
DuckDB.duckdb_bind_set_cardinalityMethod

Sets the cardinality estimate for the table function, used for optimization.

  • info: The bind data object.
  • is_exact: Whether or not the cardinality estimate is exact, or an approximation
DuckDB.duckdb_bind_timeMethod

Binds a duckdbtime value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbindtime(duckdbpreparedstatement preparedstatement, idxt paramidx, duckdb_time val);

DuckDB.duckdb_bind_timestampMethod

Binds a duckdbtimestamp value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbindtimestamp(duckdbpreparedstatement preparedstatement, idxt paramidx, duckdb_timestamp val);

DuckDB.duckdb_bind_uhugeintMethod

Binds an duckdbuhugeint value to the prepared statement at the specified index. */ DUCKDBAPI duckdbstate duckdbbindhugeint(duckdbpreparedstatement preparedstatement, idxt paramidx, duckdb_uhugeint val);

DuckDB.duckdb_bind_uint16Method

Binds an uint16t value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbinduint16(duckdbpreparedstatement preparedstatement, idxt paramidx, uint16_t val);

DuckDB.duckdb_bind_uint32Method

Binds an uint32t value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbinduint32(duckdbpreparedstatement preparedstatement, idxt paramidx, uint32_t val);

DuckDB.duckdb_bind_uint64Method

Binds an uint64t value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbinduint64(duckdbpreparedstatement preparedstatement, idxt paramidx, uint64_t val);

DuckDB.duckdb_bind_uint8Method

Binds an uint8t value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbinduint8(duckdbpreparedstatement preparedstatement, idxt paramidx, uint8_t val);

DuckDB.duckdb_bind_varcharMethod

Binds a null-terminated varchar value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbindvarchar(duckdbpreparedstatement preparedstatement, idxt param_idx, const char *val);

DuckDB.duckdb_bind_varchar_lengthMethod

Binds a varchar value to the prepared statement at the specified index. DUCKDBAPI duckdbstate duckdbbindvarcharlength(duckdbpreparedstatement preparedstatement, idxt paramidx, const char *val, idx_t length);

DuckDB.duckdb_closeMethod
duckdb_close(database)

Closes the specified database and de-allocates all memory allocated for that database. This should be called after you are done with any database allocated through duckdb_open. Note that failing to call duckdb_close (in case of e.g. a program crash) will not cause data corruption. Still it is recommended to always correctly close a database object after you are done with it.

  • database: The database object to shut down.
DuckDB.duckdb_column_countMethod
duckdb_column_count(result)

Returns the number of columns present in a the result object.

  • result: The result object.
  • returns: The number of columns present in the result object.
DuckDB.duckdb_column_dataMethod
duckdb_column_data(result,col)

Returns the data of a specific column of a result in columnar format. This is the fastest way of accessing data in a query result, as no conversion or type checking must be performed (outside of the original switch). If performance is a concern, it is recommended to use this API over the duckdb_value functions. The function returns a dense array which contains the result data. The exact type stored in the array depends on the corresponding duckdbtype (as provided by `duckdbcolumntype). For the exact type by which the data should be accessed, see the comments in [the types section](types) or theDUCKDBTYPEenum. For example, for a column of typeDUCKDBTYPEINTEGER`, rows can be accessed in the following manner:

int32_t *data = (int32_t *) duckdb_column_data(&result, 0);
printf("Data for row %d: %d\n", row, data[row]);
  • result: The result object to fetch the column data from.
  • col: The column index.
  • returns: The column data of the specified column.
DuckDB.duckdb_column_logical_typeMethod

Returns the logical column type of the specified column.

The return type of this call should be destroyed with duckdb_destroy_logical_type.

Returns NULL if the column is out of range.

  • result: The result object to fetch the column type from.
  • col: The column index.
  • returns: The logical column type of the specified column.
DuckDB.duckdb_column_nameMethod
duckdb_column_name(result,col)

Returns the column name of the specified column. The result should not need be freed; the column names will automatically be destroyed when the result is destroyed. Returns NULL if the column is out of range.

  • result: The result object to fetch the column name from.
  • col: The column index.
  • returns: The column name of the specified column.
DuckDB.duckdb_column_typeMethod
duckdb_column_type(result,col)

Returns the column type of the specified column. Returns DUCKDB_TYPE_INVALID if the column is out of range.

  • result: The result object to fetch the column type from.
  • col: The column index.
  • returns: The column type of the specified column.
DuckDB.duckdb_config_countMethod
duckdb_config_count()

This returns the total amount of configuration options available for usage with duckdb_get_config_flag. This should not be called in a loop as it internally loops over all the options.

  • returns: The amount of config options available.
DuckDB.duckdb_connectMethod
duckdb_connect(database, out_connection)

Opens a connection to a database. Connections are required to query the database, and store transactional state associated with the connection.

  • database: The database file to connect to.
  • out_connection: The result connection object.
  • returns: DuckDBSuccess on success or DuckDBError on failure.
DuckDB.duckdb_create_configMethod
duckdb_create_config(config)

Initializes an empty configuration object that can be used to provide start-up options for the DuckDB instance through duckdb_open_ext. This will always succeed unless there is a malloc failure.

  • out_config: The result configuration object.
  • returns: DuckDBSuccess on success or DuckDBError on failure.
DuckDB.duckdb_create_data_chunkMethod

Creates an empty DataChunk with the specified set of types.

  • types: An array of types of the data chunk.
  • column_count: The number of columns.
  • returns: The data chunk.
DuckDB.duckdb_create_decimal_typeMethod

Creates a duckdb_logical_type of type decimal with the specified width and scale The resulting type should be destroyed with duckdb_destroy_logical_type.

  • width: The width of the decimal type
  • scale: The scale of the decimal type
  • returns: The logical type.
DuckDB.duckdb_create_int64Method

Creates a value from an int64

  • value: The bigint value
  • returns: The value. This must be destroyed with duckdb_destroy_value.
DuckDB.duckdb_create_logical_typeMethod

Creates a duckdb_logical_type from a standard primitive type. The resulting type should be destroyed with duckdb_destroy_logical_type.

This should not be used with DUCKDB_TYPE_DECIMAL.

  • type: The primitive type to create.
  • returns: The logical type type.
DuckDB.duckdb_create_table_functionMethod

Creates a new empty table function.

The return value should be destroyed with duckdb_destroy_table_function.

  • returns: The table function object.
DuckDB.duckdb_create_task_stateMethod

Creates a task state that can be used with duckdbexecutetasksstate to execute tasks until duckdbfinish_execution is called on the state.

duckdbdestroystate should be called on the result in order to free memory.

  • returns: The task state that can be used with duckdbexecutetasks_state.
DuckDB.duckdb_create_varcharMethod

Creates a value from a null-terminated string

  • value: The null-terminated string
  • returns: The value. This must be destroyed with duckdb_destroy_value.
DuckDB.duckdb_create_varchar_lengthMethod

Creates a value from a string

  • value: The text
  • length: The length of the text
  • returns: The value. This must be destroyed with duckdb_destroy_value.
DuckDB.duckdb_data_chunk_get_sizeMethod

Retrieves the current number of tuples in a data chunk.

  • chunk: The data chunk to get the data from
  • returns: The number of tuples in the data chunk
DuckDB.duckdb_data_chunk_get_vectorMethod

Retrieves the vector at the specified column index in the data chunk.

The pointer to the vector is valid for as long as the chunk is alive. It does NOT need to be destroyed.

  • chunk: The data chunk to get the data from
  • returns: The vector
DuckDB.duckdb_data_chunk_resetMethod

Resets a data chunk, clearing the validity masks and setting the cardinality of the data chunk to 0.

  • chunk: The data chunk to reset.
DuckDB.duckdb_data_chunk_set_sizeMethod

Sets the current number of tuples in a data chunk.

  • chunk: The data chunk to set the size in
  • size: The number of tuples in the data chunk
DuckDB.duckdb_decimal_internal_typeMethod

Retrieves the internal storage type of a decimal type.

  • type: The logical type object
  • returns: The internal type of the decimal type
DuckDB.duckdb_decimal_scaleMethod

Retrieves the scale of a decimal type.

  • type: The logical type object
  • returns: The scale of the decimal type
DuckDB.duckdb_decimal_widthMethod

Retrieves the width of a decimal type.

  • type: The logical type object
  • returns: The width of the decimal type
DuckDB.duckdb_destroy_configMethod
duckdb_destroy_config(config)

Destroys the specified configuration option and de-allocates all memory allocated for the object.

  • config: The configuration object to destroy.
DuckDB.duckdb_destroy_pendingMethod

Closes the pending result and de-allocates all memory allocated for the result.

  • pending_result: The pending result to destroy.
DuckDB.duckdb_destroy_prepareMethod

Closes the prepared statement and de-allocates all memory allocated for that connection.

  • prepared_statement: The prepared statement to destroy.

DUCKDBAPI void duckdbdestroyprepare(duckdbpreparedstatement *preparedstatement);

DuckDB.duckdb_destroy_resultMethod
duckdb_destroy_result(result)

Closes the result and de-allocates all memory allocated for that connection.

  • result: The result to destroy.
DuckDB.duckdb_destroy_task_stateMethod

Destroys the task state returned from duckdbcreatetask_state.

Note that this should not be called while there is an active duckdbexecutetasks_state running on the task state.

  • state: The task state to clean up
DuckDB.duckdb_destroy_valueMethod

Destroys the value and de-allocates all memory allocated for that type.

  • value: The value to destroy.
DuckDB.duckdb_disconnectMethod
duckdb_disconnect(connection)

Closes the specified connection and de-allocates all memory allocated for that connection.

  • connection: The connection to close.
DuckDB.duckdb_enum_dictionary_valueMethod

Retrieves the dictionary value at the specified position from the enum.

The result must be freed with duckdb_free

  • type: The logical type object
  • index: The index in the dictionary
  • returns: The string value of the enum type. Must be freed with duckdb_free.
DuckDB.duckdb_enum_internal_typeMethod

Retrieves the internal storage type of an enum type.

  • type: The logical type object
  • returns: The internal type of the enum type
DuckDB.duckdb_execute_n_tasks_stateMethod

Execute DuckDB tasks on this thread.

The thread will keep on executing tasks until either duckdbfinishexecution is called on the state, max_tasks tasks have been executed or there are no more tasks to be executed.

Multiple threads can share the same duckdbtaskstate.

  • state: The task state of the executor
  • max_tasks: The maximum amount of tasks to execute
  • returns: The amount of tasks that have actually been executed
DuckDB.duckdb_execute_pendingMethod

Fully execute a pending query result, returning the final query result.

If duckdbpendingexecutetask has been called until DUCKDBPENDINGRESULTREADY was returned, this will return fast. Otherwise, all remaining tasks must be executed first.

  • pending_result: The pending result to execute.
  • out_result: The result object.
  • returns: DuckDBSuccess on success or DuckDBError on failure.
DuckDB.duckdb_execute_preparedMethod

Executes the prepared statement with the given bound parameters, and returns a materialized query result. This method can be called multiple times for each prepared statement, and the parameters can be modified between calls to this function.

  • prepared_statement: The prepared statement to execute.
  • out_result: The query result.
  • returns: DuckDBSuccess on success or DuckDBError on failure.

DUCKDBAPI duckdbstate duckdbexecuteprepared(duckdbpreparedstatement preparedstatement, duckdbresult *out_result);

DuckDB.duckdb_execute_tasksMethod

Execute DuckDB tasks on this thread.

Will return after max_tasks have been executed, or if there are no more tasks present.

  • database: The database object to execute tasks for
  • max_tasks: The maximum amount of tasks to execute
DuckDB.duckdb_execute_tasks_stateMethod

Execute DuckDB tasks on this thread.

The thread will keep on executing tasks forever, until duckdbfinishexecution is called on the state. Multiple threads can share the same duckdbtaskstate.

  • database: The database object to execute tasks for
  • state: The task state of the executor
DuckDB.duckdb_freeMethod

duckdbfree(ptr) Free a value returned from `duckdbmalloc,duckdbvaluevarcharorduckdbvalueblob`.

  • ptr: The memory region to de-allocate.

DUCKDBAPI void duckdbfree(void *ptr);

DuckDB.duckdb_from_time_tzMethod

Decompose a TIME_TZ objects into micros and a timezone offset.

Use duckdb_from_time to further decompose the micros into hour, minute, second and microsecond.

  • micros: The time object, as obtained from a DUCKDB_TYPE_TIME_TZ column.
  • out_micros: The microsecond component of the time.
  • out_offset: The timezone offset component of the time.
DuckDB.duckdb_function_get_bind_dataMethod

Gets the bind data set by duckdb_bind_set_bind_data during the bind.

Note that the bind data should be considered as read-only. For tracking state, use the init data instead.

  • info: The info object
  • returns: The bind data object
DuckDB.duckdb_get_config_flagMethod
duckdb_get_config_flag(index,out_name,out_description)

Obtains a human-readable name and description of a specific configuration option. This can be used to e.g. display configuration options. This will succeed unless index is out of range (i.e. >= duckdb_config_count). The result name or description MUST NOT be freed.

  • index: The index of the configuration option (between 0 and duckdb_config_count)
  • out_name: A name of the configuration flag.
  • out_description: A description of the configuration flag.
  • returns: DuckDBSuccess on success or DuckDBError on failure.
DuckDB.duckdb_get_int64Method

Obtains an int64 of the given value.

  • value: The value
  • returns: The int64 value, or 0 if no conversion is possible
DuckDB.duckdb_get_type_idMethod

Retrieves the type class of a duckdb_logical_type.

  • type: The logical type object
  • returns: The type id
DuckDB.duckdb_get_varcharMethod

Obtains a string representation of the given value. The result must be destroyed with duckdb_free.

  • value: The value
  • returns: The string value. This must be destroyed with duckdb_free.
DuckDB.duckdb_init_get_bind_dataMethod

Gets the bind data set by duckdb_bind_set_bind_data during the bind.

Note that the bind data should be considered as read-only. For tracking state, use the init data instead.

  • info: The info object
  • returns: The bind data object
DuckDB.duckdb_init_get_column_countMethod

Returns the number of projected columns.

This function must be used if projection pushdown is enabled to figure out which columns to emit.

  • info: The info object
  • returns: The number of projected columns.
DuckDB.duckdb_init_get_column_indexMethod

Returns the column index of the projected column at the specified position.

This function must be used if projection pushdown is enabled to figure out which columns to emit.

  • info: The info object
  • columnindex: The index at which to get the projected column index, from 0..duckdbinitgetcolumn_count(info)
  • returns: The column index of the projected column.
DuckDB.duckdb_init_get_extra_infoMethod

Retrieves the extra info of the function as set in duckdb_table_function_set_extra_info

  • info: The info object
  • returns: The extra info
DuckDB.duckdb_init_set_init_dataMethod

Sets the user-provided init data in the init object. This object can be retrieved again during execution.

  • info: The info object
  • extra_data: The init data object.
  • destroy: The callback that will be called to destroy the init data (if any)
DuckDB.duckdb_init_set_max_threadsMethod

Sets how many threads can process this table function in parallel (default: 1)

  • info: The info object
  • max_threads: The maximum amount of threads that can process this table function
DuckDB.duckdb_list_type_child_typeMethod

Retrieves the child type of the given list type.

The result must be freed with duckdb_destroy_logical_type

  • type: The logical type object
  • returns: The child type of the list type. Must be destroyed with duckdb_destroy_logical_type.
DuckDB.duckdb_list_vector_get_childMethod

Retrieves the child vector of a list vector.

The resulting vector is valid as long as the parent vector is valid.

  • vector: The vector
  • returns: The child vector
DuckDB.duckdb_mallocMethod

duckdb_malloc(size)

Allocate size bytes of memory using the duckdb internal malloc function. Any memory allocated in this manner should be freed using duckdb_free.

  • size: The number of bytes to allocate.
  • returns: A pointer to the allocated memory region.

DUCKDBAPI void *duckdbmalloc(size_t size);

DuckDB.duckdb_nparamsMethod

Returns the number of parameters that can be provided to the given prepared statement. Returns 0 if the query was not successfully prepared.

  • prepared_statement: The prepared statement to obtain the number of parameters for.

DUCKDBAPI idxt duckdbnparams(duckdbpreparedstatement preparedstatement);

DuckDB.duckdb_nullmask_dataMethod
duckdb_nullmask_data(result,col)

Returns the nullmask of a specific column of a result in columnar format. The nullmask indicates for every row whether or not the corresponding row is NULL. If a row is NULL, the values present in the array provided by duckdb_column_data are undefined.

int32_t *data = (int32_t *) duckdb_column_data(&result, 0);
bool *nullmask = duckdb_nullmask_data(&result, 0);
if (nullmask[row]) {
    printf("Data for row %d: NULL
", row);
} else {
    printf("Data for row %d: %d
", row, data[row]);
}
  • result: The result object to fetch the nullmask from.
  • col: The column index.
  • returns: The nullmask of the specified column.
DuckDB.duckdb_openMethod
duckdb_open(path, out_database)

Creates a new database or opens an existing database file stored at the given path. If no path is given a new in-memory database is created instead.

  • path: Path to the database file on disk, or nullptr or :memory: to open an in-memory database.
  • out_database: The result database object.
  • returns: DuckDBSuccess on success or DuckDBError on failure.
DuckDB.duckdb_open_extMethod
Extended version of duckdb_open. Creates a new database or opens an existing database file stored at the given path.

* path: Path to the database file on disk, or `nullptr` or `:memory:` to open an in-memory database.
* out_database: The result database object.
* config: (Optional) configuration used to start up the database system.
* out_error: If set and the function returns DuckDBError, this will contain the reason why the start-up failed.
Note that the error must be freed using `duckdb_free`.
* returns: `DuckDBSuccess` on success or `DuckDBError` on failure.
DuckDB.duckdb_param_typeMethod

Returns the parameter type for the parameter at the given index. Returns DUCKDB_TYPE_INVALID if the parameter index is out of range or the statement was not successfully prepared.

  • prepared_statement: The prepared statement.
  • param_idx: The parameter index.
  • returns: The parameter type

DUCKDBAPI duckdbtype duckdbparamtype(duckdbpreparedstatement preparedstatement, idxt param_idx);

DuckDB.duckdb_pending_errorMethod

Returns the error message contained within the pending result.

The result of this function must not be freed. It will be cleaned up when duckdb_destroy_pending is called.

  • result: The pending result to fetch the error from.
  • returns: The error of the pending result.
DuckDB.duckdb_pending_execute_check_stateMethod

Checks the state of the execution, returning it. The pending result represents an intermediate structure for a query that is not yet fully executed.

If this returns DUCKDBPENDINGRESULTREADY, the duckdbexecutepending function can be called to obtain the result. If this returns DUCKDBPENDINGRESULTNOTREADY, the duckdbpendingexecutecheckstate function should be called again. If this returns DUCKDBPENDING_ERROR, an error occurred during execution.

The error message can be obtained by calling duckdbpendingerror on the pending_result.

  • pending_result: The pending result to check the state of.
  • returns: The state of the pending result.
DuckDB.duckdb_pending_execute_taskMethod

Executes a single task within the query, returning whether or not the query is ready.

If this returns DUCKDBPENDINGRESULTREADY, the duckdbexecutepending function can be called to obtain the result. If this returns DUCKDBPENDINGRESULTNOTREADY, the duckdbpendingexecutetask function should be called again. If this returns DUCKDBPENDINGERROR, an error occurred during execution.

The error message can be obtained by calling duckdbpendingerror on the pending_result.

  • pending_result: The pending result to execute a task within.
  • returns: The state of the pending result after the execution.
DuckDB.duckdb_pending_execution_is_finishedMethod

Returns whether a duckdbpendingstate is finished executing. For example if pending_state is DUCKDBPENDINGRESULT_READY, this function will return true.

  • pending_state: The pending state on which to decide whether to finish execution.
  • returns: Boolean indicating pending execution should be considered finished.
DuckDB.duckdb_pending_preparedMethod

Executes the prepared statement with the given bound parameters, and returns a pending result. The pending result represents an intermediate structure for a query that is not yet fully executed. The pending result can be used to incrementally execute a query, returning control to the client between tasks.

Note that after calling duckdb_pending_prepared, the pending result should always be destroyed using duckdb_destroy_pending, even if this function returns DuckDBError.

  • prepared_statement: The prepared statement to execute.
  • out_result: The pending query result.
  • returns: DuckDBSuccess on success or DuckDBError on failure.
DuckDB.duckdb_pending_prepared_streamingMethod

Executes the prepared statement with the given bound parameters, and returns a pending result. This pending result will create a streaming duckdb_result when executed. The pending result represents an intermediate structure for a query that is not yet fully executed.

Note that after calling duckdb_pending_prepared_streaming, the pending result should always be destroyed using duckdb_destroy_pending, even if this function returns DuckDBError.

  • prepared_statement: The prepared statement to execute.
  • out_result: The pending query result.
  • returns: DuckDBSuccess on success or DuckDBError on failure.
DuckDB.duckdb_prepareMethod

Create a prepared statement object from a query. Note that after calling duckdb_prepare, the prepared statement should always be destroyed using duckdb_destroy_prepare, even if the prepare fails. If the prepare fails, duckdb_prepare_error can be called to obtain the reason why the prepare failed.

  • connection: The connection object
  • query: The SQL query to prepare
  • outpreparedstatement: The resulting prepared statement object
  • returns: DuckDBSuccess on success or DuckDBError on failure.

DUCKDBAPI duckdbstate duckdbprepare(duckdbconnection connection, const char *query, duckdbpreparedstatement *outpreparedstatement);

DuckDB.duckdb_prepare_errorMethod

Returns the error message associated with the given prepared statement. If the prepared statement has no error message, this returns nullptr instead. The error message should not be freed. It will be de-allocated when duckdb_destroy_prepare is called.

  • prepared_statement: The prepared statement to obtain the error from.
  • returns: The error message, or nullptr if there is none.

DUCKDBAPI const char *duckdbprepareerror(duckdbpreparedstatement preparedstatement);

DuckDB.duckdb_queryMethod
duckdb_query(connection,query,out_result)

Executes a SQL query within a connection and stores the full (materialized) result in the outresult pointer. If the query fails to execute, DuckDBError is returned and the error message can be retrieved by calling `duckdbresulterror. Note that after runningduckdbquery,duckdbdestroyresult` must be called on the result object even if the query fails, otherwise the error stored within the result will not be freed correctly.

  • connection: The connection to perform the query in.
  • query: The SQL query to run.
  • out_result: The query result.
  • returns: DuckDBSuccess on success or DuckDBError on failure.
DuckDB.duckdb_register_table_functionMethod

Register the table function object within the given connection.

The function requires at least a name, a bind function, an init function and a main function.

If the function is incomplete or a function with this name already exists DuckDBError is returned.

  • con: The connection to register it in.
  • function: The function pointer
  • returns: Whether or not the registration was successful.
DuckDB.duckdb_replacement_scan_add_parameterMethod

Adds a parameter to the replacement scan function.

  • info: The info object
  • parameter: The parameter to add. The function will call duckdb_destroy_value on the parameter.
DuckDB.duckdb_replacement_scan_set_function_nameMethod

Sets the replacement function name to use. If this function is called in the replacement callback, the replacement scan is performed. If it is not called, the replacement callback is not performed.

  • info: The info object
  • function_name: The function name to substitute.
DuckDB.duckdb_result_chunk_countMethod

Returns the number of data chunks present in the result.

  • result: The result object
  • returns: The resulting data chunk. Returns NULL if the chunk index is out of bounds.
DuckDB.duckdb_result_errorMethod
duckdb_result_error(result)

Returns the error message contained within the result. The error is only set if duckdb_query returns DuckDBError. The result of this function must not be freed. It will be cleaned up when duckdb_destroy_result is called.

  • result: The result object to fetch the nullmask from.
  • returns: The error of the result.
DuckDB.duckdb_result_get_chunkMethod

Fetches a data chunk from the duckdb_result. This function should be called repeatedly until the result is exhausted.

This function supersedes all duckdb_value functions, as well as the duckdb_column_data and duckdb_nullmask_data functions. It results in significantly better performance, and should be preferred in newer code-bases.

If this function is used, none of the other result functions can be used and vice versa (i.e. this function cannot be mixed with the legacy result functions).

Use duckdb_result_chunk_count to figure out how many chunks there are in the result.

  • result: The result object to fetch the data chunk from.
  • chunk_index: The chunk index to fetch from.
  • returns: The resulting data chunk. Returns NULL if the chunk index is out of bounds.
DuckDB.duckdb_result_is_streamingMethod

Checks if the type of the internal result is StreamQueryResult.

  • result: The result object to check.
  • returns: Whether or not the result object is of the type StreamQueryResult
DuckDB.duckdb_row_countMethod
duckdb_row_count(result)

Returns the number of rows present in a the result object.

  • result: The result object.
  • returns: The number of rows present in the result object.
DuckDB.duckdb_rows_changedMethod
duckdb_rows_changed(result)

Returns the number of rows changed by the query stored in the result. This is relevant only for INSERT/UPDATE/DELETE queries. For other queries the rows_changed will be 0.

  • result: The result object.
  • returns: The number of rows changed.
DuckDB.duckdb_set_configMethod
duckdb_set_config(config,name,option)

Sets the specified option for the specified configuration. The configuration option is indicated by name. To obtain a list of config options, see duckdb_get_config_flag. In the source code, configuration options are defined in config.cpp. This can fail if either the name is invalid, or if the value provided for the option is invalid.

  • duckdb_config: The configuration object to set the option on.
  • name: The name of the configuration flag to set.
  • option: The value to set the configuration flag to.
  • returns: DuckDBSuccess on success or DuckDBError on failure.
DuckDB.duckdb_stream_fetch_chunkMethod

Fetches a data chunk from the (streaming) duckdb_result. This function should be called repeatedly until the result is exhausted.

The result must be destroyed with duckdb_destroy_data_chunk.

This function can only be used on duckdbresults created with 'duckdbpendingpreparedstreaming'

If this function is used, none of the other result functions can be used and vice versa (i.e. this function cannot be mixed with the legacy result functions or the materialized result functions).

It is not known beforehand how many chunks will be returned by this result.

  • result: The result object to fetch the data chunk from.
  • returns: The resulting data chunk. Returns NULL if the result has an error.
DuckDB.duckdb_struct_type_child_nameMethod

Retrieves the name of the struct child.

The result must be freed with duckdb_free

  • type: The logical type object
  • index: The child index
  • returns: The name of the struct type. Must be freed with duckdb_free.
DuckDB.duckdb_struct_type_child_typeMethod

Retrieves the child type of the given struct type at the specified index.

The result must be freed with duckdb_destroy_logical_type

  • type: The logical type object
  • index: The child index
  • returns: The child type of the struct type. Must be destroyed with duckdb_destroy_logical_type.
DuckDB.duckdb_struct_vector_get_childMethod

Retrieves the child vector of a struct vector.

The resulting vector is valid as long as the parent vector is valid.

  • vector: The vector
  • index: The child index
  • returns: The child vector
DuckDB.duckdb_table_function_set_extra_infoMethod

Assigns extra information to the table function that can be fetched during binding, etc.

  • table_function: The table function
  • extra_info: The extra information
  • destroy: The callback that will be called to destroy the bind data (if any)
DuckDB.duckdb_table_function_supports_projection_pushdownMethod

Sets whether or not the given table function supports projection pushdown.

If this is set to true, the system will provide a list of all required columns in the init stage through the duckdb_init_get_column_count and duckdb_init_get_column_index functions. If this is set to false (the default), the system will expect all columns to be projected.

  • table_function: The table function
  • pushdown: True if the table function supports projection pushdown, false otherwise.
DuckDB.duckdb_task_state_is_finishedMethod

Check if the provided duckdbtaskstate has finished execution

  • state: The task state to inspect
  • returns: Whether or not duckdbfinishexecution has been called on the task state
DuckDB.duckdb_union_type_member_nameMethod

Retrieves the name of the union member.

The result must be freed with duckdb_free

  • type: The logical type object
  • index: The member index
  • returns: The name of the union member. Must be freed with duckdb_free.
DuckDB.duckdb_union_type_member_typeMethod

Retrieves the member type of the given union type at the specified index.

The result must be freed with duckdb_destroy_logical_type

  • type: The logical type object
  • index: The member index
  • returns: The member type of the union type. Must be destroyed with duckdb_destroy_logical_type.
DuckDB.duckdb_union_vector_get_memberMethod

Retrieves the member vector of a union vector.

The resulting vector is valid as long as the parent vector is valid.

  • vector: The vector
  • index: The member index
  • returns: The member vector
DuckDB.duckdb_value_booleanMethod
duckdb_value_boolean(result,col,row)
  • returns: The boolean value at the specified location, or false if the value cannot be converted.
DuckDB.duckdb_value_dateMethod

duckdbvaluedate(result,col,row)

  • returns: The duckdb_date value at the specified location, or 0 if the value cannot be converted.

DUCKDBAPI duckdbdate duckdbvaluedate(duckdbresult *result, idxt col, idx_t row);

DuckDB.duckdb_value_doubleMethod
duckdb_value_double(result,col,row)
  • returns: The double value at the specified location, or 0 if the value cannot be converted.
DuckDB.duckdb_value_floatMethod
duckdb_value_float(result,col,row)
  • returns: The float value at the specified location, or 0 if the value cannot be converted.
DuckDB.duckdb_value_hugeintMethod
duckdb_value_hugeint(result,col,row)
  • returns: The duckdb_hugeint value at the specified location, or 0 if the value cannot be converted.
DuckDB.duckdb_value_int16Method
duckdb_value_int16(result,col,row)
  • returns: The int16_t value at the specified location, or 0 if the value cannot be converted.
DuckDB.duckdb_value_int32Method
duckdb_value_int32(result,col,row)
  • returns: The int32_t value at the specified location, or 0 if the value cannot be converted.
DuckDB.duckdb_value_int64Method
duckdb_value_int64(result,col,row)
  • returns: The int64_t value at the specified location, or 0 if the value cannot be converted.
DuckDB.duckdb_value_int8Method
duckdb_value_int8(result,col,row)
  • returns: The int8_t value at the specified location, or 0 if the value cannot be converted.
DuckDB.duckdb_value_intervalMethod

duckdbvalueinterval(result,col,row)

  • returns: The duckdb_interval value at the specified location, or 0 if the value cannot be converted.

DUCKDBAPI duckdbinterval duckdbvalueinterval(duckdbresult *result, idxt col, idx_t row);

DuckDB.duckdb_value_is_nullMethod

duckdbvalueis_null(result,col,row)

  • returns: Returns true if the value at the specified index is NULL, and false otherwise.

DUCKDBAPI bool duckdbvalueisnull(duckdbresult *result, idxt col, idx_t row);

DuckDB.duckdb_value_timeMethod

duckdbvaluetime(result,col,row)

  • returns: The duckdb_time value at the specified location, or 0 if the value cannot be converted.

DUCKDBAPI duckdbtime duckdbvaluetime(duckdbresult *result, idxt col, idx_t row);

DuckDB.duckdb_value_timestampMethod

duckdbvaluetimestamp(result,col,row)

  • returns: The duckdb_timestamp value at the specified location, or 0 if the value cannot be converted.

DUCKDBAPI duckdbtimestamp duckdbvaluetimestamp(duckdbresult *result, idxt col, idx_t row);

DuckDB.duckdb_value_uhugeintMethod
duckdb_value_uhugeint(result,col,row)
  • returns: The duckdb_uhugeint value at the specified location, or 0 if the value cannot be converted.
DuckDB.duckdb_value_uint16Method
duckdb_value_uint16(result,col,row)
  • returns: The uint16_t value at the specified location, or 0 if the value cannot be converted.
DuckDB.duckdb_value_uint32Method
duckdb_value_uint32(result,col,row)
  • returns: The uint32_t value at the specified location, or 0 if the value cannot be converted.
DuckDB.duckdb_value_uint64Method
duckdb_value_uint64(result,col,row)
  • returns: The uint64_t value at the specified location, or 0 if the value cannot be converted.
DuckDB.duckdb_value_uint8Method
duckdb_value_uint8(result,col,row)
  • returns: The uint8_t value at the specified location, or 0 if the value cannot be converted.
DuckDB.duckdb_value_varcharMethod

duckdbvaluevarchar(result,col,row)

  • returns: The char* value at the specified location, or nullptr if the value cannot be converted.

The result must be freed with duckdb_free. DUCKDBAPI char *duckdbvaluevarchar(duckdbresult *result, idxt col, idxt row);

DuckDB.duckdb_value_varchar_internalMethod

duckdbvaluevarchar_internal(result,col,row)

  • returns: The char* value at the specified location. ONLY works on VARCHAR columns and does not auto-cast.

If the column is NOT a VARCHAR column this function will return NULL. The result must NOT be freed. DUCKDBAPI char *duckdbvaluevarcharinternal(duckdbresult *result, idxt col, idx_t row);

DuckDB.duckdb_vector_assign_string_elementMethod

Assigns a string element in the vector at the specified location.

  • vector: The vector to alter
  • index: The row position in the vector to assign the string to
  • str: The null-terminated string
DuckDB.duckdb_vector_assign_string_element_lenMethod

Assigns a string element in the vector at the specified location.

  • vector: The vector to alter
  • index: The row position in the vector to assign the string to
  • str: The null-terminated string
  • str_len: The string length
DuckDB.duckdb_vector_ensure_validity_writableMethod

Ensures the validity mask is writable by allocating it.

After this function is called, duckdb_vector_get_validity will ALWAYS return non-NULL. This allows null values to be written to the vector, regardless of whether a validity mask was present before.

  • vector: The vector to alter
DuckDB.duckdb_vector_get_column_typeMethod

Retrieves the column type of the specified vector.

The result must be destroyed with duckdb_destroy_logical_type.

  • vector: The vector get the data from
  • returns: The type of the vector
DuckDB.duckdb_vector_get_dataMethod

Retrieves the data pointer of the vector.

The data pointer can be used to read or write values from the vector. How to read or write values depends on the type of the vector.

  • vector: The vector to get the data from
  • returns: The data pointer
DuckDB.duckdb_vector_get_validityMethod

Retrieves the validity mask pointer of the specified vector.

If all values are valid, this function MIGHT return NULL!

The validity mask is a bitset that signifies null-ness within the data chunk. It is a series of uint64t values, where each uint64t value contains validity for 64 tuples. The bit is set to 1 if the value is valid (i.e. not NULL) or 0 if the value is invalid (i.e. NULL).

Validity of a specific value can be obtained like this:

idxt entryidx = rowidx / 64; idxt idxinentry = rowidx % 64; bool isvalid = validitymask[entryidx] & (1 << idxinentry);

Alternatively, the (slower) duckdbvalidityrowisvalid function can be used.

  • vector: The vector to get the data from
  • returns: The pointer to the validity mask, or NULL if no validity mask is present
DuckDB.duckdb_vector_sizeMethod

The internal vector size used by DuckDB. This is the amount of tuples that will fit into a data chunk created by duckdb_create_data_chunk.

  • returns: The vector size.
DuckDB.load!Function
DuckDB.load!(con, input_df, table)

Load an input DataFrame input_df into a new DuckDB table that will be named table.

DuckDB.queryMethod

Executes a SQL query within a connection and returns the full (materialized) result.

The query function is able to run queries with multiple statements, unlike DBInterface.execute(@ref) which is only able to prepare a single statement.