From 1260b68f205c5e1672906a3df675d836b1c9c88d Mon Sep 17 00:00:00 2001 From: Stephen Date: Thu, 12 Mar 2026 21:22:03 +0700 Subject: [PATCH 01/13] feat: add Cassandra and ScyllaDB database support Add Cassandra as the 11th database engine in TablePro, with ScyllaDB as a secondary type sharing the same plugin (like MySQL/MariaDB). Uses the DataStax C/C++ driver via a C bridge module. - CassandraDriverPlugin with full CQL support (keyspaces, tables, views, indexes, schema introspection via system_schema) - DatabaseType enum: .cassandra and .scylladb cases across all switch sites - Connection URL schemes: cassandra://, cql://, scylladb://, scylla:// - Theme colors, icon assets, default port 9042 - CQL dialect with keywords, functions, and data types for autocomplete - CI workflow support for building downloadable plugin (build-plugin.yml) - Build script for DataStax cpp-driver + libuv static libraries - Documentation (English + Vietnamese) - Tests for DatabaseType properties and URL parsing Co-Authored-By: Claude Opus 4.6 --- .github/workflows/build-plugin.yml | 11 + CHANGELOG.md | 1 + Libs/libcassandra.a | 3 + Libs/libcassandra_arm64.a | 3 + Libs/libuv.a | 3 + Libs/libuv_arm64.a | 3 + .../CCassandra/CCassandra.h | 14 + .../CCassandra/include/cassandra.h | 11534 ++++++++++++++++ .../CCassandra/module.modulemap | 4 + .../CassandraPlugin.swift | 1034 ++ Plugins/CassandraDriverPlugin/Info.plist | 24 + TablePro.xcodeproj/project.pbxproj | 219 +- TablePro/AppDelegate+FileOpen.swift | 3 +- .../cassandra-icon.imageset/Contents.json | 16 + .../cassandra-icon.imageset/cassandra.svg | 4 + .../scylladb-icon.imageset/Contents.json | 16 + .../scylladb-icon.imageset/scylladb.svg | 5 + .../Autocomplete/SQLCompletionProvider.swift | 8 + .../SQLStatementGenerator.swift | 42 +- TablePro/Core/Database/DatabaseDriver.swift | 12 +- .../Core/Database/FilterSQLGenerator.swift | 8 +- TablePro/Core/Database/SQLEscaping.swift | 2 +- .../Core/Plugins/ImportDataSinkAdapter.swift | 4 +- .../Services/Query/SQLDialectProvider.swift | 61 + .../Connection/ConnectionURLFormatter.swift | 2 + .../Connection/ConnectionURLParser.swift | 4 + .../Utilities/SQL/SQLParameterInliner.swift | 2 +- TablePro/Info.plist | 4 + .../Connection/DatabaseConnection.swift | 18 +- TablePro/Theme/Theme.swift | 6 + .../DatabaseSwitcherViewModel.swift | 2 + .../Views/Connection/ConnectionFormView.swift | 1 + TablePro/Views/Export/ExportDialog.swift | 2 +- .../MainContentCoordinator+Navigation.swift | 17 +- ...ainContentCoordinator+SidebarActions.swift | 4 + .../Views/Main/MainContentCoordinator.swift | 5 + TablePro/Views/Main/MainContentView.swift | 13 +- .../Structure/TypePickerContentView.swift | 10 + .../Utilities/DatabaseURLSchemeTests.swift | 15 +- .../Models/DatabaseTypeCassandraTests.swift | 115 + TableProTests/Models/DatabaseTypeTests.swift | 8 +- docs/databases/cassandra.mdx | 357 + docs/databases/connection-urls.mdx | 12 + docs/databases/overview.mdx | 18 +- docs/docs.json | 2 + docs/vi/databases/cassandra.mdx | 357 + docs/vi/databases/connection-urls.mdx | 12 + docs/vi/databases/overview.mdx | 18 +- scripts/build-cassandra.sh | 168 + scripts/build-release.sh | 1 + 50 files changed, 14121 insertions(+), 86 deletions(-) create mode 100644 Libs/libcassandra.a create mode 100644 Libs/libcassandra_arm64.a create mode 100644 Libs/libuv.a create mode 100644 Libs/libuv_arm64.a create mode 100644 Plugins/CassandraDriverPlugin/CCassandra/CCassandra.h create mode 100644 Plugins/CassandraDriverPlugin/CCassandra/include/cassandra.h create mode 100644 Plugins/CassandraDriverPlugin/CCassandra/module.modulemap create mode 100644 Plugins/CassandraDriverPlugin/CassandraPlugin.swift create mode 100644 Plugins/CassandraDriverPlugin/Info.plist create mode 100644 TablePro/Assets.xcassets/cassandra-icon.imageset/Contents.json create mode 100644 TablePro/Assets.xcassets/cassandra-icon.imageset/cassandra.svg create mode 100644 TablePro/Assets.xcassets/scylladb-icon.imageset/Contents.json create mode 100644 TablePro/Assets.xcassets/scylladb-icon.imageset/scylladb.svg create mode 100644 TableProTests/Models/DatabaseTypeCassandraTests.swift create mode 100644 docs/databases/cassandra.mdx create mode 100644 docs/vi/databases/cassandra.mdx create mode 100755 scripts/build-cassandra.sh diff --git a/.github/workflows/build-plugin.yml b/.github/workflows/build-plugin.yml index a246abf3e..ff5485f7f 100644 --- a/.github/workflows/build-plugin.yml +++ b/.github/workflows/build-plugin.yml @@ -73,6 +73,11 @@ jobs: DISPLAY_NAME="DuckDB Driver"; SUMMARY="DuckDB analytical database driver" DB_TYPE_IDS='["DuckDB"]'; ICON="bird"; BUNDLE_NAME="DuckDBDriver" HOMEPAGE="https://tablepro.app" ;; + cassandra) + TARGET="CassandraDriver"; BUNDLE_ID="com.TablePro.CassandraDriver" + DISPLAY_NAME="Cassandra Driver"; SUMMARY="Apache Cassandra and ScyllaDB driver via DataStax C driver" + DB_TYPE_IDS='["Cassandra"]'; ICON="cassandra-icon"; BUNDLE_NAME="CassandraDriver" + HOMEPAGE="https://tablepro.app/databases/cassandra" ;; *) echo "Unknown plugin: $plugin_name"; return 1 ;; esac } @@ -91,6 +96,12 @@ jobs: echo "Building $TARGET v$VERSION" + # Build Cassandra dependencies if needed + if [ "$PLUGIN_NAME" = "cassandra" ]; then + ./scripts/build-cassandra.sh arm64 + ./scripts/build-cassandra.sh x86_64 + fi + # Build both architectures ./scripts/build-plugin.sh "$TARGET" arm64 ./scripts/build-plugin.sh "$TARGET" x86_64 diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e765b596..a9d82ceb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Pre-connect script: run a shell command before each connection (e.g., to refresh credentials or update ~/.pgpass) - `ParameterStyle` enum in TableProPluginKit: plugins declare `?` or `$1` placeholder style via `parameterStyle` property on `PluginDatabaseDriver` - DML statement generation in ClickHouse, MSSQL, and Oracle plugins via `generateStatements()` for database-specific UPDATE/DELETE syntax +- Cassandra and ScyllaDB database support via DataStax C driver (downloadable plugin) ### Changed diff --git a/Libs/libcassandra.a b/Libs/libcassandra.a new file mode 100644 index 000000000..b71dea90b --- /dev/null +++ b/Libs/libcassandra.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4ca80d0764d15c1f96dc9dac8919477c71fc437e5f452f5c25128faa03e6f32f +size 5525840 diff --git a/Libs/libcassandra_arm64.a b/Libs/libcassandra_arm64.a new file mode 100644 index 000000000..b71dea90b --- /dev/null +++ b/Libs/libcassandra_arm64.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4ca80d0764d15c1f96dc9dac8919477c71fc437e5f452f5c25128faa03e6f32f +size 5525840 diff --git a/Libs/libuv.a b/Libs/libuv.a new file mode 100644 index 000000000..dd747cd33 --- /dev/null +++ b/Libs/libuv.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f68094acef3ad60d58a59dd3c0d77f49f149a2868da15b38f82fbdc1aff63299 +size 251656 diff --git a/Libs/libuv_arm64.a b/Libs/libuv_arm64.a new file mode 100644 index 000000000..dd747cd33 --- /dev/null +++ b/Libs/libuv_arm64.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f68094acef3ad60d58a59dd3c0d77f49f149a2868da15b38f82fbdc1aff63299 +size 251656 diff --git a/Plugins/CassandraDriverPlugin/CCassandra/CCassandra.h b/Plugins/CassandraDriverPlugin/CCassandra/CCassandra.h new file mode 100644 index 000000000..879ff621d --- /dev/null +++ b/Plugins/CassandraDriverPlugin/CCassandra/CCassandra.h @@ -0,0 +1,14 @@ +// +// CCassandra.h +// TablePro +// +// C bridging header for the DataStax Cassandra C driver. +// Headers are bundled in the include/ subdirectory. +// + +#ifndef CCassandra_h +#define CCassandra_h + +#include "include/cassandra.h" + +#endif /* CCassandra_h */ diff --git a/Plugins/CassandraDriverPlugin/CCassandra/include/cassandra.h b/Plugins/CassandraDriverPlugin/CCassandra/include/cassandra.h new file mode 100644 index 000000000..6faf3d268 --- /dev/null +++ b/Plugins/CassandraDriverPlugin/CCassandra/include/cassandra.h @@ -0,0 +1,11534 @@ +/* + Copyright (c) DataStax, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef __CASSANDRA_H_INCLUDED__ +#define __CASSANDRA_H_INCLUDED__ + +#include +#include + +#if !defined(CASS_STATIC) +# if (defined(WIN32) || defined(_WIN32)) +# if defined(CASS_BUILDING) +# define CASS_EXPORT __declspec(dllexport) +# else +# define CASS_EXPORT __declspec(dllimport) +# endif +# elif (defined(__SUNPRO_C) || defined(__SUNPRO_CC)) && !defined(CASS_STATIC) +# define CASS_EXPORT __global +# elif (defined(__GNUC__) && __GNUC__ >= 4) || defined(__INTEL_COMPILER) +# define CASS_EXPORT __attribute__ ((visibility("default"))) +# endif +#else +#define CASS_EXPORT +#endif + +#if defined(_MSC_VER) +# define CASS_DEPRECATED(func) __declspec(deprecated) func +#elif defined(__GNUC__) || defined(__INTEL_COMPILER) +# define CASS_DEPRECATED(func) func __attribute__((deprecated)) +#else +# define CASS_DEPRECATED(func) func +#endif + +/** + * @file include/cassandra.h + * + * C/C++ driver for Apache Cassandra. Uses the Cassandra Query Language versions 3 + * over the Cassandra Binary Protocol (versions 1, 2, or 3). + */ + +#define CASS_VERSION_MAJOR 2 +#define CASS_VERSION_MINOR 17 +#define CASS_VERSION_PATCH 1 +#define CASS_VERSION_SUFFIX "" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { cass_false = 0, cass_true = 1 } cass_bool_t; + +typedef float cass_float_t; +typedef double cass_double_t; + +typedef int8_t cass_int8_t; +typedef uint8_t cass_uint8_t; + +typedef int16_t cass_int16_t; +typedef uint16_t cass_uint16_t; + +typedef int32_t cass_int32_t; +typedef uint32_t cass_uint32_t; + +typedef int64_t cass_int64_t; +typedef uint64_t cass_uint64_t; + +#define CASS_UINT64_MAX 18446744073709551615ULL + +typedef cass_uint8_t cass_byte_t; +typedef cass_uint64_t cass_duration_t; + +/** + * The size of an IPv4 address + */ +#define CASS_INET_V4_LENGTH 4 + +/** + * The size of an IPv6 address + */ +#define CASS_INET_V6_LENGTH 16 + +/** + * The size of an inet string including a null terminator. + */ +#define CASS_INET_STRING_LENGTH 46 + +/** + * IP address for either IPv4 or IPv6. + * + * @struct CassInet + */ +typedef struct CassInet_ { + /** + * Big-endian, binary representation of a IPv4 or IPv6 address + */ + cass_uint8_t address[CASS_INET_V6_LENGTH]; + /** + * Number of address bytes. 4 bytes for IPv4 and 16 bytes for IPv6. + */ + cass_uint8_t address_length; +} CassInet; + +/** + * The size of a hexadecimal UUID string including a null terminator. + */ +#define CASS_UUID_STRING_LENGTH 37 + +/** + * Version 1 (time-based) or version 4 (random) UUID. + * + * @struct CassUuid + */ +typedef struct CassUuid_ { + /** + * Represents the time and version part of a UUID. The most significant + * 4 bits represent the version and the bottom 60 bits representing the + * time part. For version 1 the time part represents the number of + * 100 nanosecond periods since 00:00:00 UTC, January 1, 1970 (the Epoch). + * For version 4 the time part is randomly generated. + */ + cass_uint64_t time_and_version; + /** + * Represents the clock sequence and the node part of a UUID. The most + * significant 16 bits represent the clock sequence (except for the most + * significant bit which is always set) and the bottom 48 bits represent + * the node part. For version 1 (time-based) the clock sequence part is randomly + * generated and the node part can be explicitly set, otherwise, it's generated + * from node unique information. For version 4 both the clock sequence and the node + * parts are randomly generated. + */ + cass_uint64_t clock_seq_and_node; +} CassUuid; + +/** + * A cluster object describes the configuration of the Cassandra cluster and is used + * to construct a session instance. Unlike other DataStax drivers the cluster object + * does not maintain the control connection. + * + * @struct CassCluster + */ +typedef struct CassCluster_ CassCluster; + +/** + * A session object is used to execute queries and maintains cluster state through + * the control connection. The control connection is used to auto-discover nodes and + * monitor cluster changes (topology and schema). Each session also maintains multiple + * pools of connections to cluster nodes which are used to query the cluster. + * + * Instances of the session object are thread-safe to execute queries. + * + * @struct CassSession + */ +typedef struct CassSession_ CassSession; + +/** + * A statement object is an executable query. It represents either a regular + * (adhoc) statement or a prepared statement. It maintains the queries' parameter + * values along with query options (consistency level, paging state, etc.) + * + * Note: Parameters for regular queries are not supported by the binary protocol + * version 1. + * + * @struct CassStatement + */ +typedef struct CassStatement_ CassStatement; + +/** + * A group of statements that are executed as a single batch. + * + * Note: Batches are not supported by the binary protocol version 1. + * + * @cassandra{2.0+} + * + * @struct CassBatch + */ +typedef struct CassBatch_ CassBatch; + +/** + * The future result of an operation. + * + * It can represent a result if the operation completed successfully or an + * error if the operation failed. It can be waited on, polled or a callback + * can be attached. + * + * @struct CassFuture + */ +typedef struct CassFuture_ CassFuture; + +/** + * A statement that has been prepared cluster-side (It has been pre-parsed + * and cached). + * + * A prepared statement is read-only and it is thread-safe to concurrently + * bind new statements. + * + * @struct CassPrepared + */ +typedef struct CassPrepared_ CassPrepared; + +/** + * The result of a query. + * + * A result object is read-only and is thread-safe to read or iterate over + * concurrently. + * + * @struct CassResult + */ +typedef struct CassResult_ CassResult; + +/** + * A error result of a request + * + * @struct CassErrorResult + */ +typedef struct CassErrorResult_ CassErrorResult; + + +/** + * An object that represents a cluster node. + * + * @struct CassNode + */ +typedef struct CassNode_ CassNode; + +/** + * An object used to iterate over a group of rows, columns or collection values. + * + * @struct CassIterator + */ +typedef struct CassIterator_ CassIterator; + +/** + * A collection of column values. + * + * @struct CassRow + */ +typedef struct CassRow_ CassRow; + +/** + * A single primitive value or a collection of values. + * + * @struct CassValue + */ +typedef struct CassValue_ CassValue; + +/** + * A data type used to describe a value, collection or + * user defined type. + * + * @struct CassDataType + */ +typedef struct CassDataType_ CassDataType; + +/** + * @struct CassFunctionMeta + * + * @cassandra{2.2+} + */ +typedef struct CassFunctionMeta_ CassFunctionMeta; + +/** + * @struct CassAggregateMeta + * + * @cassandra{2.2+} + */ +typedef struct CassAggregateMeta_ CassAggregateMeta; + +/** + * A collection of values. + * + * @struct CassCollection + */ +typedef struct CassCollection_ CassCollection; + +/** + * A tuple of values. + * + * @struct CassTuple + * + * @cassandra{2.1+} + */ +typedef struct CassTuple_ CassTuple; + +/** + * A user defined type. + * + * @struct CassUserType + * + * @cassandra{2.1+} + */ +typedef struct CassUserType_ CassUserType; + +/** + * Describes the SSL configuration of a cluster. + * + * @struct CassSsl + */ +typedef struct CassSsl_ CassSsl; + +/** + * Describes the version of the connected Cassandra cluster. + * + * @struct CassVersion + */ + +typedef struct CassVersion_ { + int major_version; + int minor_version; + int patch_version; +} CassVersion; + +/** + * A snapshot of the schema's metadata. + * + * @struct CassSchemaMeta + */ +typedef struct CassSchemaMeta_ CassSchemaMeta; + +/** + * Keyspace metadata + * + * @struct CassKeyspaceMeta + */ +typedef struct CassKeyspaceMeta_ CassKeyspaceMeta; + +/** + * Table metadata + * + * @struct CassTableMeta + */ +typedef struct CassTableMeta_ CassTableMeta; + +/** + * MaterializedView metadata + * + * @struct CassMaterializedViewMeta + * + * @cassandra{3.0+} + */ +typedef struct CassMaterializedViewMeta_ CassMaterializedViewMeta; + +/** + * Column metadata + * + * @struct CassColumnMeta + */ +typedef struct CassColumnMeta_ CassColumnMeta; + +/** + * Index metadata + * + * @struct CassIndexMeta + */ +typedef struct CassIndexMeta_ CassIndexMeta; + +/** + * A UUID generator object. + * + * Instances of the UUID generator object are thread-safe to generate UUIDs. + * + * @struct CassUuidGen + */ +typedef struct CassUuidGen_ CassUuidGen; + +/** + * Policies that defined the behavior of a request when a server-side + * read/write timeout or unavailable error occurs. + * + * Generators of client-side, microsecond-precision timestamps. + * + * @struct CassTimestampGen + * + * @cassandra{2.1+} + */ +typedef struct CassTimestampGen_ CassTimestampGen; + +/** + * @struct CassRetryPolicy + */ +typedef struct CassRetryPolicy_ CassRetryPolicy; + +/** + * @struct CassCustomPayload + * + * @cassandra{2.2+} + */ +typedef struct CassCustomPayload_ CassCustomPayload; + +/** + * A snapshot of the session's performance/diagnostic metrics. + * + * @struct CassMetrics + */ +typedef struct CassMetrics_ { + struct { + cass_uint64_t min; /**< Minimum in microseconds */ + cass_uint64_t max; /**< Maximum in microseconds */ + cass_uint64_t mean; /**< Mean in microseconds */ + cass_uint64_t stddev; /**< Standard deviation in microseconds */ + cass_uint64_t median; /**< Median in microseconds */ + cass_uint64_t percentile_75th; /**< 75th percentile in microseconds */ + cass_uint64_t percentile_95th; /**< 95th percentile in microseconds */ + cass_uint64_t percentile_98th; /**< 98th percentile in microseconds */ + cass_uint64_t percentile_99th; /**< 99the percentile in microseconds */ + cass_uint64_t percentile_999th; /**< 99.9th percentile in microseconds */ + cass_double_t mean_rate; /**< Mean rate in requests per second */ + cass_double_t one_minute_rate; /**< 1 minute rate in requests per second */ + cass_double_t five_minute_rate; /**< 5 minute rate in requests per second */ + cass_double_t fifteen_minute_rate; /**< 15 minute rate in requests per second */ + } requests; /**< Performance request metrics */ + + struct { + cass_uint64_t total_connections; /**< The total number of connections */ + cass_uint64_t available_connections; /**< Deprecated */ + cass_uint64_t exceeded_pending_requests_water_mark; /**< Deprecated */ + cass_uint64_t exceeded_write_bytes_water_mark; /**< Deprecated */ + } stats; /**< Diagnostic metrics */ + + struct { + cass_uint64_t connection_timeouts; /**< Occurrences of a connection timeout */ + cass_uint64_t pending_request_timeouts; /**< Deprecated */ + cass_uint64_t request_timeouts; /**< Occurrences of requests that timed out waiting for a request to finish */ + } errors; /**< Error metrics */ +} CassMetrics; + +typedef struct CassSpeculativeExecutionMetrics_ { + cass_uint64_t min; /**< Minimum in microseconds */ + cass_uint64_t max; /**< Maximum in microseconds */ + cass_uint64_t mean; /**< Mean in microseconds */ + cass_uint64_t stddev; /**< Standard deviation in microseconds */ + cass_uint64_t median; /**< Median in microseconds */ + cass_uint64_t percentile_75th; /**< 75th percentile in microseconds */ + cass_uint64_t percentile_95th; /**< 95th percentile in microseconds */ + cass_uint64_t percentile_98th; /**< 98th percentile in microseconds */ + cass_uint64_t percentile_99th; /**< 99the percentile in microseconds */ + cass_uint64_t percentile_999th; /**< 99.9th percentile in microseconds */ + cass_uint64_t count; /**< The number of aborted speculative retries */ + cass_double_t percentage; /**< Fraction of requests that are aborted speculative retries */ +} CassSpeculativeExecutionMetrics; + +typedef enum CassConsistency_ { + CASS_CONSISTENCY_UNKNOWN = 0xFFFF, + CASS_CONSISTENCY_ANY = 0x0000, + CASS_CONSISTENCY_ONE = 0x0001, + CASS_CONSISTENCY_TWO = 0x0002, + CASS_CONSISTENCY_THREE = 0x0003, + CASS_CONSISTENCY_QUORUM = 0x0004, + CASS_CONSISTENCY_ALL = 0x0005, + CASS_CONSISTENCY_LOCAL_QUORUM = 0x0006, + CASS_CONSISTENCY_EACH_QUORUM = 0x0007, + CASS_CONSISTENCY_SERIAL = 0x0008, + CASS_CONSISTENCY_LOCAL_SERIAL = 0x0009, + CASS_CONSISTENCY_LOCAL_ONE = 0x000A +} CassConsistency; + +#define CASS_CONSISTENCY_MAPPING(XX) \ + XX(CASS_CONSISTENCY_UNKNOWN, "UNKNOWN") \ + XX(CASS_CONSISTENCY_ANY, "ANY") \ + XX(CASS_CONSISTENCY_ONE, "ONE") \ + XX(CASS_CONSISTENCY_TWO, "TWO") \ + XX(CASS_CONSISTENCY_THREE, "THREE") \ + XX(CASS_CONSISTENCY_QUORUM, "QUORUM") \ + XX(CASS_CONSISTENCY_ALL, "ALL") \ + XX(CASS_CONSISTENCY_LOCAL_QUORUM, "LOCAL_QUORUM") \ + XX(CASS_CONSISTENCY_EACH_QUORUM, "EACH_QUORUM") \ + XX(CASS_CONSISTENCY_SERIAL, "SERIAL") \ + XX(CASS_CONSISTENCY_LOCAL_SERIAL, "LOCAL_SERIAL") \ + XX(CASS_CONSISTENCY_LOCAL_ONE, "LOCAL_ONE") + +/* @cond IGNORE */ +#define CASS_CONSISTENCY_MAP CASS_CONSISTENCY_MAPPING /* Deprecated */ +/* @endcond */ + +typedef enum CassWriteType_ { + CASS_WRITE_TYPE_UNKNOWN, + CASS_WRITE_TYPE_SIMPLE, + CASS_WRITE_TYPE_BATCH, + CASS_WRITE_TYPE_UNLOGGED_BATCH, + CASS_WRITE_TYPE_COUNTER, + CASS_WRITE_TYPE_BATCH_LOG, + CASS_WRITE_TYPE_CAS, + CASS_WRITE_TYPE_VIEW, + CASS_WRITE_TYPE_CDC +} CassWriteType; + +#define CASS_WRITE_TYPE_MAPPING(XX) \ + XX(CASS_WRITE_TYPE_SIMPLE, "SIMPLE") \ + XX(CASS_WRITE_TYPE_BATCH, "BATCH") \ + XX(CASS_WRITE_TYPE_UNLOGGED_BATCH, "UNLOGGED_BATCH") \ + XX(CASS_WRITE_TYPE_COUNTER, "COUNTER") \ + XX(CASS_WRITE_TYPE_BATCH_LOG, "BATCH_LOG") \ + XX(CASS_WRITE_TYPE_CAS, "CAS") \ + XX(CASS_WRITE_TYPE_VIEW, "VIEW") \ + XX(CASS_WRITE_TYPE_CDC, "CDC") + +/* @cond IGNORE */ +#define CASS_WRITE_TYPE_MAP CASS_WRITE_TYPE_MAPPING /* Deprecated */ +/* @endcond */ + +typedef enum CassColumnType_ { + CASS_COLUMN_TYPE_REGULAR, + CASS_COLUMN_TYPE_PARTITION_KEY, + CASS_COLUMN_TYPE_CLUSTERING_KEY, + CASS_COLUMN_TYPE_STATIC, + CASS_COLUMN_TYPE_COMPACT_VALUE +} CassColumnType; + +typedef enum CassIndexType_ { + CASS_INDEX_TYPE_UNKNOWN, + CASS_INDEX_TYPE_KEYS, + CASS_INDEX_TYPE_CUSTOM, + CASS_INDEX_TYPE_COMPOSITES +} CassIndexType; + +#define CASS_VALUE_TYPE_MAPPING(XX) \ + XX(CASS_VALUE_TYPE_CUSTOM, 0x0000, "", "") \ + XX(CASS_VALUE_TYPE_ASCII, 0x0001, "ascii", "org.apache.cassandra.db.marshal.AsciiType") \ + XX(CASS_VALUE_TYPE_BIGINT, 0x0002, "bigint", "org.apache.cassandra.db.marshal.LongType") \ + XX(CASS_VALUE_TYPE_BLOB, 0x0003, "blob", "org.apache.cassandra.db.marshal.BytesType") \ + XX(CASS_VALUE_TYPE_BOOLEAN, 0x0004, "boolean", "org.apache.cassandra.db.marshal.BooleanType") \ + XX(CASS_VALUE_TYPE_COUNTER, 0x0005, "counter", "org.apache.cassandra.db.marshal.CounterColumnType") \ + XX(CASS_VALUE_TYPE_DECIMAL, 0x0006, "decimal", "org.apache.cassandra.db.marshal.DecimalType") \ + XX(CASS_VALUE_TYPE_DOUBLE, 0x0007, "double", "org.apache.cassandra.db.marshal.DoubleType") \ + XX(CASS_VALUE_TYPE_FLOAT, 0x0008, "float", "org.apache.cassandra.db.marshal.FloatType") \ + XX(CASS_VALUE_TYPE_INT, 0x0009, "int", "org.apache.cassandra.db.marshal.Int32Type") \ + XX(CASS_VALUE_TYPE_TEXT, 0x000A, "text", "org.apache.cassandra.db.marshal.UTF8Type") \ + XX(CASS_VALUE_TYPE_TIMESTAMP, 0x000B, "timestamp", "org.apache.cassandra.db.marshal.TimestampType") \ + XX(CASS_VALUE_TYPE_UUID, 0x000C, "uuid", "org.apache.cassandra.db.marshal.UUIDType") \ + XX(CASS_VALUE_TYPE_VARCHAR, 0x000D, "varchar", "") \ + XX(CASS_VALUE_TYPE_VARINT, 0x000E, "varint", "org.apache.cassandra.db.marshal.IntegerType") \ + XX(CASS_VALUE_TYPE_TIMEUUID, 0x000F, "timeuuid", "org.apache.cassandra.db.marshal.TimeUUIDType") \ + XX(CASS_VALUE_TYPE_INET, 0x0010, "inet", "org.apache.cassandra.db.marshal.InetAddressType") \ + XX(CASS_VALUE_TYPE_DATE, 0x0011, "date", "org.apache.cassandra.db.marshal.SimpleDateType") \ + XX(CASS_VALUE_TYPE_TIME, 0x0012, "time", "org.apache.cassandra.db.marshal.TimeType") \ + XX(CASS_VALUE_TYPE_SMALL_INT, 0x0013, "smallint", "org.apache.cassandra.db.marshal.ShortType") \ + XX(CASS_VALUE_TYPE_TINY_INT, 0x0014, "tinyint", "org.apache.cassandra.db.marshal.ByteType") \ + XX(CASS_VALUE_TYPE_DURATION, 0x0015, "duration", "org.apache.cassandra.db.marshal.DurationType") \ + XX(CASS_VALUE_TYPE_LIST, 0x0020, "list", "org.apache.cassandra.db.marshal.ListType") \ + XX(CASS_VALUE_TYPE_MAP, 0x0021, "map", "org.apache.cassandra.db.marshal.MapType") \ + XX(CASS_VALUE_TYPE_SET, 0x0022, "set", "org.apache.cassandra.db.marshal.SetType") \ + XX(CASS_VALUE_TYPE_UDT, 0x0030, "", "") \ + XX(CASS_VALUE_TYPE_TUPLE, 0x0031, "tuple", "org.apache.cassandra.db.marshal.TupleType") + +typedef enum CassValueType_ { + CASS_VALUE_TYPE_UNKNOWN = 0xFFFF, +#define XX_VALUE_TYPE(name, type, cql, klass) name = type, + CASS_VALUE_TYPE_MAPPING(XX_VALUE_TYPE) +#undef XX_VALUE_TYPE + /* @cond IGNORE */ + CASS_VALUE_TYPE_LAST_ENTRY + /* @endcond */ +} CassValueType; + +typedef enum CassClusteringOrder_ { + CASS_CLUSTERING_ORDER_NONE, + CASS_CLUSTERING_ORDER_ASC, + CASS_CLUSTERING_ORDER_DESC +} CassClusteringOrder; + +typedef enum CassCollectionType_ { + CASS_COLLECTION_TYPE_LIST = CASS_VALUE_TYPE_LIST, + CASS_COLLECTION_TYPE_MAP = CASS_VALUE_TYPE_MAP, + CASS_COLLECTION_TYPE_SET = CASS_VALUE_TYPE_SET +} CassCollectionType; + +typedef enum CassBatchType_ { + CASS_BATCH_TYPE_LOGGED = 0x00, + CASS_BATCH_TYPE_UNLOGGED = 0x01, + CASS_BATCH_TYPE_COUNTER = 0x02 +} CassBatchType; + +typedef enum CassIteratorType_ { + CASS_ITERATOR_TYPE_RESULT, + CASS_ITERATOR_TYPE_ROW, + CASS_ITERATOR_TYPE_COLLECTION, + CASS_ITERATOR_TYPE_MAP, + CASS_ITERATOR_TYPE_TUPLE, + CASS_ITERATOR_TYPE_USER_TYPE_FIELD, + CASS_ITERATOR_TYPE_META_FIELD, + CASS_ITERATOR_TYPE_KEYSPACE_META, + CASS_ITERATOR_TYPE_TABLE_META, + CASS_ITERATOR_TYPE_TYPE_META, + CASS_ITERATOR_TYPE_FUNCTION_META, + CASS_ITERATOR_TYPE_AGGREGATE_META, + CASS_ITERATOR_TYPE_COLUMN_META, + CASS_ITERATOR_TYPE_INDEX_META, + CASS_ITERATOR_TYPE_MATERIALIZED_VIEW_META +} CassIteratorType; + +#define CASS_LOG_LEVEL_MAPPING(XX) \ + XX(CASS_LOG_DISABLED, "") \ + XX(CASS_LOG_CRITICAL, "CRITICAL") \ + XX(CASS_LOG_ERROR, "ERROR") \ + XX(CASS_LOG_WARN, "WARN") \ + XX(CASS_LOG_INFO, "INFO") \ + XX(CASS_LOG_DEBUG, "DEBUG") \ + XX(CASS_LOG_TRACE, "TRACE") + +/* @cond IGNORE */ +#define CASS_LOG_LEVEL_MAP CASS_LOG_LEVEL_MAPPING /* Deprecated */ +/* @endcond */ + +typedef enum CassLogLevel_ { +#define XX_LOG(log_level, _) log_level, + CASS_LOG_LEVEL_MAPPING(XX_LOG) +#undef XX_LOG + /* @cond IGNORE */ + CASS_LOG_LAST_ENTRY + /* @endcond */ +} CassLogLevel; + +typedef enum CassSslVerifyFlags_ { + CASS_SSL_VERIFY_NONE = 0x00, + CASS_SSL_VERIFY_PEER_CERT = 0x01, + CASS_SSL_VERIFY_PEER_IDENTITY = 0x02, + CASS_SSL_VERIFY_PEER_IDENTITY_DNS = 0x04 +} CassSslVerifyFlags; + +typedef enum CassSslTlsVersion_ { + CASS_SSL_VERSION_TLS1 = 0x00, + CASS_SSL_VERSION_TLS1_1 = 0x01, + CASS_SSL_VERSION_TLS1_2 = 0x02 +} CassSslTlsVersion; + +typedef enum CassProtocolVersion_ { + CASS_PROTOCOL_VERSION_V1 = 0x01, /**< Deprecated */ + CASS_PROTOCOL_VERSION_V2 = 0x02, /**< Deprecated */ + CASS_PROTOCOL_VERSION_V3 = 0x03, + CASS_PROTOCOL_VERSION_V4 = 0x04, + CASS_PROTOCOL_VERSION_V5 = 0x05, + CASS_PROTOCOL_VERSION_DSEV1 = 0x41, /**< Only supported when using the DSE + driver with DataStax Enterprise */ + CASS_PROTOCOL_VERSION_DSEV2 = 0x42 /**< Only supported when using the DSE + driver with DataStax Enterprise */ +} CassProtocolVersion; + +typedef enum CassErrorSource_ { + CASS_ERROR_SOURCE_NONE, + CASS_ERROR_SOURCE_LIB, + CASS_ERROR_SOURCE_SERVER, + CASS_ERROR_SOURCE_SSL, + CASS_ERROR_SOURCE_COMPRESSION +} CassErrorSource; + +#define CASS_ERROR_MAPPING(XX) \ + XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_BAD_PARAMS, 1, "Bad parameters") \ + XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_NO_STREAMS, 2, "No streams available") \ + XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_UNABLE_TO_INIT, 3, "Unable to initialize") \ + XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_MESSAGE_ENCODE, 4, "Unable to encode message") \ + XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_HOST_RESOLUTION, 5, "Unable to resolve host") \ + XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_UNEXPECTED_RESPONSE, 6, "Unexpected response from server") \ + XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_REQUEST_QUEUE_FULL, 7, "The request queue is full") \ + XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_NO_AVAILABLE_IO_THREAD, 8, "No available IO threads") \ + XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_WRITE_ERROR, 9, "Write error") \ + XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_NO_HOSTS_AVAILABLE, 10, "No hosts available") \ + XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_INDEX_OUT_OF_BOUNDS, 11, "Index out of bounds") \ + XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_INVALID_ITEM_COUNT, 12, "Invalid item count") \ + XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_INVALID_VALUE_TYPE, 13, "Invalid value type") \ + XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_REQUEST_TIMED_OUT, 14, "Request timed out") \ + XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_UNABLE_TO_SET_KEYSPACE, 15, "Unable to set keyspace") \ + XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_CALLBACK_ALREADY_SET, 16, "Callback already set") \ + XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_INVALID_STATEMENT_TYPE, 17, "Invalid statement type") \ + XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_NAME_DOES_NOT_EXIST, 18, "No value or column for name") \ + XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_UNABLE_TO_DETERMINE_PROTOCOL, 19, "Unable to find supported protocol version") \ + XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_NULL_VALUE, 20, "NULL value specified") \ + XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_NOT_IMPLEMENTED, 21, "Not implemented") \ + XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_UNABLE_TO_CONNECT, 22, "Unable to connect") \ + XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_UNABLE_TO_CLOSE, 23, "Unable to close") \ + XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_NO_PAGING_STATE, 24, "No paging state") \ + XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_PARAMETER_UNSET, 25, "Parameter unset") \ + XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_INVALID_ERROR_RESULT_TYPE, 26, "Invalid error result type") \ + XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_INVALID_FUTURE_TYPE, 27, "Invalid future type") \ + XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_INTERNAL_ERROR, 28, "Internal error") \ + XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_INVALID_CUSTOM_TYPE, 29, "Invalid custom type") \ + XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_INVALID_DATA, 30, "Invalid data") \ + XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_NOT_ENOUGH_DATA, 31, "Not enough data") \ + XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_INVALID_STATE, 32, "Invalid state") \ + XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_NO_CUSTOM_PAYLOAD, 33, "No custom payload") \ + XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_EXECUTION_PROFILE_INVALID, 34, "Invalid execution profile specified") \ + XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_NO_TRACING_ID, 35, "No tracing ID") \ + XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_SERVER_ERROR, 0x0000, "Server error") \ + XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_PROTOCOL_ERROR, 0x000A, "Protocol error") \ + XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_BAD_CREDENTIALS, 0x0100, "Bad credentials") \ + XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_UNAVAILABLE, 0x1000, "Unavailable") \ + XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_OVERLOADED, 0x1001, "Overloaded") \ + XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_IS_BOOTSTRAPPING, 0x1002, "Is bootstrapping") \ + XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_TRUNCATE_ERROR, 0x1003, "Truncate error") \ + XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_WRITE_TIMEOUT, 0x1100, "Write timeout") \ + XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_READ_TIMEOUT, 0x1200, "Read timeout") \ + XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_READ_FAILURE, 0x1300, "Read failure") \ + XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_FUNCTION_FAILURE, 0x1400, "Function failure") \ + XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_WRITE_FAILURE, 0x1500, "Write failure") \ + XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_SYNTAX_ERROR, 0x2000, "Syntax error") \ + XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_UNAUTHORIZED, 0x2100, "Unauthorized") \ + XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_INVALID_QUERY, 0x2200, "Invalid query") \ + XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_CONFIG_ERROR, 0x2300, "Configuration error") \ + XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_ALREADY_EXISTS, 0x2400, "Already exists") \ + XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_UNPREPARED, 0x2500, "Unprepared") \ + XX(CASS_ERROR_SOURCE_SSL, CASS_ERROR_SSL_INVALID_CERT, 1, "Unable to load certificate") \ + XX(CASS_ERROR_SOURCE_SSL, CASS_ERROR_SSL_INVALID_PRIVATE_KEY, 2, "Unable to load private key") \ + XX(CASS_ERROR_SOURCE_SSL, CASS_ERROR_SSL_NO_PEER_CERT, 3, "No peer certificate") \ + XX(CASS_ERROR_SOURCE_SSL, CASS_ERROR_SSL_INVALID_PEER_CERT, 4, "Invalid peer certificate") \ + XX(CASS_ERROR_SOURCE_SSL, CASS_ERROR_SSL_IDENTITY_MISMATCH, 5, "Certificate does not match host or IP address") \ + XX(CASS_ERROR_SOURCE_SSL, CASS_ERROR_SSL_PROTOCOL_ERROR, 6, "Protocol error") \ + XX(CASS_ERROR_SOURCE_SSL, CASS_ERROR_SSL_CLOSED, 7, "Connection closed") + +/* @cond IGNORE */ +#define CASS_ERROR_MAP CASS_ERROR_MAPPING /* Deprecated */ +/* @endcond*/ + +#define CASS_ERROR(source, code) ((source << 24) | code) + +typedef enum CassError_ { + CASS_OK = 0, +#define XX_ERROR(source, name, code, _) name = CASS_ERROR(source, code), + CASS_ERROR_MAPPING(XX_ERROR) +#undef XX_ERROR + /* @cond IGNORE */ + CASS_ERROR_LAST_ENTRY + /* @endcond*/ +} CassError; + +/** + * A callback that's notified when the future is set. + * + * @param[in] message + * @param[in] data user defined data provided when the callback + * was registered. + * + * @see cass_future_set_callback() + */ +typedef void (*CassFutureCallback)(CassFuture* future, + void* data); + +/** + * Maximum size of a log message + */ +#define CASS_LOG_MAX_MESSAGE_SIZE 1024 + +/** + * A log message. + */ +typedef struct CassLogMessage_ { + /** + * The millisecond timestamp (since the Epoch) when the message was logged + */ + cass_uint64_t time_ms; + CassLogLevel severity; /**< The severity of the log message */ + const char* file; /**< The file where the message was logged */ + int line; /**< The line in the file where the message was logged */ + const char* function; /**< The function where the message was logged */ + char message[CASS_LOG_MAX_MESSAGE_SIZE]; /**< The message */ +} CassLogMessage; + +/** + * A callback that's used to handle logging. + * + * @param[in] message + * @param[in] data user defined data provided when the callback + * was registered. + * + * @see cass_log_set_callback() + */ +typedef void (*CassLogCallback)(const CassLogMessage* message, + void* data); + +/** + * A custom malloc function. This function should allocate "size" bytes and + * return a pointer to that memory + * + * @param[in] size The size of the memory to allocate + * + * @see CassFreeFunction + * @see cass_alloc_set_functions() + */ +typedef void* (*CassMallocFunction)(size_t size); + +/** + * A custom realloc function. This function attempts to change the size of the + * memory pointed to by "ptr". If the memory cannot be resized then new memory + * should be allocated and contain the contents of the original memory at "ptr". + * + * @param[in] ptr A pointer to the original memory. If NULL it should behave the + * same as "CassMallocFunction" + * @param[in] size The size of the memory to allocate/resize. + * + * @see CassMallocFunction + * @see CassFreeFunction + * @see cass_alloc_set_functions() + */ +typedef void* (*CassReallocFunction)(void* ptr, size_t size); + +/** + * A custom free function. This function deallocates the memory pointed to by + * "ptr" that was previously allocated by a "CassMallocFunction" or + * "CassReallocFunction" function. + * + * @param[in] ptr A pointer to memory that should be deallocated. If NULL then + * this will perform no operation. + * + * @see CassMallocFunction + * @see CassReallocFunction + * @see cass_alloc_set_functions() + */ +typedef void (*CassFreeFunction)(void* ptr); + +/** + * An authenticator. + * + * @struct CassAuthenticator + */ +typedef struct CassAuthenticator_ CassAuthenticator; + +/** + * A callback used to initiate an authentication exchange. + * + * Use cass_authenticator_set_response() to set the response token. + * + * Use cass_authenticator_set_error() if an error occurred during + * initialization. + * + * @param[in] auth + * @param[in] data + */ +typedef void (*CassAuthenticatorInitialCallback)(CassAuthenticator* auth, + void* data); + +/** + * A callback used when an authentication challenge initiated + * by the server. + * + * Use cass_authenticator_set_response() to set the response token. + * + * Use cass_authenticator_set_error() if an error occurred during the + * challenge. + * + * @param[in] auth + * @param[in] data + * @param[in] token + * @param[in] token_size + */ +typedef void (*CassAuthenticatorChallengeCallback)(CassAuthenticator* auth, + void* data, + const char* token, + size_t token_size); +/** + * A callback used to indicate the success of the authentication + * exchange. + * + * Use cass_authenticator_set_error() if an error occurred while evaluating + * the success token. + * + * @param[in] auth + * @param[in] data + * @param[in] token + * @param[in] token_size + */ +typedef void (*CassAuthenticatorSuccessCallback)(CassAuthenticator* auth, + void* data, + const char* token, + size_t token_size); +/** + * A callback used to cleanup resources that were acquired during + * the process of the authentication exchange. This is called after + * the termination of the exchange regardless of the outcome. + * + * @param[in] auth + * @param[in] data + */ +typedef void (*CassAuthenticatorCleanupCallback)(CassAuthenticator* auth, + void* data); + +/** + * A callback used to cleanup resources. + * + * @param[in] data + */ +typedef void (*CassAuthenticatorDataCleanupCallback)(void* data); + +/** + * Authenticator callbacks + */ +typedef struct CassAuthenticatorCallbacks_ { + CassAuthenticatorInitialCallback initial_callback; + CassAuthenticatorChallengeCallback challenge_callback; + CassAuthenticatorSuccessCallback success_callback; + CassAuthenticatorCleanupCallback cleanup_callback; +} CassAuthenticatorCallbacks; + +typedef enum CassHostListenerEvent_ { + CASS_HOST_LISTENER_EVENT_UP, + CASS_HOST_LISTENER_EVENT_DOWN, + CASS_HOST_LISTENER_EVENT_ADD, + CASS_HOST_LISTENER_EVENT_REMOVE +} CassHostListenerEvent; + +/** + * A callback used to indicate the host state for a node in the cluster. + * + * @param[in] event + * @param[in] address + * @param[in] data + * @see cass_cluster_set_host_listener_callback() + */ +typedef void(*CassHostListenerCallback)(CassHostListenerEvent event, + const CassInet address, + void* data); + +/*********************************************************************************** + * + * Execution Profile + * + ***********************************************************************************/ + +/** + * An execution profile object provides a mechanism to group together a set of + * configuration options and reuse them across different statement executions. + * This feature is useful when dealing with different query workloads. + * + * @struct CassExecProfile + */ +typedef struct CassExecProfile_ CassExecProfile; + +/** + * Creates a new execution profile. + * + * @public @memberof CassExecProfile + * + * @return Returns a execution profile that must be freed. + * + * @see cass_execution_profile_free() + */ +CASS_EXPORT CassExecProfile* +cass_execution_profile_new(); + +/** + * Frees a execution profile instance. + * + * @public @memberof CassExecProfile + * + * @param[in] profile + */ +CASS_EXPORT void +cass_execution_profile_free(CassExecProfile* profile); + +/** + * Sets the timeout waiting for a response from a node. + * + * Default: Disabled (uses the cluster request timeout) + * + * @public @memberof CassExecProfile + * + * @param[in] profile + * @param[in] timeout_ms Request timeout in milliseconds. Use 0 for no timeout + * or CASS_UINT64_MAX to disable. + * @return CASS_OK if successful, otherwise an error occurred. + * + * @see cass_statement_set_request_timeout() + */ +CASS_EXPORT CassError +cass_execution_profile_set_request_timeout(CassExecProfile* profile, + cass_uint64_t timeout_ms); + +/** + * Sets the consistency level. + * + * Default: Disabled (uses the default consistency) + * + * @public @memberof CassExecProfile + * + * @param[in] profile + * @param[in] consistency + * @return CASS_OK if successful, otherwise an error occurred. + * + * @see cass_statement_set_consistency() + */ +CASS_EXPORT CassError +cass_execution_profile_set_consistency(CassExecProfile* profile, + CassConsistency consistency); + +/** + * Sets the serial consistency level. + * + * Default: Disabled (uses the default serial consistency) + * + * @public @memberof CassExecProfile + * + * @param[in] profile + * @param[in] serial_consistency + * @return CASS_OK if successful, otherwise an error occurred. + * + * @see cass_statement_set_serial_consistency() + */ +CASS_EXPORT CassError +cass_execution_profile_set_serial_consistency(CassExecProfile* profile, + CassConsistency serial_consistency); + +/** + * Configures the execution profile to use round-robin load balancing. + * + * The driver discovers all nodes in a cluster and cycles through + * them per request. All are considered 'local'. + * + * Note: Profile-based load balancing policy is disabled by default; + * cluster load balancing policy is used when profile does not contain a policy. + * + * @public @memberof CassExecProfile + * + * @param[in] profile + * @return CASS_OK if successful, otherwise an error occurred. + * + * @see cass_cluster_set_load_balance_round_robin() + */ +CASS_EXPORT CassError +cass_execution_profile_set_load_balance_round_robin(CassExecProfile* profile); + +/** + * Configures the execution profile to use DC-aware load balancing. + * For each query, all live nodes in a primary 'local' DC are tried first, + * followed by any node from other DCs. + * + * Note: Profile-based load balancing policy is disabled by default; + * cluster load balancing policy is used when profile does not contain a policy. + * + * @deprecated The remote DC settings for DC-aware are not suitable for most + * scenarios that require DC failover. There is also unhandled gap between + * replication factor number of nodes failing and the full cluster failing. Only + * the remote DC settings are being deprecated. + * + * @public @memberof CassExecProfile + * + * @param[in] profile + * @param[in] local_dc The primary data center to try first + * @param[in] used_hosts_per_remote_dc The number of hosts used in each remote + * DC if no hosts are available in the local dc (deprecated) + * @param[in] allow_remote_dcs_for_local_cl Allows remote hosts to be used if no + * local dc hosts are available and the consistency level is LOCAL_ONE or + * LOCAL_QUORUM (deprecated) + * @return CASS_OK if successful, otherwise an error occurred. + * + * @see cass_cluster_set_load_balance_dc_aware() + */ +CASS_EXPORT CassError +cass_execution_profile_set_load_balance_dc_aware(CassExecProfile* profile, + const char* local_dc, + unsigned used_hosts_per_remote_dc, + cass_bool_t allow_remote_dcs_for_local_cl); + +/** + * Same as cass_execution_profile_set_load_balance_dc_aware(), but with lengths + * for string parameters. + * + * @deprecated The remote DC settings for DC-aware are not suitable for most + * scenarios that require DC failover. There is also unhandled gap between + * replication factor number of nodes failing and the full cluster failing. Only + * the remote DC settings are being deprecated. + * + * @public @memberof CassExecProfile + * + * @param[in] profile + * @param[in] local_dc + * @param[in] local_dc_length + * @param[in] used_hosts_per_remote_dc (deprecated) + * @param[in] allow_remote_dcs_for_local_cl (deprecated) + * @return same as cass_execution_profile_set_load_balance_dc_aware() + * + * @see cass_execution_profile_set_load_balance_dc_aware() + * @see cass_cluster_set_load_balance_dc_aware_n() + */ +CASS_EXPORT CassError +cass_execution_profile_set_load_balance_dc_aware_n(CassExecProfile* profile, + const char* local_dc, + size_t local_dc_length, + unsigned used_hosts_per_remote_dc, + cass_bool_t allow_remote_dcs_for_local_cl); + +/** + * Configures the execution profile to use token-aware request routing or not. + * + * Important: Token-aware routing depends on keyspace metadata. + * For this reason enabling token-aware routing will also enable retrieving + * and updating keyspace schema metadata. + * + * Default: cass_true (enabled). + * + * This routing policy composes the base routing policy, routing + * requests first to replicas on nodes considered 'local' by + * the base load balancing policy. + * + * Note: Execution profiles use the cluster-level load balancing policy + * unless enabled. This setting is not applicable unless a load balancing policy + * is enabled on the execution profile. + * + * @public @memberof CassExecProfile + * + * @param[in] profile + * @param[in] enabled + * @return CASS_OK if successful, otherwise an error occurred. + * + * @see cass_cluster_set_token_aware_routing() + */ +CASS_EXPORT CassError +cass_execution_profile_set_token_aware_routing(CassExecProfile* profile, + cass_bool_t enabled); + +/** + * Configures the execution profile's token-aware routing to randomly shuffle + * replicas. This can reduce the effectiveness of server-side caching, but it + * can better distribute load over replicas for a given partition key. + * + * Note: Token-aware routing must be enabled and a load balancing policy + * must be enabled on the execution profile for the setting to be applicable. + * + * Default: cass_true (enabled). + * + * @public @memberof CassExecProfile + * + * @param[in] profile + * @param[in] enabled + * @return CASS_OK if successful, otherwise an error occurred. + * + * @see cass_cluster_set_token_aware_routing_shuffle_replicas() + */ +CASS_EXPORT CassError +cass_execution_profile_set_token_aware_routing_shuffle_replicas(CassExecProfile* profile, + cass_bool_t enabled); + +/** + * Configures the execution profile to use latency-aware request routing or not. + * + * Note: Execution profiles use the cluster-level load balancing policy + * unless enabled. This setting is not applicable unless a load balancing policy + * is enabled on the execution profile. + * + * Default: cass_false (disabled). + * + * This routing policy is a top-level routing policy. It uses the + * base routing policy to determine locality (dc-aware) and/or + * placement (token-aware) before considering the latency. + * + * @public @memberof CassExecProfile + * + * @param[in] profile + * @param[in] enabled + * @return CASS_OK if successful, otherwise an error occurred. + * + * @see cass_cluster_set_latency_aware_routing() + */ +CASS_EXPORT CassError +cass_execution_profile_set_latency_aware_routing(CassExecProfile* profile, + cass_bool_t enabled); + +/** + * Configures the execution profile's settings for latency-aware request + * routing. + * + * Note: Execution profiles use the cluster-level load balancing policy + * unless enabled. This setting is not applicable unless a load balancing policy + * is enabled on the execution profile. + * + * Defaults: + * + *
    + *
  • exclusion_threshold: 2.0
  • + *
  • scale_ms: 100 milliseconds
  • + *
  • retry_period_ms: 10,000 milliseconds (10 seconds)
  • + *
  • update_rate_ms: 100 milliseconds
  • + *
  • min_measured: 50
  • + *
+ * + * @public @memberof CassExecProfile + * + * @param[in] profile + * @param[in] exclusion_threshold Controls how much worse the latency must be + * compared to the average latency of the best performing node before it + * penalized. + * @param[in] scale_ms Controls the weight given to older latencies when + * calculating the average latency of a node. A bigger scale will give more + * weight to older latency measurements. + * @param[in] retry_period_ms The amount of time a node is penalized by the + * policy before being given a second chance when the current average latency + * exceeds the calculated threshold + * (exclusion_threshold * best_average_latency). + * @param[in] update_rate_ms The rate at which the best average latency is + * recomputed. + * @param[in] min_measured The minimum number of measurements per-host required + * to be considered by the policy. + * @return CASS_OK if successful, otherwise an error occurred. + * + * @see cass_cluster_set_latency_aware_routing_settings() + */ +CASS_EXPORT CassError +cass_execution_profile_set_latency_aware_routing_settings(CassExecProfile* profile, + cass_double_t exclusion_threshold, + cass_uint64_t scale_ms, + cass_uint64_t retry_period_ms, + cass_uint64_t update_rate_ms, + cass_uint64_t min_measured); + +/** + * Sets/Appends whitelist hosts for the execution profile. The first call sets + * the whitelist hosts and any subsequent calls appends additional hosts. + * Passing an empty string will clear and disable the whitelist. White space is + * striped from the hosts. + * + * This policy filters requests to all other policies, only allowing requests + * to the hosts contained in the whitelist. Any host not in the whitelist will + * be ignored and a connection will not be established. This policy is useful + * for ensuring that the driver will only connect to a predefined set of hosts. + * + * Examples: "127.0.0.1" "127.0.0.1,127.0.0.2" + * + * Note: Execution profiles use the cluster-level load balancing policy + * unless enabled. This setting is not applicable unless a load balancing policy + * is enabled on the execution profile. + * + * @public @memberof CassExecProfile + * + * @param[in] profile + * @param[in] hosts A comma delimited list of addresses. An empty string will + * clear the whitelist hosts. The string is copied into the cluster + * configuration; the memory pointed to by this parameter can be freed after + * this call. + * @return CASS_OK if successful, otherwise an error occurred. + * + * @see cass_cluster_set_whitelist_filtering() + */ +CASS_EXPORT CassError +cass_execution_profile_set_whitelist_filtering(CassExecProfile* profile, + const char* hosts); + +/** + * Same as cass_execution_profile_set_whitelist_filtering(), but with lengths + * for string parameters. + * + * @public @memberof CassExecProfile + * + * @param[in] profile + * @param[in] hosts + * @param[in] hosts_length + * @return same as cass_execution_profile_set_whitelist_filtering() + * + * @see cass_execution_profile_set_whitelist_filtering() + * @see cass_cluster_set_whitelist_filtering() + */ +CASS_EXPORT CassError +cass_execution_profile_set_whitelist_filtering_n(CassExecProfile* profile, + const char* hosts, + size_t hosts_length); + +/** + * Sets/Appends blacklist hosts for the execution profile. The first call sets + * the blacklist hosts and any subsequent calls appends additional hosts. + * Passing an empty string will clear and disable the blacklist. White space is + * striped from the hosts. + * + * This policy filters requests to all other policies, only allowing requests + * to the hosts not contained in the blacklist. Any host in the blacklist will + * be ignored and a connection will not be established. This policy is useful + * for ensuring that the driver will not connect to a predefined set of hosts. + * + * Examples: "127.0.0.1" "127.0.0.1,127.0.0.2" + * + * Note: Execution profiles use the cluster-level load balancing policy + * unless enabled. This setting is not applicable unless a load balancing policy + * is enabled on the execution profile. + * + * @public @memberof CassExecProfile + * + * @param[in] profile + * @param[in] hosts A comma delimited list of addresses. An empty string will + * clear the blacklist hosts. The string is copied into the cluster + * configuration; the memory pointed to by this parameter can be freed after + * this call. + * @return CASS_OK if successful, otherwise an error occurred. + * + * @see cass_cluster_set_blacklist_filtering() + */ +CASS_EXPORT CassError +cass_execution_profile_set_blacklist_filtering(CassExecProfile* profile, + const char* hosts); + +/** + * Same as cass_execution_profile_set_blacklist_filtering(), but with lengths + * for string parameters. + * + * @public @memberof CassExecProfile + * + * @param[in] profile + * @param[in] hosts + * @param[in] hosts_length + * @return same as cass_execution_profile_set_blacklist_filtering_hosts() + * + * @see cass_execution_profile_set_blacklist_filtering() + * @see cass_cluster_set_blacklist_filtering() + */ +CASS_EXPORT CassError +cass_execution_profile_set_blacklist_filtering_n(CassExecProfile* profile, + const char* hosts, + size_t hosts_length); + +/** + * Same as cass_execution_profile_set_whitelist_filtering(), but whitelist all + * hosts of a dc. + * + * Examples: "dc1", "dc1,dc2" + * + * @public @memberof CassExecProfile + * + * @param[in] profile + * @param[in] dcs A comma delimited list of dcs. An empty string will clear the + * whitelist dcs. The string is copied into the cluster configuration; the + * memory pointed to by this parameter can be freed after this call. + * @return CASS_OK if successful, otherwise an error occurred. + * + * @see cass_cluster_set_whitelist_dc_filtering() + */ +CASS_EXPORT CassError +cass_execution_profile_set_whitelist_dc_filtering(CassExecProfile* profile, + const char* dcs); + +/** + * Same as cass_execution_profile_set_whitelist_dc_filtering(), but with lengths + * for string parameters. + * + * @public @memberof CassExecProfile + * + * @param[in] profile + * @param[in] dcs + * @param[in] dcs_length + * @return same as cass_execution_profile_set_whitelist_dc_filtering() + * + * @see cass_execution_profile_set_whitelist_dc_filtering() + * @see cass_cluster_set_whitelist_dc_filtering() + */ +CASS_EXPORT CassError +cass_execution_profile_set_whitelist_dc_filtering_n(CassExecProfile* profile, + const char* dcs, + size_t dcs_length); + +/** + * Same as cass_execution_profile_set_blacklist_filtering(), but blacklist all + * hosts of a dc. + * + * Examples: "dc1", "dc1,dc2" + * + * @public @memberof CassExecProfile + * + * @param[in] profile + * @param[in] dcs A comma delimited list of dcs. An empty string will clear the + * blacklist dcs. The string is copied into the cluster configuration; the + * memory pointed to by this parameter can be freed after this call. + * @return CASS_OK if successful, otherwise an error occurred. + * + * @see cass_execution_profile_set_blacklist_filtering() + * @see cass_cluster_set_blacklist_dc_filtering() + */ +CASS_EXPORT CassError +cass_execution_profile_set_blacklist_dc_filtering(CassExecProfile* profile, + const char* dcs); + +/** + * Same as cass_execution_profile_set_blacklist_dc_filtering(), but with lengths + * for string parameters. + * + * @public @memberof CassExecProfile + * + * @param[in] profile + * @param[in] dcs + * @param[in] dcs_length + * @return same as cass_execution_profile_set_blacklist_dc_filtering() + * + * @see cass_execution_profile_set_blacklist_dc_filtering() + * @see cass_cluster_set_blacklist_dc_filtering() + */ +CASS_EXPORT CassError +cass_execution_profile_set_blacklist_dc_filtering_n(CassExecProfile* profile, + const char* dcs, + size_t dcs_length); + +/** + * Sets the execution profile's retry policy. + * + * Note: Profile-based retry policy is disabled by default; cluster retry + * policy is used when profile does not contain a policy unless the retry policy + * was explicitly set on the batch/statement request. + * + * @public @memberof CassExecProfile + * + * @param[in] profile + * @param[in] retry_policy NULL will clear retry policy from execution profile + * @return CASS_OK if successful, otherwise an error occurred. + * + * @see cass_cluster_set_retry_policy() + */ +CASS_EXPORT CassError +cass_execution_profile_set_retry_policy(CassExecProfile* profile, + CassRetryPolicy* retry_policy); + +/** + * Enable constant speculative executions with the supplied settings for the + * execution profile. + * + * Note: Profile-based speculative execution policy is disabled by + * default; cluster speculative execution policy is used when profile does not + * contain a policy. + * + * @public @memberof CassExecProfile + * + * @param[in] profile + * @param[in] constant_delay_ms + * @param[in] max_speculative_executions + * @return CASS_OK if successful, otherwise an error occurred + * + * @see cass_cluster_set_constant_speculative_execution_policy() + */ +CASS_EXPORT CassError +cass_execution_profile_set_constant_speculative_execution_policy(CassExecProfile* profile, + cass_int64_t constant_delay_ms, + int max_speculative_executions); + +/** + * Disable speculative executions for the execution profile. + * + * Note: Profile-based speculative execution policy is disabled by + * default; cluster speculative execution policy is used when profile does not + * contain a policy. + * + * @public @memberof CassExecProfile + * + * @param[in] profile + * @return CASS_OK if successful, otherwise an error occurred + * + * @see cass_cluster_set_no_speculative_execution_policy() + */ +CASS_EXPORT CassError +cass_execution_profile_set_no_speculative_execution_policy(CassExecProfile* profile); + +/*********************************************************************************** + * + * Cluster + * + ***********************************************************************************/ + +/** + * Creates a new cluster. + * + * @public @memberof CassCluster + * + * @return Returns a cluster that must be freed. + * + * @see cass_cluster_free() + */ +CASS_EXPORT CassCluster* +cass_cluster_new(); + +/** + * Frees a cluster instance. + * + * @public @memberof CassCluster + * + * @param[in] cluster + */ +CASS_EXPORT void +cass_cluster_free(CassCluster* cluster); + +/** + * Sets/Appends contact points. This *MUST* be set. The first call sets + * the contact points and any subsequent calls appends additional contact + * points. Passing an empty string will clear the contact points. White space + * is striped from the contact points. + * + * Examples: "127.0.0.1" "127.0.0.1,127.0.0.2", "server1.domain.com" + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] contact_points A comma delimited list of addresses or + * names. An empty string will clear the contact points. + * The string is copied into the cluster configuration; the memory pointed + * to by this parameter can be freed after this call. + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_cluster_set_contact_points(CassCluster* cluster, + const char* contact_points); + +/** + * Same as cass_cluster_set_contact_points(), but with lengths for string + * parameters. + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] contact_points + * @param[in] contact_points_length + * @return same as cass_cluster_set_contact_points() + * + * @see cass_cluster_set_contact_points() + */ +CASS_EXPORT CassError +cass_cluster_set_contact_points_n(CassCluster* cluster, + const char* contact_points, + size_t contact_points_length); + +/** + * Sets the port. + * + * Default: 9042 + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] port + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_cluster_set_port(CassCluster* cluster, + int port); + +/** + * Sets the local address to bind when connecting to the cluster, + * if desired. + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] name IP address to bind, or empty string for no binding. + * Only numeric addresses are supported; no resolution is done. + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_cluster_set_local_address(CassCluster* cluster, + const char* name); + +/** + * Same as cass_cluster_set_local_address(), but with lengths for string + * parameters. + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] name + * @param[in] name_length + * @return same as cass_cluster_set_local_address() + * + * @see cass_cluster_set_local_address() + */ +CASS_EXPORT CassError +cass_cluster_set_local_address_n(CassCluster* cluster, + const char* name, + size_t name_length); + +/** + * Sets the SSL context and enables SSL. + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] ssl + * + * @see cass_ssl_new() + */ +CASS_EXPORT void +cass_cluster_set_ssl(CassCluster* cluster, + CassSsl* ssl); + +/** + * Sets custom authenticator + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] exchange_callbacks + * @param[in] cleanup_callback + * @param[in] data + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_cluster_set_authenticator_callbacks(CassCluster* cluster, + const CassAuthenticatorCallbacks* exchange_callbacks, + CassAuthenticatorDataCleanupCallback cleanup_callback, + void* data); + +/** + * Sets the protocol version. The driver will automatically downgrade to the lowest + * supported protocol version. + * + * Default: CASS_PROTOCOL_VERSION_V4 or CASS_PROTOCOL_VERSION_DSEV1 when + * using the DSE driver with DataStax Enterprise. + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] protocol_version + * @return CASS_OK if successful, otherwise an error occurred. + * + * @see cass_cluster_set_use_beta_protocol_version() + */ +CASS_EXPORT CassError +cass_cluster_set_protocol_version(CassCluster* cluster, + int protocol_version); + +/** + * Use the newest beta protocol version. This currently enables the use of + * protocol version v5 (CASS_PROTOCOL_VERSION_V5) or DSEv2 (CASS_PROTOCOL_VERSION_DSEV2) + * when using the DSE driver with DataStax Enterprise. + * + * Default: cass_false + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] enable if false the highest non-beta protocol version will be used + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_cluster_set_use_beta_protocol_version(CassCluster* cluster, + cass_bool_t enable); + +/** + * Sets default consistency level of statement. + * + * Default: CASS_CONSISTENCY_LOCAL_ONE + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] consistency + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_cluster_set_consistency(CassCluster* cluster, + CassConsistency consistency); + +/** + * Sets default serial consistency level of statement. + * + * Default: CASS_CONSISTENCY_ANY + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] consistency + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_cluster_set_serial_consistency(CassCluster* cluster, + CassConsistency consistency); + +/** + * Sets the number of IO threads. This is the number of threads + * that will handle query requests. + * + * Default: 1 + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] num_threads + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_cluster_set_num_threads_io(CassCluster* cluster, + unsigned num_threads); + +/** + * Sets the size of the fixed size queue that stores + * pending requests. + * + * Default: 8192 + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] queue_size + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_cluster_set_queue_size_io(CassCluster* cluster, + unsigned queue_size); + +/** + * Sets the size of the fixed size queue that stores + * events. + * + * Default: 8192 + * + * @public @memberof CassCluster + * + * @deprecated This is no longer useful and does nothing. Expect this to be + * removed in a future release. + * + * @param[in] cluster + * @param[in] queue_size + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CASS_DEPRECATED(CassError +cass_cluster_set_queue_size_event(CassCluster* cluster, + unsigned queue_size)); + +/** + * Sets the number of connections made to each server in each + * IO thread. + * + * Default: 1 + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] num_connections + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_cluster_set_core_connections_per_host(CassCluster* cluster, + unsigned num_connections); + +/** + * Sets the maximum number of connections made to each server in each + * IO thread. + * + * Default: 2 + * + * @public @memberof CassCluster + * + * @deprecated This is no longer useful and does nothing. Expect this to be + * removed in a future release. + * + * @param[in] cluster + * @param[in] num_connections + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CASS_DEPRECATED(CassError +cass_cluster_set_max_connections_per_host(CassCluster* cluster, + unsigned num_connections)); + +/** + * Sets the amount of time to wait before attempting to reconnect. + * + * @public @memberof CassCluster + * + * @deprecated This is being replaced with cass_cluster_set_constant_reconnect(). + * Expect this to be removed in a future release. + * + * @param[in] cluster + * @param[in] wait_time + */ +CASS_EXPORT CASS_DEPRECATED(void +cass_cluster_set_reconnect_wait_time(CassCluster* cluster, + unsigned wait_time)); + +/** + * Configures the cluster to use a reconnection policy that waits a constant + * time between each reconnection attempt. + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] delay_ms Time in milliseconds to delay attempting a reconnection; + * 0 to perform a reconnection immediately. + */ +CASS_EXPORT void +cass_cluster_set_constant_reconnect(CassCluster* cluster, + cass_uint64_t delay_ms); + +/** + * Configures the cluster to use a reconnection policy that waits exponentially + * longer between each reconnection attempt; however will maintain a constant + * delay once the maximum delay is reached. + * + * Default: + *
    + *
  • 2000 milliseconds base delay
  • + *
  • 60000 milliseconds max delay
  • + *
+ * + *

+ * Note: A random amount of jitter (+/- 15%) will be added to the pure + * exponential delay value. This helps to prevent situations where multiple + * connections are in the reconnection process at exactly the same time. The + * jitter will never cause the delay to be less than the base delay, or more + * than the max delay. + *

+ * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] base_delay_ms The base delay (in milliseconds) to use for + * scheduling reconnection attempts. + * @param[in] max_delay_ms The maximum delay to wait between two reconnection + * attempts. + * @return CASS_OK if successful, otherwise error occurred. + */ +CASS_EXPORT CassError +cass_cluster_set_exponential_reconnect(CassCluster* cluster, + cass_uint64_t base_delay_ms, + cass_uint64_t max_delay_ms); + +/** + * Sets the amount of time, in microseconds, to wait for new requests to + * coalesce into a single system call. This should be set to a value around + * the latency SLA of your application's requests while also considering the + * request's roundtrip time. Larger values should be used for throughput + * bound workloads and lower values should be used for latency bound + * workloads. + * + * Default: 200 us + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] delay_us + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_cluster_set_coalesce_delay(CassCluster* cluster, + cass_int64_t delay_us); + +/** + * Sets the ratio of time spent processing new requests versus handling the I/O + * and processing of outstanding requests. The range of this setting is 1 to 100, + * where larger values allocate more time to processing new requests and smaller + * values allocate more time to processing outstanding requests. + * + * Default: 50 + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] ratio + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_cluster_set_new_request_ratio(CassCluster* cluster, + cass_int32_t ratio); + +/** + * Sets the maximum number of connections that will be created concurrently. + * Connections are created when the current connections are unable to keep up with + * request throughput. + * + * Default: 1 + * + * @public @memberof CassCluster + * + * @deprecated This is no longer useful and does nothing. Expect this to be + * removed in a future release. + * + * @param[in] cluster + * @param[in] num_connections + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CASS_DEPRECATED(CassError +cass_cluster_set_max_concurrent_creation(CassCluster* cluster, + unsigned num_connections)); + +/** + * Sets the threshold for the maximum number of concurrent requests in-flight + * on a connection before creating a new connection. The number of new connections + * created will not exceed max_connections_per_host. + * + * Default: 100 + * + * @public @memberof CassCluster + * + * @deprecated This is no longer useful and does nothing. Expect this to be + * removed in a future release. + * + * @param[in] cluster + * @param[in] num_requests + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CASS_DEPRECATED(CassError +cass_cluster_set_max_concurrent_requests_threshold(CassCluster* cluster, + unsigned num_requests)); + +/** + * Sets the maximum number of requests processed by an IO worker + * per flush. + * + * Default: 128 + * + * @public @memberof CassCluster + * + * @deprecated This is no longer useful and does nothing. Expect this to be + * removed in a future release. + * + * @param[in] cluster + * @param[in] num_requests + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CASS_DEPRECATED(CassError +cass_cluster_set_max_requests_per_flush(CassCluster* cluster, + unsigned num_requests)); + +/** + * Sets the high water mark for the number of bytes outstanding + * on a connection. Disables writes to a connection if the number + * of bytes queued exceed this value. + * + * Default: 64 KB + * + * @public @memberof CassCluster + * + * @deprecated This is no longer useful and does nothing. Expect this to be + * removed in a future release. + * + * @param[in] cluster + * @param[in] num_bytes + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CASS_DEPRECATED(CassError +cass_cluster_set_write_bytes_high_water_mark(CassCluster* cluster, + unsigned num_bytes)); + +/** + * Sets the low water mark for number of bytes outstanding on a + * connection. After exceeding high water mark bytes, writes will + * only resume once the number of bytes fall below this value. + * + * Default: 32 KB + * + * @public @memberof CassCluster + * + * @deprecated This is no longer useful and does nothing. Expect this to be + * removed in a future release. + * + * @param[in] cluster + * @param[in] num_bytes + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CASS_DEPRECATED(CassError +cass_cluster_set_write_bytes_low_water_mark(CassCluster* cluster, + unsigned num_bytes)); + +/** + * Sets the high water mark for the number of requests queued waiting + * for a connection in a connection pool. Disables writes to a + * host on an IO worker if the number of requests queued exceed this + * value. + * + * Default: 256 + * + * @public @memberof CassCluster + * + * @deprecated This is no longer useful and does nothing. Expect this to be + * removed in a future release. + * + * @param[in] cluster + * @param[in] num_requests + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CASS_DEPRECATED(CassError +cass_cluster_set_pending_requests_high_water_mark(CassCluster* cluster, + unsigned num_requests)); + +/** + * Sets the low water mark for the number of requests queued waiting + * for a connection in a connection pool. After exceeding high water mark + * requests, writes to a host will only resume once the number of requests + * fall below this value. + * + * Default: 128 + * + * @public @memberof CassCluster + * + * @deprecated This is no longer useful and does nothing. Expect this to be + * removed in a future release. + * + * @param[in] cluster + * @param[in] num_requests + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CASS_DEPRECATED(CassError +cass_cluster_set_pending_requests_low_water_mark(CassCluster* cluster, + unsigned num_requests)); + +/** + * Sets the timeout for connecting to a node. + * + * Default: 5000 milliseconds + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] timeout_ms Connect timeout in milliseconds + */ +CASS_EXPORT void +cass_cluster_set_connect_timeout(CassCluster* cluster, + unsigned timeout_ms); + +/** + * Sets the timeout for waiting for a response from a node. + * + * Default: 12000 milliseconds + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] timeout_ms Request timeout in milliseconds. Use 0 for no timeout. + */ +CASS_EXPORT void +cass_cluster_set_request_timeout(CassCluster* cluster, + unsigned timeout_ms); + +/** + * Sets the timeout for waiting for DNS name resolution. + * + * Default: 2000 milliseconds + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] timeout_ms Request timeout in milliseconds + */ +CASS_EXPORT void +cass_cluster_set_resolve_timeout(CassCluster* cluster, + unsigned timeout_ms); + +/** + * Sets the maximum time to wait for schema agreement after a schema change + * is made (e.g. creating, altering, dropping a table/keyspace/view/index etc). + * + * Default: 10000 milliseconds + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] wait_time_ms Wait time in milliseconds + */ +CASS_EXPORT void +cass_cluster_set_max_schema_wait_time(CassCluster* cluster, + unsigned wait_time_ms); + + +/** + * Sets the maximum time to wait for tracing data to become available. + * + * Default: 15 milliseconds + * + * @param[in] cluster + * @param[in] max_wait_time_ms + */ +CASS_EXPORT void +cass_cluster_set_tracing_max_wait_time(CassCluster* cluster, + unsigned max_wait_time_ms); + +/** + * Sets the amount of time to wait between attempts to check to see if tracing is + * available. + * + * Default: 3 milliseconds + * + * @param[in] cluster + * @param[in] retry_wait_time_ms + */ +CASS_EXPORT void +cass_cluster_set_tracing_retry_wait_time(CassCluster* cluster, + unsigned retry_wait_time_ms); + +/** + * Sets the consistency level to use for checking to see if tracing data is + * available. + * + * Default: CASS_CONSISTENCY_ONE + * + * @param[in] cluster + * @param[in] consistency + */ +CASS_EXPORT void +cass_cluster_set_tracing_consistency(CassCluster* cluster, + CassConsistency consistency); + + +/** + * Sets credentials for plain text authentication. + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] username + * @param[in] password + */ +CASS_EXPORT void +cass_cluster_set_credentials(CassCluster* cluster, + const char* username, + const char* password); + +/** + * Same as cass_cluster_set_credentials(), but with lengths for string + * parameters. + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] username + * @param[in] username_length + * @param[in] password + * @param[in] password_length + * @return same as cass_cluster_set_credentials() + * + * @see cass_cluster_set_credentials(); + */ +CASS_EXPORT void +cass_cluster_set_credentials_n(CassCluster* cluster, + const char* username, + size_t username_length, + const char* password, + size_t password_length); + +/** + * Configures the cluster to use round-robin load balancing. + * + * The driver discovers all nodes in a cluster and cycles through + * them per request. All are considered 'local'. + * + * @public @memberof CassCluster + * + * @param[in] cluster + */ +CASS_EXPORT void +cass_cluster_set_load_balance_round_robin(CassCluster* cluster); + +/** + * Configures the cluster to use DC-aware load balancing. + * For each query, all live nodes in a primary 'local' DC are tried first, + * followed by any node from other DCs. + * + * Note: This is the default, and does not need to be called unless + * switching an existing from another policy or changing settings. + * Without further configuration, a default local_dc is chosen from the + * first connected contact point, and no remote hosts are considered in + * query plans. If relying on this mechanism, be sure to use only contact + * points from the local DC. + * + * @deprecated The remote DC settings for DC-aware are not suitable for most + * scenarios that require DC failover. There is also unhandled gap between + * replication factor number of nodes failing and the full cluster failing. Only + * the remote DC settings are being deprecated. + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] local_dc The primary data center to try first + * @param[in] used_hosts_per_remote_dc The number of hosts used in each remote + * DC if no hosts are available in the local dc (deprecated) + * @param[in] allow_remote_dcs_for_local_cl Allows remote hosts to be used if no + * local dc hosts are available and the consistency level is LOCAL_ONE or + * LOCAL_QUORUM (deprecated) + * @return CASS_OK if successful, otherwise an error occurred + */ +CASS_EXPORT CassError +cass_cluster_set_load_balance_dc_aware(CassCluster* cluster, + const char* local_dc, + unsigned used_hosts_per_remote_dc, + cass_bool_t allow_remote_dcs_for_local_cl); + + +/** + * Same as cass_cluster_set_load_balance_dc_aware(), but with lengths for string + * parameters. + * + * @deprecated The remote DC settings for DC-aware are not suitable for most + * scenarios that require DC failover. There is also unhandled gap between + * replication factor number of nodes failing and the full cluster failing. Only + * the remote DC settings are being deprecated. + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] local_dc + * @param[in] local_dc_length + * @param[in] used_hosts_per_remote_dc (deprecated) + * @param[in] allow_remote_dcs_for_local_cl (deprecated) + * @return same as cass_cluster_set_load_balance_dc_aware() + * + * @see cass_cluster_set_load_balance_dc_aware() + */ +CASS_EXPORT CassError +cass_cluster_set_load_balance_dc_aware_n(CassCluster* cluster, + const char* local_dc, + size_t local_dc_length, + unsigned used_hosts_per_remote_dc, + cass_bool_t allow_remote_dcs_for_local_cl); + +/** + * Configures the cluster to use token-aware request routing or not. + * + * Important: Token-aware routing depends on keyspace metadata. + * For this reason enabling token-aware routing will also enable retrieving + * and updating keyspace schema metadata. + * + * Default: cass_true (enabled). + * + * This routing policy composes the base routing policy, routing + * requests first to replicas on nodes considered 'local' by + * the base load balancing policy. + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] enabled + */ +CASS_EXPORT void +cass_cluster_set_token_aware_routing(CassCluster* cluster, + cass_bool_t enabled); + + +/** + * Configures token-aware routing to randomly shuffle replicas. This can reduce + * the effectiveness of server-side caching, but it can better distribute load over + * replicas for a given partition key. + * + * Note: Token-aware routing must be enabled for the setting to + * be applicable. + * + * Default: cass_true (enabled). + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] enabled + */ +CASS_EXPORT void +cass_cluster_set_token_aware_routing_shuffle_replicas(CassCluster* cluster, + cass_bool_t enabled); + +/** + * Configures the cluster to use latency-aware request routing or not. + * + * Default: cass_false (disabled). + * + * This routing policy is a top-level routing policy. It uses the + * base routing policy to determine locality (dc-aware) and/or + * placement (token-aware) before considering the latency. + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] enabled + */ +CASS_EXPORT void +cass_cluster_set_latency_aware_routing(CassCluster* cluster, + cass_bool_t enabled); + +/** + * Configures the settings for latency-aware request routing. + * + * Defaults: + * + *
    + *
  • exclusion_threshold: 2.0
  • + *
  • scale_ms: 100 milliseconds
  • + *
  • retry_period_ms: 10,000 milliseconds (10 seconds)
  • + *
  • update_rate_ms: 100 milliseconds
  • + *
  • min_measured: 50
  • + *
+ * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] exclusion_threshold Controls how much worse the latency must be compared to the + * average latency of the best performing node before it penalized. + * @param[in] scale_ms Controls the weight given to older latencies when calculating the average + * latency of a node. A bigger scale will give more weight to older latency measurements. + * @param[in] retry_period_ms The amount of time a node is penalized by the policy before + * being given a second chance when the current average latency exceeds the calculated + * threshold (exclusion_threshold * best_average_latency). + * @param[in] update_rate_ms The rate at which the best average latency is recomputed. + * @param[in] min_measured The minimum number of measurements per-host required to + * be considered by the policy. + */ +CASS_EXPORT void +cass_cluster_set_latency_aware_routing_settings(CassCluster* cluster, + cass_double_t exclusion_threshold, + cass_uint64_t scale_ms, + cass_uint64_t retry_period_ms, + cass_uint64_t update_rate_ms, + cass_uint64_t min_measured); + +/** + * Sets/Appends whitelist hosts. The first call sets the whitelist hosts and + * any subsequent calls appends additional hosts. Passing an empty string will + * clear and disable the whitelist. White space is striped from the hosts. + * + * This policy filters requests to all other policies, only allowing requests + * to the hosts contained in the whitelist. Any host not in the whitelist will + * be ignored and a connection will not be established. This policy is useful + * for ensuring that the driver will only connect to a predefined set of hosts. + * + * Examples: "127.0.0.1" "127.0.0.1,127.0.0.2" + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] hosts A comma delimited list of addresses. An empty string will + * clear the whitelist hosts. The string is copied into the cluster + * configuration; the memory pointed to by this parameter can be freed after + * this call. + */ +CASS_EXPORT void +cass_cluster_set_whitelist_filtering(CassCluster* cluster, + const char* hosts); + +/** + * Same as cass_cluster_set_whitelist_filtering(), but with lengths for + * string parameters. + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] hosts + * @param[in] hosts_length + * @return same as cass_cluster_set_whitelist_filtering() + * + * @see cass_cluster_set_whitelist_filtering() + */ +CASS_EXPORT void +cass_cluster_set_whitelist_filtering_n(CassCluster* cluster, + const char* hosts, + size_t hosts_length); + +/** + * Sets/Appends blacklist hosts. The first call sets the blacklist hosts and + * any subsequent calls appends additional hosts. Passing an empty string will + * clear and disable the blacklist. White space is striped from the hosts. + * + * This policy filters requests to all other policies, only allowing requests + * to the hosts not contained in the blacklist. Any host in the blacklist will + * be ignored and a connection will not be established. This policy is useful + * for ensuring that the driver will not connect to a predefined set of hosts. + * + * Examples: "127.0.0.1" "127.0.0.1,127.0.0.2" + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] hosts A comma delimited list of addresses. An empty string will + * clear the blacklist hosts. The string is copied into the cluster + * configuration; the memory pointed to by this parameter can be freed after + * this call. + */ +CASS_EXPORT void +cass_cluster_set_blacklist_filtering(CassCluster* cluster, + const char* hosts); + +/** + * Same as cass_cluster_set_blacklist_filtering_hosts(), but with lengths for + * string parameters. + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] hosts + * @param[in] hosts_length + * @return same as cass_cluster_set_blacklist_filtering() + * + * @see cass_cluster_set_blacklist_filtering() + */ +CASS_EXPORT void +cass_cluster_set_blacklist_filtering_n(CassCluster* cluster, + const char* hosts, + size_t hosts_length); + +/** + * Same as cass_cluster_set_whitelist_filtering(), but whitelist all hosts of a dc + * + * Examples: "dc1", "dc1,dc2" + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] dcs A comma delimited list of dcs. An empty string will clear the + * whitelist dcs. The string is copied into the cluster configuration; the + * memory pointed to by this parameter can be freed after this call. + */ +CASS_EXPORT void +cass_cluster_set_whitelist_dc_filtering(CassCluster* cluster, + const char* dcs); + +/** + * Same as cass_cluster_set_whitelist_dc_filtering(), but with lengths for + * string parameters. + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] dcs + * @param[in] dcs_length + * @return same as cass_cluster_set_whitelist_dc_filtering() + * + * @see cass_cluster_set_whitelist_dc_filtering() + */ +CASS_EXPORT void +cass_cluster_set_whitelist_dc_filtering_n(CassCluster* cluster, + const char* dcs, + size_t dcs_length); + +/** + * Same as cass_cluster_set_blacklist_filtering(), but blacklist all hosts of a dc + * + * Examples: "dc1", "dc1,dc2" + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] dcs A comma delimited list of dcs. An empty string will clear the + * blacklist dcs. The string is copied into the cluster configuration; the + * memory pointed to by this parameter can be freed after this call. + */ +CASS_EXPORT void +cass_cluster_set_blacklist_dc_filtering(CassCluster* cluster, + const char* dcs); + +/** + * Same as cass_cluster_set_blacklist_dc_filtering(), but with lengths for + * string parameters. + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] dcs + * @param[in] dcs_length + * @return same as cass_cluster_set_blacklist_dc_filtering() + * + * @see cass_cluster_set_blacklist_dc_filtering() + */ +CASS_EXPORT void +cass_cluster_set_blacklist_dc_filtering_n(CassCluster* cluster, + const char* dcs, + size_t dcs_length); + +/** + * Enable/Disable Nagle's algorithm on connections. + * + * Default: cass_true (disables Nagle's algorithm). + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] enabled + */ +CASS_EXPORT void +cass_cluster_set_tcp_nodelay(CassCluster* cluster, + cass_bool_t enabled); + +/** + * Enable/Disable TCP keep-alive + * + * Default: cass_false (disabled). + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] enabled + * @param[in] delay_secs The initial delay in seconds, ignored when + * `enabled` is false. + */ +CASS_EXPORT void +cass_cluster_set_tcp_keepalive(CassCluster* cluster, + cass_bool_t enabled, + unsigned delay_secs); +/** + * Sets the timestamp generator used to assign timestamps to all requests + * unless overridden by setting the timestamp on a statement or a batch. + * + * Default: Monotonically increasing, client-side timestamp generator. + * + * @cassandra{2.1+} + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] timestamp_gen + * + * @see cass_statement_set_timestamp() + * @see cass_batch_set_timestamp() + */ +CASS_EXPORT void +cass_cluster_set_timestamp_gen(CassCluster* cluster, + CassTimestampGen* timestamp_gen); + +/** + * Sets the amount of time between heartbeat messages and controls the amount + * of time the connection must be idle before sending heartbeat messages. This + * is useful for preventing intermediate network devices from dropping + * connections. + * + * Default: 30 seconds + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] interval_secs Use 0 to disable heartbeat messages + */ +CASS_EXPORT void +cass_cluster_set_connection_heartbeat_interval(CassCluster* cluster, + unsigned interval_secs); + +/** + * Sets the amount of time a connection is allowed to be without a successful + * heartbeat response before being terminated and scheduled for reconnection. + * + * Default: 60 seconds + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] timeout_secs + */ +CASS_EXPORT void +cass_cluster_set_connection_idle_timeout(CassCluster* cluster, + unsigned timeout_secs); + +/** + * Sets the retry policy used for all requests unless overridden by setting + * a retry policy on a statement or a batch. + * + * Default: The same policy as would be created by the function: + * cass_retry_policy_default_new(). This policy will retry on a read timeout + * if there was enough replicas, but no data present, on a write timeout if a + * logged batch request failed to write the batch log, and on a unavailable + * error it retries using a new host. In all other cases the default policy + * will return an error. + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] retry_policy + * + * @see cass_retry_policy_default_new() + * @see cass_statement_set_retry_policy() + * @see cass_batch_set_retry_policy() + */ +CASS_EXPORT void +cass_cluster_set_retry_policy(CassCluster* cluster, + CassRetryPolicy* retry_policy); + +/** + * Enable/Disable retrieving and updating schema metadata. If disabled + * this is allows the driver to skip over retrieving and updating schema + * metadata and cass_session_get_schema_meta() will always return an empty object. + * This can be useful for reducing the startup overhead of short-lived sessions. + * + * Default: cass_true (enabled). + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] enabled + * + * @see cass_session_get_schema_meta() + */ +CASS_EXPORT void +cass_cluster_set_use_schema(CassCluster* cluster, + cass_bool_t enabled); + +/** + * Enable/Disable retrieving hostnames for IP addresses using reverse IP lookup. + * + * @deprecated Do not use. Using reverse DNS lookup to verify the certificate + * does not protect against man-in-the-middle attacks. + * + * Default: cass_false (disabled). + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] enabled + * @return CASS_OK if successful, otherwise an error occurred + * + * @see cass_cluster_set_resolve_timeout() + */ +CASS_EXPORT CASS_DEPRECATED(CassError +cass_cluster_set_use_hostname_resolution(CassCluster* cluster, + cass_bool_t enabled)); + +/** + * Enable/Disable the randomization of the contact points list. + * + * Default: cass_true (enabled). + * + * Important: This setting should only be disabled for debugging or + * tests. + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] enabled + * @return CASS_OK if successful, otherwise an error occurred + */ +CASS_EXPORT CassError +cass_cluster_set_use_randomized_contact_points(CassCluster* cluster, + cass_bool_t enabled); + +/** + * Enable constant speculative executions with the supplied settings. + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] constant_delay_ms + * @param[in] max_speculative_executions + * @return CASS_OK if successful, otherwise an error occurred + */ +CASS_EXPORT CassError +cass_cluster_set_constant_speculative_execution_policy(CassCluster* cluster, + cass_int64_t constant_delay_ms, + int max_speculative_executions); + +/** + * Disable speculative executions + * + * Default: This is the default speculative execution policy. + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @return CASS_OK if successful, otherwise an error occurred + */ +CASS_EXPORT CassError +cass_cluster_set_no_speculative_execution_policy(CassCluster* cluster); + +/** + * Sets the maximum number of "pending write" objects that will be + * saved for re-use for marshalling new requests. These objects may + * hold on to a significant amount of memory and reducing the + * number of these objects may reduce memory usage of the application. + * + * The cost of reducing the value of this setting is potentially slower + * marshalling of requests prior to sending. + * + * Default: Max unsigned integer value + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] num_objects + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_cluster_set_max_reusable_write_objects(CassCluster* cluster, + unsigned num_objects); + +/** + * Associates a named execution profile which can be utilized during execution. + * + * Note: Once the execution profile is added to a cluster, it is + * immutable and any changes made to the execution profile must be re-assigned + * to the cluster before a session connection is established in order for those + * settings to be utilized during query execution. + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] name + * @param[in] profile + * @return CASS_OK if successful, otherwise an error occurred + * + * @see cass_batch_set_execution_profile() + * @see cass_statement_set_execution_profile() + */ +CASS_EXPORT CassError +cass_cluster_set_execution_profile(CassCluster* cluster, + const char* name, + CassExecProfile* profile); + +/** + * Same as cass_cluster_add_execution_profile(), but with lengths for string + * parameters. + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] name + * @param[in] name_length + * @param[in] profile + * @return same as cass_cluster_set_execution_profile() + * + * @see cass_batch_set_execution_profile() + * @see cass_statement_set_execution_profile() + */ +CASS_EXPORT CassError +cass_cluster_set_execution_profile_n(CassCluster* cluster, + const char* name, + size_t name_length, + CassExecProfile* profile); + +/** + * Prepare statements on all available hosts. + * + * Default: cass_true + * + * @public @memberof CassCluster + * + * @param cluster + * @param enabled + * @return CASS_OK if successful, otherwise an error occurred + */ +CASS_EXPORT CassError +cass_cluster_set_prepare_on_all_hosts(CassCluster* cluster, + cass_bool_t enabled); + +/** + * Enable pre-preparing cached prepared statements when existing hosts become + * available again or when new hosts are added to the cluster. + * + * This can help mitigate request latency when executing prepared statements + * by avoiding an extra round trip in cases where the statement is + * unprepared on a freshly started server. The main tradeoff is extra background + * network traffic is required to prepare the statements on hosts as they become + * available. + * + * Default: cass_true + * + * @param cluster + * @param enabled + * @return CASS_OK if successful, otherwise an error occurred + */ +CASS_EXPORT CassError +cass_cluster_set_prepare_on_up_or_add_host(CassCluster* cluster, + cass_bool_t enabled); + +/** + * Enable the NO_COMPACT startup option. + * + * This can help facilitate uninterrupted cluster upgrades where tables using + * COMPACT_STORAGE will operate in "compatibility mode" for + * BATCH, DELETE, SELECT, and UPDATE CQL operations. + * + * Default: cass_false + * + * @cassandra{3.0.16+} + * @cassandra{3.11.2+} + * @cassandra{4.0+} + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] enabled + */ +CASS_EXPORT CassError +cass_cluster_set_no_compact(CassCluster* cluster, + cass_bool_t enabled); + +/** + * Sets a callback for handling host state changes in the cluster. + * + * Note: The callback is invoked only when state changes in the cluster + * are applicable to the configured load balancing policy(s). + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] callback + * @param[in] data + * @return CASS_OK if successful, otherwise and error occurred + */ +CASS_EXPORT CassError +cass_cluster_set_host_listener_callback(CassCluster* cluster, + CassHostListenerCallback callback, + void* data); + +/** + * Sets the secure connection bundle path for processing DBaaS credentials. + * + * This will pre-configure a cluster using the credentials format provided by + * the DBaaS cloud provider. + * + * @param[in] cluster + * @param[in] path Absolute path to DBaaS credentials file. + * @return CASS_OK if successful, otherwise error occured. + */ +CASS_EXPORT CassError +cass_cluster_set_cloud_secure_connection_bundle(CassCluster* cluster, + const char* path); + +/** + * Same as cass_cluster_set_cloud_secure_connection_bundle(), but with lengths + * for string parameters. + * + * @see cass_cluster_set_cloud_secure_connection_bundle() + * + * @param[in] cluster + * @param[in] path Absolute path to DBaaS credentials file. + * @param[in] path_length Length of path variable. + * @return CASS_OK if successful, otherwise error occured. + */ +CASS_EXPORT CassError +cass_cluster_set_cloud_secure_connection_bundle_n(CassCluster* cluster, + const char* path, + size_t path_length); + +/** + * Same as cass_cluster_set_cloud_secure_connection_bundle(), but it does not + * initialize the underlying SSL library implementation. The SSL library still + * needs to be initialized, but it's up to the client application to handle + * initialization. This is similar to the function cass_ssl_new_no_lib_init(), + * and its documentation should be used as a reference to properly initialize + * the underlying SSL library. + * + * @see cass_ssl_new_no_lib_init() + * @see cass_cluster_set_cloud_secure_connection_bundle() + * + * @param[in] cluster + * @param[in] path Absolute path to DBaaS credentials file. + * @return CASS_OK if successful, otherwise error occured. + */ +CASS_EXPORT CassError +cass_cluster_set_cloud_secure_connection_bundle_no_ssl_lib_init(CassCluster* cluster, + const char* path); + +/** + * Same as cass_cluster_set_cloud_secure_connection_bundle_no_ssl_lib_init(), + * but with lengths for string parameters. + * + * @see cass_cluster_set_cloud_secure_connection_bundle_no_ssl_lib_init() + * + * @param[in] cluster + * @param[in] path Absolute path to DBaaS credentials file. + * @param[in] path_length Length of path variable. + * @return CASS_OK if successful, otherwise error occured. + */ +CASS_EXPORT CassError +cass_cluster_set_cloud_secure_connection_bundle_no_ssl_lib_init_n(CassCluster* cluster, + const char* path, + size_t path_length); + +/** + * Set the application name. + * + * This is optional; however it provides the server with the application name + * that can aid in debugging issues with larger clusters where there are a lot + * of client (or application) connections. + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] application_name + */ +CASS_EXPORT void +cass_cluster_set_application_name(CassCluster* cluster, + const char* application_name); + +/** + * Same as cass_cluster_set_application_name(), but with lengths for string + * parameters. + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] application_name + * @param[in] application_name_length + */ +CASS_EXPORT void +cass_cluster_set_application_name_n(CassCluster* cluster, + const char* application_name, + size_t application_name_length); + +/** + * Set the application version. + * + * This is optional; however it provides the server with the application + * version that can aid in debugging issues with large clusters where there are + * a lot of client (or application) connections that may have different + * versions in use. + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] application_version + */ + +CASS_EXPORT void +cass_cluster_set_application_version(CassCluster* cluster, + const char* application_version); + +/** + * Same as cass_cluster_set_application_version(), but with lengths for string + * parameters. + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] application_version + * @param[in] application_version_length + */ +CASS_EXPORT void +cass_cluster_set_application_version_n(CassCluster* cluster, + const char* application_version, + size_t application_version_length); + +/** + * Set the client id. + * + * This is optional; however it provides the server with the client ID that can + * aid in debugging issues with large clusters where there are a lot of client + * connections. + * + * Default: UUID v4 generated (@see cass_session_get_client_id()) + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] client_id + */ +CASS_EXPORT void +cass_cluster_set_client_id(CassCluster* cluster, CassUuid client_id); + +/** + * Sets the amount of time between monitor reporting event messages. + * + * Default: 300 seconds. + * + * @public @memberof CassCluster + * + * @param[in] cluster + * @param[in] interval_secs Use 0 to disable monitor reporting event messages. + */ +CASS_EXPORT void +cass_cluster_set_monitor_reporting_interval(CassCluster* cluster, + unsigned interval_secs); + +/** + * Sets the amount of time after which metric histograms should be refreshed. + * Upon refresh histograms are reset to zero, effectively dropping any history to + * that point. Refresh occurs when a snapshot is requested so ths value should + * be thought of as a minimum time to refresh. + * + * If refresh is not enabled the driver will continue to accumulate histogram + * data over the life of a session; this is the default behaviour and replicates + * the behaviour of previous versions. + * + * Note that the specified interval must be > 0 otherwise CASS_ERROR_LIB_BAD_PARAMS + * will be returned. + * + * @public @memberof CassCluster + * + * @param cluster + * @param refresh_interval Minimum interval (in milliseconds) for refresh interval + */ +CASS_EXPORT CassError +cass_cluster_set_histogram_refresh_interval(CassCluster* cluster, + unsigned refresh_interval); + +/*********************************************************************************** + * + * Session + * + ***********************************************************************************/ + +/** + * Creates a new session. + * + * @public @memberof CassSession + * + * @return Returns a session that must be freed. + * + * @see cass_session_free() + */ +CASS_EXPORT CassSession* +cass_session_new(); + +/** + * Frees a session instance. If the session is still connected it will be synchronously + * closed before being deallocated. + * + * Important: Do not free a session in a future callback. Freeing a session in a future + * callback will cause a deadlock. + * + * @public @memberof CassSession + * + * @param[in] session + */ +CASS_EXPORT void +cass_session_free(CassSession* session); + +/** + * Connects a session. + * + * @public @memberof CassSession + * + * @param[in] session + * @param[in] cluster The cluster configuration is copied into the session and + * is immutable after connection. + * @return A future that must be freed. + * + * @see cass_session_close() + */ +CASS_EXPORT CassFuture* +cass_session_connect(CassSession* session, + const CassCluster* cluster); + +/** + * Connects a session and sets the keyspace. + * + * @public @memberof CassSession + * + * @param[in] session + * @param[in] cluster The cluster configuration is copied into the session and + * is immutable after connection. + * @param[in] keyspace + * @return A future that must be freed. + * + * @see cass_session_close() + */ +CASS_EXPORT CassFuture* +cass_session_connect_keyspace(CassSession* session, + const CassCluster* cluster, + const char* keyspace); + +/** + * Same as cass_session_connect_keyspace(), but with lengths for string + * parameters. + * + * @public @memberof CassSession + * + * @param[in] session + * @param[in] cluster + * @param[in] keyspace + * @param[in] keyspace_length + * @return same as cass_session_connect_keyspace() + * + * @see cass_session_connect_keyspace() + */ +CASS_EXPORT CassFuture* +cass_session_connect_keyspace_n(CassSession* session, + const CassCluster* cluster, + const char* keyspace, + size_t keyspace_length); + +/** + * Closes the session instance, outputs a close future which can + * be used to determine when the session has been terminated. This allows + * in-flight requests to finish. + * + * @public @memberof CassSession + * + * @param[in] session + * @return A future that must be freed. + */ +CASS_EXPORT CassFuture* +cass_session_close(CassSession* session); + +/** + * Create a prepared statement. + * + * @public @memberof CassSession + * + * @param[in] session + * @param[in] query The query is copied into the statement object; the + * memory pointed to by this parameter can be freed after this call. + * @return A future that must be freed. + * + * @see cass_future_get_prepared() + */ +CASS_EXPORT CassFuture* +cass_session_prepare(CassSession* session, + const char* query); + +/** + * Same as cass_session_prepare(), but with lengths for string + * parameters. + * + * @public @memberof CassSession + * + * @param[in] session + * @param[in] query + * @param[in] query_length + * @return same as cass_session_prepare() + * + * @see cass_session_prepare() + */ +CASS_EXPORT CassFuture* +cass_session_prepare_n(CassSession* session, + const char* query, + size_t query_length); + +/** + * Create a prepared statement from an existing statement. + * + * Note: Bound statements will inherit the keyspace, consistency, + * serial consistency, request timeout and retry policy of the existing + * statement. + * + * @public @memberof CassSession + * + * @param[in] session + * @param[in] statement + * @return A future that must be freed. + * + * @see cass_future_get_prepared() + */ +CASS_EXPORT CassFuture* +cass_session_prepare_from_existing(CassSession* session, + CassStatement* statement); + +/** + * Execute a query or bound statement. + * + * @public @memberof CassSession + * + * @param[in] session + * @param[in] statement + * @return A future that must be freed. + * + * @see cass_future_get_result() + */ +CASS_EXPORT CassFuture* +cass_session_execute(CassSession* session, + const CassStatement* statement); + +/** + * Execute a batch statement. + * + * @cassandra{2.0+} + * + * @public @memberof CassSession + * + * @param[in] session + * @param[in] batch + * @return A future that must be freed. + * + * @see cass_future_get_result() + */ +CASS_EXPORT CassFuture* +cass_session_execute_batch(CassSession* session, + const CassBatch* batch); + +/** + * Gets a snapshot of this session's schema metadata. The returned + * snapshot of the schema metadata is not updated. This function + * must be called again to retrieve any schema changes since the + * previous call. + * + * @public @memberof CassSession + * + * @param[in] session + * @return A schema instance that must be freed. + * + * @see cass_schema_meta_free() + */ +CASS_EXPORT const CassSchemaMeta* +cass_session_get_schema_meta(const CassSession* session); + +/** + * Gets a copy of this session's performance/diagnostic metrics. + * + * @public @memberof CassSession + * + * @param[in] session + * @param[out] output + */ +CASS_EXPORT void +cass_session_get_metrics(const CassSession* session, + CassMetrics* output); + +/** + * Gets a copy of this session's speculative execution metrics. + * + * @public @memberof CassSession + * + * @param[in] session + * @param[out] output + */ +CASS_EXPORT void +cass_session_get_speculative_execution_metrics(const CassSession* session, + CassSpeculativeExecutionMetrics* output); + +/** + * Get the client id. + * + * @public @memberof CassSession + * + * @param[in] session + * @return Client id. + */ +CASS_EXPORT CassUuid +cass_session_get_client_id(CassSession* session); + +/*********************************************************************************** + * + * Schema Metadata + * + ***********************************************************************************/ + +/** + * Frees a schema metadata instance. + * + * @public @memberof CassSchemaMeta + * + * @param[in] schema_meta + */ +CASS_EXPORT void +cass_schema_meta_free(const CassSchemaMeta* schema_meta); + +/** + * Gets the version of the schema metadata snapshot. + * + * @public @memberof CassSchemaMeta + * + * @param[in] schema_meta + * + * @return The snapshot version. + */ +CASS_EXPORT cass_uint32_t +cass_schema_meta_snapshot_version(const CassSchemaMeta* schema_meta); + +/** + * Gets the version of the connected Cassandra cluster. + * + * @public @memberof CassSchemaMeta + * + * @param[in] schema_meta + * + * @return Cassandra's version + */ +CASS_EXPORT CassVersion +cass_schema_meta_version(const CassSchemaMeta* schema_meta); + +/** + * Gets the keyspace metadata for the provided keyspace name. + * + * @public @memberof CassSchemaMeta + * + * @param[in] schema_meta + * @param[in] keyspace + * + * @return The metadata for a keyspace. NULL if keyspace does not exist. + */ +CASS_EXPORT const CassKeyspaceMeta* +cass_schema_meta_keyspace_by_name(const CassSchemaMeta* schema_meta, + const char* keyspace); + +/** + * Same as cass_schema_meta_keyspace_by_name(), but with lengths for string + * parameters. + * + * @public @memberof CassSchemaMeta + * + * @param[in] schema_meta + * @param[in] keyspace + * @param[in] keyspace_length + * @return same as cass_schema_meta_keyspace_by_name() + * + * @see cass_schema_meta_keyspace_by_name() + */ +CASS_EXPORT const CassKeyspaceMeta* +cass_schema_meta_keyspace_by_name_n(const CassSchemaMeta* schema_meta, + const char* keyspace, + size_t keyspace_length); + +/** + * Gets the name of the keyspace. + * + * @public @memberof CassKeyspaceMeta + * + * @param[in] keyspace_meta + * @param[out] name + * @param[out] name_length + */ +CASS_EXPORT void +cass_keyspace_meta_name(const CassKeyspaceMeta* keyspace_meta, + const char** name, + size_t* name_length); + + +/** + * Determine if the keyspace is a virtual keyspace. + * + * @public @memberof CassKeyspaceMeta + * + * @param[in] keyspace_meta + * @return cass_true is the keyspace is virtual, otherwise cass_false + */ +CASS_EXPORT cass_bool_t +cass_keyspace_meta_is_virtual(const CassKeyspaceMeta* keyspace_meta); + +/** + * Gets the table metadata for the provided table name. + * + * @public @memberof CassKeyspaceMeta + * + * @param[in] keyspace_meta + * @param[in] table + * + * @return The metadata for a table. NULL if table does not exist. + */ +CASS_EXPORT const CassTableMeta* +cass_keyspace_meta_table_by_name(const CassKeyspaceMeta* keyspace_meta, + const char* table); + +/** + * Same as cass_keyspace_meta_table_by_name(), but with lengths for string + * parameters. + * + * @public @memberof CassKeyspaceMeta + * + * @param[in] keyspace_meta + * @param[in] table + * @param[in] table_length + * @return same as cass_keyspace_meta_table_by_name() + * + * @see cass_keyspace_meta_table_by_name() + */ +CASS_EXPORT const CassTableMeta* +cass_keyspace_meta_table_by_name_n(const CassKeyspaceMeta* keyspace_meta, + const char* table, + size_t table_length); + +/** + * Gets the materialized view metadata for the provided view name. + * + * @cassandra{3.0+} + * + * @public @memberof CassKeyspaceMeta + * + * @param[in] keyspace_meta + * @param[in] view + * + * @return The metadata for a view. NULL if view does not exist. + */ +CASS_EXPORT const CassMaterializedViewMeta* +cass_keyspace_meta_materialized_view_by_name(const CassKeyspaceMeta* keyspace_meta, + const char* view); + +/** + * Same as cass_keyspace_meta_materialized_view_by_name(), but with lengths for string + * parameters. + * + * @cassandra{3.0+} + * + * @public @memberof CassKeyspaceMeta + * + * @param[in] keyspace_meta + * @param[in] view + * @param[in] view_length + * @return same as cass_keyspace_meta_materialized_view_by_name() + * + * @see cass_keyspace_meta_materialized_view_by_name() + */ +CASS_EXPORT const CassMaterializedViewMeta* +cass_keyspace_meta_materialized_view_by_name_n(const CassKeyspaceMeta* keyspace_meta, + const char* view, + size_t view_length); + +/** + * Gets the data type for the provided type name. + * + * @cassandra{2.1+} + * + * @public @memberof CassKeyspaceMeta + * + * @param[in] keyspace_meta + * @param[in] type + * + * @return The data type for a user defined type. NULL if type does not exist. + */ +CASS_EXPORT const CassDataType* +cass_keyspace_meta_user_type_by_name(const CassKeyspaceMeta* keyspace_meta, + const char* type); + +/** + * Same as cass_keyspace_meta_type_by_name(), but with lengths for string + * parameters. + * + * @cassandra{2.1+} + * + * @public @memberof CassKeyspaceMeta + * + * @param[in] keyspace_meta + * @param[in] type + * @param[in] type_length + * @return same as cass_keyspace_meta_type_by_name() + * + * @see cass_keyspace_meta_type_by_name() + */ +CASS_EXPORT const CassDataType* +cass_keyspace_meta_user_type_by_name_n(const CassKeyspaceMeta* keyspace_meta, + const char* type, + size_t type_length); + +/** + * Gets the function metadata for the provided function name. + * + * @cassandra{2.2+} + * + * @public @memberof CassKeyspaceMeta + * + * @param[in] keyspace_meta + * @param[in] name + * @param[in] arguments A comma delimited list of CQL types (e.g "text,int,...") + * describing the function's signature. + * + * @return The data function for a user defined function. NULL if function does not exist. + */ +CASS_EXPORT const CassFunctionMeta* +cass_keyspace_meta_function_by_name(const CassKeyspaceMeta* keyspace_meta, + const char* name, + const char* arguments); + +/** + * Same as cass_keyspace_meta_function_by_name(), but with lengths for string + * parameters. + * + * @cassandra{2.2+} + * + * @public @memberof CassKeyspaceMeta + * + * @param[in] keyspace_meta + * @param[in] name + * @param[in] name_length + * @param[in] arguments + * @param[in] arguments_length + * @return same as cass_keyspace_meta_function_by_name() + * + * @see cass_keyspace_meta_function_by_name() + */ +CASS_EXPORT const CassFunctionMeta* +cass_keyspace_meta_function_by_name_n(const CassKeyspaceMeta* keyspace_meta, + const char* name, + size_t name_length, + const char* arguments, + size_t arguments_length); + +/** + * Gets the aggregate metadata for the provided aggregate name. + * + * @cassandra{2.2+} + * + * @public @memberof CassKeyspaceMeta + * + * @param[in] keyspace_meta + * @param[in] name + * @param[in] arguments A comma delimited list of CQL types (e.g "text,int,...") + * describing the aggregate's signature. + * + * @return The data aggregate for a user defined aggregate. NULL if aggregate does not exist. + */ +CASS_EXPORT const CassAggregateMeta* +cass_keyspace_meta_aggregate_by_name(const CassKeyspaceMeta* keyspace_meta, + const char* name, + const char* arguments); + +/** + * Same as cass_keyspace_meta_aggregate_by_name(), but with lengths for string + * parameters. + * + * @cassandra{2.2+} + * + * @public @memberof CassKeyspaceMeta + * + * @param[in] keyspace_meta + * @param[in] name + * @param[in] name_length + * @param[in] arguments + * @param[in] arguments_length + * @return same as cass_keyspace_meta_aggregate_by_name() + * + * @see cass_keyspace_meta_aggregate_by_name() + */ +CASS_EXPORT const CassAggregateMeta* +cass_keyspace_meta_aggregate_by_name_n(const CassKeyspaceMeta* keyspace_meta, + const char* name, + size_t name_length, + const char* arguments, + size_t arguments_length); + +/** + * Gets a metadata field for the provided name. Metadata fields allow direct + * access to the column data found in the underlying "keyspaces" metadata table. + * + * @public @memberof CassKeyspaceMeta + * + * @param[in] keyspace_meta + * @param[in] name + * @return A metadata field value. NULL if the field does not exist. + */ +CASS_EXPORT const CassValue* +cass_keyspace_meta_field_by_name(const CassKeyspaceMeta* keyspace_meta, + const char* name); + +/** + * Same as cass_keyspace_meta_field_by_name(), but with lengths for string + * parameters. + * + * @public @memberof CassKeyspaceMeta + * + * @param[in] keyspace_meta + * @param[in] name + * @param[in] name_length + * @return same as cass_keyspace_meta_field_by_name() + * + * @see cass_keyspace_meta_field_by_name() + */ +CASS_EXPORT const CassValue* +cass_keyspace_meta_field_by_name_n(const CassKeyspaceMeta* keyspace_meta, + const char* name, + size_t name_length); + +/** + * Gets the name of the table. + * + * @public @memberof CassTableMeta + * + * @param[in] table_meta + * @param[out] name + * @param[out] name_length + */ +CASS_EXPORT void +cass_table_meta_name(const CassTableMeta* table_meta, + const char** name, + size_t* name_length); + +/** + * Determine if the table is a virtual table. + * + * @public @memberof CassTableMeta + * + * @param[in] table_meta + * @return cass_true is the table is virtual, otherwise cass_false + */ +CASS_EXPORT cass_bool_t +cass_table_meta_is_virtual(const CassTableMeta* table_meta); + +/** + * Gets the column metadata for the provided column name. + * + * @public @memberof CassTableMeta + * + * @param[in] table_meta + * @param[in] column + * + * @return The metadata for a column. NULL if column does not exist. + */ +CASS_EXPORT const CassColumnMeta* +cass_table_meta_column_by_name(const CassTableMeta* table_meta, + const char* column); + +/** + * Same as cass_table_meta_column_by_name(), but with lengths for string + * parameters. + * + * @public @memberof CassTableMeta + * + * @param[in] table_meta + * @param[in] column + * @param[in] column_length + * @return same as cass_table_meta_column_by_name() + * + * @see cass_table_meta_column_by_name() + */ +CASS_EXPORT const CassColumnMeta* +cass_table_meta_column_by_name_n(const CassTableMeta* table_meta, + const char* column, + size_t column_length); + +/** + * Gets the total number of columns for the table. + * + * @public @memberof CassTableMeta + * + * @param[in] table_meta + * @return The total column count. + */ +CASS_EXPORT size_t +cass_table_meta_column_count(const CassTableMeta* table_meta); + +/** + * Gets the column metadata for the provided index. + * + * @public @memberof CassTableMeta + * + * @param[in] table_meta + * @param[in] index + * @return The metadata for a column. NULL returned if the index is out of range. + */ +CASS_EXPORT const CassColumnMeta* +cass_table_meta_column(const CassTableMeta* table_meta, + size_t index); + +/** + * Gets the index metadata for the provided index name. + * + * @public @memberof CassTableMeta + * + * @param[in] table_meta + * @param[in] index + * + * @return The metadata for a index. NULL if index does not exist. + */ +CASS_EXPORT const CassIndexMeta* +cass_table_meta_index_by_name(const CassTableMeta* table_meta, + const char* index); + +/** + * Same as cass_table_meta_index_by_name(), but with lengths for string + * parameters. + * + * @public @memberof CassTableMeta + * + * @param[in] table_meta + * @param[in] index + * @param[in] index_length + * @return same as cass_table_meta_index_by_name() + * + * @see cass_table_meta_index_by_name() + */ +CASS_EXPORT const CassIndexMeta* +cass_table_meta_index_by_name_n(const CassTableMeta* table_meta, + const char* index, + size_t index_length); + +/** + * Gets the total number of indexes for the table. + * + * @public @memberof CassTableMeta + * + * @param[in] table_meta + * @return The total index count. + */ +CASS_EXPORT size_t +cass_table_meta_index_count(const CassTableMeta* table_meta); + +/** + * Gets the index metadata for the provided index. + * + * @public @memberof CassTableMeta + * + * @param[in] table_meta + * @param[in] index + * @return The metadata for a index. NULL returned if the index is out of range. + */ +CASS_EXPORT const CassIndexMeta* +cass_table_meta_index(const CassTableMeta* table_meta, + size_t index); + +/** + * Gets the materialized view metadata for the provided view name. + * + * @cassandra{3.0+} + * + * @public @memberof CassTableMeta + * + * @param[in] table_meta + * @param[in] view + * + * @return The metadata for a view. NULL if view does not exist. + */ +CASS_EXPORT const CassMaterializedViewMeta* +cass_table_meta_materialized_view_by_name(const CassTableMeta* table_meta, + const char* view); + +/** + * Same as cass_table_meta_materialized_view_by_name(), but with lengths for string + * parameters. + * + * @cassandra{3.0+} + * + * @public @memberof CassTableMeta + * + * @param[in] table_meta + * @param[in] view + * @param[in] view_length + * @return same as cass_table_meta_materialized_view_by_name() + * + * @see cass_table_meta_materialized_view_by_name() + */ +CASS_EXPORT const CassMaterializedViewMeta* +cass_table_meta_materialized_view_by_name_n(const CassTableMeta* table_meta, + const char* view, + size_t view_length); + +/** + * Gets the total number of views for the table. + * + * @cassandra{3.0+} + * + * @public @memberof CassTableMeta + * + * @param[in] table_meta + * @return The total view count. + */ +CASS_EXPORT size_t +cass_table_meta_materialized_view_count(const CassTableMeta* table_meta); + +/** + * Gets the materialized view metadata for the provided index. + * + * @cassandra{3.0+} + * + * @public @memberof CassTableMeta + * + * @param[in] table_meta + * @param[in] index + * @return The metadata for a view. NULL returned if the index is out of range. + */ +CASS_EXPORT const CassMaterializedViewMeta* +cass_table_meta_materialized_view(const CassTableMeta* table_meta, + size_t index); + +/** + * Gets the number of columns for the table's partition key. + * + * @public @memberof CassTableMeta + * + * @param[in] table_meta + * @return The count for the number of columns in the partition key. + */ +CASS_EXPORT size_t +cass_table_meta_partition_key_count(const CassTableMeta* table_meta); + +/** + * Gets the partition key column metadata for the provided index. + * + * @public @memberof CassTableMeta + * + * @param[in] table_meta + * @param[in] index + * @return The metadata for a column. NULL returned if the index is out of range. + * + * @see cass_table_meta_partition_key_count() + */ +CASS_EXPORT const CassColumnMeta* +cass_table_meta_partition_key(const CassTableMeta* table_meta, + size_t index); + +/** + * Gets the number of columns for the table's clustering key. + * + * @public @memberof CassTableMeta + * + * @param[in] table_meta + * @return The count for the number of columns in the clustering key. + */ +CASS_EXPORT size_t +cass_table_meta_clustering_key_count(const CassTableMeta* table_meta); + +/** + * Gets the clustering key column metadata for the provided index. + * + * @public @memberof CassTableMeta + * + * @param[in] table_meta + * @param[in] index + * @return The metadata for a column. NULL returned if the index is out of range. + * + * @see cass_table_meta_clustering_key_count() + */ +CASS_EXPORT const CassColumnMeta* +cass_table_meta_clustering_key(const CassTableMeta* table_meta, + size_t index); + +/** + * Gets the clustering order column metadata for the provided index. + * + * @public @memberof CassTableMeta + * + * @param[in] table_meta + * @param[in] index + * @return The clustering order for a column. + * CASS_CLUSTERING_ORDER_NONE returned if the index is out of range. + * + * @see cass_table_meta_clustering_key_count() + */ +CASS_EXPORT CassClusteringOrder +cass_table_meta_clustering_key_order(const CassTableMeta* table_meta, + size_t index); + +/** + * Gets a metadata field for the provided name. Metadata fields allow direct + * access to the column data found in the underlying "tables" metadata table. + * + * @public @memberof CassTableMeta + * + * @param[in] table_meta + * @param[in] name + * @return A metadata field value. NULL if the field does not exist. + */ +CASS_EXPORT const CassValue* +cass_table_meta_field_by_name(const CassTableMeta* table_meta, + const char* name); + +/** + * Same as cass_table_meta_field_by_name(), but with lengths for string + * parameters. + * + * @public @memberof CassTableMeta + * + * @param[in] table_meta + * @param[in] name + * @param[in] name_length + * @return same as cass_table_meta_field_by_name() + * + * @see cass_table_meta_field_by_name() + */ +CASS_EXPORT const CassValue* +cass_table_meta_field_by_name_n(const CassTableMeta* table_meta, + const char* name, + size_t name_length); + +/** + * Gets the column metadata for the provided column name. + * + * @cassandra{3.0+} + * + * @public @memberof CassMaterializedViewMeta + * + * @param[in] view_meta + * @param[in] column + * + * @return The metadata for a column. NULL if column does not exist. + */ +CASS_EXPORT const CassColumnMeta* +cass_materialized_view_meta_column_by_name(const CassMaterializedViewMeta* view_meta, + const char* column); + +/** + * Same as cass_materialized_view_meta_column_by_name(), but with lengths for string + * parameters. + * + * @cassandra{3.0+} + * + * @public @memberof CassMaterializedViewMeta + * + * @param[in] view_meta + * @param[in] column + * @param[in] column_length + * @return same as cass_materialized_view_meta_column_by_name() + * + * @see cass_materialized_view_meta_column_by_name() + */ +CASS_EXPORT const CassColumnMeta* +cass_materialized_view_meta_column_by_name_n(const CassMaterializedViewMeta* view_meta, + const char* column, + size_t column_length); + +/** + * Gets the name of the view. + * + * @cassandra{3.0+} + * + * @public @memberof CassMaterializedViewMeta + * + * @param[in] view_meta + * @param[out] name + * @param[out] name_length + */ +CASS_EXPORT void +cass_materialized_view_meta_name(const CassMaterializedViewMeta* view_meta, + const char** name, + size_t* name_length); + +/** + * Gets the base table of the view. + * + * @cassandra{3.0+} + * + * @public @memberof CassMaterializedViewMeta + * + * @param[in] view_meta + * + * @return The base table for the view. + */ +CASS_EXPORT const CassTableMeta* +cass_materialized_view_meta_base_table(const CassMaterializedViewMeta* view_meta); + +/** + * Gets the total number of columns for the view. + * + * @cassandra{3.0+} + * + * @public @memberof CassMaterializedViewMeta + * + * @param[in] view_meta + * @return The total column count. + */ +CASS_EXPORT size_t +cass_materialized_view_meta_column_count(const CassMaterializedViewMeta* view_meta); + +/** + * Gets the column metadata for the provided index. + * + * @cassandra{3.0+} + * + * @public @memberof CassMaterializedViewMeta + * + * @param[in] view_meta + * @param[in] index + * @return The metadata for a column. NULL returned if the index is out of range. + */ +CASS_EXPORT const CassColumnMeta* +cass_materialized_view_meta_column(const CassMaterializedViewMeta* view_meta, + size_t index); + +/** + * Gets the number of columns for the view's partition key. + * + * @cassandra{3.0+} + * + * @public @memberof CassMaterializedViewMeta + * + * @param[in] view_meta + * @return The count for the number of columns in the partition key. + */ +CASS_EXPORT size_t +cass_materialized_view_meta_partition_key_count(const CassMaterializedViewMeta* view_meta); + +/** + * Gets the partition key column metadata for the provided index. + * + * @cassandra{3.0+} + * + * @public @memberof CassMaterializedViewMeta + * + * @param[in] view_meta + * @param[in] index + * @return The metadata for a column. NULL returned if the index is out of range. + */ +CASS_EXPORT const CassColumnMeta* +cass_materialized_view_meta_partition_key(const CassMaterializedViewMeta* view_meta, + size_t index); + +/** + * Gets the number of columns for the view's clustering key. + * + * @cassandra{3.0+} + * + * @public @memberof CassMaterializedViewMeta + * + * @param[in] view_meta + * @return The count for the number of columns in the clustering key. + */ +CASS_EXPORT size_t +cass_materialized_view_meta_clustering_key_count(const CassMaterializedViewMeta* view_meta); + +/** + * Gets the clustering key column metadata for the provided index. + * + * @cassandra{3.0+} + * + * @public @memberof CassMaterializedViewMeta + * + * @param[in] view_meta + * @param[in] index + * @return The metadata for a column. NULL returned if the index is out of range. + */ +CASS_EXPORT const CassColumnMeta* +cass_materialized_view_meta_clustering_key(const CassMaterializedViewMeta* view_meta, + size_t index); + +/** + * Gets the clustering order column metadata for the provided index. + * + * @public @memberof CassMaterializedViewMeta + * + * @param[in] view_meta + * @param[in] index + * @return The clustering order for a column. + * CASS_CLUSTERING_ORDER_NONE returned if the index is out of range. + * + * @see cass_materialized_view_meta_clustering_key_count() + */ +CASS_EXPORT CassClusteringOrder +cass_materialized_view_meta_clustering_key_order(const CassMaterializedViewMeta* view_meta, + size_t index); + +/** + * Gets a metadata field for the provided name. Metadata fields allow direct + * access to the column data found in the underlying "views" metadata view. + * + * @cassandra{3.0+} + * + * @public @memberof CassMaterializedViewMeta + * + * @param[in] view_meta + * @param[in] name + * @return A metadata field value. NULL if the field does not exist. + */ +CASS_EXPORT const CassValue* +cass_materialized_view_meta_field_by_name(const CassMaterializedViewMeta* view_meta, + const char* name); + +/** + * Same as cass_materialized_view_meta_field_by_name(), but with lengths for string + * parameters. + * + * @cassandra{3.0+} + * + * @public @memberof CassMaterializedViewMeta + * + * @param[in] view_meta + * @param[in] name + * @param[in] name_length + * @return same as cass_materialized_view_meta_field_by_name() + * + * @see cass_materialized_view_meta_field_by_name() + */ +CASS_EXPORT const CassValue* +cass_materialized_view_meta_field_by_name_n(const CassMaterializedViewMeta* view_meta, + const char* name, + size_t name_length); + +/** + * Gets the name of the column. + * + * @public @memberof CassColumnMeta + * + * @param[in] column_meta + * @param[out] name + * @param[out] name_length + */ +CASS_EXPORT void +cass_column_meta_name(const CassColumnMeta* column_meta, + const char** name, + size_t* name_length); + +/** + * Gets the type of the column. + * + * @public @memberof CassColumnMeta + * + * @param[in] column_meta + * @return The column's type. + */ +CASS_EXPORT CassColumnType +cass_column_meta_type(const CassColumnMeta* column_meta); + +/** + * Gets the data type of the column. + * + * @public @memberof CassColumnMeta + * + * @param[in] column_meta + * @return The column's data type. + */ +CASS_EXPORT const CassDataType* +cass_column_meta_data_type(const CassColumnMeta* column_meta); + +/** + * Gets a metadata field for the provided name. Metadata fields allow direct + * access to the column data found in the underlying "columns" metadata table. + * + * @public @memberof CassColumnMeta + * + * @param[in] column_meta + * @param[in] name + * @return A metadata field value. NULL if the field does not exist. + */ +CASS_EXPORT const CassValue* +cass_column_meta_field_by_name(const CassColumnMeta* column_meta, + const char* name); + +/** + * Same as cass_column_meta_field_by_name(), but with lengths for string + * parameters. + * + * @public @memberof CassColumnMeta + * + * @param[in] column_meta + * @param[in] name + * @param[in] name_length + * @return same as cass_column_meta_field_by_name() + * + * @see cass_column_meta_field_by_name() + */ +CASS_EXPORT const CassValue* +cass_column_meta_field_by_name_n(const CassColumnMeta* column_meta, + const char* name, + size_t name_length); + +/** + * Gets the name of the index. + * + * @public @memberof CassIndexMeta + * + * @param[in] index_meta + * @param[out] name + * @param[out] name_length + */ +CASS_EXPORT void +cass_index_meta_name(const CassIndexMeta* index_meta, + const char** name, + size_t* name_length); + +/** + * Gets the type of the index. + * + * @public @memberof CassIndexMeta + * + * @param[in] index_meta + * @return The index's type. + */ +CASS_EXPORT CassIndexType +cass_index_meta_type(const CassIndexMeta* index_meta); + +/** + * Gets the target of the index. + * + * @public @memberof CassIndexMeta + * + * @param[in] index_meta + * @param[out] target + * @param[out] target_length + */ +CASS_EXPORT void +cass_index_meta_target(const CassIndexMeta* index_meta, + const char** target, + size_t* target_length); + +/** + * Gets the options of the index. + * + * @public @memberof CassIndexMeta + * + * @param[in] index_meta + * @return The index's options. + */ +CASS_EXPORT const CassValue* +cass_index_meta_options(const CassIndexMeta* index_meta); + +/** + * Gets a metadata field for the provided name. Metadata fields allow direct + * access to the index data found in the underlying "indexes" metadata table. + * + * @public @memberof CassIndexMeta + * + * @param[in] index_meta + * @param[in] name + * @return A metadata field value. NULL if the field does not exist. + */ +CASS_EXPORT const CassValue* +cass_index_meta_field_by_name(const CassIndexMeta* index_meta, + const char* name); + +/** + * Same as cass_index_meta_field_by_name(), but with lengths for string + * parameters. + * + * @public @memberof CassIndexMeta + * + * @param[in] index_meta + * @param[in] name + * @param[in] name_length + * @return same as cass_index_meta_field_by_name() + * + * @see cass_index_meta_field_by_name() + */ +CASS_EXPORT const CassValue* +cass_index_meta_field_by_name_n(const CassIndexMeta* index_meta, + const char* name, + size_t name_length); + +/** + * Gets the name of the function. + * + * @cassandra{2.2+} + * + * @public @memberof CassFunctionMeta + * + * @param[in] function_meta + * @param[out] name + * @param[out] name_length + */ +CASS_EXPORT void +cass_function_meta_name(const CassFunctionMeta* function_meta, + const char** name, + size_t* name_length); + +/** + * Gets the full name of the function. The full name includes the + * function's name and the function's signature: + * "name(type1 type2.. typeN)". + * + * @cassandra{2.2+} + * + * @public @memberof CassFunctionMeta + * + * @param[in] function_meta + * @param[out] full_name + * @param[out] full_name_length + */ +CASS_EXPORT void +cass_function_meta_full_name(const CassFunctionMeta* function_meta, + const char** full_name, + size_t* full_name_length); + +/** + * Gets the body of the function. + * + * @cassandra{2.2+} + * + * @public @memberof CassFunctionMeta + * + * @param[in] function_meta + * @param[out] body + * @param[out] body_length + */ +CASS_EXPORT void +cass_function_meta_body(const CassFunctionMeta* function_meta, + const char** body, + size_t* body_length); + +/** + * Gets the language of the function. + * + * @cassandra{2.2+} + * + * @public @memberof CassFunctionMeta + * + * @param[in] function_meta + * @param[out] language + * @param[out] language_length + */ +CASS_EXPORT void +cass_function_meta_language(const CassFunctionMeta* function_meta, + const char** language, + size_t* language_length); + +/** + * Gets whether a function is called on "null". + * + * @cassandra{2.2+} + * + * @public @memberof CassFunctionMeta + * + * @param[in] function_meta + * @return cass_true if a function is called on null, otherwise cass_false. + */ +CASS_EXPORT cass_bool_t +cass_function_meta_called_on_null_input(const CassFunctionMeta* function_meta); + +/** + * Gets the number of arguments this function takes. + * + * @cassandra{2.2+} + * + * @public @memberof CassFunctionMeta + * + * @param[in] function_meta + * @return The number of arguments. + */ +CASS_EXPORT size_t +cass_function_meta_argument_count(const CassFunctionMeta* function_meta); + +/** + * Gets the function's argument name and type for the provided index. + * + * @cassandra{2.2+} + * + * @public @memberof CassFunctionMeta + * + * @param[in] function_meta + * @param[in] index + * @param[out] name + * @param[out] name_length + * @param[out] type + * @return CASS_OK if successful, otherwise an error occurred + */ +CASS_EXPORT CassError +cass_function_meta_argument(const CassFunctionMeta* function_meta, + size_t index, + const char** name, + size_t* name_length, + const CassDataType** type); + +/** + * Gets the function's argument and type for the provided name. + * + * @cassandra{2.2+} + * + * @public @memberof CassFunctionMeta + * + * @param[in] function_meta + * @param[in] name + * @return A data type. NULL if the argument does not exist. + */ +CASS_EXPORT const CassDataType* +cass_function_meta_argument_type_by_name(const CassFunctionMeta* function_meta, + const char* name); + +/** + * Same as cass_function_meta_argument_type_by_name(), but with lengths for string + * parameters. + * + * @cassandra{2.2+} + * + * @public @memberof CassFunctionMeta + * + * @param[in] function_meta + * @param[in] name + * @param[in] name_length + * @return same as cass_function_meta_argument_type_by_name() + * + * @see cass_function_meta_argument_type_by_name() + */ +CASS_EXPORT const CassDataType* +cass_function_meta_argument_type_by_name_n(const CassFunctionMeta* function_meta, + const char* name, + size_t name_length); + +/** + * Gets the return type of the function. + * + * @cassandra{2.2+} + * + * @public @memberof CassFunctionMeta + * + * @param[in] function_meta + * @return The data type returned by the function. + */ +CASS_EXPORT const CassDataType* +cass_function_meta_return_type(const CassFunctionMeta* function_meta); + +/** + * Gets a metadata field for the provided name. Metadata fields allow direct + * access to the column data found in the underlying "functions" metadata table. + * + * @cassandra{2.2+} + * + * @public @memberof CassFunctionMeta + * + * @param[in] function_meta + * @param[in] name + * @return A metadata field value. NULL if the field does not exist. + */ +CASS_EXPORT const CassValue* +cass_function_meta_field_by_name(const CassFunctionMeta* function_meta, + const char* name); + +/** + * Same as cass_function_meta_field_by_name(), but with lengths for string + * parameters. + * + * @cassandra{2.2+} + * + * @public @memberof CassFunctionMeta + * + * @param[in] function_meta + * @param[in] name + * @param[in] name_length + * @return same as cass_function_meta_field_by_name() + * + * @see cass_function_meta_field_by_name() + */ +CASS_EXPORT const CassValue* +cass_function_meta_field_by_name_n(const CassFunctionMeta* function_meta, + const char* name, + size_t name_length); + +/** + * Gets the name of the aggregate. + * + * @cassandra{2.2+} + * + * @public @memberof CassAggregateMeta + * + * @param[in] aggregate_meta + * @param[out] name + * @param[out] name_length + */ +CASS_EXPORT void +cass_aggregate_meta_name(const CassAggregateMeta* aggregate_meta, + const char** name, + size_t* name_length); + +/** + * Gets the full name of the aggregate. The full name includes the + * aggregate's name and the aggregate's signature: + * "name(type1 type2.. typeN)". + * + * @cassandra{2.2+} + * + * @public @memberof CassAggregateMeta + * + * @param[in] aggregate_meta + * @param[out] full_name + * @param[out] full_name_length + */ +CASS_EXPORT void +cass_aggregate_meta_full_name(const CassAggregateMeta* aggregate_meta, + const char** full_name, + size_t* full_name_length); + +/** + * Gets the number of arguments this aggregate takes. + * + * @cassandra{2.2+} + * + * @public @memberof CassAggregateMeta + * + * @param[in] aggregate_meta + * @return The number of arguments. + */ +CASS_EXPORT size_t +cass_aggregate_meta_argument_count(const CassAggregateMeta* aggregate_meta); + +/** + * Gets the aggregate's argument type for the provided index. + * + * @cassandra{2.2+} + * + * @public @memberof CassAggregateMeta + * + * @param[in] aggregate_meta + * @param[in] index + * @return The data type for argument. NULL returned if the index is out of range. + */ +CASS_EXPORT const CassDataType* +cass_aggregate_meta_argument_type(const CassAggregateMeta* aggregate_meta, + size_t index); + +/** + * Gets the return type of the aggregate. + * + * @cassandra{2.2+} + * + * @public @memberof CassAggregateMeta + * + * @param[in] aggregate_meta + * @return The data type returned by the aggregate. + */ +CASS_EXPORT const CassDataType* +cass_aggregate_meta_return_type(const CassAggregateMeta* aggregate_meta); + +/** + * Gets the state type of the aggregate. + * + * @cassandra{2.2+} + * + * @public @memberof CassAggregateMeta + * + * @param[in] aggregate_meta + * @return The data type of the aggregate's state. + */ +CASS_EXPORT const CassDataType* +cass_aggregate_meta_state_type(const CassAggregateMeta* aggregate_meta); + +/** + * Gets the function metadata for the aggregate's state function. + * + * @cassandra{2.2+} + * + * @public @memberof CassAggregateMeta + * + * @param[in] aggregate_meta + * @return The function metadata for the state function. + */ +CASS_EXPORT const CassFunctionMeta* +cass_aggregate_meta_state_func(const CassAggregateMeta* aggregate_meta); + +/** + * Gets the function metadata for the aggregates's final function. + * + * @cassandra{2.2+} + * + * @public @memberof CassAggregateMeta + * + * @param[in] aggregate_meta + * @return The function metadata for the final function. + */ +CASS_EXPORT const CassFunctionMeta* +cass_aggregate_meta_final_func(const CassAggregateMeta* aggregate_meta); + +/** + * Gets the initial condition value for the aggregate. + * + * @cassandra{2.2+} + * + * Note: The value of the initial condition will always be + * a "varchar" type for Cassandra 3.0+. + * + * @public @memberof CassAggregateMeta + * + * @param[in] aggregate_meta + * @return The value of the initial condition. + */ +CASS_EXPORT const CassValue* +cass_aggregate_meta_init_cond(const CassAggregateMeta* aggregate_meta); + +/** + * Gets a metadata field for the provided name. Metadata fields allow direct + * access to the column data found in the underlying "aggregates" metadata table. + * + * @cassandra{2.2+} + * + * @public @memberof CassAggregateMeta + * + * @param[in] aggregate_meta + * @param[in] name + * @return A metadata field value. NULL if the field does not exist. + */ +CASS_EXPORT const CassValue* +cass_aggregate_meta_field_by_name(const CassAggregateMeta* aggregate_meta, + const char* name); + +/** + * Same as cass_aggregate_meta_field_by_name(), but with lengths for string + * parameters. + * + * @cassandra{2.2+} + * + * @public @memberof CassAggregateMeta + * + * @param[in] aggregate_meta + * @param[in] name + * @param[in] name_length + * @return same as cass_aggregate_meta_field_by_name() + * + * @see cass_aggregate_meta_field_by_name() + */ +CASS_EXPORT const CassValue* +cass_aggregate_meta_field_by_name_n(const CassAggregateMeta* aggregate_meta, + const char* name, + size_t name_length); + +/*********************************************************************************** + * + * SSL + * + ************************************************************************************/ + +/** + * Creates a new SSL context. + * + * @public @memberof CassSsl + * + * @return Returns a SSL context that must be freed. + * + * @see cass_ssl_free() + */ +CASS_EXPORT CassSsl* +cass_ssl_new(); + +/** + * Creates a new SSL context without initializing the underlying library + * implementation. The integrating application is responsible for + * initializing the underlying SSL implementation. The driver uses the SSL + * implmentation from several threads concurrently so it's important that it's + * properly setup for multithreaded use e.g. lock callbacks for OpenSSL. + * + * Important: The SSL library must be initialized before calling this + * function. + * + * When using OpenSSL the following components need to be initialized: + * + * SSL_library_init(); + * SSL_load_error_strings(); + * OpenSSL_add_all_algorithms(); + * + * The following thread-safety callbacks also need to be set: + * + * CRYPTO_set_locking_callback(...); + * CRYPTO_set_id_callback(...); + * + * @public @memberof CassSsl + * + * @return Returns a SSL context that must be freed. + * + * @see cass_ssl_new() + * @see cass_ssl_free() + */ +CASS_EXPORT CassSsl* +cass_ssl_new_no_lib_init(); + +/** + * Frees a SSL context instance. + * + * @public @memberof CassSsl + * + * @param[in] ssl + */ +CASS_EXPORT void +cass_ssl_free(CassSsl* ssl); + +/** + * Adds a trusted certificate. This is used to verify + * the peer's certificate. + * + * @public @memberof CassSsl + * + * @param[in] ssl + * @param[in] cert PEM formatted certificate string + * @return CASS_OK if successful, otherwise an error occurred + */ +CASS_EXPORT CassError +cass_ssl_add_trusted_cert(CassSsl* ssl, + const char* cert); + +/** + * Same as cass_ssl_add_trusted_cert(), but with lengths for string + * parameters. + * + * @public @memberof CassSsl + * + * @param[in] ssl + * @param[in] cert + * @param[in] cert_length + * @return same as cass_ssl_add_trusted_cert() + * + * @see cass_ssl_add_trusted_cert() + */ +CASS_EXPORT CassError +cass_ssl_add_trusted_cert_n(CassSsl* ssl, + const char* cert, + size_t cert_length); + +/** + * Sets verification performed on the peer's certificate. + * + * CASS_SSL_VERIFY_NONE - No verification is performed + * CASS_SSL_VERIFY_PEER_CERT - Certificate is present and valid + * CASS_SSL_VERIFY_PEER_IDENTITY - IP address matches the certificate's + * common name or one of its subject alternative names. This implies the + * certificate is also present. + * CASS_SSL_VERIFY_PEER_IDENTITY_DNS - Do not use. This option requires the + * use of reverse DNS lookup which is not sufficient to protect against + * man-in-the-middle attacks. + * + * Default: CASS_SSL_VERIFY_PEER_CERT + * + * @public @memberof CassSsl + * + * @param[in] ssl + * @param[in] flags + * @return CASS_OK if successful, otherwise an error occurred + * + */ +CASS_EXPORT void +cass_ssl_set_verify_flags(CassSsl* ssl, + int flags); + +/** + * Set client-side certificate chain. This is used to authenticate + * the client on the server-side. This should contain the entire + * Certificate chain starting with the certificate itself. + * + * @public @memberof CassSsl + * + * @param[in] ssl + * @param[in] cert PEM formatted certificate string + * @return CASS_OK if successful, otherwise an error occurred + */ +CASS_EXPORT CassError +cass_ssl_set_cert(CassSsl* ssl, + const char* cert); + +/** + * Same as cass_ssl_set_cert(), but with lengths for string + * parameters. + * + * @public @memberof CassSsl + * + * @param[in] ssl + * @param[in] cert + * @param[in] cert_length + * @return same as cass_ssl_set_cert() + * + * @see cass_ssl_set_cert() + */ +CASS_EXPORT CassError +cass_ssl_set_cert_n(CassSsl* ssl, + const char* cert, + size_t cert_length); + +/** + * Set client-side private key. This is used to authenticate + * the client on the server-side. + * + * @public @memberof CassSsl + * + * @param[in] ssl + * @param[in] key PEM formatted key string + * @param[in] password used to decrypt key + * @return CASS_OK if successful, otherwise an error occurred + */ +CASS_EXPORT CassError +cass_ssl_set_private_key(CassSsl* ssl, + const char* key, + const char* password); + +/** + * Same as cass_ssl_set_private_key(), but with lengths for string + * parameters. + * + * @public @memberof CassSsl + * + * @param[in] ssl + * @param[in] key + * @param[in] key_length + * @param[in] password + * @param[in] password_length + * @return same as cass_ssl_set_private_key() + * + * @see cass_ssl_set_private_key() + */ +CASS_EXPORT CassError +cass_ssl_set_private_key_n(CassSsl* ssl, + const char* key, + size_t key_length, + const char* password, + size_t password_length); + +/** + * Set minimum supported client-side protocol version. This will prevent the + * connection using protocol versions earlier than the specified one. Useful + * for preventing TLS downgrade attacks. + * + * @public @memberof CassSsl + * + * @param[in] ssl + * @param[in] min_version + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_ssl_set_min_protocol_version(CassSsl* ssl, CassSslTlsVersion min_version); + +/*********************************************************************************** + * + * Authenticator + * + ************************************************************************************/ + +/** + * Gets the IP address of the host being authenticated. + * + * @param[in] auth + * @param[out] address + * + * @public @memberof CassAuthenticator + */ +CASS_EXPORT void +cass_authenticator_address(const CassAuthenticator* auth, + CassInet* address); + +/** + * Gets the hostname of the host being authenticated. + * + * @public @memberof CassAuthenticator + * + * @param[in] auth + * @param[out] length + * @return A null-terminated string. + */ +CASS_EXPORT const char* +cass_authenticator_hostname(const CassAuthenticator* auth, + size_t* length); + +/** + * Gets the class name for the server-side IAuthentication implementation. + * + * @public @memberof CassAuthenticator + * + * @param[in] auth + * @param[out] length + * @return A null-terminated string. + */ +CASS_EXPORT const char* +cass_authenticator_class_name(const CassAuthenticator* auth, + size_t* length); + +/** + * Gets the user data created during the authenticator exchange. This + * is set using cass_authenticator_set_exchange_data(). + * + * @public @memberof CassAuthenticator + * + * @param[in] auth + * @return User specified exchange data previously set by + * cass_authenticator_set_exchange_data(). + * + * @see cass_authenticator_set_exchange_data() + */ +CASS_EXPORT void* +cass_authenticator_exchange_data(CassAuthenticator* auth); + +/** + * Sets the user data to be used during the authenticator exchange. + * + * @public @memberof CassAuthenticator + * + * @param[in] auth + * @param[in] exchange_data + * + * @see cass_authenticator_exchange_data() + */ +CASS_EXPORT void +cass_authenticator_set_exchange_data(CassAuthenticator* auth, + void* exchange_data); + +/** + * Gets a response token buffer of the provided size. + * + * @public @memberof CassAuthenticator + * + * @param[in] auth + * @param[in] size + * @return A buffer to copy the response token. + */ +CASS_EXPORT char* +cass_authenticator_response(CassAuthenticator* auth, + size_t size); + +/** + * Sets the response token. + * + * @public @memberof CassAuthenticator + * + * @param[in] auth + * @param[in] response + * @param[in] response_size + */ +CASS_EXPORT void +cass_authenticator_set_response(CassAuthenticator* auth, + const char* response, + size_t response_size); + +/** + * Sets an error for the authenticator exchange. + * + * @public @memberof CassAuthenticator + * + * @param[in] auth + * @param[in] message + */ +CASS_EXPORT void +cass_authenticator_set_error(CassAuthenticator* auth, + const char* message); + +/** + * Same as cass_authenticator_set_error(), but with lengths for string + * parameters. + * + * @public @memberof CassAuthenticator + * + * @param[in] auth + * @param[in] message + * @param[in] message_length + * + * @see cass_authenticator_set_error() + */ +CASS_EXPORT void +cass_authenticator_set_error_n(CassAuthenticator* auth, + const char* message, + size_t message_length); + +/*********************************************************************************** + * + * Future + * + ***********************************************************************************/ + +/** + * Frees a future instance. A future can be freed anytime. + * + * @public @memberof CassFuture + */ +CASS_EXPORT void +cass_future_free(CassFuture* future); + +/** + * Sets a callback that is called when a future is set + * + * @public @memberof CassFuture + * + * @param[in] future + * @param[in] callback + * @param[in] data + * @return CASS_OK if successful, otherwise an error occurred + */ +CASS_EXPORT CassError +cass_future_set_callback(CassFuture* future, + CassFutureCallback callback, + void* data); + +/** + * Gets the set status of the future. + * + * @public @memberof CassFuture + * + * @param[in] future + * @return true if set + */ +CASS_EXPORT cass_bool_t +cass_future_ready(CassFuture* future); + +/** + * Wait for the future to be set with either a result or error. + * + * Important: Do not wait in a future callback. Waiting in a future + * callback will cause a deadlock. + * + * @public @memberof CassFuture + * + * @param[in] future + */ +CASS_EXPORT void +cass_future_wait(CassFuture* future); + +/** + * Wait for the future to be set or timeout. + * + * @public @memberof CassFuture + * + * @param[in] future + * @param[in] timeout_us wait time in microseconds + * @return false if returned due to timeout + */ +CASS_EXPORT cass_bool_t +cass_future_wait_timed(CassFuture* future, + cass_duration_t timeout_us); + +/** + * Gets the result of a successful future. If the future is not ready this method will + * wait for the future to be set. + * + * @public @memberof CassFuture + * + * @param[in] future + * @return CassResult instance if successful, otherwise NULL for error. The return instance + * must be freed using cass_result_free(). + * + * @see cass_session_execute() and cass_session_execute_batch() + */ +CASS_EXPORT const CassResult* +cass_future_get_result(CassFuture* future); + +/** + * Gets the error result from a future that failed as a result of a server error. If the + * future is not ready this method will wait for the future to be set. + * + * @public @memberof CassFuture + * + * @param[in] future + * @return CassErrorResult instance if the request failed with a server error, + * otherwise NULL if the request was successful or the failure was not caused by + * a server error. The return instance must be freed using cass_error_result_free(). + * + * @see cass_session_execute() and cass_session_execute_batch() + */ +CASS_EXPORT const CassErrorResult* +cass_future_get_error_result(CassFuture* future); + +/** + * Gets the result of a successful future. If the future is not ready this method will + * wait for the future to be set. The first successful call consumes the future, all + * subsequent calls will return NULL. + * + * @public @memberof CassFuture + * + * @param[in] future + * @return CassPrepared instance if successful, otherwise NULL for error. The return instance + * must be freed using cass_prepared_free(). + * + * @see cass_session_prepare() + */ +CASS_EXPORT const CassPrepared* +cass_future_get_prepared(CassFuture* future); + +/** + * Gets the error code from future. If the future is not ready this method will + * wait for the future to be set. + * + * @public @memberof CassFuture + * + * @param[in] future + * @return CASS_OK if successful, otherwise an error occurred. + * + * @see cass_error_desc() + */ +CASS_EXPORT CassError +cass_future_error_code(CassFuture* future); + +/** + * Gets the error message from future. If the future is not ready this method will + * wait for the future to be set. + * + * @public @memberof CassFuture + * + * @param[in] future + * @param[out] message Empty string returned if successful, otherwise + * a message describing the error is returned. + * @param[out] message_length + */ +CASS_EXPORT void +cass_future_error_message(CassFuture* future, + const char** message, + size_t* message_length); + +/** + * Gets the tracing ID associated with the request. + * + * @public @memberof CassFuture + * + * @param[in] future + * @param[out] tracing_id + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_future_tracing_id(CassFuture* future, + CassUuid* tracing_id); + +/** + * Gets a the number of custom payload items from a response future. If the future is not + * ready this method will wait for the future to be set. + * + * @cassandra{2.2+} + * + * @public @memberof CassFuture + * + * @param[in] future + * @return the number of custom payload items. + */ +CASS_EXPORT size_t +cass_future_custom_payload_item_count(CassFuture* future); + +/** + * Gets a custom payload item from a response future at the specified index. If the future is not + * ready this method will wait for the future to be set. + * + * @cassandra{2.2+} + * + * @public @memberof CassFuture + * + * @param[in] future + * @param[in] index + * @param[out] name + * @param[out] name_length + * @param[out] value + * @param[out] value_size + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_future_custom_payload_item(CassFuture* future, + size_t index, + const char** name, + size_t* name_length, + const cass_byte_t** value, + size_t* value_size); + +/** + * Gets the node that acted as coordinator for this query. If the future is not + * ready this method will wait for the future to be set. + * + * @public @memberof CassFuture + * + * @param future + * @return The coordinator node that handled the query. The lifetime of this + * object is the same as the result object it came from. NULL can be returned + * if the future is not a response future or if an error occurs before a + * coordinator responds. + * + * @see cass_statement_set_node() + */ +CASS_EXPORT const CassNode* +cass_future_coordinator(CassFuture* future); + +/*********************************************************************************** + * + * Statement + * + ***********************************************************************************/ + +/** + * Creates a new query statement. + * + * @public @memberof CassStatement + * + * @param[in] query The query is copied into the statement object; the + * memory pointed to by this parameter can be freed after this call. + * @param[in] parameter_count The number of bound parameters. + * @return Returns a statement that must be freed. + * + * @see cass_statement_free() + */ +CASS_EXPORT CassStatement* +cass_statement_new(const char* query, + size_t parameter_count); + +/** + * Same as cass_statement_new(), but with lengths for string + * parameters. + * + * @public @memberof CassStatement + * + * @param[in] query + * @param[in] query_length + * @param[in] parameter_count + * @return same as cass_statement_new() + * + * @see cass_statement_new() + */ +CASS_EXPORT CassStatement* +cass_statement_new_n(const char* query, + size_t query_length, + size_t parameter_count); + +/** + * Clear and/or resize the statement's parameters. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] count + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_reset_parameters(CassStatement* statement, + size_t count); + +/** + * Frees a statement instance. Statements can be immediately freed after + * being prepared, executed or added to a batch. + * + * @public @memberof CassStatement + * + * @param[in] statement + */ +CASS_EXPORT void +cass_statement_free(CassStatement* statement); + +/** + * Adds a key index specifier to this a statement. + * When using token-aware routing, this can be used to tell the driver which + * parameters within a non-prepared, parameterized statement are part of + * the partition key. + * + * Use consecutive calls for composite partition keys. + * + * This is not necessary for prepared statements, as the key + * parameters are determined in the metadata processed in the prepare phase. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] index + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_add_key_index(CassStatement* statement, + size_t index); + +/** + * Sets the statement's keyspace. This is used for token-aware routing and when + * using protocol v5 or greater it also overrides the session's current + * keyspace for the statement. + * + * This is not necessary and will not work for bound statements, as the keyspace + * is determined by the prepared statement metadata. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] keyspace + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_set_keyspace(CassStatement* statement, + const char* keyspace); + +/** + * Same as cass_statement_set_keyspace(), but with lengths for string + * parameters. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] keyspace + * @param[in] keyspace_length + * @return same as cass_statement_set_keyspace() + * + * @see cass_statement_set_keyspace() + */ +CASS_EXPORT CassError +cass_statement_set_keyspace_n(CassStatement* statement, + const char* keyspace, + size_t keyspace_length); + +/** + * Sets the statement's consistency level. + * + * Default: CASS_CONSISTENCY_LOCAL_ONE + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] consistency + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_set_consistency(CassStatement* statement, + CassConsistency consistency); + +/** + * Sets the statement's serial consistency level. + * + * @cassandra{2.0+} + * + * Default: Not set + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] serial_consistency + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_set_serial_consistency(CassStatement* statement, + CassConsistency serial_consistency); + +/** + * Sets the statement's page size. + * + * @cassandra{2.0+} + * + * Default: -1 (Disabled) + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] page_size + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_set_paging_size(CassStatement* statement, + int page_size); + +/** + * Sets the statement's paging state. This can be used to get the next page of + * data in a multi-page query. + * + * @cassandra{2.0+} + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] result + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_set_paging_state(CassStatement* statement, + const CassResult* result); + +/** + * Sets the statement's paging state. This can be used to get the next page of + * data in a multi-page query. + * + * @cassandra{2.0+} + * + * Warning: The paging state should not be exposed to or come from + * untrusted environments. The paging state could be spoofed and potentially + * used to gain access to other data. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] paging_state + * @param[in] paging_state_size + * @return CASS_OK if successful, otherwise an error occurred. + * + * @see cass_result_paging_state_token() + */ +CASS_EXPORT CassError +cass_statement_set_paging_state_token(CassStatement* statement, + const char* paging_state, + size_t paging_state_size); + +/** + * Sets the statement's timestamp. + * + * @cassandra{2.1+} + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] timestamp + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_set_timestamp(CassStatement* statement, + cass_int64_t timestamp); + +/** + * Sets the statement's timeout for waiting for a response from a node. + * + * Default: Disabled (use the cluster-level request timeout) + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] timeout_ms Request timeout in milliseconds. Use 0 for no timeout + * or CASS_UINT64_MAX to disable (to use the cluster-level request timeout). + * @return CASS_OK if successful, otherwise an error occurred. + * + * @see cass_cluster_set_request_timeout() + */ +CASS_EXPORT CassError +cass_statement_set_request_timeout(CassStatement* statement, + cass_uint64_t timeout_ms); + +/** + * Sets whether the statement is idempotent. Idempotent statements are able to be + * automatically retried after timeouts/errors and can be speculatively executed. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] is_idempotent + * @return CASS_OK if successful, otherwise an error occurred. + * + * @see cass_cluster_set_constant_speculative_execution_policy() + * @see cass_execution_profile_set_constant_speculative_execution_policy() + */ +CASS_EXPORT CassError +cass_statement_set_is_idempotent(CassStatement* statement, + cass_bool_t is_idempotent); + +/** + * Sets the statement's retry policy. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] retry_policy + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_set_retry_policy(CassStatement* statement, + CassRetryPolicy* retry_policy); + +/** + * Sets the statement's custom payload. + * + * @cassandra{2.2+} + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] payload + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_set_custom_payload(CassStatement* statement, + const CassCustomPayload* payload); + +/** + * Sets the execution profile to execute the statement with. + * + * Note: NULL or empty string will clear execution profile from statement + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @return CASS_OK if successful, otherwise an error occurred. + * + * @see cass_cluster_set_execution_profile() + */ +CASS_EXPORT CassError +cass_statement_set_execution_profile(CassStatement* statement, + const char* name); + +/** + * Same as cass_statement_set_execution_profile(), but with lengths for string + * parameters. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] name_length + * @return CASS_OK if successful, otherwise an error occurred. + * + * @see cass_statement_set_execution_profile() + */ +CASS_EXPORT CassError +cass_statement_set_execution_profile_n(CassStatement* statement, + const char* name, + size_t name_length); + +/** + * Sets whether the statement should use tracing. + * + * @cassandra{2.2+} + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] enabled + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_set_tracing(CassStatement* statement, + cass_bool_t enabled); + +/** + * Sets a specific host that should run the query. + * + * In general, this should not be used, but it can be useful in the following + * situations: + * * To query node-local tables such as system and virtual tables. + * * To apply a sequence of schema changes where it makes sense for all the + * changes to be applied on a single node. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] host + * @param[in] port + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_set_host(CassStatement* statement, + const char* host, + int port); + +/** + * Same as cass_statement_set_host(), but with lengths for string + * parameters. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] host + * @param[in] host_length + * @param[in] port + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_set_host_n(CassStatement* statement, + const char* host, + size_t host_length, + int port); + +/** + * Same as cass_statement_set_host(), but with the `CassInet` type + * for the host instead of a string. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] host + * @param[in] port + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_set_host_inet(CassStatement* statement, + const CassInet* host, + int port); + +/** + * Same as cass_statement_set_host(), but using the `CassNode` type. This can + * be used to re-query the same coordinator when used with the result of + * `cass_future_coordinator()` + * + * @public @memberof CassStatement + * + * @param statement + * @param node + * @return CASS_OK if successful, otherwise an error occurred. + * + * @see cass_future_coordinator() + */ +CASS_EXPORT CassError +cass_statement_set_node(CassStatement* statement, + const CassNode* node); + +/** + * Binds null to a query or bound statement at the specified index. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] index + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_null(CassStatement* statement, + size_t index); + +/** + * Binds a null to all the values with the specified name. + * + * This can only be used with statements created by + * cass_prepared_bind() when using Cassandra 2.0 or earlier. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_null_by_name(CassStatement* statement, + const char* name); + +/** + * Same as cass_statement_bind_null_by_name(), but with lengths for string + * parameters. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] name_length + * @return same as cass_statement_bind_null_by_name() + * + * @see cass_statement_bind_null_by_name() + */ +CASS_EXPORT CassError +cass_statement_bind_null_by_name_n(CassStatement* statement, + const char* name, + size_t name_length); + +/** + * Binds a "tinyint" to a query or bound statement at the specified index. + * + * @cassandra{2.2+} + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] index + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_int8(CassStatement* statement, + size_t index, + cass_int8_t value); + +/** + * Binds a "tinyint" to all the values with the specified name. + * + * @cassandra{2.2+} + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_int8_by_name(CassStatement* statement, + const char* name, + cass_int8_t value); + +/** + * Same as cass_statement_bind_int8_by_name(), but with lengths for string + * parameters. + * + * @cassandra{2.2+} + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] name_length + * @param[in] value + * @return same as cass_statement_bind_int8_by_name() + * + * @see cass_statement_bind_int8_by_name() + */ +CASS_EXPORT CassError +cass_statement_bind_int8_by_name_n(CassStatement* statement, + const char* name, + size_t name_length, + cass_int8_t value); + +/** + * Binds an "smallint" to a query or bound statement at the specified index. + * + * @cassandra{2.2+} + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] index + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_int16(CassStatement* statement, + size_t index, + cass_int16_t value); + +/** + * Binds an "smallint" to all the values with the specified name. + * + * @cassandra{2.2+} + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_int16_by_name(CassStatement* statement, + const char* name, + cass_int16_t value); + +/** + * Same as cass_statement_bind_int16_by_name(), but with lengths for string + * parameters. + * + * @cassandra{2.2+} + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] name_length + * @param[in] value + * @return same as cass_statement_bind_int16_by_name() + * + * @see cass_statement_bind_int16_by_name() + */ +CASS_EXPORT CassError +cass_statement_bind_int16_by_name_n(CassStatement* statement, + const char* name, + size_t name_length, + cass_int16_t value); + +/** + * Binds an "int" to a query or bound statement at the specified index. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] index + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_int32(CassStatement* statement, + size_t index, + cass_int32_t value); + +/** + * Binds an "int" to all the values with the specified name. + * + * This can only be used with statements created by + * cass_prepared_bind() when using Cassandra 2.0 or earlier. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_int32_by_name(CassStatement* statement, + const char* name, + cass_int32_t value); + +/** + * Same as cass_statement_bind_int32_by_name(), but with lengths for string + * parameters. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] name_length + * @param[in] value + * @return same as cass_statement_bind_int32_by_name() + * + * @see cass_statement_bind_int32_by_name() + */ +CASS_EXPORT CassError +cass_statement_bind_int32_by_name_n(CassStatement* statement, + const char* name, + size_t name_length, + cass_int32_t value); + +/** + * Binds a "date" to a query or bound statement at the specified index. + * + * @cassandra{2.2+} + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] index + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_uint32(CassStatement* statement, + size_t index, + cass_uint32_t value); + +/** + * Binds a "date" to all the values with the specified name. + * + * @cassandra{2.2+} + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_uint32_by_name(CassStatement* statement, + const char* name, + cass_uint32_t value); + +/** + * Same as cass_statement_bind_uint32_by_name(), but with lengths for string + * parameters. + * + * @cassandra{2.2+} + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] name_length + * @param[in] value + * @return same as cass_statement_bind_uint32_by_name() + * + * @see cass_statement_bind_uint32_by_name() + */ +CASS_EXPORT CassError +cass_statement_bind_uint32_by_name_n(CassStatement* statement, + const char* name, + size_t name_length, + cass_uint32_t value); + +/** + * Binds a "bigint", "counter", "timestamp" or "time" to a query or + * bound statement at the specified index. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] index + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_int64(CassStatement* statement, + size_t index, + cass_int64_t value); + +/** + * Binds a "bigint", "counter", "timestamp" or "time" to all values + * with the specified name. + * + * This can only be used with statements created by + * cass_prepared_bind() when using Cassandra 2.0 or earlier. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_int64_by_name(CassStatement* statement, + const char* name, + cass_int64_t value); + +/** + * Same as cass_statement_bind_int64_by_name(), but with lengths for string + * parameters. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] name_length + * @param[in] value + * @return same as cass_statement_bind_int64_by_name(0 + * + * @see cass_statement_bind_int64_by_name() + */ +CASS_EXPORT CassError +cass_statement_bind_int64_by_name_n(CassStatement* statement, + const char* name, + size_t name_length, + cass_int64_t value); + +/** + * Binds a "float" to a query or bound statement at the specified index. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] index + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_float(CassStatement* statement, + size_t index, + cass_float_t value); + +/** + * Binds a "float" to all the values with the specified name. + * + * This can only be used with statements created by + * cass_prepared_bind() when using Cassandra 2.0 or earlier. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_float_by_name(CassStatement* statement, + const char* name, + cass_float_t value); + +/** + * Same as cass_statement_bind_float_by_name(), but with lengths for string + * parameters. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] name_length + * @param[in] value + * @return same as cass_statement_bind_float_by_name() + * + * @see cass_statement_bind_float_by_name() + */ +CASS_EXPORT CassError +cass_statement_bind_float_by_name_n(CassStatement* statement, + const char* name, + size_t name_length, + cass_float_t value); + +/** + * Binds a "double" to a query or bound statement at the specified index. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] index + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_double(CassStatement* statement, + size_t index, + cass_double_t value); + +/** + * Binds a "double" to all the values with the specified name. + * + * This can only be used with statements created by + * cass_prepared_bind() when using Cassandra 2.0 or earlier. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_double_by_name(CassStatement* statement, + const char* name, + cass_double_t value); + +/** + * Same as cass_statement_bind_double_by_name(), but with lengths for string + * parameters. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] name_length + * @param[in] value + * @return same as cass_statement_bind_double_by_name() + * + * @see cass_statement_bind_double_by_name() + */ +CASS_EXPORT CassError +cass_statement_bind_double_by_name_n(CassStatement* statement, + const char* name, + size_t name_length, + cass_double_t value); + +/** + * Binds a "boolean" to a query or bound statement at the specified index. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] index + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_bool(CassStatement* statement, + size_t index, + cass_bool_t value); + +/** + * Binds a "boolean" to all the values with the specified name. + * + * This can only be used with statements created by + * cass_prepared_bind() when using Cassandra 2.0 or earlier. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_bool_by_name(CassStatement* statement, + const char* name, + cass_bool_t value); + +/** + * Same as cass_statement_bind_bool_by_name(), but with lengths for string + * parameters. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] name_length + * @param[in] value + * @return same as cass_statement_bind_bool_by_name() + * + * @see cass_statement_bind_bool_by_name() + */ +CASS_EXPORT CassError +cass_statement_bind_bool_by_name_n(CassStatement* statement, + const char* name, + size_t name_length, + cass_bool_t value); + +/** + * Binds an "ascii", "text" or "varchar" to a query or bound statement + * at the specified index. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] index + * @param[in] value The value is copied into the statement object; the + * memory pointed to by this parameter can be freed after this call. + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_string(CassStatement* statement, + size_t index, + const char* value); + +/** + * Same as cass_statement_bind_string(), but with lengths for string + * parameters. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] index + * @param[in] value + * @param[in] value_length + * @return same as cass_statement_bind_string() + * + * @see cass_statement_bind_string() + */ +CASS_EXPORT CassError +cass_statement_bind_string_n(CassStatement* statement, + size_t index, + const char* value, + size_t value_length); + +/** + * Binds an "ascii", "text" or "varchar" to all the values + * with the specified name. + * + * This can only be used with statements created by + * cass_prepared_bind() when using Cassandra 2.0 or earlier. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] value The value is copied into the statement object; the + * memory pointed to by this parameter can be freed after this call. + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_string_by_name(CassStatement* statement, + const char* name, + const char* value); + +/** + * Same as cass_statement_bind_string_by_name(), but with lengths for string + * parameters. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] name_length + * @param[in] value + * @param[in] value_length + * @return same as cass_statement_bind_string_by_name() + * + * @see cass_statement_bind_string_by_name() + */ +CASS_EXPORT CassError +cass_statement_bind_string_by_name_n(CassStatement* statement, + const char* name, + size_t name_length, + const char* value, + size_t value_length); + +/** + * Binds a "blob", "varint" or "custom" to a query or bound statement at the specified index. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] index + * @param[in] value The value is copied into the statement object; the + * memory pointed to by this parameter can be freed after this call. + * @param[in] value_size + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_bytes(CassStatement* statement, + size_t index, + const cass_byte_t* value, + size_t value_size); + +/** + * Binds a "blob", "varint" or "custom" to all the values with the + * specified name. + * + * This can only be used with statements created by + * cass_prepared_bind() when using Cassandra 2.0 or earlier. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] value The value is copied into the statement object; the + * memory pointed to by this parameter can be freed after this call. + * @param[in] value_size + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_bytes_by_name(CassStatement* statement, + const char* name, + const cass_byte_t* value, + size_t value_size); + +/** + * Same as cass_statement_bind_bytes_by_name(), but with lengths for string + * parameters. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] name_length + * @param[in] value + * @param[in] value_size + * @return same as cass_statement_bind_bytes_by_name() + * + * @see cass_statement_bind_bytes_by_name() + */ +CASS_EXPORT CassError +cass_statement_bind_bytes_by_name_n(CassStatement* statement, + const char* name, + size_t name_length, + const cass_byte_t* value, + size_t value_size); + +/** + * Binds a "custom" to a query or bound statement at the specified index. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] index + * @param[in] class_name + * @param[in] value The value is copied into the statement object; the + * memory pointed to by this parameter can be freed after this call. + * @param[in] value_size + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_custom(CassStatement* statement, + size_t index, + const char* class_name, + const cass_byte_t* value, + size_t value_size); +/** + * Same as cass_statement_bind_custom(), but with lengths for string + * parameters. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] index + * @param[in] class_name + * @param[in] class_name_length + * @param[in] value The value is copied into the statement object; the + * memory pointed to by this parameter can be freed after this call. + * @param[in] value_size + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_custom_n(CassStatement* statement, + size_t index, + const char* class_name, + size_t class_name_length, + const cass_byte_t* value, + size_t value_size); + +/** + * Binds a "custom" to all the values with the specified name. + * + * This can only be used with statements created by + * cass_prepared_bind() when using Cassandra 2.0 or earlier. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] class_name + * @param[in] value The value is copied into the statement object; the + * memory pointed to by this parameter can be freed after this call. + * @param[in] value_size + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_custom_by_name(CassStatement* statement, + const char* name, + const char* class_name, + const cass_byte_t* value, + size_t value_size); + +/** + * Same as cass_statement_bind_custom_by_name(), but with lengths for string + * parameters. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] name_length + * @param[in] class_name + * @param[in] class_name_length + * @param[in] value + * @param[in] value_size + * @return same as cass_statement_bind_custom_by_name() + * + * @see cass_statement_bind_custom_by_name() + */ +CASS_EXPORT CassError +cass_statement_bind_custom_by_name_n(CassStatement* statement, + const char* name, + size_t name_length, + const char* class_name, + size_t class_name_length, + const cass_byte_t* value, + size_t value_size); + +/** + * Binds a "uuid" or "timeuuid" to a query or bound statement at the specified index. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] index + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_uuid(CassStatement* statement, + size_t index, + CassUuid value); + +/** + * Binds a "uuid" or "timeuuid" to all the values + * with the specified name. + * + * This can only be used with statements created by + * cass_prepared_bind() when using Cassandra 2.0 or earlier. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_uuid_by_name(CassStatement* statement, + const char* name, + CassUuid value); + +/** + * Same as cass_statement_bind_uuid_by_name(), but with lengths for string + * parameters. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] name_length + * @param[in] value + * @return same as cass_statement_bind_uuid_by_name() + * + * @see cass_statement_bind_uuid_by_name() + */ +CASS_EXPORT CassError +cass_statement_bind_uuid_by_name_n(CassStatement* statement, + const char* name, + size_t name_length, + CassUuid value); + +/** + * Binds an "inet" to a query or bound statement at the specified index. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] index + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_inet(CassStatement* statement, + size_t index, + CassInet value); + +/** + * Binds an "inet" to all the values with the specified name. + * + * This can only be used with statements created by + * cass_prepared_bind() when using Cassandra 2.0 or earlier. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_inet_by_name(CassStatement* statement, + const char* name, + CassInet value); + +/** + * Same as cass_statement_bind_inet_by_name(), but with lengths for string + * parameters. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] name_length + * @param[in] value + * @return same as cass_statement_bind_inet_by_name() + * + * @see cass_statement_bind_inet_by_name() + */ +CASS_EXPORT CassError +cass_statement_bind_inet_by_name_n(CassStatement* statement, + const char* name, + size_t name_length, + CassInet value); + +/** + * Bind a "decimal" to a query or bound statement at the specified index. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] index + * @param[in] varint The value is copied into the statement object; the + * memory pointed to by this parameter can be freed after this call. + * @param[in] varint_size + * @param[in] scale + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_decimal(CassStatement* statement, + size_t index, + const cass_byte_t* varint, + size_t varint_size, + cass_int32_t scale); + +/** + * Binds a "decimal" to all the values with the specified name. + * + * This can only be used with statements created by + * cass_prepared_bind() when using Cassandra 2.0 or earlier. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] varint The value is copied into the statement object; the + * memory pointed to by this parameter can be freed after this call. + * @param[in] varint_size + * @param[in] scale + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_decimal_by_name(CassStatement* statement, + const char* name, + const cass_byte_t* varint, + size_t varint_size, + cass_int32_t scale); + +/** + * Same as cass_statement_bind_decimal_by_name(), but with lengths for string + * parameters. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] name_length + * @param[in] varint + * @param[in] varint_size + * @param[in] scale + * @return same as cass_statement_bind_decimal_by_name() + * + * @see cass_statement_bind_decimal_by_name() + */ +CASS_EXPORT CassError +cass_statement_bind_decimal_by_name_n(CassStatement* statement, + const char* name, + size_t name_length, + const cass_byte_t* varint, + size_t varint_size, + cass_int32_t scale); + +/** + * Binds a "duration" to a query or bound statement at the specified index. + * + * @cassandra{3.10+} + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] index + * @param[in] months + * @param[in] days + * @param[in] nanos + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_duration(CassStatement* statement, + size_t index, + cass_int32_t months, + cass_int32_t days, + cass_int64_t nanos); + +/** + * Binds a "duration" to all the values with the specified name. + * + * @cassandra{3.10+} + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] months + * @param[in] days + * @param[in] nanos + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_duration_by_name(CassStatement* statement, + const char* name, + cass_int32_t months, + cass_int32_t days, + cass_int64_t nanos); + +/** + * Same as cass_statement_bind_duration_by_name(), but with lengths for string + * parameters. + * + * @cassandra{3.10+} + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] name_length + * @param[in] months + * @param[in] days + * @param[in] nanos + * @return same as cass_statement_bind_duration_by_name() + * + * @see cass_statement_bind_duration_by_name() + */ +CASS_EXPORT CassError +cass_statement_bind_duration_by_name_n(CassStatement* statement, + const char* name, + size_t name_length, + cass_int32_t months, + cass_int32_t days, + cass_int64_t nanos); + +/** + * Bind a "list", "map" or "set" to a query or bound statement at the + * specified index. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] index + * @param[in] collection The collection can be freed after this call. + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_collection(CassStatement* statement, + size_t index, + const CassCollection* collection); + +/** + * Bind a "list", "map" or "set" to all the values with the + * specified name. + * + * This can only be used with statements created by + * cass_prepared_bind() when using Cassandra 2.0 or earlier. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] collection The collection can be freed after this call. + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_collection_by_name(CassStatement* statement, + const char* name, + const CassCollection* collection); + +/** + * Same as cass_statement_bind_collection_by_name(), but with lengths for string + * parameters. + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] name_length + * @param[in] collection + * @return same as cass_statement_bind_collection_by_name() + * + * @see cass_statement_bind_collection_by_name() + */ +CASS_EXPORT CassError +cass_statement_bind_collection_by_name_n(CassStatement* statement, + const char* name, + size_t name_length, + const CassCollection* collection); + +/** + * Bind a "tuple" to a query or bound statement at the specified index. + * + * @cassandra{2.1+} + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] index + * @param[in] tuple The tuple can be freed after this call. + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_tuple(CassStatement* statement, + size_t index, + const CassTuple* tuple); + +/** + * Bind a "tuple" to all the values with the specified name. + * + * @cassandra{2.1+} + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] tuple The tuple can be freed after this call. + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_tuple_by_name(CassStatement* statement, + const char* name, + const CassTuple* tuple); + +/** + * Same as cass_statement_bind_tuple_by_name(), but with lengths for string + * parameters. + * + * @cassandra{2.1+} + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] name_length + * @param[in] tuple + * @return same as cass_statement_bind_tuple_by_name() + * + * @see cass_statement_bind_tuple_by_name() + */ +CASS_EXPORT CassError +cass_statement_bind_tuple_by_name_n(CassStatement* statement, + const char* name, + size_t name_length, + const CassTuple* tuple); + +/** + * Bind a user defined type to a query or bound statement at the + * specified index. + * + * @cassandra{2.1+} + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] index + * @param[in] user_type The user type can be freed after this call. + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_user_type(CassStatement* statement, + size_t index, + const CassUserType* user_type); +/** + * Bind a user defined type to a query or bound statement with the + * specified name. + * + * @cassandra{2.1+} + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] user_type The user type can be freed after this call. + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_statement_bind_user_type_by_name(CassStatement* statement, + const char* name, + const CassUserType* user_type); + +/** + * Same as cass_statement_bind_user_type_by_name(), but with lengths for string + * parameters. + * + * @cassandra{2.1+} + * + * @public @memberof CassStatement + * + * @param[in] statement + * @param[in] name + * @param[in] name_length + * @param[in] user_type + * @return same as cass_statement_bind_user_type_by_name() + * + * @see cass_statement_bind_collection_by_name() + */ +CASS_EXPORT CassError +cass_statement_bind_user_type_by_name_n(CassStatement* statement, + const char* name, + size_t name_length, + const CassUserType* user_type); + +/*********************************************************************************** + * + * Prepared + * + ***********************************************************************************/ + +/** + * Frees a prepared instance. + * + * @public @memberof CassPrepared + * + * @param[in] prepared + */ +CASS_EXPORT void +cass_prepared_free(const CassPrepared* prepared); + +/** + * Creates a bound statement from a pre-prepared statement. + * + * @public @memberof CassPrepared + * + * @param[in] prepared + * @return Returns a bound statement that must be freed. + * + * @see cass_statement_free() + */ +CASS_EXPORT CassStatement* +cass_prepared_bind(const CassPrepared* prepared); + +/** + * Gets the name of a parameter at the specified index. + * + * @public @memberof CassPrepared + * + * @param[in] prepared + * @param[in] index + * @param[out] name + * @param[out] name_length + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_prepared_parameter_name(const CassPrepared* prepared, + size_t index, + const char** name, + size_t* name_length); + +/** + * Gets the data type of a parameter at the specified index. + * + * @public @memberof CassPrepared + * + * @param[in] prepared + * @param[in] index + * @return Returns a reference to the data type of the parameter. Do not free + * this reference as it is bound to the lifetime of the prepared. + */ +CASS_EXPORT const CassDataType* +cass_prepared_parameter_data_type(const CassPrepared* prepared, + size_t index); + +/** + * Gets the data type of a parameter for the specified name. + * + * @public @memberof CassPrepared + * + * @param[in] prepared + * @param[in] name + * @return Returns a reference to the data type of the parameter. Do not free + * this reference as it is bound to the lifetime of the prepared. + */ +CASS_EXPORT const CassDataType* +cass_prepared_parameter_data_type_by_name(const CassPrepared* prepared, + const char* name); + +/** + * Same as cass_prepared_parameter_data_type_by_name(), but with lengths for string + * parameters. + * + * @public @memberof CassPrepared + * + * @param[in] prepared + * @param[in] name + * @param[in] name_length + * @return Returns a reference to the data type of the parameter. Do not free + * this reference as it is bound to the lifetime of the prepared. + * + * @see cass_prepared_parameter_data_type_by_name() + */ +CASS_EXPORT const CassDataType* +cass_prepared_parameter_data_type_by_name_n(const CassPrepared* prepared, + const char* name, + size_t name_length); + +/*********************************************************************************** + * + * Batch + * + ***********************************************************************************/ + +/** + * Creates a new batch statement with batch type. + * + * @cassandra{2.0+} + * + * @public @memberof CassBatch + * + * @param[in] type + * @return Returns a batch statement that must be freed. + * + * @see cass_batch_free() + */ +CASS_EXPORT CassBatch* +cass_batch_new(CassBatchType type); + +/** + * Frees a batch instance. Batches can be immediately freed after being + * executed. + * + * @cassandra{2.0+} + * + * @public @memberof CassBatch + * + * @param[in] batch + */ +CASS_EXPORT void +cass_batch_free(CassBatch* batch); + +/** + * Sets the batch's keyspace. When using protocol v5 or greater it overrides + * the session's keyspace for the batch. + * + * Note: If not set explicitly then the batch will inherit the keyspace + * of the first child statement with a non-empty keyspace. + * + * @public @memberof CassBatch + * + * @param[in] batch + * @param[in] keyspace + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_batch_set_keyspace(CassBatch* batch, + const char* keyspace); + +/** + * Same as cass_batch_set_keyspace(), but with lengths for string + * parameters. + * + * @public @memberof CassBatch + * + * @param[in] batch + * @param[in] keyspace + * @param[in] keyspace_length + * @return same as cass_batch_set_keyspace() + * + * @see cass_batch_set_keyspace() + */ +CASS_EXPORT CassError +cass_batch_set_keyspace_n(CassBatch* batch, + const char* keyspace, + size_t keyspace_length); + +/** + * Sets the batch's consistency level + * + * @cassandra{2.0+} + * + * @public @memberof CassBatch + * + * @param[in] batch + * @param[in] consistency The batch's write consistency. + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_batch_set_consistency(CassBatch* batch, + CassConsistency consistency); + +/** + * Sets the batch's serial consistency level. + * + * @cassandra{2.0+} + * + * Default: Not set + * + * @public @memberof CassBatch + * + * @param[in] batch + * @param[in] serial_consistency + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_batch_set_serial_consistency(CassBatch* batch, + CassConsistency serial_consistency); + +/** + * Sets the batch's timestamp. + * + * @cassandra{2.1+} + * + * @public @memberof CassBatch + * + * @param[in] batch + * @param[in] timestamp + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_batch_set_timestamp(CassBatch* batch, + cass_int64_t timestamp); + +/** + * Sets the batch's timeout for waiting for a response from a node. + * + * Default: Disabled (use the cluster-level request timeout) + * + * @public @memberof CassBatch + * + * @param[in] batch + * @param[in] timeout_ms Request timeout in milliseconds. Use 0 for no timeout + * or CASS_UINT64_MAX to disable (to use the cluster-level request timeout). + * @return CASS_OK if successful, otherwise an error occurred. + * + * @see cass_cluster_set_request_timeout() + */ +CASS_EXPORT CassError +cass_batch_set_request_timeout(CassBatch* batch, + cass_uint64_t timeout_ms); + +/** + * Sets whether the statements in a batch are idempotent. Idempotent batches + * are able to be automatically retried after timeouts/errors and can be + * speculatively executed. + * + * @public @memberof CassBatch + * + * @param[in] batch + * @param[in] is_idempotent + * @return CASS_OK if successful, otherwise an error occurred. + * + * @see cass_cluster_set_constant_speculative_execution_policy() + * @see cass_execution_profile_set_constant_speculative_execution_policy() + */ +CASS_EXPORT CassError +cass_batch_set_is_idempotent(CassBatch* batch, + cass_bool_t is_idempotent); + +/** + * Sets the batch's retry policy. + * + * @cassandra{2.0+} + * + * @public @memberof CassBatch + * + * @param[in] batch + * @param[in] retry_policy + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_batch_set_retry_policy(CassBatch* batch, + CassRetryPolicy* retry_policy); + +/** + * Sets the batch's custom payload. + * + * @cassandra{2.2+} + * + * @public @memberof CassBatch + * + * @param[in] batch + * @param[in] payload + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_batch_set_custom_payload(CassBatch* batch, + const CassCustomPayload* payload); + +/** + * Sets whether the batch should use tracing. + * + * @cassandra{2.2+} + * + * @public @memberof CassStatement + * + * @param[in] batch + * @param[in] enabled + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_batch_set_tracing(CassBatch* batch, + cass_bool_t enabled); + +/** + * Adds a statement to a batch. + * + * @cassandra{2.0+} + * + * @public @memberof CassBatch + * + * @param[in] batch + * @param[in] statement + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_batch_add_statement(CassBatch* batch, + CassStatement* statement); + +/** + * Sets the execution profile to execute the batch with. + * + * Note: NULL or empty string will clear execution profile from batch + * + * @public @memberof CassBatch + * + * @param[in] batch + * @param[in] name + * @return CASS_OK if successful, otherwise an error occurred. + * + * @see cass_cluster_set_execution_profile() + */ +CASS_EXPORT CassError +cass_batch_set_execution_profile(CassBatch* batch, + const char* name); + +/** + * Same as cass_batch_set_execution_profile(), but with lengths for string + * parameters. + * + * @public @memberof CassBatch + * + * @param[in] batch + * @param[in] name + * @param[in] name_length + * @return CASS_OK if successful, otherwise an error occurred. + * + * @see cass_batch_set_execution_profile() + */ +CASS_EXPORT CassError +cass_batch_set_execution_profile_n(CassBatch* batch, + const char* name, + size_t name_length); + +/*********************************************************************************** + * + * Data type + * + ***********************************************************************************/ + +/** + * Creates a new data type with value type. + * + * @public @memberof CassDataType + * + * @param[in] type + * @return Returns a data type that must be freed. + * + * @see cass_data_type_free() + */ +CASS_EXPORT CassDataType* +cass_data_type_new(CassValueType type); + +/** + * Creates a new data type from an existing data type. + * + * @public @memberof CassDataType + * + * @param[in] data_type + * @return Returns a data type that must be freed. + * + * @see cass_data_type_free() + */ +CASS_EXPORT CassDataType* +cass_data_type_new_from_existing(const CassDataType* data_type); + +/** + * Creates a new tuple data type. + * + * @cassandra{2.1+} + * + * @public @memberof CassDataType + * + * @param[in] item_count The number of items in the tuple + * @return Returns a data type that must be freed. + * + * @see cass_data_type_free() + */ +CASS_EXPORT CassDataType* +cass_data_type_new_tuple(size_t item_count); + +/** + * Creates a new UDT (user defined type) data type. + * + * @cassandra{2.1+} + * + * @public @memberof CassDataType + * + * @param[in] field_count The number of fields in the UDT + * @return Returns a data type that must be freed. + * + * @see cass_data_type_free() + */ +CASS_EXPORT CassDataType* +cass_data_type_new_udt(size_t field_count); + +/** + * Frees a data type instance. + * + * @public @memberof CassDataType + * + * @param[in] data_type + */ +CASS_EXPORT void +cass_data_type_free(CassDataType* data_type); + +/** + * Gets the value type of the specified data type. + * + * @param[in] data_type + * @return The value type + */ +CASS_EXPORT CassValueType +cass_data_type_type(const CassDataType* data_type); + +/** + * Gets whether a data type is frozen. + * + * @cassandra{2.1+} + * + * @param[in] data_type + * @return cass_true if the data type is frozen, otherwise cass_false. + */ +CASS_EXPORT cass_bool_t +cass_data_type_is_frozen(const CassDataType* data_type); + +/** + * Gets the type name of a UDT data type. + * + * Note: Only valid for UDT data types. + * + * @param[in] data_type + * @param[out] type_name + * @param[out] type_name_length + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_data_type_type_name(const CassDataType* data_type, + const char** type_name, + size_t* type_name_length); + +/** + * Sets the type name of a UDT data type. + * + * Note: Only valid for UDT data types. + * + * @param[in] data_type + * @param[in] type_name + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_data_type_set_type_name(CassDataType* data_type, + const char* type_name); + +/** + * Same as cass_data_type_set_type_name(), but with lengths for string + * parameters. + * + * @public @memberof CassDataType + * + * @param[in] data_type + * @param[in] type_name + * @param[in] type_name_length + * @return Returns a data type that must be freed. + */ +CASS_EXPORT CassError +cass_data_type_set_type_name_n(CassDataType* data_type, + const char* type_name, + size_t type_name_length); + +/** + * Gets the type name of a UDT data type. + * + * Note: Only valid for UDT data types. + * + * @cassandra{2.1+} + * + * @param[in] data_type + * @param[out] keyspace + * @param[out] keyspace_length + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_data_type_keyspace(const CassDataType* data_type, + const char** keyspace, + size_t* keyspace_length); + +/** + * Sets the keyspace of a UDT data type. + * + * Note: Only valid for UDT data types. + * + * @cassandra{2.1+} + * + * @param[in] data_type + * @param[in] keyspace + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_data_type_set_keyspace(CassDataType* data_type, + const char* keyspace); + +/** + * Same as cass_data_type_set_keyspace(), but with lengths for string + * parameters. + * + * @cassandra{2.1+} + * + * @public @memberof CassDataType + * + * @param[in] data_type + * @param[in] keyspace + * @param[in] keyspace_length + * @return Returns a data type that must be freed. + */ +CASS_EXPORT CassError +cass_data_type_set_keyspace_n(CassDataType* data_type, + const char* keyspace, + size_t keyspace_length); + +/** + * Gets the class name of a custom data type. + * + * Note: Only valid for custom data types. + * + * @param[in] data_type + * @param[out] class_name + * @param[out] class_name_length + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_data_type_class_name(const CassDataType* data_type, + const char** class_name, + size_t* class_name_length); + +/** + * Sets the class name of a custom data type. + * + * Note: Only valid for custom data types. + * + * @param[in] data_type + * @param[in] class_name + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_data_type_set_class_name(CassDataType* data_type, + const char* class_name); + +/** + * Same as cass_data_type_set_class_name(), but with lengths for string + * parameters. + * + * @public @memberof CassDataType + * + * @param[in] data_type + * @param[in] class_name + * @param[in] class_name_length + * @return Returns a data type that must be freed. + */ +CASS_EXPORT CassError +cass_data_type_set_class_name_n(CassDataType* data_type, + const char* class_name, + size_t class_name_length); + +/** + * Gets the sub-data type count of a UDT (user defined type), tuple + * or collection. + * + * Note: Only valid for UDT, tuple and collection data types. + * + * @param[in] data_type + * @return Returns the number of sub-data types + */ +CASS_EXPORT size_t +cass_data_type_sub_type_count(const CassDataType* data_type); + +/** + * @deprecated Use cass_data_type_sub_type_count() + */ +CASS_EXPORT CASS_DEPRECATED(size_t +cass_data_sub_type_count(const CassDataType* data_type)); + +/** + * Gets the sub-data type count of a UDT (user defined type), tuple + * or collection. + * + * Note: Only valid for UDT, tuple and collection data types. + * + * @param[in] data_type + * @return Returns the number of sub-data types + */ + +/** + * Gets the sub-data type of a UDT (user defined type), tuple or collection at + * the specified index. + * + * Note: Only valid for UDT, tuple and collection data types. + * + * @param[in] data_type + * @param[in] index + * @return Returns a reference to a child data type. Do not free this + * reference as it is bound to the lifetime of the parent data type. NULL + * is returned if the index is out of range. + */ +CASS_EXPORT const CassDataType* +cass_data_type_sub_data_type(const CassDataType* data_type, + size_t index); + +/** + * Gets the sub-data type of a UDT (user defined type) at the specified index. + * + * Note: Only valid for UDT data types. + * + * @cassandra{2.1+} + * + * @param[in] data_type + * @param[in] name + * @return Returns a reference to a child data type. Do not free this + * reference as it is bound to the lifetime of the parent data type. NULL + * is returned if the name doesn't exist. + */ +CASS_EXPORT const CassDataType* +cass_data_type_sub_data_type_by_name(const CassDataType* data_type, + const char* name); + +/** + * Same as cass_data_type_sub_data_type_by_name(), but with lengths for string + * parameters. + * + * @cassandra{2.1+} + * + * @public @memberof CassDataType + * + * @param[in] data_type + * @param[in] name + * @param[in] name_length + * @return Returns a reference to a child data type. Do not free this + * reference as it is bound to the lifetime of the parent data type. NULL + * is returned if the name doesn't exist. + */ +CASS_EXPORT const CassDataType* +cass_data_type_sub_data_type_by_name_n(const CassDataType* data_type, + const char* name, + size_t name_length); + +/** + * Gets the sub-type name of a UDT (user defined type) at the specified index. + * + * @cassandra{2.1+} + * + * Note: Only valid for UDT data types. + * + * @param[in] data_type + * @param[in] index + * @param[out] name + * @param[out] name_length + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_data_type_sub_type_name(const CassDataType* data_type, + size_t index, + const char** name, + size_t* name_length); + +/** + * Adds a sub-data type to a tuple or collection. + * + * Note: Only valid for tuple and collection data types. + * + * @param[in] data_type + * @param[in] sub_data_type + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_data_type_add_sub_type(CassDataType* data_type, + const CassDataType* sub_data_type); + +/** + * Adds a sub-data type to a UDT (user defined type). + * + * Note: Only valid for UDT data types. + * + * @cassandra{2.1+} + * + * @param[in] data_type + * @param[in] name + * @param[in] sub_data_type + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_data_type_add_sub_type_by_name(CassDataType* data_type, + const char* name, + const CassDataType* sub_data_type); + +/** + * Same as cass_data_type_add_sub_type_by_name(), but with lengths for string + * parameters. + * + * Note: Only valid for UDT data types. + * + * @cassandra{2.1+} + * + * @param[in] data_type + * @param[in] name + * @param[in] name_length + * @param[in] sub_data_type + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_data_type_add_sub_type_by_name_n(CassDataType* data_type, + const char* name, + size_t name_length, + const CassDataType* sub_data_type); + +/** + * Adds a sub-data type to a tuple or collection using a value type. + * + * Note: Only valid for tuple and collection data types. + * + * @param[in] data_type + * @param[in] sub_value_type + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_data_type_add_sub_value_type(CassDataType* data_type, + CassValueType sub_value_type); + + +/** + * Adds a sub-data type to a UDT (user defined type) using a value type. + * + * Note: Only valid for UDT data types. + * + * @cassandra{2.1+} + * + * @param[in] data_type + * @param[in] name + * @param[in] sub_value_type + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_data_type_add_sub_value_type_by_name(CassDataType* data_type, + const char* name, + CassValueType sub_value_type); + +/** + * Same as cass_data_type_add_sub_value_type_by_name(), but with lengths for string + * parameters. + * + * Note: Only valid for UDT data types. + * + * @cassandra{2.1+} + * + * @param[in] data_type + * @param[in] name + * @param[in] name_length + * @param[in] sub_value_type + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_data_type_add_sub_value_type_by_name_n(CassDataType* data_type, + const char* name, + size_t name_length, + CassValueType sub_value_type); + +/*********************************************************************************** + * + * Collection + * + ***********************************************************************************/ + +/** + * Creates a new collection. + * + * @public @memberof CassCollection + * + * @param[in] type + * @param[in] item_count The approximate number of items in the collection. + * @return Returns a collection that must be freed. + * + * @see cass_collection_free() + */ +CASS_EXPORT CassCollection* +cass_collection_new(CassCollectionType type, + size_t item_count); + +/** + * Creates a new collection from an existing data type. + * + * @public @memberof CassCollection + * + * @param[in] data_type + * @param[in] item_count The approximate number of items in the collection. + * @return Returns a collection that must be freed. + * + * @see cass_collection_free(); + */ +CASS_EXPORT CassCollection* +cass_collection_new_from_data_type(const CassDataType* data_type, + size_t item_count); + +/** + * Frees a collection instance. + * + * @public @memberof CassCollection + * + * @param[in] collection + */ +CASS_EXPORT void +cass_collection_free(CassCollection* collection); + +/** + * Gets the data type of a collection. + * + * @param[in] collection + * @return Returns a reference to the data type of the collection. Do not free + * this reference as it is bound to the lifetime of the collection. + */ +CASS_EXPORT const CassDataType* +cass_collection_data_type(const CassCollection* collection); + +/** + * Appends a "tinyint" to the collection. + * + * @cassandra{2.2+} + * + * @public @memberof CassCollection + * + * @param[in] collection + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_collection_append_int8(CassCollection* collection, + cass_int8_t value); + +/** + * Appends an "smallint" to the collection. + * + * @cassandra{2.2+} + * + * @public @memberof CassCollection + * + * @param[in] collection + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_collection_append_int16(CassCollection* collection, + cass_int16_t value); + +/** + * Appends an "int" to the collection. + * + * @public @memberof CassCollection + * + * @param[in] collection + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_collection_append_int32(CassCollection* collection, + cass_int32_t value); + +/** + * Appends a "date" to the collection. + * + * @cassandra{2.2+} + * + * @public @memberof CassCollection + * + * @param[in] collection + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_collection_append_uint32(CassCollection* collection, + cass_uint32_t value); + + +/** + * Appends a "bigint", "counter", "timestamp" or "time" to the + * collection. + * + * @public @memberof CassCollection + * + * @param[in] collection + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_collection_append_int64(CassCollection* collection, + cass_int64_t value); + +/** + * Appends a "float" to the collection. + * + * @public @memberof CassCollection + * + * @param[in] collection + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_collection_append_float(CassCollection* collection, + cass_float_t value); + +/** + * Appends a "double" to the collection. + * + * @public @memberof CassCollection + * + * @param[in] collection + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_collection_append_double(CassCollection* collection, + cass_double_t value); + +/** + * Appends a "boolean" to the collection. + * + * @public @memberof CassCollection + * + * @param[in] collection + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_collection_append_bool(CassCollection* collection, + cass_bool_t value); + +/** + * Appends an "ascii", "text" or "varchar" to the collection. + * + * @public @memberof CassCollection + * + * @param[in] collection + * @param[in] value The value is copied into the collection object; the + * memory pointed to by this parameter can be freed after this call. + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_collection_append_string(CassCollection* collection, + const char* value); + + +/** + * Same as cass_collection_append_string(), but with lengths for string + * parameters. + * + * @public @memberof CassCollection + * + * @param[in] collection + * @param[in] value + * @param[in] value_length + * @return same as cass_collection_append_string() + * + * @see cass_collection_append_string(); + */ +CASS_EXPORT CassError +cass_collection_append_string_n(CassCollection* collection, + const char* value, + size_t value_length); + +/** + * Appends a "blob", "varint" or "custom" to the collection. + * + * @public @memberof CassCollection + * + * @param[in] collection + * @param[in] value The value is copied into the collection object; the + * memory pointed to by this parameter can be freed after this call. + * @param[in] value_size + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_collection_append_bytes(CassCollection* collection, + const cass_byte_t* value, + size_t value_size); + +/** + * Appends a "custom" to the collection. + * + * @public @memberof CassCollection + * + * @param[in] collection + * @param[in] class_name + * @param[in] value The value is copied into the collection object; the + * memory pointed to by this parameter can be freed after this call. + * @param[in] value_size + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_collection_append_custom(CassCollection* collection, + const char* class_name, + const cass_byte_t* value, + size_t value_size); + +/** + * Same as cass_collection_append_custom(), but with lengths for string + * parameters. + * + * @public @memberof CassCollection + * + * @param[in] collection + * @param[in] class_name + * @param[in] class_name_length + * @param[in] value + * @param[in] value_size + * @return same as cass_collection_append_custom() + * + * @see cass_collection_append_custom() + */ +CASS_EXPORT CassError +cass_collection_append_custom_n(CassCollection* collection, + const char* class_name, + size_t class_name_length, + const cass_byte_t* value, + size_t value_size); + +/** + * Appends a "uuid" or "timeuuid" to the collection. + * + * @public @memberof CassCollection + * + * @param[in] collection + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_collection_append_uuid(CassCollection* collection, + CassUuid value); + +/** + * Appends an "inet" to the collection. + * + * @public @memberof CassCollection + * + * @param[in] collection + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_collection_append_inet(CassCollection* collection, + CassInet value); + +/** + * Appends a "decimal" to the collection. + * + * @public @memberof CassCollection + * + * @param[in] collection + * @param[in] varint The value is copied into the collection object; the + * memory pointed to by this parameter can be freed after this call. + * @param[in] varint_size + * @param[in] scale + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_collection_append_decimal(CassCollection* collection, + const cass_byte_t* varint, + size_t varint_size, + cass_int32_t scale); + +/** + * Appends a "duration" to the collection. + * + * @cassandra{3.10+} + * + * @public @memberof CassCollection + * + * @param[in] collection + * @param[in] months + * @param[in] days + * @param[in] nanos + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_collection_append_duration(CassCollection* collection, + cass_int32_t months, + cass_int32_t days, + cass_int64_t nanos); + +/** + * Appends a "list", "map" or "set" to the collection. + * + * @cassandra{2.1+} + * + * @public @memberof CassCollection + * + * @param[in] collection + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_collection_append_collection(CassCollection* collection, + const CassCollection* value); + +/** + * Appends a "tuple" to the collection. + * + * @cassandra{2.1+} + * + * @public @memberof CassCollection + * + * @param[in] collection + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_collection_append_tuple(CassCollection* collection, + const CassTuple* value); + +/** + * Appends a "udt" to the collection. + * + * @cassandra{2.1+} + * + * @public @memberof CassCollection + * + * @param[in] collection + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_collection_append_user_type(CassCollection* collection, + const CassUserType* value); + +/*********************************************************************************** + * + * Tuple + * + ***********************************************************************************/ + +/** + * Creates a new tuple. + * + * @cassandra{2.1+} + * + * @public @memberof CassTuple + * + * @param[in] item_count The number of items in the tuple. + * @return Returns a tuple that must be freed. + * + * @see cass_tuple_free() + */ +CASS_EXPORT CassTuple* +cass_tuple_new(size_t item_count); + +/** + * Creates a new tuple from an existing data type. + * + * @cassandra{2.1+} + * + * @public @memberof CassTuple + * + * @param[in] data_type + * @return Returns a tuple that must be freed. + * + * @see cass_tuple_free(); + */ +CASS_EXPORT CassTuple* +cass_tuple_new_from_data_type(const CassDataType* data_type); + +/** + * Frees a tuple instance. + * + * @cassandra{2.1+} + * + * @public @memberof CassTuple + * + * @param[in] tuple + */ +CASS_EXPORT void +cass_tuple_free(CassTuple* tuple); + +/** + * Gets the data type of a tuple. + * + * @cassandra{2.1+} + * + * @param[in] tuple + * @return Returns a reference to the data type of the tuple. Do not free + * this reference as it is bound to the lifetime of the tuple. + */ +CASS_EXPORT const CassDataType* +cass_tuple_data_type(const CassTuple* tuple); + +/** + * Sets an null in a tuple at the specified index. + * + * @cassandra{2.1+} + * + * @public @memberof CassTuple + * + * @param[in] tuple + * @param[in] index + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_tuple_set_null(CassTuple* tuple, size_t index); + +/** + * Sets a "tinyint" in a tuple at the specified index. + * + * @cassandra{2.2+} + * + * @public @memberof CassTuple + * + * @param[in] tuple + * @param[in] index + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_tuple_set_int8(CassTuple* tuple, + size_t index, + cass_int8_t value); + +/** + * Sets an "smallint" in a tuple at the specified index. + * + * @cassandra{2.2+} + * + * @public @memberof CassTuple + * + * @param[in] tuple + * @param[in] index + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_tuple_set_int16(CassTuple* tuple, + size_t index, + cass_int16_t value); + +/** + * Sets an "int" in a tuple at the specified index. + * + * @cassandra{2.1+} + * + * @public @memberof CassTuple + * + * @param[in] tuple + * @param[in] index + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_tuple_set_int32(CassTuple* tuple, + size_t index, + cass_int32_t value); + +/** + * Sets a "date" in a tuple at the specified index. + * + * @cassandra{2.2+} + * + * @public @memberof CassTuple + * + * @param[in] tuple + * @param[in] index + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_tuple_set_uint32(CassTuple* tuple, + size_t index, + cass_uint32_t value); + +/** + * Sets a "bigint", "counter", "timestamp" or "time" in a tuple at the + * specified index. + * + * @cassandra{2.1+} + * + * @public @memberof CassTuple + * + * @param[in] tuple + * @param[in] index + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_tuple_set_int64(CassTuple* tuple, + size_t index, + cass_int64_t value); + +/** + * Sets a "float" in a tuple at the specified index. + * + * @cassandra{2.1+} + * + * @public @memberof CassTuple + * + * @param[in] tuple + * @param[in] index + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_tuple_set_float(CassTuple* tuple, + size_t index, + cass_float_t value); + +/** + * Sets a "double" in a tuple at the specified index. + * + * @cassandra{2.1+} + * + * @public @memberof CassTuple + * + * @param[in] tuple + * @param[in] index + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_tuple_set_double(CassTuple* tuple, + size_t index, + cass_double_t value); + +/** + * Sets a "boolean" in a tuple at the specified index. + * + * @cassandra{2.1+} + * + * @public @memberof CassTuple + * + * @param[in] tuple + * @param[in] index + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_tuple_set_bool(CassTuple* tuple, + size_t index, + cass_bool_t value); + +/** + * Sets an "ascii", "text" or "varchar" in a tuple at the specified index. + * + * @cassandra{2.1+} + * + * @public @memberof CassTuple + * + * @param[in] tuple + * @param[in] index + * @param[in] value The value is copied into the tuple object; the + * memory pointed to by this parameter can be freed after this call. + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_tuple_set_string(CassTuple* tuple, + size_t index, + const char* value); + +/** + * Same as cass_tuple_set_string(), but with lengths for string + * parameters. + * + * @cassandra{2.1+} + * + * @public @memberof CassTuple + * + * @param[in] tuple + * @param[in] index + * @param[in] value + * @param[in] value_length + * @return same as cass_tuple_set_string() + * + * @see cass_tuple_set_string(); + */ +CASS_EXPORT CassError +cass_tuple_set_string_n(CassTuple* tuple, + size_t index, + const char* value, + size_t value_length); + +/** + * Sets a "blob", "varint" or "custom" in a tuple at the specified index. + * + * @cassandra{2.1+} + * + * @public @memberof CassTuple + * + * @param[in] tuple + * @param[in] index + * @param[in] value The value is copied into the tuple object; the + * memory pointed to by this parameter can be freed after this call. + * @param[in] value_size + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_tuple_set_bytes(CassTuple* tuple, + size_t index, + const cass_byte_t* value, + size_t value_size); + +/** + * Sets a "custom" in a tuple at the specified index. + * + * @public @memberof CassTuple + * + * @param[in] tuple + * @param[in] index + * @param[in] class_name + * @param[in] value The value is copied into the tuple object; the + * memory pointed to by this parameter can be freed after this call. + * @param[in] value_size + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_tuple_set_custom(CassTuple* tuple, + size_t index, + const char* class_name, + const cass_byte_t* value, + size_t value_size); + +/** + * Same as cass_tuple_set_custom(), but with lengths for string + * parameters. + * + * @public @memberof CassTuple + * + * @param[in] tuple + * @param[in] index + * @param[in] class_name + * @param[in] class_name_length + * @param[in] value + * @param[in] value_size + * @return same as cass_tuple_set_custom() + * + * @see cass_tuple_set_custom() + */ +CASS_EXPORT CassError +cass_tuple_set_custom_n(CassTuple* tuple, + size_t index, + const char* class_name, + size_t class_name_length, + const cass_byte_t* value, + size_t value_size); + +/** + * Sets a "uuid" or "timeuuid" in a tuple at the specified index. + * + * @cassandra{2.1+} + * + * @public @memberof CassTuple + * + * @param[in] tuple + * @param[in] index + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_tuple_set_uuid(CassTuple* tuple, + size_t index, + CassUuid value); + +/** + * Sets an "inet" in a tuple at the specified index. + * + * @cassandra{2.1+} + * + * @public @memberof CassTuple + * + * @param[in] tuple + * @param[in] index + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_tuple_set_inet(CassTuple* tuple, + size_t index, + CassInet value); + +/** + * Sets a "decimal" in a tuple at the specified index. + * + * @cassandra{2.1+} + * + * @public @memberof CassTuple + * + * @param[in] tuple + * @param[in] index + * @param[in] varint The value is copied into the tuple object; the + * memory pointed to by this parameter can be freed after this call. + * @param[in] varint_size + * @param[in] scale + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_tuple_set_decimal(CassTuple* tuple, + size_t index, + const cass_byte_t* varint, + size_t varint_size, + cass_int32_t scale); + +/** + * Sets a "duration" in a tuple at the specified index. + * + * @cassandra{3.10+} + * + * @public @memberof CassTuple + * + * @param[in] tuple + * @param[in] index + * @param[in] months + * @param[in] days + * @param[in] nanos + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_tuple_set_duration(CassTuple* tuple, + size_t index, + cass_int32_t months, + cass_int32_t days, + cass_int64_t nanos); + +/** + * Sets a "list", "map" or "set" in a tuple at the specified index. + * + * @cassandra{2.1+} + * + * @public @memberof CassTuple + * + * @param[in] tuple + * @param[in] index + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_tuple_set_collection(CassTuple* tuple, + size_t index, + const CassCollection* value); + +/** + * Sets a "tuple" in a tuple at the specified index. + * + * @cassandra{2.1+} + * + * @public @memberof CassTuple + * + * @param[in] tuple + * @param[in] index + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_tuple_set_tuple(CassTuple* tuple, + size_t index, + const CassTuple* value); + +/** + * Sets a "udt" in a tuple at the specified index. + * + * @cassandra{2.1+} + * + * @public @memberof CassTuple + * + * @param[in] tuple + * @param[in] index + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_tuple_set_user_type(CassTuple* tuple, + size_t index, + const CassUserType* value); + +/*********************************************************************************** + * + * User defined type + * + ***********************************************************************************/ + +/** + * Creates a new user defined type from existing data type; + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] data_type + * @return Returns a user defined type that must be freed. NULL is returned if + * the data type is not a user defined type. + * + * @see cass_user_type_free() + */ +CASS_EXPORT CassUserType* +cass_user_type_new_from_data_type(const CassDataType* data_type); + +/** + * Frees a user defined type instance. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + */ +CASS_EXPORT void +cass_user_type_free(CassUserType* user_type); + +/** + * Gets the data type of a user defined type. + * + * @cassandra{2.1+} + * + * @param[in] user_type + * @return Returns a reference to the data type of the user defined type. + * Do not free this reference as it is bound to the lifetime of the + * user defined type. + */ +CASS_EXPORT const CassDataType* +cass_user_type_data_type(const CassUserType* user_type); + +/** + * Sets a null in a user defined type at the specified index. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] index + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_null(CassUserType* user_type, + size_t index); + +/** + * Sets a null in a user defined type at the specified name. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_null_by_name(CassUserType* user_type, + const char* name); + +/** + * Same as cass_user_type_set_null_by_name(), but with lengths for string + * parameters. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @param[in] name_length + * @return same as cass_user_type_set_null_by_name() + * + * @see cass_user_type_set_null_by_name() + */ +CASS_EXPORT CassError +cass_user_type_set_null_by_name_n(CassUserType* user_type, + const char* name, + size_t name_length); + +/** + * Sets a "tinyint" in a user defined type at the specified index. + * + * @cassandra{2.2+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] index + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_int8(CassUserType* user_type, + size_t index, + cass_int8_t value); + +/** + * Sets a "tinyint" in a user defined type at the specified name. + * + * @cassandra{2.2+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_int8_by_name(CassUserType* user_type, + const char* name, + cass_int8_t value); + +/** + * Same as cass_user_type_set_int8_by_name(), but with lengths for string + * parameters. + * + * @cassandra{2.2+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @param[in] name_length + * @param[in] value + * @return same as cass_user_type_set_int8_by_name() + * + * @see cass_user_type_set_int8_by_name() + */ +CASS_EXPORT CassError +cass_user_type_set_int8_by_name_n(CassUserType* user_type, + const char* name, + size_t name_length, + cass_int8_t value); + +/** + * Sets an "smallint" in a user defined type at the specified index. + * + * @cassandra{2.2+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] index + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_int16(CassUserType* user_type, + size_t index, + cass_int16_t value); + +/** + * Sets an "smallint" in a user defined type at the specified name. + * + * @cassandra{2.2+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_int16_by_name(CassUserType* user_type, + const char* name, + cass_int16_t value); + +/** + * Same as cass_user_type_set_int16_by_name(), but with lengths for string + * parameters. + * + * @cassandra{2.2+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @param[in] name_length + * @param[in] value + * @return same as cass_user_type_set_int16_by_name() + * + * @see cass_user_type_set_int16_by_name() + */ +CASS_EXPORT CassError +cass_user_type_set_int16_by_name_n(CassUserType* user_type, + const char* name, + size_t name_length, + cass_int16_t value); + +/** + * Sets an "int" in a user defined type at the specified index. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] index + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_int32(CassUserType* user_type, + size_t index, + cass_int32_t value); + +/** + * Sets an "int" in a user defined type at the specified name. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_int32_by_name(CassUserType* user_type, + const char* name, + cass_int32_t value); + +/** + * Same as cass_user_type_set_int32_by_name(), but with lengths for string + * parameters. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @param[in] name_length + * @param[in] value + * @return same as cass_user_type_set_int32_by_name() + * + * @see cass_user_type_set_int32_by_name() + */ +CASS_EXPORT CassError +cass_user_type_set_int32_by_name_n(CassUserType* user_type, + const char* name, + size_t name_length, + cass_int32_t value); + +/** + * Sets a "date" in a user defined type at the specified index. + * + * @cassandra{2.2+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] index + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_uint32(CassUserType* user_type, + size_t index, + cass_uint32_t value); + +/** + * Sets a "date" in a user defined type at the specified name. + * + * @cassandra{2.2+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_uint32_by_name(CassUserType* user_type, + const char* name, + cass_uint32_t value); + +/** + * Same as cass_user_type_set_uint32_by_name(), but with lengths for string + * parameters. + * + * @cassandra{2.2+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @param[in] name_length + * @param[in] value + * @return same as cass_user_type_set_uint32_by_name() + * + * @see cass_user_type_set_uint32_by_name() + */ +CASS_EXPORT CassError +cass_user_type_set_uint32_by_name_n(CassUserType* user_type, + const char* name, + size_t name_length, + cass_uint32_t value); + + +/** + * Sets an "bigint", "counter", "timestamp" or "time" in a + * user defined type at the specified index. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] index + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_int64(CassUserType* user_type, + size_t index, + cass_int64_t value); + +/** + * Sets an "bigint", "counter", "timestamp" or "time" in a + * user defined type at the specified name. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_int64_by_name(CassUserType* user_type, + const char* name, + cass_int64_t value); + +/** + * Same as cass_user_type_set_int64_by_name(), but with lengths for string + * parameters. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @param[in] name_length + * @param[in] value + * @return same as cass_user_type_set_int64_by_name() + * + * @see cass_user_type_set_int64_by_name() + */ +CASS_EXPORT CassError +cass_user_type_set_int64_by_name_n(CassUserType* user_type, + const char* name, + size_t name_length, + cass_int64_t value); + +/** + * Sets a "float" in a user defined type at the specified index. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] index + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_float(CassUserType* user_type, + size_t index, + cass_float_t value); + +/** + * Sets a "float" in a user defined type at the specified name. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_float_by_name(CassUserType* user_type, + const char* name, + cass_float_t value); + +/** + * Same as cass_user_type_set_float_by_name(), but with lengths for string + * parameters. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @param[in] name_length + * @param[in] value + * @return same as cass_user_type_set_float_by_name() + * + * @see cass_user_type_set_float_by_name() + */ +CASS_EXPORT CassError +cass_user_type_set_float_by_name_n(CassUserType* user_type, + const char* name, + size_t name_length, + cass_float_t value); + +/** + * Sets an "double" in a user defined type at the specified index. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] index + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_double(CassUserType* user_type, + size_t index, + cass_double_t value); + +/** + * Sets an "double" in a user defined type at the specified name. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_double_by_name(CassUserType* user_type, + const char* name, + cass_double_t value); + +/** + * Same as cass_user_type_set_double_by_name(), but with lengths for string + * parameters. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @param[in] name_length + * @param[in] value + * @return same as cass_user_type_set_double_by_name() + * + * @see cass_user_type_set_double_by_name() + */ +CASS_EXPORT CassError +cass_user_type_set_double_by_name_n(CassUserType* user_type, + const char* name, + size_t name_length, + cass_double_t value); + +/** + * Sets a "boolean" in a user defined type at the specified index. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] index + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_bool(CassUserType* user_type, + size_t index, + cass_bool_t value); + +/** + * Sets a "boolean" in a user defined type at the specified name. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_bool_by_name(CassUserType* user_type, + const char* name, + cass_bool_t value); + +/** + * Same as cass_user_type_set_double_by_name(), but with lengths for string + * parameters. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @param[in] name_length + * @param[in] value + * @return same as cass_user_type_set_double_by_name() + * + * @see cass_user_type_set_double_by_name() + */ +CASS_EXPORT CassError +cass_user_type_set_bool_by_name_n(CassUserType* user_type, + const char* name, + size_t name_length, + cass_bool_t value); + + +/** + * Sets an "ascii", "text" or "varchar" in a user defined type at the + * specified index. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] index + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_string(CassUserType* user_type, + size_t index, + const char* value); + +/** + * Same as cass_user_type_set_string(), but with lengths for string + * parameters. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] index + * @param[in] value + * @param[in] value_length + * @return same as cass_user_type_set_string() + * + * @see cass_user_type_set_string() + */ +CASS_EXPORT CassError +cass_user_type_set_string_n(CassUserType* user_type, + size_t index, + const char* value, + size_t value_length); + +/** + * Sets an "ascii", "text" or "varchar" in a user defined type at the + * specified name. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_string_by_name(CassUserType* user_type, + const char* name, + const char* value); + +/** + * Same as cass_user_type_set_string_by_name(), but with lengths for string + * parameters. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @param[in] name_length + * @param[in] value + * @param[in] value_length + * @return same as cass_user_type_set_string_by_name() + * + * @see cass_user_type_set_string_by_name() + */ +CASS_EXPORT CassError +cass_user_type_set_string_by_name_n(CassUserType* user_type, + const char* name, + size_t name_length, + const char* value, + size_t value_length); + +/** + * Sets a "blob" "varint" or "custom" in a user defined type at the specified index. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] index + * @param[in] value + * @param[in] value_size + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_bytes(CassUserType* user_type, + size_t index, + const cass_byte_t* value, + size_t value_size); + +/** + * Sets a "blob", "varint" or "custom" in a user defined type at the specified name. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @param[in] value + * @param[in] value_size + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_bytes_by_name(CassUserType* user_type, + const char* name, + const cass_byte_t* value, + size_t value_size); + +/** + * Same as cass_user_type_set_bytes_by_name(), but with lengths for string + * parameters. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @param[in] name_length + * @param[in] value + * @param[in] value_size + * @return same as cass_user_type_set_bytes_by_name() + * + * @see cass_user_type_set_bytes_by_name() + */ +CASS_EXPORT CassError +cass_user_type_set_bytes_by_name_n(CassUserType* user_type, + const char* name, + size_t name_length, + const cass_byte_t* value, + size_t value_size); + +/** + * Sets a "custom" in a user defined type at the specified index. + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] index + * @param[in] class_name + * @param[in] value + * @param[in] value_size + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_custom(CassUserType* user_type, + size_t index, + const char* class_name, + const cass_byte_t* value, + size_t value_size); + +/** + * Same as cass_user_type_set_custom(), but with lengths for string + * parameters. + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] index + * @param[in] class_name + * @param[in] class_name_length + * @param[in] value + * @param[in] value_size + * @return same as cass_user_type_set_custom() + * + * @see cass_user_type_set_custom() + */ +CASS_EXPORT CassError +cass_user_type_set_custom_n(CassUserType* user_type, + size_t index, + const char* class_name, + size_t class_name_length, + const cass_byte_t* value, + size_t value_size); + +/** + * Sets a "custom" in a user defined type at the specified name. + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @param[in] class_name + * @param[in] value + * @param[in] value_size + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_custom_by_name(CassUserType* user_type, + const char* name, + const char* class_name, + const cass_byte_t* value, + size_t value_size); + +/** + * Same as cass_user_type_set_custom_by_name(), but with lengths for string + * parameters. + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @param[in] name_length + * @param[in] class_name + * @param[in] class_name_length + * @param[in] value + * @param[in] value_size + * @return same as cass_user_type_set_custom_by_name() + * + * @see cass_user_type_set_custom_by_name() + */ +CASS_EXPORT CassError +cass_user_type_set_custom_by_name_n(CassUserType* user_type, + const char* name, + size_t name_length, + const char* class_name, + size_t class_name_length, + const cass_byte_t* value, + size_t value_size); + +/** + * Sets a "uuid" or "timeuuid" in a user defined type at the specified index. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] index + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_uuid(CassUserType* user_type, + size_t index, + CassUuid value); + +/** + * Sets a "uuid" or "timeuuid" in a user defined type at the specified name. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_uuid_by_name(CassUserType* user_type, + const char* name, + CassUuid value); + +/** + * Same as cass_user_type_set_uuid_by_name(), but with lengths for string + * parameters. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @param[in] name_length + * @param[in] value + * @return same as cass_user_type_set_uuid_by_name() + * + * @see cass_user_type_set_uuid_by_name() + */ +CASS_EXPORT CassError +cass_user_type_set_uuid_by_name_n(CassUserType* user_type, + const char* name, + size_t name_length, + CassUuid value); + +/** + * Sets a "inet" in a user defined type at the specified index. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] index + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_inet(CassUserType* user_type, + size_t index, + CassInet value); + +/** + * Sets a "inet" in a user defined type at the specified name. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_inet_by_name(CassUserType* user_type, + const char* name, + CassInet value); + +/** + * Same as cass_user_type_set_inet_by_name(), but with lengths for string + * parameters. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @param[in] name_length + * @param[in] value + * @return same as cass_user_type_set_inet_by_name() + * + * @see cass_user_type_set_inet_by_name() + */ +CASS_EXPORT CassError +cass_user_type_set_inet_by_name_n(CassUserType* user_type, + const char* name, + size_t name_length, + CassInet value); + +/** + * Sets an "decimal" in a user defined type at the specified index. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] index + * @param[in] varint + * @param[in] varint_size + * @param[in] scale + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_decimal(CassUserType* user_type, + size_t index, + const cass_byte_t* varint, + size_t varint_size, + int scale); + +/** + * Sets "decimal" in a user defined type at the specified name. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @param[in] varint + * @param[in] varint_size + * @param[in] scale + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_decimal_by_name(CassUserType* user_type, + const char* name, + const cass_byte_t* varint, + size_t varint_size, + int scale); + +/** + * Same as cass_user_type_set_decimal_by_name(), but with lengths for string + * parameters. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @param[in] name_length + * @param[in] varint + * @param[in] varint_size + * @param[in] scale + * @return same as cass_user_type_set_decimal_by_name() + * + * @see cass_user_type_set_decimal_by_name() + */ +CASS_EXPORT CassError +cass_user_type_set_decimal_by_name_n(CassUserType* user_type, + const char* name, + size_t name_length, + const cass_byte_t* varint, + size_t varint_size, + int scale); + +/** + * Sets a "duration" in a user defined type at the specified index. + * + * @cassandra{3.10+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] index + * @param[in] months + * @param[in] days + * @param[in] nanos + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_duration(CassUserType* user_type, + size_t index, + cass_int32_t months, + cass_int32_t days, + cass_int64_t nanos); + +/** + * Sets "duration" in a user defined type at the specified name. + * + * @cassandra{3.10+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @param[in] months + * @param[in] days + * @param[in] nanos + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_duration_by_name(CassUserType* user_type, + const char* name, + cass_int32_t months, + cass_int32_t days, + cass_int64_t nanos); + +/** + * Same as cass_user_type_set_duration_by_name(), but with lengths for string + * parameters. + * + * @cassandra{3.10+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @param[in] name_length + * @param[in] months + * @param[in] days + * @param[in] nanos + * @return same as cass_user_type_set_duration_by_name() + * + * @see cass_user_type_set_duration_by_name() + */ +CASS_EXPORT CassError +cass_user_type_set_duration_by_name_n(CassUserType* user_type, + const char* name, + size_t name_length, + cass_int32_t months, + cass_int32_t days, + cass_int64_t nanos); + +/** + * Sets a "list", "map" or "set" in a user defined type at the + * specified index. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] index + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_collection(CassUserType* user_type, + size_t index, + const CassCollection* value); + +/** + * Sets a "list", "map" or "set" in a user defined type at the + * specified name. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_collection_by_name(CassUserType* user_type, + const char* name, + const CassCollection* value); + +/** + * Same as cass_user_type_set_collection_by_name(), but with lengths for string + * parameters. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @param[in] name_length + * @param[in] value + * @return same as cass_user_type_set_collection_by_name() + * + * @see cass_user_type_set_collection_by_name() + */ +CASS_EXPORT CassError +cass_user_type_set_collection_by_name_n(CassUserType* user_type, + const char* name, + size_t name_length, + const CassCollection* value); + +/** + * Sets a "tuple" in a user defined type at the specified index. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] index + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_tuple(CassUserType* user_type, + size_t index, + const CassTuple* value); + +/** + * Sets a "tuple" in a user defined type at the specified name. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_tuple_by_name(CassUserType* user_type, + const char* name, + const CassTuple* value); + +/** + * Same as cass_user_type_set_tuple_by_name(), but with lengths for string + * parameters. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @param[in] name_length + * @param[in] value + * @return same as cass_user_type_set_tuple_by_name() + * + * @see cass_user_type_set_tuple_by_name() + */ +CASS_EXPORT CassError +cass_user_type_set_tuple_by_name_n(CassUserType* user_type, + const char* name, + size_t name_length, + const CassTuple* value); + +/** + * Sets a user defined type in a user defined type at the specified index. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] index + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_user_type(CassUserType* user_type, + size_t index, + const CassUserType* value); + +/** + * Sets a user defined type in a user defined type at the specified name. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @param[in] value + * @return CASS_OK if successful, otherwise an error occurred. + */ +CASS_EXPORT CassError +cass_user_type_set_user_type_by_name(CassUserType* user_type, + const char* name, + const CassUserType* value); + +/** + * Same as cass_user_type_set_user_type_by_name(), but with lengths for string + * parameters. + * + * @cassandra{2.1+} + * + * @public @memberof CassUserType + * + * @param[in] user_type + * @param[in] name + * @param[in] name_length + * @param[in] value + * @return same as cass_user_type_set_user_type_by_name() + * + * @see cass_user_type_set_user_type_by_name() + */ +CASS_EXPORT CassError +cass_user_type_set_user_type_by_name_n(CassUserType* user_type, + const char* name, + size_t name_length, + const CassUserType* value); + +/*********************************************************************************** + * + * Result + * + ***********************************************************************************/ + +/** + * Frees a result instance. + * + * This method invalidates all values, rows, and + * iterators that were derived from this result. + * + * @public @memberof CassResult + * + * @param[in] result + */ +CASS_EXPORT void +cass_result_free(const CassResult* result); + +/** + * Gets the number of rows for the specified result. + * + * @public @memberof CassResult + * + * @param[in] result + * @return The number of rows in the result. + */ +CASS_EXPORT size_t +cass_result_row_count(const CassResult* result); + +/** + * Gets the number of columns per row for the specified result. + * + * @public @memberof CassResult + * + * @param[in] result + * @return The number of columns per row in the result. + */ +CASS_EXPORT size_t +cass_result_column_count(const CassResult* result); + +/** + * Gets the column name at index for the specified result. + * + * @public @memberof CassResult + * + * @param[in] result + * @param[in] index + * @param[out] name The column name at the specified index. + * @param[out] name_length + * @return CASS_OK if successful, otherwise error occurred + */ +CASS_EXPORT CassError +cass_result_column_name(const CassResult *result, + size_t index, + const char** name, + size_t* name_length); + +/** + * Gets the column type at index for the specified result. + * + * @public @memberof CassResult + * + * @param[in] result + * @param[in] index + * @return The column type at the specified index. CASS_VALUE_TYPE_UNKNOWN + * is returned if the index is out of bounds. + */ +CASS_EXPORT CassValueType +cass_result_column_type(const CassResult* result, + size_t index); + +/** + * Gets the column data type at index for the specified result. + * + * @public @memberof CassResult + * + * @param[in] result + * @param[in] index + * @return The column type at the specified index. NULL is returned if the + * index is out of bounds. + */ +CASS_EXPORT const CassDataType* +cass_result_column_data_type(const CassResult* result, size_t index); + +/** + * Gets the first row of the result. + * + * @public @memberof CassResult + * + * @param[in] result + * @return The first row of the result. NULL if there are no rows. + */ +CASS_EXPORT const CassRow* +cass_result_first_row(const CassResult* result); + +/** + * Returns true if there are more pages. + * + * @cassandra{2.0+} + * + * @public @memberof CassResult + * + * @param[in] result + * @return cass_true if there are more pages + */ +CASS_EXPORT cass_bool_t +cass_result_has_more_pages(const CassResult* result); + +/** + * Gets the raw paging state from the result. The paging state is bound to the + * lifetime of the result object. If paging state needs to live beyond the + * lifetime of the result object it must be copied. + * + * Warning: The paging state should not be exposed to or come from + * untrusted environments. The paging state could be spoofed and potentially + * used to gain access to other data. + * + * @cassandra{2.0+} + * + * @public @memberof CassResult + * + * @param[in] result + * @param[out] paging_state + * @param[out] paging_state_size + * @return CASS_OK if successful, otherwise error occurred + * + * @see cass_statement_set_paging_state_token() + */ +CASS_EXPORT CassError +cass_result_paging_state_token(const CassResult* result, + const char** paging_state, + size_t* paging_state_size); + +/*********************************************************************************** + * + * Error result + * + ***********************************************************************************/ + +/** + * Frees an error result instance. + * + * @public @memberof CassErrorResult + * + * @param[in] error_result + */ +CASS_EXPORT void +cass_error_result_free(const CassErrorResult* error_result); + +/** + * Gets error code for the error result. This error code will always + * have an server error source. + * + * @public @memberof CassErrorResult + * + * @param[in] error_result + * @return The server error code + */ +CASS_EXPORT CassError +cass_error_result_code(const CassErrorResult* error_result); + +/** + * Gets consistency that triggered the error result of the + * following types: + * + *
    + *
  • CASS_ERROR_SERVER_READ_TIMEOUT
  • + *
  • CASS_ERROR_SERVER_WRITE_TIMEOUT
  • + *
  • CASS_ERROR_SERVER_READ_FAILURE
  • + *
  • CASS_ERROR_SERVER_WRITE_FAILURE
  • + *
  • CASS_ERROR_SERVER_UNAVAILABLE
  • + *
+ * + * @public @memberof CassErrorResult + * + * @param[in] error_result + * @return The consistency that triggered the error for a read timeout, + * write timeout or an unavailable error result. Undefined for other + * error result types. + */ +CASS_EXPORT CassConsistency +cass_error_result_consistency(const CassErrorResult* error_result); + +/** + * Gets the actual number of received responses, received acknowledgments + * or alive nodes for following error result types, respectively: + * + *
    + *
  • CASS_ERROR_SERVER_READ_TIMEOUT
  • + *
  • CASS_ERROR_SERVER_WRITE_TIMEOUT
  • + *
  • CASS_ERROR_SERVER_READ_FAILURE
  • + *
  • CASS_ERROR_SERVER_WRITE_FAILURE
  • + *
  • CASS_ERROR_SERVER_UNAVAILABLE
  • + *
+ * + * @public @memberof CassErrorResult + * + * @param[in] error_result + * @return The actual received responses for a read timeout, actual received + * acknowledgments for a write timeout or actual alive nodes for a unavailable + * error. Undefined for other error result types. + */ +CASS_EXPORT cass_int32_t +cass_error_result_responses_received(const CassErrorResult* error_result); + +/** + * Gets required responses, required acknowledgments or required alive nodes + * needed to successfully complete the request for following error result types, + * respectively: + * + *
    + *
  • CASS_ERROR_SERVER_READ_TIMEOUT
  • + *
  • CASS_ERROR_SERVER_WRITE_TIMEOUT
  • + *
  • CASS_ERROR_SERVER_READ_FAILURE
  • + *
  • CASS_ERROR_SERVER_WRITE_FAILURE
  • + *
  • CASS_ERROR_SERVER_UNAVAILABLE
  • + *
+ * + * @public @memberof CassErrorResult + * + * @param[in] error_result + * @return The required responses for a read time, required acknowledgments + * for a write timeout or required alive nodes for an unavailable error result. + * Undefined for other error result types. + */ +CASS_EXPORT cass_int32_t +cass_error_result_responses_required(const CassErrorResult* error_result); + +/** + * Gets the number of nodes that experienced failures for the following error types: + * + *
    + *
  • CASS_ERROR_SERVER_READ_FAILURE
  • + *
  • CASS_ERROR_SERVER_WRITE_FAILURE
  • + *
+ * + * @public @memberof CassErrorResult + * + * @param[in] error_result + * @return The number of nodes that failed during a read or write request. + */ +CASS_EXPORT cass_int32_t +cass_error_result_num_failures(const CassErrorResult* error_result); + +/** + * Determines whether the actual data was present in the responses from the + * replicas for the following error result types: + * + *
    + *
  • CASS_ERROR_SERVER_READ_TIMEOUT
  • + *
  • CASS_ERROR_SERVER_READ_FAILURE
  • + *
+ * + * @public @memberof CassErrorResult + * + * @param[in] error_result + * @return cass_true if the data was present in the received responses when the + * read timeout occurred. Undefined for other error result types. + */ +CASS_EXPORT cass_bool_t +cass_error_result_data_present(const CassErrorResult* error_result); + +/** + * Gets the write type of a request for the following error result types: + * + *
    + *
  • CASS_ERROR_SERVER_WRITE_TIMEOUT
  • + *
  • CASS_ERROR_SERVER_WRITE_FAILURE
  • + *
+ * + * @public @memberof CassErrorResult + * + * @param[in] error_result + * @return The type of the write that timed out. Undefined for + * other error result types. + */ +CASS_EXPORT CassWriteType +cass_error_result_write_type(const CassErrorResult* error_result); + +/** + * Gets the affected keyspace for the following error result types: + * + *
    + *
  • CASS_ERROR_SERVER_ALREADY_EXISTS
  • + *
  • CASS_ERROR_SERVER_FUNCTION_FAILURE
  • + *
+ * + * @public @memberof CassErrorResult + * + * @param[in] error_result + * @param[out] keyspace + * @param[out] keyspace_length + * @return CASS_OK if successful, otherwise error occurred + */ +CASS_EXPORT CassError +cass_error_result_keyspace(const CassErrorResult* error_result, + const char** keyspace, + size_t* keyspace_length); + +/** + * Gets the affected table for the already exists error + * (CASS_ERROR_SERVER_ALREADY_EXISTS) result type. + * + * @public @memberof CassErrorResult + * + * @param[in] error_result + * @param[out] table + * @param[out] table_length + * @return CASS_OK if successful, otherwise error occurred + */ +CASS_EXPORT CassError +cass_error_result_table(const CassErrorResult* error_result, + const char** table, + size_t* table_length); + +/** + * Gets the affected function for the function failure error + * (CASS_ERROR_SERVER_FUNCTION_FAILURE) result type. + * + * @cassandra{2.2+} + * + * @public @memberof CassErrorResult + * + * @param[in] error_result + * @param[out] function + * @param[out] function_length + * @return CASS_OK if successful, otherwise error occurred + */ +CASS_EXPORT CassError +cass_error_result_function(const CassErrorResult* error_result, + const char** function, + size_t* function_length); + +/** + * Gets the number of argument types for the function failure error + * (CASS_ERROR_SERVER_FUNCTION_FAILURE) result type. + * + * @cassandra{2.2+} + * + * @public @memberof CassErrorResult + * + * @param[in] error_result + * @return The number of arguments for the affected function. + */ +CASS_EXPORT size_t +cass_error_num_arg_types(const CassErrorResult* error_result); + +/** + * Gets the argument type at the specified index for the function failure + * error (CASS_ERROR_SERVER_FUNCTION_FAILURE) result type. + * + * @cassandra{2.2+} + * + * @public @memberof CassErrorResult + * + * @param[in] error_result + * @param[in] index + * @param[out] arg_type + * @param[out] arg_type_length + * @return CASS_OK if successful, otherwise error occurred + */ +CASS_EXPORT CassError +cass_error_result_arg_type(const CassErrorResult* error_result, + size_t index, + const char** arg_type, + size_t* arg_type_length); + +/*********************************************************************************** + * + * Iterator + * + ***********************************************************************************/ + +/** + * Frees an iterator instance. + * + * @public @memberof CassIterator + * + * @param[in] iterator + */ +CASS_EXPORT void +cass_iterator_free(CassIterator* iterator); + +/** + * Gets the type of the specified iterator. + * + * @public @memberof CassIterator + * + * @param[in] iterator + * @return The type of the iterator. + */ +CASS_EXPORT CassIteratorType +cass_iterator_type(CassIterator* iterator); + +/** + * Creates a new iterator for the specified result. This can be + * used to iterate over rows in the result. + * + * @public @memberof CassResult + * + * @param[in] result + * @return A new iterator that must be freed. + * + * @see cass_iterator_free() + */ +CASS_EXPORT CassIterator* +cass_iterator_from_result(const CassResult* result); + +/** + * Creates a new iterator for the specified row. This can be + * used to iterate over columns in a row. + * + * @public @memberof CassRow + * + * @param[in] row + * @return A new iterator that must be freed. + * + * @see cass_iterator_free() + */ +CASS_EXPORT CassIterator* +cass_iterator_from_row(const CassRow* row); + +/** + * Creates a new iterator for the specified collection. This can be + * used to iterate over values in a collection. + * + * @public @memberof CassValue + * + * @param[in] value + * @return A new iterator that must be freed. NULL returned if the + * value is not a collection. + * + * @see cass_iterator_free() + */ +CASS_EXPORT CassIterator* +cass_iterator_from_collection(const CassValue* value); + +/** + * Creates a new iterator for the specified map. This can be + * used to iterate over key/value pairs in a map. + * + * @public @memberof CassValue + * + * @param[in] value + * @return A new iterator that must be freed. NULL returned if the + * value is not a map. + * + * @see cass_iterator_free() + */ +CASS_EXPORT CassIterator* +cass_iterator_from_map(const CassValue* value); + +/** + * Creates a new iterator for the specified tuple. This can be + * used to iterate over values in a tuple. + * + * @cassandra{2.1+} + * + * @public @memberof CassValue + * + * @param[in] value + * @return A new iterator that must be freed. NULL returned if the + * value is not a tuple. + * + * @see cass_iterator_free() + */ +CASS_EXPORT CassIterator* +cass_iterator_from_tuple(const CassValue* value); + +/** + * Creates a new iterator for the specified user defined type. This can be + * used to iterate over fields in a user defined type. + * + * @cassandra{2.1+} + * + * @public @memberof CassValue + * + * @param[in] value + * @return A new iterator that must be freed. NULL returned if the + * value is not a user defined type. + * + * @see cass_iterator_free() + */ +CASS_EXPORT CassIterator* +cass_iterator_fields_from_user_type(const CassValue* value); + +/** + * Creates a new iterator for the specified schema metadata. + * This can be used to iterate over keyspace. + * + * @public @memberof CassSchemaMeta + * + * @param[in] schema_meta + * @return A new iterator that must be freed. + * + * @see cass_iterator_get_keyspace_meta() + * @see cass_iterator_free() + */ +CASS_EXPORT CassIterator* +cass_iterator_keyspaces_from_schema_meta(const CassSchemaMeta* schema_meta); + +/** + * Creates a new iterator for the specified keyspace metadata. + * This can be used to iterate over tables. + * + * @public @memberof CassKeyspaceMeta + * + * @param[in] keyspace_meta + * @return A new iterator that must be freed. + * + * @see cass_iterator_get_table_meta() + * @see cass_iterator_free() + */ +CASS_EXPORT CassIterator* +cass_iterator_tables_from_keyspace_meta(const CassKeyspaceMeta* keyspace_meta); + +/** + * Creates a new iterator for the specified keyspace metadata. + * This can be used to iterate over views. + * + * @cassandra{3.0+} + * + * @public @memberof CassKeyspaceMeta + * + * @param[in] keyspace_meta + * @return A new iterator that must be freed. + * + * @see cass_iterator_get_materialized_view_meta() + * @see cass_iterator_free() + */ +CASS_EXPORT CassIterator* +cass_iterator_materialized_views_from_keyspace_meta(const CassKeyspaceMeta* keyspace_meta); + +/** + * Creates a new iterator for the specified keyspace metadata. + * This can be used to iterate over types. + * + * @cassandra{2.1+} + * + * @public @memberof CassKeyspaceMeta + * + * @param[in] keyspace_meta + * @return A new iterator that must be freed. + * + * @see cass_iterator_get_user_type() + * @see cass_iterator_free() + */ +CASS_EXPORT CassIterator* +cass_iterator_user_types_from_keyspace_meta(const CassKeyspaceMeta* keyspace_meta); + +/** + * Creates a new iterator for the specified keyspace metadata. + * This can be used to iterate over functions. + * + * @cassandra{2.2+} + * + * @public @memberof CassKeyspaceMeta + * + * @param[in] keyspace_meta + * @return A new iterator that must be freed. + * + * @see cass_iterator_get_function_meta() + * @see cass_iterator_free() + */ +CASS_EXPORT CassIterator* +cass_iterator_functions_from_keyspace_meta(const CassKeyspaceMeta* keyspace_meta); + +/** + * Creates a new iterator for the specified keyspace metadata. + * This can be used to iterate over aggregates. + * + * @cassandra{2.2+} + * + * @public @memberof CassKeyspaceMeta + * + * @param[in] keyspace_meta + * @return A new iterator that must be freed. + * + * @see cass_iterator_get_aggregate_meta() + * @see cass_iterator_free() + */ +CASS_EXPORT CassIterator* +cass_iterator_aggregates_from_keyspace_meta(const CassKeyspaceMeta* keyspace_meta); + +/** + * Creates a new fields iterator for the specified keyspace metadata. Metadata + * fields allow direct access to the column data found in the underlying + * "keyspaces" metadata table. This can be used to iterate those metadata + * field entries. + * + * @public @memberof CassKeyspaceMeta + * + * @param[in] keyspace_meta + * @return A new iterator that must be freed. + * + * @see cass_iterator_get_meta_field_name() + * @see cass_iterator_get_meta_field_value() + * @see cass_iterator_free() + */ +CASS_EXPORT CassIterator* +cass_iterator_fields_from_keyspace_meta(const CassKeyspaceMeta* keyspace_meta); + +/** + * Creates a new iterator for the specified table metadata. + * This can be used to iterate over columns. + * + * @public @memberof CassTableMeta + * + * @param[in] table_meta + * @return A new iterator that must be freed. + * + * @see cass_iterator_get_column_meta() + * @see cass_iterator_free() + */ +CASS_EXPORT CassIterator* +cass_iterator_columns_from_table_meta(const CassTableMeta* table_meta); + +/** + * Creates a new iterator for the specified table metadata. + * This can be used to iterate over indexes. + * + * @public @memberof CassTableMeta + * + * @param[in] table_meta + * @return A new iterator that must be freed. + * + * @see cass_iterator_get_index_meta() + * @see cass_iterator_free() + */ +CASS_EXPORT CassIterator* +cass_iterator_indexes_from_table_meta(const CassTableMeta* table_meta); + +/** + * Creates a new iterator for the specified materialized view metadata. + * This can be used to iterate over columns. + * + * @cassandra{3.0+} + * + * @public @memberof CassTableMeta + * + * @param[in] table_meta + * @return A new iterator that must be freed. + * + * @see cass_iterator_get_materialized_view_meta() + * @see cass_iterator_free() + */ +CASS_EXPORT CassIterator* +cass_iterator_materialized_views_from_table_meta(const CassTableMeta* table_meta); + +/** + * Creates a new fields iterator for the specified table metadata. Metadata + * fields allow direct access to the column data found in the underlying + * "tables" metadata table. This can be used to iterate those metadata + * field entries. + * + * @public @memberof CassTableMeta + * + * @param[in] table_meta + * @return A new iterator that must be freed. + * + * @see cass_iterator_get_meta_field_name() + * @see cass_iterator_get_meta_field_value() + * @see cass_iterator_free() + */ +CASS_EXPORT CassIterator* +cass_iterator_fields_from_table_meta(const CassTableMeta* table_meta); + +/** + * Creates a new iterator for the specified materialized view metadata. + * This can be used to iterate over columns. + * + * @cassandra{3.0+} + * + * @public @memberof CassMaterializedViewMeta + * + * @param[in] view_meta + * @return A new iterator that must be freed. + * + * @see cass_iterator_get_column_meta() + * @see cass_iterator_free() + */ +CASS_EXPORT CassIterator* +cass_iterator_columns_from_materialized_view_meta(const CassMaterializedViewMeta* view_meta); + +/** + * Creates a new fields iterator for the specified materialized view metadata. + * Metadata fields allow direct access to the column data found in the + * underlying "views" metadata view. This can be used to iterate those metadata + * field entries. + * + * @cassandra{3.0+} + * + * @public @memberof CassMaterializedViewMeta + * + * @param[in] view_meta + * @return A new iterator that must be freed. + * + * @see cass_iterator_get_meta_field_name() + * @see cass_iterator_get_meta_field_value() + * @see cass_iterator_free() + */ +CASS_EXPORT CassIterator* +cass_iterator_fields_from_materialized_view_meta(const CassMaterializedViewMeta* view_meta); + +/** + * Creates a new fields iterator for the specified column metadata. Metadata + * fields allow direct access to the column data found in the underlying + * "columns" metadata table. This can be used to iterate those metadata + * field entries. + * + * @public @memberof CassColumnMeta + * + * @param[in] column_meta + * @return A new iterator that must be freed. + * + * @see cass_iterator_get_meta_field_name() + * @see cass_iterator_get_meta_field_value() + * @see cass_iterator_free() + */ +CASS_EXPORT CassIterator* +cass_iterator_fields_from_column_meta(const CassColumnMeta* column_meta); + +/** + * Creates a new fields iterator for the specified index metadata. Metadata + * fields allow direct access to the index data found in the underlying + * "indexes" metadata table. This can be used to iterate those metadata + * field entries. + * + * @public @memberof CassIndexMeta + * + * @param[in] index_meta + * @return A new iterator that must be freed. + * + * @see cass_iterator_get_meta_field_name() + * @see cass_iterator_get_meta_field_value() + * @see cass_iterator_free() + */ +CASS_EXPORT CassIterator* +cass_iterator_fields_from_index_meta(const CassIndexMeta* index_meta); + +/** + * Creates a new fields iterator for the specified function metadata. Metadata + * fields allow direct access to the column data found in the underlying + * "functions" metadata table. This can be used to iterate those metadata + * field entries. + * + * @cassandra{2.2+} + * + * @public @memberof CassFunctionMeta + * + * @param[in] function_meta + * @return A new iterator that must be freed. + * + * @see cass_iterator_get_meta_field() + * @see cass_iterator_free() + */ +CASS_EXPORT CassIterator* +cass_iterator_fields_from_function_meta(const CassFunctionMeta* function_meta); + +/** + * Creates a new fields iterator for the specified aggregate metadata. Metadata + * fields allow direct access to the column data found in the underlying + * "aggregates" metadata table. This can be used to iterate those metadata + * field entries. + * + * @cassandra{2.2+} + * + * @public @memberof CassAggregateMeta + * + * @param[in] aggregate_meta + * @return A new iterator that must be freed. + * + * @see cass_iterator_get_meta_field() + * @see cass_iterator_free() + */ +CASS_EXPORT CassIterator* +cass_iterator_fields_from_aggregate_meta(const CassAggregateMeta* aggregate_meta); + +/** + * Advance the iterator to the next row, column or collection item. + * + * @public @memberof CassIterator + * + * @param[in] iterator + * @return false if no more rows, columns or items, otherwise true + */ +CASS_EXPORT cass_bool_t +cass_iterator_next(CassIterator* iterator); + +/** + * Gets the row at the result iterator's current position. + * + * Calling cass_iterator_next() will invalidate the previous + * row returned by this method. + * + * @public @memberof CassIterator + * + * @param[in] iterator + * @return A row + */ +CASS_EXPORT const CassRow* +cass_iterator_get_row(const CassIterator* iterator); + +/** + * Gets the column value at the row iterator's current position. + * + * Calling cass_iterator_next() will invalidate the previous + * column returned by this method. + * + * @public @memberof CassIterator + * + * @param[in] iterator + * @return A value + */ +CASS_EXPORT const CassValue* +cass_iterator_get_column(const CassIterator* iterator); + +/** + * Gets the value at a collection or tuple iterator's current position. + * + * Calling cass_iterator_next() will invalidate the previous + * value returned by this method. + * + * @public @memberof CassIterator + * + * @param[in] iterator + * @return A value + */ +CASS_EXPORT const CassValue* +cass_iterator_get_value(const CassIterator* iterator); + +/** + * Gets the key at the map iterator's current position. + * + * Calling cass_iterator_next() will invalidate the previous + * value returned by this method. + * + * @public @memberof CassIterator + * + * @param[in] iterator + * @return A value + */ +CASS_EXPORT const CassValue* +cass_iterator_get_map_key(const CassIterator* iterator); + + +/** + * Gets the value at the map iterator's current position. + * + * Calling cass_iterator_next() will invalidate the previous + * value returned by this method. + * + * @public @memberof CassIterator + * + * @param[in] iterator + * @return A value + */ +CASS_EXPORT const CassValue* +cass_iterator_get_map_value(const CassIterator* iterator); + +/** + * Gets the field name at the user type defined iterator's current position. + * + * Calling cass_iterator_next() will invalidate the previous + * name returned by this method. + * + * @cassandra{2.1+} + * + * @public @memberof CassIterator + * + * @param[in] iterator + * @param[out] name + * @param[out] name_length + * @return CASS_OK if successful, otherwise error occurred + */ +CASS_EXPORT CassError +cass_iterator_get_user_type_field_name(const CassIterator* iterator, + const char** name, + size_t* name_length); + +/** + * Gets the field value at the user type defined iterator's current position. + * + * Calling cass_iterator_next() will invalidate the previous + * value returned by this method. + * + * @cassandra{2.1+} + * + * @public @memberof CassIterator + * + * @param[in] iterator + * @return A value + */ +CASS_EXPORT const CassValue* +cass_iterator_get_user_type_field_value(const CassIterator* iterator); + +/** + * Gets the keyspace metadata entry at the iterator's current position. + * + * Calling cass_iterator_next() will invalidate the previous + * value returned by this method. + * + * @public @memberof CassIterator + * + * @param[in] iterator + * @return A keyspace metadata entry + */ +CASS_EXPORT const CassKeyspaceMeta* +cass_iterator_get_keyspace_meta(const CassIterator* iterator); + +/** + * Gets the table metadata entry at the iterator's current position. + * + * Calling cass_iterator_next() will invalidate the previous + * value returned by this method. + * + * @public @memberof CassIterator + * + * @param[in] iterator + * @return A table metadata entry + */ +CASS_EXPORT const CassTableMeta* +cass_iterator_get_table_meta(const CassIterator* iterator); + +/** + * Gets the materialized view metadata entry at the iterator's current position. + * + * Calling cass_iterator_next() will invalidate the previous + * value returned by this method. + * + * @cassandra{3.0+} + * + * @public @memberof CassIterator + * + * @param[in] iterator + * @return A materialized view metadata entry + */ +CASS_EXPORT const CassMaterializedViewMeta* +cass_iterator_get_materialized_view_meta(const CassIterator* iterator); + +/** + * Gets the type metadata entry at the iterator's current position. + * + * Calling cass_iterator_next() will invalidate the previous + * value returned by this method. + * + * @cassandra{2.1+} + * + * @public @memberof CassIterator + * + * @param[in] iterator + * @return A type metadata entry + */ +CASS_EXPORT const CassDataType* +cass_iterator_get_user_type(const CassIterator* iterator); + +/** + * Gets the function metadata entry at the iterator's current position. + * + * Calling cass_iterator_next() will invalidate the previous + * value returned by this method. + * + * @cassandra{2.2+} + * + * @public @memberof CassIterator + * + * @param[in] iterator + * @return A function metadata entry + */ +CASS_EXPORT const CassFunctionMeta* +cass_iterator_get_function_meta(const CassIterator* iterator); + +/** + * Gets the aggregate metadata entry at the iterator's current position. + * + * Calling cass_iterator_next() will invalidate the previous + * value returned by this method. + * + * @cassandra{2.2+} + * + * @public @memberof CassIterator + * + * @param[in] iterator + * @return A aggregate metadata entry + */ +CASS_EXPORT const CassAggregateMeta* +cass_iterator_get_aggregate_meta(const CassIterator* iterator); + +/** + * Gets the column metadata entry at the iterator's current position. + * + * Calling cass_iterator_next() will invalidate the previous + * value returned by this method. + * + * @public @memberof CassIterator + * + * @param[in] iterator + * @return A column metadata entry + */ +CASS_EXPORT const CassColumnMeta* +cass_iterator_get_column_meta(const CassIterator* iterator); + +/** + * Gets the index metadata entry at the iterator's current position. + * + * Calling cass_iterator_next() will invalidate the previous + * value returned by this method. + * + * @public @memberof CassIterator + * + * @param[in] iterator + * @return A index metadata entry + */ +CASS_EXPORT const CassIndexMeta* +cass_iterator_get_index_meta(const CassIterator* iterator); + +/** + * Gets the metadata field name at the iterator's current position. + * + * Calling cass_iterator_next() will invalidate the previous + * value returned by this method. + * + * @public @memberof CassIterator + * + * @param[in] iterator + * @param[out] name + * @param[out] name_length + * @return CASS_OK if successful, otherwise error occurred + */ +CASS_EXPORT CassError +cass_iterator_get_meta_field_name(const CassIterator* iterator, + const char** name, + size_t* name_length); + +/** + * Gets the metadata field value at the iterator's current position. + * + * Calling cass_iterator_next() will invalidate the previous + * value returned by this method. + * + * @public @memberof CassIterator + * + * @param[in] iterator + * @return A metadata field value + */ +CASS_EXPORT const CassValue* +cass_iterator_get_meta_field_value(const CassIterator* iterator); + +/*********************************************************************************** + * + * Row + * + ***********************************************************************************/ + +/** + * Get the column value at index for the specified row. + * + * @public @memberof CassRow + * + * @param[in] row + * @param[in] index + * @return The column value at the specified index. NULL is + * returned if the index is out of bounds. + */ +CASS_EXPORT const CassValue* +cass_row_get_column(const CassRow* row, + size_t index); + + +/** + * Get the column value by name for the specified row. + * + * @public @memberof CassRow + * + * @param[in] row + * @param[in] name + * @return The column value for the specified name. NULL is + * returned if the column does not exist. + */ +CASS_EXPORT const CassValue* +cass_row_get_column_by_name(const CassRow* row, + const char* name); + +/** + * Same as cass_row_get_column_by_name(), but with lengths for string + * parameters. + * + * @public @memberof CassRow + * + * @param[in] row + * @param[in] name + * @param[in] name_length + * @return same as cass_row_get_column_by_name() + * + * @see cass_row_get_column_by_name() + */ +CASS_EXPORT const CassValue* +cass_row_get_column_by_name_n(const CassRow* row, + const char* name, + size_t name_length); + +/*********************************************************************************** + * + * Value + * + ***********************************************************************************/ + +/** + * Gets the data type of a value. + * + * @public @memberof CassValue + * + * @param[in] value + * @return Returns a reference to the data type of the value. + * Do not free this reference as it is bound to the lifetime of the value. + */ +CASS_EXPORT const CassDataType* +cass_value_data_type(const CassValue* value); + +/** + * Gets an int8 for the specified value. + * + * @cassandra{2.2+} + * + * @public @memberof CassValue + * + * @param[in] value + * @param[out] output + * @return CASS_OK if successful, otherwise error occurred + */ +CASS_EXPORT CassError +cass_value_get_int8(const CassValue* value, + cass_int8_t* output); + +/** + * Gets an int16 for the specified value. + * + * @cassandra{2.2+} + * + * @public @memberof CassValue + * + * @param[in] value + * @param[out] output + * @return CASS_OK if successful, otherwise error occurred + */ +CASS_EXPORT CassError +cass_value_get_int16(const CassValue* value, + cass_int16_t* output); + +/** + * Gets an int32 for the specified value. + * + * @public @memberof CassValue + * + * @param[in] value + * @param[out] output + * @return CASS_OK if successful, otherwise error occurred + */ +CASS_EXPORT CassError +cass_value_get_int32(const CassValue* value, + cass_int32_t* output); + +/** + * Gets an uint32 for the specified value. + * + * @cassandra{2.2+} + * + * @public @memberof CassValue + * + * @param[in] value + * @param[out] output + * @return CASS_OK if successful, otherwise error occurred + */ +CASS_EXPORT CassError +cass_value_get_uint32(const CassValue* value, + cass_uint32_t* output); + +/** + * Gets an int64 for the specified value. + * + * @public @memberof CassValue + * + * @param[in] value + * @param[out] output + * @return CASS_OK if successful, otherwise error occurred + */ +CASS_EXPORT CassError +cass_value_get_int64(const CassValue* value, + cass_int64_t* output); + +/** + * Gets a float for the specified value. + * + * @public @memberof CassValue + * + * @param[in] value + * @param[out] output + * @return CASS_OK if successful, otherwise error occurred + */ +CASS_EXPORT CassError +cass_value_get_float(const CassValue* value, + cass_float_t* output); + +/** + * Gets a double for the specified value. + * + * @public @memberof CassValue + * + * @param[in] value + * @param[out] output + * @return CASS_OK if successful, otherwise error occurred + */ +CASS_EXPORT CassError +cass_value_get_double(const CassValue* value, + cass_double_t* output); + +/** + * Gets a bool for the specified value. + * + * @public @memberof CassValue + * + * @param[in] value + * @param[out] output + * @return CASS_OK if successful, otherwise error occurred + */ +CASS_EXPORT CassError +cass_value_get_bool(const CassValue* value, + cass_bool_t* output); + +/** + * Gets a UUID for the specified value. + * + * @public @memberof CassValue + * + * @param[in] value + * @param[out] output + * @return CASS_OK if successful, otherwise error occurred + */ +CASS_EXPORT CassError +cass_value_get_uuid(const CassValue* value, + CassUuid* output); + +/** + * Gets an INET for the specified value. + * + * @public @memberof CassValue + * + * @param[in] value + * @param[out] output + * @return CASS_OK if successful, otherwise error occurred + */ +CASS_EXPORT CassError +cass_value_get_inet(const CassValue* value, + CassInet* output); + +/** + * Gets a string for the specified value. + * + * @public @memberof CassValue + * + * @param[in] value + * @param[out] output + * @param[out] output_size + * @return CASS_OK if successful, otherwise error occurred + */ +CASS_EXPORT CassError +cass_value_get_string(const CassValue* value, + const char** output, + size_t* output_size); + +/** + * Gets the bytes of the specified value. + * + * @public @memberof CassValue + * + * @param[in] value + * @param[out] output + * @param[out] output_size + * @return CASS_OK if successful, otherwise error occurred + */ +CASS_EXPORT CassError +cass_value_get_bytes(const CassValue* value, + const cass_byte_t** output, + size_t* output_size); + +/** + * Gets a decimal for the specified value. + * + * @public @memberof CassValue + * + * @param[in] value + * @param[out] varint + * @param[out] varint_size + * @param[out] scale + * @return CASS_OK if successful, otherwise error occurred + */ +CASS_EXPORT CassError +cass_value_get_decimal(const CassValue* value, + const cass_byte_t** varint, + size_t* varint_size, + cass_int32_t* scale); + +/** + * Gets a duration for the specified value. + * + * @cassandra{3.10+} + * + * @public @memberof CassValue + * + * @param[in] value + * @param[out] months + * @param[out] days + * @param[out] nanos + * @return CASS_OK if successful, otherwise error occurred + */ +CASS_EXPORT CassError +cass_value_get_duration(const CassValue* value, + cass_int32_t* months, + cass_int32_t* days, + cass_int64_t* nanos); + +/** + * Gets the type of the specified value. + * + * @public @memberof CassValue + * + * @param[in] value + * @return The type of the specified value. + */ +CASS_EXPORT CassValueType +cass_value_type(const CassValue* value); + +/** + * Returns true if a specified value is null. + * + * @public @memberof CassValue + * + * @param[in] value + * @return true if the value is null, otherwise false. + */ +CASS_EXPORT cass_bool_t +cass_value_is_null(const CassValue* value); + +/** + * Returns true if a specified value is a collection. + * + * @public @memberof CassValue + * + * @param[in] value + * @return true if the value is a collection, otherwise false. + */ +CASS_EXPORT cass_bool_t +cass_value_is_collection(const CassValue* value); + +/** + * Returns true if a specified value is a duration. + * + * @public @memberof CassValue + * + * @param[in] value + * @return true if the value is a duration, otherwise false. + */ +CASS_EXPORT cass_bool_t +cass_value_is_duration(const CassValue* value); + +/** + * Get the number of items in a collection. Works for all collection types. + * + * @public @memberof CassValue + * + * @param[in] collection + * @return Count of items in a collection. 0 if not a collection. + */ +CASS_EXPORT size_t +cass_value_item_count(const CassValue* collection); + +/** + * Get the primary sub-type for a collection. This returns the sub-type for a + * list or set and the key type for a map. + * + * @public @memberof CassValue + * + * @param[in] collection + * @return The type of the primary sub-type. CASS_VALUE_TYPE_UNKNOWN + * returned if not a collection. + */ +CASS_EXPORT CassValueType +cass_value_primary_sub_type(const CassValue* collection); + +/** + * Get the secondary sub-type for a collection. This returns the value type for a + * map. + * + * @public @memberof CassValue + * + * @param[in] collection + * @return The type of the primary sub-type. CASS_VALUE_TYPE_UNKNOWN + * returned if not a collection or not a map. + */ +CASS_EXPORT CassValueType +cass_value_secondary_sub_type(const CassValue* collection); + + +/*********************************************************************************** + * + * UUID + * + ************************************************************************************/ + +/** + * Creates a new UUID generator. + * + * Note: This object is thread-safe. It is best practice to create and reuse + * a single object per application. + * + * Note: If unique node information (IP address) is unable to be determined + * then random node information will be generated. + * + * @public @memberof CassUuidGen + * + * @return Returns a UUID generator that must be freed. + * + * @see cass_uuid_gen_free() + * @see cass_uuid_gen_new_with_node() + */ +CASS_EXPORT CassUuidGen* +cass_uuid_gen_new(); + +/** + * Creates a new UUID generator with custom node information. + * + * Note: This object is thread-safe. It is best practice to create and reuse + * a single object per application. + * + * @public @memberof CassUuidGen + * + * @return Returns a UUID generator that must be freed. + * + * @see cass_uuid_gen_free() + */ +CASS_EXPORT CassUuidGen* +cass_uuid_gen_new_with_node(cass_uint64_t node); + +/** + * Frees a UUID generator instance. + * + * @public @memberof CassUuidGen + * + * @param[in] uuid_gen + */ +CASS_EXPORT void +cass_uuid_gen_free(CassUuidGen* uuid_gen); + +/** + * Generates a V1 (time) UUID. + * + * Note: This method is thread-safe + * + * @public @memberof CassUuidGen + * + * @param[in] uuid_gen + * @param[out] output A V1 UUID for the current time. + */ +CASS_EXPORT void +cass_uuid_gen_time(CassUuidGen* uuid_gen, + CassUuid* output); + +/** + * Generates a new V4 (random) UUID + * + * Note:: This method is thread-safe + * + * @public @memberof CassUuidGen + * + * @param[in] uuid_gen + * @param output A randomly generated V4 UUID. + */ +CASS_EXPORT void +cass_uuid_gen_random(CassUuidGen* uuid_gen, + CassUuid* output); + +/** + * Generates a V1 (time) UUID for the specified time. + * + * Note:: This method is thread-safe + * + * @public @memberof CassUuidGen + * + * @param[in] uuid_gen + * @param[in] timestamp + * @param[out] output A V1 UUID for the specified time. + */ +CASS_EXPORT void +cass_uuid_gen_from_time(CassUuidGen* uuid_gen, + cass_uint64_t timestamp, + CassUuid* output); + +/** + * Sets the UUID to the minimum V1 (time) value for the specified time. + * + * @public @memberof CassUuid + * + * @param[in] time + * @param[out] output A minimum V1 UUID for the specified time. + */ +CASS_EXPORT void +cass_uuid_min_from_time(cass_uint64_t time, + CassUuid* output); + +/** + * Sets the UUID to the maximum V1 (time) value for the specified time. + * + * @public @memberof CassUuid + * + * @param[in] time + * @param[out] output A maximum V1 UUID for the specified time. + */ +CASS_EXPORT void +cass_uuid_max_from_time(cass_uint64_t time, + CassUuid* output); + +/** + * Gets the timestamp for a V1 UUID + * + * @public @memberof CassUuid + * + * @param[in] uuid + * @return The timestamp in milliseconds since the Epoch + * (00:00:00 UTC on 1 January 1970). 0 returned if the UUID + * is not V1. + */ +CASS_EXPORT cass_uint64_t +cass_uuid_timestamp(CassUuid uuid); + +/** + * Gets the version for a UUID + * + * @public @memberof CassUuid + * + * @param[in] uuid + * @return The version of the UUID (1 or 4) + */ +CASS_EXPORT cass_uint8_t +cass_uuid_version(CassUuid uuid); + +/** + * Returns a null-terminated string for the specified UUID. + * + * @public @memberof CassUuid + * + * @param[in] uuid + * @param[out] output A null-terminated string of length CASS_UUID_STRING_LENGTH. + */ +CASS_EXPORT void +cass_uuid_string(CassUuid uuid, + char* output); + +/** + * Returns a UUID for the specified string. + * + * Example: "550e8400-e29b-41d4-a716-446655440000" + * + * @public @memberof CassUuid + * + * @param[in] str + * @param[out] output + */ +CASS_EXPORT CassError +cass_uuid_from_string(const char* str, + CassUuid* output); + +/** + * Same as cass_uuid_from_string(), but with lengths for string + * parameters. + * + * @public @memberof CassUuid + * + * @param[in] str + * @param[in] str_length + * @param[out] output + * @return same as cass_uuid_from_string() + * + * @see cass_uuid_from_string() + */ +CASS_EXPORT CassError +cass_uuid_from_string_n(const char* str, + size_t str_length, + CassUuid* output); + +/*********************************************************************************** + * + * Timestamp generators + * + ***********************************************************************************/ + +/** + * Creates a new server-side timestamp generator. This generator allows Cassandra + * to assign timestamps server-side. + * + * Note: This is the default timestamp generator. + * + * @cassandra{2.1+} + * + * @public @memberof CassTimestampGen + * + * @return Returns a timestamp generator that must be freed. + * + * @see cass_timestamp_gen_free() + */ +CASS_EXPORT CassTimestampGen* +cass_timestamp_gen_server_side_new(); + +/** + * Creates a new monotonically increasing timestamp generator with microsecond + * precision. + * + * This implementation guarantees a monotonically increasing timestamp. If the + * timestamp generation rate exceeds one per microsecond or if the clock skews + * into the past the generator will artificially increment the previously + * generated timestamp until the request rate decreases or the clock skew + * is corrected. + * + * By default, this timestamp generator will generate warnings if more than + * 1 second of clock skew is detected. It will print an error every second until + * the clock skew is resolved. These settings can be changed by using + * `cass_timestamp_gen_monotonic_new_with_settings()` to create the generator + * instance. + * + * Note: This generator is thread-safe and can be shared by multiple + * sessions. + * + * @cassandra{2.1+} + * + * @public @memberof CassTimestampGen + * + * @return Returns a timestamp generator that must be freed. + * + * @see cass_timestamp_gen_monotonic_new_with_settings(); + * @see cass_timestamp_gen_free() + */ +CASS_EXPORT CassTimestampGen* +cass_timestamp_gen_monotonic_new(); + +/** + * Same as cass_timestamp_gen_monotonic_new(), but with settings for controlling + * warnings about clock skew. + * + * @param warning_threshold_us The amount of clock skew, in microseconds, that + * must be detected before a warning is triggered. A threshold less than 0 can + * be used to disable warnings. + * @param warning_interval_ms The amount of time, in milliseconds, to wait before + * warning again about clock skew. An interval value less than or equal to 0 allows + * the warning to be triggered every millisecond. + * @return Returns a timestamp generator that must be freed. + */ +CASS_EXPORT CassTimestampGen* +cass_timestamp_gen_monotonic_new_with_settings(cass_int64_t warning_threshold_us, + cass_int64_t warning_interval_ms); + +/** + * Frees a timestamp generator instance. + * + * @cassandra{2.1+} + * + * @public @memberof CassTimestampGen + * + * @param[in] timestamp_gen + */ +CASS_EXPORT void +cass_timestamp_gen_free(CassTimestampGen* timestamp_gen); + + +/*********************************************************************************** + * + * Retry policies + * + ***********************************************************************************/ + +/** + * Creates a new default retry policy. + * + * This policy retries queries in the following cases: + *
    + *
  • On a read timeout, if enough replicas replied but data was not received.
  • + *
  • On a write timeout, if a timeout occurs while writing the distributed batch log
  • + *
  • On unavailable, it will move to the next host
  • + *
+ * + * In all other cases the error will be returned. + * + * This policy always uses the query's original consistency level. + * + * @public @memberof CassRetryPolicy + * + * @return Returns a retry policy that must be freed. + * + * @see cass_retry_policy_free() + */ +CASS_EXPORT CassRetryPolicy* +cass_retry_policy_default_new(); + +/** + * Creates a new downgrading consistency retry policy. + * + * Important: This policy may attempt to retry requests with a lower + * consistency level. Using this policy can break consistency guarantees. + * + * This policy will retry in the same scenarios as the default policy, but + * it will also retry in the following cases: + *
    + *
  • On a read timeout, if some replicas responded but is lower than + * required by the current consistency level then retry with a lower + * consistency level.
  • + *
  • On a write timeout, Retry unlogged batches at a lower consistency level + * if at least one replica responded. For single queries and batch if any + * replicas responded then consider the request successful and swallow the + * error.
  • + *
  • On unavailable, retry at a lower consistency if at lease one replica + * responded.
  • + *
+ * + * This goal of this policy is to attempt to save a request if there's any + * chance of success. A writes succeeds as long as there's a single copy + * persisted and a read will succeed if there's some data available even + * if it increases the risk of reading stale data. + * + * @deprecated This still works, but should not be used in new applications. It + * can lead to unexpected behavior when the cluster is in a degraded state. + * Instead, applications should prefer using the lowest consistency level on + * statements that can be tolerated by a specific use case. + * + * @public @memberof CassRetryPolicy + * + * @return Returns a retry policy that must be freed. + * + * @see cass_retry_policy_free() + */ +CASS_EXPORT CASS_DEPRECATED(CassRetryPolicy* +cass_retry_policy_downgrading_consistency_new()); + +/** + * Creates a new fallthrough retry policy. + * + * This policy never retries or ignores a server-side failure. The error + * is always returned. + * + * @public @memberof CassRetryPolicy + * + * @return Returns a retry policy that must be freed. + * + * @see cass_retry_policy_free() + */ +CASS_EXPORT CassRetryPolicy* +cass_retry_policy_fallthrough_new(); + +/** + * Creates a new logging retry policy. + * + * This policy logs the retry decision of its child policy. Logging is + * done using CASS_LOG_INFO. + * + * @public @memberof CassRetryPolicy + * + * @param[in] child_retry_policy + * @return Returns a retry policy that must be freed. NULL is returned if + * the child_policy is a logging retry policy. + * + * @see cass_retry_policy_free() + */ +CASS_EXPORT CassRetryPolicy* +cass_retry_policy_logging_new(CassRetryPolicy* child_retry_policy); + +/** + * Frees a retry policy instance. + * + * @public @memberof CassRetryPolicy + * + * @param[in] policy + */ +CASS_EXPORT void +cass_retry_policy_free(CassRetryPolicy* policy); + +/*********************************************************************************** + * + * Custom payload + * + ***********************************************************************************/ + +/** + * Creates a new custom payload. + * + * @public @memberof CassCustomPayload + * + * @cassandra{2.2+} + * + * @return Returns a custom payload that must be freed. + * + * @see cass_custom_payload_free() + */ +CASS_EXPORT CassCustomPayload* +cass_custom_payload_new(); + +/** + * Frees a custom payload instance. + * + * @cassandra{2.2+} + * + * @public @memberof CassCustomPayload + * + * @param[in] payload + */ +CASS_EXPORT void +cass_custom_payload_free(CassCustomPayload* payload); + +/** + * Sets an item to the custom payload. + * + * @cassandra{2.2+} + * + * @public @memberof CassCustomPayload + * + * @param[in] payload + * @param[in] name + * @param[in] value + * @param[in] value_size + */ +CASS_EXPORT void +cass_custom_payload_set(CassCustomPayload* payload, + const char* name, + const cass_byte_t* value, + size_t value_size); + +/** + * Same as cass_custom_payload_set(), but with lengths for string + * parameters. + * + * @cassandra{2.2+} + * + * @public @memberof CassCustomPayload + * + * @param[in] payload + * @param[in] name + * @param[in] name_length + * @param[in] value + * @param[in] value_size + */ +CASS_EXPORT void +cass_custom_payload_set_n(CassCustomPayload* payload, + const char* name, + size_t name_length, + const cass_byte_t* value, + size_t value_size); + +/** + * Removes an item from the custom payload. + * + * @cassandra{2.2+} + * + * @public @memberof CassCustomPayload + * + * @param[in] payload + * @param[in] name + */ +CASS_EXPORT void +cass_custom_payload_remove(CassCustomPayload* payload, + const char* name); + +/** + * Same as cass_custom_payload_set(), but with lengths for string + * parameters. + * + * @cassandra{2.2+} + * + * @public @memberof CassCustomPayload + * + * @param[in] payload + * @param[in] name + * @param[in] name_length + */ +CASS_EXPORT void +cass_custom_payload_remove_n(CassCustomPayload* payload, + const char* name, + size_t name_length); + + +/*********************************************************************************** + * + * Consistency + * + ***********************************************************************************/ + +/** + * Gets the string for a consistency. + * + * @param[in] consistency + * @return A null-terminated string for the consistency. + * Example: "ALL", "ONE", "QUORUM", etc. + */ +CASS_EXPORT const char* +cass_consistency_string(CassConsistency consistency); + +/*********************************************************************************** + * + * Write type + * + ***********************************************************************************/ +/** + * Gets the string for a write type. + * + * @param[in] write_type + * @return A null-terminated string for the write type. + * Example: "BATCH", "SIMPLE", "COUNTER", etc. + */ +CASS_EXPORT const char* +cass_write_type_string(CassWriteType write_type); + +/*********************************************************************************** + * + * Error + * + ***********************************************************************************/ + +/** + * Gets a description for an error code. + * + * @param[in] error + * @return A null-terminated string describing the error. + */ +CASS_EXPORT const char* +cass_error_desc(CassError error); + +/*********************************************************************************** + * + * Log + * + ***********************************************************************************/ + +/** + * Explicitly wait for the log to flush and deallocate resources. + * This *MUST* be the last call using the library. It is an error + * to call any cass_*() functions after this call. + * + * @deprecated This is no longer useful and does nothing. Expect this to be + * removed in a future release. + */ +CASS_EXPORT CASS_DEPRECATED(void +cass_log_cleanup()); + +/** + * Sets the log level. + * + * Note: This needs to be done before any call that might log, such as + * any of the cass_cluster_*() or cass_ssl_*() functions. + * + * Default: CASS_LOG_WARN + * + * @param[in] log_level + */ +CASS_EXPORT void +cass_log_set_level(CassLogLevel log_level); + +/** + * Sets a callback for handling logging events. + * + * Note: This needs to be done before any call that might log, such as + * any of the cass_cluster_*() or cass_ssl_*() functions. + * + * Default: An internal callback that prints to stderr + * + * @param[in] data An opaque data object passed to the callback. + * @param[in] callback A callback that handles logging events. This is + * called in a separate thread so access to shared data must be synchronized. + */ +CASS_EXPORT void +cass_log_set_callback(CassLogCallback callback, + void* data); + +/** + * Sets the log queue size. + * + * Note: This needs to be done before any call that might log, such as + * any of the cass_cluster_*() or cass_ssl_*() functions. + * + * Default: 2048 + * + * @deprecated This is no longer useful and does nothing. Expect this to be + * removed in a future release. + * + * @param[in] queue_size + */ +CASS_EXPORT CASS_DEPRECATED(void +cass_log_set_queue_size(size_t queue_size)); + +/** + * Gets the string for a log level. + * + * @param[in] log_level + * @return A null-terminated string for the log level. + * Example: "ERROR", "WARN", "INFO", etc. + */ +CASS_EXPORT const char* +cass_log_level_string(CassLogLevel log_level); + +/*********************************************************************************** + * + * Inet + * + ************************************************************************************/ + +/** + * Constructs an inet v4 object. + * + * @public @memberof CassInet + * + * @param[in] address An address of size CASS_INET_V4_LENGTH + * @return An inet object. + */ +CASS_EXPORT CassInet +cass_inet_init_v4(const cass_uint8_t* address); + +/** + * Constructs an inet v6 object. + * + * @public @memberof CassInet + * + * @param[in] address An address of size CASS_INET_V6_LENGTH + * @return An inet object. + */ +CASS_EXPORT CassInet +cass_inet_init_v6(const cass_uint8_t* address); + +/** + * Returns a null-terminated string for the specified inet. + * + * @public @memberof CassInet + * + * @param[in] inet + * @param[out] output A null-terminated string of length CASS_INET_STRING_LENGTH. + */ +CASS_EXPORT void +cass_inet_string(CassInet inet, + char* output); + +/** + * Returns an inet for the specified string. + * + * Examples: "127.0.0.1" or "::1" + * + * @public @memberof CassInet + * + * @param[in] str + * @param[out] output + */ +CASS_EXPORT CassError +cass_inet_from_string(const char* str, + CassInet* output); + +/** + * Same as cass_inet_from_string(), but with lengths for string + * parameters. + * + * @public @memberof CassInet + * + * @param[in] str + * @param[in] str_length + * @param[out] output + * @return same as cass_inet_from_string() + * + * @see cass_inet_from_string() + */ +CASS_EXPORT CassError +cass_inet_from_string_n(const char* str, + size_t str_length, + CassInet* output); + +/*********************************************************************************** + * + * Date/Time + * + ************************************************************************************/ + +/** + * Converts a unix timestamp (in seconds) to the Cassandra "date" type. The "date" type + * represents the number of days since the Epoch (1970-01-01) with the Epoch centered at + * the value 2^31. + * + * @cassandra{2.2+} + * + * @param[in] epoch_secs + * @return the number of days since the date -5877641-06-23 + */ +CASS_EXPORT cass_uint32_t +cass_date_from_epoch(cass_int64_t epoch_secs); + +/** + * Converts a unix timestamp (in seconds) to the Cassandra "time" type. The "time" type + * represents the number of nanoseconds since midnight (range 0 to 86399999999999). + * + * @cassandra{2.2+} + * + * @param[in] epoch_secs + * @return nanoseconds since midnight + */ +CASS_EXPORT cass_int64_t +cass_time_from_epoch(cass_int64_t epoch_secs); + +/** + * Combines the Cassandra "date" and "time" types to Epoch time in seconds. + * + * @cassandra{2.2+} + * + * @param[in] date + * @param[in] time + * @return Epoch time in seconds. Negative times are possible if the date + * occurs before the Epoch (1970-1-1). + */ +CASS_EXPORT cass_int64_t +cass_date_time_to_epoch(cass_uint32_t date, + cass_int64_t time); + +/*********************************************************************************** + * + * Allocator + * + ************************************************************************************/ + +/** + * Set custom allocation functions. + * + * Note: This is not thread-safe. The allocation functions must be set + * before any other library function is called. + * + * Default: The C runtime's malloc(), realloc() and free() + * + * Important: The C runtime's malloc(), realloc() and free() will be + * used by libuv when using versions 1.5 or earlier. + * + * @param[in] malloc_func + * @param[in] realloc_func + * @param[in] free_func + */ +CASS_EXPORT void +cass_alloc_set_functions(CassMallocFunction malloc_func, + CassReallocFunction realloc_func, + CassFreeFunction free_func); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* __CASS_H_INCLUDED__ */ diff --git a/Plugins/CassandraDriverPlugin/CCassandra/module.modulemap b/Plugins/CassandraDriverPlugin/CCassandra/module.modulemap new file mode 100644 index 000000000..18c490824 --- /dev/null +++ b/Plugins/CassandraDriverPlugin/CCassandra/module.modulemap @@ -0,0 +1,4 @@ +module CCassandra [system] { + header "CCassandra.h" + export * +} diff --git a/Plugins/CassandraDriverPlugin/CassandraPlugin.swift b/Plugins/CassandraDriverPlugin/CassandraPlugin.swift new file mode 100644 index 000000000..3fb9083ed --- /dev/null +++ b/Plugins/CassandraDriverPlugin/CassandraPlugin.swift @@ -0,0 +1,1034 @@ +// +// CassandraPlugin.swift +// TablePro +// +// Cassandra/ScyllaDB database driver plugin using the DataStax C driver. +// Provides CQL query execution and schema introspection via system_schema tables. +// + +#if canImport(CCassandra) +import CCassandra +#endif +import Foundation +import os +import TableProPluginKit + +// MARK: - Plugin Entry Point + +final class CassandraPlugin: NSObject, TableProPlugin, DriverPlugin { + static let pluginName = "Cassandra Driver" + static let pluginVersion = "1.0.0" + static let pluginDescription = "Apache Cassandra and ScyllaDB support via DataStax C driver" + static let capabilities: [PluginCapability] = [.databaseDriver] + + static let databaseTypeId = "Cassandra" + static let databaseDisplayName = "Cassandra / ScyllaDB" + static let iconName = "cassandra-icon" + static let defaultPort = 9042 + static let additionalConnectionFields: [ConnectionField] = [] + static let additionalDatabaseTypeIds: [String] = [] + + func createDriver(config: DriverConnectionConfig) -> any PluginDatabaseDriver { + CassandraPluginDriver(config: config) + } +} + +// MARK: - Connection Actor + +private actor CassandraConnectionActor { + private static let logger = Logger(subsystem: "com.TablePro.CassandraDriver", category: "Connection") + + private var cluster: OpaquePointer? // CassCluster* + private var session: OpaquePointer? // CassSession* + private var currentKeyspace: String? + + var isConnected: Bool { session != nil } + + var keyspace: String? { currentKeyspace } + + func connect( + host: String, + port: Int, + username: String?, + password: String?, + keyspace: String?, + sslEnabled: Bool, + sslCaCertPath: String? + ) throws { + cluster = cass_cluster_new() + guard let cluster else { + throw CassandraPluginError.connectionFailed("Failed to create cluster object") + } + + cass_cluster_set_contact_points(cluster, host) + cass_cluster_set_port(cluster, Int32(port)) + + if let username, !username.isEmpty, let password { + cass_cluster_set_credentials(cluster, username, password) + } + + // SSL/TLS + if sslEnabled { + let ssl = cass_ssl_new() + cass_ssl_set_verify_flags(ssl, Int32(CASS_SSL_VERIFY_PEER_CERT.rawValue)) + + if let caCertPath = sslCaCertPath, !caCertPath.isEmpty, + let certData = FileManager.default.contents(atPath: caCertPath), + let certString = String(data: certData, encoding: .utf8) { + cass_ssl_add_trusted_cert(ssl, certString) + } else { + // No verification if no CA cert provided + cass_ssl_set_verify_flags(ssl, Int32(CASS_SSL_VERIFY_NONE.rawValue)) + } + + cass_cluster_set_ssl(cluster, ssl) + cass_ssl_free(ssl) + } + + // Connection timeout (10 seconds) + cass_cluster_set_connect_timeout(cluster, 10_000) + cass_cluster_set_request_timeout(cluster, 30_000) + + let newSession = cass_session_new() + guard let newSession else { + cass_cluster_free(cluster) + self.cluster = nil + throw CassandraPluginError.connectionFailed("Failed to create session") + } + + let connectFuture: OpaquePointer? + if let keyspace, !keyspace.isEmpty { + connectFuture = cass_session_connect_keyspace(newSession, cluster, keyspace) + currentKeyspace = keyspace + } else { + connectFuture = cass_session_connect(newSession, cluster) + currentKeyspace = nil + } + + guard let future = connectFuture else { + cass_session_free(newSession) + cass_cluster_free(cluster) + self.cluster = nil + throw CassandraPluginError.connectionFailed("Failed to initiate connection") + } + + cass_future_wait(future) + let rc = cass_future_error_code(future) + + if rc != CASS_OK { + let errorMessage = extractFutureError(future) + cass_future_free(future) + cass_session_free(newSession) + cass_cluster_free(cluster) + self.cluster = nil + throw CassandraPluginError.connectionFailed(errorMessage) + } + + cass_future_free(future) + session = newSession + + Self.logger.info("Connected to Cassandra at \(host):\(port)") + } + + func close() { + if let session { + let closeFuture = cass_session_close(session) + if let closeFuture { + cass_future_wait(closeFuture) + cass_future_free(closeFuture) + } + cass_session_free(session) + self.session = nil + } + + if let cluster { + cass_cluster_free(cluster) + self.cluster = nil + } + + currentKeyspace = nil + Self.logger.info("Disconnected from Cassandra") + } + + func executeQuery(_ cql: String) throws -> CassandraRawResult { + guard let session else { + throw CassandraPluginError.notConnected + } + + let startTime = Date() + let statement = cass_statement_new(cql, 0) + guard let statement else { + throw CassandraPluginError.queryFailed("Failed to create statement") + } + + defer { cass_statement_free(statement) } + + let future = cass_session_execute(session, statement) + guard let future else { + throw CassandraPluginError.queryFailed("Failed to execute query") + } + + defer { cass_future_free(future) } + + cass_future_wait(future) + let rc = cass_future_error_code(future) + + if rc != CASS_OK { + throw CassandraPluginError.queryFailed(extractFutureError(future)) + } + + let result = cass_future_get_result(future) + defer { + if let result { cass_result_free(result) } + } + + guard let result else { + let executionTime = Date().timeIntervalSince(startTime) + return CassandraRawResult( + columns: [], + columnTypeNames: [], + rows: [], + rowsAffected: 0, + executionTime: executionTime + ) + } + + return extractResult(from: result, startTime: startTime) + } + + func executePrepared(_ cql: String, parameters: [String?]) throws -> CassandraRawResult { + guard let session else { + throw CassandraPluginError.notConnected + } + + let startTime = Date() + + // Prepare + let prepareFuture = cass_session_prepare(session, cql) + guard let prepareFuture else { + throw CassandraPluginError.queryFailed("Failed to prepare statement") + } + defer { cass_future_free(prepareFuture) } + + cass_future_wait(prepareFuture) + let prepRc = cass_future_error_code(prepareFuture) + if prepRc != CASS_OK { + throw CassandraPluginError.queryFailed(extractFutureError(prepareFuture)) + } + + let prepared = cass_future_get_prepared(prepareFuture) + guard let prepared else { + throw CassandraPluginError.queryFailed("Failed to get prepared statement") + } + defer { cass_prepared_free(prepared) } + + // Bind parameters + let statement = cass_prepared_bind(prepared) + guard let statement else { + throw CassandraPluginError.queryFailed("Failed to bind prepared statement") + } + defer { cass_statement_free(statement) } + + for (index, param) in parameters.enumerated() { + if let value = param { + cass_statement_bind_string(statement, index, value) + } else { + cass_statement_bind_null(statement, index) + } + } + + // Execute + let future = cass_session_execute(session, statement) + guard let future else { + throw CassandraPluginError.queryFailed("Failed to execute prepared statement") + } + defer { cass_future_free(future) } + + cass_future_wait(future) + let rc = cass_future_error_code(future) + + if rc != CASS_OK { + throw CassandraPluginError.queryFailed(extractFutureError(future)) + } + + let result = cass_future_get_result(future) + defer { + if let result { cass_result_free(result) } + } + + guard let result else { + let executionTime = Date().timeIntervalSince(startTime) + return CassandraRawResult( + columns: [], + columnTypeNames: [], + rows: [], + rowsAffected: 0, + executionTime: executionTime + ) + } + + return extractResult(from: result, startTime: startTime) + } + + func switchKeyspace(_ keyspace: String) throws { + _ = try executeQuery("USE \"\(escapeIdentifier(keyspace))\"") + currentKeyspace = keyspace + } + + func serverVersion() throws -> String? { + let result = try executeQuery("SELECT release_version FROM system.local WHERE key = 'local'") + return result.rows.first?.first ?? nil + } + + // MARK: - Private Helpers + + private func extractResult( + from result: OpaquePointer, + startTime: Date + ) -> CassandraRawResult { + let colCount = cass_result_column_count(result) + let rowCount = cass_result_row_count(result) + + var columns: [String] = [] + var columnTypeNames: [String] = [] + + for i in 0..? + var nameLength: Int = 0 + cass_result_column_name(result, i, &namePtr, &nameLength) + if let namePtr { + columns.append(String(cString: namePtr)) + } else { + columns.append("column_\(i)") + } + + let colType = cass_result_column_type(result, i) + columnTypeNames.append(Self.cassTypeName(colType)) + } + + var rows: [[String?]] = [] + let iterator = cass_iterator_from_result(result) + defer { + if let iterator { cass_iterator_free(iterator) } + } + + guard let iterator else { + let executionTime = Date().timeIntervalSince(startTime) + return CassandraRawResult( + columns: columns, + columnTypeNames: columnTypeNames, + rows: [], + rowsAffected: Int(rowCount), + executionTime: executionTime + ) + } + + let maxRows = min(Int(rowCount), 100_000) + var count = 0 + + while cass_iterator_next(iterator) == cass_true && count < maxRows { + let row = cass_iterator_get_row(iterator) + guard let row else { continue } + + var rowData: [String?] = [] + for col in 0.. String? { + let valueType = cass_value_type(value) + + switch valueType { + case CASS_VALUE_TYPE_ASCII, CASS_VALUE_TYPE_TEXT, CASS_VALUE_TYPE_VARCHAR: + var output: UnsafePointer? + var outputLength: Int = 0 + let rc = cass_value_get_string(value, &output, &outputLength) + if rc == CASS_OK, let output { + return String( + bytesNoCopy: UnsafeMutableRawPointer(mutating: output), + length: outputLength, + encoding: .utf8, + freeWhenDone: false + ) + } + return nil + + case CASS_VALUE_TYPE_INT: + var intVal: Int32 = 0 + if cass_value_get_int32(value, &intVal) == CASS_OK { + return String(intVal) + } + return nil + + case CASS_VALUE_TYPE_BIGINT, CASS_VALUE_TYPE_COUNTER: + var bigintVal: Int64 = 0 + if cass_value_get_int64(value, &bigintVal) == CASS_OK { + return String(bigintVal) + } + return nil + + case CASS_VALUE_TYPE_SMALL_INT: + var smallVal: Int16 = 0 + if cass_value_get_int16(value, &smallVal) == CASS_OK { + return String(smallVal) + } + return nil + + case CASS_VALUE_TYPE_TINY_INT: + var tinyVal: Int8 = 0 + if cass_value_get_int8(value, &tinyVal) == CASS_OK { + return String(tinyVal) + } + return nil + + case CASS_VALUE_TYPE_FLOAT: + var floatVal: Float = 0 + if cass_value_get_float(value, &floatVal) == CASS_OK { + return String(floatVal) + } + return nil + + case CASS_VALUE_TYPE_DOUBLE: + var doubleVal: Double = 0 + if cass_value_get_double(value, &doubleVal) == CASS_OK { + return String(doubleVal) + } + return nil + + case CASS_VALUE_TYPE_BOOLEAN: + var boolVal: cass_bool_t = cass_false + if cass_value_get_bool(value, &boolVal) == CASS_OK { + return boolVal == cass_true ? "true" : "false" + } + return nil + + case CASS_VALUE_TYPE_UUID, CASS_VALUE_TYPE_TIMEUUID: + var uuid = CassUuid() + if cass_value_get_uuid(value, &uuid) == CASS_OK { + var buffer = [CChar](repeating: 0, count: Int(CASS_UUID_STRING_LENGTH)) + cass_uuid_string(uuid, &buffer) + return String(cString: buffer) + } + return nil + + case CASS_VALUE_TYPE_TIMESTAMP: + var timestamp: Int64 = 0 + if cass_value_get_int64(value, ×tamp) == CASS_OK { + let date = Date(timeIntervalSince1970: Double(timestamp) / 1000.0) + let formatter = ISO8601DateFormatter() + formatter.formatOptions = [.withInternetDateTime, .withFractionalSeconds] + return formatter.string(from: date) + } + return nil + + case CASS_VALUE_TYPE_BLOB: + var bytes: UnsafePointer? + var length: Int = 0 + if cass_value_get_bytes(value, &bytes, &length) == CASS_OK, let bytes { + let data = Data(bytes: bytes, count: length) + return "0x" + data.map { String(format: "%02x", $0) }.joined() + } + return nil + + case CASS_VALUE_TYPE_INET: + var inet = CassInet() + if cass_value_get_inet(value, &inet) == CASS_OK { + var buffer = [CChar](repeating: 0, count: Int(CASS_INET_STRING_LENGTH)) + cass_inet_string(inet, &buffer) + return String(cString: buffer) + } + return nil + + case CASS_VALUE_TYPE_LIST, CASS_VALUE_TYPE_SET: + return extractCollectionString(value, open: "[", close: "]") + + case CASS_VALUE_TYPE_MAP: + return extractMapString(value) + + case CASS_VALUE_TYPE_TUPLE: + return extractCollectionString(value, open: "(", close: ")") + + default: + // Fallback: try reading as string + var output: UnsafePointer? + var outputLength: Int = 0 + if cass_value_get_string(value, &output, &outputLength) == CASS_OK, let output { + return String( + bytesNoCopy: UnsafeMutableRawPointer(mutating: output), + length: outputLength, + encoding: .utf8, + freeWhenDone: false + ) + } + return "" + } + } + + private static func extractCollectionString( + _ value: OpaquePointer, + open: String, + close: String + ) -> String { + guard let iterator = cass_iterator_from_collection(value) else { + return "\(open)\(close)" + } + defer { cass_iterator_free(iterator) } + + var elements: [String] = [] + while cass_iterator_next(iterator) == cass_true { + if let elem = cass_iterator_get_value(iterator) { + elements.append(extractStringValue(elem) ?? "null") + } + } + return "\(open)\(elements.joined(separator: ", "))\(close)" + } + + private static func extractMapString(_ value: OpaquePointer) -> String { + guard let iterator = cass_iterator_from_map(value) else { + return "{}" + } + defer { cass_iterator_free(iterator) } + + var pairs: [String] = [] + while cass_iterator_next(iterator) == cass_true { + let key = cass_iterator_get_map_key(iterator) + let val = cass_iterator_get_map_value(iterator) + let keyStr = key.flatMap { extractStringValue($0) } ?? "null" + let valStr = val.flatMap { extractStringValue($0) } ?? "null" + pairs.append("\(keyStr): \(valStr)") + } + return "{\(pairs.joined(separator: ", "))}" + } + + private static func cassTypeName(_ type: CassValueType) -> String { + switch type { + case CASS_VALUE_TYPE_ASCII: return "ascii" + case CASS_VALUE_TYPE_BIGINT: return "bigint" + case CASS_VALUE_TYPE_BLOB: return "blob" + case CASS_VALUE_TYPE_BOOLEAN: return "boolean" + case CASS_VALUE_TYPE_COUNTER: return "counter" + case CASS_VALUE_TYPE_DECIMAL: return "decimal" + case CASS_VALUE_TYPE_DOUBLE: return "double" + case CASS_VALUE_TYPE_FLOAT: return "float" + case CASS_VALUE_TYPE_INT: return "int" + case CASS_VALUE_TYPE_TEXT: return "text" + case CASS_VALUE_TYPE_TIMESTAMP: return "timestamp" + case CASS_VALUE_TYPE_UUID: return "uuid" + case CASS_VALUE_TYPE_VARCHAR: return "varchar" + case CASS_VALUE_TYPE_VARINT: return "varint" + case CASS_VALUE_TYPE_TIMEUUID: return "timeuuid" + case CASS_VALUE_TYPE_INET: return "inet" + case CASS_VALUE_TYPE_DATE: return "date" + case CASS_VALUE_TYPE_TIME: return "time" + case CASS_VALUE_TYPE_SMALL_INT: return "smallint" + case CASS_VALUE_TYPE_TINY_INT: return "tinyint" + case CASS_VALUE_TYPE_LIST: return "list" + case CASS_VALUE_TYPE_MAP: return "map" + case CASS_VALUE_TYPE_SET: return "set" + case CASS_VALUE_TYPE_TUPLE: return "tuple" + case CASS_VALUE_TYPE_UDT: return "udt" + default: return "text" + } + } + + private func extractFutureError(_ future: OpaquePointer) -> String { + var message: UnsafePointer? + var messageLength: Int = 0 + cass_future_error_message(future, &message, &messageLength) + if let message { + return String( + bytesNoCopy: UnsafeMutableRawPointer(mutating: message), + length: messageLength, + encoding: .utf8, + freeWhenDone: false + ) ?? "Unknown error" + } + return "Unknown error" + } + + private func escapeIdentifier(_ value: String) -> String { + value.replacingOccurrences(of: "\"", with: "\"\"") + } +} + +// MARK: - Raw Result + +private struct CassandraRawResult: Sendable { + let columns: [String] + let columnTypeNames: [String] + let rows: [[String?]] + let rowsAffected: Int + let executionTime: TimeInterval +} + +// MARK: - Plugin Driver + +final class CassandraPluginDriver: PluginDatabaseDriver, @unchecked Sendable { + private let config: DriverConnectionConfig + private let connectionActor = CassandraConnectionActor() + private let stateLock = NSLock() + nonisolated(unsafe) private var _currentKeyspace: String? + + private static let logger = Logger(subsystem: "com.TablePro.CassandraDriver", category: "Driver") + + var currentSchema: String? { + stateLock.lock() + defer { stateLock.unlock() } + return _currentKeyspace + } + + var serverVersion: String? { + // Fetched lazily and cached + stateLock.lock() + let cached = _cachedVersion + stateLock.unlock() + return cached + } + + nonisolated(unsafe) private var _cachedVersion: String? + + var supportsSchemas: Bool { false } + var supportsTransactions: Bool { false } + + init(config: DriverConnectionConfig) { + self.config = config + } + + // MARK: - Connection + + func connect() async throws { + let sslMode = config.additionalFields["sslMode"] ?? "Disabled" + let sslEnabled = sslMode != "Disabled" + let sslCaCertPath = config.additionalFields["sslCaCertPath"] + + let keyspace = config.database.isEmpty ? nil : config.database + + try await connectionActor.connect( + host: config.host, + port: Int(config.port) ?? 9042, + username: config.username.isEmpty ? nil : config.username, + password: config.password.isEmpty ? nil : config.password, + keyspace: keyspace, + sslEnabled: sslEnabled, + sslCaCertPath: sslCaCertPath + ) + + if let keyspace { + stateLock.lock() + _currentKeyspace = keyspace + stateLock.unlock() + } + + // Cache server version + if let version = try? await connectionActor.serverVersion() { + stateLock.lock() + _cachedVersion = version + stateLock.unlock() + } + } + + func disconnect() { + let actor = connectionActor + Task { await actor.close() } + stateLock.lock() + _currentKeyspace = nil + _cachedVersion = nil + stateLock.unlock() + } + + func ping() async throws { + _ = try await execute(query: "SELECT key FROM system.local WHERE key = 'local'") + } + + func applyQueryTimeout(_ seconds: Int) async throws { + // Cassandra doesn't support session-level query timeouts via CQL. + // The request timeout is set at connection time via cass_cluster_set_request_timeout. + } + + // MARK: - Query Execution + + func execute(query: String) async throws -> PluginQueryResult { + let rawResult = try await connectionActor.executeQuery(query) + return PluginQueryResult( + columns: rawResult.columns, + columnTypeNames: rawResult.columnTypeNames, + rows: rawResult.rows, + rowsAffected: rawResult.rowsAffected, + executionTime: rawResult.executionTime + ) + } + + func executeParameterized( + query: String, + parameters: [String?] + ) async throws -> PluginQueryResult { + let rawResult = try await connectionActor.executePrepared(query, parameters: parameters) + return PluginQueryResult( + columns: rawResult.columns, + columnTypeNames: rawResult.columnTypeNames, + rows: rawResult.rows, + rowsAffected: rawResult.rowsAffected, + executionTime: rawResult.executionTime + ) + } + + // MARK: - Pagination + + func fetchRowCount(query: String) async throws -> Int { + let countQuery = "SELECT COUNT(*) FROM (\(stripTrailingSemicolon(query)))" + let result = try await execute(query: countQuery) + guard let firstRow = result.rows.first, let countStr = firstRow.first else { return 0 } + return Int(countStr ?? "0") ?? 0 + } + + func fetchRows(query: String, offset: Int, limit: Int) async throws -> PluginQueryResult { + // Cassandra doesn't support OFFSET natively. + // For paginated browsing, we use LIMIT and let the default protocol handle paging. + let baseQuery = stripTrailingSemicolon(query) + let paginatedQuery = "\(baseQuery) LIMIT \(limit)" + return try await execute(query: paginatedQuery) + } + + // MARK: - Schema Operations + + func fetchTables(schema: String?) async throws -> [PluginTableInfo] { + let ks = resolveKeyspace(schema) + + // Fetch tables + let tablesQuery = """ + SELECT table_name FROM system_schema.tables WHERE keyspace_name = '\(escapeSingleQuote(ks))' + """ + let tablesResult = try await execute(query: tablesQuery) + + var tables = tablesResult.rows.compactMap { row -> PluginTableInfo? in + guard let name = row[safe: 0] ?? nil else { return nil } + return PluginTableInfo(name: name, type: "TABLE") + } + + // Fetch materialized views + let viewsQuery = """ + SELECT view_name FROM system_schema.views WHERE keyspace_name = '\(escapeSingleQuote(ks))' + """ + if let viewsResult = try? await execute(query: viewsQuery) { + let views = viewsResult.rows.compactMap { row -> PluginTableInfo? in + guard let name = row[safe: 0] ?? nil else { return nil } + return PluginTableInfo(name: name, type: "VIEW") + } + tables.append(contentsOf: views) + } + + return tables.sorted { $0.name < $1.name } + } + + func fetchColumns(table: String, schema: String?) async throws -> [PluginColumnInfo] { + let ks = resolveKeyspace(schema) + let query = """ + SELECT column_name, type, kind, clustering_order, position + FROM system_schema.columns + WHERE keyspace_name = '\(escapeSingleQuote(ks))' + AND table_name = '\(escapeSingleQuote(table))' + """ + let result = try await execute(query: query) + + return result.rows.compactMap { row in + guard let name = row[safe: 0] ?? nil, + let dataType = row[safe: 1] ?? nil else { + return nil + } + let kind = row[safe: 2] ?? nil // partition_key, clustering, regular, static + let isPrimaryKey = kind == "partition_key" || kind == "clustering" + + return PluginColumnInfo( + name: name, + dataType: dataType, + isNullable: !isPrimaryKey, + isPrimaryKey: isPrimaryKey, + defaultValue: nil + ) + }.sorted { lhs, rhs in + // Sort: partition keys first, then clustering, then regular + let lhsOrder = columnKindOrder(lhs.isPrimaryKey ? "key" : "regular") + let rhsOrder = columnKindOrder(rhs.isPrimaryKey ? "key" : "regular") + if lhsOrder != rhsOrder { return lhsOrder < rhsOrder } + return lhs.name < rhs.name + } + } + + func fetchAllColumns(schema: String?) async throws -> [String: [PluginColumnInfo]] { + let ks = resolveKeyspace(schema) + let query = """ + SELECT table_name, column_name, type, kind, clustering_order, position + FROM system_schema.columns + WHERE keyspace_name = '\(escapeSingleQuote(ks))' + """ + let result = try await execute(query: query) + + var allColumns: [String: [PluginColumnInfo]] = [:] + + for row in result.rows { + guard let tableName = row[safe: 0] ?? nil, + let columnName = row[safe: 1] ?? nil, + let dataType = row[safe: 2] ?? nil else { + continue + } + let kind = row[safe: 3] ?? nil + let isPrimaryKey = kind == "partition_key" || kind == "clustering" + + let column = PluginColumnInfo( + name: columnName, + dataType: dataType, + isNullable: !isPrimaryKey, + isPrimaryKey: isPrimaryKey, + defaultValue: nil + ) + + allColumns[tableName, default: []].append(column) + } + + return allColumns + } + + func fetchIndexes(table: String, schema: String?) async throws -> [PluginIndexInfo] { + let ks = resolveKeyspace(schema) + let query = """ + SELECT index_name, kind, options + FROM system_schema.indexes + WHERE keyspace_name = '\(escapeSingleQuote(ks))' + AND table_name = '\(escapeSingleQuote(table))' + """ + + do { + let result = try await execute(query: query) + return result.rows.compactMap { row in + guard let name = row[safe: 0] ?? nil else { return nil } + let kind = (row[safe: 1] ?? nil) ?? "COMPOSITES" + let options = (row[safe: 2] ?? nil) ?? "" + + // Extract target column from options map + var targetColumns: [String] = [] + if let targetRange = options.range(of: "target: ") { + let target = String(options[targetRange.upperBound...]) + .trimmingCharacters(in: CharacterSet(charactersIn: "{},' ")) + targetColumns = [target] + } + + return PluginIndexInfo( + name: name, + columns: targetColumns, + isUnique: false, + isPrimary: false, + type: kind + ) + } + } catch { + return [] + } + } + + func fetchForeignKeys(table: String, schema: String?) async throws -> [PluginForeignKeyInfo] { + // Cassandra does not support foreign keys + [] + } + + func fetchTableDDL(table: String, schema: String?) async throws -> String { + let ks = resolveKeyspace(schema) + + // Build DDL from schema metadata + let columns = try await fetchColumns(table: table, schema: ks) + + let partitionKeys = columns.filter(\.isPrimaryKey) + let regularColumns = columns.filter { !$0.isPrimaryKey } + + var ddl = "CREATE TABLE \"\(escapeIdentifier(ks))\".\"\(escapeIdentifier(table))\" (\n" + + let allCols = partitionKeys + regularColumns + let colDefs = allCols.map { col in + " \"\(escapeIdentifier(col.name))\" \(col.dataType)" + } + + var allDefs = colDefs + + if !partitionKeys.isEmpty { + let pkCols = partitionKeys.map { "\"\(escapeIdentifier($0.name))\"" } + .joined(separator: ", ") + allDefs.append(" PRIMARY KEY (\(pkCols))") + } + + ddl += allDefs.joined(separator: ",\n") + ddl += "\n);" + + return ddl + } + + func fetchViewDefinition(view: String, schema: String?) async throws -> String { + let ks = resolveKeyspace(schema) + let query = """ + SELECT base_table_name, where_clause, include_all_columns + FROM system_schema.views + WHERE keyspace_name = '\(escapeSingleQuote(ks))' + AND view_name = '\(escapeSingleQuote(view))' + """ + let result = try await execute(query: query) + + guard let row = result.rows.first else { + throw CassandraPluginError.queryFailed("View '\(view)' not found") + } + + let baseTable = (row[safe: 0] ?? nil) ?? "unknown" + let whereClause = (row[safe: 1] ?? nil) ?? "" + + let columns = try await fetchColumns(table: view, schema: ks) + let colNames = columns.map { "\"\(escapeIdentifier($0.name))\"" }.joined(separator: ", ") + let pkColumns = columns.filter(\.isPrimaryKey) + let pkStr = pkColumns.map { "\"\(escapeIdentifier($0.name))\"" }.joined(separator: ", ") + + var ddl = "CREATE MATERIALIZED VIEW \"\(escapeIdentifier(ks))\".\"\(escapeIdentifier(view))\" AS\n" + ddl += " SELECT \(colNames)\n" + ddl += " FROM \"\(escapeIdentifier(ks))\".\"\(escapeIdentifier(baseTable))\"\n" + if !whereClause.isEmpty { + ddl += " WHERE \(whereClause)\n" + } + ddl += " PRIMARY KEY (\(pkStr));" + + return ddl + } + + func fetchTableMetadata(table: String, schema: String?) async throws -> PluginTableMetadata { + let ks = resolveKeyspace(schema) + let safeTable = escapeSingleQuote(table) + let safeKs = escapeSingleQuote(ks) + + // Cassandra doesn't have a cheap row count — use a bounded count + let countQuery = "SELECT COUNT(*) FROM \"\(escapeIdentifier(ks))\".\"\(escapeIdentifier(table))\" LIMIT 100001" + let countResult = try? await execute(query: countQuery) + let rowCount: Int64? = { + guard let row = countResult?.rows.first, let countStr = row.first else { return nil } + return Int64(countStr ?? "0") + }() + + return PluginTableMetadata( + tableName: table, + rowCount: rowCount, + engine: "Cassandra" + ) + } + + // MARK: - Database (Keyspace) Operations + + func fetchDatabases() async throws -> [String] { + let query = "SELECT keyspace_name FROM system_schema.keyspaces" + let result = try await execute(query: query) + return result.rows.compactMap { $0[safe: 0] ?? nil } + .filter { !$0.hasPrefix("system") } + .sorted() + } + + func fetchDatabaseMetadata(_ database: String) async throws -> PluginDatabaseMetadata { + PluginDatabaseMetadata(name: database) + } + + func fetchAllDatabaseMetadata() async throws -> [PluginDatabaseMetadata] { + let databases = try await fetchDatabases() + return databases.map { PluginDatabaseMetadata(name: $0) } + } + + func createDatabase(name: String, charset: String, collation: String?) async throws { + let safeKs = escapeIdentifier(name) + let query = """ + CREATE KEYSPACE "\(safeKs)" + WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1} + """ + _ = try await execute(query: query) + } + + func switchDatabase(to database: String) async throws { + try await connectionActor.switchKeyspace(database) + stateLock.lock() + _currentKeyspace = database + stateLock.unlock() + } + + // MARK: - Schemas (Cassandra uses keyspaces, not schemas) + + func fetchSchemas() async throws -> [String] { + [] + } + + func switchSchema(to schema: String) async throws { + // Cassandra uses keyspaces instead of schemas + try await switchDatabase(to: schema) + } + + // MARK: - Private Helpers + + private func resolveKeyspace(_ schema: String?) -> String { + if let schema, !schema.isEmpty { return schema } + stateLock.lock() + defer { stateLock.unlock() } + return _currentKeyspace ?? "system" + } + + private func escapeIdentifier(_ value: String) -> String { + value.replacingOccurrences(of: "\"", with: "\"\"") + } + + private func escapeSingleQuote(_ value: String) -> String { + value.replacingOccurrences(of: "'", with: "''") + } + + private func stripTrailingSemicolon(_ query: String) -> String { + var result = query.trimmingCharacters(in: .whitespacesAndNewlines) + while result.hasSuffix(";") { + result = String(result.dropLast()).trimmingCharacters(in: .whitespaces) + } + return result + } + + private func columnKindOrder(_ kind: String) -> Int { + switch kind { + case "partition_key": return 0 + case "clustering": return 1 + case "static": return 2 + default: return 3 + } + } +} + +// MARK: - Errors + +enum CassandraPluginError: Error { + case connectionFailed(String) + case notConnected + case queryFailed(String) + case unsupportedOperation +} + +extension CassandraPluginError: PluginDriverError { + var pluginErrorMessage: String { + switch self { + case .connectionFailed(let msg): return msg + case .notConnected: return String(localized: "Not connected to database") + case .queryFailed(let msg): return msg + case .unsupportedOperation: return String(localized: "Operation not supported by Cassandra") + } + } +} diff --git a/Plugins/CassandraDriverPlugin/Info.plist b/Plugins/CassandraDriverPlugin/Info.plist new file mode 100644 index 000000000..737aa31f0 --- /dev/null +++ b/Plugins/CassandraDriverPlugin/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + $(MARKETING_VERSION) + CFBundleVersion + $(CURRENT_PROJECT_VERSION) + NSPrincipalClass + $(PRODUCT_MODULE_NAME).CassandraPlugin + + diff --git a/TablePro.xcodeproj/project.pbxproj b/TablePro.xcodeproj/project.pbxproj index 73d93cd80..d68f0efa7 100644 --- a/TablePro.xcodeproj/project.pbxproj +++ b/TablePro.xcodeproj/project.pbxproj @@ -34,6 +34,7 @@ 5A86E000D00000000 /* MQLExport.tableplugin in Copy Plug-Ins (12 items) */ = {isa = PBXBuildFile; fileRef = 5A86E000100000000 /* MQLExport.tableplugin */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 5A86F000A00000000 /* TableProPluginKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5A860000100000000 /* TableProPluginKit.framework */; }; 5A86F000D00000000 /* SQLImport.tableplugin in Copy Plug-Ins (12 items) */ = {isa = PBXBuildFile; fileRef = 5A86F000100000000 /* SQLImport.tableplugin */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 5A87A000A00000000 /* TableProPluginKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5A860000100000000 /* TableProPluginKit.framework */; }; 5ACE00012F4F000000000004 /* CodeEditSourceEditor in Frameworks */ = {isa = PBXBuildFile; productRef = 5ACE00012F4F000000000002 /* CodeEditSourceEditor */; }; 5ACE00012F4F000000000005 /* CodeEditLanguages in Frameworks */ = {isa = PBXBuildFile; productRef = 5ACE00012F4F000000000003 /* CodeEditLanguages */; }; 5ACE00012F4F000000000006 /* CodeEditTextView in Frameworks */ = {isa = PBXBuildFile; productRef = 5ACE00012F4F000000000007 /* CodeEditTextView */; }; @@ -217,6 +218,7 @@ 5A86D000100000000 /* XLSXExport.tableplugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = XLSXExport.tableplugin; sourceTree = BUILT_PRODUCTS_DIR; }; 5A86E000100000000 /* MQLExport.tableplugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MQLExport.tableplugin; sourceTree = BUILT_PRODUCTS_DIR; }; 5A86F000100000000 /* SQLImport.tableplugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SQLImport.tableplugin; sourceTree = BUILT_PRODUCTS_DIR; }; + 5A87A000100000000 /* CassandraDriver.tableplugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CassandraDriver.tableplugin; sourceTree = BUILT_PRODUCTS_DIR; }; 5ABCC5A72F43856700EAF3FC /* TableProTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TableProTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 5ASECRETS000000000000001 /* Secrets.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Secrets.xcconfig; sourceTree = SOURCE_ROOT; }; /* End PBXFileReference section */ @@ -334,6 +336,13 @@ ); target = 5A86F000000000000 /* SQLImport */; }; + 5A87A000900000000 /* Exceptions for "Plugins/CassandraDriverPlugin" folder in "CassandraDriver" target */ = { + isa = PBXFileSystemSynchronizedBuildFileExceptionSet; + membershipExceptions = ( + Info.plist, + ); + target = 5A87A000000000000 /* CassandraDriver */; + }; 5AF312BE2F36FF7500E86682 /* Exceptions for "TablePro" folder in "TablePro" target */ = { isa = PBXFileSystemSynchronizedBuildFileExceptionSet; membershipExceptions = ( @@ -480,6 +489,14 @@ path = Plugins/SQLImportPlugin; sourceTree = ""; }; + 5A87A000500000000 /* Plugins/CassandraDriverPlugin */ = { + isa = PBXFileSystemSynchronizedRootGroup; + exceptions = ( + 5A87A000900000000 /* Exceptions for "Plugins/CassandraDriverPlugin" folder in "CassandraDriver" target */, + ); + path = Plugins/CassandraDriverPlugin; + sourceTree = ""; + }; 5ABCC5A82F43856700EAF3FC /* TableProTests */ = { isa = PBXFileSystemSynchronizedRootGroup; path = TableProTests; @@ -628,6 +645,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 5A87A000300000000 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 5A87A000A00000000 /* TableProPluginKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 5ABCC5A42F43856700EAF3FC /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -660,6 +685,7 @@ 5A867000500000000 /* Plugins/RedisDriverPlugin */, 5A868000500000000 /* Plugins/PostgreSQLDriverPlugin */, 5A869000500000000 /* Plugins/DuckDBDriverPlugin */, + 5A87A000500000000 /* Plugins/CassandraDriverPlugin */, 5A86A000500000000 /* Plugins/CSVExportPlugin */, 5A86B000500000000 /* Plugins/JSONExportPlugin */, 5A86C000500000000 /* Plugins/SQLExportPlugin */, @@ -686,6 +712,7 @@ 5A867000100000000 /* RedisDriver.tableplugin */, 5A868000100000000 /* PostgreSQLDriver.tableplugin */, 5A869000100000000 /* DuckDBDriver.tableplugin */, + 5A87A000100000000 /* CassandraDriver.tableplugin */, 5A86A000100000000 /* CSVExport.tableplugin */, 5A86B000100000000 /* JSONExport.tableplugin */, 5A86C000100000000 /* SQLExport.tableplugin */, @@ -1079,6 +1106,26 @@ productReference = 5A86F000100000000 /* SQLImport.tableplugin */; productType = "com.apple.product-type.bundle"; }; + 5A87A000000000000 /* CassandraDriver */ = { + isa = PBXNativeTarget; + buildConfigurationList = 5A87A000800000000 /* Build configuration list for PBXNativeTarget "CassandraDriver" */; + buildPhases = ( + 5A87A000200000000 /* Sources */, + 5A87A000300000000 /* Frameworks */, + 5A87A000400000000 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + fileSystemSynchronizedGroups = ( + 5A87A000500000000 /* Plugins/CassandraDriverPlugin */, + ); + name = CassandraDriver; + productName = CassandraDriver; + productReference = 5A87A000100000000 /* CassandraDriver.tableplugin */; + productType = "com.apple.product-type.bundle"; + }; 5ABCC5A62F43856700EAF3FC /* TableProTests */ = { isa = PBXNativeTarget; buildConfigurationList = 5ABCC5AD2F43856700EAF3FC /* Build configuration list for PBXNativeTarget "TableProTests" */; @@ -1198,6 +1245,7 @@ 5A867000000000000 /* RedisDriver */, 5A868000000000000 /* PostgreSQLDriver */, 5A869000000000000 /* DuckDBDriver */, + 5A87A000000000000 /* CassandraDriver */, 5A86A000000000000 /* CSVExport */, 5A86B000000000000 /* JSONExport */, 5A86C000000000000 /* SQLExport */, @@ -1329,6 +1377,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 5A87A000400000000 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 5ABCC5A52F43856700EAF3FC /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -1458,6 +1513,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 5A87A000200000000 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 5ABCC5A32F43856700EAF3FC /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -1690,11 +1752,11 @@ AUTOMATION_APPLE_EVENTS = NO; CODE_SIGN_ENTITLEMENTS = TablePro/TablePro.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; - "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "-"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 31; DEAD_CODE_STRIPPING = YES; - DEVELOPMENT_TEAM = D7HJ5TFYCU; + DEVELOPMENT_TEAM = ""; ENABLE_APP_SANDBOX = NO; ENABLE_HARDENED_RUNTIME = YES; ENABLE_PREVIEWS = YES; @@ -1750,13 +1812,13 @@ AUTOMATION_APPLE_EVENTS = NO; CODE_SIGN_ENTITLEMENTS = TablePro/TablePro.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; - "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "-"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = YES; CURRENT_PROJECT_VERSION = 31; DEAD_CODE_STRIPPING = YES; DEPLOYMENT_POSTPROCESSING = YES; - DEVELOPMENT_TEAM = D7HJ5TFYCU; + DEVELOPMENT_TEAM = ""; ENABLE_APP_SANDBOX = NO; ENABLE_HARDENED_RUNTIME = YES; ENABLE_PREVIEWS = YES; @@ -1808,7 +1870,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = D7HJ5TFYCU; + DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -1834,7 +1896,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = D7HJ5TFYCU; + DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -1860,7 +1922,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = D7HJ5TFYCU; + DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = Plugins/OracleDriverPlugin/Info.plist; INFOPLIST_KEY_NSPrincipalClass = "$(PRODUCT_MODULE_NAME).OraclePlugin"; @@ -1883,7 +1945,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = D7HJ5TFYCU; + DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = Plugins/OracleDriverPlugin/Info.plist; INFOPLIST_KEY_NSPrincipalClass = "$(PRODUCT_MODULE_NAME).OraclePlugin"; @@ -1906,7 +1968,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = D7HJ5TFYCU; + DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = Plugins/SQLiteDriverPlugin/Info.plist; INFOPLIST_KEY_NSPrincipalClass = "$(PRODUCT_MODULE_NAME).SQLitePlugin"; @@ -1930,7 +1992,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = D7HJ5TFYCU; + DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = Plugins/SQLiteDriverPlugin/Info.plist; INFOPLIST_KEY_NSPrincipalClass = "$(PRODUCT_MODULE_NAME).SQLitePlugin"; @@ -1954,7 +2016,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = D7HJ5TFYCU; + DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = Plugins/ClickHouseDriverPlugin/Info.plist; INFOPLIST_KEY_NSPrincipalClass = "$(PRODUCT_MODULE_NAME).ClickHousePlugin"; @@ -1977,7 +2039,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = D7HJ5TFYCU; + DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = Plugins/ClickHouseDriverPlugin/Info.plist; INFOPLIST_KEY_NSPrincipalClass = "$(PRODUCT_MODULE_NAME).ClickHousePlugin"; @@ -2000,7 +2062,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = D7HJ5TFYCU; + DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; HEADER_SEARCH_PATHS = "$(SRCROOT)/Plugins/MSSQLDriverPlugin/CFreeTDS/include"; INFOPLIST_FILE = Plugins/MSSQLDriverPlugin/Info.plist; @@ -2033,7 +2095,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = D7HJ5TFYCU; + DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; HEADER_SEARCH_PATHS = "$(SRCROOT)/Plugins/MSSQLDriverPlugin/CFreeTDS/include"; INFOPLIST_FILE = Plugins/MSSQLDriverPlugin/Info.plist; @@ -2066,7 +2128,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = D7HJ5TFYCU; + DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; HEADER_SEARCH_PATHS = "$(SRCROOT)/Plugins/MySQLDriverPlugin/CMariaDB/include"; INFOPLIST_FILE = Plugins/MySQLDriverPlugin/Info.plist; @@ -2099,7 +2161,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = D7HJ5TFYCU; + DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; HEADER_SEARCH_PATHS = "$(SRCROOT)/Plugins/MySQLDriverPlugin/CMariaDB/include"; INFOPLIST_FILE = Plugins/MySQLDriverPlugin/Info.plist; @@ -2132,7 +2194,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = D7HJ5TFYCU; + DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; HEADER_SEARCH_PATHS = ( "$(SRCROOT)/Plugins/MongoDBDriverPlugin/CLibMongoc/include", @@ -2172,7 +2234,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = D7HJ5TFYCU; + DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; HEADER_SEARCH_PATHS = ( "$(SRCROOT)/Plugins/MongoDBDriverPlugin/CLibMongoc/include", @@ -2212,7 +2274,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = D7HJ5TFYCU; + DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; HEADER_SEARCH_PATHS = "$(SRCROOT)/Plugins/RedisDriverPlugin/CRedis/include"; INFOPLIST_FILE = Plugins/RedisDriverPlugin/Info.plist; @@ -2246,7 +2308,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = D7HJ5TFYCU; + DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; HEADER_SEARCH_PATHS = "$(SRCROOT)/Plugins/RedisDriverPlugin/CRedis/include"; INFOPLIST_FILE = Plugins/RedisDriverPlugin/Info.plist; @@ -2280,7 +2342,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = D7HJ5TFYCU; + DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; HEADER_SEARCH_PATHS = "$(SRCROOT)/Plugins/PostgreSQLDriverPlugin/CLibPQ/include"; INFOPLIST_FILE = Plugins/PostgreSQLDriverPlugin/Info.plist; @@ -2315,7 +2377,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = D7HJ5TFYCU; + DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; HEADER_SEARCH_PATHS = "$(SRCROOT)/Plugins/PostgreSQLDriverPlugin/CLibPQ/include"; INFOPLIST_FILE = Plugins/PostgreSQLDriverPlugin/Info.plist; @@ -2350,7 +2412,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = D7HJ5TFYCU; + DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; HEADER_SEARCH_PATHS = "$(SRCROOT)/Plugins/DuckDBDriverPlugin/CDuckDB/include"; INFOPLIST_FILE = Plugins/DuckDBDriverPlugin/Info.plist; @@ -2381,7 +2443,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = D7HJ5TFYCU; + DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; HEADER_SEARCH_PATHS = "$(SRCROOT)/Plugins/DuckDBDriverPlugin/CDuckDB/include"; INFOPLIST_FILE = Plugins/DuckDBDriverPlugin/Info.plist; @@ -2412,7 +2474,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = D7HJ5TFYCU; + DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = Plugins/CSVExportPlugin/Info.plist; INFOPLIST_KEY_NSPrincipalClass = "$(PRODUCT_MODULE_NAME).CSVExportPlugin"; @@ -2435,7 +2497,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = D7HJ5TFYCU; + DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = Plugins/CSVExportPlugin/Info.plist; INFOPLIST_KEY_NSPrincipalClass = "$(PRODUCT_MODULE_NAME).CSVExportPlugin"; @@ -2458,7 +2520,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = D7HJ5TFYCU; + DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = Plugins/JSONExportPlugin/Info.plist; INFOPLIST_KEY_NSPrincipalClass = "$(PRODUCT_MODULE_NAME).JSONExportPlugin"; @@ -2481,7 +2543,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = D7HJ5TFYCU; + DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = Plugins/JSONExportPlugin/Info.plist; INFOPLIST_KEY_NSPrincipalClass = "$(PRODUCT_MODULE_NAME).JSONExportPlugin"; @@ -2504,7 +2566,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = D7HJ5TFYCU; + DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = Plugins/SQLExportPlugin/Info.plist; INFOPLIST_KEY_NSPrincipalClass = "$(PRODUCT_MODULE_NAME).SQLExportPlugin"; @@ -2527,7 +2589,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = D7HJ5TFYCU; + DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = Plugins/SQLExportPlugin/Info.plist; INFOPLIST_KEY_NSPrincipalClass = "$(PRODUCT_MODULE_NAME).SQLExportPlugin"; @@ -2550,7 +2612,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = D7HJ5TFYCU; + DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = Plugins/XLSXExportPlugin/Info.plist; INFOPLIST_KEY_NSPrincipalClass = "$(PRODUCT_MODULE_NAME).XLSXExportPlugin"; @@ -2573,7 +2635,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = D7HJ5TFYCU; + DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = Plugins/XLSXExportPlugin/Info.plist; INFOPLIST_KEY_NSPrincipalClass = "$(PRODUCT_MODULE_NAME).XLSXExportPlugin"; @@ -2596,7 +2658,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = D7HJ5TFYCU; + DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = Plugins/MQLExportPlugin/Info.plist; INFOPLIST_KEY_NSPrincipalClass = "$(PRODUCT_MODULE_NAME).MQLExportPlugin"; @@ -2619,7 +2681,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = D7HJ5TFYCU; + DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = Plugins/MQLExportPlugin/Info.plist; INFOPLIST_KEY_NSPrincipalClass = "$(PRODUCT_MODULE_NAME).MQLExportPlugin"; @@ -2642,7 +2704,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = D7HJ5TFYCU; + DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = Plugins/SQLImportPlugin/Info.plist; INFOPLIST_KEY_NSPrincipalClass = "$(PRODUCT_MODULE_NAME).SQLImportPlugin"; @@ -2665,7 +2727,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = D7HJ5TFYCU; + DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = Plugins/SQLImportPlugin/Info.plist; INFOPLIST_KEY_NSPrincipalClass = "$(PRODUCT_MODULE_NAME).SQLImportPlugin"; @@ -2682,13 +2744,85 @@ }; name = Release; }; + 5A87A000600000000 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = ""; + GENERATE_INFOPLIST_FILE = YES; + HEADER_SEARCH_PATHS = "$(SRCROOT)/Plugins/CassandraDriverPlugin/CCassandra/include"; + INFOPLIST_FILE = Plugins/CassandraDriverPlugin/Info.plist; + INFOPLIST_KEY_NSPrincipalClass = "$(PRODUCT_MODULE_NAME).CassandraPlugin"; + LD_RUNPATH_SEARCH_PATHS = "@executable_path/../Frameworks"; + LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/Libs"; + MACOSX_DEPLOYMENT_TARGET = 14.0; + MARKETING_VERSION = 1.0; + OTHER_LDFLAGS = ( + "-force_load", + "$(PROJECT_DIR)/Libs/libcassandra.a", + "-force_load", + "$(PROJECT_DIR)/Libs/libuv.a", + "-lssl", + "-lcrypto", + "-lc++", + "-lz", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.TablePro.CassandraDriver; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + SKIP_INSTALL = YES; + SUPPORTED_PLATFORMS = macosx; + SWIFT_INCLUDE_PATHS = "$(SRCROOT)/Plugins/CassandraDriverPlugin/CCassandra"; + SWIFT_VERSION = 5.9; + WRAPPER_EXTENSION = tableplugin; + }; + name = Debug; + }; + 5A87A000700000000 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = ""; + GENERATE_INFOPLIST_FILE = YES; + HEADER_SEARCH_PATHS = "$(SRCROOT)/Plugins/CassandraDriverPlugin/CCassandra/include"; + INFOPLIST_FILE = Plugins/CassandraDriverPlugin/Info.plist; + INFOPLIST_KEY_NSPrincipalClass = "$(PRODUCT_MODULE_NAME).CassandraPlugin"; + LD_RUNPATH_SEARCH_PATHS = "@executable_path/../Frameworks"; + LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/Libs"; + MACOSX_DEPLOYMENT_TARGET = 14.0; + MARKETING_VERSION = 1.0; + OTHER_LDFLAGS = ( + "-force_load", + "$(PROJECT_DIR)/Libs/libcassandra.a", + "-force_load", + "$(PROJECT_DIR)/Libs/libuv.a", + "-lssl", + "-lcrypto", + "-lc++", + "-lz", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.TablePro.CassandraDriver; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + SKIP_INSTALL = YES; + SUPPORTED_PLATFORMS = macosx; + SWIFT_INCLUDE_PATHS = "$(SRCROOT)/Plugins/CassandraDriverPlugin/CCassandra"; + SWIFT_VERSION = 5.9; + WRAPPER_EXTENSION = tableplugin; + }; + name = Release; + }; 5ABCC5AE2F43856700EAF3FC /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = D7HJ5TFYCU; + DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; MACOSX_DEPLOYMENT_TARGET = 26.2; MARKETING_VERSION = 1.0; @@ -2710,7 +2844,7 @@ BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = D7HJ5TFYCU; + DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; MACOSX_DEPLOYMENT_TARGET = 26.2; MARKETING_VERSION = 1.0; @@ -2891,6 +3025,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 5A87A000800000000 /* Build configuration list for PBXNativeTarget "CassandraDriver" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 5A87A000600000000 /* Debug */, + 5A87A000700000000 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 5ABCC5AD2F43856700EAF3FC /* Build configuration list for PBXNativeTarget "TableProTests" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/TablePro/AppDelegate+FileOpen.swift b/TablePro/AppDelegate+FileOpen.swift index 109ca0abb..d60eb7851 100644 --- a/TablePro/AppDelegate+FileOpen.swift +++ b/TablePro/AppDelegate+FileOpen.swift @@ -17,7 +17,8 @@ extension AppDelegate { private static let databaseURLSchemes: Set = [ "postgresql", "postgres", "mysql", "mariadb", "sqlite", "mongodb", "mongodb+srv", "redis", "rediss", "redshift", - "mssql", "sqlserver", "oracle", "duckdb" + "mssql", "sqlserver", "oracle", "duckdb", + "cassandra", "cql", "scylladb", "scylla" ] static let sqliteFileExtensions: Set = [ diff --git a/TablePro/Assets.xcassets/cassandra-icon.imageset/Contents.json b/TablePro/Assets.xcassets/cassandra-icon.imageset/Contents.json new file mode 100644 index 000000000..02cbfc783 --- /dev/null +++ b/TablePro/Assets.xcassets/cassandra-icon.imageset/Contents.json @@ -0,0 +1,16 @@ +{ + "images" : [ + { + "filename" : "cassandra.svg", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" + } +} diff --git a/TablePro/Assets.xcassets/cassandra-icon.imageset/cassandra.svg b/TablePro/Assets.xcassets/cassandra-icon.imageset/cassandra.svg new file mode 100644 index 000000000..6410f737b --- /dev/null +++ b/TablePro/Assets.xcassets/cassandra-icon.imageset/cassandra.svg @@ -0,0 +1,4 @@ + + + + diff --git a/TablePro/Assets.xcassets/scylladb-icon.imageset/Contents.json b/TablePro/Assets.xcassets/scylladb-icon.imageset/Contents.json new file mode 100644 index 000000000..e5fdcfbda --- /dev/null +++ b/TablePro/Assets.xcassets/scylladb-icon.imageset/Contents.json @@ -0,0 +1,16 @@ +{ + "images" : [ + { + "filename" : "scylladb.svg", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" + } +} diff --git a/TablePro/Assets.xcassets/scylladb-icon.imageset/scylladb.svg b/TablePro/Assets.xcassets/scylladb-icon.imageset/scylladb.svg new file mode 100644 index 000000000..8e07c53d3 --- /dev/null +++ b/TablePro/Assets.xcassets/scylladb-icon.imageset/scylladb.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/TablePro/Core/Autocomplete/SQLCompletionProvider.swift b/TablePro/Core/Autocomplete/SQLCompletionProvider.swift index 1d23c4777..8302bc158 100644 --- a/TablePro/Core/Autocomplete/SQLCompletionProvider.swift +++ b/TablePro/Core/Autocomplete/SQLCompletionProvider.swift @@ -538,6 +538,14 @@ final class SQLCompletionProvider { ] + case .cassandra, .scylladb: + types += [ + "ASCII", "VARINT", + "UUID", "TIMEUUID", + "INET", "COUNTER", + "LIST", "SET", "MAP", "TUPLE", "FROZEN", + ] + case .sqlite: types += [ "BLOB", diff --git a/TablePro/Core/ChangeTracking/SQLStatementGenerator.swift b/TablePro/Core/ChangeTracking/SQLStatementGenerator.swift index 57bec156b..e82fceb15 100644 --- a/TablePro/Core/ChangeTracking/SQLStatementGenerator.swift +++ b/TablePro/Core/ChangeTracking/SQLStatementGenerator.swift @@ -44,7 +44,7 @@ struct SQLStatementGenerator { switch databaseType { case .postgresql, .redshift, .duckdb: return .dollar - case .mysql, .mariadb, .sqlite, .mongodb, .redis, .mssql, .oracle, .clickhouse: + case .mysql, .mariadb, .sqlite, .mongodb, .redis, .mssql, .oracle, .clickhouse, .cassandra, .scylladb: return .questionMark } } @@ -299,8 +299,25 @@ struct SQLStatementGenerator { guard !conditions.isEmpty else { return nil } let whereClause = conditions.joined(separator: " AND ") - let sql = - "UPDATE \(databaseType.quoteIdentifier(tableName)) SET \(setClauses) WHERE \(whereClause)" + + let sql: String + switch databaseType { + case .mysql, .mariadb, .sqlite: + sql = + "UPDATE \(databaseType.quoteIdentifier(tableName)) SET \(setClauses) WHERE \(whereClause) LIMIT 1" + case .mssql: + sql = + "UPDATE TOP (1) \(databaseType.quoteIdentifier(tableName)) SET \(setClauses) WHERE \(whereClause)" + case .oracle: + sql = + "UPDATE \(databaseType.quoteIdentifier(tableName)) SET \(setClauses) WHERE \(whereClause) AND ROWNUM = 1" + case .clickhouse: + sql = + "ALTER TABLE \(databaseType.quoteIdentifier(tableName)) UPDATE \(setClauses) WHERE \(whereClause)" + case .postgresql, .redshift, .duckdb, .mongodb, .redis, .cassandra, .scylladb: + sql = + "UPDATE \(databaseType.quoteIdentifier(tableName)) SET \(setClauses) WHERE \(whereClause)" + } return ParameterizedStatement(sql: sql, parameters: parameters) } @@ -367,7 +384,24 @@ struct SQLStatementGenerator { guard !conditions.isEmpty else { return nil } let whereClause = conditions.joined(separator: " AND ") - let sql = "DELETE FROM \(databaseType.quoteIdentifier(tableName)) WHERE \(whereClause)" + + let sql: String + switch databaseType { + case .mysql, .mariadb, .sqlite: + sql = + "DELETE FROM \(databaseType.quoteIdentifier(tableName)) WHERE \(whereClause) LIMIT 1" + case .mssql: + sql = + "DELETE TOP (1) FROM \(databaseType.quoteIdentifier(tableName)) WHERE \(whereClause)" + case .oracle: + sql = + "DELETE FROM \(databaseType.quoteIdentifier(tableName)) WHERE \(whereClause) AND ROWNUM = 1" + case .clickhouse: + sql = + "ALTER TABLE \(databaseType.quoteIdentifier(tableName)) DELETE WHERE \(whereClause)" + case .postgresql, .redshift, .duckdb, .mongodb, .redis, .cassandra, .scylladb: + sql = "DELETE FROM \(databaseType.quoteIdentifier(tableName)) WHERE \(whereClause)" + } return ParameterizedStatement(sql: sql, parameters: parameters) } diff --git a/TablePro/Core/Database/DatabaseDriver.swift b/TablePro/Core/Database/DatabaseDriver.swift index 3cd7ed59b..50abb655a 100644 --- a/TablePro/Core/Database/DatabaseDriver.swift +++ b/TablePro/Core/Database/DatabaseDriver.swift @@ -285,6 +285,8 @@ extension DatabaseDriver { break // MongoDB timeout handled per-operation by MongoDBDriver case .redis: break // Redis does not support session-level query timeouts + case .cassandra, .scylladb: + break // Cassandra/ScyllaDB timeout handled per-query by driver case .mssql: _ = try await execute(query: "SET LOCK_TIMEOUT \(ms)") case .oracle: @@ -359,7 +361,15 @@ enum DatabaseDriverFactory { switch connection.type { case .mongodb: fields["sslCACertPath"] = ssl.caCertificatePath - default: + fields["mongoReadPreference"] = connection.mongoReadPreference ?? "" + fields["mongoWriteConcern"] = connection.mongoWriteConcern ?? "" + case .redis: + fields["redisDatabase"] = String(connection.redisDatabase ?? 0) + case .mssql: + fields["mssqlSchema"] = connection.mssqlSchema ?? "dbo" + case .oracle: + fields["oracleServiceName"] = connection.oracleServiceName ?? "" + case .mysql, .mariadb, .sqlite, .clickhouse, .postgresql, .redshift, .cassandra, .scylladb, .duckdb: break } diff --git a/TablePro/Core/Database/FilterSQLGenerator.swift b/TablePro/Core/Database/FilterSQLGenerator.swift index 4fdb4eeaf..0562773e2 100644 --- a/TablePro/Core/Database/FilterSQLGenerator.swift +++ b/TablePro/Core/Database/FilterSQLGenerator.swift @@ -126,7 +126,7 @@ struct FilterSQLGenerator { switch databaseType { case .mysql, .mariadb: return "" - case .postgresql, .redshift, .sqlite, .mongodb, .redis, .mssql, .oracle, .clickhouse, .duckdb: + case .postgresql, .redshift, .sqlite, .mongodb, .redis, .mssql, .oracle, .clickhouse, .duckdb, .cassandra, .scylladb: return " ESCAPE '\\'" } } @@ -153,7 +153,7 @@ struct FilterSQLGenerator { return "\(column) ~ '\(escapedPattern)'" case .duckdb: return "regexp_matches(\(column), '\(escapedPattern)')" - case .sqlite, .mongodb, .redis, .mssql, .oracle, .clickhouse: + case .sqlite, .mongodb, .redis, .mssql, .oracle, .clickhouse, .cassandra, .scylladb: return "\(column) LIKE '%\(escapedPattern)%'" } } @@ -171,10 +171,10 @@ struct FilterSQLGenerator { // Check for boolean literals if trimmed.caseInsensitiveCompare("TRUE") == .orderedSame { - return databaseType == .postgresql || databaseType == .redshift || databaseType == .duckdb ? "TRUE" : "1" + return databaseType == .postgresql || databaseType == .redshift || databaseType == .duckdb || databaseType == .cassandra || databaseType == .scylladb ? "TRUE" : "1" } if trimmed.caseInsensitiveCompare("FALSE") == .orderedSame { - return databaseType == .postgresql || databaseType == .redshift || databaseType == .duckdb ? "FALSE" : "0" + return databaseType == .postgresql || databaseType == .redshift || databaseType == .duckdb || databaseType == .cassandra || databaseType == .scylladb ? "FALSE" : "0" } // Try to detect numeric values diff --git a/TablePro/Core/Database/SQLEscaping.swift b/TablePro/Core/Database/SQLEscaping.swift index 46ffaba20..668618773 100644 --- a/TablePro/Core/Database/SQLEscaping.swift +++ b/TablePro/Core/Database/SQLEscaping.swift @@ -48,7 +48,7 @@ enum SQLEscaping { result = result.replacingOccurrences(of: "\u{1A}", with: "\\Z") // MySQL EOF marker (Ctrl+Z) return result - case .postgresql, .redshift, .sqlite, .mongodb, .redis, .mssql, .oracle, .duckdb: + case .postgresql, .redshift, .sqlite, .mongodb, .redis, .mssql, .oracle, .duckdb, .cassandra, .scylladb: // Standard SQL: only single quotes need doubling // Newlines, tabs, backslashes are valid as-is in string literals var result = str diff --git a/TablePro/Core/Plugins/ImportDataSinkAdapter.swift b/TablePro/Core/Plugins/ImportDataSinkAdapter.swift index a0e485b18..b4de493fc 100644 --- a/TablePro/Core/Plugins/ImportDataSinkAdapter.swift +++ b/TablePro/Core/Plugins/ImportDataSinkAdapter.swift @@ -58,7 +58,7 @@ final class ImportDataSinkAdapter: PluginImportDataSink, @unchecked Sendable { return [] case .sqlite: return ["PRAGMA foreign_keys = OFF"] - case .mongodb, .redis, .clickhouse, .duckdb: + case .mongodb, .redis, .clickhouse, .duckdb, .cassandra, .scylladb: return [] } } @@ -71,7 +71,7 @@ final class ImportDataSinkAdapter: PluginImportDataSink, @unchecked Sendable { return [] case .sqlite: return ["PRAGMA foreign_keys = ON"] - case .mongodb, .redis, .clickhouse, .duckdb: + case .mongodb, .redis, .clickhouse, .duckdb, .cassandra, .scylladb: return [] } } diff --git a/TablePro/Core/Services/Query/SQLDialectProvider.swift b/TablePro/Core/Services/Query/SQLDialectProvider.swift index e64ef7b40..82a12172f 100644 --- a/TablePro/Core/Services/Query/SQLDialectProvider.swift +++ b/TablePro/Core/Services/Query/SQLDialectProvider.swift @@ -33,6 +33,67 @@ private struct EmptyDialect: SQLDialectProvider { let dataTypes: Set = [] } +// MARK: - Cassandra/ScyllaDB Dialect + +struct CassandraDialect: SQLDialectProvider { + let identifierQuote = "\"" + + let keywords: Set = [ + // Core DML keywords + "SELECT", "FROM", "WHERE", "AND", "OR", "NOT", "IN", "AS", + "ORDER", "BY", "LIMIT", + "INSERT", "INTO", "VALUES", "UPDATE", "SET", "DELETE", + + // DDL keywords + "CREATE", "ALTER", "DROP", "TABLE", "INDEX", "VIEW", + "PRIMARY", "KEY", "ADD", "COLUMN", "RENAME", + + // Data attributes + "NULL", "IS", "ASC", "DESC", "DISTINCT", + + // Control flow + "CASE", "WHEN", "THEN", "ELSE", "END", + + // Cassandra-specific + "KEYSPACE", "USE", "TRUNCATE", "BATCH", "GRANT", "REVOKE", + "CLUSTERING", "PARTITION", "TTL", "WRITETIME", + "ALLOW FILTERING", "IF NOT EXISTS", "IF EXISTS", + "USING TIMESTAMP", "USING TTL", + "MATERIALIZED VIEW", "CONTAINS", "FROZEN", "COUNTER", "TOKEN" + ] + + let functions: Set = [ + // Aggregate + "COUNT", "SUM", "AVG", "MAX", "MIN", + + // Cassandra-specific + "NOW", "UUID", "TOTIMESTAMP", "TOKEN", "TTL", "WRITETIME", + "MINTIMEUUID", "MAXTIMEUUID", "TODATE", "TOUNIXTIMESTAMP", + + // Conversion + "CAST" + ] + + let dataTypes: Set = [ + // String types + "TEXT", "VARCHAR", "ASCII", + + // Integer types + "INT", "BIGINT", "SMALLINT", "TINYINT", "VARINT", + + // Decimal types + "FLOAT", "DOUBLE", "DECIMAL", + + // Other types + "BOOLEAN", "UUID", "TIMEUUID", + "TIMESTAMP", "DATE", "TIME", + "BLOB", "INET", "COUNTER", + + // Collection types + "LIST", "SET", "MAP", "TUPLE", "FROZEN" + ] +} + // MARK: - Dialect Factory struct SQLDialectFactory { diff --git a/TablePro/Core/Utilities/Connection/ConnectionURLFormatter.swift b/TablePro/Core/Utilities/Connection/ConnectionURLFormatter.swift index 72e7c12f9..f5553883e 100644 --- a/TablePro/Core/Utilities/Connection/ConnectionURLFormatter.swift +++ b/TablePro/Core/Utilities/Connection/ConnectionURLFormatter.swift @@ -39,6 +39,8 @@ struct ConnectionURLFormatter { case .oracle: return "oracle" case .clickhouse: return "clickhouse" case .duckdb: return "duckdb" + case .cassandra: return "cassandra" + case .scylladb: return "scylladb" } } diff --git a/TablePro/Core/Utilities/Connection/ConnectionURLParser.swift b/TablePro/Core/Utilities/Connection/ConnectionURLParser.swift index 96ce8674c..e2f2bc90b 100644 --- a/TablePro/Core/Utilities/Connection/ConnectionURLParser.swift +++ b/TablePro/Core/Utilities/Connection/ConnectionURLParser.swift @@ -110,6 +110,10 @@ struct ConnectionURLParser { dbType = .oracle case "clickhouse", "ch": dbType = .clickhouse + case "cassandra", "cql": + dbType = .cassandra + case "scylladb", "scylla": + dbType = .scylladb default: return .failure(.unsupportedScheme(scheme)) } diff --git a/TablePro/Core/Utilities/SQL/SQLParameterInliner.swift b/TablePro/Core/Utilities/SQL/SQLParameterInliner.swift index 97b04f689..6241cae2d 100644 --- a/TablePro/Core/Utilities/SQL/SQLParameterInliner.swift +++ b/TablePro/Core/Utilities/SQL/SQLParameterInliner.swift @@ -21,7 +21,7 @@ struct SQLParameterInliner { switch databaseType { case .postgresql, .redshift, .duckdb: return inlineDollarPlaceholders(statement.sql, parameters: statement.parameters) - case .mysql, .mariadb, .sqlite, .mongodb, .redis, .mssql, .oracle, .clickhouse: + case .mysql, .mariadb, .sqlite, .mongodb, .redis, .mssql, .oracle, .clickhouse, .cassandra, .scylladb: return inlineQuestionMarkPlaceholders(statement.sql, parameters: statement.parameters) } } diff --git a/TablePro/Info.plist b/TablePro/Info.plist index 77d14f1de..d68fc0518 100644 --- a/TablePro/Info.plist +++ b/TablePro/Info.plist @@ -200,6 +200,10 @@ mssql sqlserver duckdb + cassandra + cql + scylladb + scylla CFBundleTypeRole Viewer diff --git a/TablePro/Models/Connection/DatabaseConnection.swift b/TablePro/Models/Connection/DatabaseConnection.swift index 931d656d8..a3d3358f8 100644 --- a/TablePro/Models/Connection/DatabaseConnection.swift +++ b/TablePro/Models/Connection/DatabaseConnection.swift @@ -208,6 +208,8 @@ enum DatabaseType: String, CaseIterable, Identifiable, Codable { case mssql = "SQL Server" case oracle = "Oracle" case clickhouse = "ClickHouse" + case cassandra = "Cassandra" + case scylladb = "ScyllaDB" case duckdb = "DuckDB" var id: String { rawValue } @@ -226,13 +228,14 @@ enum DatabaseType: String, CaseIterable, Identifiable, Codable { case .redis: return "Redis" case .oracle: return "Oracle" case .clickhouse: return "ClickHouse" + case .cassandra, .scylladb: return "Cassandra" case .duckdb: return "DuckDB" } } var isDownloadablePlugin: Bool { switch self { - case .oracle, .clickhouse, .sqlite, .duckdb: return true + case .oracle, .clickhouse, .sqlite, .duckdb, .cassandra, .scylladb: return true default: return false } } @@ -260,6 +263,10 @@ enum DatabaseType: String, CaseIterable, Identifiable, Codable { return "oracle-icon" case .clickhouse: return "clickhouse-icon" + case .cassandra: + return "cassandra-icon" + case .scylladb: + return "scylladb-icon" case .duckdb: return "duckdb-icon" } @@ -277,6 +284,7 @@ enum DatabaseType: String, CaseIterable, Identifiable, Codable { case .mssql: return 1_433 case .oracle: return 1_521 case .clickhouse: return 8_123 + case .cassandra, .scylladb: return 9_042 case .duckdb: return 0 } } @@ -287,7 +295,7 @@ enum DatabaseType: String, CaseIterable, Identifiable, Codable { var requiresAuthentication: Bool { switch self { case .mysql, .mariadb, .postgresql, .redshift, .mssql, .oracle, .clickhouse: return true - case .sqlite, .duckdb, .mongodb, .redis: return false + case .sqlite, .duckdb, .mongodb, .redis, .cassandra, .scylladb: return false } } @@ -296,7 +304,7 @@ enum DatabaseType: String, CaseIterable, Identifiable, Codable { switch self { case .mysql, .mariadb, .postgresql, .sqlite, .redshift, .mssql, .oracle, .duckdb: return true - case .mongodb, .redis, .clickhouse: + case .mongodb, .redis, .clickhouse, .cassandra, .scylladb: return false } } @@ -304,7 +312,7 @@ enum DatabaseType: String, CaseIterable, Identifiable, Codable { /// Whether this database type supports SQL-based schema editing (ALTER TABLE etc.) var supportsSchemaEditing: Bool { switch self { - case .mysql, .mariadb, .postgresql, .sqlite, .mssql, .oracle, .clickhouse, .duckdb: + case .mysql, .mariadb, .postgresql, .sqlite, .mssql, .oracle, .clickhouse, .cassandra, .scylladb, .duckdb: return true case .redshift, .mongodb, .redis: return false @@ -317,7 +325,7 @@ enum DatabaseType: String, CaseIterable, Identifiable, Codable { switch self { case .mysql, .mariadb, .sqlite, .clickhouse: return "`" - case .postgresql, .redshift, .mongodb, .redis, .oracle, .duckdb: + case .postgresql, .redshift, .mongodb, .redis, .oracle, .cassandra, .scylladb, .duckdb: return "\"" case .mssql: return "[" diff --git a/TablePro/Theme/Theme.swift b/TablePro/Theme/Theme.swift index 52f18da52..33694a422 100644 --- a/TablePro/Theme/Theme.swift +++ b/TablePro/Theme/Theme.swift @@ -24,6 +24,8 @@ enum Theme { static let mssqlColor = Color(red: 0.89, green: 0.27, blue: 0.09) static let oracleColor = Color(red: 0.76, green: 0.09, blue: 0.07) // #C3160B Oracle red static let clickhouseColor = Color(red: 1.0, green: 0.82, blue: 0.0) + static let cassandraColor = Color(red: 0.15, green: 0.68, blue: 0.85) + static let scylladbColor = Color(red: 0.42, green: 0.18, blue: 0.89) static let duckdbColor = Color(red: 1.0, green: 0.85, blue: 0.0) // MARK: - Semantic Colors @@ -121,6 +123,10 @@ extension DatabaseType { return Theme.oracleColor case .clickhouse: return Theme.clickhouseColor + case .cassandra: + return Theme.cassandraColor + case .scylladb: + return Theme.scylladbColor case .duckdb: return Theme.duckdbColor } diff --git a/TablePro/ViewModels/DatabaseSwitcherViewModel.swift b/TablePro/ViewModels/DatabaseSwitcherViewModel.swift index abe215b95..5bc6b4f90 100644 --- a/TablePro/ViewModels/DatabaseSwitcherViewModel.swift +++ b/TablePro/ViewModels/DatabaseSwitcherViewModel.swift @@ -194,6 +194,8 @@ final class DatabaseSwitcherViewModel { return ["master", "tempdb", "model", "msdb"].contains(name) case .oracle: return ["SYS", "SYSTEM", "OUTLN", "DBSNMP", "APPQOSSYS", "WMSYS", "XDB"].contains(name) + case .cassandra, .scylladb: + return name.hasPrefix("system") } } } diff --git a/TablePro/Views/Connection/ConnectionFormView.swift b/TablePro/Views/Connection/ConnectionFormView.swift index b6abb4b49..38f7e0850 100644 --- a/TablePro/Views/Connection/ConnectionFormView.swift +++ b/TablePro/Views/Connection/ConnectionFormView.swift @@ -773,6 +773,7 @@ struct ConnectionFormView: View { case .redis: return "6379" case .mssql: return "1433" case .oracle: return "1521" + case .cassandra, .scylladb: return "9042" } } diff --git a/TablePro/Views/Export/ExportDialog.swift b/TablePro/Views/Export/ExportDialog.swift index 175ad2b82..5838d73be 100644 --- a/TablePro/Views/Export/ExportDialog.swift +++ b/TablePro/Views/Export/ExportDialog.swift @@ -463,7 +463,7 @@ struct ExportDialog: View { return item1.name < item2.name } - case .sqlite, .mongodb, .redis, .duckdb: + case .sqlite, .mongodb, .redis, .duckdb, .cassandra, .scylladb: let fallbackName = connection.type == .redis ? "db0" : "main" let dbItem = try await buildFlatDatabaseItem( driver: driver, diff --git a/TablePro/Views/Main/Extensions/MainContentCoordinator+Navigation.swift b/TablePro/Views/Main/Extensions/MainContentCoordinator+Navigation.swift index 613857cf7..77e1fdbb7 100644 --- a/TablePro/Views/Main/Extensions/MainContentCoordinator+Navigation.swift +++ b/TablePro/Views/Main/Extensions/MainContentCoordinator+Navigation.swift @@ -243,10 +243,17 @@ extension MainContentCoordinator { WindowOpener.shared.openNativeTab(payload) } + private func currentSchemaName(fallback: String) -> String { + if let schemaDriver = DatabaseManager.shared.driver(for: connectionId) as? SchemaSwitchable { + return schemaDriver.escapedSchema + } + return fallback + } + private func allTablesMetadataSQL() -> String? { switch connection.type { case .postgresql: - let schema = (DatabaseManager.shared.driver(for: connectionId) as? SchemaSwitchable)?.escapedSchema ?? "public" + let schema = currentSchemaName(fallback: "public") return """ SELECT schemaname as schema, @@ -262,7 +269,7 @@ extension MainContentCoordinator { ORDER BY relname """ case .redshift: - let schema = (DatabaseManager.shared.driver(for: connectionId) as? SchemaSwitchable)?.escapedSchema ?? "public" + let schema = currentSchemaName(fallback: "public") return """ SELECT schema, @@ -345,7 +352,7 @@ extension MainContentCoordinator { ORDER BY t.name """ case .oracle: - let schema = (DatabaseManager.shared.driver(for: connectionId) as? SchemaSwitchable)?.escapedSchema ?? "SYSTEM" + let schema = currentSchemaName(fallback: "SYSTEM") return """ SELECT OWNER as schema_name, @@ -357,7 +364,7 @@ extension MainContentCoordinator { ORDER BY TABLE_NAME """ case .duckdb: - let schema = (DatabaseManager.shared.driver(for: connectionId) as? SchemaSwitchable)?.escapedSchema ?? "main" + let schema = currentSchemaName(fallback: "main") return """ SELECT table_schema as schema_name, @@ -381,6 +388,8 @@ extension MainContentCoordinator { ) runQuery() return nil + case .cassandra, .scylladb: + return nil } } diff --git a/TablePro/Views/Main/Extensions/MainContentCoordinator+SidebarActions.swift b/TablePro/Views/Main/Extensions/MainContentCoordinator+SidebarActions.swift index fd6d7f93a..18316117c 100644 --- a/TablePro/Views/Main/Extensions/MainContentCoordinator+SidebarActions.swift +++ b/TablePro/Views/Main/Extensions/MainContentCoordinator+SidebarActions.swift @@ -31,6 +31,8 @@ extension MainContentCoordinator { template = "db.createView(\"view_name\", \"source_collection\", [\n {\"$match\": {}},\n {\"$project\": {\"_id\": 1}}\n])" case .redis: template = "-- Redis does not support views" + case .cassandra, .scylladb: + template = "-- Cassandra does not support views via CQL CREATE VIEW" } let payload = EditorTabPayload( @@ -71,6 +73,8 @@ extension MainContentCoordinator { fallbackSQL = "db.runCommand({\"collMod\": \"\(viewName)\", \"viewOn\": \"source_collection\", \"pipeline\": [{\"$match\": {}}]})" case .redis: fallbackSQL = "-- Redis does not support views" + case .cassandra, .scylladb: + fallbackSQL = "-- Cassandra does not support ALTER VIEW" } let payload = EditorTabPayload( diff --git a/TablePro/Views/Main/MainContentCoordinator.swift b/TablePro/Views/Main/MainContentCoordinator.swift index d18431a89..405f0c86c 100644 --- a/TablePro/Views/Main/MainContentCoordinator.swift +++ b/TablePro/Views/Main/MainContentCoordinator.swift @@ -699,6 +699,11 @@ final class MainContentCoordinator { return } + // Cassandra/ScyllaDB don't support EXPLAIN + if connection.type == .cassandra || connection.type == .scylladb { + return + } + guard let adapter = DatabaseManager.shared.driver(for: connectionId) as? PluginDriverAdapter, let explainSQL = adapter.buildExplainQuery(stmt) else { return diff --git a/TablePro/Views/Main/MainContentView.swift b/TablePro/Views/Main/MainContentView.swift index f5c663461..0b91ab4f5 100644 --- a/TablePro/Views/Main/MainContentView.swift +++ b/TablePro/Views/Main/MainContentView.swift @@ -331,12 +331,13 @@ struct MainContentView: View { } // Lazy-load: execute query for restored tabs that skipped auto-execute, // or re-query tabs whose row data was evicted while inactive. - if let tab = tabManager.selectedTab, - tab.tabType == .table, - tab.resultRows.isEmpty || tab.rowBuffer.isEvicted, - tab.lastExecutedAt == nil || tab.rowBuffer.isEvicted, - !tab.query.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty - { + let needsLazyLoad = tabManager.selectedTab.map { tab in + tab.tabType == .table + && (tab.resultRows.isEmpty || tab.rowBuffer.isEvicted) + && (tab.lastExecutedAt == nil || tab.rowBuffer.isEvicted) + && !tab.query.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty + } ?? false + if needsLazyLoad { coordinator.runQuery() } } diff --git a/TablePro/Views/Structure/TypePickerContentView.swift b/TablePro/Views/Structure/TypePickerContentView.swift index 35329d8c9..b49053e16 100644 --- a/TablePro/Views/Structure/TypePickerContentView.swift +++ b/TablePro/Views/Structure/TypePickerContentView.swift @@ -37,6 +37,8 @@ enum DataTypeCategory: String, CaseIterable { return ["INTEGER", "REAL", "NUMERIC"] case .duckdb: return ["INTEGER", "BIGINT", "HUGEINT", "SMALLINT", "TINYINT", "DOUBLE", "FLOAT", "DECIMAL", "REAL", "NUMERIC"] + case .cassandra, .scylladb: + return ["TINYINT", "SMALLINT", "INT", "BIGINT", "VARINT", "FLOAT", "DOUBLE", "DECIMAL", "COUNTER"] case .mongodb: return ["Int32", "Int64", "Double", "Decimal128"] case .redis: @@ -58,6 +60,8 @@ enum DataTypeCategory: String, CaseIterable { return ["TEXT"] case .duckdb: return ["VARCHAR", "TEXT", "CHAR", "BPCHAR"] + case .cassandra, .scylladb: + return ["TEXT", "VARCHAR", "ASCII"] case .mongodb: return ["String", "ObjectId", "UUID"] case .redis: @@ -79,6 +83,8 @@ enum DataTypeCategory: String, CaseIterable { return ["DATE", "DATETIME"] case .duckdb: return ["DATE", "TIME", "TIMESTAMP", "TIMESTAMP WITH TIME ZONE", "INTERVAL"] + case .cassandra, .scylladb: + return ["TIMESTAMP", "DATE", "TIME"] case .mongodb: return ["Date", "Timestamp"] case .redis: @@ -100,6 +106,8 @@ enum DataTypeCategory: String, CaseIterable { return ["BLOB"] case .duckdb: return ["BLOB", "BYTEA"] + case .cassandra, .scylladb: + return ["BLOB"] case .mongodb: return ["BinData"] case .redis: @@ -121,6 +129,8 @@ enum DataTypeCategory: String, CaseIterable { return ["BOOLEAN"] case .duckdb: return ["BOOLEAN", "UUID", "JSON", "LIST", "MAP", "STRUCT", "ENUM", "BIT", "UNION"] + case .cassandra, .scylladb: + return ["BOOLEAN", "UUID", "TIMEUUID", "INET", "LIST", "SET", "MAP", "TUPLE", "FROZEN"] case .mongodb: return ["Boolean", "Object", "Array", "Null", "Regex"] case .redis: diff --git a/TableProTests/Core/Utilities/DatabaseURLSchemeTests.swift b/TableProTests/Core/Utilities/DatabaseURLSchemeTests.swift index 6ad779a2c..44030fabf 100644 --- a/TableProTests/Core/Utilities/DatabaseURLSchemeTests.swift +++ b/TableProTests/Core/Utilities/DatabaseURLSchemeTests.swift @@ -195,13 +195,18 @@ struct DatabaseURLSchemeTests { #expect(error == .unsupportedScheme("http")) } - @Test("Cassandra scheme returns unsupported error") - func cassandraSchemeUnsupported() { + @Test("Cassandra scheme parses successfully") + func cassandraSchemeSupported() { let result = ConnectionURLParser.parse("cassandra://user:pass@host:9042/keyspace") - guard case .failure(let error) = result else { - Issue.record("Expected failure"); return + guard case .success(let parsed) = result else { + Issue.record("Expected success, got: \(result)"); return } - #expect(error == .unsupportedScheme("cassandra")) + #expect(parsed.type == .cassandra) + #expect(parsed.host == "host") + #expect(parsed.port == nil) // 9042 is the default port, so parser normalizes to nil + #expect(parsed.database == "keyspace") + #expect(parsed.username == "user") + #expect(parsed.password == "pass") } // MARK: - Case Insensitivity diff --git a/TableProTests/Models/DatabaseTypeCassandraTests.swift b/TableProTests/Models/DatabaseTypeCassandraTests.swift new file mode 100644 index 000000000..2a90534ee --- /dev/null +++ b/TableProTests/Models/DatabaseTypeCassandraTests.swift @@ -0,0 +1,115 @@ +import Testing +@testable import TablePro + +@Suite("DatabaseType Cassandra Properties") +struct DatabaseTypeCassandraTests { + @Test("Cassandra raw value is Cassandra") + func cassandraRawValue() { + #expect(DatabaseType.cassandra.rawValue == "Cassandra") + } + + @Test("ScyllaDB raw value is ScyllaDB") + func scylladbRawValue() { + #expect(DatabaseType.scylladb.rawValue == "ScyllaDB") + } + + @Test("Cassandra pluginTypeId is Cassandra") + func cassandraPluginTypeId() { + #expect(DatabaseType.cassandra.pluginTypeId == "Cassandra") + } + + @Test("ScyllaDB pluginTypeId is Cassandra") + func scylladbPluginTypeId() { + #expect(DatabaseType.scylladb.pluginTypeId == "Cassandra") + } + + @Test("Cassandra default port is 9042") + func cassandraDefaultPort() { + #expect(DatabaseType.cassandra.defaultPort == 9_042) + } + + @Test("ScyllaDB default port is 9042") + func scylladbDefaultPort() { + #expect(DatabaseType.scylladb.defaultPort == 9_042) + } + + @Test("Cassandra does not require authentication") + func cassandraRequiresAuthentication() { + #expect(DatabaseType.cassandra.requiresAuthentication == false) + } + + @Test("ScyllaDB does not require authentication") + func scylladbRequiresAuthentication() { + #expect(DatabaseType.scylladb.requiresAuthentication == false) + } + + @Test("Cassandra does not support foreign keys") + func cassandraSupportsForeignKeys() { + #expect(DatabaseType.cassandra.supportsForeignKeys == false) + } + + @Test("ScyllaDB does not support foreign keys") + func scylladbSupportsForeignKeys() { + #expect(DatabaseType.scylladb.supportsForeignKeys == false) + } + + @Test("Cassandra supports schema editing") + func cassandraSupportsSchemaEditing() { + #expect(DatabaseType.cassandra.supportsSchemaEditing == true) + } + + @Test("ScyllaDB supports schema editing") + func scylladbSupportsSchemaEditing() { + #expect(DatabaseType.scylladb.supportsSchemaEditing == true) + } + + @Test("Cassandra identifier quote is double quote") + func cassandraIdentifierQuote() { + #expect(DatabaseType.cassandra.identifierQuote == "\"") + } + + @Test("ScyllaDB identifier quote is double quote") + func scylladbIdentifierQuote() { + #expect(DatabaseType.scylladb.identifierQuote == "\"") + } + + @Test("Cassandra icon name is cassandra-icon") + func cassandraIconName() { + #expect(DatabaseType.cassandra.iconName == "cassandra-icon") + } + + @Test("ScyllaDB icon name is scylladb-icon") + func scylladbIconName() { + #expect(DatabaseType.scylladb.iconName == "scylladb-icon") + } + + @Test("Cassandra theme color matches Theme.cassandraColor") + func cassandraThemeColor() { + #expect(DatabaseType.cassandra.themeColor == Theme.cassandraColor) + } + + @Test("ScyllaDB theme color matches Theme.scylladbColor") + func scylladbThemeColor() { + #expect(DatabaseType.scylladb.themeColor == Theme.scylladbColor) + } + + @Test("Cassandra is a downloadable plugin") + func cassandraIsDownloadablePlugin() { + #expect(DatabaseType.cassandra.isDownloadablePlugin == true) + } + + @Test("ScyllaDB is a downloadable plugin") + func scylladbIsDownloadablePlugin() { + #expect(DatabaseType.scylladb.isDownloadablePlugin == true) + } + + @Test("Cassandra included in allCases") + func cassandraIncludedInAllCases() { + #expect(DatabaseType.allCases.contains(.cassandra)) + } + + @Test("ScyllaDB included in allCases") + func scylladbIncludedInAllCases() { + #expect(DatabaseType.allCases.contains(.scylladb)) + } +} diff --git a/TableProTests/Models/DatabaseTypeTests.swift b/TableProTests/Models/DatabaseTypeTests.swift index 09710a26c..d85397637 100644 --- a/TableProTests/Models/DatabaseTypeTests.swift +++ b/TableProTests/Models/DatabaseTypeTests.swift @@ -71,9 +71,9 @@ struct DatabaseTypeTests { #expect(result == "\"user\"\"s\"") } - @Test("CaseIterable count is 10") + @Test("CaseIterable count is 13") func testCaseIterableCount() { - #expect(DatabaseType.allCases.count == 10) + #expect(DatabaseType.allCases.count == 13) } @Test("Raw value matches display name", arguments: [ @@ -86,7 +86,9 @@ struct DatabaseTypeTests { (DatabaseType.redshift, "Redshift"), (DatabaseType.mssql, "SQL Server"), (DatabaseType.oracle, "Oracle"), - (DatabaseType.clickhouse, "ClickHouse") + (DatabaseType.clickhouse, "ClickHouse"), + (DatabaseType.cassandra, "Cassandra"), + (DatabaseType.scylladb, "ScyllaDB") ]) func testRawValueMatchesDisplayName(dbType: DatabaseType, expectedRawValue: String) { #expect(dbType.rawValue == expectedRawValue) diff --git a/docs/databases/cassandra.mdx b/docs/databases/cassandra.mdx new file mode 100644 index 000000000..41dd9d149 --- /dev/null +++ b/docs/databases/cassandra.mdx @@ -0,0 +1,357 @@ +--- +title: Cassandra / ScyllaDB +description: Connect to Cassandra and ScyllaDB clusters, browse keyspaces, and run CQL queries +--- + +# Cassandra / ScyllaDB Connections + +TablePro supports Apache Cassandra 3.11+ and ScyllaDB 4.0+ via the CQL native protocol. Browse keyspaces, inspect table structures, view materialized views, and run CQL queries from the editor. + +## Quick Setup + + + + Click **New Connection** from the Welcome screen or **File** > **New Connection** + + + Choose **Cassandra** or **ScyllaDB** from the database type selector + + + Fill in host, port, username, password, and keyspace + + + Click **Test Connection**, then **Create** + + + +## Connection Settings + +### Required Fields + +| Field | Description | Default | +|-------|-------------|---------| +| **Name** | Connection identifier | - | +| **Host** | Contact point hostname or IP | `localhost` | +| **Port** | CQL native transport port | `9042` | + +### Optional Fields + +| Field | Description | +|-------|-------------| +| **Username** | Authentication username | +| **Password** | Authentication password | +| **Keyspace** | Default keyspace to use after connecting | + + +Local Cassandra installations typically have authentication disabled. Leave username and password empty for local development. + + +## Connection URL Format + +Import connections using a Cassandra or ScyllaDB URL. + +See [Connection URL Reference](/databases/connection-urls#cassandra--scylladb) for the full URL format. + +## Example Configurations + +### Local Development Server + +``` +Name: Local Cassandra +Host: localhost +Port: 9042 +Username: (empty) +Password: (empty) +Keyspace: my_keyspace +``` + +### Docker Cassandra Container + +``` +Name: Docker Cassandra +Host: localhost +Port: 9042 (or your mapped port) +Username: cassandra +Password: cassandra +Keyspace: (empty) +``` + +### DataStax Astra DB (Cloud) + +``` +Name: Astra DB +Host: -.apps.astra.datastax.com +Port: 29042 +Username: (Client ID from token) +Password: (Client Secret from token) +Keyspace: my_keyspace +``` + + +Astra DB requires a Secure Connect Bundle for TLS. Download the bundle from the Astra dashboard and configure it in the SSL/TLS section. + + +### Remote Server + +``` +Name: Production Cassandra +Host: cassandra.example.com +Port: 9042 +Username: app_user +Password: (secure password) +Keyspace: production +``` + + +For production Cassandra clusters, consider using [SSH tunneling](/databases/ssh-tunneling) for secure connections. + + +## SSL/TLS Connections + +Configure SSL in the **SSL/TLS** section of the connection form. + +| SSL Mode | Description | +|----------|-------------| +| **Disabled** | No SSL encryption | +| **Required** | Require SSL encryption | +| **Verify CA** | Require SSL and verify the server certificate against a CA | + +For **Verify CA** mode, provide the path to your CA certificate file. You can also provide optional client certificate and key files for mutual TLS. + + +If you'd rather skip SSL certificate setup, [SSH tunneling](/databases/ssh-tunneling) encrypts all traffic through an SSH tunnel instead. + + +## SSH Tunnel Support + +Connect to Cassandra through an SSH tunnel for secure access to remote clusters. See [SSH Tunneling](/databases/ssh-tunneling) for setup instructions. + +## Features + +### Keyspace Browsing + +After connecting, the sidebar lists all keyspaces. Expand a keyspace to see its tables, materialized views, user-defined types (UDTs), and secondary indexes. + +1. Click the connection name in the sidebar +2. Expand a keyspace to see its objects +3. Click a table to view its data + +### Table Structure + +View the full schema for any table: + +- **Columns**: name, CQL type, clustering order +- **Partition key**: columns that determine data distribution +- **Clustering columns**: columns that determine row ordering within a partition +- **Secondary indexes**: index name, target column, index class +- **Table options**: compaction strategy, compression, TTL defaults, gc_grace_seconds + +### Materialized Views + +Browse materialized views alongside tables in the sidebar. View their definition, base table, and column mappings. + +### Data Grid + +Browse table data with pagination. Cell values display with CQL type-aware formatting: + +- **text/varchar** values show as plain text +- **int/bigint/varint** display as numbers +- **uuid/timeuuid** display as formatted UUIDs +- **timestamp** values display with configurable date formatting +- **map/set/list/tuple** display as formatted collections +- **blob** values display as hex + +### CQL Editor + +Execute CQL statements directly in the editor tab: + +```sql +-- Select with partition key restriction +SELECT * FROM users WHERE user_id = 123e4567-e89b-12d3-a456-426614174000; + +-- Insert data +INSERT INTO users (user_id, name, email, created_at) +VALUES (uuid(), 'Alice', 'alice@example.com', toTimestamp(now())); + +-- Update with TTL +UPDATE users USING TTL 86400 +SET email = 'new@example.com' +WHERE user_id = 123e4567-e89b-12d3-a456-426614174000; + +-- Delete +DELETE FROM users WHERE user_id = 123e4567-e89b-12d3-a456-426614174000; + +-- Create table +CREATE TABLE IF NOT EXISTS events ( + event_id timeuuid, + user_id uuid, + event_type text, + payload text, + PRIMARY KEY ((user_id), event_id) +) WITH CLUSTERING ORDER BY (event_id DESC); + +-- Create index +CREATE INDEX ON users (email); + +-- Describe table +DESCRIBE TABLE users; +``` + +## CQL-Specific Notes + +Cassandra Query Language (CQL) looks like SQL but has important differences: + +### No JOINs + +CQL does not support JOIN operations. Design your data model around query patterns, denormalizing data across multiple tables as needed. + +### No Subqueries + +CQL does not support subqueries. Break complex queries into multiple sequential statements. + +### Partition Key Restrictions + +Every SELECT query must include the full partition key in the WHERE clause, unless you use `ALLOW FILTERING` (which scans the entire cluster and should be avoided in production). + +```sql +-- Good: includes partition key +SELECT * FROM orders WHERE customer_id = 42; + +-- Bad: missing partition key, requires ALLOW FILTERING +SELECT * FROM orders WHERE total > 100 ALLOW FILTERING; +``` + +### ALLOW FILTERING + +The `ALLOW FILTERING` clause forces a full cluster scan. It works for development and small datasets but causes timeouts and performance issues on production clusters. TablePro shows a warning when a query includes `ALLOW FILTERING`. + +### Lightweight Transactions + +Cassandra supports conditional writes using `IF` clauses (lightweight transactions / compare-and-set): + +```sql +INSERT INTO users (user_id, email) VALUES (uuid(), 'alice@example.com') IF NOT EXISTS; +UPDATE users SET email = 'new@example.com' WHERE user_id = ? IF email = 'old@example.com'; +``` + +### TTL and Writetime + +Set per-row or per-column TTL (time-to-live) in seconds: + +```sql +INSERT INTO cache (key, value) VALUES ('k1', 'v1') USING TTL 3600; +SELECT TTL(value), WRITETIME(value) FROM cache WHERE key = 'k1'; +``` + +## Troubleshooting + +### Connection Refused + +**Symptoms**: "Connection refused" or timeout + +**Causes and Solutions**: + +1. **Cassandra not running** + ```bash + # Check if Cassandra is running + nodetool status + + # Start Cassandra (macOS with Homebrew) + brew services start cassandra + + # Start Cassandra (Docker) + docker run -d -p 9042:9042 cassandra:latest + ``` + +2. **Wrong port** + - Verify `native_transport_port` in `cassandra.yaml` + - Default CQL port is `9042`, not `9160` (Thrift, deprecated) + +3. **Cassandra not listening on the expected address** + - Check `rpc_address` and `listen_address` in `cassandra.yaml` + - For remote connections, set `rpc_address` to `0.0.0.0` + +### Authentication Failed + +**Symptoms**: "Provided username and/or password are incorrect" + +**Solutions**: + +1. Verify credentials match the role configured in Cassandra +2. Check if authentication is enabled: + ```yaml + # cassandra.yaml + authenticator: PasswordAuthenticator + ``` +3. Default superuser is `cassandra` / `cassandra` (change this in production) + +### Connection Timeout + +**Symptoms**: Connection hangs or times out + +**Solutions**: + +1. Verify the host and port are correct +2. Check network connectivity and firewall rules (port 9042) +3. For cloud-hosted Cassandra, ensure your IP is in the allowed list +4. Increase the connection timeout in the Advanced tab + +### Read Timeout + +**Symptoms**: "Read timed out" on queries + +**Solutions**: + +1. Add the full partition key to your WHERE clause +2. Remove `ALLOW FILTERING` and redesign the query +3. Check cluster health with `nodetool status` +4. Reduce the result set with `LIMIT` + +## Known Limitations + +- **Multi-datacenter**: connecting to a specific datacenter is not yet configurable. TablePro connects to whichever node the contact point resolves to. +- **User-Defined Functions (UDFs)**: UDFs and UDAs are not displayed in the sidebar but can be used in CQL queries. +- **BATCH statements**: supported in the CQL editor but not generated by the change tracking system. +- **Counter tables**: counter columns are read-only in the data grid. Use the CQL editor for counter updates. +- **Large partitions**: partitions with millions of rows are paginated automatically to prevent memory issues. + +## Performance Tips + +### Query Performance + +For Cassandra clusters with large datasets: + +1. Always include the partition key in WHERE clauses +2. Avoid `ALLOW FILTERING` in production +3. Use `LIMIT` to cap result sets +4. Use `TOKEN()` for range scans across partitions + +### Monitoring + +Check cluster health and performance: + +```sql +-- Check cluster status (via nodetool, not CQL) +-- nodetool status +-- nodetool info + +-- Check table statistics +SELECT * FROM system.size_estimates WHERE keyspace_name = 'my_keyspace'; +``` + +## Next Steps + + + + Connect securely to remote Cassandra clusters + + + Master the query editor features + + + Import and export Cassandra data + + + Browse and edit data in the data grid + + diff --git a/docs/databases/connection-urls.mdx b/docs/databases/connection-urls.mdx index 42cc9aa01..716ac7a37 100644 --- a/docs/databases/connection-urls.mdx +++ b/docs/databases/connection-urls.mdx @@ -25,6 +25,8 @@ TablePro parses standard database connection URLs for importing connections, ope | `sqlserver://` | Microsoft SQL Server (alias) | | `oracle://` | Oracle Database | | `jdbc:oracle:thin:@//` | Oracle Database (JDBC thin) | +| `cassandra://` | Cassandra | +| `scylladb://` | ScyllaDB | Append `+ssh` to any scheme (except SQLite) to use an SSH tunnel: @@ -164,6 +166,16 @@ redis://:password@host:6379/2 # database index 2 rediss://:password@host:6380 # TLS, default index 0 ``` +### Cassandra / ScyllaDB + +The path component sets the default keyspace. Both `cassandra://` and `scylladb://` schemes use the same format. + +``` +cassandra://user:pass@host:9042/my_keyspace +scylladb://user:pass@host:9042/my_keyspace +cassandra://host:9042 # no auth, no default keyspace +``` + ### SSH Tunnel | Parameter | Description | diff --git a/docs/databases/overview.mdx b/docs/databases/overview.mdx index cea7c5fa4..ba7f54e06 100644 --- a/docs/databases/overview.mdx +++ b/docs/databases/overview.mdx @@ -1,15 +1,15 @@ --- title: Connection Management -description: Create, organize, and manage database connections across 10 supported engines in TablePro +description: Create, organize, and manage database connections across 12 supported engines in TablePro --- # Connection Management -TablePro connects to ten database systems from a single interface. Create connections, organize them with colors, tags, and groups, and switch between them without leaving your workflow. +TablePro connects to twelve database systems from a single interface. Create connections, organize them with colors, tags, and groups, and switch between them without leaving your workflow. ## Supported Databases -TablePro supports ten database systems natively: +TablePro supports twelve database systems natively: @@ -42,6 +42,9 @@ TablePro supports ten database systems natively: ClickHouse OLAP database via HTTP API. Default port: 8123 + + Cassandra 3.11+ and ScyllaDB 4.0+ via CQL native protocol. Default port: 9042 + ## Creating a Connection @@ -105,7 +108,7 @@ open "mysql://root:secret@localhost:3306/myapp" open "redis://:password@localhost:6379" ``` -TablePro registers `postgresql`, `postgres`, `mysql`, `mariadb`, `sqlite`, `mongodb`, `mongodb+srv`, `redis`, `rediss`, `redshift`, `mssql`, `sqlserver`, `oracle`, and `clickhouse` as URL schemes on macOS, so the OS routes these URLs directly to the app. +TablePro registers `postgresql`, `postgres`, `mysql`, `mariadb`, `sqlite`, `mongodb`, `mongodb+srv`, `redis`, `rediss`, `redshift`, `mssql`, `sqlserver`, `oracle`, `clickhouse`, `cassandra`, and `scylladb` as URL schemes on macOS, so the OS routes these URLs directly to the app. **What happens:** @@ -128,7 +131,7 @@ This is different from **Import from URL**, which fills in the connection form s | Field | Description | |-------|-------------| | **Name** | A friendly name to identify this connection | -| **Type** | Database type: MySQL, MariaDB, PostgreSQL, SQLite, MongoDB, Redis, Redshift, SQL Server, or Oracle | +| **Type** | Database type: MySQL, MariaDB, PostgreSQL, SQLite, MongoDB, Redis, Redshift, SQL Server, Oracle, ClickHouse, Cassandra, or ScyllaDB | #### Appearance Section @@ -569,6 +572,8 @@ TablePro auto-fills the port when you select a database type: | Microsoft SQL Server | 1433 | | Oracle Database | 1521 | | ClickHouse | 8123 | +| Cassandra | 9042 | +| ScyllaDB | 9042 | ## Related Guides @@ -600,6 +605,9 @@ TablePro auto-fills the port when you select a database type: ClickHouse OLAP database connections + + Cassandra and ScyllaDB CQL connections + Secure connections through SSH diff --git a/docs/docs.json b/docs/docs.json index 797910318..8101323f0 100644 --- a/docs/docs.json +++ b/docs/docs.json @@ -41,6 +41,7 @@ "databases/redshift", "databases/oracle", "databases/clickhouse", + "databases/cassandra", "databases/mssql", "databases/oracle", "databases/ssh-tunneling" @@ -134,6 +135,7 @@ "vi/databases/redshift", "vi/databases/oracle", "vi/databases/clickhouse", + "vi/databases/cassandra", "vi/databases/mssql", "vi/databases/oracle", "vi/databases/ssh-tunneling" diff --git a/docs/vi/databases/cassandra.mdx b/docs/vi/databases/cassandra.mdx new file mode 100644 index 000000000..738e6a46f --- /dev/null +++ b/docs/vi/databases/cassandra.mdx @@ -0,0 +1,357 @@ +--- +title: Cassandra / ScyllaDB +description: Kết nối Cassandra và ScyllaDB cluster, duyệt keyspace và chạy truy vấn CQL +--- + +# Kết nối Cassandra / ScyllaDB + +TablePro hỗ trợ Apache Cassandra 3.11+ và ScyllaDB 4.0+ qua giao thức CQL native. Duyệt keyspace, xem cấu trúc bảng, materialized view và chạy truy vấn CQL từ editor. + +## Thiết lập Nhanh + + + + Nhấp **New Connection** từ màn hình Chào mừng hoặc **File** > **New Connection** + + + Chọn **Cassandra** hoặc **ScyllaDB** từ trình chọn loại database + + + Điền host, port, username, password và keyspace + + + Nhấp **Test Connection**, rồi **Create** + + + +## Cài đặt Kết nối + +### Trường Bắt buộc + +| Trường | Mô tả | Mặc định | +|-------|-------------|---------| +| **Name** | Tên định danh kết nối | - | +| **Host** | Hostname hoặc IP contact point | `localhost` | +| **Port** | Cổng CQL native transport | `9042` | + +### Trường Tùy chọn + +| Trường | Mô tả | +|-------|-------------| +| **Username** | Tên đăng nhập | +| **Password** | Mật khẩu | +| **Keyspace** | Keyspace mặc định sau khi kết nối | + + +Cassandra cài local thường tắt xác thực. Để trống username và password cho dev local. + + +## Định dạng URL + +Import kết nối bằng Cassandra hoặc ScyllaDB URL. + +Xem [Tham chiếu URL kết nối](/vi/databases/connection-urls#cassandra--scylladb) để biết format đầy đủ. + +## Ví dụ Cấu hình + +### Server Dev Local + +``` +Name: Local Cassandra +Host: localhost +Port: 9042 +Username: (để trống) +Password: (để trống) +Keyspace: my_keyspace +``` + +### Docker Cassandra Container + +``` +Name: Docker Cassandra +Host: localhost +Port: 9042 (hoặc cổng mapped) +Username: cassandra +Password: cassandra +Keyspace: (để trống) +``` + +### DataStax Astra DB (Cloud) + +``` +Name: Astra DB +Host: -.apps.astra.datastax.com +Port: 29042 +Username: (Client ID từ token) +Password: (Client Secret từ token) +Keyspace: my_keyspace +``` + + +Astra DB yêu cầu Secure Connect Bundle cho TLS. Tải bundle từ Astra dashboard và cấu hình trong phần SSL/TLS. + + +### Server Từ xa + +``` +Name: Production Cassandra +Host: cassandra.example.com +Port: 9042 +Username: app_user +Password: (mật khẩu bảo mật) +Keyspace: production +``` + + +Cho Cassandra cluster production, nên dùng [SSH tunneling](/vi/databases/ssh-tunneling) để kết nối an toàn. + + +## Kết nối SSL/TLS + +Cấu hình SSL trong phần **SSL/TLS** của form kết nối. + +| Chế độ SSL | Mô tả | +|----------|-------------| +| **Disabled** | Không mã hóa SSL | +| **Required** | Bắt buộc SSL | +| **Verify CA** | Bắt buộc SSL và xác minh chứng chỉ server với CA | + +Với **Verify CA**, cung cấp file chứng chỉ CA. Tùy chọn thêm file chứng chỉ client và key cho mutual TLS. + + +Nếu không muốn cấu hình chứng chỉ SSL, [SSH tunneling](/vi/databases/ssh-tunneling) mã hóa toàn bộ traffic qua tunnel SSH. + + +## Hỗ trợ SSH Tunnel + +Kết nối Cassandra qua SSH tunnel để truy cập an toàn cluster từ xa. Xem [SSH Tunneling](/vi/databases/ssh-tunneling) để biết cách cài đặt. + +## Tính năng + +### Duyệt Keyspace + +Sau khi kết nối, sidebar liệt kê tất cả keyspace. Mở rộng keyspace để xem bảng, materialized view, user-defined type (UDT) và secondary index. + +1. Nhấp tên kết nối trong sidebar +2. Mở rộng keyspace để xem các đối tượng +3. Nhấp bảng để xem dữ liệu + +### Cấu trúc Bảng + +Xem schema đầy đủ cho bất kỳ bảng nào: + +- **Cột**: tên, kiểu CQL, thứ tự clustering +- **Partition key**: cột xác định phân phối dữ liệu +- **Clustering column**: cột xác định thứ tự hàng trong partition +- **Secondary index**: tên index, cột đích, lớp index +- **Tùy chọn bảng**: chiến lược compaction, compression, TTL mặc định, gc_grace_seconds + +### Materialized View + +Duyệt materialized view cạnh bảng trong sidebar. Xem định nghĩa, bảng gốc và ánh xạ cột. + +### Data Grid + +Duyệt dữ liệu bảng với phân trang. Giá trị hiển thị theo kiểu CQL: + +- **text/varchar** hiển thị văn bản thuần +- **int/bigint/varint** hiển thị số +- **uuid/timeuuid** hiển thị UUID đã format +- **timestamp** hiển thị với format ngày tùy chỉnh +- **map/set/list/tuple** hiển thị collection đã format +- **blob** hiển thị dạng hex + +### CQL Editor + +Chạy lệnh CQL trực tiếp trong editor tab: + +```sql +-- Select với partition key +SELECT * FROM users WHERE user_id = 123e4567-e89b-12d3-a456-426614174000; + +-- Thêm dữ liệu +INSERT INTO users (user_id, name, email, created_at) +VALUES (uuid(), 'Alice', 'alice@example.com', toTimestamp(now())); + +-- Cập nhật với TTL +UPDATE users USING TTL 86400 +SET email = 'new@example.com' +WHERE user_id = 123e4567-e89b-12d3-a456-426614174000; + +-- Xóa +DELETE FROM users WHERE user_id = 123e4567-e89b-12d3-a456-426614174000; + +-- Tạo bảng +CREATE TABLE IF NOT EXISTS events ( + event_id timeuuid, + user_id uuid, + event_type text, + payload text, + PRIMARY KEY ((user_id), event_id) +) WITH CLUSTERING ORDER BY (event_id DESC); + +-- Tạo index +CREATE INDEX ON users (email); + +-- Mô tả bảng +DESCRIBE TABLE users; +``` + +## Lưu ý CQL + +Cassandra Query Language (CQL) giống SQL nhưng có các khác biệt quan trọng: + +### Không có JOIN + +CQL không hỗ trợ JOIN. Thiết kế data model theo query pattern, denormalize dữ liệu qua nhiều bảng khi cần. + +### Không có Subquery + +CQL không hỗ trợ subquery. Tách truy vấn phức tạp thành nhiều lệnh tuần tự. + +### Hạn chế Partition Key + +Mọi truy vấn SELECT phải có đầy đủ partition key trong WHERE, trừ khi dùng `ALLOW FILTERING` (quét toàn bộ cluster, nên tránh trong production). + +```sql +-- Tốt: có partition key +SELECT * FROM orders WHERE customer_id = 42; + +-- Không tốt: thiếu partition key, cần ALLOW FILTERING +SELECT * FROM orders WHERE total > 100 ALLOW FILTERING; +``` + +### ALLOW FILTERING + +`ALLOW FILTERING` buộc quét toàn bộ cluster. Dùng được cho dev và dataset nhỏ nhưng gây timeout trên cluster production. TablePro hiển thị cảnh báo khi truy vấn có `ALLOW FILTERING`. + +### Lightweight Transaction + +Cassandra hỗ trợ ghi có điều kiện dùng mệnh đề `IF` (lightweight transaction / compare-and-set): + +```sql +INSERT INTO users (user_id, email) VALUES (uuid(), 'alice@example.com') IF NOT EXISTS; +UPDATE users SET email = 'new@example.com' WHERE user_id = ? IF email = 'old@example.com'; +``` + +### TTL và Writetime + +Đặt TTL (thời gian sống) theo giây cho mỗi hàng hoặc cột: + +```sql +INSERT INTO cache (key, value) VALUES ('k1', 'v1') USING TTL 3600; +SELECT TTL(value), WRITETIME(value) FROM cache WHERE key = 'k1'; +``` + +## Khắc phục sự cố + +### Kết nối Bị từ chối + +**Triệu chứng**: "Connection refused" hoặc timeout + +**Nguyên nhân và Giải pháp**: + +1. **Cassandra không chạy** + ```bash + # Kiểm tra Cassandra + nodetool status + + # Khởi động (macOS Homebrew) + brew services start cassandra + + # Khởi động (Docker) + docker run -d -p 9042:9042 cassandra:latest + ``` + +2. **Sai cổng** + - Kiểm tra `native_transport_port` trong `cassandra.yaml` + - Cổng CQL mặc định là `9042`, không phải `9160` (Thrift, đã deprecated) + +3. **Cassandra không lắng nghe đúng địa chỉ** + - Kiểm tra `rpc_address` và `listen_address` trong `cassandra.yaml` + - Cho kết nối remote, đặt `rpc_address` thành `0.0.0.0` + +### Xác thực Thất bại + +**Triệu chứng**: "Provided username and/or password are incorrect" + +**Giải pháp**: + +1. Kiểm tra thông tin đăng nhập khớp role cấu hình trong Cassandra +2. Kiểm tra xác thực đã bật: + ```yaml + # cassandra.yaml + authenticator: PasswordAuthenticator + ``` +3. Superuser mặc định là `cassandra` / `cassandra` (đổi trong production) + +### Hết thời gian Kết nối + +**Triệu chứng**: Kết nối treo hoặc timeout + +**Giải pháp**: + +1. Kiểm tra host và port đúng +2. Kiểm tra mạng và firewall (cổng 9042) +3. Cho Cassandra cloud, đảm bảo IP nằm trong danh sách cho phép +4. Tăng timeout kết nối trong tab Advanced + +### Read Timeout + +**Triệu chứng**: "Read timed out" khi truy vấn + +**Giải pháp**: + +1. Thêm đầy đủ partition key vào WHERE +2. Bỏ `ALLOW FILTERING` và thiết kế lại truy vấn +3. Kiểm tra sức khỏe cluster bằng `nodetool status` +4. Giảm tập kết quả bằng `LIMIT` + +## Hạn chế + +- **Multi-datacenter**: chưa hỗ trợ cấu hình datacenter cụ thể. TablePro kết nối đến node mà contact point phân giải. +- **User-Defined Function (UDF)**: UDF và UDA không hiển thị trong sidebar nhưng dùng được trong truy vấn CQL. +- **BATCH**: hỗ trợ trong CQL editor nhưng change tracking không tạo BATCH. +- **Counter table**: cột counter chỉ đọc trong data grid. Dùng CQL editor để cập nhật counter. +- **Partition lớn**: partition có hàng triệu hàng được phân trang tự động để tránh vấn đề bộ nhớ. + +## Mẹo Hiệu suất + +### Hiệu suất Truy vấn + +Cho Cassandra cluster có dataset lớn: + +1. Luôn có partition key trong WHERE +2. Tránh `ALLOW FILTERING` trong production +3. Dùng `LIMIT` để giới hạn kết quả +4. Dùng `TOKEN()` cho range scan qua nhiều partition + +### Giám sát + +Kiểm tra sức khỏe và hiệu suất cluster: + +```sql +-- Kiểm tra trạng thái cluster (qua nodetool, không phải CQL) +-- nodetool status +-- nodetool info + +-- Kiểm tra thống kê bảng +SELECT * FROM system.size_estimates WHERE keyspace_name = 'my_keyspace'; +``` + +## Các bước tiếp theo + + + + Kết nối an toàn đến Cassandra cluster từ xa + + + Các tính năng query editor + + + Import và export dữ liệu Cassandra + + + Duyệt và chỉnh sửa dữ liệu trong data grid + + diff --git a/docs/vi/databases/connection-urls.mdx b/docs/vi/databases/connection-urls.mdx index bd17b287e..ee0653a8f 100644 --- a/docs/vi/databases/connection-urls.mdx +++ b/docs/vi/databases/connection-urls.mdx @@ -25,6 +25,8 @@ TablePro phân tích URL kết nối database chuẩn để import kết nối, | `sqlserver://` | Microsoft SQL Server (alias) | | `oracle://` | Oracle Database | | `jdbc:oracle:thin:@//` | Oracle Database (JDBC thin) | +| `cassandra://` | Cassandra | +| `scylladb://` | ScyllaDB | Thêm `+ssh` vào bất kỳ scheme nào (trừ SQLite) để dùng SSH tunnel: @@ -164,6 +166,16 @@ redis://:password@host:6379/2 # database index 2 rediss://:password@host:6380 # TLS, index mặc định 0 ``` +### Cassandra / ScyllaDB + +Phần path đặt keyspace mặc định. Cả hai scheme `cassandra://` và `scylladb://` dùng cùng format. + +``` +cassandra://user:pass@host:9042/my_keyspace +scylladb://user:pass@host:9042/my_keyspace +cassandra://host:9042 # không auth, không keyspace mặc định +``` + ### SSH Tunnel | Parameter | Mô tả | diff --git a/docs/vi/databases/overview.mdx b/docs/vi/databases/overview.mdx index a91785f34..98f00542d 100644 --- a/docs/vi/databases/overview.mdx +++ b/docs/vi/databases/overview.mdx @@ -1,15 +1,15 @@ --- title: Quản lý Kết nối -description: Tạo, tổ chức và quản lý kết nối đến 10 hệ quản trị cơ sở dữ liệu từ một giao diện duy nhất +description: Tạo, tổ chức và quản lý kết nối đến 12 hệ quản trị cơ sở dữ liệu từ một giao diện duy nhất --- # Quản lý Kết nối -TablePro kết nối được đến 10 hệ quản trị cơ sở dữ liệu từ cùng một giao diện. Tạo kết nối, sắp xếp bằng màu sắc, tag và nhóm, rồi chuyển đổi giữa chúng mà không cần rời khỏi cửa sổ làm việc. +TablePro kết nối được đến 12 hệ quản trị cơ sở dữ liệu từ cùng một giao diện. Tạo kết nối, sắp xếp bằng màu sắc, tag và nhóm, rồi chuyển đổi giữa chúng mà không cần rời khỏi cửa sổ làm việc. ## Cơ sở dữ liệu được hỗ trợ -TablePro hỗ trợ 10 hệ thống cơ sở dữ liệu: +TablePro hỗ trợ 12 hệ thống cơ sở dữ liệu: @@ -42,6 +42,9 @@ TablePro hỗ trợ 10 hệ thống cơ sở dữ liệu: Cơ sở dữ liệu OLAP ClickHouse qua HTTP API. Cổng mặc định: 8123 + + Cassandra 3.11+ và ScyllaDB 4.0+ qua giao thức CQL native. Cổng mặc định: 9042 + ## Tạo Kết nối @@ -105,7 +108,7 @@ open "mysql://root:secret@localhost:3306/myapp" open "redis://:password@localhost:6379" ``` -TablePro đăng ký `postgresql`, `postgres`, `mysql`, `mariadb`, `sqlite`, `mongodb`, `mongodb+srv`, `redis`, `rediss`, `redshift`, `mssql`, `sqlserver`, `oracle` và `clickhouse` là các URL scheme trên macOS, nên hệ điều hành sẽ chuyển hướng các URL này trực tiếp đến ứng dụng. +TablePro đăng ký `postgresql`, `postgres`, `mysql`, `mariadb`, `sqlite`, `mongodb`, `mongodb+srv`, `redis`, `rediss`, `redshift`, `mssql`, `sqlserver`, `oracle`, `clickhouse`, `cassandra` và `scylladb` là các URL scheme trên macOS, nên hệ điều hành sẽ chuyển hướng các URL này trực tiếp đến ứng dụng. **Khi mở URL:** @@ -128,7 +131,7 @@ Khác với **Import from URL** (điền form để bạn xem xét và lưu), m | Trường | Mô tả | |-------|-------------| | **Name** | Tên thân thiện để xác định kết nối này | -| **Type** | Loại cơ sở dữ liệu: MySQL, MariaDB, PostgreSQL, SQLite, MongoDB, Redis, Redshift, SQL Server hoặc Oracle | +| **Type** | Loại cơ sở dữ liệu: MySQL, MariaDB, PostgreSQL, SQLite, MongoDB, Redis, Redshift, SQL Server, Oracle, ClickHouse, Cassandra hoặc ScyllaDB | #### Phần Appearance @@ -569,6 +572,8 @@ TablePro tự động điền cổng khi chọn loại database: | Microsoft SQL Server | 1433 | | Oracle Database | 1521 | | ClickHouse | 8123 | +| Cassandra | 9042 | +| ScyllaDB | 9042 | ## Hướng dẫn Liên quan @@ -600,6 +605,9 @@ TablePro tự động điền cổng khi chọn loại database: Kết nối cơ sở dữ liệu OLAP ClickHouse + + Kết nối Cassandra và ScyllaDB qua CQL + Kết nối an toàn qua SSH diff --git a/scripts/build-cassandra.sh b/scripts/build-cassandra.sh new file mode 100755 index 000000000..18aad4073 --- /dev/null +++ b/scripts/build-cassandra.sh @@ -0,0 +1,168 @@ +#!/bin/bash +set -euo pipefail + +# Build DataStax C/C++ driver (cassandra-cpp-driver) static library for TablePro +# Usage: ./scripts/build-cassandra.sh [arm64|x86_64|both] +# +# Dependencies: cmake, libuv (built automatically), OpenSSL (from Libs/) + +CASSANDRA_VERSION="2.17.1" +LIBUV_VERSION="1.48.0" +BUILD_DIR="/tmp/cassandra-build" +LIBS_DIR="$(cd "$(dirname "$0")/.." && pwd)/Libs" +HEADERS_DIR="$(cd "$(dirname "$0")/.." && pwd)/Plugins/CassandraDriverPlugin/CCassandra/include" +ARCH="${1:-both}" +MACOS_TARGET="14.0" + +echo "Building DataStax Cassandra C driver $CASSANDRA_VERSION..." + +mkdir -p "$BUILD_DIR" +mkdir -p "$LIBS_DIR" +mkdir -p "$HEADERS_DIR" + +# --- Build libuv --- +build_libuv() { + local arch=$1 + local uv_build_dir="$BUILD_DIR/libuv-build-${arch}" + + if [ -f "$LIBS_DIR/libuv_${arch}.a" ]; then + echo "✅ libuv_${arch}.a already exists, skipping" + return 0 + fi + + echo "📦 Building libuv $LIBUV_VERSION for $arch..." + cd "$BUILD_DIR" + + if [ ! -d "libuv-v${LIBUV_VERSION}" ]; then + curl -sL "https://dist.libuv.org/dist/v${LIBUV_VERSION}/libuv-v${LIBUV_VERSION}.tar.gz" -o libuv.tar.gz + tar xzf libuv.tar.gz + fi + + rm -rf "$uv_build_dir" + mkdir -p "$uv_build_dir" + + cmake -S "libuv-v${LIBUV_VERSION}" -B "$uv_build_dir" \ + -DCMAKE_OSX_ARCHITECTURES="$arch" \ + -DCMAKE_OSX_DEPLOYMENT_TARGET="$MACOS_TARGET" \ + -DCMAKE_BUILD_TYPE=Release \ + -DLIBUV_BUILD_TESTS=OFF \ + -DLIBUV_BUILD_BENCH=OFF \ + -DBUILD_TESTING=OFF + + cmake --build "$uv_build_dir" --config Release -j "$(sysctl -n hw.ncpu)" + + cp "$uv_build_dir/libuv_a.a" "$LIBS_DIR/libuv_${arch}.a" 2>/dev/null \ + || cp "$uv_build_dir/libuv.a" "$LIBS_DIR/libuv_${arch}.a" + + echo "✅ Created libuv_${arch}.a" +} + +# --- Build cassandra-cpp-driver --- +build_cassandra() { + local arch=$1 + local cass_build_dir="$BUILD_DIR/cassandra-build-${arch}" + + if [ -f "$LIBS_DIR/libcassandra_${arch}.a" ]; then + echo "✅ libcassandra_${arch}.a already exists, skipping" + return 0 + fi + + echo "📦 Building cassandra-cpp-driver $CASSANDRA_VERSION for $arch..." + cd "$BUILD_DIR" + + if [ ! -d "cassandra-cpp-driver-${CASSANDRA_VERSION}" ]; then + curl -sL "https://github.com/datastax/cpp-driver/archive/refs/tags/${CASSANDRA_VERSION}.tar.gz" -o cpp-driver.tar.gz + tar xzf cpp-driver.tar.gz + fi + + # Patch CMakeLists.txt to accept AppleClang (macOS default compiler) + sed -i '' 's/"${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"/"${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang"/g' \ + "cassandra-cpp-driver-${CASSANDRA_VERSION}/CMakeLists.txt" + + rm -rf "$cass_build_dir" + mkdir -p "$cass_build_dir" + + cmake -S "cassandra-cpp-driver-${CASSANDRA_VERSION}" -B "$cass_build_dir" \ + -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \ + -DCMAKE_OSX_ARCHITECTURES="$arch" \ + -DCMAKE_OSX_DEPLOYMENT_TARGET="$MACOS_TARGET" \ + -DCMAKE_BUILD_TYPE=Release \ + -DCASS_BUILD_STATIC=ON \ + -DCASS_BUILD_SHARED=OFF \ + -DCASS_BUILD_TESTS=OFF \ + -DCASS_BUILD_EXAMPLES=OFF \ + -DCASS_USE_OPENSSL=ON \ + -DOPENSSL_ROOT_DIR="$(brew --prefix openssl@3 2>/dev/null || echo /usr/local/opt/openssl)" \ + -DLIBUV_ROOT_DIR="$BUILD_DIR/libuv-v${LIBUV_VERSION}" \ + -DLIBUV_LIBRARY="$LIBS_DIR/libuv_${arch}.a" \ + -DLIBUV_INCLUDE_DIR="$BUILD_DIR/libuv-v${LIBUV_VERSION}/include" + + cmake --build "$cass_build_dir" --config Release -j "$(sysctl -n hw.ncpu)" + + cp "$cass_build_dir/libcassandra_static.a" "$LIBS_DIR/libcassandra_${arch}.a" 2>/dev/null \ + || cp "$cass_build_dir/libcassandra.a" "$LIBS_DIR/libcassandra_${arch}.a" + + echo "✅ Created libcassandra_${arch}.a" +} + +# --- Copy headers --- +copy_headers() { + echo "📋 Copying cassandra.h header..." + cd "$BUILD_DIR" + + if [ -f "cassandra-cpp-driver-${CASSANDRA_VERSION}/include/cassandra.h" ]; then + cp "cassandra-cpp-driver-${CASSANDRA_VERSION}/include/cassandra.h" "$HEADERS_DIR/" + echo "✅ Copied cassandra.h" + else + echo "❌ cassandra.h not found!" + exit 1 + fi +} + +# --- Main --- +case "$ARCH" in + arm64) + build_libuv arm64 + build_cassandra arm64 + cp "$LIBS_DIR/libcassandra_arm64.a" "$LIBS_DIR/libcassandra.a" + cp "$LIBS_DIR/libuv_arm64.a" "$LIBS_DIR/libuv.a" + copy_headers + ;; + x86_64) + build_libuv x86_64 + build_cassandra x86_64 + cp "$LIBS_DIR/libcassandra_x86_64.a" "$LIBS_DIR/libcassandra.a" + cp "$LIBS_DIR/libuv_x86_64.a" "$LIBS_DIR/libuv.a" + copy_headers + ;; + both|universal) + build_libuv arm64 + build_libuv x86_64 + build_cassandra arm64 + build_cassandra x86_64 + + echo "Creating universal binaries..." + lipo -create "$LIBS_DIR/libcassandra_arm64.a" "$LIBS_DIR/libcassandra_x86_64.a" \ + -output "$LIBS_DIR/libcassandra_universal.a" + cp "$LIBS_DIR/libcassandra_universal.a" "$LIBS_DIR/libcassandra.a" + + lipo -create "$LIBS_DIR/libuv_arm64.a" "$LIBS_DIR/libuv_x86_64.a" \ + -output "$LIBS_DIR/libuv_universal.a" + cp "$LIBS_DIR/libuv_universal.a" "$LIBS_DIR/libuv.a" + + echo "✅ Created universal binaries" + copy_headers + ;; + *) + echo "Usage: $0 [arm64|x86_64|both]" + exit 1 + ;; +esac + +echo "" +echo "Cassandra driver built successfully!" +echo "Libraries:" +ls -lh "$LIBS_DIR"/libcassandra*.a "$LIBS_DIR"/libuv*.a 2>/dev/null +echo "" +echo "Headers:" +ls -lh "$HEADERS_DIR"/cassandra.h 2>/dev/null diff --git a/scripts/build-release.sh b/scripts/build-release.sh index 070feeb12..6c8268377 100755 --- a/scripts/build-release.sh +++ b/scripts/build-release.sh @@ -180,6 +180,7 @@ prepare_hiredis() { echo "✅ hiredis libraries ready for $target_arch" } + # Bundle non-system dynamic libraries into the app bundle # so the app runs without Homebrew on end-user machines. bundle_dylibs() { From dc2a7b8bbbdf68e24d8c1c29d65fe8da2d4c4c00 Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Sat, 14 Mar 2026 09:07:34 +0700 Subject: [PATCH 02/13] fix: address PR review feedback for Cassandra plugin --- .github/workflows/build-plugin.yml | 3 +- .../CassandraPlugin.swift | 22 ++++--- docs/databases/cassandra.mdx | 65 +++++++++---------- docs/databases/connection-urls.mdx | 2 +- docs/vi/databases/cassandra.mdx | 8 +-- docs/vi/databases/connection-urls.mdx | 2 +- docs/vi/databases/overview.mdx | 4 +- scripts/build-cassandra.sh | 6 ++ 8 files changed, 59 insertions(+), 53 deletions(-) diff --git a/.github/workflows/build-plugin.yml b/.github/workflows/build-plugin.yml index ff5485f7f..81008d007 100644 --- a/.github/workflows/build-plugin.yml +++ b/.github/workflows/build-plugin.yml @@ -98,8 +98,7 @@ jobs: # Build Cassandra dependencies if needed if [ "$PLUGIN_NAME" = "cassandra" ]; then - ./scripts/build-cassandra.sh arm64 - ./scripts/build-cassandra.sh x86_64 + ./scripts/build-cassandra.sh both fi # Build both architectures diff --git a/Plugins/CassandraDriverPlugin/CassandraPlugin.swift b/Plugins/CassandraDriverPlugin/CassandraPlugin.swift index 3fb9083ed..16cb1c44f 100644 --- a/Plugins/CassandraDriverPlugin/CassandraPlugin.swift +++ b/Plugins/CassandraDriverPlugin/CassandraPlugin.swift @@ -52,7 +52,7 @@ private actor CassandraConnectionActor { username: String?, password: String?, keyspace: String?, - sslEnabled: Bool, + sslMode: String, sslCaCertPath: String? ) throws { cluster = cass_cluster_new() @@ -68,16 +68,19 @@ private actor CassandraConnectionActor { } // SSL/TLS - if sslEnabled { + if sslMode != "Disabled" { let ssl = cass_ssl_new() - cass_ssl_set_verify_flags(ssl, Int32(CASS_SSL_VERIFY_PEER_CERT.rawValue)) - if let caCertPath = sslCaCertPath, !caCertPath.isEmpty, - let certData = FileManager.default.contents(atPath: caCertPath), - let certString = String(data: certData, encoding: .utf8) { - cass_ssl_add_trusted_cert(ssl, certString) + if sslMode == "Verify CA" || sslMode == "Verify Identity" { + cass_ssl_set_verify_flags(ssl, Int32(CASS_SSL_VERIFY_PEER_CERT.rawValue)) + + if let caCertPath = sslCaCertPath, !caCertPath.isEmpty, + let certData = FileManager.default.contents(atPath: caCertPath), + let certString = String(data: certData, encoding: .utf8) { + cass_ssl_add_trusted_cert(ssl, certString) + } } else { - // No verification if no CA cert provided + // "Preferred" / "Required" — encrypt but skip cert verification cass_ssl_set_verify_flags(ssl, Int32(CASS_SSL_VERIFY_NONE.rawValue)) } @@ -617,7 +620,6 @@ final class CassandraPluginDriver: PluginDatabaseDriver, @unchecked Sendable { func connect() async throws { let sslMode = config.additionalFields["sslMode"] ?? "Disabled" - let sslEnabled = sslMode != "Disabled" let sslCaCertPath = config.additionalFields["sslCaCertPath"] let keyspace = config.database.isEmpty ? nil : config.database @@ -628,7 +630,7 @@ final class CassandraPluginDriver: PluginDatabaseDriver, @unchecked Sendable { username: config.username.isEmpty ? nil : config.username, password: config.password.isEmpty ? nil : config.password, keyspace: keyspace, - sslEnabled: sslEnabled, + sslMode: sslMode, sslCaCertPath: sslCaCertPath ) diff --git a/docs/databases/cassandra.mdx b/docs/databases/cassandra.mdx index 41dd9d149..e73759f74 100644 --- a/docs/databases/cassandra.mdx +++ b/docs/databases/cassandra.mdx @@ -7,7 +7,7 @@ description: Connect to Cassandra and ScyllaDB clusters, browse keyspaces, and r TablePro supports Apache Cassandra 3.11+ and ScyllaDB 4.0+ via the CQL native protocol. Browse keyspaces, inspect table structures, view materialized views, and run CQL queries from the editor. -## Quick Setup +## Quick setup @@ -24,9 +24,9 @@ TablePro supports Apache Cassandra 3.11+ and ScyllaDB 4.0+ via the CQL native pr -## Connection Settings +## Connection settings -### Required Fields +### Required fields | Field | Description | Default | |-------|-------------|---------| @@ -34,7 +34,7 @@ TablePro supports Apache Cassandra 3.11+ and ScyllaDB 4.0+ via the CQL native pr | **Host** | Contact point hostname or IP | `localhost` | | **Port** | CQL native transport port | `9042` | -### Optional Fields +### Optional fields | Field | Description | |-------|-------------| @@ -46,17 +46,17 @@ TablePro supports Apache Cassandra 3.11+ and ScyllaDB 4.0+ via the CQL native pr Local Cassandra installations typically have authentication disabled. Leave username and password empty for local development. -## Connection URL Format +## Connection URL format Import connections using a Cassandra or ScyllaDB URL. See [Connection URL Reference](/databases/connection-urls#cassandra--scylladb) for the full URL format. -## Example Configurations +## Example configurations -### Local Development Server +### Local development server -``` +```text Name: Local Cassandra Host: localhost Port: 9042 @@ -65,9 +65,9 @@ Password: (empty) Keyspace: my_keyspace ``` -### Docker Cassandra Container +### Docker Cassandra container -``` +```text Name: Docker Cassandra Host: localhost Port: 9042 (or your mapped port) @@ -78,7 +78,7 @@ Keyspace: (empty) ### DataStax Astra DB (Cloud) -``` +```text Name: Astra DB Host: -.apps.astra.datastax.com Port: 29042 @@ -91,9 +91,9 @@ Keyspace: my_keyspace Astra DB requires a Secure Connect Bundle for TLS. Download the bundle from the Astra dashboard and configure it in the SSL/TLS section. -### Remote Server +### Remote server -``` +```text Name: Production Cassandra Host: cassandra.example.com Port: 9042 @@ -106,7 +106,7 @@ Keyspace: production For production Cassandra clusters, consider using [SSH tunneling](/databases/ssh-tunneling) for secure connections. -## SSL/TLS Connections +## SSL/TLS connections Configure SSL in the **SSL/TLS** section of the connection form. @@ -122,13 +122,13 @@ For **Verify CA** mode, provide the path to your CA certificate file. You can al If you'd rather skip SSL certificate setup, [SSH tunneling](/databases/ssh-tunneling) encrypts all traffic through an SSH tunnel instead. -## SSH Tunnel Support +## SSH tunnel support Connect to Cassandra through an SSH tunnel for secure access to remote clusters. See [SSH Tunneling](/databases/ssh-tunneling) for setup instructions. ## Features -### Keyspace Browsing +### Keyspace browsing After connecting, the sidebar lists all keyspaces. Expand a keyspace to see its tables, materialized views, user-defined types (UDTs), and secondary indexes. @@ -136,7 +136,7 @@ After connecting, the sidebar lists all keyspaces. Expand a keyspace to see its 2. Expand a keyspace to see its objects 3. Click a table to view its data -### Table Structure +### Table structure View the full schema for any table: @@ -146,11 +146,11 @@ View the full schema for any table: - **Secondary indexes**: index name, target column, index class - **Table options**: compaction strategy, compression, TTL defaults, gc_grace_seconds -### Materialized Views +### Materialized views Browse materialized views alongside tables in the sidebar. View their definition, base table, and column mappings. -### Data Grid +### Data grid Browse table data with pagination. Cell values display with CQL type-aware formatting: @@ -161,7 +161,7 @@ Browse table data with pagination. Cell values display with CQL type-aware forma - **map/set/list/tuple** display as formatted collections - **blob** values display as hex -### CQL Editor +### CQL editor Execute CQL statements directly in the editor tab: @@ -197,19 +197,18 @@ CREATE INDEX ON users (email); DESCRIBE TABLE users; ``` -## CQL-Specific Notes +## CQL-specific notes Cassandra Query Language (CQL) looks like SQL but has important differences: ### No JOINs - CQL does not support JOIN operations. Design your data model around query patterns, denormalizing data across multiple tables as needed. -### No Subqueries +### No subqueries CQL does not support subqueries. Break complex queries into multiple sequential statements. -### Partition Key Restrictions +### Partition key restrictions Every SELECT query must include the full partition key in the WHERE clause, unless you use `ALLOW FILTERING` (which scans the entire cluster and should be avoided in production). @@ -225,7 +224,7 @@ SELECT * FROM orders WHERE total > 100 ALLOW FILTERING; The `ALLOW FILTERING` clause forces a full cluster scan. It works for development and small datasets but causes timeouts and performance issues on production clusters. TablePro shows a warning when a query includes `ALLOW FILTERING`. -### Lightweight Transactions +### Lightweight transactions Cassandra supports conditional writes using `IF` clauses (lightweight transactions / compare-and-set): @@ -245,7 +244,7 @@ SELECT TTL(value), WRITETIME(value) FROM cache WHERE key = 'k1'; ## Troubleshooting -### Connection Refused +### Connection refused **Symptoms**: "Connection refused" or timeout @@ -271,7 +270,7 @@ SELECT TTL(value), WRITETIME(value) FROM cache WHERE key = 'k1'; - Check `rpc_address` and `listen_address` in `cassandra.yaml` - For remote connections, set `rpc_address` to `0.0.0.0` -### Authentication Failed +### Authentication failed **Symptoms**: "Provided username and/or password are incorrect" @@ -285,7 +284,7 @@ SELECT TTL(value), WRITETIME(value) FROM cache WHERE key = 'k1'; ``` 3. Default superuser is `cassandra` / `cassandra` (change this in production) -### Connection Timeout +### Connection timeout **Symptoms**: Connection hangs or times out @@ -296,7 +295,7 @@ SELECT TTL(value), WRITETIME(value) FROM cache WHERE key = 'k1'; 3. For cloud-hosted Cassandra, ensure your IP is in the allowed list 4. Increase the connection timeout in the Advanced tab -### Read Timeout +### Read timeout **Symptoms**: "Read timed out" on queries @@ -307,7 +306,7 @@ SELECT TTL(value), WRITETIME(value) FROM cache WHERE key = 'k1'; 3. Check cluster health with `nodetool status` 4. Reduce the result set with `LIMIT` -## Known Limitations +## Known limitations - **Multi-datacenter**: connecting to a specific datacenter is not yet configurable. TablePro connects to whichever node the contact point resolves to. - **User-Defined Functions (UDFs)**: UDFs and UDAs are not displayed in the sidebar but can be used in CQL queries. @@ -315,9 +314,9 @@ SELECT TTL(value), WRITETIME(value) FROM cache WHERE key = 'k1'; - **Counter tables**: counter columns are read-only in the data grid. Use the CQL editor for counter updates. - **Large partitions**: partitions with millions of rows are paginated automatically to prevent memory issues. -## Performance Tips +## Performance tips -### Query Performance +### Query performance For Cassandra clusters with large datasets: @@ -339,7 +338,7 @@ Check cluster health and performance: SELECT * FROM system.size_estimates WHERE keyspace_name = 'my_keyspace'; ``` -## Next Steps +## Next steps diff --git a/docs/databases/connection-urls.mdx b/docs/databases/connection-urls.mdx index 716ac7a37..7d1f72539 100644 --- a/docs/databases/connection-urls.mdx +++ b/docs/databases/connection-urls.mdx @@ -170,7 +170,7 @@ rediss://:password@host:6380 # TLS, default index 0 The path component sets the default keyspace. Both `cassandra://` and `scylladb://` schemes use the same format. -``` +```text cassandra://user:pass@host:9042/my_keyspace scylladb://user:pass@host:9042/my_keyspace cassandra://host:9042 # no auth, no default keyspace diff --git a/docs/vi/databases/cassandra.mdx b/docs/vi/databases/cassandra.mdx index 738e6a46f..08da1a53b 100644 --- a/docs/vi/databases/cassandra.mdx +++ b/docs/vi/databases/cassandra.mdx @@ -56,7 +56,7 @@ Xem [Tham chiếu URL kết nối](/vi/databases/connection-urls#cassandra--scyl ### Server Dev Local -``` +```text Name: Local Cassandra Host: localhost Port: 9042 @@ -67,7 +67,7 @@ Keyspace: my_keyspace ### Docker Cassandra Container -``` +```text Name: Docker Cassandra Host: localhost Port: 9042 (hoặc cổng mapped) @@ -78,7 +78,7 @@ Keyspace: (để trống) ### DataStax Astra DB (Cloud) -``` +```text Name: Astra DB Host: -.apps.astra.datastax.com Port: 29042 @@ -93,7 +93,7 @@ Astra DB yêu cầu Secure Connect Bundle cho TLS. Tải bundle từ Astra dashb ### Server Từ xa -``` +```text Name: Production Cassandra Host: cassandra.example.com Port: 9042 diff --git a/docs/vi/databases/connection-urls.mdx b/docs/vi/databases/connection-urls.mdx index ee0653a8f..09a8b26be 100644 --- a/docs/vi/databases/connection-urls.mdx +++ b/docs/vi/databases/connection-urls.mdx @@ -170,7 +170,7 @@ rediss://:password@host:6380 # TLS, index mặc định 0 Phần path đặt keyspace mặc định. Cả hai scheme `cassandra://` và `scylladb://` dùng cùng format. -``` +```text cassandra://user:pass@host:9042/my_keyspace scylladb://user:pass@host:9042/my_keyspace cassandra://host:9042 # không auth, không keyspace mặc định diff --git a/docs/vi/databases/overview.mdx b/docs/vi/databases/overview.mdx index 98f00542d..66416c180 100644 --- a/docs/vi/databases/overview.mdx +++ b/docs/vi/databases/overview.mdx @@ -108,7 +108,7 @@ open "mysql://root:secret@localhost:3306/myapp" open "redis://:password@localhost:6379" ``` -TablePro đăng ký `postgresql`, `postgres`, `mysql`, `mariadb`, `sqlite`, `mongodb`, `mongodb+srv`, `redis`, `rediss`, `redshift`, `mssql`, `sqlserver`, `oracle`, `clickhouse`, `cassandra` và `scylladb` là các URL scheme trên macOS, nên hệ điều hành sẽ chuyển hướng các URL này trực tiếp đến ứng dụng. +TablePro đăng ký `postgresql`, `postgres`, `mysql`, `mariadb`, `sqlite`, `mongodb`, `mongodb+srv`, `redis`, `rediss`, `redshift`, `mssql`, `sqlserver`, `oracle`, `clickhouse`, `duckdb`, `cassandra` và `scylladb` là các URL scheme trên macOS, nên hệ điều hành sẽ chuyển hướng các URL này trực tiếp đến ứng dụng. **Khi mở URL:** @@ -131,7 +131,7 @@ Khác với **Import from URL** (điền form để bạn xem xét và lưu), m | Trường | Mô tả | |-------|-------------| | **Name** | Tên thân thiện để xác định kết nối này | -| **Type** | Loại cơ sở dữ liệu: MySQL, MariaDB, PostgreSQL, SQLite, MongoDB, Redis, Redshift, SQL Server, Oracle, ClickHouse, Cassandra hoặc ScyllaDB | +| **Type** | Loại cơ sở dữ liệu: MySQL, MariaDB, PostgreSQL, SQLite, MongoDB, Redis, Redshift, SQL Server, Oracle, ClickHouse, DuckDB, Cassandra hoặc ScyllaDB | #### Phần Appearance diff --git a/scripts/build-cassandra.sh b/scripts/build-cassandra.sh index 18aad4073..f3427df46 100755 --- a/scripts/build-cassandra.sh +++ b/scripts/build-cassandra.sh @@ -108,6 +108,12 @@ build_cassandra() { # --- Copy headers --- copy_headers() { echo "📋 Copying cassandra.h header..." + + if [ -f "$HEADERS_DIR/cassandra.h" ]; then + echo "✅ cassandra.h already exists, skipping" + return 0 + fi + cd "$BUILD_DIR" if [ -f "cassandra-cpp-driver-${CASSANDRA_VERSION}/include/cassandra.h" ]; then From 9222702aeda38be68c1a0484bb9bcf7081b81b86 Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Sat, 14 Mar 2026 09:09:12 +0700 Subject: [PATCH 03/13] fix: remove orphaned case statement and add default branch for open DatabaseType --- TablePro/Core/Database/DatabaseDriver.swift | 2 ++ .../Main/Extensions/MainContentCoordinator+Navigation.swift | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/TablePro/Core/Database/DatabaseDriver.swift b/TablePro/Core/Database/DatabaseDriver.swift index fc511c942..110b2493b 100644 --- a/TablePro/Core/Database/DatabaseDriver.swift +++ b/TablePro/Core/Database/DatabaseDriver.swift @@ -391,6 +391,8 @@ enum DatabaseDriverFactory { fields["oracleServiceName"] = connection.oracleServiceName ?? "" case .mysql, .mariadb, .sqlite, .clickhouse, .postgresql, .redshift, .cassandra, .scylladb, .duckdb: break + default: + break } return fields diff --git a/TablePro/Views/Main/Extensions/MainContentCoordinator+Navigation.swift b/TablePro/Views/Main/Extensions/MainContentCoordinator+Navigation.swift index 031b141e6..35594420e 100644 --- a/TablePro/Views/Main/Extensions/MainContentCoordinator+Navigation.swift +++ b/TablePro/Views/Main/Extensions/MainContentCoordinator+Navigation.swift @@ -268,8 +268,6 @@ extension MainContentCoordinator { ) runQuery() return nil - case .cassandra, .scylladb: - return nil } // SQL databases: delegate to plugin driver From a339dda690585eef354d79f2c907fcb578e440a6 Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Sat, 14 Mar 2026 09:18:54 +0700 Subject: [PATCH 04/13] fix: address code review issues in Cassandra plugin driver --- .../CassandraPlugin.swift | 43 +++++++++++++------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/Plugins/CassandraDriverPlugin/CassandraPlugin.swift b/Plugins/CassandraDriverPlugin/CassandraPlugin.swift index 16cb1c44f..5243c534e 100644 --- a/Plugins/CassandraDriverPlugin/CassandraPlugin.swift +++ b/Plugins/CassandraDriverPlugin/CassandraPlugin.swift @@ -38,6 +38,12 @@ final class CassandraPlugin: NSObject, TableProPlugin, DriverPlugin { private actor CassandraConnectionActor { private static let logger = Logger(subsystem: "com.TablePro.CassandraDriver", category: "Connection") + nonisolated(unsafe) private static let isoFormatter: ISO8601DateFormatter = { + let f = ISO8601DateFormatter() + f.formatOptions = [.withInternetDateTime, .withFractionalSeconds] + return f + }() + private var cluster: OpaquePointer? // CassCluster* private var session: OpaquePointer? // CassSession* private var currentKeyspace: String? @@ -69,7 +75,11 @@ private actor CassandraConnectionActor { // SSL/TLS if sslMode != "Disabled" { - let ssl = cass_ssl_new() + guard let ssl = cass_ssl_new() else { + cass_cluster_free(cluster) + self.cluster = nil + throw CassandraPluginError.connectionFailed("Failed to create SSL context") + } if sslMode == "Verify CA" || sslMode == "Verify Identity" { cass_ssl_set_verify_flags(ssl, Int32(CASS_SSL_VERIFY_PEER_CERT.rawValue)) @@ -77,7 +87,11 @@ private actor CassandraConnectionActor { if let caCertPath = sslCaCertPath, !caCertPath.isEmpty, let certData = FileManager.default.contents(atPath: caCertPath), let certString = String(data: certData, encoding: .utf8) { - cass_ssl_add_trusted_cert(ssl, certString) + let rc = cass_ssl_add_trusted_cert(ssl, certString) + if rc != CASS_OK { + Self.logger.warning("Failed to add CA certificate, proceeding without verification") + cass_ssl_set_verify_flags(ssl, Int32(CASS_SSL_VERIFY_NONE.rawValue)) + } } } else { // "Preferred" / "Required" — encrypt but skip cert verification @@ -437,9 +451,7 @@ private actor CassandraConnectionActor { var timestamp: Int64 = 0 if cass_value_get_int64(value, ×tamp) == CASS_OK { let date = Date(timeIntervalSince1970: Double(timestamp) / 1000.0) - let formatter = ISO8601DateFormatter() - formatter.formatOptions = [.withInternetDateTime, .withFractionalSeconds] - return formatter.string(from: date) + return isoFormatter.string(from: date) } return nil @@ -650,7 +662,12 @@ final class CassandraPluginDriver: PluginDatabaseDriver, @unchecked Sendable { func disconnect() { let actor = connectionActor - Task { await actor.close() } + let semaphore = DispatchSemaphore(value: 0) + Task { + await actor.close() + semaphore.signal() + } + semaphore.wait() stateLock.lock() _currentKeyspace = nil _cachedVersion = nil @@ -696,15 +713,17 @@ final class CassandraPluginDriver: PluginDatabaseDriver, @unchecked Sendable { // MARK: - Pagination func fetchRowCount(query: String) async throws -> Int { - let countQuery = "SELECT COUNT(*) FROM (\(stripTrailingSemicolon(query)))" - let result = try await execute(query: countQuery) - guard let firstRow = result.rows.first, let countStr = firstRow.first else { return 0 } - return Int(countStr ?? "0") ?? 0 + // CQL does not support subqueries, so we can't wrap an arbitrary query in SELECT COUNT(*) FROM (...). + // Return -1 to signal unknown count; the UI will hide the total page count. + -1 } func fetchRows(query: String, offset: Int, limit: Int) async throws -> PluginQueryResult { - // Cassandra doesn't support OFFSET natively. - // For paginated browsing, we use LIMIT and let the default protocol handle paging. + // CQL does not support OFFSET. Only the first page (offset=0) can be fetched via simple LIMIT. + // For offset>0, throw so the caller knows pagination is unsupported for arbitrary queries. + if offset > 0 { + throw CassandraPluginError.unsupportedOperation + } let baseQuery = stripTrailingSemicolon(query) let paginatedQuery = "\(baseQuery) LIMIT \(limit)" return try await execute(query: paginatedQuery) From 2e0d764162d94b1743b2b08303203b1a178bab28 Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Sat, 14 Mar 2026 09:24:16 +0700 Subject: [PATCH 05/13] fix: improve Cassandra plugin SSL, type extraction, column ordering, and UX --- .../CassandraPlugin.swift | 107 ++++++++++++++---- .../Views/Main/MainContentCoordinator.swift | 3 + 2 files changed, 91 insertions(+), 19 deletions(-) diff --git a/Plugins/CassandraDriverPlugin/CassandraPlugin.swift b/Plugins/CassandraDriverPlugin/CassandraPlugin.swift index 5243c534e..31422bf19 100644 --- a/Plugins/CassandraDriverPlugin/CassandraPlugin.swift +++ b/Plugins/CassandraDriverPlugin/CassandraPlugin.swift @@ -15,7 +15,7 @@ import TableProPluginKit // MARK: - Plugin Entry Point -final class CassandraPlugin: NSObject, TableProPlugin, DriverPlugin { +internal final class CassandraPlugin: NSObject, TableProPlugin, DriverPlugin { static let pluginName = "Cassandra Driver" static let pluginVersion = "1.0.0" static let pluginDescription = "Apache Cassandra and ScyllaDB support via DataStax C driver" @@ -25,7 +25,14 @@ final class CassandraPlugin: NSObject, TableProPlugin, DriverPlugin { static let databaseDisplayName = "Cassandra / ScyllaDB" static let iconName = "cassandra-icon" static let defaultPort = 9042 - static let additionalConnectionFields: [ConnectionField] = [] + static let additionalConnectionFields: [ConnectionField] = [ + ConnectionField( + id: "sslCaCertPath", + label: "CA Certificate", + placeholder: "/path/to/ca-cert.pem", + section: .advanced + ), + ] static let additionalDatabaseTypeIds: [String] = [] func createDriver(config: DriverConnectionConfig) -> any PluginDatabaseDriver { @@ -44,6 +51,13 @@ private actor CassandraConnectionActor { return f }() + nonisolated(unsafe) private static let dateFormatter: DateFormatter = { + let f = DateFormatter() + f.dateFormat = "yyyy-MM-dd" + f.timeZone = TimeZone(identifier: "UTC") + return f + }() + private var cluster: OpaquePointer? // CassCluster* private var session: OpaquePointer? // CassSession* private var currentKeyspace: String? @@ -82,7 +96,12 @@ private actor CassandraConnectionActor { } if sslMode == "Verify CA" || sslMode == "Verify Identity" { - cass_ssl_set_verify_flags(ssl, Int32(CASS_SSL_VERIFY_PEER_CERT.rawValue)) + if sslMode == "Verify Identity" { + let flags = Int32(CASS_SSL_VERIFY_PEER_CERT.rawValue | CASS_SSL_VERIFY_PEER_IDENTITY.rawValue) + cass_ssl_set_verify_flags(ssl, flags) + } else { + cass_ssl_set_verify_flags(ssl, Int32(CASS_SSL_VERIFY_PEER_CERT.rawValue)) + } if let caCertPath = sslCaCertPath, !caCertPath.isEmpty, let certData = FileManager.default.contents(atPath: caCertPath), @@ -482,6 +501,44 @@ private actor CassandraConnectionActor { case CASS_VALUE_TYPE_TUPLE: return extractCollectionString(value, open: "(", close: ")") + case CASS_VALUE_TYPE_DATE: + var dateVal: UInt32 = 0 + if cass_value_get_uint32(value, &dateVal) == CASS_OK { + let daysSinceEpoch = Int64(dateVal) - Int64(1 << 31) + let epochSeconds = daysSinceEpoch * 86400 + let date = Date(timeIntervalSince1970: Double(epochSeconds)) + return dateFormatter.string(from: date) + } + return nil + + case CASS_VALUE_TYPE_TIME: + var timeVal: Int64 = 0 + if cass_value_get_int64(value, &timeVal) == CASS_OK { + // Cassandra time is nanoseconds since midnight + let totalSeconds = timeVal / 1_000_000_000 + let hours = totalSeconds / 3600 + let minutes = (totalSeconds % 3600) / 60 + let seconds = totalSeconds % 60 + let nanos = timeVal % 1_000_000_000 + if nanos > 0 { + let millis = nanos / 1_000_000 + return String(format: "%02lld:%02lld:%02lld.%03lld", hours, minutes, seconds, millis) + } + return String(format: "%02lld:%02lld:%02lld", hours, minutes, seconds) + } + return nil + + case CASS_VALUE_TYPE_DECIMAL, CASS_VALUE_TYPE_VARINT: + // Read as bytes and display as hex since proper numeric decoding + // requires BigInteger support not available in the C driver API + var bytes: UnsafePointer? + var length: Int = 0 + if cass_value_get_bytes(value, &bytes, &length) == CASS_OK, let bytes { + let data = Data(bytes: bytes, count: length) + return "0x" + data.map { String(format: "%02x", $0) }.joined() + } + return nil + default: // Fallback: try reading as string var output: UnsafePointer? @@ -597,7 +654,7 @@ private struct CassandraRawResult: Sendable { // MARK: - Plugin Driver -final class CassandraPluginDriver: PluginDatabaseDriver, @unchecked Sendable { +internal final class CassandraPluginDriver: PluginDatabaseDriver, @unchecked Sendable { private let config: DriverConnectionConfig private let connectionActor = CassandraConnectionActor() private let stateLock = NSLock() @@ -770,27 +827,39 @@ final class CassandraPluginDriver: PluginDatabaseDriver, @unchecked Sendable { """ let result = try await execute(query: query) - return result.rows.compactMap { row in + // Parse and sort by kind order then position before mapping to PluginColumnInfo + struct RawColumn { + let name: String + let dataType: String + let kind: String + let position: Int + let isPrimaryKey: Bool + } + + let rawColumns = result.rows.compactMap { row -> RawColumn? in guard let name = row[safe: 0] ?? nil, let dataType = row[safe: 1] ?? nil else { return nil } - let kind = row[safe: 2] ?? nil // partition_key, clustering, regular, static + let kind = (row[safe: 2] ?? nil) ?? "regular" + let position = Int((row[safe: 4] ?? nil) ?? "0") ?? 0 let isPrimaryKey = kind == "partition_key" || kind == "clustering" + return RawColumn(name: name, dataType: dataType, kind: kind, position: position, isPrimaryKey: isPrimaryKey) + }.sorted { lhs, rhs in + let lhsOrder = columnKindOrder(lhs.kind) + let rhsOrder = columnKindOrder(rhs.kind) + if lhsOrder != rhsOrder { return lhsOrder < rhsOrder } + return lhs.position < rhs.position + } - return PluginColumnInfo( - name: name, - dataType: dataType, - isNullable: !isPrimaryKey, - isPrimaryKey: isPrimaryKey, + return rawColumns.map { col in + PluginColumnInfo( + name: col.name, + dataType: col.dataType, + isNullable: !col.isPrimaryKey, + isPrimaryKey: col.isPrimaryKey, defaultValue: nil ) - }.sorted { lhs, rhs in - // Sort: partition keys first, then clustering, then regular - let lhsOrder = columnKindOrder(lhs.isPrimaryKey ? "key" : "regular") - let rhsOrder = columnKindOrder(rhs.isPrimaryKey ? "key" : "regular") - if lhsOrder != rhsOrder { return lhsOrder < rhsOrder } - return lhs.name < rhs.name } } @@ -976,7 +1045,7 @@ final class CassandraPluginDriver: PluginDatabaseDriver, @unchecked Sendable { let safeKs = escapeIdentifier(name) let query = """ CREATE KEYSPACE "\(safeKs)" - WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1} + WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 3} """ _ = try await execute(query: query) } @@ -1036,7 +1105,7 @@ final class CassandraPluginDriver: PluginDatabaseDriver, @unchecked Sendable { // MARK: - Errors -enum CassandraPluginError: Error { +internal enum CassandraPluginError: Error { case connectionFailed(String) case notConnected case queryFailed(String) diff --git a/TablePro/Views/Main/MainContentCoordinator.swift b/TablePro/Views/Main/MainContentCoordinator.swift index 63a943591..65bf886a1 100644 --- a/TablePro/Views/Main/MainContentCoordinator.swift +++ b/TablePro/Views/Main/MainContentCoordinator.swift @@ -710,6 +710,9 @@ final class MainContentCoordinator { // Cassandra/ScyllaDB don't support EXPLAIN if connection.type == .cassandra || connection.type == .scylladb { + if let index = tabManager.selectedTabIndex { + tabManager.tabs[index].errorMessage = String(localized: "EXPLAIN is not supported for this database type.") + } return } From e5e433f792a7f0633bd5797f93ca10537d32ded2 Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Sat, 14 Mar 2026 09:27:52 +0700 Subject: [PATCH 06/13] fix: register ScyllaDB as additional database type ID in Cassandra plugin --- .github/workflows/build-plugin.yml | 12 ++++++------ Plugins/CassandraDriverPlugin/CassandraPlugin.swift | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-plugin.yml b/.github/workflows/build-plugin.yml index 81008d007..04f789bee 100644 --- a/.github/workflows/build-plugin.yml +++ b/.github/workflows/build-plugin.yml @@ -57,27 +57,27 @@ jobs: TARGET="OracleDriver"; BUNDLE_ID="com.TablePro.OracleDriver" DISPLAY_NAME="Oracle Driver"; SUMMARY="Oracle Database 12c+ driver via OracleNIO" DB_TYPE_IDS='["Oracle"]'; ICON="server.rack"; BUNDLE_NAME="OracleDriver" - HOMEPAGE="https://tablepro.app/databases/oracle" ;; + HOMEPAGE="https://docs.tablepro.app/databases/oracle" ;; clickhouse) TARGET="ClickHouseDriver"; BUNDLE_ID="com.TablePro.ClickHouseDriver" DISPLAY_NAME="ClickHouse Driver"; SUMMARY="ClickHouse OLAP database driver via HTTP interface" DB_TYPE_IDS='["ClickHouse"]'; ICON="chart.bar.xaxis"; BUNDLE_NAME="ClickHouseDriver" - HOMEPAGE="https://tablepro.app/databases/clickhouse" ;; + HOMEPAGE="https://docs.tablepro.app/databases/clickhouse" ;; sqlite) TARGET="SQLiteDriver"; BUNDLE_ID="com.TablePro.SQLiteDriver" DISPLAY_NAME="SQLite Driver"; SUMMARY="SQLite embedded database driver" DB_TYPE_IDS='["SQLite"]'; ICON="internaldrive"; BUNDLE_NAME="SQLiteDriver" - HOMEPAGE="https://tablepro.app" ;; + HOMEPAGE="https://docs.tablepro.app/databases/sqlite" ;; duckdb) TARGET="DuckDBDriver"; BUNDLE_ID="com.TablePro.DuckDBDriver" DISPLAY_NAME="DuckDB Driver"; SUMMARY="DuckDB analytical database driver" DB_TYPE_IDS='["DuckDB"]'; ICON="bird"; BUNDLE_NAME="DuckDBDriver" - HOMEPAGE="https://tablepro.app" ;; + HOMEPAGE="https://docs.tablepro.app/databases/duckdb" ;; cassandra) TARGET="CassandraDriver"; BUNDLE_ID="com.TablePro.CassandraDriver" DISPLAY_NAME="Cassandra Driver"; SUMMARY="Apache Cassandra and ScyllaDB driver via DataStax C driver" - DB_TYPE_IDS='["Cassandra"]'; ICON="cassandra-icon"; BUNDLE_NAME="CassandraDriver" - HOMEPAGE="https://tablepro.app/databases/cassandra" ;; + DB_TYPE_IDS='["Cassandra", "ScyllaDB"]'; ICON="cassandra-icon"; BUNDLE_NAME="CassandraDriver" + HOMEPAGE="https://docs.tablepro.app/databases/cassandra" ;; *) echo "Unknown plugin: $plugin_name"; return 1 ;; esac } diff --git a/Plugins/CassandraDriverPlugin/CassandraPlugin.swift b/Plugins/CassandraDriverPlugin/CassandraPlugin.swift index 31422bf19..9ed769120 100644 --- a/Plugins/CassandraDriverPlugin/CassandraPlugin.swift +++ b/Plugins/CassandraDriverPlugin/CassandraPlugin.swift @@ -33,7 +33,7 @@ internal final class CassandraPlugin: NSObject, TableProPlugin, DriverPlugin { section: .advanced ), ] - static let additionalDatabaseTypeIds: [String] = [] + static let additionalDatabaseTypeIds: [String] = ["ScyllaDB"] func createDriver(config: DriverConnectionConfig) -> any PluginDatabaseDriver { CassandraPluginDriver(config: config) From 07e7df4574c05f41bee1b5fcb871020863317f5e Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Sat, 14 Mar 2026 09:34:10 +0700 Subject: [PATCH 07/13] fix: resolve deadlock, dead code, system keyspace filter, and EXPLAIN handling --- .../CassandraDriverPlugin/CassandraPlugin.swift | 17 +++++++---------- .../Views/Main/MainContentCoordinator.swift | 9 ++------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/Plugins/CassandraDriverPlugin/CassandraPlugin.swift b/Plugins/CassandraDriverPlugin/CassandraPlugin.swift index 9ed769120..61efd2d18 100644 --- a/Plugins/CassandraDriverPlugin/CassandraPlugin.swift +++ b/Plugins/CassandraDriverPlugin/CassandraPlugin.swift @@ -718,13 +718,9 @@ internal final class CassandraPluginDriver: PluginDatabaseDriver, @unchecked Sen } func disconnect() { - let actor = connectionActor - let semaphore = DispatchSemaphore(value: 0) - Task { - await actor.close() - semaphore.signal() + Task.detached(priority: .utility) { [connectionActor] in + await connectionActor.close() } - semaphore.wait() stateLock.lock() _currentKeyspace = nil _cachedVersion = nil @@ -1004,9 +1000,6 @@ internal final class CassandraPluginDriver: PluginDatabaseDriver, @unchecked Sen func fetchTableMetadata(table: String, schema: String?) async throws -> PluginTableMetadata { let ks = resolveKeyspace(schema) - let safeTable = escapeSingleQuote(table) - let safeKs = escapeSingleQuote(ks) - // Cassandra doesn't have a cheap row count — use a bounded count let countQuery = "SELECT COUNT(*) FROM \"\(escapeIdentifier(ks))\".\"\(escapeIdentifier(table))\" LIMIT 100001" let countResult = try? await execute(query: countQuery) @@ -1027,8 +1020,12 @@ internal final class CassandraPluginDriver: PluginDatabaseDriver, @unchecked Sen func fetchDatabases() async throws -> [String] { let query = "SELECT keyspace_name FROM system_schema.keyspaces" let result = try await execute(query: query) + let systemKeyspaces: Set = [ + "system", "system_schema", "system_auth", + "system_distributed", "system_traces", "system_virtual_schema", + ] return result.rows.compactMap { $0[safe: 0] ?? nil } - .filter { !$0.hasPrefix("system") } + .filter { !systemKeyspaces.contains($0) } .sorted() } diff --git a/TablePro/Views/Main/MainContentCoordinator.swift b/TablePro/Views/Main/MainContentCoordinator.swift index 65bf886a1..51ee465af 100644 --- a/TablePro/Views/Main/MainContentCoordinator.swift +++ b/TablePro/Views/Main/MainContentCoordinator.swift @@ -708,19 +708,14 @@ final class MainContentCoordinator { return } - // Cassandra/ScyllaDB don't support EXPLAIN - if connection.type == .cassandra || connection.type == .scylladb { + guard let adapter = DatabaseManager.shared.driver(for: connectionId) as? PluginDriverAdapter, + let explainSQL = adapter.buildExplainQuery(stmt) else { if let index = tabManager.selectedTabIndex { tabManager.tabs[index].errorMessage = String(localized: "EXPLAIN is not supported for this database type.") } return } - guard let adapter = DatabaseManager.shared.driver(for: connectionId) as? PluginDriverAdapter, - let explainSQL = adapter.buildExplainQuery(stmt) else { - return - } - if needsConfirmation { Task { @MainActor in let window = NSApp.keyWindow From 1fc1c0e29b061456655668fff96a9657cb4b8146 Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Sat, 14 Mar 2026 09:35:12 +0700 Subject: [PATCH 08/13] chore: remove pre-built Cassandra libs from PR --- Libs/libcassandra.a | 3 --- Libs/libcassandra_arm64.a | 3 --- Libs/libuv.a | 3 --- Libs/libuv_arm64.a | 3 --- 4 files changed, 12 deletions(-) delete mode 100644 Libs/libcassandra.a delete mode 100644 Libs/libcassandra_arm64.a delete mode 100644 Libs/libuv.a delete mode 100644 Libs/libuv_arm64.a diff --git a/Libs/libcassandra.a b/Libs/libcassandra.a deleted file mode 100644 index b71dea90b..000000000 --- a/Libs/libcassandra.a +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4ca80d0764d15c1f96dc9dac8919477c71fc437e5f452f5c25128faa03e6f32f -size 5525840 diff --git a/Libs/libcassandra_arm64.a b/Libs/libcassandra_arm64.a deleted file mode 100644 index b71dea90b..000000000 --- a/Libs/libcassandra_arm64.a +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4ca80d0764d15c1f96dc9dac8919477c71fc437e5f452f5c25128faa03e6f32f -size 5525840 diff --git a/Libs/libuv.a b/Libs/libuv.a deleted file mode 100644 index dd747cd33..000000000 --- a/Libs/libuv.a +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f68094acef3ad60d58a59dd3c0d77f49f149a2868da15b38f82fbdc1aff63299 -size 251656 diff --git a/Libs/libuv_arm64.a b/Libs/libuv_arm64.a deleted file mode 100644 index dd747cd33..000000000 --- a/Libs/libuv_arm64.a +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f68094acef3ad60d58a59dd3c0d77f49f149a2868da15b38f82fbdc1aff63299 -size 251656 From 3e53cb70b505482451b7ccf5ecb2a2bf00ea1722 Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Sat, 14 Mar 2026 09:35:41 +0700 Subject: [PATCH 09/13] chore: remove pre-built cassandra.h header from PR --- .../CCassandra/include/cassandra.h | 11534 ---------------- 1 file changed, 11534 deletions(-) delete mode 100644 Plugins/CassandraDriverPlugin/CCassandra/include/cassandra.h diff --git a/Plugins/CassandraDriverPlugin/CCassandra/include/cassandra.h b/Plugins/CassandraDriverPlugin/CCassandra/include/cassandra.h deleted file mode 100644 index 6faf3d268..000000000 --- a/Plugins/CassandraDriverPlugin/CCassandra/include/cassandra.h +++ /dev/null @@ -1,11534 +0,0 @@ -/* - Copyright (c) DataStax, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#ifndef __CASSANDRA_H_INCLUDED__ -#define __CASSANDRA_H_INCLUDED__ - -#include -#include - -#if !defined(CASS_STATIC) -# if (defined(WIN32) || defined(_WIN32)) -# if defined(CASS_BUILDING) -# define CASS_EXPORT __declspec(dllexport) -# else -# define CASS_EXPORT __declspec(dllimport) -# endif -# elif (defined(__SUNPRO_C) || defined(__SUNPRO_CC)) && !defined(CASS_STATIC) -# define CASS_EXPORT __global -# elif (defined(__GNUC__) && __GNUC__ >= 4) || defined(__INTEL_COMPILER) -# define CASS_EXPORT __attribute__ ((visibility("default"))) -# endif -#else -#define CASS_EXPORT -#endif - -#if defined(_MSC_VER) -# define CASS_DEPRECATED(func) __declspec(deprecated) func -#elif defined(__GNUC__) || defined(__INTEL_COMPILER) -# define CASS_DEPRECATED(func) func __attribute__((deprecated)) -#else -# define CASS_DEPRECATED(func) func -#endif - -/** - * @file include/cassandra.h - * - * C/C++ driver for Apache Cassandra. Uses the Cassandra Query Language versions 3 - * over the Cassandra Binary Protocol (versions 1, 2, or 3). - */ - -#define CASS_VERSION_MAJOR 2 -#define CASS_VERSION_MINOR 17 -#define CASS_VERSION_PATCH 1 -#define CASS_VERSION_SUFFIX "" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum { cass_false = 0, cass_true = 1 } cass_bool_t; - -typedef float cass_float_t; -typedef double cass_double_t; - -typedef int8_t cass_int8_t; -typedef uint8_t cass_uint8_t; - -typedef int16_t cass_int16_t; -typedef uint16_t cass_uint16_t; - -typedef int32_t cass_int32_t; -typedef uint32_t cass_uint32_t; - -typedef int64_t cass_int64_t; -typedef uint64_t cass_uint64_t; - -#define CASS_UINT64_MAX 18446744073709551615ULL - -typedef cass_uint8_t cass_byte_t; -typedef cass_uint64_t cass_duration_t; - -/** - * The size of an IPv4 address - */ -#define CASS_INET_V4_LENGTH 4 - -/** - * The size of an IPv6 address - */ -#define CASS_INET_V6_LENGTH 16 - -/** - * The size of an inet string including a null terminator. - */ -#define CASS_INET_STRING_LENGTH 46 - -/** - * IP address for either IPv4 or IPv6. - * - * @struct CassInet - */ -typedef struct CassInet_ { - /** - * Big-endian, binary representation of a IPv4 or IPv6 address - */ - cass_uint8_t address[CASS_INET_V6_LENGTH]; - /** - * Number of address bytes. 4 bytes for IPv4 and 16 bytes for IPv6. - */ - cass_uint8_t address_length; -} CassInet; - -/** - * The size of a hexadecimal UUID string including a null terminator. - */ -#define CASS_UUID_STRING_LENGTH 37 - -/** - * Version 1 (time-based) or version 4 (random) UUID. - * - * @struct CassUuid - */ -typedef struct CassUuid_ { - /** - * Represents the time and version part of a UUID. The most significant - * 4 bits represent the version and the bottom 60 bits representing the - * time part. For version 1 the time part represents the number of - * 100 nanosecond periods since 00:00:00 UTC, January 1, 1970 (the Epoch). - * For version 4 the time part is randomly generated. - */ - cass_uint64_t time_and_version; - /** - * Represents the clock sequence and the node part of a UUID. The most - * significant 16 bits represent the clock sequence (except for the most - * significant bit which is always set) and the bottom 48 bits represent - * the node part. For version 1 (time-based) the clock sequence part is randomly - * generated and the node part can be explicitly set, otherwise, it's generated - * from node unique information. For version 4 both the clock sequence and the node - * parts are randomly generated. - */ - cass_uint64_t clock_seq_and_node; -} CassUuid; - -/** - * A cluster object describes the configuration of the Cassandra cluster and is used - * to construct a session instance. Unlike other DataStax drivers the cluster object - * does not maintain the control connection. - * - * @struct CassCluster - */ -typedef struct CassCluster_ CassCluster; - -/** - * A session object is used to execute queries and maintains cluster state through - * the control connection. The control connection is used to auto-discover nodes and - * monitor cluster changes (topology and schema). Each session also maintains multiple - * pools of connections to cluster nodes which are used to query the cluster. - * - * Instances of the session object are thread-safe to execute queries. - * - * @struct CassSession - */ -typedef struct CassSession_ CassSession; - -/** - * A statement object is an executable query. It represents either a regular - * (adhoc) statement or a prepared statement. It maintains the queries' parameter - * values along with query options (consistency level, paging state, etc.) - * - * Note: Parameters for regular queries are not supported by the binary protocol - * version 1. - * - * @struct CassStatement - */ -typedef struct CassStatement_ CassStatement; - -/** - * A group of statements that are executed as a single batch. - * - * Note: Batches are not supported by the binary protocol version 1. - * - * @cassandra{2.0+} - * - * @struct CassBatch - */ -typedef struct CassBatch_ CassBatch; - -/** - * The future result of an operation. - * - * It can represent a result if the operation completed successfully or an - * error if the operation failed. It can be waited on, polled or a callback - * can be attached. - * - * @struct CassFuture - */ -typedef struct CassFuture_ CassFuture; - -/** - * A statement that has been prepared cluster-side (It has been pre-parsed - * and cached). - * - * A prepared statement is read-only and it is thread-safe to concurrently - * bind new statements. - * - * @struct CassPrepared - */ -typedef struct CassPrepared_ CassPrepared; - -/** - * The result of a query. - * - * A result object is read-only and is thread-safe to read or iterate over - * concurrently. - * - * @struct CassResult - */ -typedef struct CassResult_ CassResult; - -/** - * A error result of a request - * - * @struct CassErrorResult - */ -typedef struct CassErrorResult_ CassErrorResult; - - -/** - * An object that represents a cluster node. - * - * @struct CassNode - */ -typedef struct CassNode_ CassNode; - -/** - * An object used to iterate over a group of rows, columns or collection values. - * - * @struct CassIterator - */ -typedef struct CassIterator_ CassIterator; - -/** - * A collection of column values. - * - * @struct CassRow - */ -typedef struct CassRow_ CassRow; - -/** - * A single primitive value or a collection of values. - * - * @struct CassValue - */ -typedef struct CassValue_ CassValue; - -/** - * A data type used to describe a value, collection or - * user defined type. - * - * @struct CassDataType - */ -typedef struct CassDataType_ CassDataType; - -/** - * @struct CassFunctionMeta - * - * @cassandra{2.2+} - */ -typedef struct CassFunctionMeta_ CassFunctionMeta; - -/** - * @struct CassAggregateMeta - * - * @cassandra{2.2+} - */ -typedef struct CassAggregateMeta_ CassAggregateMeta; - -/** - * A collection of values. - * - * @struct CassCollection - */ -typedef struct CassCollection_ CassCollection; - -/** - * A tuple of values. - * - * @struct CassTuple - * - * @cassandra{2.1+} - */ -typedef struct CassTuple_ CassTuple; - -/** - * A user defined type. - * - * @struct CassUserType - * - * @cassandra{2.1+} - */ -typedef struct CassUserType_ CassUserType; - -/** - * Describes the SSL configuration of a cluster. - * - * @struct CassSsl - */ -typedef struct CassSsl_ CassSsl; - -/** - * Describes the version of the connected Cassandra cluster. - * - * @struct CassVersion - */ - -typedef struct CassVersion_ { - int major_version; - int minor_version; - int patch_version; -} CassVersion; - -/** - * A snapshot of the schema's metadata. - * - * @struct CassSchemaMeta - */ -typedef struct CassSchemaMeta_ CassSchemaMeta; - -/** - * Keyspace metadata - * - * @struct CassKeyspaceMeta - */ -typedef struct CassKeyspaceMeta_ CassKeyspaceMeta; - -/** - * Table metadata - * - * @struct CassTableMeta - */ -typedef struct CassTableMeta_ CassTableMeta; - -/** - * MaterializedView metadata - * - * @struct CassMaterializedViewMeta - * - * @cassandra{3.0+} - */ -typedef struct CassMaterializedViewMeta_ CassMaterializedViewMeta; - -/** - * Column metadata - * - * @struct CassColumnMeta - */ -typedef struct CassColumnMeta_ CassColumnMeta; - -/** - * Index metadata - * - * @struct CassIndexMeta - */ -typedef struct CassIndexMeta_ CassIndexMeta; - -/** - * A UUID generator object. - * - * Instances of the UUID generator object are thread-safe to generate UUIDs. - * - * @struct CassUuidGen - */ -typedef struct CassUuidGen_ CassUuidGen; - -/** - * Policies that defined the behavior of a request when a server-side - * read/write timeout or unavailable error occurs. - * - * Generators of client-side, microsecond-precision timestamps. - * - * @struct CassTimestampGen - * - * @cassandra{2.1+} - */ -typedef struct CassTimestampGen_ CassTimestampGen; - -/** - * @struct CassRetryPolicy - */ -typedef struct CassRetryPolicy_ CassRetryPolicy; - -/** - * @struct CassCustomPayload - * - * @cassandra{2.2+} - */ -typedef struct CassCustomPayload_ CassCustomPayload; - -/** - * A snapshot of the session's performance/diagnostic metrics. - * - * @struct CassMetrics - */ -typedef struct CassMetrics_ { - struct { - cass_uint64_t min; /**< Minimum in microseconds */ - cass_uint64_t max; /**< Maximum in microseconds */ - cass_uint64_t mean; /**< Mean in microseconds */ - cass_uint64_t stddev; /**< Standard deviation in microseconds */ - cass_uint64_t median; /**< Median in microseconds */ - cass_uint64_t percentile_75th; /**< 75th percentile in microseconds */ - cass_uint64_t percentile_95th; /**< 95th percentile in microseconds */ - cass_uint64_t percentile_98th; /**< 98th percentile in microseconds */ - cass_uint64_t percentile_99th; /**< 99the percentile in microseconds */ - cass_uint64_t percentile_999th; /**< 99.9th percentile in microseconds */ - cass_double_t mean_rate; /**< Mean rate in requests per second */ - cass_double_t one_minute_rate; /**< 1 minute rate in requests per second */ - cass_double_t five_minute_rate; /**< 5 minute rate in requests per second */ - cass_double_t fifteen_minute_rate; /**< 15 minute rate in requests per second */ - } requests; /**< Performance request metrics */ - - struct { - cass_uint64_t total_connections; /**< The total number of connections */ - cass_uint64_t available_connections; /**< Deprecated */ - cass_uint64_t exceeded_pending_requests_water_mark; /**< Deprecated */ - cass_uint64_t exceeded_write_bytes_water_mark; /**< Deprecated */ - } stats; /**< Diagnostic metrics */ - - struct { - cass_uint64_t connection_timeouts; /**< Occurrences of a connection timeout */ - cass_uint64_t pending_request_timeouts; /**< Deprecated */ - cass_uint64_t request_timeouts; /**< Occurrences of requests that timed out waiting for a request to finish */ - } errors; /**< Error metrics */ -} CassMetrics; - -typedef struct CassSpeculativeExecutionMetrics_ { - cass_uint64_t min; /**< Minimum in microseconds */ - cass_uint64_t max; /**< Maximum in microseconds */ - cass_uint64_t mean; /**< Mean in microseconds */ - cass_uint64_t stddev; /**< Standard deviation in microseconds */ - cass_uint64_t median; /**< Median in microseconds */ - cass_uint64_t percentile_75th; /**< 75th percentile in microseconds */ - cass_uint64_t percentile_95th; /**< 95th percentile in microseconds */ - cass_uint64_t percentile_98th; /**< 98th percentile in microseconds */ - cass_uint64_t percentile_99th; /**< 99the percentile in microseconds */ - cass_uint64_t percentile_999th; /**< 99.9th percentile in microseconds */ - cass_uint64_t count; /**< The number of aborted speculative retries */ - cass_double_t percentage; /**< Fraction of requests that are aborted speculative retries */ -} CassSpeculativeExecutionMetrics; - -typedef enum CassConsistency_ { - CASS_CONSISTENCY_UNKNOWN = 0xFFFF, - CASS_CONSISTENCY_ANY = 0x0000, - CASS_CONSISTENCY_ONE = 0x0001, - CASS_CONSISTENCY_TWO = 0x0002, - CASS_CONSISTENCY_THREE = 0x0003, - CASS_CONSISTENCY_QUORUM = 0x0004, - CASS_CONSISTENCY_ALL = 0x0005, - CASS_CONSISTENCY_LOCAL_QUORUM = 0x0006, - CASS_CONSISTENCY_EACH_QUORUM = 0x0007, - CASS_CONSISTENCY_SERIAL = 0x0008, - CASS_CONSISTENCY_LOCAL_SERIAL = 0x0009, - CASS_CONSISTENCY_LOCAL_ONE = 0x000A -} CassConsistency; - -#define CASS_CONSISTENCY_MAPPING(XX) \ - XX(CASS_CONSISTENCY_UNKNOWN, "UNKNOWN") \ - XX(CASS_CONSISTENCY_ANY, "ANY") \ - XX(CASS_CONSISTENCY_ONE, "ONE") \ - XX(CASS_CONSISTENCY_TWO, "TWO") \ - XX(CASS_CONSISTENCY_THREE, "THREE") \ - XX(CASS_CONSISTENCY_QUORUM, "QUORUM") \ - XX(CASS_CONSISTENCY_ALL, "ALL") \ - XX(CASS_CONSISTENCY_LOCAL_QUORUM, "LOCAL_QUORUM") \ - XX(CASS_CONSISTENCY_EACH_QUORUM, "EACH_QUORUM") \ - XX(CASS_CONSISTENCY_SERIAL, "SERIAL") \ - XX(CASS_CONSISTENCY_LOCAL_SERIAL, "LOCAL_SERIAL") \ - XX(CASS_CONSISTENCY_LOCAL_ONE, "LOCAL_ONE") - -/* @cond IGNORE */ -#define CASS_CONSISTENCY_MAP CASS_CONSISTENCY_MAPPING /* Deprecated */ -/* @endcond */ - -typedef enum CassWriteType_ { - CASS_WRITE_TYPE_UNKNOWN, - CASS_WRITE_TYPE_SIMPLE, - CASS_WRITE_TYPE_BATCH, - CASS_WRITE_TYPE_UNLOGGED_BATCH, - CASS_WRITE_TYPE_COUNTER, - CASS_WRITE_TYPE_BATCH_LOG, - CASS_WRITE_TYPE_CAS, - CASS_WRITE_TYPE_VIEW, - CASS_WRITE_TYPE_CDC -} CassWriteType; - -#define CASS_WRITE_TYPE_MAPPING(XX) \ - XX(CASS_WRITE_TYPE_SIMPLE, "SIMPLE") \ - XX(CASS_WRITE_TYPE_BATCH, "BATCH") \ - XX(CASS_WRITE_TYPE_UNLOGGED_BATCH, "UNLOGGED_BATCH") \ - XX(CASS_WRITE_TYPE_COUNTER, "COUNTER") \ - XX(CASS_WRITE_TYPE_BATCH_LOG, "BATCH_LOG") \ - XX(CASS_WRITE_TYPE_CAS, "CAS") \ - XX(CASS_WRITE_TYPE_VIEW, "VIEW") \ - XX(CASS_WRITE_TYPE_CDC, "CDC") - -/* @cond IGNORE */ -#define CASS_WRITE_TYPE_MAP CASS_WRITE_TYPE_MAPPING /* Deprecated */ -/* @endcond */ - -typedef enum CassColumnType_ { - CASS_COLUMN_TYPE_REGULAR, - CASS_COLUMN_TYPE_PARTITION_KEY, - CASS_COLUMN_TYPE_CLUSTERING_KEY, - CASS_COLUMN_TYPE_STATIC, - CASS_COLUMN_TYPE_COMPACT_VALUE -} CassColumnType; - -typedef enum CassIndexType_ { - CASS_INDEX_TYPE_UNKNOWN, - CASS_INDEX_TYPE_KEYS, - CASS_INDEX_TYPE_CUSTOM, - CASS_INDEX_TYPE_COMPOSITES -} CassIndexType; - -#define CASS_VALUE_TYPE_MAPPING(XX) \ - XX(CASS_VALUE_TYPE_CUSTOM, 0x0000, "", "") \ - XX(CASS_VALUE_TYPE_ASCII, 0x0001, "ascii", "org.apache.cassandra.db.marshal.AsciiType") \ - XX(CASS_VALUE_TYPE_BIGINT, 0x0002, "bigint", "org.apache.cassandra.db.marshal.LongType") \ - XX(CASS_VALUE_TYPE_BLOB, 0x0003, "blob", "org.apache.cassandra.db.marshal.BytesType") \ - XX(CASS_VALUE_TYPE_BOOLEAN, 0x0004, "boolean", "org.apache.cassandra.db.marshal.BooleanType") \ - XX(CASS_VALUE_TYPE_COUNTER, 0x0005, "counter", "org.apache.cassandra.db.marshal.CounterColumnType") \ - XX(CASS_VALUE_TYPE_DECIMAL, 0x0006, "decimal", "org.apache.cassandra.db.marshal.DecimalType") \ - XX(CASS_VALUE_TYPE_DOUBLE, 0x0007, "double", "org.apache.cassandra.db.marshal.DoubleType") \ - XX(CASS_VALUE_TYPE_FLOAT, 0x0008, "float", "org.apache.cassandra.db.marshal.FloatType") \ - XX(CASS_VALUE_TYPE_INT, 0x0009, "int", "org.apache.cassandra.db.marshal.Int32Type") \ - XX(CASS_VALUE_TYPE_TEXT, 0x000A, "text", "org.apache.cassandra.db.marshal.UTF8Type") \ - XX(CASS_VALUE_TYPE_TIMESTAMP, 0x000B, "timestamp", "org.apache.cassandra.db.marshal.TimestampType") \ - XX(CASS_VALUE_TYPE_UUID, 0x000C, "uuid", "org.apache.cassandra.db.marshal.UUIDType") \ - XX(CASS_VALUE_TYPE_VARCHAR, 0x000D, "varchar", "") \ - XX(CASS_VALUE_TYPE_VARINT, 0x000E, "varint", "org.apache.cassandra.db.marshal.IntegerType") \ - XX(CASS_VALUE_TYPE_TIMEUUID, 0x000F, "timeuuid", "org.apache.cassandra.db.marshal.TimeUUIDType") \ - XX(CASS_VALUE_TYPE_INET, 0x0010, "inet", "org.apache.cassandra.db.marshal.InetAddressType") \ - XX(CASS_VALUE_TYPE_DATE, 0x0011, "date", "org.apache.cassandra.db.marshal.SimpleDateType") \ - XX(CASS_VALUE_TYPE_TIME, 0x0012, "time", "org.apache.cassandra.db.marshal.TimeType") \ - XX(CASS_VALUE_TYPE_SMALL_INT, 0x0013, "smallint", "org.apache.cassandra.db.marshal.ShortType") \ - XX(CASS_VALUE_TYPE_TINY_INT, 0x0014, "tinyint", "org.apache.cassandra.db.marshal.ByteType") \ - XX(CASS_VALUE_TYPE_DURATION, 0x0015, "duration", "org.apache.cassandra.db.marshal.DurationType") \ - XX(CASS_VALUE_TYPE_LIST, 0x0020, "list", "org.apache.cassandra.db.marshal.ListType") \ - XX(CASS_VALUE_TYPE_MAP, 0x0021, "map", "org.apache.cassandra.db.marshal.MapType") \ - XX(CASS_VALUE_TYPE_SET, 0x0022, "set", "org.apache.cassandra.db.marshal.SetType") \ - XX(CASS_VALUE_TYPE_UDT, 0x0030, "", "") \ - XX(CASS_VALUE_TYPE_TUPLE, 0x0031, "tuple", "org.apache.cassandra.db.marshal.TupleType") - -typedef enum CassValueType_ { - CASS_VALUE_TYPE_UNKNOWN = 0xFFFF, -#define XX_VALUE_TYPE(name, type, cql, klass) name = type, - CASS_VALUE_TYPE_MAPPING(XX_VALUE_TYPE) -#undef XX_VALUE_TYPE - /* @cond IGNORE */ - CASS_VALUE_TYPE_LAST_ENTRY - /* @endcond */ -} CassValueType; - -typedef enum CassClusteringOrder_ { - CASS_CLUSTERING_ORDER_NONE, - CASS_CLUSTERING_ORDER_ASC, - CASS_CLUSTERING_ORDER_DESC -} CassClusteringOrder; - -typedef enum CassCollectionType_ { - CASS_COLLECTION_TYPE_LIST = CASS_VALUE_TYPE_LIST, - CASS_COLLECTION_TYPE_MAP = CASS_VALUE_TYPE_MAP, - CASS_COLLECTION_TYPE_SET = CASS_VALUE_TYPE_SET -} CassCollectionType; - -typedef enum CassBatchType_ { - CASS_BATCH_TYPE_LOGGED = 0x00, - CASS_BATCH_TYPE_UNLOGGED = 0x01, - CASS_BATCH_TYPE_COUNTER = 0x02 -} CassBatchType; - -typedef enum CassIteratorType_ { - CASS_ITERATOR_TYPE_RESULT, - CASS_ITERATOR_TYPE_ROW, - CASS_ITERATOR_TYPE_COLLECTION, - CASS_ITERATOR_TYPE_MAP, - CASS_ITERATOR_TYPE_TUPLE, - CASS_ITERATOR_TYPE_USER_TYPE_FIELD, - CASS_ITERATOR_TYPE_META_FIELD, - CASS_ITERATOR_TYPE_KEYSPACE_META, - CASS_ITERATOR_TYPE_TABLE_META, - CASS_ITERATOR_TYPE_TYPE_META, - CASS_ITERATOR_TYPE_FUNCTION_META, - CASS_ITERATOR_TYPE_AGGREGATE_META, - CASS_ITERATOR_TYPE_COLUMN_META, - CASS_ITERATOR_TYPE_INDEX_META, - CASS_ITERATOR_TYPE_MATERIALIZED_VIEW_META -} CassIteratorType; - -#define CASS_LOG_LEVEL_MAPPING(XX) \ - XX(CASS_LOG_DISABLED, "") \ - XX(CASS_LOG_CRITICAL, "CRITICAL") \ - XX(CASS_LOG_ERROR, "ERROR") \ - XX(CASS_LOG_WARN, "WARN") \ - XX(CASS_LOG_INFO, "INFO") \ - XX(CASS_LOG_DEBUG, "DEBUG") \ - XX(CASS_LOG_TRACE, "TRACE") - -/* @cond IGNORE */ -#define CASS_LOG_LEVEL_MAP CASS_LOG_LEVEL_MAPPING /* Deprecated */ -/* @endcond */ - -typedef enum CassLogLevel_ { -#define XX_LOG(log_level, _) log_level, - CASS_LOG_LEVEL_MAPPING(XX_LOG) -#undef XX_LOG - /* @cond IGNORE */ - CASS_LOG_LAST_ENTRY - /* @endcond */ -} CassLogLevel; - -typedef enum CassSslVerifyFlags_ { - CASS_SSL_VERIFY_NONE = 0x00, - CASS_SSL_VERIFY_PEER_CERT = 0x01, - CASS_SSL_VERIFY_PEER_IDENTITY = 0x02, - CASS_SSL_VERIFY_PEER_IDENTITY_DNS = 0x04 -} CassSslVerifyFlags; - -typedef enum CassSslTlsVersion_ { - CASS_SSL_VERSION_TLS1 = 0x00, - CASS_SSL_VERSION_TLS1_1 = 0x01, - CASS_SSL_VERSION_TLS1_2 = 0x02 -} CassSslTlsVersion; - -typedef enum CassProtocolVersion_ { - CASS_PROTOCOL_VERSION_V1 = 0x01, /**< Deprecated */ - CASS_PROTOCOL_VERSION_V2 = 0x02, /**< Deprecated */ - CASS_PROTOCOL_VERSION_V3 = 0x03, - CASS_PROTOCOL_VERSION_V4 = 0x04, - CASS_PROTOCOL_VERSION_V5 = 0x05, - CASS_PROTOCOL_VERSION_DSEV1 = 0x41, /**< Only supported when using the DSE - driver with DataStax Enterprise */ - CASS_PROTOCOL_VERSION_DSEV2 = 0x42 /**< Only supported when using the DSE - driver with DataStax Enterprise */ -} CassProtocolVersion; - -typedef enum CassErrorSource_ { - CASS_ERROR_SOURCE_NONE, - CASS_ERROR_SOURCE_LIB, - CASS_ERROR_SOURCE_SERVER, - CASS_ERROR_SOURCE_SSL, - CASS_ERROR_SOURCE_COMPRESSION -} CassErrorSource; - -#define CASS_ERROR_MAPPING(XX) \ - XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_BAD_PARAMS, 1, "Bad parameters") \ - XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_NO_STREAMS, 2, "No streams available") \ - XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_UNABLE_TO_INIT, 3, "Unable to initialize") \ - XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_MESSAGE_ENCODE, 4, "Unable to encode message") \ - XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_HOST_RESOLUTION, 5, "Unable to resolve host") \ - XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_UNEXPECTED_RESPONSE, 6, "Unexpected response from server") \ - XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_REQUEST_QUEUE_FULL, 7, "The request queue is full") \ - XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_NO_AVAILABLE_IO_THREAD, 8, "No available IO threads") \ - XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_WRITE_ERROR, 9, "Write error") \ - XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_NO_HOSTS_AVAILABLE, 10, "No hosts available") \ - XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_INDEX_OUT_OF_BOUNDS, 11, "Index out of bounds") \ - XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_INVALID_ITEM_COUNT, 12, "Invalid item count") \ - XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_INVALID_VALUE_TYPE, 13, "Invalid value type") \ - XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_REQUEST_TIMED_OUT, 14, "Request timed out") \ - XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_UNABLE_TO_SET_KEYSPACE, 15, "Unable to set keyspace") \ - XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_CALLBACK_ALREADY_SET, 16, "Callback already set") \ - XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_INVALID_STATEMENT_TYPE, 17, "Invalid statement type") \ - XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_NAME_DOES_NOT_EXIST, 18, "No value or column for name") \ - XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_UNABLE_TO_DETERMINE_PROTOCOL, 19, "Unable to find supported protocol version") \ - XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_NULL_VALUE, 20, "NULL value specified") \ - XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_NOT_IMPLEMENTED, 21, "Not implemented") \ - XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_UNABLE_TO_CONNECT, 22, "Unable to connect") \ - XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_UNABLE_TO_CLOSE, 23, "Unable to close") \ - XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_NO_PAGING_STATE, 24, "No paging state") \ - XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_PARAMETER_UNSET, 25, "Parameter unset") \ - XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_INVALID_ERROR_RESULT_TYPE, 26, "Invalid error result type") \ - XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_INVALID_FUTURE_TYPE, 27, "Invalid future type") \ - XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_INTERNAL_ERROR, 28, "Internal error") \ - XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_INVALID_CUSTOM_TYPE, 29, "Invalid custom type") \ - XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_INVALID_DATA, 30, "Invalid data") \ - XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_NOT_ENOUGH_DATA, 31, "Not enough data") \ - XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_INVALID_STATE, 32, "Invalid state") \ - XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_NO_CUSTOM_PAYLOAD, 33, "No custom payload") \ - XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_EXECUTION_PROFILE_INVALID, 34, "Invalid execution profile specified") \ - XX(CASS_ERROR_SOURCE_LIB, CASS_ERROR_LIB_NO_TRACING_ID, 35, "No tracing ID") \ - XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_SERVER_ERROR, 0x0000, "Server error") \ - XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_PROTOCOL_ERROR, 0x000A, "Protocol error") \ - XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_BAD_CREDENTIALS, 0x0100, "Bad credentials") \ - XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_UNAVAILABLE, 0x1000, "Unavailable") \ - XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_OVERLOADED, 0x1001, "Overloaded") \ - XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_IS_BOOTSTRAPPING, 0x1002, "Is bootstrapping") \ - XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_TRUNCATE_ERROR, 0x1003, "Truncate error") \ - XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_WRITE_TIMEOUT, 0x1100, "Write timeout") \ - XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_READ_TIMEOUT, 0x1200, "Read timeout") \ - XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_READ_FAILURE, 0x1300, "Read failure") \ - XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_FUNCTION_FAILURE, 0x1400, "Function failure") \ - XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_WRITE_FAILURE, 0x1500, "Write failure") \ - XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_SYNTAX_ERROR, 0x2000, "Syntax error") \ - XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_UNAUTHORIZED, 0x2100, "Unauthorized") \ - XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_INVALID_QUERY, 0x2200, "Invalid query") \ - XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_CONFIG_ERROR, 0x2300, "Configuration error") \ - XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_ALREADY_EXISTS, 0x2400, "Already exists") \ - XX(CASS_ERROR_SOURCE_SERVER, CASS_ERROR_SERVER_UNPREPARED, 0x2500, "Unprepared") \ - XX(CASS_ERROR_SOURCE_SSL, CASS_ERROR_SSL_INVALID_CERT, 1, "Unable to load certificate") \ - XX(CASS_ERROR_SOURCE_SSL, CASS_ERROR_SSL_INVALID_PRIVATE_KEY, 2, "Unable to load private key") \ - XX(CASS_ERROR_SOURCE_SSL, CASS_ERROR_SSL_NO_PEER_CERT, 3, "No peer certificate") \ - XX(CASS_ERROR_SOURCE_SSL, CASS_ERROR_SSL_INVALID_PEER_CERT, 4, "Invalid peer certificate") \ - XX(CASS_ERROR_SOURCE_SSL, CASS_ERROR_SSL_IDENTITY_MISMATCH, 5, "Certificate does not match host or IP address") \ - XX(CASS_ERROR_SOURCE_SSL, CASS_ERROR_SSL_PROTOCOL_ERROR, 6, "Protocol error") \ - XX(CASS_ERROR_SOURCE_SSL, CASS_ERROR_SSL_CLOSED, 7, "Connection closed") - -/* @cond IGNORE */ -#define CASS_ERROR_MAP CASS_ERROR_MAPPING /* Deprecated */ -/* @endcond*/ - -#define CASS_ERROR(source, code) ((source << 24) | code) - -typedef enum CassError_ { - CASS_OK = 0, -#define XX_ERROR(source, name, code, _) name = CASS_ERROR(source, code), - CASS_ERROR_MAPPING(XX_ERROR) -#undef XX_ERROR - /* @cond IGNORE */ - CASS_ERROR_LAST_ENTRY - /* @endcond*/ -} CassError; - -/** - * A callback that's notified when the future is set. - * - * @param[in] message - * @param[in] data user defined data provided when the callback - * was registered. - * - * @see cass_future_set_callback() - */ -typedef void (*CassFutureCallback)(CassFuture* future, - void* data); - -/** - * Maximum size of a log message - */ -#define CASS_LOG_MAX_MESSAGE_SIZE 1024 - -/** - * A log message. - */ -typedef struct CassLogMessage_ { - /** - * The millisecond timestamp (since the Epoch) when the message was logged - */ - cass_uint64_t time_ms; - CassLogLevel severity; /**< The severity of the log message */ - const char* file; /**< The file where the message was logged */ - int line; /**< The line in the file where the message was logged */ - const char* function; /**< The function where the message was logged */ - char message[CASS_LOG_MAX_MESSAGE_SIZE]; /**< The message */ -} CassLogMessage; - -/** - * A callback that's used to handle logging. - * - * @param[in] message - * @param[in] data user defined data provided when the callback - * was registered. - * - * @see cass_log_set_callback() - */ -typedef void (*CassLogCallback)(const CassLogMessage* message, - void* data); - -/** - * A custom malloc function. This function should allocate "size" bytes and - * return a pointer to that memory - * - * @param[in] size The size of the memory to allocate - * - * @see CassFreeFunction - * @see cass_alloc_set_functions() - */ -typedef void* (*CassMallocFunction)(size_t size); - -/** - * A custom realloc function. This function attempts to change the size of the - * memory pointed to by "ptr". If the memory cannot be resized then new memory - * should be allocated and contain the contents of the original memory at "ptr". - * - * @param[in] ptr A pointer to the original memory. If NULL it should behave the - * same as "CassMallocFunction" - * @param[in] size The size of the memory to allocate/resize. - * - * @see CassMallocFunction - * @see CassFreeFunction - * @see cass_alloc_set_functions() - */ -typedef void* (*CassReallocFunction)(void* ptr, size_t size); - -/** - * A custom free function. This function deallocates the memory pointed to by - * "ptr" that was previously allocated by a "CassMallocFunction" or - * "CassReallocFunction" function. - * - * @param[in] ptr A pointer to memory that should be deallocated. If NULL then - * this will perform no operation. - * - * @see CassMallocFunction - * @see CassReallocFunction - * @see cass_alloc_set_functions() - */ -typedef void (*CassFreeFunction)(void* ptr); - -/** - * An authenticator. - * - * @struct CassAuthenticator - */ -typedef struct CassAuthenticator_ CassAuthenticator; - -/** - * A callback used to initiate an authentication exchange. - * - * Use cass_authenticator_set_response() to set the response token. - * - * Use cass_authenticator_set_error() if an error occurred during - * initialization. - * - * @param[in] auth - * @param[in] data - */ -typedef void (*CassAuthenticatorInitialCallback)(CassAuthenticator* auth, - void* data); - -/** - * A callback used when an authentication challenge initiated - * by the server. - * - * Use cass_authenticator_set_response() to set the response token. - * - * Use cass_authenticator_set_error() if an error occurred during the - * challenge. - * - * @param[in] auth - * @param[in] data - * @param[in] token - * @param[in] token_size - */ -typedef void (*CassAuthenticatorChallengeCallback)(CassAuthenticator* auth, - void* data, - const char* token, - size_t token_size); -/** - * A callback used to indicate the success of the authentication - * exchange. - * - * Use cass_authenticator_set_error() if an error occurred while evaluating - * the success token. - * - * @param[in] auth - * @param[in] data - * @param[in] token - * @param[in] token_size - */ -typedef void (*CassAuthenticatorSuccessCallback)(CassAuthenticator* auth, - void* data, - const char* token, - size_t token_size); -/** - * A callback used to cleanup resources that were acquired during - * the process of the authentication exchange. This is called after - * the termination of the exchange regardless of the outcome. - * - * @param[in] auth - * @param[in] data - */ -typedef void (*CassAuthenticatorCleanupCallback)(CassAuthenticator* auth, - void* data); - -/** - * A callback used to cleanup resources. - * - * @param[in] data - */ -typedef void (*CassAuthenticatorDataCleanupCallback)(void* data); - -/** - * Authenticator callbacks - */ -typedef struct CassAuthenticatorCallbacks_ { - CassAuthenticatorInitialCallback initial_callback; - CassAuthenticatorChallengeCallback challenge_callback; - CassAuthenticatorSuccessCallback success_callback; - CassAuthenticatorCleanupCallback cleanup_callback; -} CassAuthenticatorCallbacks; - -typedef enum CassHostListenerEvent_ { - CASS_HOST_LISTENER_EVENT_UP, - CASS_HOST_LISTENER_EVENT_DOWN, - CASS_HOST_LISTENER_EVENT_ADD, - CASS_HOST_LISTENER_EVENT_REMOVE -} CassHostListenerEvent; - -/** - * A callback used to indicate the host state for a node in the cluster. - * - * @param[in] event - * @param[in] address - * @param[in] data - * @see cass_cluster_set_host_listener_callback() - */ -typedef void(*CassHostListenerCallback)(CassHostListenerEvent event, - const CassInet address, - void* data); - -/*********************************************************************************** - * - * Execution Profile - * - ***********************************************************************************/ - -/** - * An execution profile object provides a mechanism to group together a set of - * configuration options and reuse them across different statement executions. - * This feature is useful when dealing with different query workloads. - * - * @struct CassExecProfile - */ -typedef struct CassExecProfile_ CassExecProfile; - -/** - * Creates a new execution profile. - * - * @public @memberof CassExecProfile - * - * @return Returns a execution profile that must be freed. - * - * @see cass_execution_profile_free() - */ -CASS_EXPORT CassExecProfile* -cass_execution_profile_new(); - -/** - * Frees a execution profile instance. - * - * @public @memberof CassExecProfile - * - * @param[in] profile - */ -CASS_EXPORT void -cass_execution_profile_free(CassExecProfile* profile); - -/** - * Sets the timeout waiting for a response from a node. - * - * Default: Disabled (uses the cluster request timeout) - * - * @public @memberof CassExecProfile - * - * @param[in] profile - * @param[in] timeout_ms Request timeout in milliseconds. Use 0 for no timeout - * or CASS_UINT64_MAX to disable. - * @return CASS_OK if successful, otherwise an error occurred. - * - * @see cass_statement_set_request_timeout() - */ -CASS_EXPORT CassError -cass_execution_profile_set_request_timeout(CassExecProfile* profile, - cass_uint64_t timeout_ms); - -/** - * Sets the consistency level. - * - * Default: Disabled (uses the default consistency) - * - * @public @memberof CassExecProfile - * - * @param[in] profile - * @param[in] consistency - * @return CASS_OK if successful, otherwise an error occurred. - * - * @see cass_statement_set_consistency() - */ -CASS_EXPORT CassError -cass_execution_profile_set_consistency(CassExecProfile* profile, - CassConsistency consistency); - -/** - * Sets the serial consistency level. - * - * Default: Disabled (uses the default serial consistency) - * - * @public @memberof CassExecProfile - * - * @param[in] profile - * @param[in] serial_consistency - * @return CASS_OK if successful, otherwise an error occurred. - * - * @see cass_statement_set_serial_consistency() - */ -CASS_EXPORT CassError -cass_execution_profile_set_serial_consistency(CassExecProfile* profile, - CassConsistency serial_consistency); - -/** - * Configures the execution profile to use round-robin load balancing. - * - * The driver discovers all nodes in a cluster and cycles through - * them per request. All are considered 'local'. - * - * Note: Profile-based load balancing policy is disabled by default; - * cluster load balancing policy is used when profile does not contain a policy. - * - * @public @memberof CassExecProfile - * - * @param[in] profile - * @return CASS_OK if successful, otherwise an error occurred. - * - * @see cass_cluster_set_load_balance_round_robin() - */ -CASS_EXPORT CassError -cass_execution_profile_set_load_balance_round_robin(CassExecProfile* profile); - -/** - * Configures the execution profile to use DC-aware load balancing. - * For each query, all live nodes in a primary 'local' DC are tried first, - * followed by any node from other DCs. - * - * Note: Profile-based load balancing policy is disabled by default; - * cluster load balancing policy is used when profile does not contain a policy. - * - * @deprecated The remote DC settings for DC-aware are not suitable for most - * scenarios that require DC failover. There is also unhandled gap between - * replication factor number of nodes failing and the full cluster failing. Only - * the remote DC settings are being deprecated. - * - * @public @memberof CassExecProfile - * - * @param[in] profile - * @param[in] local_dc The primary data center to try first - * @param[in] used_hosts_per_remote_dc The number of hosts used in each remote - * DC if no hosts are available in the local dc (deprecated) - * @param[in] allow_remote_dcs_for_local_cl Allows remote hosts to be used if no - * local dc hosts are available and the consistency level is LOCAL_ONE or - * LOCAL_QUORUM (deprecated) - * @return CASS_OK if successful, otherwise an error occurred. - * - * @see cass_cluster_set_load_balance_dc_aware() - */ -CASS_EXPORT CassError -cass_execution_profile_set_load_balance_dc_aware(CassExecProfile* profile, - const char* local_dc, - unsigned used_hosts_per_remote_dc, - cass_bool_t allow_remote_dcs_for_local_cl); - -/** - * Same as cass_execution_profile_set_load_balance_dc_aware(), but with lengths - * for string parameters. - * - * @deprecated The remote DC settings for DC-aware are not suitable for most - * scenarios that require DC failover. There is also unhandled gap between - * replication factor number of nodes failing and the full cluster failing. Only - * the remote DC settings are being deprecated. - * - * @public @memberof CassExecProfile - * - * @param[in] profile - * @param[in] local_dc - * @param[in] local_dc_length - * @param[in] used_hosts_per_remote_dc (deprecated) - * @param[in] allow_remote_dcs_for_local_cl (deprecated) - * @return same as cass_execution_profile_set_load_balance_dc_aware() - * - * @see cass_execution_profile_set_load_balance_dc_aware() - * @see cass_cluster_set_load_balance_dc_aware_n() - */ -CASS_EXPORT CassError -cass_execution_profile_set_load_balance_dc_aware_n(CassExecProfile* profile, - const char* local_dc, - size_t local_dc_length, - unsigned used_hosts_per_remote_dc, - cass_bool_t allow_remote_dcs_for_local_cl); - -/** - * Configures the execution profile to use token-aware request routing or not. - * - * Important: Token-aware routing depends on keyspace metadata. - * For this reason enabling token-aware routing will also enable retrieving - * and updating keyspace schema metadata. - * - * Default: cass_true (enabled). - * - * This routing policy composes the base routing policy, routing - * requests first to replicas on nodes considered 'local' by - * the base load balancing policy. - * - * Note: Execution profiles use the cluster-level load balancing policy - * unless enabled. This setting is not applicable unless a load balancing policy - * is enabled on the execution profile. - * - * @public @memberof CassExecProfile - * - * @param[in] profile - * @param[in] enabled - * @return CASS_OK if successful, otherwise an error occurred. - * - * @see cass_cluster_set_token_aware_routing() - */ -CASS_EXPORT CassError -cass_execution_profile_set_token_aware_routing(CassExecProfile* profile, - cass_bool_t enabled); - -/** - * Configures the execution profile's token-aware routing to randomly shuffle - * replicas. This can reduce the effectiveness of server-side caching, but it - * can better distribute load over replicas for a given partition key. - * - * Note: Token-aware routing must be enabled and a load balancing policy - * must be enabled on the execution profile for the setting to be applicable. - * - * Default: cass_true (enabled). - * - * @public @memberof CassExecProfile - * - * @param[in] profile - * @param[in] enabled - * @return CASS_OK if successful, otherwise an error occurred. - * - * @see cass_cluster_set_token_aware_routing_shuffle_replicas() - */ -CASS_EXPORT CassError -cass_execution_profile_set_token_aware_routing_shuffle_replicas(CassExecProfile* profile, - cass_bool_t enabled); - -/** - * Configures the execution profile to use latency-aware request routing or not. - * - * Note: Execution profiles use the cluster-level load balancing policy - * unless enabled. This setting is not applicable unless a load balancing policy - * is enabled on the execution profile. - * - * Default: cass_false (disabled). - * - * This routing policy is a top-level routing policy. It uses the - * base routing policy to determine locality (dc-aware) and/or - * placement (token-aware) before considering the latency. - * - * @public @memberof CassExecProfile - * - * @param[in] profile - * @param[in] enabled - * @return CASS_OK if successful, otherwise an error occurred. - * - * @see cass_cluster_set_latency_aware_routing() - */ -CASS_EXPORT CassError -cass_execution_profile_set_latency_aware_routing(CassExecProfile* profile, - cass_bool_t enabled); - -/** - * Configures the execution profile's settings for latency-aware request - * routing. - * - * Note: Execution profiles use the cluster-level load balancing policy - * unless enabled. This setting is not applicable unless a load balancing policy - * is enabled on the execution profile. - * - * Defaults: - * - *
    - *
  • exclusion_threshold: 2.0
  • - *
  • scale_ms: 100 milliseconds
  • - *
  • retry_period_ms: 10,000 milliseconds (10 seconds)
  • - *
  • update_rate_ms: 100 milliseconds
  • - *
  • min_measured: 50
  • - *
- * - * @public @memberof CassExecProfile - * - * @param[in] profile - * @param[in] exclusion_threshold Controls how much worse the latency must be - * compared to the average latency of the best performing node before it - * penalized. - * @param[in] scale_ms Controls the weight given to older latencies when - * calculating the average latency of a node. A bigger scale will give more - * weight to older latency measurements. - * @param[in] retry_period_ms The amount of time a node is penalized by the - * policy before being given a second chance when the current average latency - * exceeds the calculated threshold - * (exclusion_threshold * best_average_latency). - * @param[in] update_rate_ms The rate at which the best average latency is - * recomputed. - * @param[in] min_measured The minimum number of measurements per-host required - * to be considered by the policy. - * @return CASS_OK if successful, otherwise an error occurred. - * - * @see cass_cluster_set_latency_aware_routing_settings() - */ -CASS_EXPORT CassError -cass_execution_profile_set_latency_aware_routing_settings(CassExecProfile* profile, - cass_double_t exclusion_threshold, - cass_uint64_t scale_ms, - cass_uint64_t retry_period_ms, - cass_uint64_t update_rate_ms, - cass_uint64_t min_measured); - -/** - * Sets/Appends whitelist hosts for the execution profile. The first call sets - * the whitelist hosts and any subsequent calls appends additional hosts. - * Passing an empty string will clear and disable the whitelist. White space is - * striped from the hosts. - * - * This policy filters requests to all other policies, only allowing requests - * to the hosts contained in the whitelist. Any host not in the whitelist will - * be ignored and a connection will not be established. This policy is useful - * for ensuring that the driver will only connect to a predefined set of hosts. - * - * Examples: "127.0.0.1" "127.0.0.1,127.0.0.2" - * - * Note: Execution profiles use the cluster-level load balancing policy - * unless enabled. This setting is not applicable unless a load balancing policy - * is enabled on the execution profile. - * - * @public @memberof CassExecProfile - * - * @param[in] profile - * @param[in] hosts A comma delimited list of addresses. An empty string will - * clear the whitelist hosts. The string is copied into the cluster - * configuration; the memory pointed to by this parameter can be freed after - * this call. - * @return CASS_OK if successful, otherwise an error occurred. - * - * @see cass_cluster_set_whitelist_filtering() - */ -CASS_EXPORT CassError -cass_execution_profile_set_whitelist_filtering(CassExecProfile* profile, - const char* hosts); - -/** - * Same as cass_execution_profile_set_whitelist_filtering(), but with lengths - * for string parameters. - * - * @public @memberof CassExecProfile - * - * @param[in] profile - * @param[in] hosts - * @param[in] hosts_length - * @return same as cass_execution_profile_set_whitelist_filtering() - * - * @see cass_execution_profile_set_whitelist_filtering() - * @see cass_cluster_set_whitelist_filtering() - */ -CASS_EXPORT CassError -cass_execution_profile_set_whitelist_filtering_n(CassExecProfile* profile, - const char* hosts, - size_t hosts_length); - -/** - * Sets/Appends blacklist hosts for the execution profile. The first call sets - * the blacklist hosts and any subsequent calls appends additional hosts. - * Passing an empty string will clear and disable the blacklist. White space is - * striped from the hosts. - * - * This policy filters requests to all other policies, only allowing requests - * to the hosts not contained in the blacklist. Any host in the blacklist will - * be ignored and a connection will not be established. This policy is useful - * for ensuring that the driver will not connect to a predefined set of hosts. - * - * Examples: "127.0.0.1" "127.0.0.1,127.0.0.2" - * - * Note: Execution profiles use the cluster-level load balancing policy - * unless enabled. This setting is not applicable unless a load balancing policy - * is enabled on the execution profile. - * - * @public @memberof CassExecProfile - * - * @param[in] profile - * @param[in] hosts A comma delimited list of addresses. An empty string will - * clear the blacklist hosts. The string is copied into the cluster - * configuration; the memory pointed to by this parameter can be freed after - * this call. - * @return CASS_OK if successful, otherwise an error occurred. - * - * @see cass_cluster_set_blacklist_filtering() - */ -CASS_EXPORT CassError -cass_execution_profile_set_blacklist_filtering(CassExecProfile* profile, - const char* hosts); - -/** - * Same as cass_execution_profile_set_blacklist_filtering(), but with lengths - * for string parameters. - * - * @public @memberof CassExecProfile - * - * @param[in] profile - * @param[in] hosts - * @param[in] hosts_length - * @return same as cass_execution_profile_set_blacklist_filtering_hosts() - * - * @see cass_execution_profile_set_blacklist_filtering() - * @see cass_cluster_set_blacklist_filtering() - */ -CASS_EXPORT CassError -cass_execution_profile_set_blacklist_filtering_n(CassExecProfile* profile, - const char* hosts, - size_t hosts_length); - -/** - * Same as cass_execution_profile_set_whitelist_filtering(), but whitelist all - * hosts of a dc. - * - * Examples: "dc1", "dc1,dc2" - * - * @public @memberof CassExecProfile - * - * @param[in] profile - * @param[in] dcs A comma delimited list of dcs. An empty string will clear the - * whitelist dcs. The string is copied into the cluster configuration; the - * memory pointed to by this parameter can be freed after this call. - * @return CASS_OK if successful, otherwise an error occurred. - * - * @see cass_cluster_set_whitelist_dc_filtering() - */ -CASS_EXPORT CassError -cass_execution_profile_set_whitelist_dc_filtering(CassExecProfile* profile, - const char* dcs); - -/** - * Same as cass_execution_profile_set_whitelist_dc_filtering(), but with lengths - * for string parameters. - * - * @public @memberof CassExecProfile - * - * @param[in] profile - * @param[in] dcs - * @param[in] dcs_length - * @return same as cass_execution_profile_set_whitelist_dc_filtering() - * - * @see cass_execution_profile_set_whitelist_dc_filtering() - * @see cass_cluster_set_whitelist_dc_filtering() - */ -CASS_EXPORT CassError -cass_execution_profile_set_whitelist_dc_filtering_n(CassExecProfile* profile, - const char* dcs, - size_t dcs_length); - -/** - * Same as cass_execution_profile_set_blacklist_filtering(), but blacklist all - * hosts of a dc. - * - * Examples: "dc1", "dc1,dc2" - * - * @public @memberof CassExecProfile - * - * @param[in] profile - * @param[in] dcs A comma delimited list of dcs. An empty string will clear the - * blacklist dcs. The string is copied into the cluster configuration; the - * memory pointed to by this parameter can be freed after this call. - * @return CASS_OK if successful, otherwise an error occurred. - * - * @see cass_execution_profile_set_blacklist_filtering() - * @see cass_cluster_set_blacklist_dc_filtering() - */ -CASS_EXPORT CassError -cass_execution_profile_set_blacklist_dc_filtering(CassExecProfile* profile, - const char* dcs); - -/** - * Same as cass_execution_profile_set_blacklist_dc_filtering(), but with lengths - * for string parameters. - * - * @public @memberof CassExecProfile - * - * @param[in] profile - * @param[in] dcs - * @param[in] dcs_length - * @return same as cass_execution_profile_set_blacklist_dc_filtering() - * - * @see cass_execution_profile_set_blacklist_dc_filtering() - * @see cass_cluster_set_blacklist_dc_filtering() - */ -CASS_EXPORT CassError -cass_execution_profile_set_blacklist_dc_filtering_n(CassExecProfile* profile, - const char* dcs, - size_t dcs_length); - -/** - * Sets the execution profile's retry policy. - * - * Note: Profile-based retry policy is disabled by default; cluster retry - * policy is used when profile does not contain a policy unless the retry policy - * was explicitly set on the batch/statement request. - * - * @public @memberof CassExecProfile - * - * @param[in] profile - * @param[in] retry_policy NULL will clear retry policy from execution profile - * @return CASS_OK if successful, otherwise an error occurred. - * - * @see cass_cluster_set_retry_policy() - */ -CASS_EXPORT CassError -cass_execution_profile_set_retry_policy(CassExecProfile* profile, - CassRetryPolicy* retry_policy); - -/** - * Enable constant speculative executions with the supplied settings for the - * execution profile. - * - * Note: Profile-based speculative execution policy is disabled by - * default; cluster speculative execution policy is used when profile does not - * contain a policy. - * - * @public @memberof CassExecProfile - * - * @param[in] profile - * @param[in] constant_delay_ms - * @param[in] max_speculative_executions - * @return CASS_OK if successful, otherwise an error occurred - * - * @see cass_cluster_set_constant_speculative_execution_policy() - */ -CASS_EXPORT CassError -cass_execution_profile_set_constant_speculative_execution_policy(CassExecProfile* profile, - cass_int64_t constant_delay_ms, - int max_speculative_executions); - -/** - * Disable speculative executions for the execution profile. - * - * Note: Profile-based speculative execution policy is disabled by - * default; cluster speculative execution policy is used when profile does not - * contain a policy. - * - * @public @memberof CassExecProfile - * - * @param[in] profile - * @return CASS_OK if successful, otherwise an error occurred - * - * @see cass_cluster_set_no_speculative_execution_policy() - */ -CASS_EXPORT CassError -cass_execution_profile_set_no_speculative_execution_policy(CassExecProfile* profile); - -/*********************************************************************************** - * - * Cluster - * - ***********************************************************************************/ - -/** - * Creates a new cluster. - * - * @public @memberof CassCluster - * - * @return Returns a cluster that must be freed. - * - * @see cass_cluster_free() - */ -CASS_EXPORT CassCluster* -cass_cluster_new(); - -/** - * Frees a cluster instance. - * - * @public @memberof CassCluster - * - * @param[in] cluster - */ -CASS_EXPORT void -cass_cluster_free(CassCluster* cluster); - -/** - * Sets/Appends contact points. This *MUST* be set. The first call sets - * the contact points and any subsequent calls appends additional contact - * points. Passing an empty string will clear the contact points. White space - * is striped from the contact points. - * - * Examples: "127.0.0.1" "127.0.0.1,127.0.0.2", "server1.domain.com" - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] contact_points A comma delimited list of addresses or - * names. An empty string will clear the contact points. - * The string is copied into the cluster configuration; the memory pointed - * to by this parameter can be freed after this call. - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_cluster_set_contact_points(CassCluster* cluster, - const char* contact_points); - -/** - * Same as cass_cluster_set_contact_points(), but with lengths for string - * parameters. - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] contact_points - * @param[in] contact_points_length - * @return same as cass_cluster_set_contact_points() - * - * @see cass_cluster_set_contact_points() - */ -CASS_EXPORT CassError -cass_cluster_set_contact_points_n(CassCluster* cluster, - const char* contact_points, - size_t contact_points_length); - -/** - * Sets the port. - * - * Default: 9042 - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] port - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_cluster_set_port(CassCluster* cluster, - int port); - -/** - * Sets the local address to bind when connecting to the cluster, - * if desired. - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] name IP address to bind, or empty string for no binding. - * Only numeric addresses are supported; no resolution is done. - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_cluster_set_local_address(CassCluster* cluster, - const char* name); - -/** - * Same as cass_cluster_set_local_address(), but with lengths for string - * parameters. - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] name - * @param[in] name_length - * @return same as cass_cluster_set_local_address() - * - * @see cass_cluster_set_local_address() - */ -CASS_EXPORT CassError -cass_cluster_set_local_address_n(CassCluster* cluster, - const char* name, - size_t name_length); - -/** - * Sets the SSL context and enables SSL. - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] ssl - * - * @see cass_ssl_new() - */ -CASS_EXPORT void -cass_cluster_set_ssl(CassCluster* cluster, - CassSsl* ssl); - -/** - * Sets custom authenticator - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] exchange_callbacks - * @param[in] cleanup_callback - * @param[in] data - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_cluster_set_authenticator_callbacks(CassCluster* cluster, - const CassAuthenticatorCallbacks* exchange_callbacks, - CassAuthenticatorDataCleanupCallback cleanup_callback, - void* data); - -/** - * Sets the protocol version. The driver will automatically downgrade to the lowest - * supported protocol version. - * - * Default: CASS_PROTOCOL_VERSION_V4 or CASS_PROTOCOL_VERSION_DSEV1 when - * using the DSE driver with DataStax Enterprise. - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] protocol_version - * @return CASS_OK if successful, otherwise an error occurred. - * - * @see cass_cluster_set_use_beta_protocol_version() - */ -CASS_EXPORT CassError -cass_cluster_set_protocol_version(CassCluster* cluster, - int protocol_version); - -/** - * Use the newest beta protocol version. This currently enables the use of - * protocol version v5 (CASS_PROTOCOL_VERSION_V5) or DSEv2 (CASS_PROTOCOL_VERSION_DSEV2) - * when using the DSE driver with DataStax Enterprise. - * - * Default: cass_false - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] enable if false the highest non-beta protocol version will be used - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_cluster_set_use_beta_protocol_version(CassCluster* cluster, - cass_bool_t enable); - -/** - * Sets default consistency level of statement. - * - * Default: CASS_CONSISTENCY_LOCAL_ONE - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] consistency - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_cluster_set_consistency(CassCluster* cluster, - CassConsistency consistency); - -/** - * Sets default serial consistency level of statement. - * - * Default: CASS_CONSISTENCY_ANY - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] consistency - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_cluster_set_serial_consistency(CassCluster* cluster, - CassConsistency consistency); - -/** - * Sets the number of IO threads. This is the number of threads - * that will handle query requests. - * - * Default: 1 - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] num_threads - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_cluster_set_num_threads_io(CassCluster* cluster, - unsigned num_threads); - -/** - * Sets the size of the fixed size queue that stores - * pending requests. - * - * Default: 8192 - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] queue_size - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_cluster_set_queue_size_io(CassCluster* cluster, - unsigned queue_size); - -/** - * Sets the size of the fixed size queue that stores - * events. - * - * Default: 8192 - * - * @public @memberof CassCluster - * - * @deprecated This is no longer useful and does nothing. Expect this to be - * removed in a future release. - * - * @param[in] cluster - * @param[in] queue_size - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CASS_DEPRECATED(CassError -cass_cluster_set_queue_size_event(CassCluster* cluster, - unsigned queue_size)); - -/** - * Sets the number of connections made to each server in each - * IO thread. - * - * Default: 1 - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] num_connections - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_cluster_set_core_connections_per_host(CassCluster* cluster, - unsigned num_connections); - -/** - * Sets the maximum number of connections made to each server in each - * IO thread. - * - * Default: 2 - * - * @public @memberof CassCluster - * - * @deprecated This is no longer useful and does nothing. Expect this to be - * removed in a future release. - * - * @param[in] cluster - * @param[in] num_connections - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CASS_DEPRECATED(CassError -cass_cluster_set_max_connections_per_host(CassCluster* cluster, - unsigned num_connections)); - -/** - * Sets the amount of time to wait before attempting to reconnect. - * - * @public @memberof CassCluster - * - * @deprecated This is being replaced with cass_cluster_set_constant_reconnect(). - * Expect this to be removed in a future release. - * - * @param[in] cluster - * @param[in] wait_time - */ -CASS_EXPORT CASS_DEPRECATED(void -cass_cluster_set_reconnect_wait_time(CassCluster* cluster, - unsigned wait_time)); - -/** - * Configures the cluster to use a reconnection policy that waits a constant - * time between each reconnection attempt. - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] delay_ms Time in milliseconds to delay attempting a reconnection; - * 0 to perform a reconnection immediately. - */ -CASS_EXPORT void -cass_cluster_set_constant_reconnect(CassCluster* cluster, - cass_uint64_t delay_ms); - -/** - * Configures the cluster to use a reconnection policy that waits exponentially - * longer between each reconnection attempt; however will maintain a constant - * delay once the maximum delay is reached. - * - * Default: - *
    - *
  • 2000 milliseconds base delay
  • - *
  • 60000 milliseconds max delay
  • - *
- * - *

- * Note: A random amount of jitter (+/- 15%) will be added to the pure - * exponential delay value. This helps to prevent situations where multiple - * connections are in the reconnection process at exactly the same time. The - * jitter will never cause the delay to be less than the base delay, or more - * than the max delay. - *

- * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] base_delay_ms The base delay (in milliseconds) to use for - * scheduling reconnection attempts. - * @param[in] max_delay_ms The maximum delay to wait between two reconnection - * attempts. - * @return CASS_OK if successful, otherwise error occurred. - */ -CASS_EXPORT CassError -cass_cluster_set_exponential_reconnect(CassCluster* cluster, - cass_uint64_t base_delay_ms, - cass_uint64_t max_delay_ms); - -/** - * Sets the amount of time, in microseconds, to wait for new requests to - * coalesce into a single system call. This should be set to a value around - * the latency SLA of your application's requests while also considering the - * request's roundtrip time. Larger values should be used for throughput - * bound workloads and lower values should be used for latency bound - * workloads. - * - * Default: 200 us - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] delay_us - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_cluster_set_coalesce_delay(CassCluster* cluster, - cass_int64_t delay_us); - -/** - * Sets the ratio of time spent processing new requests versus handling the I/O - * and processing of outstanding requests. The range of this setting is 1 to 100, - * where larger values allocate more time to processing new requests and smaller - * values allocate more time to processing outstanding requests. - * - * Default: 50 - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] ratio - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_cluster_set_new_request_ratio(CassCluster* cluster, - cass_int32_t ratio); - -/** - * Sets the maximum number of connections that will be created concurrently. - * Connections are created when the current connections are unable to keep up with - * request throughput. - * - * Default: 1 - * - * @public @memberof CassCluster - * - * @deprecated This is no longer useful and does nothing. Expect this to be - * removed in a future release. - * - * @param[in] cluster - * @param[in] num_connections - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CASS_DEPRECATED(CassError -cass_cluster_set_max_concurrent_creation(CassCluster* cluster, - unsigned num_connections)); - -/** - * Sets the threshold for the maximum number of concurrent requests in-flight - * on a connection before creating a new connection. The number of new connections - * created will not exceed max_connections_per_host. - * - * Default: 100 - * - * @public @memberof CassCluster - * - * @deprecated This is no longer useful and does nothing. Expect this to be - * removed in a future release. - * - * @param[in] cluster - * @param[in] num_requests - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CASS_DEPRECATED(CassError -cass_cluster_set_max_concurrent_requests_threshold(CassCluster* cluster, - unsigned num_requests)); - -/** - * Sets the maximum number of requests processed by an IO worker - * per flush. - * - * Default: 128 - * - * @public @memberof CassCluster - * - * @deprecated This is no longer useful and does nothing. Expect this to be - * removed in a future release. - * - * @param[in] cluster - * @param[in] num_requests - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CASS_DEPRECATED(CassError -cass_cluster_set_max_requests_per_flush(CassCluster* cluster, - unsigned num_requests)); - -/** - * Sets the high water mark for the number of bytes outstanding - * on a connection. Disables writes to a connection if the number - * of bytes queued exceed this value. - * - * Default: 64 KB - * - * @public @memberof CassCluster - * - * @deprecated This is no longer useful and does nothing. Expect this to be - * removed in a future release. - * - * @param[in] cluster - * @param[in] num_bytes - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CASS_DEPRECATED(CassError -cass_cluster_set_write_bytes_high_water_mark(CassCluster* cluster, - unsigned num_bytes)); - -/** - * Sets the low water mark for number of bytes outstanding on a - * connection. After exceeding high water mark bytes, writes will - * only resume once the number of bytes fall below this value. - * - * Default: 32 KB - * - * @public @memberof CassCluster - * - * @deprecated This is no longer useful and does nothing. Expect this to be - * removed in a future release. - * - * @param[in] cluster - * @param[in] num_bytes - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CASS_DEPRECATED(CassError -cass_cluster_set_write_bytes_low_water_mark(CassCluster* cluster, - unsigned num_bytes)); - -/** - * Sets the high water mark for the number of requests queued waiting - * for a connection in a connection pool. Disables writes to a - * host on an IO worker if the number of requests queued exceed this - * value. - * - * Default: 256 - * - * @public @memberof CassCluster - * - * @deprecated This is no longer useful and does nothing. Expect this to be - * removed in a future release. - * - * @param[in] cluster - * @param[in] num_requests - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CASS_DEPRECATED(CassError -cass_cluster_set_pending_requests_high_water_mark(CassCluster* cluster, - unsigned num_requests)); - -/** - * Sets the low water mark for the number of requests queued waiting - * for a connection in a connection pool. After exceeding high water mark - * requests, writes to a host will only resume once the number of requests - * fall below this value. - * - * Default: 128 - * - * @public @memberof CassCluster - * - * @deprecated This is no longer useful and does nothing. Expect this to be - * removed in a future release. - * - * @param[in] cluster - * @param[in] num_requests - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CASS_DEPRECATED(CassError -cass_cluster_set_pending_requests_low_water_mark(CassCluster* cluster, - unsigned num_requests)); - -/** - * Sets the timeout for connecting to a node. - * - * Default: 5000 milliseconds - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] timeout_ms Connect timeout in milliseconds - */ -CASS_EXPORT void -cass_cluster_set_connect_timeout(CassCluster* cluster, - unsigned timeout_ms); - -/** - * Sets the timeout for waiting for a response from a node. - * - * Default: 12000 milliseconds - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] timeout_ms Request timeout in milliseconds. Use 0 for no timeout. - */ -CASS_EXPORT void -cass_cluster_set_request_timeout(CassCluster* cluster, - unsigned timeout_ms); - -/** - * Sets the timeout for waiting for DNS name resolution. - * - * Default: 2000 milliseconds - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] timeout_ms Request timeout in milliseconds - */ -CASS_EXPORT void -cass_cluster_set_resolve_timeout(CassCluster* cluster, - unsigned timeout_ms); - -/** - * Sets the maximum time to wait for schema agreement after a schema change - * is made (e.g. creating, altering, dropping a table/keyspace/view/index etc). - * - * Default: 10000 milliseconds - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] wait_time_ms Wait time in milliseconds - */ -CASS_EXPORT void -cass_cluster_set_max_schema_wait_time(CassCluster* cluster, - unsigned wait_time_ms); - - -/** - * Sets the maximum time to wait for tracing data to become available. - * - * Default: 15 milliseconds - * - * @param[in] cluster - * @param[in] max_wait_time_ms - */ -CASS_EXPORT void -cass_cluster_set_tracing_max_wait_time(CassCluster* cluster, - unsigned max_wait_time_ms); - -/** - * Sets the amount of time to wait between attempts to check to see if tracing is - * available. - * - * Default: 3 milliseconds - * - * @param[in] cluster - * @param[in] retry_wait_time_ms - */ -CASS_EXPORT void -cass_cluster_set_tracing_retry_wait_time(CassCluster* cluster, - unsigned retry_wait_time_ms); - -/** - * Sets the consistency level to use for checking to see if tracing data is - * available. - * - * Default: CASS_CONSISTENCY_ONE - * - * @param[in] cluster - * @param[in] consistency - */ -CASS_EXPORT void -cass_cluster_set_tracing_consistency(CassCluster* cluster, - CassConsistency consistency); - - -/** - * Sets credentials for plain text authentication. - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] username - * @param[in] password - */ -CASS_EXPORT void -cass_cluster_set_credentials(CassCluster* cluster, - const char* username, - const char* password); - -/** - * Same as cass_cluster_set_credentials(), but with lengths for string - * parameters. - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] username - * @param[in] username_length - * @param[in] password - * @param[in] password_length - * @return same as cass_cluster_set_credentials() - * - * @see cass_cluster_set_credentials(); - */ -CASS_EXPORT void -cass_cluster_set_credentials_n(CassCluster* cluster, - const char* username, - size_t username_length, - const char* password, - size_t password_length); - -/** - * Configures the cluster to use round-robin load balancing. - * - * The driver discovers all nodes in a cluster and cycles through - * them per request. All are considered 'local'. - * - * @public @memberof CassCluster - * - * @param[in] cluster - */ -CASS_EXPORT void -cass_cluster_set_load_balance_round_robin(CassCluster* cluster); - -/** - * Configures the cluster to use DC-aware load balancing. - * For each query, all live nodes in a primary 'local' DC are tried first, - * followed by any node from other DCs. - * - * Note: This is the default, and does not need to be called unless - * switching an existing from another policy or changing settings. - * Without further configuration, a default local_dc is chosen from the - * first connected contact point, and no remote hosts are considered in - * query plans. If relying on this mechanism, be sure to use only contact - * points from the local DC. - * - * @deprecated The remote DC settings for DC-aware are not suitable for most - * scenarios that require DC failover. There is also unhandled gap between - * replication factor number of nodes failing and the full cluster failing. Only - * the remote DC settings are being deprecated. - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] local_dc The primary data center to try first - * @param[in] used_hosts_per_remote_dc The number of hosts used in each remote - * DC if no hosts are available in the local dc (deprecated) - * @param[in] allow_remote_dcs_for_local_cl Allows remote hosts to be used if no - * local dc hosts are available and the consistency level is LOCAL_ONE or - * LOCAL_QUORUM (deprecated) - * @return CASS_OK if successful, otherwise an error occurred - */ -CASS_EXPORT CassError -cass_cluster_set_load_balance_dc_aware(CassCluster* cluster, - const char* local_dc, - unsigned used_hosts_per_remote_dc, - cass_bool_t allow_remote_dcs_for_local_cl); - - -/** - * Same as cass_cluster_set_load_balance_dc_aware(), but with lengths for string - * parameters. - * - * @deprecated The remote DC settings for DC-aware are not suitable for most - * scenarios that require DC failover. There is also unhandled gap between - * replication factor number of nodes failing and the full cluster failing. Only - * the remote DC settings are being deprecated. - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] local_dc - * @param[in] local_dc_length - * @param[in] used_hosts_per_remote_dc (deprecated) - * @param[in] allow_remote_dcs_for_local_cl (deprecated) - * @return same as cass_cluster_set_load_balance_dc_aware() - * - * @see cass_cluster_set_load_balance_dc_aware() - */ -CASS_EXPORT CassError -cass_cluster_set_load_balance_dc_aware_n(CassCluster* cluster, - const char* local_dc, - size_t local_dc_length, - unsigned used_hosts_per_remote_dc, - cass_bool_t allow_remote_dcs_for_local_cl); - -/** - * Configures the cluster to use token-aware request routing or not. - * - * Important: Token-aware routing depends on keyspace metadata. - * For this reason enabling token-aware routing will also enable retrieving - * and updating keyspace schema metadata. - * - * Default: cass_true (enabled). - * - * This routing policy composes the base routing policy, routing - * requests first to replicas on nodes considered 'local' by - * the base load balancing policy. - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] enabled - */ -CASS_EXPORT void -cass_cluster_set_token_aware_routing(CassCluster* cluster, - cass_bool_t enabled); - - -/** - * Configures token-aware routing to randomly shuffle replicas. This can reduce - * the effectiveness of server-side caching, but it can better distribute load over - * replicas for a given partition key. - * - * Note: Token-aware routing must be enabled for the setting to - * be applicable. - * - * Default: cass_true (enabled). - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] enabled - */ -CASS_EXPORT void -cass_cluster_set_token_aware_routing_shuffle_replicas(CassCluster* cluster, - cass_bool_t enabled); - -/** - * Configures the cluster to use latency-aware request routing or not. - * - * Default: cass_false (disabled). - * - * This routing policy is a top-level routing policy. It uses the - * base routing policy to determine locality (dc-aware) and/or - * placement (token-aware) before considering the latency. - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] enabled - */ -CASS_EXPORT void -cass_cluster_set_latency_aware_routing(CassCluster* cluster, - cass_bool_t enabled); - -/** - * Configures the settings for latency-aware request routing. - * - * Defaults: - * - *
    - *
  • exclusion_threshold: 2.0
  • - *
  • scale_ms: 100 milliseconds
  • - *
  • retry_period_ms: 10,000 milliseconds (10 seconds)
  • - *
  • update_rate_ms: 100 milliseconds
  • - *
  • min_measured: 50
  • - *
- * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] exclusion_threshold Controls how much worse the latency must be compared to the - * average latency of the best performing node before it penalized. - * @param[in] scale_ms Controls the weight given to older latencies when calculating the average - * latency of a node. A bigger scale will give more weight to older latency measurements. - * @param[in] retry_period_ms The amount of time a node is penalized by the policy before - * being given a second chance when the current average latency exceeds the calculated - * threshold (exclusion_threshold * best_average_latency). - * @param[in] update_rate_ms The rate at which the best average latency is recomputed. - * @param[in] min_measured The minimum number of measurements per-host required to - * be considered by the policy. - */ -CASS_EXPORT void -cass_cluster_set_latency_aware_routing_settings(CassCluster* cluster, - cass_double_t exclusion_threshold, - cass_uint64_t scale_ms, - cass_uint64_t retry_period_ms, - cass_uint64_t update_rate_ms, - cass_uint64_t min_measured); - -/** - * Sets/Appends whitelist hosts. The first call sets the whitelist hosts and - * any subsequent calls appends additional hosts. Passing an empty string will - * clear and disable the whitelist. White space is striped from the hosts. - * - * This policy filters requests to all other policies, only allowing requests - * to the hosts contained in the whitelist. Any host not in the whitelist will - * be ignored and a connection will not be established. This policy is useful - * for ensuring that the driver will only connect to a predefined set of hosts. - * - * Examples: "127.0.0.1" "127.0.0.1,127.0.0.2" - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] hosts A comma delimited list of addresses. An empty string will - * clear the whitelist hosts. The string is copied into the cluster - * configuration; the memory pointed to by this parameter can be freed after - * this call. - */ -CASS_EXPORT void -cass_cluster_set_whitelist_filtering(CassCluster* cluster, - const char* hosts); - -/** - * Same as cass_cluster_set_whitelist_filtering(), but with lengths for - * string parameters. - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] hosts - * @param[in] hosts_length - * @return same as cass_cluster_set_whitelist_filtering() - * - * @see cass_cluster_set_whitelist_filtering() - */ -CASS_EXPORT void -cass_cluster_set_whitelist_filtering_n(CassCluster* cluster, - const char* hosts, - size_t hosts_length); - -/** - * Sets/Appends blacklist hosts. The first call sets the blacklist hosts and - * any subsequent calls appends additional hosts. Passing an empty string will - * clear and disable the blacklist. White space is striped from the hosts. - * - * This policy filters requests to all other policies, only allowing requests - * to the hosts not contained in the blacklist. Any host in the blacklist will - * be ignored and a connection will not be established. This policy is useful - * for ensuring that the driver will not connect to a predefined set of hosts. - * - * Examples: "127.0.0.1" "127.0.0.1,127.0.0.2" - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] hosts A comma delimited list of addresses. An empty string will - * clear the blacklist hosts. The string is copied into the cluster - * configuration; the memory pointed to by this parameter can be freed after - * this call. - */ -CASS_EXPORT void -cass_cluster_set_blacklist_filtering(CassCluster* cluster, - const char* hosts); - -/** - * Same as cass_cluster_set_blacklist_filtering_hosts(), but with lengths for - * string parameters. - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] hosts - * @param[in] hosts_length - * @return same as cass_cluster_set_blacklist_filtering() - * - * @see cass_cluster_set_blacklist_filtering() - */ -CASS_EXPORT void -cass_cluster_set_blacklist_filtering_n(CassCluster* cluster, - const char* hosts, - size_t hosts_length); - -/** - * Same as cass_cluster_set_whitelist_filtering(), but whitelist all hosts of a dc - * - * Examples: "dc1", "dc1,dc2" - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] dcs A comma delimited list of dcs. An empty string will clear the - * whitelist dcs. The string is copied into the cluster configuration; the - * memory pointed to by this parameter can be freed after this call. - */ -CASS_EXPORT void -cass_cluster_set_whitelist_dc_filtering(CassCluster* cluster, - const char* dcs); - -/** - * Same as cass_cluster_set_whitelist_dc_filtering(), but with lengths for - * string parameters. - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] dcs - * @param[in] dcs_length - * @return same as cass_cluster_set_whitelist_dc_filtering() - * - * @see cass_cluster_set_whitelist_dc_filtering() - */ -CASS_EXPORT void -cass_cluster_set_whitelist_dc_filtering_n(CassCluster* cluster, - const char* dcs, - size_t dcs_length); - -/** - * Same as cass_cluster_set_blacklist_filtering(), but blacklist all hosts of a dc - * - * Examples: "dc1", "dc1,dc2" - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] dcs A comma delimited list of dcs. An empty string will clear the - * blacklist dcs. The string is copied into the cluster configuration; the - * memory pointed to by this parameter can be freed after this call. - */ -CASS_EXPORT void -cass_cluster_set_blacklist_dc_filtering(CassCluster* cluster, - const char* dcs); - -/** - * Same as cass_cluster_set_blacklist_dc_filtering(), but with lengths for - * string parameters. - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] dcs - * @param[in] dcs_length - * @return same as cass_cluster_set_blacklist_dc_filtering() - * - * @see cass_cluster_set_blacklist_dc_filtering() - */ -CASS_EXPORT void -cass_cluster_set_blacklist_dc_filtering_n(CassCluster* cluster, - const char* dcs, - size_t dcs_length); - -/** - * Enable/Disable Nagle's algorithm on connections. - * - * Default: cass_true (disables Nagle's algorithm). - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] enabled - */ -CASS_EXPORT void -cass_cluster_set_tcp_nodelay(CassCluster* cluster, - cass_bool_t enabled); - -/** - * Enable/Disable TCP keep-alive - * - * Default: cass_false (disabled). - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] enabled - * @param[in] delay_secs The initial delay in seconds, ignored when - * `enabled` is false. - */ -CASS_EXPORT void -cass_cluster_set_tcp_keepalive(CassCluster* cluster, - cass_bool_t enabled, - unsigned delay_secs); -/** - * Sets the timestamp generator used to assign timestamps to all requests - * unless overridden by setting the timestamp on a statement or a batch. - * - * Default: Monotonically increasing, client-side timestamp generator. - * - * @cassandra{2.1+} - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] timestamp_gen - * - * @see cass_statement_set_timestamp() - * @see cass_batch_set_timestamp() - */ -CASS_EXPORT void -cass_cluster_set_timestamp_gen(CassCluster* cluster, - CassTimestampGen* timestamp_gen); - -/** - * Sets the amount of time between heartbeat messages and controls the amount - * of time the connection must be idle before sending heartbeat messages. This - * is useful for preventing intermediate network devices from dropping - * connections. - * - * Default: 30 seconds - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] interval_secs Use 0 to disable heartbeat messages - */ -CASS_EXPORT void -cass_cluster_set_connection_heartbeat_interval(CassCluster* cluster, - unsigned interval_secs); - -/** - * Sets the amount of time a connection is allowed to be without a successful - * heartbeat response before being terminated and scheduled for reconnection. - * - * Default: 60 seconds - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] timeout_secs - */ -CASS_EXPORT void -cass_cluster_set_connection_idle_timeout(CassCluster* cluster, - unsigned timeout_secs); - -/** - * Sets the retry policy used for all requests unless overridden by setting - * a retry policy on a statement or a batch. - * - * Default: The same policy as would be created by the function: - * cass_retry_policy_default_new(). This policy will retry on a read timeout - * if there was enough replicas, but no data present, on a write timeout if a - * logged batch request failed to write the batch log, and on a unavailable - * error it retries using a new host. In all other cases the default policy - * will return an error. - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] retry_policy - * - * @see cass_retry_policy_default_new() - * @see cass_statement_set_retry_policy() - * @see cass_batch_set_retry_policy() - */ -CASS_EXPORT void -cass_cluster_set_retry_policy(CassCluster* cluster, - CassRetryPolicy* retry_policy); - -/** - * Enable/Disable retrieving and updating schema metadata. If disabled - * this is allows the driver to skip over retrieving and updating schema - * metadata and cass_session_get_schema_meta() will always return an empty object. - * This can be useful for reducing the startup overhead of short-lived sessions. - * - * Default: cass_true (enabled). - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] enabled - * - * @see cass_session_get_schema_meta() - */ -CASS_EXPORT void -cass_cluster_set_use_schema(CassCluster* cluster, - cass_bool_t enabled); - -/** - * Enable/Disable retrieving hostnames for IP addresses using reverse IP lookup. - * - * @deprecated Do not use. Using reverse DNS lookup to verify the certificate - * does not protect against man-in-the-middle attacks. - * - * Default: cass_false (disabled). - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] enabled - * @return CASS_OK if successful, otherwise an error occurred - * - * @see cass_cluster_set_resolve_timeout() - */ -CASS_EXPORT CASS_DEPRECATED(CassError -cass_cluster_set_use_hostname_resolution(CassCluster* cluster, - cass_bool_t enabled)); - -/** - * Enable/Disable the randomization of the contact points list. - * - * Default: cass_true (enabled). - * - * Important: This setting should only be disabled for debugging or - * tests. - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] enabled - * @return CASS_OK if successful, otherwise an error occurred - */ -CASS_EXPORT CassError -cass_cluster_set_use_randomized_contact_points(CassCluster* cluster, - cass_bool_t enabled); - -/** - * Enable constant speculative executions with the supplied settings. - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] constant_delay_ms - * @param[in] max_speculative_executions - * @return CASS_OK if successful, otherwise an error occurred - */ -CASS_EXPORT CassError -cass_cluster_set_constant_speculative_execution_policy(CassCluster* cluster, - cass_int64_t constant_delay_ms, - int max_speculative_executions); - -/** - * Disable speculative executions - * - * Default: This is the default speculative execution policy. - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @return CASS_OK if successful, otherwise an error occurred - */ -CASS_EXPORT CassError -cass_cluster_set_no_speculative_execution_policy(CassCluster* cluster); - -/** - * Sets the maximum number of "pending write" objects that will be - * saved for re-use for marshalling new requests. These objects may - * hold on to a significant amount of memory and reducing the - * number of these objects may reduce memory usage of the application. - * - * The cost of reducing the value of this setting is potentially slower - * marshalling of requests prior to sending. - * - * Default: Max unsigned integer value - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] num_objects - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_cluster_set_max_reusable_write_objects(CassCluster* cluster, - unsigned num_objects); - -/** - * Associates a named execution profile which can be utilized during execution. - * - * Note: Once the execution profile is added to a cluster, it is - * immutable and any changes made to the execution profile must be re-assigned - * to the cluster before a session connection is established in order for those - * settings to be utilized during query execution. - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] name - * @param[in] profile - * @return CASS_OK if successful, otherwise an error occurred - * - * @see cass_batch_set_execution_profile() - * @see cass_statement_set_execution_profile() - */ -CASS_EXPORT CassError -cass_cluster_set_execution_profile(CassCluster* cluster, - const char* name, - CassExecProfile* profile); - -/** - * Same as cass_cluster_add_execution_profile(), but with lengths for string - * parameters. - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] name - * @param[in] name_length - * @param[in] profile - * @return same as cass_cluster_set_execution_profile() - * - * @see cass_batch_set_execution_profile() - * @see cass_statement_set_execution_profile() - */ -CASS_EXPORT CassError -cass_cluster_set_execution_profile_n(CassCluster* cluster, - const char* name, - size_t name_length, - CassExecProfile* profile); - -/** - * Prepare statements on all available hosts. - * - * Default: cass_true - * - * @public @memberof CassCluster - * - * @param cluster - * @param enabled - * @return CASS_OK if successful, otherwise an error occurred - */ -CASS_EXPORT CassError -cass_cluster_set_prepare_on_all_hosts(CassCluster* cluster, - cass_bool_t enabled); - -/** - * Enable pre-preparing cached prepared statements when existing hosts become - * available again or when new hosts are added to the cluster. - * - * This can help mitigate request latency when executing prepared statements - * by avoiding an extra round trip in cases where the statement is - * unprepared on a freshly started server. The main tradeoff is extra background - * network traffic is required to prepare the statements on hosts as they become - * available. - * - * Default: cass_true - * - * @param cluster - * @param enabled - * @return CASS_OK if successful, otherwise an error occurred - */ -CASS_EXPORT CassError -cass_cluster_set_prepare_on_up_or_add_host(CassCluster* cluster, - cass_bool_t enabled); - -/** - * Enable the NO_COMPACT startup option. - * - * This can help facilitate uninterrupted cluster upgrades where tables using - * COMPACT_STORAGE will operate in "compatibility mode" for - * BATCH, DELETE, SELECT, and UPDATE CQL operations. - * - * Default: cass_false - * - * @cassandra{3.0.16+} - * @cassandra{3.11.2+} - * @cassandra{4.0+} - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] enabled - */ -CASS_EXPORT CassError -cass_cluster_set_no_compact(CassCluster* cluster, - cass_bool_t enabled); - -/** - * Sets a callback for handling host state changes in the cluster. - * - * Note: The callback is invoked only when state changes in the cluster - * are applicable to the configured load balancing policy(s). - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] callback - * @param[in] data - * @return CASS_OK if successful, otherwise and error occurred - */ -CASS_EXPORT CassError -cass_cluster_set_host_listener_callback(CassCluster* cluster, - CassHostListenerCallback callback, - void* data); - -/** - * Sets the secure connection bundle path for processing DBaaS credentials. - * - * This will pre-configure a cluster using the credentials format provided by - * the DBaaS cloud provider. - * - * @param[in] cluster - * @param[in] path Absolute path to DBaaS credentials file. - * @return CASS_OK if successful, otherwise error occured. - */ -CASS_EXPORT CassError -cass_cluster_set_cloud_secure_connection_bundle(CassCluster* cluster, - const char* path); - -/** - * Same as cass_cluster_set_cloud_secure_connection_bundle(), but with lengths - * for string parameters. - * - * @see cass_cluster_set_cloud_secure_connection_bundle() - * - * @param[in] cluster - * @param[in] path Absolute path to DBaaS credentials file. - * @param[in] path_length Length of path variable. - * @return CASS_OK if successful, otherwise error occured. - */ -CASS_EXPORT CassError -cass_cluster_set_cloud_secure_connection_bundle_n(CassCluster* cluster, - const char* path, - size_t path_length); - -/** - * Same as cass_cluster_set_cloud_secure_connection_bundle(), but it does not - * initialize the underlying SSL library implementation. The SSL library still - * needs to be initialized, but it's up to the client application to handle - * initialization. This is similar to the function cass_ssl_new_no_lib_init(), - * and its documentation should be used as a reference to properly initialize - * the underlying SSL library. - * - * @see cass_ssl_new_no_lib_init() - * @see cass_cluster_set_cloud_secure_connection_bundle() - * - * @param[in] cluster - * @param[in] path Absolute path to DBaaS credentials file. - * @return CASS_OK if successful, otherwise error occured. - */ -CASS_EXPORT CassError -cass_cluster_set_cloud_secure_connection_bundle_no_ssl_lib_init(CassCluster* cluster, - const char* path); - -/** - * Same as cass_cluster_set_cloud_secure_connection_bundle_no_ssl_lib_init(), - * but with lengths for string parameters. - * - * @see cass_cluster_set_cloud_secure_connection_bundle_no_ssl_lib_init() - * - * @param[in] cluster - * @param[in] path Absolute path to DBaaS credentials file. - * @param[in] path_length Length of path variable. - * @return CASS_OK if successful, otherwise error occured. - */ -CASS_EXPORT CassError -cass_cluster_set_cloud_secure_connection_bundle_no_ssl_lib_init_n(CassCluster* cluster, - const char* path, - size_t path_length); - -/** - * Set the application name. - * - * This is optional; however it provides the server with the application name - * that can aid in debugging issues with larger clusters where there are a lot - * of client (or application) connections. - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] application_name - */ -CASS_EXPORT void -cass_cluster_set_application_name(CassCluster* cluster, - const char* application_name); - -/** - * Same as cass_cluster_set_application_name(), but with lengths for string - * parameters. - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] application_name - * @param[in] application_name_length - */ -CASS_EXPORT void -cass_cluster_set_application_name_n(CassCluster* cluster, - const char* application_name, - size_t application_name_length); - -/** - * Set the application version. - * - * This is optional; however it provides the server with the application - * version that can aid in debugging issues with large clusters where there are - * a lot of client (or application) connections that may have different - * versions in use. - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] application_version - */ - -CASS_EXPORT void -cass_cluster_set_application_version(CassCluster* cluster, - const char* application_version); - -/** - * Same as cass_cluster_set_application_version(), but with lengths for string - * parameters. - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] application_version - * @param[in] application_version_length - */ -CASS_EXPORT void -cass_cluster_set_application_version_n(CassCluster* cluster, - const char* application_version, - size_t application_version_length); - -/** - * Set the client id. - * - * This is optional; however it provides the server with the client ID that can - * aid in debugging issues with large clusters where there are a lot of client - * connections. - * - * Default: UUID v4 generated (@see cass_session_get_client_id()) - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] client_id - */ -CASS_EXPORT void -cass_cluster_set_client_id(CassCluster* cluster, CassUuid client_id); - -/** - * Sets the amount of time between monitor reporting event messages. - * - * Default: 300 seconds. - * - * @public @memberof CassCluster - * - * @param[in] cluster - * @param[in] interval_secs Use 0 to disable monitor reporting event messages. - */ -CASS_EXPORT void -cass_cluster_set_monitor_reporting_interval(CassCluster* cluster, - unsigned interval_secs); - -/** - * Sets the amount of time after which metric histograms should be refreshed. - * Upon refresh histograms are reset to zero, effectively dropping any history to - * that point. Refresh occurs when a snapshot is requested so ths value should - * be thought of as a minimum time to refresh. - * - * If refresh is not enabled the driver will continue to accumulate histogram - * data over the life of a session; this is the default behaviour and replicates - * the behaviour of previous versions. - * - * Note that the specified interval must be > 0 otherwise CASS_ERROR_LIB_BAD_PARAMS - * will be returned. - * - * @public @memberof CassCluster - * - * @param cluster - * @param refresh_interval Minimum interval (in milliseconds) for refresh interval - */ -CASS_EXPORT CassError -cass_cluster_set_histogram_refresh_interval(CassCluster* cluster, - unsigned refresh_interval); - -/*********************************************************************************** - * - * Session - * - ***********************************************************************************/ - -/** - * Creates a new session. - * - * @public @memberof CassSession - * - * @return Returns a session that must be freed. - * - * @see cass_session_free() - */ -CASS_EXPORT CassSession* -cass_session_new(); - -/** - * Frees a session instance. If the session is still connected it will be synchronously - * closed before being deallocated. - * - * Important: Do not free a session in a future callback. Freeing a session in a future - * callback will cause a deadlock. - * - * @public @memberof CassSession - * - * @param[in] session - */ -CASS_EXPORT void -cass_session_free(CassSession* session); - -/** - * Connects a session. - * - * @public @memberof CassSession - * - * @param[in] session - * @param[in] cluster The cluster configuration is copied into the session and - * is immutable after connection. - * @return A future that must be freed. - * - * @see cass_session_close() - */ -CASS_EXPORT CassFuture* -cass_session_connect(CassSession* session, - const CassCluster* cluster); - -/** - * Connects a session and sets the keyspace. - * - * @public @memberof CassSession - * - * @param[in] session - * @param[in] cluster The cluster configuration is copied into the session and - * is immutable after connection. - * @param[in] keyspace - * @return A future that must be freed. - * - * @see cass_session_close() - */ -CASS_EXPORT CassFuture* -cass_session_connect_keyspace(CassSession* session, - const CassCluster* cluster, - const char* keyspace); - -/** - * Same as cass_session_connect_keyspace(), but with lengths for string - * parameters. - * - * @public @memberof CassSession - * - * @param[in] session - * @param[in] cluster - * @param[in] keyspace - * @param[in] keyspace_length - * @return same as cass_session_connect_keyspace() - * - * @see cass_session_connect_keyspace() - */ -CASS_EXPORT CassFuture* -cass_session_connect_keyspace_n(CassSession* session, - const CassCluster* cluster, - const char* keyspace, - size_t keyspace_length); - -/** - * Closes the session instance, outputs a close future which can - * be used to determine when the session has been terminated. This allows - * in-flight requests to finish. - * - * @public @memberof CassSession - * - * @param[in] session - * @return A future that must be freed. - */ -CASS_EXPORT CassFuture* -cass_session_close(CassSession* session); - -/** - * Create a prepared statement. - * - * @public @memberof CassSession - * - * @param[in] session - * @param[in] query The query is copied into the statement object; the - * memory pointed to by this parameter can be freed after this call. - * @return A future that must be freed. - * - * @see cass_future_get_prepared() - */ -CASS_EXPORT CassFuture* -cass_session_prepare(CassSession* session, - const char* query); - -/** - * Same as cass_session_prepare(), but with lengths for string - * parameters. - * - * @public @memberof CassSession - * - * @param[in] session - * @param[in] query - * @param[in] query_length - * @return same as cass_session_prepare() - * - * @see cass_session_prepare() - */ -CASS_EXPORT CassFuture* -cass_session_prepare_n(CassSession* session, - const char* query, - size_t query_length); - -/** - * Create a prepared statement from an existing statement. - * - * Note: Bound statements will inherit the keyspace, consistency, - * serial consistency, request timeout and retry policy of the existing - * statement. - * - * @public @memberof CassSession - * - * @param[in] session - * @param[in] statement - * @return A future that must be freed. - * - * @see cass_future_get_prepared() - */ -CASS_EXPORT CassFuture* -cass_session_prepare_from_existing(CassSession* session, - CassStatement* statement); - -/** - * Execute a query or bound statement. - * - * @public @memberof CassSession - * - * @param[in] session - * @param[in] statement - * @return A future that must be freed. - * - * @see cass_future_get_result() - */ -CASS_EXPORT CassFuture* -cass_session_execute(CassSession* session, - const CassStatement* statement); - -/** - * Execute a batch statement. - * - * @cassandra{2.0+} - * - * @public @memberof CassSession - * - * @param[in] session - * @param[in] batch - * @return A future that must be freed. - * - * @see cass_future_get_result() - */ -CASS_EXPORT CassFuture* -cass_session_execute_batch(CassSession* session, - const CassBatch* batch); - -/** - * Gets a snapshot of this session's schema metadata. The returned - * snapshot of the schema metadata is not updated. This function - * must be called again to retrieve any schema changes since the - * previous call. - * - * @public @memberof CassSession - * - * @param[in] session - * @return A schema instance that must be freed. - * - * @see cass_schema_meta_free() - */ -CASS_EXPORT const CassSchemaMeta* -cass_session_get_schema_meta(const CassSession* session); - -/** - * Gets a copy of this session's performance/diagnostic metrics. - * - * @public @memberof CassSession - * - * @param[in] session - * @param[out] output - */ -CASS_EXPORT void -cass_session_get_metrics(const CassSession* session, - CassMetrics* output); - -/** - * Gets a copy of this session's speculative execution metrics. - * - * @public @memberof CassSession - * - * @param[in] session - * @param[out] output - */ -CASS_EXPORT void -cass_session_get_speculative_execution_metrics(const CassSession* session, - CassSpeculativeExecutionMetrics* output); - -/** - * Get the client id. - * - * @public @memberof CassSession - * - * @param[in] session - * @return Client id. - */ -CASS_EXPORT CassUuid -cass_session_get_client_id(CassSession* session); - -/*********************************************************************************** - * - * Schema Metadata - * - ***********************************************************************************/ - -/** - * Frees a schema metadata instance. - * - * @public @memberof CassSchemaMeta - * - * @param[in] schema_meta - */ -CASS_EXPORT void -cass_schema_meta_free(const CassSchemaMeta* schema_meta); - -/** - * Gets the version of the schema metadata snapshot. - * - * @public @memberof CassSchemaMeta - * - * @param[in] schema_meta - * - * @return The snapshot version. - */ -CASS_EXPORT cass_uint32_t -cass_schema_meta_snapshot_version(const CassSchemaMeta* schema_meta); - -/** - * Gets the version of the connected Cassandra cluster. - * - * @public @memberof CassSchemaMeta - * - * @param[in] schema_meta - * - * @return Cassandra's version - */ -CASS_EXPORT CassVersion -cass_schema_meta_version(const CassSchemaMeta* schema_meta); - -/** - * Gets the keyspace metadata for the provided keyspace name. - * - * @public @memberof CassSchemaMeta - * - * @param[in] schema_meta - * @param[in] keyspace - * - * @return The metadata for a keyspace. NULL if keyspace does not exist. - */ -CASS_EXPORT const CassKeyspaceMeta* -cass_schema_meta_keyspace_by_name(const CassSchemaMeta* schema_meta, - const char* keyspace); - -/** - * Same as cass_schema_meta_keyspace_by_name(), but with lengths for string - * parameters. - * - * @public @memberof CassSchemaMeta - * - * @param[in] schema_meta - * @param[in] keyspace - * @param[in] keyspace_length - * @return same as cass_schema_meta_keyspace_by_name() - * - * @see cass_schema_meta_keyspace_by_name() - */ -CASS_EXPORT const CassKeyspaceMeta* -cass_schema_meta_keyspace_by_name_n(const CassSchemaMeta* schema_meta, - const char* keyspace, - size_t keyspace_length); - -/** - * Gets the name of the keyspace. - * - * @public @memberof CassKeyspaceMeta - * - * @param[in] keyspace_meta - * @param[out] name - * @param[out] name_length - */ -CASS_EXPORT void -cass_keyspace_meta_name(const CassKeyspaceMeta* keyspace_meta, - const char** name, - size_t* name_length); - - -/** - * Determine if the keyspace is a virtual keyspace. - * - * @public @memberof CassKeyspaceMeta - * - * @param[in] keyspace_meta - * @return cass_true is the keyspace is virtual, otherwise cass_false - */ -CASS_EXPORT cass_bool_t -cass_keyspace_meta_is_virtual(const CassKeyspaceMeta* keyspace_meta); - -/** - * Gets the table metadata for the provided table name. - * - * @public @memberof CassKeyspaceMeta - * - * @param[in] keyspace_meta - * @param[in] table - * - * @return The metadata for a table. NULL if table does not exist. - */ -CASS_EXPORT const CassTableMeta* -cass_keyspace_meta_table_by_name(const CassKeyspaceMeta* keyspace_meta, - const char* table); - -/** - * Same as cass_keyspace_meta_table_by_name(), but with lengths for string - * parameters. - * - * @public @memberof CassKeyspaceMeta - * - * @param[in] keyspace_meta - * @param[in] table - * @param[in] table_length - * @return same as cass_keyspace_meta_table_by_name() - * - * @see cass_keyspace_meta_table_by_name() - */ -CASS_EXPORT const CassTableMeta* -cass_keyspace_meta_table_by_name_n(const CassKeyspaceMeta* keyspace_meta, - const char* table, - size_t table_length); - -/** - * Gets the materialized view metadata for the provided view name. - * - * @cassandra{3.0+} - * - * @public @memberof CassKeyspaceMeta - * - * @param[in] keyspace_meta - * @param[in] view - * - * @return The metadata for a view. NULL if view does not exist. - */ -CASS_EXPORT const CassMaterializedViewMeta* -cass_keyspace_meta_materialized_view_by_name(const CassKeyspaceMeta* keyspace_meta, - const char* view); - -/** - * Same as cass_keyspace_meta_materialized_view_by_name(), but with lengths for string - * parameters. - * - * @cassandra{3.0+} - * - * @public @memberof CassKeyspaceMeta - * - * @param[in] keyspace_meta - * @param[in] view - * @param[in] view_length - * @return same as cass_keyspace_meta_materialized_view_by_name() - * - * @see cass_keyspace_meta_materialized_view_by_name() - */ -CASS_EXPORT const CassMaterializedViewMeta* -cass_keyspace_meta_materialized_view_by_name_n(const CassKeyspaceMeta* keyspace_meta, - const char* view, - size_t view_length); - -/** - * Gets the data type for the provided type name. - * - * @cassandra{2.1+} - * - * @public @memberof CassKeyspaceMeta - * - * @param[in] keyspace_meta - * @param[in] type - * - * @return The data type for a user defined type. NULL if type does not exist. - */ -CASS_EXPORT const CassDataType* -cass_keyspace_meta_user_type_by_name(const CassKeyspaceMeta* keyspace_meta, - const char* type); - -/** - * Same as cass_keyspace_meta_type_by_name(), but with lengths for string - * parameters. - * - * @cassandra{2.1+} - * - * @public @memberof CassKeyspaceMeta - * - * @param[in] keyspace_meta - * @param[in] type - * @param[in] type_length - * @return same as cass_keyspace_meta_type_by_name() - * - * @see cass_keyspace_meta_type_by_name() - */ -CASS_EXPORT const CassDataType* -cass_keyspace_meta_user_type_by_name_n(const CassKeyspaceMeta* keyspace_meta, - const char* type, - size_t type_length); - -/** - * Gets the function metadata for the provided function name. - * - * @cassandra{2.2+} - * - * @public @memberof CassKeyspaceMeta - * - * @param[in] keyspace_meta - * @param[in] name - * @param[in] arguments A comma delimited list of CQL types (e.g "text,int,...") - * describing the function's signature. - * - * @return The data function for a user defined function. NULL if function does not exist. - */ -CASS_EXPORT const CassFunctionMeta* -cass_keyspace_meta_function_by_name(const CassKeyspaceMeta* keyspace_meta, - const char* name, - const char* arguments); - -/** - * Same as cass_keyspace_meta_function_by_name(), but with lengths for string - * parameters. - * - * @cassandra{2.2+} - * - * @public @memberof CassKeyspaceMeta - * - * @param[in] keyspace_meta - * @param[in] name - * @param[in] name_length - * @param[in] arguments - * @param[in] arguments_length - * @return same as cass_keyspace_meta_function_by_name() - * - * @see cass_keyspace_meta_function_by_name() - */ -CASS_EXPORT const CassFunctionMeta* -cass_keyspace_meta_function_by_name_n(const CassKeyspaceMeta* keyspace_meta, - const char* name, - size_t name_length, - const char* arguments, - size_t arguments_length); - -/** - * Gets the aggregate metadata for the provided aggregate name. - * - * @cassandra{2.2+} - * - * @public @memberof CassKeyspaceMeta - * - * @param[in] keyspace_meta - * @param[in] name - * @param[in] arguments A comma delimited list of CQL types (e.g "text,int,...") - * describing the aggregate's signature. - * - * @return The data aggregate for a user defined aggregate. NULL if aggregate does not exist. - */ -CASS_EXPORT const CassAggregateMeta* -cass_keyspace_meta_aggregate_by_name(const CassKeyspaceMeta* keyspace_meta, - const char* name, - const char* arguments); - -/** - * Same as cass_keyspace_meta_aggregate_by_name(), but with lengths for string - * parameters. - * - * @cassandra{2.2+} - * - * @public @memberof CassKeyspaceMeta - * - * @param[in] keyspace_meta - * @param[in] name - * @param[in] name_length - * @param[in] arguments - * @param[in] arguments_length - * @return same as cass_keyspace_meta_aggregate_by_name() - * - * @see cass_keyspace_meta_aggregate_by_name() - */ -CASS_EXPORT const CassAggregateMeta* -cass_keyspace_meta_aggregate_by_name_n(const CassKeyspaceMeta* keyspace_meta, - const char* name, - size_t name_length, - const char* arguments, - size_t arguments_length); - -/** - * Gets a metadata field for the provided name. Metadata fields allow direct - * access to the column data found in the underlying "keyspaces" metadata table. - * - * @public @memberof CassKeyspaceMeta - * - * @param[in] keyspace_meta - * @param[in] name - * @return A metadata field value. NULL if the field does not exist. - */ -CASS_EXPORT const CassValue* -cass_keyspace_meta_field_by_name(const CassKeyspaceMeta* keyspace_meta, - const char* name); - -/** - * Same as cass_keyspace_meta_field_by_name(), but with lengths for string - * parameters. - * - * @public @memberof CassKeyspaceMeta - * - * @param[in] keyspace_meta - * @param[in] name - * @param[in] name_length - * @return same as cass_keyspace_meta_field_by_name() - * - * @see cass_keyspace_meta_field_by_name() - */ -CASS_EXPORT const CassValue* -cass_keyspace_meta_field_by_name_n(const CassKeyspaceMeta* keyspace_meta, - const char* name, - size_t name_length); - -/** - * Gets the name of the table. - * - * @public @memberof CassTableMeta - * - * @param[in] table_meta - * @param[out] name - * @param[out] name_length - */ -CASS_EXPORT void -cass_table_meta_name(const CassTableMeta* table_meta, - const char** name, - size_t* name_length); - -/** - * Determine if the table is a virtual table. - * - * @public @memberof CassTableMeta - * - * @param[in] table_meta - * @return cass_true is the table is virtual, otherwise cass_false - */ -CASS_EXPORT cass_bool_t -cass_table_meta_is_virtual(const CassTableMeta* table_meta); - -/** - * Gets the column metadata for the provided column name. - * - * @public @memberof CassTableMeta - * - * @param[in] table_meta - * @param[in] column - * - * @return The metadata for a column. NULL if column does not exist. - */ -CASS_EXPORT const CassColumnMeta* -cass_table_meta_column_by_name(const CassTableMeta* table_meta, - const char* column); - -/** - * Same as cass_table_meta_column_by_name(), but with lengths for string - * parameters. - * - * @public @memberof CassTableMeta - * - * @param[in] table_meta - * @param[in] column - * @param[in] column_length - * @return same as cass_table_meta_column_by_name() - * - * @see cass_table_meta_column_by_name() - */ -CASS_EXPORT const CassColumnMeta* -cass_table_meta_column_by_name_n(const CassTableMeta* table_meta, - const char* column, - size_t column_length); - -/** - * Gets the total number of columns for the table. - * - * @public @memberof CassTableMeta - * - * @param[in] table_meta - * @return The total column count. - */ -CASS_EXPORT size_t -cass_table_meta_column_count(const CassTableMeta* table_meta); - -/** - * Gets the column metadata for the provided index. - * - * @public @memberof CassTableMeta - * - * @param[in] table_meta - * @param[in] index - * @return The metadata for a column. NULL returned if the index is out of range. - */ -CASS_EXPORT const CassColumnMeta* -cass_table_meta_column(const CassTableMeta* table_meta, - size_t index); - -/** - * Gets the index metadata for the provided index name. - * - * @public @memberof CassTableMeta - * - * @param[in] table_meta - * @param[in] index - * - * @return The metadata for a index. NULL if index does not exist. - */ -CASS_EXPORT const CassIndexMeta* -cass_table_meta_index_by_name(const CassTableMeta* table_meta, - const char* index); - -/** - * Same as cass_table_meta_index_by_name(), but with lengths for string - * parameters. - * - * @public @memberof CassTableMeta - * - * @param[in] table_meta - * @param[in] index - * @param[in] index_length - * @return same as cass_table_meta_index_by_name() - * - * @see cass_table_meta_index_by_name() - */ -CASS_EXPORT const CassIndexMeta* -cass_table_meta_index_by_name_n(const CassTableMeta* table_meta, - const char* index, - size_t index_length); - -/** - * Gets the total number of indexes for the table. - * - * @public @memberof CassTableMeta - * - * @param[in] table_meta - * @return The total index count. - */ -CASS_EXPORT size_t -cass_table_meta_index_count(const CassTableMeta* table_meta); - -/** - * Gets the index metadata for the provided index. - * - * @public @memberof CassTableMeta - * - * @param[in] table_meta - * @param[in] index - * @return The metadata for a index. NULL returned if the index is out of range. - */ -CASS_EXPORT const CassIndexMeta* -cass_table_meta_index(const CassTableMeta* table_meta, - size_t index); - -/** - * Gets the materialized view metadata for the provided view name. - * - * @cassandra{3.0+} - * - * @public @memberof CassTableMeta - * - * @param[in] table_meta - * @param[in] view - * - * @return The metadata for a view. NULL if view does not exist. - */ -CASS_EXPORT const CassMaterializedViewMeta* -cass_table_meta_materialized_view_by_name(const CassTableMeta* table_meta, - const char* view); - -/** - * Same as cass_table_meta_materialized_view_by_name(), but with lengths for string - * parameters. - * - * @cassandra{3.0+} - * - * @public @memberof CassTableMeta - * - * @param[in] table_meta - * @param[in] view - * @param[in] view_length - * @return same as cass_table_meta_materialized_view_by_name() - * - * @see cass_table_meta_materialized_view_by_name() - */ -CASS_EXPORT const CassMaterializedViewMeta* -cass_table_meta_materialized_view_by_name_n(const CassTableMeta* table_meta, - const char* view, - size_t view_length); - -/** - * Gets the total number of views for the table. - * - * @cassandra{3.0+} - * - * @public @memberof CassTableMeta - * - * @param[in] table_meta - * @return The total view count. - */ -CASS_EXPORT size_t -cass_table_meta_materialized_view_count(const CassTableMeta* table_meta); - -/** - * Gets the materialized view metadata for the provided index. - * - * @cassandra{3.0+} - * - * @public @memberof CassTableMeta - * - * @param[in] table_meta - * @param[in] index - * @return The metadata for a view. NULL returned if the index is out of range. - */ -CASS_EXPORT const CassMaterializedViewMeta* -cass_table_meta_materialized_view(const CassTableMeta* table_meta, - size_t index); - -/** - * Gets the number of columns for the table's partition key. - * - * @public @memberof CassTableMeta - * - * @param[in] table_meta - * @return The count for the number of columns in the partition key. - */ -CASS_EXPORT size_t -cass_table_meta_partition_key_count(const CassTableMeta* table_meta); - -/** - * Gets the partition key column metadata for the provided index. - * - * @public @memberof CassTableMeta - * - * @param[in] table_meta - * @param[in] index - * @return The metadata for a column. NULL returned if the index is out of range. - * - * @see cass_table_meta_partition_key_count() - */ -CASS_EXPORT const CassColumnMeta* -cass_table_meta_partition_key(const CassTableMeta* table_meta, - size_t index); - -/** - * Gets the number of columns for the table's clustering key. - * - * @public @memberof CassTableMeta - * - * @param[in] table_meta - * @return The count for the number of columns in the clustering key. - */ -CASS_EXPORT size_t -cass_table_meta_clustering_key_count(const CassTableMeta* table_meta); - -/** - * Gets the clustering key column metadata for the provided index. - * - * @public @memberof CassTableMeta - * - * @param[in] table_meta - * @param[in] index - * @return The metadata for a column. NULL returned if the index is out of range. - * - * @see cass_table_meta_clustering_key_count() - */ -CASS_EXPORT const CassColumnMeta* -cass_table_meta_clustering_key(const CassTableMeta* table_meta, - size_t index); - -/** - * Gets the clustering order column metadata for the provided index. - * - * @public @memberof CassTableMeta - * - * @param[in] table_meta - * @param[in] index - * @return The clustering order for a column. - * CASS_CLUSTERING_ORDER_NONE returned if the index is out of range. - * - * @see cass_table_meta_clustering_key_count() - */ -CASS_EXPORT CassClusteringOrder -cass_table_meta_clustering_key_order(const CassTableMeta* table_meta, - size_t index); - -/** - * Gets a metadata field for the provided name. Metadata fields allow direct - * access to the column data found in the underlying "tables" metadata table. - * - * @public @memberof CassTableMeta - * - * @param[in] table_meta - * @param[in] name - * @return A metadata field value. NULL if the field does not exist. - */ -CASS_EXPORT const CassValue* -cass_table_meta_field_by_name(const CassTableMeta* table_meta, - const char* name); - -/** - * Same as cass_table_meta_field_by_name(), but with lengths for string - * parameters. - * - * @public @memberof CassTableMeta - * - * @param[in] table_meta - * @param[in] name - * @param[in] name_length - * @return same as cass_table_meta_field_by_name() - * - * @see cass_table_meta_field_by_name() - */ -CASS_EXPORT const CassValue* -cass_table_meta_field_by_name_n(const CassTableMeta* table_meta, - const char* name, - size_t name_length); - -/** - * Gets the column metadata for the provided column name. - * - * @cassandra{3.0+} - * - * @public @memberof CassMaterializedViewMeta - * - * @param[in] view_meta - * @param[in] column - * - * @return The metadata for a column. NULL if column does not exist. - */ -CASS_EXPORT const CassColumnMeta* -cass_materialized_view_meta_column_by_name(const CassMaterializedViewMeta* view_meta, - const char* column); - -/** - * Same as cass_materialized_view_meta_column_by_name(), but with lengths for string - * parameters. - * - * @cassandra{3.0+} - * - * @public @memberof CassMaterializedViewMeta - * - * @param[in] view_meta - * @param[in] column - * @param[in] column_length - * @return same as cass_materialized_view_meta_column_by_name() - * - * @see cass_materialized_view_meta_column_by_name() - */ -CASS_EXPORT const CassColumnMeta* -cass_materialized_view_meta_column_by_name_n(const CassMaterializedViewMeta* view_meta, - const char* column, - size_t column_length); - -/** - * Gets the name of the view. - * - * @cassandra{3.0+} - * - * @public @memberof CassMaterializedViewMeta - * - * @param[in] view_meta - * @param[out] name - * @param[out] name_length - */ -CASS_EXPORT void -cass_materialized_view_meta_name(const CassMaterializedViewMeta* view_meta, - const char** name, - size_t* name_length); - -/** - * Gets the base table of the view. - * - * @cassandra{3.0+} - * - * @public @memberof CassMaterializedViewMeta - * - * @param[in] view_meta - * - * @return The base table for the view. - */ -CASS_EXPORT const CassTableMeta* -cass_materialized_view_meta_base_table(const CassMaterializedViewMeta* view_meta); - -/** - * Gets the total number of columns for the view. - * - * @cassandra{3.0+} - * - * @public @memberof CassMaterializedViewMeta - * - * @param[in] view_meta - * @return The total column count. - */ -CASS_EXPORT size_t -cass_materialized_view_meta_column_count(const CassMaterializedViewMeta* view_meta); - -/** - * Gets the column metadata for the provided index. - * - * @cassandra{3.0+} - * - * @public @memberof CassMaterializedViewMeta - * - * @param[in] view_meta - * @param[in] index - * @return The metadata for a column. NULL returned if the index is out of range. - */ -CASS_EXPORT const CassColumnMeta* -cass_materialized_view_meta_column(const CassMaterializedViewMeta* view_meta, - size_t index); - -/** - * Gets the number of columns for the view's partition key. - * - * @cassandra{3.0+} - * - * @public @memberof CassMaterializedViewMeta - * - * @param[in] view_meta - * @return The count for the number of columns in the partition key. - */ -CASS_EXPORT size_t -cass_materialized_view_meta_partition_key_count(const CassMaterializedViewMeta* view_meta); - -/** - * Gets the partition key column metadata for the provided index. - * - * @cassandra{3.0+} - * - * @public @memberof CassMaterializedViewMeta - * - * @param[in] view_meta - * @param[in] index - * @return The metadata for a column. NULL returned if the index is out of range. - */ -CASS_EXPORT const CassColumnMeta* -cass_materialized_view_meta_partition_key(const CassMaterializedViewMeta* view_meta, - size_t index); - -/** - * Gets the number of columns for the view's clustering key. - * - * @cassandra{3.0+} - * - * @public @memberof CassMaterializedViewMeta - * - * @param[in] view_meta - * @return The count for the number of columns in the clustering key. - */ -CASS_EXPORT size_t -cass_materialized_view_meta_clustering_key_count(const CassMaterializedViewMeta* view_meta); - -/** - * Gets the clustering key column metadata for the provided index. - * - * @cassandra{3.0+} - * - * @public @memberof CassMaterializedViewMeta - * - * @param[in] view_meta - * @param[in] index - * @return The metadata for a column. NULL returned if the index is out of range. - */ -CASS_EXPORT const CassColumnMeta* -cass_materialized_view_meta_clustering_key(const CassMaterializedViewMeta* view_meta, - size_t index); - -/** - * Gets the clustering order column metadata for the provided index. - * - * @public @memberof CassMaterializedViewMeta - * - * @param[in] view_meta - * @param[in] index - * @return The clustering order for a column. - * CASS_CLUSTERING_ORDER_NONE returned if the index is out of range. - * - * @see cass_materialized_view_meta_clustering_key_count() - */ -CASS_EXPORT CassClusteringOrder -cass_materialized_view_meta_clustering_key_order(const CassMaterializedViewMeta* view_meta, - size_t index); - -/** - * Gets a metadata field for the provided name. Metadata fields allow direct - * access to the column data found in the underlying "views" metadata view. - * - * @cassandra{3.0+} - * - * @public @memberof CassMaterializedViewMeta - * - * @param[in] view_meta - * @param[in] name - * @return A metadata field value. NULL if the field does not exist. - */ -CASS_EXPORT const CassValue* -cass_materialized_view_meta_field_by_name(const CassMaterializedViewMeta* view_meta, - const char* name); - -/** - * Same as cass_materialized_view_meta_field_by_name(), but with lengths for string - * parameters. - * - * @cassandra{3.0+} - * - * @public @memberof CassMaterializedViewMeta - * - * @param[in] view_meta - * @param[in] name - * @param[in] name_length - * @return same as cass_materialized_view_meta_field_by_name() - * - * @see cass_materialized_view_meta_field_by_name() - */ -CASS_EXPORT const CassValue* -cass_materialized_view_meta_field_by_name_n(const CassMaterializedViewMeta* view_meta, - const char* name, - size_t name_length); - -/** - * Gets the name of the column. - * - * @public @memberof CassColumnMeta - * - * @param[in] column_meta - * @param[out] name - * @param[out] name_length - */ -CASS_EXPORT void -cass_column_meta_name(const CassColumnMeta* column_meta, - const char** name, - size_t* name_length); - -/** - * Gets the type of the column. - * - * @public @memberof CassColumnMeta - * - * @param[in] column_meta - * @return The column's type. - */ -CASS_EXPORT CassColumnType -cass_column_meta_type(const CassColumnMeta* column_meta); - -/** - * Gets the data type of the column. - * - * @public @memberof CassColumnMeta - * - * @param[in] column_meta - * @return The column's data type. - */ -CASS_EXPORT const CassDataType* -cass_column_meta_data_type(const CassColumnMeta* column_meta); - -/** - * Gets a metadata field for the provided name. Metadata fields allow direct - * access to the column data found in the underlying "columns" metadata table. - * - * @public @memberof CassColumnMeta - * - * @param[in] column_meta - * @param[in] name - * @return A metadata field value. NULL if the field does not exist. - */ -CASS_EXPORT const CassValue* -cass_column_meta_field_by_name(const CassColumnMeta* column_meta, - const char* name); - -/** - * Same as cass_column_meta_field_by_name(), but with lengths for string - * parameters. - * - * @public @memberof CassColumnMeta - * - * @param[in] column_meta - * @param[in] name - * @param[in] name_length - * @return same as cass_column_meta_field_by_name() - * - * @see cass_column_meta_field_by_name() - */ -CASS_EXPORT const CassValue* -cass_column_meta_field_by_name_n(const CassColumnMeta* column_meta, - const char* name, - size_t name_length); - -/** - * Gets the name of the index. - * - * @public @memberof CassIndexMeta - * - * @param[in] index_meta - * @param[out] name - * @param[out] name_length - */ -CASS_EXPORT void -cass_index_meta_name(const CassIndexMeta* index_meta, - const char** name, - size_t* name_length); - -/** - * Gets the type of the index. - * - * @public @memberof CassIndexMeta - * - * @param[in] index_meta - * @return The index's type. - */ -CASS_EXPORT CassIndexType -cass_index_meta_type(const CassIndexMeta* index_meta); - -/** - * Gets the target of the index. - * - * @public @memberof CassIndexMeta - * - * @param[in] index_meta - * @param[out] target - * @param[out] target_length - */ -CASS_EXPORT void -cass_index_meta_target(const CassIndexMeta* index_meta, - const char** target, - size_t* target_length); - -/** - * Gets the options of the index. - * - * @public @memberof CassIndexMeta - * - * @param[in] index_meta - * @return The index's options. - */ -CASS_EXPORT const CassValue* -cass_index_meta_options(const CassIndexMeta* index_meta); - -/** - * Gets a metadata field for the provided name. Metadata fields allow direct - * access to the index data found in the underlying "indexes" metadata table. - * - * @public @memberof CassIndexMeta - * - * @param[in] index_meta - * @param[in] name - * @return A metadata field value. NULL if the field does not exist. - */ -CASS_EXPORT const CassValue* -cass_index_meta_field_by_name(const CassIndexMeta* index_meta, - const char* name); - -/** - * Same as cass_index_meta_field_by_name(), but with lengths for string - * parameters. - * - * @public @memberof CassIndexMeta - * - * @param[in] index_meta - * @param[in] name - * @param[in] name_length - * @return same as cass_index_meta_field_by_name() - * - * @see cass_index_meta_field_by_name() - */ -CASS_EXPORT const CassValue* -cass_index_meta_field_by_name_n(const CassIndexMeta* index_meta, - const char* name, - size_t name_length); - -/** - * Gets the name of the function. - * - * @cassandra{2.2+} - * - * @public @memberof CassFunctionMeta - * - * @param[in] function_meta - * @param[out] name - * @param[out] name_length - */ -CASS_EXPORT void -cass_function_meta_name(const CassFunctionMeta* function_meta, - const char** name, - size_t* name_length); - -/** - * Gets the full name of the function. The full name includes the - * function's name and the function's signature: - * "name(type1 type2.. typeN)". - * - * @cassandra{2.2+} - * - * @public @memberof CassFunctionMeta - * - * @param[in] function_meta - * @param[out] full_name - * @param[out] full_name_length - */ -CASS_EXPORT void -cass_function_meta_full_name(const CassFunctionMeta* function_meta, - const char** full_name, - size_t* full_name_length); - -/** - * Gets the body of the function. - * - * @cassandra{2.2+} - * - * @public @memberof CassFunctionMeta - * - * @param[in] function_meta - * @param[out] body - * @param[out] body_length - */ -CASS_EXPORT void -cass_function_meta_body(const CassFunctionMeta* function_meta, - const char** body, - size_t* body_length); - -/** - * Gets the language of the function. - * - * @cassandra{2.2+} - * - * @public @memberof CassFunctionMeta - * - * @param[in] function_meta - * @param[out] language - * @param[out] language_length - */ -CASS_EXPORT void -cass_function_meta_language(const CassFunctionMeta* function_meta, - const char** language, - size_t* language_length); - -/** - * Gets whether a function is called on "null". - * - * @cassandra{2.2+} - * - * @public @memberof CassFunctionMeta - * - * @param[in] function_meta - * @return cass_true if a function is called on null, otherwise cass_false. - */ -CASS_EXPORT cass_bool_t -cass_function_meta_called_on_null_input(const CassFunctionMeta* function_meta); - -/** - * Gets the number of arguments this function takes. - * - * @cassandra{2.2+} - * - * @public @memberof CassFunctionMeta - * - * @param[in] function_meta - * @return The number of arguments. - */ -CASS_EXPORT size_t -cass_function_meta_argument_count(const CassFunctionMeta* function_meta); - -/** - * Gets the function's argument name and type for the provided index. - * - * @cassandra{2.2+} - * - * @public @memberof CassFunctionMeta - * - * @param[in] function_meta - * @param[in] index - * @param[out] name - * @param[out] name_length - * @param[out] type - * @return CASS_OK if successful, otherwise an error occurred - */ -CASS_EXPORT CassError -cass_function_meta_argument(const CassFunctionMeta* function_meta, - size_t index, - const char** name, - size_t* name_length, - const CassDataType** type); - -/** - * Gets the function's argument and type for the provided name. - * - * @cassandra{2.2+} - * - * @public @memberof CassFunctionMeta - * - * @param[in] function_meta - * @param[in] name - * @return A data type. NULL if the argument does not exist. - */ -CASS_EXPORT const CassDataType* -cass_function_meta_argument_type_by_name(const CassFunctionMeta* function_meta, - const char* name); - -/** - * Same as cass_function_meta_argument_type_by_name(), but with lengths for string - * parameters. - * - * @cassandra{2.2+} - * - * @public @memberof CassFunctionMeta - * - * @param[in] function_meta - * @param[in] name - * @param[in] name_length - * @return same as cass_function_meta_argument_type_by_name() - * - * @see cass_function_meta_argument_type_by_name() - */ -CASS_EXPORT const CassDataType* -cass_function_meta_argument_type_by_name_n(const CassFunctionMeta* function_meta, - const char* name, - size_t name_length); - -/** - * Gets the return type of the function. - * - * @cassandra{2.2+} - * - * @public @memberof CassFunctionMeta - * - * @param[in] function_meta - * @return The data type returned by the function. - */ -CASS_EXPORT const CassDataType* -cass_function_meta_return_type(const CassFunctionMeta* function_meta); - -/** - * Gets a metadata field for the provided name. Metadata fields allow direct - * access to the column data found in the underlying "functions" metadata table. - * - * @cassandra{2.2+} - * - * @public @memberof CassFunctionMeta - * - * @param[in] function_meta - * @param[in] name - * @return A metadata field value. NULL if the field does not exist. - */ -CASS_EXPORT const CassValue* -cass_function_meta_field_by_name(const CassFunctionMeta* function_meta, - const char* name); - -/** - * Same as cass_function_meta_field_by_name(), but with lengths for string - * parameters. - * - * @cassandra{2.2+} - * - * @public @memberof CassFunctionMeta - * - * @param[in] function_meta - * @param[in] name - * @param[in] name_length - * @return same as cass_function_meta_field_by_name() - * - * @see cass_function_meta_field_by_name() - */ -CASS_EXPORT const CassValue* -cass_function_meta_field_by_name_n(const CassFunctionMeta* function_meta, - const char* name, - size_t name_length); - -/** - * Gets the name of the aggregate. - * - * @cassandra{2.2+} - * - * @public @memberof CassAggregateMeta - * - * @param[in] aggregate_meta - * @param[out] name - * @param[out] name_length - */ -CASS_EXPORT void -cass_aggregate_meta_name(const CassAggregateMeta* aggregate_meta, - const char** name, - size_t* name_length); - -/** - * Gets the full name of the aggregate. The full name includes the - * aggregate's name and the aggregate's signature: - * "name(type1 type2.. typeN)". - * - * @cassandra{2.2+} - * - * @public @memberof CassAggregateMeta - * - * @param[in] aggregate_meta - * @param[out] full_name - * @param[out] full_name_length - */ -CASS_EXPORT void -cass_aggregate_meta_full_name(const CassAggregateMeta* aggregate_meta, - const char** full_name, - size_t* full_name_length); - -/** - * Gets the number of arguments this aggregate takes. - * - * @cassandra{2.2+} - * - * @public @memberof CassAggregateMeta - * - * @param[in] aggregate_meta - * @return The number of arguments. - */ -CASS_EXPORT size_t -cass_aggregate_meta_argument_count(const CassAggregateMeta* aggregate_meta); - -/** - * Gets the aggregate's argument type for the provided index. - * - * @cassandra{2.2+} - * - * @public @memberof CassAggregateMeta - * - * @param[in] aggregate_meta - * @param[in] index - * @return The data type for argument. NULL returned if the index is out of range. - */ -CASS_EXPORT const CassDataType* -cass_aggregate_meta_argument_type(const CassAggregateMeta* aggregate_meta, - size_t index); - -/** - * Gets the return type of the aggregate. - * - * @cassandra{2.2+} - * - * @public @memberof CassAggregateMeta - * - * @param[in] aggregate_meta - * @return The data type returned by the aggregate. - */ -CASS_EXPORT const CassDataType* -cass_aggregate_meta_return_type(const CassAggregateMeta* aggregate_meta); - -/** - * Gets the state type of the aggregate. - * - * @cassandra{2.2+} - * - * @public @memberof CassAggregateMeta - * - * @param[in] aggregate_meta - * @return The data type of the aggregate's state. - */ -CASS_EXPORT const CassDataType* -cass_aggregate_meta_state_type(const CassAggregateMeta* aggregate_meta); - -/** - * Gets the function metadata for the aggregate's state function. - * - * @cassandra{2.2+} - * - * @public @memberof CassAggregateMeta - * - * @param[in] aggregate_meta - * @return The function metadata for the state function. - */ -CASS_EXPORT const CassFunctionMeta* -cass_aggregate_meta_state_func(const CassAggregateMeta* aggregate_meta); - -/** - * Gets the function metadata for the aggregates's final function. - * - * @cassandra{2.2+} - * - * @public @memberof CassAggregateMeta - * - * @param[in] aggregate_meta - * @return The function metadata for the final function. - */ -CASS_EXPORT const CassFunctionMeta* -cass_aggregate_meta_final_func(const CassAggregateMeta* aggregate_meta); - -/** - * Gets the initial condition value for the aggregate. - * - * @cassandra{2.2+} - * - * Note: The value of the initial condition will always be - * a "varchar" type for Cassandra 3.0+. - * - * @public @memberof CassAggregateMeta - * - * @param[in] aggregate_meta - * @return The value of the initial condition. - */ -CASS_EXPORT const CassValue* -cass_aggregate_meta_init_cond(const CassAggregateMeta* aggregate_meta); - -/** - * Gets a metadata field for the provided name. Metadata fields allow direct - * access to the column data found in the underlying "aggregates" metadata table. - * - * @cassandra{2.2+} - * - * @public @memberof CassAggregateMeta - * - * @param[in] aggregate_meta - * @param[in] name - * @return A metadata field value. NULL if the field does not exist. - */ -CASS_EXPORT const CassValue* -cass_aggregate_meta_field_by_name(const CassAggregateMeta* aggregate_meta, - const char* name); - -/** - * Same as cass_aggregate_meta_field_by_name(), but with lengths for string - * parameters. - * - * @cassandra{2.2+} - * - * @public @memberof CassAggregateMeta - * - * @param[in] aggregate_meta - * @param[in] name - * @param[in] name_length - * @return same as cass_aggregate_meta_field_by_name() - * - * @see cass_aggregate_meta_field_by_name() - */ -CASS_EXPORT const CassValue* -cass_aggregate_meta_field_by_name_n(const CassAggregateMeta* aggregate_meta, - const char* name, - size_t name_length); - -/*********************************************************************************** - * - * SSL - * - ************************************************************************************/ - -/** - * Creates a new SSL context. - * - * @public @memberof CassSsl - * - * @return Returns a SSL context that must be freed. - * - * @see cass_ssl_free() - */ -CASS_EXPORT CassSsl* -cass_ssl_new(); - -/** - * Creates a new SSL context without initializing the underlying library - * implementation. The integrating application is responsible for - * initializing the underlying SSL implementation. The driver uses the SSL - * implmentation from several threads concurrently so it's important that it's - * properly setup for multithreaded use e.g. lock callbacks for OpenSSL. - * - * Important: The SSL library must be initialized before calling this - * function. - * - * When using OpenSSL the following components need to be initialized: - * - * SSL_library_init(); - * SSL_load_error_strings(); - * OpenSSL_add_all_algorithms(); - * - * The following thread-safety callbacks also need to be set: - * - * CRYPTO_set_locking_callback(...); - * CRYPTO_set_id_callback(...); - * - * @public @memberof CassSsl - * - * @return Returns a SSL context that must be freed. - * - * @see cass_ssl_new() - * @see cass_ssl_free() - */ -CASS_EXPORT CassSsl* -cass_ssl_new_no_lib_init(); - -/** - * Frees a SSL context instance. - * - * @public @memberof CassSsl - * - * @param[in] ssl - */ -CASS_EXPORT void -cass_ssl_free(CassSsl* ssl); - -/** - * Adds a trusted certificate. This is used to verify - * the peer's certificate. - * - * @public @memberof CassSsl - * - * @param[in] ssl - * @param[in] cert PEM formatted certificate string - * @return CASS_OK if successful, otherwise an error occurred - */ -CASS_EXPORT CassError -cass_ssl_add_trusted_cert(CassSsl* ssl, - const char* cert); - -/** - * Same as cass_ssl_add_trusted_cert(), but with lengths for string - * parameters. - * - * @public @memberof CassSsl - * - * @param[in] ssl - * @param[in] cert - * @param[in] cert_length - * @return same as cass_ssl_add_trusted_cert() - * - * @see cass_ssl_add_trusted_cert() - */ -CASS_EXPORT CassError -cass_ssl_add_trusted_cert_n(CassSsl* ssl, - const char* cert, - size_t cert_length); - -/** - * Sets verification performed on the peer's certificate. - * - * CASS_SSL_VERIFY_NONE - No verification is performed - * CASS_SSL_VERIFY_PEER_CERT - Certificate is present and valid - * CASS_SSL_VERIFY_PEER_IDENTITY - IP address matches the certificate's - * common name or one of its subject alternative names. This implies the - * certificate is also present. - * CASS_SSL_VERIFY_PEER_IDENTITY_DNS - Do not use. This option requires the - * use of reverse DNS lookup which is not sufficient to protect against - * man-in-the-middle attacks. - * - * Default: CASS_SSL_VERIFY_PEER_CERT - * - * @public @memberof CassSsl - * - * @param[in] ssl - * @param[in] flags - * @return CASS_OK if successful, otherwise an error occurred - * - */ -CASS_EXPORT void -cass_ssl_set_verify_flags(CassSsl* ssl, - int flags); - -/** - * Set client-side certificate chain. This is used to authenticate - * the client on the server-side. This should contain the entire - * Certificate chain starting with the certificate itself. - * - * @public @memberof CassSsl - * - * @param[in] ssl - * @param[in] cert PEM formatted certificate string - * @return CASS_OK if successful, otherwise an error occurred - */ -CASS_EXPORT CassError -cass_ssl_set_cert(CassSsl* ssl, - const char* cert); - -/** - * Same as cass_ssl_set_cert(), but with lengths for string - * parameters. - * - * @public @memberof CassSsl - * - * @param[in] ssl - * @param[in] cert - * @param[in] cert_length - * @return same as cass_ssl_set_cert() - * - * @see cass_ssl_set_cert() - */ -CASS_EXPORT CassError -cass_ssl_set_cert_n(CassSsl* ssl, - const char* cert, - size_t cert_length); - -/** - * Set client-side private key. This is used to authenticate - * the client on the server-side. - * - * @public @memberof CassSsl - * - * @param[in] ssl - * @param[in] key PEM formatted key string - * @param[in] password used to decrypt key - * @return CASS_OK if successful, otherwise an error occurred - */ -CASS_EXPORT CassError -cass_ssl_set_private_key(CassSsl* ssl, - const char* key, - const char* password); - -/** - * Same as cass_ssl_set_private_key(), but with lengths for string - * parameters. - * - * @public @memberof CassSsl - * - * @param[in] ssl - * @param[in] key - * @param[in] key_length - * @param[in] password - * @param[in] password_length - * @return same as cass_ssl_set_private_key() - * - * @see cass_ssl_set_private_key() - */ -CASS_EXPORT CassError -cass_ssl_set_private_key_n(CassSsl* ssl, - const char* key, - size_t key_length, - const char* password, - size_t password_length); - -/** - * Set minimum supported client-side protocol version. This will prevent the - * connection using protocol versions earlier than the specified one. Useful - * for preventing TLS downgrade attacks. - * - * @public @memberof CassSsl - * - * @param[in] ssl - * @param[in] min_version - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_ssl_set_min_protocol_version(CassSsl* ssl, CassSslTlsVersion min_version); - -/*********************************************************************************** - * - * Authenticator - * - ************************************************************************************/ - -/** - * Gets the IP address of the host being authenticated. - * - * @param[in] auth - * @param[out] address - * - * @public @memberof CassAuthenticator - */ -CASS_EXPORT void -cass_authenticator_address(const CassAuthenticator* auth, - CassInet* address); - -/** - * Gets the hostname of the host being authenticated. - * - * @public @memberof CassAuthenticator - * - * @param[in] auth - * @param[out] length - * @return A null-terminated string. - */ -CASS_EXPORT const char* -cass_authenticator_hostname(const CassAuthenticator* auth, - size_t* length); - -/** - * Gets the class name for the server-side IAuthentication implementation. - * - * @public @memberof CassAuthenticator - * - * @param[in] auth - * @param[out] length - * @return A null-terminated string. - */ -CASS_EXPORT const char* -cass_authenticator_class_name(const CassAuthenticator* auth, - size_t* length); - -/** - * Gets the user data created during the authenticator exchange. This - * is set using cass_authenticator_set_exchange_data(). - * - * @public @memberof CassAuthenticator - * - * @param[in] auth - * @return User specified exchange data previously set by - * cass_authenticator_set_exchange_data(). - * - * @see cass_authenticator_set_exchange_data() - */ -CASS_EXPORT void* -cass_authenticator_exchange_data(CassAuthenticator* auth); - -/** - * Sets the user data to be used during the authenticator exchange. - * - * @public @memberof CassAuthenticator - * - * @param[in] auth - * @param[in] exchange_data - * - * @see cass_authenticator_exchange_data() - */ -CASS_EXPORT void -cass_authenticator_set_exchange_data(CassAuthenticator* auth, - void* exchange_data); - -/** - * Gets a response token buffer of the provided size. - * - * @public @memberof CassAuthenticator - * - * @param[in] auth - * @param[in] size - * @return A buffer to copy the response token. - */ -CASS_EXPORT char* -cass_authenticator_response(CassAuthenticator* auth, - size_t size); - -/** - * Sets the response token. - * - * @public @memberof CassAuthenticator - * - * @param[in] auth - * @param[in] response - * @param[in] response_size - */ -CASS_EXPORT void -cass_authenticator_set_response(CassAuthenticator* auth, - const char* response, - size_t response_size); - -/** - * Sets an error for the authenticator exchange. - * - * @public @memberof CassAuthenticator - * - * @param[in] auth - * @param[in] message - */ -CASS_EXPORT void -cass_authenticator_set_error(CassAuthenticator* auth, - const char* message); - -/** - * Same as cass_authenticator_set_error(), but with lengths for string - * parameters. - * - * @public @memberof CassAuthenticator - * - * @param[in] auth - * @param[in] message - * @param[in] message_length - * - * @see cass_authenticator_set_error() - */ -CASS_EXPORT void -cass_authenticator_set_error_n(CassAuthenticator* auth, - const char* message, - size_t message_length); - -/*********************************************************************************** - * - * Future - * - ***********************************************************************************/ - -/** - * Frees a future instance. A future can be freed anytime. - * - * @public @memberof CassFuture - */ -CASS_EXPORT void -cass_future_free(CassFuture* future); - -/** - * Sets a callback that is called when a future is set - * - * @public @memberof CassFuture - * - * @param[in] future - * @param[in] callback - * @param[in] data - * @return CASS_OK if successful, otherwise an error occurred - */ -CASS_EXPORT CassError -cass_future_set_callback(CassFuture* future, - CassFutureCallback callback, - void* data); - -/** - * Gets the set status of the future. - * - * @public @memberof CassFuture - * - * @param[in] future - * @return true if set - */ -CASS_EXPORT cass_bool_t -cass_future_ready(CassFuture* future); - -/** - * Wait for the future to be set with either a result or error. - * - * Important: Do not wait in a future callback. Waiting in a future - * callback will cause a deadlock. - * - * @public @memberof CassFuture - * - * @param[in] future - */ -CASS_EXPORT void -cass_future_wait(CassFuture* future); - -/** - * Wait for the future to be set or timeout. - * - * @public @memberof CassFuture - * - * @param[in] future - * @param[in] timeout_us wait time in microseconds - * @return false if returned due to timeout - */ -CASS_EXPORT cass_bool_t -cass_future_wait_timed(CassFuture* future, - cass_duration_t timeout_us); - -/** - * Gets the result of a successful future. If the future is not ready this method will - * wait for the future to be set. - * - * @public @memberof CassFuture - * - * @param[in] future - * @return CassResult instance if successful, otherwise NULL for error. The return instance - * must be freed using cass_result_free(). - * - * @see cass_session_execute() and cass_session_execute_batch() - */ -CASS_EXPORT const CassResult* -cass_future_get_result(CassFuture* future); - -/** - * Gets the error result from a future that failed as a result of a server error. If the - * future is not ready this method will wait for the future to be set. - * - * @public @memberof CassFuture - * - * @param[in] future - * @return CassErrorResult instance if the request failed with a server error, - * otherwise NULL if the request was successful or the failure was not caused by - * a server error. The return instance must be freed using cass_error_result_free(). - * - * @see cass_session_execute() and cass_session_execute_batch() - */ -CASS_EXPORT const CassErrorResult* -cass_future_get_error_result(CassFuture* future); - -/** - * Gets the result of a successful future. If the future is not ready this method will - * wait for the future to be set. The first successful call consumes the future, all - * subsequent calls will return NULL. - * - * @public @memberof CassFuture - * - * @param[in] future - * @return CassPrepared instance if successful, otherwise NULL for error. The return instance - * must be freed using cass_prepared_free(). - * - * @see cass_session_prepare() - */ -CASS_EXPORT const CassPrepared* -cass_future_get_prepared(CassFuture* future); - -/** - * Gets the error code from future. If the future is not ready this method will - * wait for the future to be set. - * - * @public @memberof CassFuture - * - * @param[in] future - * @return CASS_OK if successful, otherwise an error occurred. - * - * @see cass_error_desc() - */ -CASS_EXPORT CassError -cass_future_error_code(CassFuture* future); - -/** - * Gets the error message from future. If the future is not ready this method will - * wait for the future to be set. - * - * @public @memberof CassFuture - * - * @param[in] future - * @param[out] message Empty string returned if successful, otherwise - * a message describing the error is returned. - * @param[out] message_length - */ -CASS_EXPORT void -cass_future_error_message(CassFuture* future, - const char** message, - size_t* message_length); - -/** - * Gets the tracing ID associated with the request. - * - * @public @memberof CassFuture - * - * @param[in] future - * @param[out] tracing_id - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_future_tracing_id(CassFuture* future, - CassUuid* tracing_id); - -/** - * Gets a the number of custom payload items from a response future. If the future is not - * ready this method will wait for the future to be set. - * - * @cassandra{2.2+} - * - * @public @memberof CassFuture - * - * @param[in] future - * @return the number of custom payload items. - */ -CASS_EXPORT size_t -cass_future_custom_payload_item_count(CassFuture* future); - -/** - * Gets a custom payload item from a response future at the specified index. If the future is not - * ready this method will wait for the future to be set. - * - * @cassandra{2.2+} - * - * @public @memberof CassFuture - * - * @param[in] future - * @param[in] index - * @param[out] name - * @param[out] name_length - * @param[out] value - * @param[out] value_size - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_future_custom_payload_item(CassFuture* future, - size_t index, - const char** name, - size_t* name_length, - const cass_byte_t** value, - size_t* value_size); - -/** - * Gets the node that acted as coordinator for this query. If the future is not - * ready this method will wait for the future to be set. - * - * @public @memberof CassFuture - * - * @param future - * @return The coordinator node that handled the query. The lifetime of this - * object is the same as the result object it came from. NULL can be returned - * if the future is not a response future or if an error occurs before a - * coordinator responds. - * - * @see cass_statement_set_node() - */ -CASS_EXPORT const CassNode* -cass_future_coordinator(CassFuture* future); - -/*********************************************************************************** - * - * Statement - * - ***********************************************************************************/ - -/** - * Creates a new query statement. - * - * @public @memberof CassStatement - * - * @param[in] query The query is copied into the statement object; the - * memory pointed to by this parameter can be freed after this call. - * @param[in] parameter_count The number of bound parameters. - * @return Returns a statement that must be freed. - * - * @see cass_statement_free() - */ -CASS_EXPORT CassStatement* -cass_statement_new(const char* query, - size_t parameter_count); - -/** - * Same as cass_statement_new(), but with lengths for string - * parameters. - * - * @public @memberof CassStatement - * - * @param[in] query - * @param[in] query_length - * @param[in] parameter_count - * @return same as cass_statement_new() - * - * @see cass_statement_new() - */ -CASS_EXPORT CassStatement* -cass_statement_new_n(const char* query, - size_t query_length, - size_t parameter_count); - -/** - * Clear and/or resize the statement's parameters. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] count - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_reset_parameters(CassStatement* statement, - size_t count); - -/** - * Frees a statement instance. Statements can be immediately freed after - * being prepared, executed or added to a batch. - * - * @public @memberof CassStatement - * - * @param[in] statement - */ -CASS_EXPORT void -cass_statement_free(CassStatement* statement); - -/** - * Adds a key index specifier to this a statement. - * When using token-aware routing, this can be used to tell the driver which - * parameters within a non-prepared, parameterized statement are part of - * the partition key. - * - * Use consecutive calls for composite partition keys. - * - * This is not necessary for prepared statements, as the key - * parameters are determined in the metadata processed in the prepare phase. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] index - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_add_key_index(CassStatement* statement, - size_t index); - -/** - * Sets the statement's keyspace. This is used for token-aware routing and when - * using protocol v5 or greater it also overrides the session's current - * keyspace for the statement. - * - * This is not necessary and will not work for bound statements, as the keyspace - * is determined by the prepared statement metadata. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] keyspace - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_set_keyspace(CassStatement* statement, - const char* keyspace); - -/** - * Same as cass_statement_set_keyspace(), but with lengths for string - * parameters. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] keyspace - * @param[in] keyspace_length - * @return same as cass_statement_set_keyspace() - * - * @see cass_statement_set_keyspace() - */ -CASS_EXPORT CassError -cass_statement_set_keyspace_n(CassStatement* statement, - const char* keyspace, - size_t keyspace_length); - -/** - * Sets the statement's consistency level. - * - * Default: CASS_CONSISTENCY_LOCAL_ONE - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] consistency - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_set_consistency(CassStatement* statement, - CassConsistency consistency); - -/** - * Sets the statement's serial consistency level. - * - * @cassandra{2.0+} - * - * Default: Not set - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] serial_consistency - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_set_serial_consistency(CassStatement* statement, - CassConsistency serial_consistency); - -/** - * Sets the statement's page size. - * - * @cassandra{2.0+} - * - * Default: -1 (Disabled) - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] page_size - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_set_paging_size(CassStatement* statement, - int page_size); - -/** - * Sets the statement's paging state. This can be used to get the next page of - * data in a multi-page query. - * - * @cassandra{2.0+} - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] result - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_set_paging_state(CassStatement* statement, - const CassResult* result); - -/** - * Sets the statement's paging state. This can be used to get the next page of - * data in a multi-page query. - * - * @cassandra{2.0+} - * - * Warning: The paging state should not be exposed to or come from - * untrusted environments. The paging state could be spoofed and potentially - * used to gain access to other data. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] paging_state - * @param[in] paging_state_size - * @return CASS_OK if successful, otherwise an error occurred. - * - * @see cass_result_paging_state_token() - */ -CASS_EXPORT CassError -cass_statement_set_paging_state_token(CassStatement* statement, - const char* paging_state, - size_t paging_state_size); - -/** - * Sets the statement's timestamp. - * - * @cassandra{2.1+} - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] timestamp - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_set_timestamp(CassStatement* statement, - cass_int64_t timestamp); - -/** - * Sets the statement's timeout for waiting for a response from a node. - * - * Default: Disabled (use the cluster-level request timeout) - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] timeout_ms Request timeout in milliseconds. Use 0 for no timeout - * or CASS_UINT64_MAX to disable (to use the cluster-level request timeout). - * @return CASS_OK if successful, otherwise an error occurred. - * - * @see cass_cluster_set_request_timeout() - */ -CASS_EXPORT CassError -cass_statement_set_request_timeout(CassStatement* statement, - cass_uint64_t timeout_ms); - -/** - * Sets whether the statement is idempotent. Idempotent statements are able to be - * automatically retried after timeouts/errors and can be speculatively executed. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] is_idempotent - * @return CASS_OK if successful, otherwise an error occurred. - * - * @see cass_cluster_set_constant_speculative_execution_policy() - * @see cass_execution_profile_set_constant_speculative_execution_policy() - */ -CASS_EXPORT CassError -cass_statement_set_is_idempotent(CassStatement* statement, - cass_bool_t is_idempotent); - -/** - * Sets the statement's retry policy. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] retry_policy - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_set_retry_policy(CassStatement* statement, - CassRetryPolicy* retry_policy); - -/** - * Sets the statement's custom payload. - * - * @cassandra{2.2+} - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] payload - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_set_custom_payload(CassStatement* statement, - const CassCustomPayload* payload); - -/** - * Sets the execution profile to execute the statement with. - * - * Note: NULL or empty string will clear execution profile from statement - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @return CASS_OK if successful, otherwise an error occurred. - * - * @see cass_cluster_set_execution_profile() - */ -CASS_EXPORT CassError -cass_statement_set_execution_profile(CassStatement* statement, - const char* name); - -/** - * Same as cass_statement_set_execution_profile(), but with lengths for string - * parameters. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] name_length - * @return CASS_OK if successful, otherwise an error occurred. - * - * @see cass_statement_set_execution_profile() - */ -CASS_EXPORT CassError -cass_statement_set_execution_profile_n(CassStatement* statement, - const char* name, - size_t name_length); - -/** - * Sets whether the statement should use tracing. - * - * @cassandra{2.2+} - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] enabled - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_set_tracing(CassStatement* statement, - cass_bool_t enabled); - -/** - * Sets a specific host that should run the query. - * - * In general, this should not be used, but it can be useful in the following - * situations: - * * To query node-local tables such as system and virtual tables. - * * To apply a sequence of schema changes where it makes sense for all the - * changes to be applied on a single node. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] host - * @param[in] port - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_set_host(CassStatement* statement, - const char* host, - int port); - -/** - * Same as cass_statement_set_host(), but with lengths for string - * parameters. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] host - * @param[in] host_length - * @param[in] port - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_set_host_n(CassStatement* statement, - const char* host, - size_t host_length, - int port); - -/** - * Same as cass_statement_set_host(), but with the `CassInet` type - * for the host instead of a string. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] host - * @param[in] port - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_set_host_inet(CassStatement* statement, - const CassInet* host, - int port); - -/** - * Same as cass_statement_set_host(), but using the `CassNode` type. This can - * be used to re-query the same coordinator when used with the result of - * `cass_future_coordinator()` - * - * @public @memberof CassStatement - * - * @param statement - * @param node - * @return CASS_OK if successful, otherwise an error occurred. - * - * @see cass_future_coordinator() - */ -CASS_EXPORT CassError -cass_statement_set_node(CassStatement* statement, - const CassNode* node); - -/** - * Binds null to a query or bound statement at the specified index. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] index - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_null(CassStatement* statement, - size_t index); - -/** - * Binds a null to all the values with the specified name. - * - * This can only be used with statements created by - * cass_prepared_bind() when using Cassandra 2.0 or earlier. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_null_by_name(CassStatement* statement, - const char* name); - -/** - * Same as cass_statement_bind_null_by_name(), but with lengths for string - * parameters. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] name_length - * @return same as cass_statement_bind_null_by_name() - * - * @see cass_statement_bind_null_by_name() - */ -CASS_EXPORT CassError -cass_statement_bind_null_by_name_n(CassStatement* statement, - const char* name, - size_t name_length); - -/** - * Binds a "tinyint" to a query or bound statement at the specified index. - * - * @cassandra{2.2+} - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] index - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_int8(CassStatement* statement, - size_t index, - cass_int8_t value); - -/** - * Binds a "tinyint" to all the values with the specified name. - * - * @cassandra{2.2+} - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_int8_by_name(CassStatement* statement, - const char* name, - cass_int8_t value); - -/** - * Same as cass_statement_bind_int8_by_name(), but with lengths for string - * parameters. - * - * @cassandra{2.2+} - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] name_length - * @param[in] value - * @return same as cass_statement_bind_int8_by_name() - * - * @see cass_statement_bind_int8_by_name() - */ -CASS_EXPORT CassError -cass_statement_bind_int8_by_name_n(CassStatement* statement, - const char* name, - size_t name_length, - cass_int8_t value); - -/** - * Binds an "smallint" to a query or bound statement at the specified index. - * - * @cassandra{2.2+} - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] index - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_int16(CassStatement* statement, - size_t index, - cass_int16_t value); - -/** - * Binds an "smallint" to all the values with the specified name. - * - * @cassandra{2.2+} - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_int16_by_name(CassStatement* statement, - const char* name, - cass_int16_t value); - -/** - * Same as cass_statement_bind_int16_by_name(), but with lengths for string - * parameters. - * - * @cassandra{2.2+} - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] name_length - * @param[in] value - * @return same as cass_statement_bind_int16_by_name() - * - * @see cass_statement_bind_int16_by_name() - */ -CASS_EXPORT CassError -cass_statement_bind_int16_by_name_n(CassStatement* statement, - const char* name, - size_t name_length, - cass_int16_t value); - -/** - * Binds an "int" to a query or bound statement at the specified index. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] index - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_int32(CassStatement* statement, - size_t index, - cass_int32_t value); - -/** - * Binds an "int" to all the values with the specified name. - * - * This can only be used with statements created by - * cass_prepared_bind() when using Cassandra 2.0 or earlier. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_int32_by_name(CassStatement* statement, - const char* name, - cass_int32_t value); - -/** - * Same as cass_statement_bind_int32_by_name(), but with lengths for string - * parameters. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] name_length - * @param[in] value - * @return same as cass_statement_bind_int32_by_name() - * - * @see cass_statement_bind_int32_by_name() - */ -CASS_EXPORT CassError -cass_statement_bind_int32_by_name_n(CassStatement* statement, - const char* name, - size_t name_length, - cass_int32_t value); - -/** - * Binds a "date" to a query or bound statement at the specified index. - * - * @cassandra{2.2+} - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] index - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_uint32(CassStatement* statement, - size_t index, - cass_uint32_t value); - -/** - * Binds a "date" to all the values with the specified name. - * - * @cassandra{2.2+} - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_uint32_by_name(CassStatement* statement, - const char* name, - cass_uint32_t value); - -/** - * Same as cass_statement_bind_uint32_by_name(), but with lengths for string - * parameters. - * - * @cassandra{2.2+} - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] name_length - * @param[in] value - * @return same as cass_statement_bind_uint32_by_name() - * - * @see cass_statement_bind_uint32_by_name() - */ -CASS_EXPORT CassError -cass_statement_bind_uint32_by_name_n(CassStatement* statement, - const char* name, - size_t name_length, - cass_uint32_t value); - -/** - * Binds a "bigint", "counter", "timestamp" or "time" to a query or - * bound statement at the specified index. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] index - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_int64(CassStatement* statement, - size_t index, - cass_int64_t value); - -/** - * Binds a "bigint", "counter", "timestamp" or "time" to all values - * with the specified name. - * - * This can only be used with statements created by - * cass_prepared_bind() when using Cassandra 2.0 or earlier. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_int64_by_name(CassStatement* statement, - const char* name, - cass_int64_t value); - -/** - * Same as cass_statement_bind_int64_by_name(), but with lengths for string - * parameters. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] name_length - * @param[in] value - * @return same as cass_statement_bind_int64_by_name(0 - * - * @see cass_statement_bind_int64_by_name() - */ -CASS_EXPORT CassError -cass_statement_bind_int64_by_name_n(CassStatement* statement, - const char* name, - size_t name_length, - cass_int64_t value); - -/** - * Binds a "float" to a query or bound statement at the specified index. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] index - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_float(CassStatement* statement, - size_t index, - cass_float_t value); - -/** - * Binds a "float" to all the values with the specified name. - * - * This can only be used with statements created by - * cass_prepared_bind() when using Cassandra 2.0 or earlier. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_float_by_name(CassStatement* statement, - const char* name, - cass_float_t value); - -/** - * Same as cass_statement_bind_float_by_name(), but with lengths for string - * parameters. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] name_length - * @param[in] value - * @return same as cass_statement_bind_float_by_name() - * - * @see cass_statement_bind_float_by_name() - */ -CASS_EXPORT CassError -cass_statement_bind_float_by_name_n(CassStatement* statement, - const char* name, - size_t name_length, - cass_float_t value); - -/** - * Binds a "double" to a query or bound statement at the specified index. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] index - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_double(CassStatement* statement, - size_t index, - cass_double_t value); - -/** - * Binds a "double" to all the values with the specified name. - * - * This can only be used with statements created by - * cass_prepared_bind() when using Cassandra 2.0 or earlier. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_double_by_name(CassStatement* statement, - const char* name, - cass_double_t value); - -/** - * Same as cass_statement_bind_double_by_name(), but with lengths for string - * parameters. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] name_length - * @param[in] value - * @return same as cass_statement_bind_double_by_name() - * - * @see cass_statement_bind_double_by_name() - */ -CASS_EXPORT CassError -cass_statement_bind_double_by_name_n(CassStatement* statement, - const char* name, - size_t name_length, - cass_double_t value); - -/** - * Binds a "boolean" to a query or bound statement at the specified index. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] index - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_bool(CassStatement* statement, - size_t index, - cass_bool_t value); - -/** - * Binds a "boolean" to all the values with the specified name. - * - * This can only be used with statements created by - * cass_prepared_bind() when using Cassandra 2.0 or earlier. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_bool_by_name(CassStatement* statement, - const char* name, - cass_bool_t value); - -/** - * Same as cass_statement_bind_bool_by_name(), but with lengths for string - * parameters. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] name_length - * @param[in] value - * @return same as cass_statement_bind_bool_by_name() - * - * @see cass_statement_bind_bool_by_name() - */ -CASS_EXPORT CassError -cass_statement_bind_bool_by_name_n(CassStatement* statement, - const char* name, - size_t name_length, - cass_bool_t value); - -/** - * Binds an "ascii", "text" or "varchar" to a query or bound statement - * at the specified index. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] index - * @param[in] value The value is copied into the statement object; the - * memory pointed to by this parameter can be freed after this call. - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_string(CassStatement* statement, - size_t index, - const char* value); - -/** - * Same as cass_statement_bind_string(), but with lengths for string - * parameters. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] index - * @param[in] value - * @param[in] value_length - * @return same as cass_statement_bind_string() - * - * @see cass_statement_bind_string() - */ -CASS_EXPORT CassError -cass_statement_bind_string_n(CassStatement* statement, - size_t index, - const char* value, - size_t value_length); - -/** - * Binds an "ascii", "text" or "varchar" to all the values - * with the specified name. - * - * This can only be used with statements created by - * cass_prepared_bind() when using Cassandra 2.0 or earlier. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] value The value is copied into the statement object; the - * memory pointed to by this parameter can be freed after this call. - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_string_by_name(CassStatement* statement, - const char* name, - const char* value); - -/** - * Same as cass_statement_bind_string_by_name(), but with lengths for string - * parameters. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] name_length - * @param[in] value - * @param[in] value_length - * @return same as cass_statement_bind_string_by_name() - * - * @see cass_statement_bind_string_by_name() - */ -CASS_EXPORT CassError -cass_statement_bind_string_by_name_n(CassStatement* statement, - const char* name, - size_t name_length, - const char* value, - size_t value_length); - -/** - * Binds a "blob", "varint" or "custom" to a query or bound statement at the specified index. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] index - * @param[in] value The value is copied into the statement object; the - * memory pointed to by this parameter can be freed after this call. - * @param[in] value_size - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_bytes(CassStatement* statement, - size_t index, - const cass_byte_t* value, - size_t value_size); - -/** - * Binds a "blob", "varint" or "custom" to all the values with the - * specified name. - * - * This can only be used with statements created by - * cass_prepared_bind() when using Cassandra 2.0 or earlier. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] value The value is copied into the statement object; the - * memory pointed to by this parameter can be freed after this call. - * @param[in] value_size - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_bytes_by_name(CassStatement* statement, - const char* name, - const cass_byte_t* value, - size_t value_size); - -/** - * Same as cass_statement_bind_bytes_by_name(), but with lengths for string - * parameters. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] name_length - * @param[in] value - * @param[in] value_size - * @return same as cass_statement_bind_bytes_by_name() - * - * @see cass_statement_bind_bytes_by_name() - */ -CASS_EXPORT CassError -cass_statement_bind_bytes_by_name_n(CassStatement* statement, - const char* name, - size_t name_length, - const cass_byte_t* value, - size_t value_size); - -/** - * Binds a "custom" to a query or bound statement at the specified index. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] index - * @param[in] class_name - * @param[in] value The value is copied into the statement object; the - * memory pointed to by this parameter can be freed after this call. - * @param[in] value_size - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_custom(CassStatement* statement, - size_t index, - const char* class_name, - const cass_byte_t* value, - size_t value_size); -/** - * Same as cass_statement_bind_custom(), but with lengths for string - * parameters. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] index - * @param[in] class_name - * @param[in] class_name_length - * @param[in] value The value is copied into the statement object; the - * memory pointed to by this parameter can be freed after this call. - * @param[in] value_size - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_custom_n(CassStatement* statement, - size_t index, - const char* class_name, - size_t class_name_length, - const cass_byte_t* value, - size_t value_size); - -/** - * Binds a "custom" to all the values with the specified name. - * - * This can only be used with statements created by - * cass_prepared_bind() when using Cassandra 2.0 or earlier. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] class_name - * @param[in] value The value is copied into the statement object; the - * memory pointed to by this parameter can be freed after this call. - * @param[in] value_size - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_custom_by_name(CassStatement* statement, - const char* name, - const char* class_name, - const cass_byte_t* value, - size_t value_size); - -/** - * Same as cass_statement_bind_custom_by_name(), but with lengths for string - * parameters. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] name_length - * @param[in] class_name - * @param[in] class_name_length - * @param[in] value - * @param[in] value_size - * @return same as cass_statement_bind_custom_by_name() - * - * @see cass_statement_bind_custom_by_name() - */ -CASS_EXPORT CassError -cass_statement_bind_custom_by_name_n(CassStatement* statement, - const char* name, - size_t name_length, - const char* class_name, - size_t class_name_length, - const cass_byte_t* value, - size_t value_size); - -/** - * Binds a "uuid" or "timeuuid" to a query or bound statement at the specified index. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] index - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_uuid(CassStatement* statement, - size_t index, - CassUuid value); - -/** - * Binds a "uuid" or "timeuuid" to all the values - * with the specified name. - * - * This can only be used with statements created by - * cass_prepared_bind() when using Cassandra 2.0 or earlier. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_uuid_by_name(CassStatement* statement, - const char* name, - CassUuid value); - -/** - * Same as cass_statement_bind_uuid_by_name(), but with lengths for string - * parameters. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] name_length - * @param[in] value - * @return same as cass_statement_bind_uuid_by_name() - * - * @see cass_statement_bind_uuid_by_name() - */ -CASS_EXPORT CassError -cass_statement_bind_uuid_by_name_n(CassStatement* statement, - const char* name, - size_t name_length, - CassUuid value); - -/** - * Binds an "inet" to a query or bound statement at the specified index. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] index - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_inet(CassStatement* statement, - size_t index, - CassInet value); - -/** - * Binds an "inet" to all the values with the specified name. - * - * This can only be used with statements created by - * cass_prepared_bind() when using Cassandra 2.0 or earlier. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_inet_by_name(CassStatement* statement, - const char* name, - CassInet value); - -/** - * Same as cass_statement_bind_inet_by_name(), but with lengths for string - * parameters. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] name_length - * @param[in] value - * @return same as cass_statement_bind_inet_by_name() - * - * @see cass_statement_bind_inet_by_name() - */ -CASS_EXPORT CassError -cass_statement_bind_inet_by_name_n(CassStatement* statement, - const char* name, - size_t name_length, - CassInet value); - -/** - * Bind a "decimal" to a query or bound statement at the specified index. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] index - * @param[in] varint The value is copied into the statement object; the - * memory pointed to by this parameter can be freed after this call. - * @param[in] varint_size - * @param[in] scale - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_decimal(CassStatement* statement, - size_t index, - const cass_byte_t* varint, - size_t varint_size, - cass_int32_t scale); - -/** - * Binds a "decimal" to all the values with the specified name. - * - * This can only be used with statements created by - * cass_prepared_bind() when using Cassandra 2.0 or earlier. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] varint The value is copied into the statement object; the - * memory pointed to by this parameter can be freed after this call. - * @param[in] varint_size - * @param[in] scale - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_decimal_by_name(CassStatement* statement, - const char* name, - const cass_byte_t* varint, - size_t varint_size, - cass_int32_t scale); - -/** - * Same as cass_statement_bind_decimal_by_name(), but with lengths for string - * parameters. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] name_length - * @param[in] varint - * @param[in] varint_size - * @param[in] scale - * @return same as cass_statement_bind_decimal_by_name() - * - * @see cass_statement_bind_decimal_by_name() - */ -CASS_EXPORT CassError -cass_statement_bind_decimal_by_name_n(CassStatement* statement, - const char* name, - size_t name_length, - const cass_byte_t* varint, - size_t varint_size, - cass_int32_t scale); - -/** - * Binds a "duration" to a query or bound statement at the specified index. - * - * @cassandra{3.10+} - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] index - * @param[in] months - * @param[in] days - * @param[in] nanos - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_duration(CassStatement* statement, - size_t index, - cass_int32_t months, - cass_int32_t days, - cass_int64_t nanos); - -/** - * Binds a "duration" to all the values with the specified name. - * - * @cassandra{3.10+} - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] months - * @param[in] days - * @param[in] nanos - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_duration_by_name(CassStatement* statement, - const char* name, - cass_int32_t months, - cass_int32_t days, - cass_int64_t nanos); - -/** - * Same as cass_statement_bind_duration_by_name(), but with lengths for string - * parameters. - * - * @cassandra{3.10+} - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] name_length - * @param[in] months - * @param[in] days - * @param[in] nanos - * @return same as cass_statement_bind_duration_by_name() - * - * @see cass_statement_bind_duration_by_name() - */ -CASS_EXPORT CassError -cass_statement_bind_duration_by_name_n(CassStatement* statement, - const char* name, - size_t name_length, - cass_int32_t months, - cass_int32_t days, - cass_int64_t nanos); - -/** - * Bind a "list", "map" or "set" to a query or bound statement at the - * specified index. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] index - * @param[in] collection The collection can be freed after this call. - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_collection(CassStatement* statement, - size_t index, - const CassCollection* collection); - -/** - * Bind a "list", "map" or "set" to all the values with the - * specified name. - * - * This can only be used with statements created by - * cass_prepared_bind() when using Cassandra 2.0 or earlier. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] collection The collection can be freed after this call. - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_collection_by_name(CassStatement* statement, - const char* name, - const CassCollection* collection); - -/** - * Same as cass_statement_bind_collection_by_name(), but with lengths for string - * parameters. - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] name_length - * @param[in] collection - * @return same as cass_statement_bind_collection_by_name() - * - * @see cass_statement_bind_collection_by_name() - */ -CASS_EXPORT CassError -cass_statement_bind_collection_by_name_n(CassStatement* statement, - const char* name, - size_t name_length, - const CassCollection* collection); - -/** - * Bind a "tuple" to a query or bound statement at the specified index. - * - * @cassandra{2.1+} - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] index - * @param[in] tuple The tuple can be freed after this call. - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_tuple(CassStatement* statement, - size_t index, - const CassTuple* tuple); - -/** - * Bind a "tuple" to all the values with the specified name. - * - * @cassandra{2.1+} - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] tuple The tuple can be freed after this call. - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_tuple_by_name(CassStatement* statement, - const char* name, - const CassTuple* tuple); - -/** - * Same as cass_statement_bind_tuple_by_name(), but with lengths for string - * parameters. - * - * @cassandra{2.1+} - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] name_length - * @param[in] tuple - * @return same as cass_statement_bind_tuple_by_name() - * - * @see cass_statement_bind_tuple_by_name() - */ -CASS_EXPORT CassError -cass_statement_bind_tuple_by_name_n(CassStatement* statement, - const char* name, - size_t name_length, - const CassTuple* tuple); - -/** - * Bind a user defined type to a query or bound statement at the - * specified index. - * - * @cassandra{2.1+} - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] index - * @param[in] user_type The user type can be freed after this call. - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_user_type(CassStatement* statement, - size_t index, - const CassUserType* user_type); -/** - * Bind a user defined type to a query or bound statement with the - * specified name. - * - * @cassandra{2.1+} - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] user_type The user type can be freed after this call. - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_statement_bind_user_type_by_name(CassStatement* statement, - const char* name, - const CassUserType* user_type); - -/** - * Same as cass_statement_bind_user_type_by_name(), but with lengths for string - * parameters. - * - * @cassandra{2.1+} - * - * @public @memberof CassStatement - * - * @param[in] statement - * @param[in] name - * @param[in] name_length - * @param[in] user_type - * @return same as cass_statement_bind_user_type_by_name() - * - * @see cass_statement_bind_collection_by_name() - */ -CASS_EXPORT CassError -cass_statement_bind_user_type_by_name_n(CassStatement* statement, - const char* name, - size_t name_length, - const CassUserType* user_type); - -/*********************************************************************************** - * - * Prepared - * - ***********************************************************************************/ - -/** - * Frees a prepared instance. - * - * @public @memberof CassPrepared - * - * @param[in] prepared - */ -CASS_EXPORT void -cass_prepared_free(const CassPrepared* prepared); - -/** - * Creates a bound statement from a pre-prepared statement. - * - * @public @memberof CassPrepared - * - * @param[in] prepared - * @return Returns a bound statement that must be freed. - * - * @see cass_statement_free() - */ -CASS_EXPORT CassStatement* -cass_prepared_bind(const CassPrepared* prepared); - -/** - * Gets the name of a parameter at the specified index. - * - * @public @memberof CassPrepared - * - * @param[in] prepared - * @param[in] index - * @param[out] name - * @param[out] name_length - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_prepared_parameter_name(const CassPrepared* prepared, - size_t index, - const char** name, - size_t* name_length); - -/** - * Gets the data type of a parameter at the specified index. - * - * @public @memberof CassPrepared - * - * @param[in] prepared - * @param[in] index - * @return Returns a reference to the data type of the parameter. Do not free - * this reference as it is bound to the lifetime of the prepared. - */ -CASS_EXPORT const CassDataType* -cass_prepared_parameter_data_type(const CassPrepared* prepared, - size_t index); - -/** - * Gets the data type of a parameter for the specified name. - * - * @public @memberof CassPrepared - * - * @param[in] prepared - * @param[in] name - * @return Returns a reference to the data type of the parameter. Do not free - * this reference as it is bound to the lifetime of the prepared. - */ -CASS_EXPORT const CassDataType* -cass_prepared_parameter_data_type_by_name(const CassPrepared* prepared, - const char* name); - -/** - * Same as cass_prepared_parameter_data_type_by_name(), but with lengths for string - * parameters. - * - * @public @memberof CassPrepared - * - * @param[in] prepared - * @param[in] name - * @param[in] name_length - * @return Returns a reference to the data type of the parameter. Do not free - * this reference as it is bound to the lifetime of the prepared. - * - * @see cass_prepared_parameter_data_type_by_name() - */ -CASS_EXPORT const CassDataType* -cass_prepared_parameter_data_type_by_name_n(const CassPrepared* prepared, - const char* name, - size_t name_length); - -/*********************************************************************************** - * - * Batch - * - ***********************************************************************************/ - -/** - * Creates a new batch statement with batch type. - * - * @cassandra{2.0+} - * - * @public @memberof CassBatch - * - * @param[in] type - * @return Returns a batch statement that must be freed. - * - * @see cass_batch_free() - */ -CASS_EXPORT CassBatch* -cass_batch_new(CassBatchType type); - -/** - * Frees a batch instance. Batches can be immediately freed after being - * executed. - * - * @cassandra{2.0+} - * - * @public @memberof CassBatch - * - * @param[in] batch - */ -CASS_EXPORT void -cass_batch_free(CassBatch* batch); - -/** - * Sets the batch's keyspace. When using protocol v5 or greater it overrides - * the session's keyspace for the batch. - * - * Note: If not set explicitly then the batch will inherit the keyspace - * of the first child statement with a non-empty keyspace. - * - * @public @memberof CassBatch - * - * @param[in] batch - * @param[in] keyspace - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_batch_set_keyspace(CassBatch* batch, - const char* keyspace); - -/** - * Same as cass_batch_set_keyspace(), but with lengths for string - * parameters. - * - * @public @memberof CassBatch - * - * @param[in] batch - * @param[in] keyspace - * @param[in] keyspace_length - * @return same as cass_batch_set_keyspace() - * - * @see cass_batch_set_keyspace() - */ -CASS_EXPORT CassError -cass_batch_set_keyspace_n(CassBatch* batch, - const char* keyspace, - size_t keyspace_length); - -/** - * Sets the batch's consistency level - * - * @cassandra{2.0+} - * - * @public @memberof CassBatch - * - * @param[in] batch - * @param[in] consistency The batch's write consistency. - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_batch_set_consistency(CassBatch* batch, - CassConsistency consistency); - -/** - * Sets the batch's serial consistency level. - * - * @cassandra{2.0+} - * - * Default: Not set - * - * @public @memberof CassBatch - * - * @param[in] batch - * @param[in] serial_consistency - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_batch_set_serial_consistency(CassBatch* batch, - CassConsistency serial_consistency); - -/** - * Sets the batch's timestamp. - * - * @cassandra{2.1+} - * - * @public @memberof CassBatch - * - * @param[in] batch - * @param[in] timestamp - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_batch_set_timestamp(CassBatch* batch, - cass_int64_t timestamp); - -/** - * Sets the batch's timeout for waiting for a response from a node. - * - * Default: Disabled (use the cluster-level request timeout) - * - * @public @memberof CassBatch - * - * @param[in] batch - * @param[in] timeout_ms Request timeout in milliseconds. Use 0 for no timeout - * or CASS_UINT64_MAX to disable (to use the cluster-level request timeout). - * @return CASS_OK if successful, otherwise an error occurred. - * - * @see cass_cluster_set_request_timeout() - */ -CASS_EXPORT CassError -cass_batch_set_request_timeout(CassBatch* batch, - cass_uint64_t timeout_ms); - -/** - * Sets whether the statements in a batch are idempotent. Idempotent batches - * are able to be automatically retried after timeouts/errors and can be - * speculatively executed. - * - * @public @memberof CassBatch - * - * @param[in] batch - * @param[in] is_idempotent - * @return CASS_OK if successful, otherwise an error occurred. - * - * @see cass_cluster_set_constant_speculative_execution_policy() - * @see cass_execution_profile_set_constant_speculative_execution_policy() - */ -CASS_EXPORT CassError -cass_batch_set_is_idempotent(CassBatch* batch, - cass_bool_t is_idempotent); - -/** - * Sets the batch's retry policy. - * - * @cassandra{2.0+} - * - * @public @memberof CassBatch - * - * @param[in] batch - * @param[in] retry_policy - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_batch_set_retry_policy(CassBatch* batch, - CassRetryPolicy* retry_policy); - -/** - * Sets the batch's custom payload. - * - * @cassandra{2.2+} - * - * @public @memberof CassBatch - * - * @param[in] batch - * @param[in] payload - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_batch_set_custom_payload(CassBatch* batch, - const CassCustomPayload* payload); - -/** - * Sets whether the batch should use tracing. - * - * @cassandra{2.2+} - * - * @public @memberof CassStatement - * - * @param[in] batch - * @param[in] enabled - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_batch_set_tracing(CassBatch* batch, - cass_bool_t enabled); - -/** - * Adds a statement to a batch. - * - * @cassandra{2.0+} - * - * @public @memberof CassBatch - * - * @param[in] batch - * @param[in] statement - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_batch_add_statement(CassBatch* batch, - CassStatement* statement); - -/** - * Sets the execution profile to execute the batch with. - * - * Note: NULL or empty string will clear execution profile from batch - * - * @public @memberof CassBatch - * - * @param[in] batch - * @param[in] name - * @return CASS_OK if successful, otherwise an error occurred. - * - * @see cass_cluster_set_execution_profile() - */ -CASS_EXPORT CassError -cass_batch_set_execution_profile(CassBatch* batch, - const char* name); - -/** - * Same as cass_batch_set_execution_profile(), but with lengths for string - * parameters. - * - * @public @memberof CassBatch - * - * @param[in] batch - * @param[in] name - * @param[in] name_length - * @return CASS_OK if successful, otherwise an error occurred. - * - * @see cass_batch_set_execution_profile() - */ -CASS_EXPORT CassError -cass_batch_set_execution_profile_n(CassBatch* batch, - const char* name, - size_t name_length); - -/*********************************************************************************** - * - * Data type - * - ***********************************************************************************/ - -/** - * Creates a new data type with value type. - * - * @public @memberof CassDataType - * - * @param[in] type - * @return Returns a data type that must be freed. - * - * @see cass_data_type_free() - */ -CASS_EXPORT CassDataType* -cass_data_type_new(CassValueType type); - -/** - * Creates a new data type from an existing data type. - * - * @public @memberof CassDataType - * - * @param[in] data_type - * @return Returns a data type that must be freed. - * - * @see cass_data_type_free() - */ -CASS_EXPORT CassDataType* -cass_data_type_new_from_existing(const CassDataType* data_type); - -/** - * Creates a new tuple data type. - * - * @cassandra{2.1+} - * - * @public @memberof CassDataType - * - * @param[in] item_count The number of items in the tuple - * @return Returns a data type that must be freed. - * - * @see cass_data_type_free() - */ -CASS_EXPORT CassDataType* -cass_data_type_new_tuple(size_t item_count); - -/** - * Creates a new UDT (user defined type) data type. - * - * @cassandra{2.1+} - * - * @public @memberof CassDataType - * - * @param[in] field_count The number of fields in the UDT - * @return Returns a data type that must be freed. - * - * @see cass_data_type_free() - */ -CASS_EXPORT CassDataType* -cass_data_type_new_udt(size_t field_count); - -/** - * Frees a data type instance. - * - * @public @memberof CassDataType - * - * @param[in] data_type - */ -CASS_EXPORT void -cass_data_type_free(CassDataType* data_type); - -/** - * Gets the value type of the specified data type. - * - * @param[in] data_type - * @return The value type - */ -CASS_EXPORT CassValueType -cass_data_type_type(const CassDataType* data_type); - -/** - * Gets whether a data type is frozen. - * - * @cassandra{2.1+} - * - * @param[in] data_type - * @return cass_true if the data type is frozen, otherwise cass_false. - */ -CASS_EXPORT cass_bool_t -cass_data_type_is_frozen(const CassDataType* data_type); - -/** - * Gets the type name of a UDT data type. - * - * Note: Only valid for UDT data types. - * - * @param[in] data_type - * @param[out] type_name - * @param[out] type_name_length - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_data_type_type_name(const CassDataType* data_type, - const char** type_name, - size_t* type_name_length); - -/** - * Sets the type name of a UDT data type. - * - * Note: Only valid for UDT data types. - * - * @param[in] data_type - * @param[in] type_name - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_data_type_set_type_name(CassDataType* data_type, - const char* type_name); - -/** - * Same as cass_data_type_set_type_name(), but with lengths for string - * parameters. - * - * @public @memberof CassDataType - * - * @param[in] data_type - * @param[in] type_name - * @param[in] type_name_length - * @return Returns a data type that must be freed. - */ -CASS_EXPORT CassError -cass_data_type_set_type_name_n(CassDataType* data_type, - const char* type_name, - size_t type_name_length); - -/** - * Gets the type name of a UDT data type. - * - * Note: Only valid for UDT data types. - * - * @cassandra{2.1+} - * - * @param[in] data_type - * @param[out] keyspace - * @param[out] keyspace_length - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_data_type_keyspace(const CassDataType* data_type, - const char** keyspace, - size_t* keyspace_length); - -/** - * Sets the keyspace of a UDT data type. - * - * Note: Only valid for UDT data types. - * - * @cassandra{2.1+} - * - * @param[in] data_type - * @param[in] keyspace - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_data_type_set_keyspace(CassDataType* data_type, - const char* keyspace); - -/** - * Same as cass_data_type_set_keyspace(), but with lengths for string - * parameters. - * - * @cassandra{2.1+} - * - * @public @memberof CassDataType - * - * @param[in] data_type - * @param[in] keyspace - * @param[in] keyspace_length - * @return Returns a data type that must be freed. - */ -CASS_EXPORT CassError -cass_data_type_set_keyspace_n(CassDataType* data_type, - const char* keyspace, - size_t keyspace_length); - -/** - * Gets the class name of a custom data type. - * - * Note: Only valid for custom data types. - * - * @param[in] data_type - * @param[out] class_name - * @param[out] class_name_length - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_data_type_class_name(const CassDataType* data_type, - const char** class_name, - size_t* class_name_length); - -/** - * Sets the class name of a custom data type. - * - * Note: Only valid for custom data types. - * - * @param[in] data_type - * @param[in] class_name - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_data_type_set_class_name(CassDataType* data_type, - const char* class_name); - -/** - * Same as cass_data_type_set_class_name(), but with lengths for string - * parameters. - * - * @public @memberof CassDataType - * - * @param[in] data_type - * @param[in] class_name - * @param[in] class_name_length - * @return Returns a data type that must be freed. - */ -CASS_EXPORT CassError -cass_data_type_set_class_name_n(CassDataType* data_type, - const char* class_name, - size_t class_name_length); - -/** - * Gets the sub-data type count of a UDT (user defined type), tuple - * or collection. - * - * Note: Only valid for UDT, tuple and collection data types. - * - * @param[in] data_type - * @return Returns the number of sub-data types - */ -CASS_EXPORT size_t -cass_data_type_sub_type_count(const CassDataType* data_type); - -/** - * @deprecated Use cass_data_type_sub_type_count() - */ -CASS_EXPORT CASS_DEPRECATED(size_t -cass_data_sub_type_count(const CassDataType* data_type)); - -/** - * Gets the sub-data type count of a UDT (user defined type), tuple - * or collection. - * - * Note: Only valid for UDT, tuple and collection data types. - * - * @param[in] data_type - * @return Returns the number of sub-data types - */ - -/** - * Gets the sub-data type of a UDT (user defined type), tuple or collection at - * the specified index. - * - * Note: Only valid for UDT, tuple and collection data types. - * - * @param[in] data_type - * @param[in] index - * @return Returns a reference to a child data type. Do not free this - * reference as it is bound to the lifetime of the parent data type. NULL - * is returned if the index is out of range. - */ -CASS_EXPORT const CassDataType* -cass_data_type_sub_data_type(const CassDataType* data_type, - size_t index); - -/** - * Gets the sub-data type of a UDT (user defined type) at the specified index. - * - * Note: Only valid for UDT data types. - * - * @cassandra{2.1+} - * - * @param[in] data_type - * @param[in] name - * @return Returns a reference to a child data type. Do not free this - * reference as it is bound to the lifetime of the parent data type. NULL - * is returned if the name doesn't exist. - */ -CASS_EXPORT const CassDataType* -cass_data_type_sub_data_type_by_name(const CassDataType* data_type, - const char* name); - -/** - * Same as cass_data_type_sub_data_type_by_name(), but with lengths for string - * parameters. - * - * @cassandra{2.1+} - * - * @public @memberof CassDataType - * - * @param[in] data_type - * @param[in] name - * @param[in] name_length - * @return Returns a reference to a child data type. Do not free this - * reference as it is bound to the lifetime of the parent data type. NULL - * is returned if the name doesn't exist. - */ -CASS_EXPORT const CassDataType* -cass_data_type_sub_data_type_by_name_n(const CassDataType* data_type, - const char* name, - size_t name_length); - -/** - * Gets the sub-type name of a UDT (user defined type) at the specified index. - * - * @cassandra{2.1+} - * - * Note: Only valid for UDT data types. - * - * @param[in] data_type - * @param[in] index - * @param[out] name - * @param[out] name_length - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_data_type_sub_type_name(const CassDataType* data_type, - size_t index, - const char** name, - size_t* name_length); - -/** - * Adds a sub-data type to a tuple or collection. - * - * Note: Only valid for tuple and collection data types. - * - * @param[in] data_type - * @param[in] sub_data_type - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_data_type_add_sub_type(CassDataType* data_type, - const CassDataType* sub_data_type); - -/** - * Adds a sub-data type to a UDT (user defined type). - * - * Note: Only valid for UDT data types. - * - * @cassandra{2.1+} - * - * @param[in] data_type - * @param[in] name - * @param[in] sub_data_type - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_data_type_add_sub_type_by_name(CassDataType* data_type, - const char* name, - const CassDataType* sub_data_type); - -/** - * Same as cass_data_type_add_sub_type_by_name(), but with lengths for string - * parameters. - * - * Note: Only valid for UDT data types. - * - * @cassandra{2.1+} - * - * @param[in] data_type - * @param[in] name - * @param[in] name_length - * @param[in] sub_data_type - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_data_type_add_sub_type_by_name_n(CassDataType* data_type, - const char* name, - size_t name_length, - const CassDataType* sub_data_type); - -/** - * Adds a sub-data type to a tuple or collection using a value type. - * - * Note: Only valid for tuple and collection data types. - * - * @param[in] data_type - * @param[in] sub_value_type - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_data_type_add_sub_value_type(CassDataType* data_type, - CassValueType sub_value_type); - - -/** - * Adds a sub-data type to a UDT (user defined type) using a value type. - * - * Note: Only valid for UDT data types. - * - * @cassandra{2.1+} - * - * @param[in] data_type - * @param[in] name - * @param[in] sub_value_type - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_data_type_add_sub_value_type_by_name(CassDataType* data_type, - const char* name, - CassValueType sub_value_type); - -/** - * Same as cass_data_type_add_sub_value_type_by_name(), but with lengths for string - * parameters. - * - * Note: Only valid for UDT data types. - * - * @cassandra{2.1+} - * - * @param[in] data_type - * @param[in] name - * @param[in] name_length - * @param[in] sub_value_type - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_data_type_add_sub_value_type_by_name_n(CassDataType* data_type, - const char* name, - size_t name_length, - CassValueType sub_value_type); - -/*********************************************************************************** - * - * Collection - * - ***********************************************************************************/ - -/** - * Creates a new collection. - * - * @public @memberof CassCollection - * - * @param[in] type - * @param[in] item_count The approximate number of items in the collection. - * @return Returns a collection that must be freed. - * - * @see cass_collection_free() - */ -CASS_EXPORT CassCollection* -cass_collection_new(CassCollectionType type, - size_t item_count); - -/** - * Creates a new collection from an existing data type. - * - * @public @memberof CassCollection - * - * @param[in] data_type - * @param[in] item_count The approximate number of items in the collection. - * @return Returns a collection that must be freed. - * - * @see cass_collection_free(); - */ -CASS_EXPORT CassCollection* -cass_collection_new_from_data_type(const CassDataType* data_type, - size_t item_count); - -/** - * Frees a collection instance. - * - * @public @memberof CassCollection - * - * @param[in] collection - */ -CASS_EXPORT void -cass_collection_free(CassCollection* collection); - -/** - * Gets the data type of a collection. - * - * @param[in] collection - * @return Returns a reference to the data type of the collection. Do not free - * this reference as it is bound to the lifetime of the collection. - */ -CASS_EXPORT const CassDataType* -cass_collection_data_type(const CassCollection* collection); - -/** - * Appends a "tinyint" to the collection. - * - * @cassandra{2.2+} - * - * @public @memberof CassCollection - * - * @param[in] collection - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_collection_append_int8(CassCollection* collection, - cass_int8_t value); - -/** - * Appends an "smallint" to the collection. - * - * @cassandra{2.2+} - * - * @public @memberof CassCollection - * - * @param[in] collection - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_collection_append_int16(CassCollection* collection, - cass_int16_t value); - -/** - * Appends an "int" to the collection. - * - * @public @memberof CassCollection - * - * @param[in] collection - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_collection_append_int32(CassCollection* collection, - cass_int32_t value); - -/** - * Appends a "date" to the collection. - * - * @cassandra{2.2+} - * - * @public @memberof CassCollection - * - * @param[in] collection - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_collection_append_uint32(CassCollection* collection, - cass_uint32_t value); - - -/** - * Appends a "bigint", "counter", "timestamp" or "time" to the - * collection. - * - * @public @memberof CassCollection - * - * @param[in] collection - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_collection_append_int64(CassCollection* collection, - cass_int64_t value); - -/** - * Appends a "float" to the collection. - * - * @public @memberof CassCollection - * - * @param[in] collection - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_collection_append_float(CassCollection* collection, - cass_float_t value); - -/** - * Appends a "double" to the collection. - * - * @public @memberof CassCollection - * - * @param[in] collection - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_collection_append_double(CassCollection* collection, - cass_double_t value); - -/** - * Appends a "boolean" to the collection. - * - * @public @memberof CassCollection - * - * @param[in] collection - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_collection_append_bool(CassCollection* collection, - cass_bool_t value); - -/** - * Appends an "ascii", "text" or "varchar" to the collection. - * - * @public @memberof CassCollection - * - * @param[in] collection - * @param[in] value The value is copied into the collection object; the - * memory pointed to by this parameter can be freed after this call. - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_collection_append_string(CassCollection* collection, - const char* value); - - -/** - * Same as cass_collection_append_string(), but with lengths for string - * parameters. - * - * @public @memberof CassCollection - * - * @param[in] collection - * @param[in] value - * @param[in] value_length - * @return same as cass_collection_append_string() - * - * @see cass_collection_append_string(); - */ -CASS_EXPORT CassError -cass_collection_append_string_n(CassCollection* collection, - const char* value, - size_t value_length); - -/** - * Appends a "blob", "varint" or "custom" to the collection. - * - * @public @memberof CassCollection - * - * @param[in] collection - * @param[in] value The value is copied into the collection object; the - * memory pointed to by this parameter can be freed after this call. - * @param[in] value_size - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_collection_append_bytes(CassCollection* collection, - const cass_byte_t* value, - size_t value_size); - -/** - * Appends a "custom" to the collection. - * - * @public @memberof CassCollection - * - * @param[in] collection - * @param[in] class_name - * @param[in] value The value is copied into the collection object; the - * memory pointed to by this parameter can be freed after this call. - * @param[in] value_size - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_collection_append_custom(CassCollection* collection, - const char* class_name, - const cass_byte_t* value, - size_t value_size); - -/** - * Same as cass_collection_append_custom(), but with lengths for string - * parameters. - * - * @public @memberof CassCollection - * - * @param[in] collection - * @param[in] class_name - * @param[in] class_name_length - * @param[in] value - * @param[in] value_size - * @return same as cass_collection_append_custom() - * - * @see cass_collection_append_custom() - */ -CASS_EXPORT CassError -cass_collection_append_custom_n(CassCollection* collection, - const char* class_name, - size_t class_name_length, - const cass_byte_t* value, - size_t value_size); - -/** - * Appends a "uuid" or "timeuuid" to the collection. - * - * @public @memberof CassCollection - * - * @param[in] collection - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_collection_append_uuid(CassCollection* collection, - CassUuid value); - -/** - * Appends an "inet" to the collection. - * - * @public @memberof CassCollection - * - * @param[in] collection - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_collection_append_inet(CassCollection* collection, - CassInet value); - -/** - * Appends a "decimal" to the collection. - * - * @public @memberof CassCollection - * - * @param[in] collection - * @param[in] varint The value is copied into the collection object; the - * memory pointed to by this parameter can be freed after this call. - * @param[in] varint_size - * @param[in] scale - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_collection_append_decimal(CassCollection* collection, - const cass_byte_t* varint, - size_t varint_size, - cass_int32_t scale); - -/** - * Appends a "duration" to the collection. - * - * @cassandra{3.10+} - * - * @public @memberof CassCollection - * - * @param[in] collection - * @param[in] months - * @param[in] days - * @param[in] nanos - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_collection_append_duration(CassCollection* collection, - cass_int32_t months, - cass_int32_t days, - cass_int64_t nanos); - -/** - * Appends a "list", "map" or "set" to the collection. - * - * @cassandra{2.1+} - * - * @public @memberof CassCollection - * - * @param[in] collection - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_collection_append_collection(CassCollection* collection, - const CassCollection* value); - -/** - * Appends a "tuple" to the collection. - * - * @cassandra{2.1+} - * - * @public @memberof CassCollection - * - * @param[in] collection - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_collection_append_tuple(CassCollection* collection, - const CassTuple* value); - -/** - * Appends a "udt" to the collection. - * - * @cassandra{2.1+} - * - * @public @memberof CassCollection - * - * @param[in] collection - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_collection_append_user_type(CassCollection* collection, - const CassUserType* value); - -/*********************************************************************************** - * - * Tuple - * - ***********************************************************************************/ - -/** - * Creates a new tuple. - * - * @cassandra{2.1+} - * - * @public @memberof CassTuple - * - * @param[in] item_count The number of items in the tuple. - * @return Returns a tuple that must be freed. - * - * @see cass_tuple_free() - */ -CASS_EXPORT CassTuple* -cass_tuple_new(size_t item_count); - -/** - * Creates a new tuple from an existing data type. - * - * @cassandra{2.1+} - * - * @public @memberof CassTuple - * - * @param[in] data_type - * @return Returns a tuple that must be freed. - * - * @see cass_tuple_free(); - */ -CASS_EXPORT CassTuple* -cass_tuple_new_from_data_type(const CassDataType* data_type); - -/** - * Frees a tuple instance. - * - * @cassandra{2.1+} - * - * @public @memberof CassTuple - * - * @param[in] tuple - */ -CASS_EXPORT void -cass_tuple_free(CassTuple* tuple); - -/** - * Gets the data type of a tuple. - * - * @cassandra{2.1+} - * - * @param[in] tuple - * @return Returns a reference to the data type of the tuple. Do not free - * this reference as it is bound to the lifetime of the tuple. - */ -CASS_EXPORT const CassDataType* -cass_tuple_data_type(const CassTuple* tuple); - -/** - * Sets an null in a tuple at the specified index. - * - * @cassandra{2.1+} - * - * @public @memberof CassTuple - * - * @param[in] tuple - * @param[in] index - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_tuple_set_null(CassTuple* tuple, size_t index); - -/** - * Sets a "tinyint" in a tuple at the specified index. - * - * @cassandra{2.2+} - * - * @public @memberof CassTuple - * - * @param[in] tuple - * @param[in] index - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_tuple_set_int8(CassTuple* tuple, - size_t index, - cass_int8_t value); - -/** - * Sets an "smallint" in a tuple at the specified index. - * - * @cassandra{2.2+} - * - * @public @memberof CassTuple - * - * @param[in] tuple - * @param[in] index - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_tuple_set_int16(CassTuple* tuple, - size_t index, - cass_int16_t value); - -/** - * Sets an "int" in a tuple at the specified index. - * - * @cassandra{2.1+} - * - * @public @memberof CassTuple - * - * @param[in] tuple - * @param[in] index - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_tuple_set_int32(CassTuple* tuple, - size_t index, - cass_int32_t value); - -/** - * Sets a "date" in a tuple at the specified index. - * - * @cassandra{2.2+} - * - * @public @memberof CassTuple - * - * @param[in] tuple - * @param[in] index - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_tuple_set_uint32(CassTuple* tuple, - size_t index, - cass_uint32_t value); - -/** - * Sets a "bigint", "counter", "timestamp" or "time" in a tuple at the - * specified index. - * - * @cassandra{2.1+} - * - * @public @memberof CassTuple - * - * @param[in] tuple - * @param[in] index - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_tuple_set_int64(CassTuple* tuple, - size_t index, - cass_int64_t value); - -/** - * Sets a "float" in a tuple at the specified index. - * - * @cassandra{2.1+} - * - * @public @memberof CassTuple - * - * @param[in] tuple - * @param[in] index - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_tuple_set_float(CassTuple* tuple, - size_t index, - cass_float_t value); - -/** - * Sets a "double" in a tuple at the specified index. - * - * @cassandra{2.1+} - * - * @public @memberof CassTuple - * - * @param[in] tuple - * @param[in] index - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_tuple_set_double(CassTuple* tuple, - size_t index, - cass_double_t value); - -/** - * Sets a "boolean" in a tuple at the specified index. - * - * @cassandra{2.1+} - * - * @public @memberof CassTuple - * - * @param[in] tuple - * @param[in] index - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_tuple_set_bool(CassTuple* tuple, - size_t index, - cass_bool_t value); - -/** - * Sets an "ascii", "text" or "varchar" in a tuple at the specified index. - * - * @cassandra{2.1+} - * - * @public @memberof CassTuple - * - * @param[in] tuple - * @param[in] index - * @param[in] value The value is copied into the tuple object; the - * memory pointed to by this parameter can be freed after this call. - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_tuple_set_string(CassTuple* tuple, - size_t index, - const char* value); - -/** - * Same as cass_tuple_set_string(), but with lengths for string - * parameters. - * - * @cassandra{2.1+} - * - * @public @memberof CassTuple - * - * @param[in] tuple - * @param[in] index - * @param[in] value - * @param[in] value_length - * @return same as cass_tuple_set_string() - * - * @see cass_tuple_set_string(); - */ -CASS_EXPORT CassError -cass_tuple_set_string_n(CassTuple* tuple, - size_t index, - const char* value, - size_t value_length); - -/** - * Sets a "blob", "varint" or "custom" in a tuple at the specified index. - * - * @cassandra{2.1+} - * - * @public @memberof CassTuple - * - * @param[in] tuple - * @param[in] index - * @param[in] value The value is copied into the tuple object; the - * memory pointed to by this parameter can be freed after this call. - * @param[in] value_size - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_tuple_set_bytes(CassTuple* tuple, - size_t index, - const cass_byte_t* value, - size_t value_size); - -/** - * Sets a "custom" in a tuple at the specified index. - * - * @public @memberof CassTuple - * - * @param[in] tuple - * @param[in] index - * @param[in] class_name - * @param[in] value The value is copied into the tuple object; the - * memory pointed to by this parameter can be freed after this call. - * @param[in] value_size - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_tuple_set_custom(CassTuple* tuple, - size_t index, - const char* class_name, - const cass_byte_t* value, - size_t value_size); - -/** - * Same as cass_tuple_set_custom(), but with lengths for string - * parameters. - * - * @public @memberof CassTuple - * - * @param[in] tuple - * @param[in] index - * @param[in] class_name - * @param[in] class_name_length - * @param[in] value - * @param[in] value_size - * @return same as cass_tuple_set_custom() - * - * @see cass_tuple_set_custom() - */ -CASS_EXPORT CassError -cass_tuple_set_custom_n(CassTuple* tuple, - size_t index, - const char* class_name, - size_t class_name_length, - const cass_byte_t* value, - size_t value_size); - -/** - * Sets a "uuid" or "timeuuid" in a tuple at the specified index. - * - * @cassandra{2.1+} - * - * @public @memberof CassTuple - * - * @param[in] tuple - * @param[in] index - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_tuple_set_uuid(CassTuple* tuple, - size_t index, - CassUuid value); - -/** - * Sets an "inet" in a tuple at the specified index. - * - * @cassandra{2.1+} - * - * @public @memberof CassTuple - * - * @param[in] tuple - * @param[in] index - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_tuple_set_inet(CassTuple* tuple, - size_t index, - CassInet value); - -/** - * Sets a "decimal" in a tuple at the specified index. - * - * @cassandra{2.1+} - * - * @public @memberof CassTuple - * - * @param[in] tuple - * @param[in] index - * @param[in] varint The value is copied into the tuple object; the - * memory pointed to by this parameter can be freed after this call. - * @param[in] varint_size - * @param[in] scale - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_tuple_set_decimal(CassTuple* tuple, - size_t index, - const cass_byte_t* varint, - size_t varint_size, - cass_int32_t scale); - -/** - * Sets a "duration" in a tuple at the specified index. - * - * @cassandra{3.10+} - * - * @public @memberof CassTuple - * - * @param[in] tuple - * @param[in] index - * @param[in] months - * @param[in] days - * @param[in] nanos - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_tuple_set_duration(CassTuple* tuple, - size_t index, - cass_int32_t months, - cass_int32_t days, - cass_int64_t nanos); - -/** - * Sets a "list", "map" or "set" in a tuple at the specified index. - * - * @cassandra{2.1+} - * - * @public @memberof CassTuple - * - * @param[in] tuple - * @param[in] index - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_tuple_set_collection(CassTuple* tuple, - size_t index, - const CassCollection* value); - -/** - * Sets a "tuple" in a tuple at the specified index. - * - * @cassandra{2.1+} - * - * @public @memberof CassTuple - * - * @param[in] tuple - * @param[in] index - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_tuple_set_tuple(CassTuple* tuple, - size_t index, - const CassTuple* value); - -/** - * Sets a "udt" in a tuple at the specified index. - * - * @cassandra{2.1+} - * - * @public @memberof CassTuple - * - * @param[in] tuple - * @param[in] index - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_tuple_set_user_type(CassTuple* tuple, - size_t index, - const CassUserType* value); - -/*********************************************************************************** - * - * User defined type - * - ***********************************************************************************/ - -/** - * Creates a new user defined type from existing data type; - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] data_type - * @return Returns a user defined type that must be freed. NULL is returned if - * the data type is not a user defined type. - * - * @see cass_user_type_free() - */ -CASS_EXPORT CassUserType* -cass_user_type_new_from_data_type(const CassDataType* data_type); - -/** - * Frees a user defined type instance. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - */ -CASS_EXPORT void -cass_user_type_free(CassUserType* user_type); - -/** - * Gets the data type of a user defined type. - * - * @cassandra{2.1+} - * - * @param[in] user_type - * @return Returns a reference to the data type of the user defined type. - * Do not free this reference as it is bound to the lifetime of the - * user defined type. - */ -CASS_EXPORT const CassDataType* -cass_user_type_data_type(const CassUserType* user_type); - -/** - * Sets a null in a user defined type at the specified index. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] index - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_null(CassUserType* user_type, - size_t index); - -/** - * Sets a null in a user defined type at the specified name. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_null_by_name(CassUserType* user_type, - const char* name); - -/** - * Same as cass_user_type_set_null_by_name(), but with lengths for string - * parameters. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @param[in] name_length - * @return same as cass_user_type_set_null_by_name() - * - * @see cass_user_type_set_null_by_name() - */ -CASS_EXPORT CassError -cass_user_type_set_null_by_name_n(CassUserType* user_type, - const char* name, - size_t name_length); - -/** - * Sets a "tinyint" in a user defined type at the specified index. - * - * @cassandra{2.2+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] index - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_int8(CassUserType* user_type, - size_t index, - cass_int8_t value); - -/** - * Sets a "tinyint" in a user defined type at the specified name. - * - * @cassandra{2.2+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_int8_by_name(CassUserType* user_type, - const char* name, - cass_int8_t value); - -/** - * Same as cass_user_type_set_int8_by_name(), but with lengths for string - * parameters. - * - * @cassandra{2.2+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @param[in] name_length - * @param[in] value - * @return same as cass_user_type_set_int8_by_name() - * - * @see cass_user_type_set_int8_by_name() - */ -CASS_EXPORT CassError -cass_user_type_set_int8_by_name_n(CassUserType* user_type, - const char* name, - size_t name_length, - cass_int8_t value); - -/** - * Sets an "smallint" in a user defined type at the specified index. - * - * @cassandra{2.2+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] index - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_int16(CassUserType* user_type, - size_t index, - cass_int16_t value); - -/** - * Sets an "smallint" in a user defined type at the specified name. - * - * @cassandra{2.2+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_int16_by_name(CassUserType* user_type, - const char* name, - cass_int16_t value); - -/** - * Same as cass_user_type_set_int16_by_name(), but with lengths for string - * parameters. - * - * @cassandra{2.2+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @param[in] name_length - * @param[in] value - * @return same as cass_user_type_set_int16_by_name() - * - * @see cass_user_type_set_int16_by_name() - */ -CASS_EXPORT CassError -cass_user_type_set_int16_by_name_n(CassUserType* user_type, - const char* name, - size_t name_length, - cass_int16_t value); - -/** - * Sets an "int" in a user defined type at the specified index. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] index - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_int32(CassUserType* user_type, - size_t index, - cass_int32_t value); - -/** - * Sets an "int" in a user defined type at the specified name. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_int32_by_name(CassUserType* user_type, - const char* name, - cass_int32_t value); - -/** - * Same as cass_user_type_set_int32_by_name(), but with lengths for string - * parameters. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @param[in] name_length - * @param[in] value - * @return same as cass_user_type_set_int32_by_name() - * - * @see cass_user_type_set_int32_by_name() - */ -CASS_EXPORT CassError -cass_user_type_set_int32_by_name_n(CassUserType* user_type, - const char* name, - size_t name_length, - cass_int32_t value); - -/** - * Sets a "date" in a user defined type at the specified index. - * - * @cassandra{2.2+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] index - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_uint32(CassUserType* user_type, - size_t index, - cass_uint32_t value); - -/** - * Sets a "date" in a user defined type at the specified name. - * - * @cassandra{2.2+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_uint32_by_name(CassUserType* user_type, - const char* name, - cass_uint32_t value); - -/** - * Same as cass_user_type_set_uint32_by_name(), but with lengths for string - * parameters. - * - * @cassandra{2.2+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @param[in] name_length - * @param[in] value - * @return same as cass_user_type_set_uint32_by_name() - * - * @see cass_user_type_set_uint32_by_name() - */ -CASS_EXPORT CassError -cass_user_type_set_uint32_by_name_n(CassUserType* user_type, - const char* name, - size_t name_length, - cass_uint32_t value); - - -/** - * Sets an "bigint", "counter", "timestamp" or "time" in a - * user defined type at the specified index. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] index - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_int64(CassUserType* user_type, - size_t index, - cass_int64_t value); - -/** - * Sets an "bigint", "counter", "timestamp" or "time" in a - * user defined type at the specified name. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_int64_by_name(CassUserType* user_type, - const char* name, - cass_int64_t value); - -/** - * Same as cass_user_type_set_int64_by_name(), but with lengths for string - * parameters. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @param[in] name_length - * @param[in] value - * @return same as cass_user_type_set_int64_by_name() - * - * @see cass_user_type_set_int64_by_name() - */ -CASS_EXPORT CassError -cass_user_type_set_int64_by_name_n(CassUserType* user_type, - const char* name, - size_t name_length, - cass_int64_t value); - -/** - * Sets a "float" in a user defined type at the specified index. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] index - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_float(CassUserType* user_type, - size_t index, - cass_float_t value); - -/** - * Sets a "float" in a user defined type at the specified name. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_float_by_name(CassUserType* user_type, - const char* name, - cass_float_t value); - -/** - * Same as cass_user_type_set_float_by_name(), but with lengths for string - * parameters. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @param[in] name_length - * @param[in] value - * @return same as cass_user_type_set_float_by_name() - * - * @see cass_user_type_set_float_by_name() - */ -CASS_EXPORT CassError -cass_user_type_set_float_by_name_n(CassUserType* user_type, - const char* name, - size_t name_length, - cass_float_t value); - -/** - * Sets an "double" in a user defined type at the specified index. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] index - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_double(CassUserType* user_type, - size_t index, - cass_double_t value); - -/** - * Sets an "double" in a user defined type at the specified name. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_double_by_name(CassUserType* user_type, - const char* name, - cass_double_t value); - -/** - * Same as cass_user_type_set_double_by_name(), but with lengths for string - * parameters. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @param[in] name_length - * @param[in] value - * @return same as cass_user_type_set_double_by_name() - * - * @see cass_user_type_set_double_by_name() - */ -CASS_EXPORT CassError -cass_user_type_set_double_by_name_n(CassUserType* user_type, - const char* name, - size_t name_length, - cass_double_t value); - -/** - * Sets a "boolean" in a user defined type at the specified index. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] index - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_bool(CassUserType* user_type, - size_t index, - cass_bool_t value); - -/** - * Sets a "boolean" in a user defined type at the specified name. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_bool_by_name(CassUserType* user_type, - const char* name, - cass_bool_t value); - -/** - * Same as cass_user_type_set_double_by_name(), but with lengths for string - * parameters. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @param[in] name_length - * @param[in] value - * @return same as cass_user_type_set_double_by_name() - * - * @see cass_user_type_set_double_by_name() - */ -CASS_EXPORT CassError -cass_user_type_set_bool_by_name_n(CassUserType* user_type, - const char* name, - size_t name_length, - cass_bool_t value); - - -/** - * Sets an "ascii", "text" or "varchar" in a user defined type at the - * specified index. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] index - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_string(CassUserType* user_type, - size_t index, - const char* value); - -/** - * Same as cass_user_type_set_string(), but with lengths for string - * parameters. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] index - * @param[in] value - * @param[in] value_length - * @return same as cass_user_type_set_string() - * - * @see cass_user_type_set_string() - */ -CASS_EXPORT CassError -cass_user_type_set_string_n(CassUserType* user_type, - size_t index, - const char* value, - size_t value_length); - -/** - * Sets an "ascii", "text" or "varchar" in a user defined type at the - * specified name. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_string_by_name(CassUserType* user_type, - const char* name, - const char* value); - -/** - * Same as cass_user_type_set_string_by_name(), but with lengths for string - * parameters. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @param[in] name_length - * @param[in] value - * @param[in] value_length - * @return same as cass_user_type_set_string_by_name() - * - * @see cass_user_type_set_string_by_name() - */ -CASS_EXPORT CassError -cass_user_type_set_string_by_name_n(CassUserType* user_type, - const char* name, - size_t name_length, - const char* value, - size_t value_length); - -/** - * Sets a "blob" "varint" or "custom" in a user defined type at the specified index. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] index - * @param[in] value - * @param[in] value_size - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_bytes(CassUserType* user_type, - size_t index, - const cass_byte_t* value, - size_t value_size); - -/** - * Sets a "blob", "varint" or "custom" in a user defined type at the specified name. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @param[in] value - * @param[in] value_size - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_bytes_by_name(CassUserType* user_type, - const char* name, - const cass_byte_t* value, - size_t value_size); - -/** - * Same as cass_user_type_set_bytes_by_name(), but with lengths for string - * parameters. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @param[in] name_length - * @param[in] value - * @param[in] value_size - * @return same as cass_user_type_set_bytes_by_name() - * - * @see cass_user_type_set_bytes_by_name() - */ -CASS_EXPORT CassError -cass_user_type_set_bytes_by_name_n(CassUserType* user_type, - const char* name, - size_t name_length, - const cass_byte_t* value, - size_t value_size); - -/** - * Sets a "custom" in a user defined type at the specified index. - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] index - * @param[in] class_name - * @param[in] value - * @param[in] value_size - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_custom(CassUserType* user_type, - size_t index, - const char* class_name, - const cass_byte_t* value, - size_t value_size); - -/** - * Same as cass_user_type_set_custom(), but with lengths for string - * parameters. - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] index - * @param[in] class_name - * @param[in] class_name_length - * @param[in] value - * @param[in] value_size - * @return same as cass_user_type_set_custom() - * - * @see cass_user_type_set_custom() - */ -CASS_EXPORT CassError -cass_user_type_set_custom_n(CassUserType* user_type, - size_t index, - const char* class_name, - size_t class_name_length, - const cass_byte_t* value, - size_t value_size); - -/** - * Sets a "custom" in a user defined type at the specified name. - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @param[in] class_name - * @param[in] value - * @param[in] value_size - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_custom_by_name(CassUserType* user_type, - const char* name, - const char* class_name, - const cass_byte_t* value, - size_t value_size); - -/** - * Same as cass_user_type_set_custom_by_name(), but with lengths for string - * parameters. - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @param[in] name_length - * @param[in] class_name - * @param[in] class_name_length - * @param[in] value - * @param[in] value_size - * @return same as cass_user_type_set_custom_by_name() - * - * @see cass_user_type_set_custom_by_name() - */ -CASS_EXPORT CassError -cass_user_type_set_custom_by_name_n(CassUserType* user_type, - const char* name, - size_t name_length, - const char* class_name, - size_t class_name_length, - const cass_byte_t* value, - size_t value_size); - -/** - * Sets a "uuid" or "timeuuid" in a user defined type at the specified index. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] index - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_uuid(CassUserType* user_type, - size_t index, - CassUuid value); - -/** - * Sets a "uuid" or "timeuuid" in a user defined type at the specified name. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_uuid_by_name(CassUserType* user_type, - const char* name, - CassUuid value); - -/** - * Same as cass_user_type_set_uuid_by_name(), but with lengths for string - * parameters. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @param[in] name_length - * @param[in] value - * @return same as cass_user_type_set_uuid_by_name() - * - * @see cass_user_type_set_uuid_by_name() - */ -CASS_EXPORT CassError -cass_user_type_set_uuid_by_name_n(CassUserType* user_type, - const char* name, - size_t name_length, - CassUuid value); - -/** - * Sets a "inet" in a user defined type at the specified index. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] index - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_inet(CassUserType* user_type, - size_t index, - CassInet value); - -/** - * Sets a "inet" in a user defined type at the specified name. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_inet_by_name(CassUserType* user_type, - const char* name, - CassInet value); - -/** - * Same as cass_user_type_set_inet_by_name(), but with lengths for string - * parameters. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @param[in] name_length - * @param[in] value - * @return same as cass_user_type_set_inet_by_name() - * - * @see cass_user_type_set_inet_by_name() - */ -CASS_EXPORT CassError -cass_user_type_set_inet_by_name_n(CassUserType* user_type, - const char* name, - size_t name_length, - CassInet value); - -/** - * Sets an "decimal" in a user defined type at the specified index. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] index - * @param[in] varint - * @param[in] varint_size - * @param[in] scale - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_decimal(CassUserType* user_type, - size_t index, - const cass_byte_t* varint, - size_t varint_size, - int scale); - -/** - * Sets "decimal" in a user defined type at the specified name. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @param[in] varint - * @param[in] varint_size - * @param[in] scale - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_decimal_by_name(CassUserType* user_type, - const char* name, - const cass_byte_t* varint, - size_t varint_size, - int scale); - -/** - * Same as cass_user_type_set_decimal_by_name(), but with lengths for string - * parameters. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @param[in] name_length - * @param[in] varint - * @param[in] varint_size - * @param[in] scale - * @return same as cass_user_type_set_decimal_by_name() - * - * @see cass_user_type_set_decimal_by_name() - */ -CASS_EXPORT CassError -cass_user_type_set_decimal_by_name_n(CassUserType* user_type, - const char* name, - size_t name_length, - const cass_byte_t* varint, - size_t varint_size, - int scale); - -/** - * Sets a "duration" in a user defined type at the specified index. - * - * @cassandra{3.10+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] index - * @param[in] months - * @param[in] days - * @param[in] nanos - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_duration(CassUserType* user_type, - size_t index, - cass_int32_t months, - cass_int32_t days, - cass_int64_t nanos); - -/** - * Sets "duration" in a user defined type at the specified name. - * - * @cassandra{3.10+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @param[in] months - * @param[in] days - * @param[in] nanos - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_duration_by_name(CassUserType* user_type, - const char* name, - cass_int32_t months, - cass_int32_t days, - cass_int64_t nanos); - -/** - * Same as cass_user_type_set_duration_by_name(), but with lengths for string - * parameters. - * - * @cassandra{3.10+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @param[in] name_length - * @param[in] months - * @param[in] days - * @param[in] nanos - * @return same as cass_user_type_set_duration_by_name() - * - * @see cass_user_type_set_duration_by_name() - */ -CASS_EXPORT CassError -cass_user_type_set_duration_by_name_n(CassUserType* user_type, - const char* name, - size_t name_length, - cass_int32_t months, - cass_int32_t days, - cass_int64_t nanos); - -/** - * Sets a "list", "map" or "set" in a user defined type at the - * specified index. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] index - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_collection(CassUserType* user_type, - size_t index, - const CassCollection* value); - -/** - * Sets a "list", "map" or "set" in a user defined type at the - * specified name. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_collection_by_name(CassUserType* user_type, - const char* name, - const CassCollection* value); - -/** - * Same as cass_user_type_set_collection_by_name(), but with lengths for string - * parameters. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @param[in] name_length - * @param[in] value - * @return same as cass_user_type_set_collection_by_name() - * - * @see cass_user_type_set_collection_by_name() - */ -CASS_EXPORT CassError -cass_user_type_set_collection_by_name_n(CassUserType* user_type, - const char* name, - size_t name_length, - const CassCollection* value); - -/** - * Sets a "tuple" in a user defined type at the specified index. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] index - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_tuple(CassUserType* user_type, - size_t index, - const CassTuple* value); - -/** - * Sets a "tuple" in a user defined type at the specified name. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_tuple_by_name(CassUserType* user_type, - const char* name, - const CassTuple* value); - -/** - * Same as cass_user_type_set_tuple_by_name(), but with lengths for string - * parameters. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @param[in] name_length - * @param[in] value - * @return same as cass_user_type_set_tuple_by_name() - * - * @see cass_user_type_set_tuple_by_name() - */ -CASS_EXPORT CassError -cass_user_type_set_tuple_by_name_n(CassUserType* user_type, - const char* name, - size_t name_length, - const CassTuple* value); - -/** - * Sets a user defined type in a user defined type at the specified index. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] index - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_user_type(CassUserType* user_type, - size_t index, - const CassUserType* value); - -/** - * Sets a user defined type in a user defined type at the specified name. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @param[in] value - * @return CASS_OK if successful, otherwise an error occurred. - */ -CASS_EXPORT CassError -cass_user_type_set_user_type_by_name(CassUserType* user_type, - const char* name, - const CassUserType* value); - -/** - * Same as cass_user_type_set_user_type_by_name(), but with lengths for string - * parameters. - * - * @cassandra{2.1+} - * - * @public @memberof CassUserType - * - * @param[in] user_type - * @param[in] name - * @param[in] name_length - * @param[in] value - * @return same as cass_user_type_set_user_type_by_name() - * - * @see cass_user_type_set_user_type_by_name() - */ -CASS_EXPORT CassError -cass_user_type_set_user_type_by_name_n(CassUserType* user_type, - const char* name, - size_t name_length, - const CassUserType* value); - -/*********************************************************************************** - * - * Result - * - ***********************************************************************************/ - -/** - * Frees a result instance. - * - * This method invalidates all values, rows, and - * iterators that were derived from this result. - * - * @public @memberof CassResult - * - * @param[in] result - */ -CASS_EXPORT void -cass_result_free(const CassResult* result); - -/** - * Gets the number of rows for the specified result. - * - * @public @memberof CassResult - * - * @param[in] result - * @return The number of rows in the result. - */ -CASS_EXPORT size_t -cass_result_row_count(const CassResult* result); - -/** - * Gets the number of columns per row for the specified result. - * - * @public @memberof CassResult - * - * @param[in] result - * @return The number of columns per row in the result. - */ -CASS_EXPORT size_t -cass_result_column_count(const CassResult* result); - -/** - * Gets the column name at index for the specified result. - * - * @public @memberof CassResult - * - * @param[in] result - * @param[in] index - * @param[out] name The column name at the specified index. - * @param[out] name_length - * @return CASS_OK if successful, otherwise error occurred - */ -CASS_EXPORT CassError -cass_result_column_name(const CassResult *result, - size_t index, - const char** name, - size_t* name_length); - -/** - * Gets the column type at index for the specified result. - * - * @public @memberof CassResult - * - * @param[in] result - * @param[in] index - * @return The column type at the specified index. CASS_VALUE_TYPE_UNKNOWN - * is returned if the index is out of bounds. - */ -CASS_EXPORT CassValueType -cass_result_column_type(const CassResult* result, - size_t index); - -/** - * Gets the column data type at index for the specified result. - * - * @public @memberof CassResult - * - * @param[in] result - * @param[in] index - * @return The column type at the specified index. NULL is returned if the - * index is out of bounds. - */ -CASS_EXPORT const CassDataType* -cass_result_column_data_type(const CassResult* result, size_t index); - -/** - * Gets the first row of the result. - * - * @public @memberof CassResult - * - * @param[in] result - * @return The first row of the result. NULL if there are no rows. - */ -CASS_EXPORT const CassRow* -cass_result_first_row(const CassResult* result); - -/** - * Returns true if there are more pages. - * - * @cassandra{2.0+} - * - * @public @memberof CassResult - * - * @param[in] result - * @return cass_true if there are more pages - */ -CASS_EXPORT cass_bool_t -cass_result_has_more_pages(const CassResult* result); - -/** - * Gets the raw paging state from the result. The paging state is bound to the - * lifetime of the result object. If paging state needs to live beyond the - * lifetime of the result object it must be copied. - * - * Warning: The paging state should not be exposed to or come from - * untrusted environments. The paging state could be spoofed and potentially - * used to gain access to other data. - * - * @cassandra{2.0+} - * - * @public @memberof CassResult - * - * @param[in] result - * @param[out] paging_state - * @param[out] paging_state_size - * @return CASS_OK if successful, otherwise error occurred - * - * @see cass_statement_set_paging_state_token() - */ -CASS_EXPORT CassError -cass_result_paging_state_token(const CassResult* result, - const char** paging_state, - size_t* paging_state_size); - -/*********************************************************************************** - * - * Error result - * - ***********************************************************************************/ - -/** - * Frees an error result instance. - * - * @public @memberof CassErrorResult - * - * @param[in] error_result - */ -CASS_EXPORT void -cass_error_result_free(const CassErrorResult* error_result); - -/** - * Gets error code for the error result. This error code will always - * have an server error source. - * - * @public @memberof CassErrorResult - * - * @param[in] error_result - * @return The server error code - */ -CASS_EXPORT CassError -cass_error_result_code(const CassErrorResult* error_result); - -/** - * Gets consistency that triggered the error result of the - * following types: - * - *
    - *
  • CASS_ERROR_SERVER_READ_TIMEOUT
  • - *
  • CASS_ERROR_SERVER_WRITE_TIMEOUT
  • - *
  • CASS_ERROR_SERVER_READ_FAILURE
  • - *
  • CASS_ERROR_SERVER_WRITE_FAILURE
  • - *
  • CASS_ERROR_SERVER_UNAVAILABLE
  • - *
- * - * @public @memberof CassErrorResult - * - * @param[in] error_result - * @return The consistency that triggered the error for a read timeout, - * write timeout or an unavailable error result. Undefined for other - * error result types. - */ -CASS_EXPORT CassConsistency -cass_error_result_consistency(const CassErrorResult* error_result); - -/** - * Gets the actual number of received responses, received acknowledgments - * or alive nodes for following error result types, respectively: - * - *
    - *
  • CASS_ERROR_SERVER_READ_TIMEOUT
  • - *
  • CASS_ERROR_SERVER_WRITE_TIMEOUT
  • - *
  • CASS_ERROR_SERVER_READ_FAILURE
  • - *
  • CASS_ERROR_SERVER_WRITE_FAILURE
  • - *
  • CASS_ERROR_SERVER_UNAVAILABLE
  • - *
- * - * @public @memberof CassErrorResult - * - * @param[in] error_result - * @return The actual received responses for a read timeout, actual received - * acknowledgments for a write timeout or actual alive nodes for a unavailable - * error. Undefined for other error result types. - */ -CASS_EXPORT cass_int32_t -cass_error_result_responses_received(const CassErrorResult* error_result); - -/** - * Gets required responses, required acknowledgments or required alive nodes - * needed to successfully complete the request for following error result types, - * respectively: - * - *
    - *
  • CASS_ERROR_SERVER_READ_TIMEOUT
  • - *
  • CASS_ERROR_SERVER_WRITE_TIMEOUT
  • - *
  • CASS_ERROR_SERVER_READ_FAILURE
  • - *
  • CASS_ERROR_SERVER_WRITE_FAILURE
  • - *
  • CASS_ERROR_SERVER_UNAVAILABLE
  • - *
- * - * @public @memberof CassErrorResult - * - * @param[in] error_result - * @return The required responses for a read time, required acknowledgments - * for a write timeout or required alive nodes for an unavailable error result. - * Undefined for other error result types. - */ -CASS_EXPORT cass_int32_t -cass_error_result_responses_required(const CassErrorResult* error_result); - -/** - * Gets the number of nodes that experienced failures for the following error types: - * - *
    - *
  • CASS_ERROR_SERVER_READ_FAILURE
  • - *
  • CASS_ERROR_SERVER_WRITE_FAILURE
  • - *
- * - * @public @memberof CassErrorResult - * - * @param[in] error_result - * @return The number of nodes that failed during a read or write request. - */ -CASS_EXPORT cass_int32_t -cass_error_result_num_failures(const CassErrorResult* error_result); - -/** - * Determines whether the actual data was present in the responses from the - * replicas for the following error result types: - * - *
    - *
  • CASS_ERROR_SERVER_READ_TIMEOUT
  • - *
  • CASS_ERROR_SERVER_READ_FAILURE
  • - *
- * - * @public @memberof CassErrorResult - * - * @param[in] error_result - * @return cass_true if the data was present in the received responses when the - * read timeout occurred. Undefined for other error result types. - */ -CASS_EXPORT cass_bool_t -cass_error_result_data_present(const CassErrorResult* error_result); - -/** - * Gets the write type of a request for the following error result types: - * - *
    - *
  • CASS_ERROR_SERVER_WRITE_TIMEOUT
  • - *
  • CASS_ERROR_SERVER_WRITE_FAILURE
  • - *
- * - * @public @memberof CassErrorResult - * - * @param[in] error_result - * @return The type of the write that timed out. Undefined for - * other error result types. - */ -CASS_EXPORT CassWriteType -cass_error_result_write_type(const CassErrorResult* error_result); - -/** - * Gets the affected keyspace for the following error result types: - * - *
    - *
  • CASS_ERROR_SERVER_ALREADY_EXISTS
  • - *
  • CASS_ERROR_SERVER_FUNCTION_FAILURE
  • - *
- * - * @public @memberof CassErrorResult - * - * @param[in] error_result - * @param[out] keyspace - * @param[out] keyspace_length - * @return CASS_OK if successful, otherwise error occurred - */ -CASS_EXPORT CassError -cass_error_result_keyspace(const CassErrorResult* error_result, - const char** keyspace, - size_t* keyspace_length); - -/** - * Gets the affected table for the already exists error - * (CASS_ERROR_SERVER_ALREADY_EXISTS) result type. - * - * @public @memberof CassErrorResult - * - * @param[in] error_result - * @param[out] table - * @param[out] table_length - * @return CASS_OK if successful, otherwise error occurred - */ -CASS_EXPORT CassError -cass_error_result_table(const CassErrorResult* error_result, - const char** table, - size_t* table_length); - -/** - * Gets the affected function for the function failure error - * (CASS_ERROR_SERVER_FUNCTION_FAILURE) result type. - * - * @cassandra{2.2+} - * - * @public @memberof CassErrorResult - * - * @param[in] error_result - * @param[out] function - * @param[out] function_length - * @return CASS_OK if successful, otherwise error occurred - */ -CASS_EXPORT CassError -cass_error_result_function(const CassErrorResult* error_result, - const char** function, - size_t* function_length); - -/** - * Gets the number of argument types for the function failure error - * (CASS_ERROR_SERVER_FUNCTION_FAILURE) result type. - * - * @cassandra{2.2+} - * - * @public @memberof CassErrorResult - * - * @param[in] error_result - * @return The number of arguments for the affected function. - */ -CASS_EXPORT size_t -cass_error_num_arg_types(const CassErrorResult* error_result); - -/** - * Gets the argument type at the specified index for the function failure - * error (CASS_ERROR_SERVER_FUNCTION_FAILURE) result type. - * - * @cassandra{2.2+} - * - * @public @memberof CassErrorResult - * - * @param[in] error_result - * @param[in] index - * @param[out] arg_type - * @param[out] arg_type_length - * @return CASS_OK if successful, otherwise error occurred - */ -CASS_EXPORT CassError -cass_error_result_arg_type(const CassErrorResult* error_result, - size_t index, - const char** arg_type, - size_t* arg_type_length); - -/*********************************************************************************** - * - * Iterator - * - ***********************************************************************************/ - -/** - * Frees an iterator instance. - * - * @public @memberof CassIterator - * - * @param[in] iterator - */ -CASS_EXPORT void -cass_iterator_free(CassIterator* iterator); - -/** - * Gets the type of the specified iterator. - * - * @public @memberof CassIterator - * - * @param[in] iterator - * @return The type of the iterator. - */ -CASS_EXPORT CassIteratorType -cass_iterator_type(CassIterator* iterator); - -/** - * Creates a new iterator for the specified result. This can be - * used to iterate over rows in the result. - * - * @public @memberof CassResult - * - * @param[in] result - * @return A new iterator that must be freed. - * - * @see cass_iterator_free() - */ -CASS_EXPORT CassIterator* -cass_iterator_from_result(const CassResult* result); - -/** - * Creates a new iterator for the specified row. This can be - * used to iterate over columns in a row. - * - * @public @memberof CassRow - * - * @param[in] row - * @return A new iterator that must be freed. - * - * @see cass_iterator_free() - */ -CASS_EXPORT CassIterator* -cass_iterator_from_row(const CassRow* row); - -/** - * Creates a new iterator for the specified collection. This can be - * used to iterate over values in a collection. - * - * @public @memberof CassValue - * - * @param[in] value - * @return A new iterator that must be freed. NULL returned if the - * value is not a collection. - * - * @see cass_iterator_free() - */ -CASS_EXPORT CassIterator* -cass_iterator_from_collection(const CassValue* value); - -/** - * Creates a new iterator for the specified map. This can be - * used to iterate over key/value pairs in a map. - * - * @public @memberof CassValue - * - * @param[in] value - * @return A new iterator that must be freed. NULL returned if the - * value is not a map. - * - * @see cass_iterator_free() - */ -CASS_EXPORT CassIterator* -cass_iterator_from_map(const CassValue* value); - -/** - * Creates a new iterator for the specified tuple. This can be - * used to iterate over values in a tuple. - * - * @cassandra{2.1+} - * - * @public @memberof CassValue - * - * @param[in] value - * @return A new iterator that must be freed. NULL returned if the - * value is not a tuple. - * - * @see cass_iterator_free() - */ -CASS_EXPORT CassIterator* -cass_iterator_from_tuple(const CassValue* value); - -/** - * Creates a new iterator for the specified user defined type. This can be - * used to iterate over fields in a user defined type. - * - * @cassandra{2.1+} - * - * @public @memberof CassValue - * - * @param[in] value - * @return A new iterator that must be freed. NULL returned if the - * value is not a user defined type. - * - * @see cass_iterator_free() - */ -CASS_EXPORT CassIterator* -cass_iterator_fields_from_user_type(const CassValue* value); - -/** - * Creates a new iterator for the specified schema metadata. - * This can be used to iterate over keyspace. - * - * @public @memberof CassSchemaMeta - * - * @param[in] schema_meta - * @return A new iterator that must be freed. - * - * @see cass_iterator_get_keyspace_meta() - * @see cass_iterator_free() - */ -CASS_EXPORT CassIterator* -cass_iterator_keyspaces_from_schema_meta(const CassSchemaMeta* schema_meta); - -/** - * Creates a new iterator for the specified keyspace metadata. - * This can be used to iterate over tables. - * - * @public @memberof CassKeyspaceMeta - * - * @param[in] keyspace_meta - * @return A new iterator that must be freed. - * - * @see cass_iterator_get_table_meta() - * @see cass_iterator_free() - */ -CASS_EXPORT CassIterator* -cass_iterator_tables_from_keyspace_meta(const CassKeyspaceMeta* keyspace_meta); - -/** - * Creates a new iterator for the specified keyspace metadata. - * This can be used to iterate over views. - * - * @cassandra{3.0+} - * - * @public @memberof CassKeyspaceMeta - * - * @param[in] keyspace_meta - * @return A new iterator that must be freed. - * - * @see cass_iterator_get_materialized_view_meta() - * @see cass_iterator_free() - */ -CASS_EXPORT CassIterator* -cass_iterator_materialized_views_from_keyspace_meta(const CassKeyspaceMeta* keyspace_meta); - -/** - * Creates a new iterator for the specified keyspace metadata. - * This can be used to iterate over types. - * - * @cassandra{2.1+} - * - * @public @memberof CassKeyspaceMeta - * - * @param[in] keyspace_meta - * @return A new iterator that must be freed. - * - * @see cass_iterator_get_user_type() - * @see cass_iterator_free() - */ -CASS_EXPORT CassIterator* -cass_iterator_user_types_from_keyspace_meta(const CassKeyspaceMeta* keyspace_meta); - -/** - * Creates a new iterator for the specified keyspace metadata. - * This can be used to iterate over functions. - * - * @cassandra{2.2+} - * - * @public @memberof CassKeyspaceMeta - * - * @param[in] keyspace_meta - * @return A new iterator that must be freed. - * - * @see cass_iterator_get_function_meta() - * @see cass_iterator_free() - */ -CASS_EXPORT CassIterator* -cass_iterator_functions_from_keyspace_meta(const CassKeyspaceMeta* keyspace_meta); - -/** - * Creates a new iterator for the specified keyspace metadata. - * This can be used to iterate over aggregates. - * - * @cassandra{2.2+} - * - * @public @memberof CassKeyspaceMeta - * - * @param[in] keyspace_meta - * @return A new iterator that must be freed. - * - * @see cass_iterator_get_aggregate_meta() - * @see cass_iterator_free() - */ -CASS_EXPORT CassIterator* -cass_iterator_aggregates_from_keyspace_meta(const CassKeyspaceMeta* keyspace_meta); - -/** - * Creates a new fields iterator for the specified keyspace metadata. Metadata - * fields allow direct access to the column data found in the underlying - * "keyspaces" metadata table. This can be used to iterate those metadata - * field entries. - * - * @public @memberof CassKeyspaceMeta - * - * @param[in] keyspace_meta - * @return A new iterator that must be freed. - * - * @see cass_iterator_get_meta_field_name() - * @see cass_iterator_get_meta_field_value() - * @see cass_iterator_free() - */ -CASS_EXPORT CassIterator* -cass_iterator_fields_from_keyspace_meta(const CassKeyspaceMeta* keyspace_meta); - -/** - * Creates a new iterator for the specified table metadata. - * This can be used to iterate over columns. - * - * @public @memberof CassTableMeta - * - * @param[in] table_meta - * @return A new iterator that must be freed. - * - * @see cass_iterator_get_column_meta() - * @see cass_iterator_free() - */ -CASS_EXPORT CassIterator* -cass_iterator_columns_from_table_meta(const CassTableMeta* table_meta); - -/** - * Creates a new iterator for the specified table metadata. - * This can be used to iterate over indexes. - * - * @public @memberof CassTableMeta - * - * @param[in] table_meta - * @return A new iterator that must be freed. - * - * @see cass_iterator_get_index_meta() - * @see cass_iterator_free() - */ -CASS_EXPORT CassIterator* -cass_iterator_indexes_from_table_meta(const CassTableMeta* table_meta); - -/** - * Creates a new iterator for the specified materialized view metadata. - * This can be used to iterate over columns. - * - * @cassandra{3.0+} - * - * @public @memberof CassTableMeta - * - * @param[in] table_meta - * @return A new iterator that must be freed. - * - * @see cass_iterator_get_materialized_view_meta() - * @see cass_iterator_free() - */ -CASS_EXPORT CassIterator* -cass_iterator_materialized_views_from_table_meta(const CassTableMeta* table_meta); - -/** - * Creates a new fields iterator for the specified table metadata. Metadata - * fields allow direct access to the column data found in the underlying - * "tables" metadata table. This can be used to iterate those metadata - * field entries. - * - * @public @memberof CassTableMeta - * - * @param[in] table_meta - * @return A new iterator that must be freed. - * - * @see cass_iterator_get_meta_field_name() - * @see cass_iterator_get_meta_field_value() - * @see cass_iterator_free() - */ -CASS_EXPORT CassIterator* -cass_iterator_fields_from_table_meta(const CassTableMeta* table_meta); - -/** - * Creates a new iterator for the specified materialized view metadata. - * This can be used to iterate over columns. - * - * @cassandra{3.0+} - * - * @public @memberof CassMaterializedViewMeta - * - * @param[in] view_meta - * @return A new iterator that must be freed. - * - * @see cass_iterator_get_column_meta() - * @see cass_iterator_free() - */ -CASS_EXPORT CassIterator* -cass_iterator_columns_from_materialized_view_meta(const CassMaterializedViewMeta* view_meta); - -/** - * Creates a new fields iterator for the specified materialized view metadata. - * Metadata fields allow direct access to the column data found in the - * underlying "views" metadata view. This can be used to iterate those metadata - * field entries. - * - * @cassandra{3.0+} - * - * @public @memberof CassMaterializedViewMeta - * - * @param[in] view_meta - * @return A new iterator that must be freed. - * - * @see cass_iterator_get_meta_field_name() - * @see cass_iterator_get_meta_field_value() - * @see cass_iterator_free() - */ -CASS_EXPORT CassIterator* -cass_iterator_fields_from_materialized_view_meta(const CassMaterializedViewMeta* view_meta); - -/** - * Creates a new fields iterator for the specified column metadata. Metadata - * fields allow direct access to the column data found in the underlying - * "columns" metadata table. This can be used to iterate those metadata - * field entries. - * - * @public @memberof CassColumnMeta - * - * @param[in] column_meta - * @return A new iterator that must be freed. - * - * @see cass_iterator_get_meta_field_name() - * @see cass_iterator_get_meta_field_value() - * @see cass_iterator_free() - */ -CASS_EXPORT CassIterator* -cass_iterator_fields_from_column_meta(const CassColumnMeta* column_meta); - -/** - * Creates a new fields iterator for the specified index metadata. Metadata - * fields allow direct access to the index data found in the underlying - * "indexes" metadata table. This can be used to iterate those metadata - * field entries. - * - * @public @memberof CassIndexMeta - * - * @param[in] index_meta - * @return A new iterator that must be freed. - * - * @see cass_iterator_get_meta_field_name() - * @see cass_iterator_get_meta_field_value() - * @see cass_iterator_free() - */ -CASS_EXPORT CassIterator* -cass_iterator_fields_from_index_meta(const CassIndexMeta* index_meta); - -/** - * Creates a new fields iterator for the specified function metadata. Metadata - * fields allow direct access to the column data found in the underlying - * "functions" metadata table. This can be used to iterate those metadata - * field entries. - * - * @cassandra{2.2+} - * - * @public @memberof CassFunctionMeta - * - * @param[in] function_meta - * @return A new iterator that must be freed. - * - * @see cass_iterator_get_meta_field() - * @see cass_iterator_free() - */ -CASS_EXPORT CassIterator* -cass_iterator_fields_from_function_meta(const CassFunctionMeta* function_meta); - -/** - * Creates a new fields iterator for the specified aggregate metadata. Metadata - * fields allow direct access to the column data found in the underlying - * "aggregates" metadata table. This can be used to iterate those metadata - * field entries. - * - * @cassandra{2.2+} - * - * @public @memberof CassAggregateMeta - * - * @param[in] aggregate_meta - * @return A new iterator that must be freed. - * - * @see cass_iterator_get_meta_field() - * @see cass_iterator_free() - */ -CASS_EXPORT CassIterator* -cass_iterator_fields_from_aggregate_meta(const CassAggregateMeta* aggregate_meta); - -/** - * Advance the iterator to the next row, column or collection item. - * - * @public @memberof CassIterator - * - * @param[in] iterator - * @return false if no more rows, columns or items, otherwise true - */ -CASS_EXPORT cass_bool_t -cass_iterator_next(CassIterator* iterator); - -/** - * Gets the row at the result iterator's current position. - * - * Calling cass_iterator_next() will invalidate the previous - * row returned by this method. - * - * @public @memberof CassIterator - * - * @param[in] iterator - * @return A row - */ -CASS_EXPORT const CassRow* -cass_iterator_get_row(const CassIterator* iterator); - -/** - * Gets the column value at the row iterator's current position. - * - * Calling cass_iterator_next() will invalidate the previous - * column returned by this method. - * - * @public @memberof CassIterator - * - * @param[in] iterator - * @return A value - */ -CASS_EXPORT const CassValue* -cass_iterator_get_column(const CassIterator* iterator); - -/** - * Gets the value at a collection or tuple iterator's current position. - * - * Calling cass_iterator_next() will invalidate the previous - * value returned by this method. - * - * @public @memberof CassIterator - * - * @param[in] iterator - * @return A value - */ -CASS_EXPORT const CassValue* -cass_iterator_get_value(const CassIterator* iterator); - -/** - * Gets the key at the map iterator's current position. - * - * Calling cass_iterator_next() will invalidate the previous - * value returned by this method. - * - * @public @memberof CassIterator - * - * @param[in] iterator - * @return A value - */ -CASS_EXPORT const CassValue* -cass_iterator_get_map_key(const CassIterator* iterator); - - -/** - * Gets the value at the map iterator's current position. - * - * Calling cass_iterator_next() will invalidate the previous - * value returned by this method. - * - * @public @memberof CassIterator - * - * @param[in] iterator - * @return A value - */ -CASS_EXPORT const CassValue* -cass_iterator_get_map_value(const CassIterator* iterator); - -/** - * Gets the field name at the user type defined iterator's current position. - * - * Calling cass_iterator_next() will invalidate the previous - * name returned by this method. - * - * @cassandra{2.1+} - * - * @public @memberof CassIterator - * - * @param[in] iterator - * @param[out] name - * @param[out] name_length - * @return CASS_OK if successful, otherwise error occurred - */ -CASS_EXPORT CassError -cass_iterator_get_user_type_field_name(const CassIterator* iterator, - const char** name, - size_t* name_length); - -/** - * Gets the field value at the user type defined iterator's current position. - * - * Calling cass_iterator_next() will invalidate the previous - * value returned by this method. - * - * @cassandra{2.1+} - * - * @public @memberof CassIterator - * - * @param[in] iterator - * @return A value - */ -CASS_EXPORT const CassValue* -cass_iterator_get_user_type_field_value(const CassIterator* iterator); - -/** - * Gets the keyspace metadata entry at the iterator's current position. - * - * Calling cass_iterator_next() will invalidate the previous - * value returned by this method. - * - * @public @memberof CassIterator - * - * @param[in] iterator - * @return A keyspace metadata entry - */ -CASS_EXPORT const CassKeyspaceMeta* -cass_iterator_get_keyspace_meta(const CassIterator* iterator); - -/** - * Gets the table metadata entry at the iterator's current position. - * - * Calling cass_iterator_next() will invalidate the previous - * value returned by this method. - * - * @public @memberof CassIterator - * - * @param[in] iterator - * @return A table metadata entry - */ -CASS_EXPORT const CassTableMeta* -cass_iterator_get_table_meta(const CassIterator* iterator); - -/** - * Gets the materialized view metadata entry at the iterator's current position. - * - * Calling cass_iterator_next() will invalidate the previous - * value returned by this method. - * - * @cassandra{3.0+} - * - * @public @memberof CassIterator - * - * @param[in] iterator - * @return A materialized view metadata entry - */ -CASS_EXPORT const CassMaterializedViewMeta* -cass_iterator_get_materialized_view_meta(const CassIterator* iterator); - -/** - * Gets the type metadata entry at the iterator's current position. - * - * Calling cass_iterator_next() will invalidate the previous - * value returned by this method. - * - * @cassandra{2.1+} - * - * @public @memberof CassIterator - * - * @param[in] iterator - * @return A type metadata entry - */ -CASS_EXPORT const CassDataType* -cass_iterator_get_user_type(const CassIterator* iterator); - -/** - * Gets the function metadata entry at the iterator's current position. - * - * Calling cass_iterator_next() will invalidate the previous - * value returned by this method. - * - * @cassandra{2.2+} - * - * @public @memberof CassIterator - * - * @param[in] iterator - * @return A function metadata entry - */ -CASS_EXPORT const CassFunctionMeta* -cass_iterator_get_function_meta(const CassIterator* iterator); - -/** - * Gets the aggregate metadata entry at the iterator's current position. - * - * Calling cass_iterator_next() will invalidate the previous - * value returned by this method. - * - * @cassandra{2.2+} - * - * @public @memberof CassIterator - * - * @param[in] iterator - * @return A aggregate metadata entry - */ -CASS_EXPORT const CassAggregateMeta* -cass_iterator_get_aggregate_meta(const CassIterator* iterator); - -/** - * Gets the column metadata entry at the iterator's current position. - * - * Calling cass_iterator_next() will invalidate the previous - * value returned by this method. - * - * @public @memberof CassIterator - * - * @param[in] iterator - * @return A column metadata entry - */ -CASS_EXPORT const CassColumnMeta* -cass_iterator_get_column_meta(const CassIterator* iterator); - -/** - * Gets the index metadata entry at the iterator's current position. - * - * Calling cass_iterator_next() will invalidate the previous - * value returned by this method. - * - * @public @memberof CassIterator - * - * @param[in] iterator - * @return A index metadata entry - */ -CASS_EXPORT const CassIndexMeta* -cass_iterator_get_index_meta(const CassIterator* iterator); - -/** - * Gets the metadata field name at the iterator's current position. - * - * Calling cass_iterator_next() will invalidate the previous - * value returned by this method. - * - * @public @memberof CassIterator - * - * @param[in] iterator - * @param[out] name - * @param[out] name_length - * @return CASS_OK if successful, otherwise error occurred - */ -CASS_EXPORT CassError -cass_iterator_get_meta_field_name(const CassIterator* iterator, - const char** name, - size_t* name_length); - -/** - * Gets the metadata field value at the iterator's current position. - * - * Calling cass_iterator_next() will invalidate the previous - * value returned by this method. - * - * @public @memberof CassIterator - * - * @param[in] iterator - * @return A metadata field value - */ -CASS_EXPORT const CassValue* -cass_iterator_get_meta_field_value(const CassIterator* iterator); - -/*********************************************************************************** - * - * Row - * - ***********************************************************************************/ - -/** - * Get the column value at index for the specified row. - * - * @public @memberof CassRow - * - * @param[in] row - * @param[in] index - * @return The column value at the specified index. NULL is - * returned if the index is out of bounds. - */ -CASS_EXPORT const CassValue* -cass_row_get_column(const CassRow* row, - size_t index); - - -/** - * Get the column value by name for the specified row. - * - * @public @memberof CassRow - * - * @param[in] row - * @param[in] name - * @return The column value for the specified name. NULL is - * returned if the column does not exist. - */ -CASS_EXPORT const CassValue* -cass_row_get_column_by_name(const CassRow* row, - const char* name); - -/** - * Same as cass_row_get_column_by_name(), but with lengths for string - * parameters. - * - * @public @memberof CassRow - * - * @param[in] row - * @param[in] name - * @param[in] name_length - * @return same as cass_row_get_column_by_name() - * - * @see cass_row_get_column_by_name() - */ -CASS_EXPORT const CassValue* -cass_row_get_column_by_name_n(const CassRow* row, - const char* name, - size_t name_length); - -/*********************************************************************************** - * - * Value - * - ***********************************************************************************/ - -/** - * Gets the data type of a value. - * - * @public @memberof CassValue - * - * @param[in] value - * @return Returns a reference to the data type of the value. - * Do not free this reference as it is bound to the lifetime of the value. - */ -CASS_EXPORT const CassDataType* -cass_value_data_type(const CassValue* value); - -/** - * Gets an int8 for the specified value. - * - * @cassandra{2.2+} - * - * @public @memberof CassValue - * - * @param[in] value - * @param[out] output - * @return CASS_OK if successful, otherwise error occurred - */ -CASS_EXPORT CassError -cass_value_get_int8(const CassValue* value, - cass_int8_t* output); - -/** - * Gets an int16 for the specified value. - * - * @cassandra{2.2+} - * - * @public @memberof CassValue - * - * @param[in] value - * @param[out] output - * @return CASS_OK if successful, otherwise error occurred - */ -CASS_EXPORT CassError -cass_value_get_int16(const CassValue* value, - cass_int16_t* output); - -/** - * Gets an int32 for the specified value. - * - * @public @memberof CassValue - * - * @param[in] value - * @param[out] output - * @return CASS_OK if successful, otherwise error occurred - */ -CASS_EXPORT CassError -cass_value_get_int32(const CassValue* value, - cass_int32_t* output); - -/** - * Gets an uint32 for the specified value. - * - * @cassandra{2.2+} - * - * @public @memberof CassValue - * - * @param[in] value - * @param[out] output - * @return CASS_OK if successful, otherwise error occurred - */ -CASS_EXPORT CassError -cass_value_get_uint32(const CassValue* value, - cass_uint32_t* output); - -/** - * Gets an int64 for the specified value. - * - * @public @memberof CassValue - * - * @param[in] value - * @param[out] output - * @return CASS_OK if successful, otherwise error occurred - */ -CASS_EXPORT CassError -cass_value_get_int64(const CassValue* value, - cass_int64_t* output); - -/** - * Gets a float for the specified value. - * - * @public @memberof CassValue - * - * @param[in] value - * @param[out] output - * @return CASS_OK if successful, otherwise error occurred - */ -CASS_EXPORT CassError -cass_value_get_float(const CassValue* value, - cass_float_t* output); - -/** - * Gets a double for the specified value. - * - * @public @memberof CassValue - * - * @param[in] value - * @param[out] output - * @return CASS_OK if successful, otherwise error occurred - */ -CASS_EXPORT CassError -cass_value_get_double(const CassValue* value, - cass_double_t* output); - -/** - * Gets a bool for the specified value. - * - * @public @memberof CassValue - * - * @param[in] value - * @param[out] output - * @return CASS_OK if successful, otherwise error occurred - */ -CASS_EXPORT CassError -cass_value_get_bool(const CassValue* value, - cass_bool_t* output); - -/** - * Gets a UUID for the specified value. - * - * @public @memberof CassValue - * - * @param[in] value - * @param[out] output - * @return CASS_OK if successful, otherwise error occurred - */ -CASS_EXPORT CassError -cass_value_get_uuid(const CassValue* value, - CassUuid* output); - -/** - * Gets an INET for the specified value. - * - * @public @memberof CassValue - * - * @param[in] value - * @param[out] output - * @return CASS_OK if successful, otherwise error occurred - */ -CASS_EXPORT CassError -cass_value_get_inet(const CassValue* value, - CassInet* output); - -/** - * Gets a string for the specified value. - * - * @public @memberof CassValue - * - * @param[in] value - * @param[out] output - * @param[out] output_size - * @return CASS_OK if successful, otherwise error occurred - */ -CASS_EXPORT CassError -cass_value_get_string(const CassValue* value, - const char** output, - size_t* output_size); - -/** - * Gets the bytes of the specified value. - * - * @public @memberof CassValue - * - * @param[in] value - * @param[out] output - * @param[out] output_size - * @return CASS_OK if successful, otherwise error occurred - */ -CASS_EXPORT CassError -cass_value_get_bytes(const CassValue* value, - const cass_byte_t** output, - size_t* output_size); - -/** - * Gets a decimal for the specified value. - * - * @public @memberof CassValue - * - * @param[in] value - * @param[out] varint - * @param[out] varint_size - * @param[out] scale - * @return CASS_OK if successful, otherwise error occurred - */ -CASS_EXPORT CassError -cass_value_get_decimal(const CassValue* value, - const cass_byte_t** varint, - size_t* varint_size, - cass_int32_t* scale); - -/** - * Gets a duration for the specified value. - * - * @cassandra{3.10+} - * - * @public @memberof CassValue - * - * @param[in] value - * @param[out] months - * @param[out] days - * @param[out] nanos - * @return CASS_OK if successful, otherwise error occurred - */ -CASS_EXPORT CassError -cass_value_get_duration(const CassValue* value, - cass_int32_t* months, - cass_int32_t* days, - cass_int64_t* nanos); - -/** - * Gets the type of the specified value. - * - * @public @memberof CassValue - * - * @param[in] value - * @return The type of the specified value. - */ -CASS_EXPORT CassValueType -cass_value_type(const CassValue* value); - -/** - * Returns true if a specified value is null. - * - * @public @memberof CassValue - * - * @param[in] value - * @return true if the value is null, otherwise false. - */ -CASS_EXPORT cass_bool_t -cass_value_is_null(const CassValue* value); - -/** - * Returns true if a specified value is a collection. - * - * @public @memberof CassValue - * - * @param[in] value - * @return true if the value is a collection, otherwise false. - */ -CASS_EXPORT cass_bool_t -cass_value_is_collection(const CassValue* value); - -/** - * Returns true if a specified value is a duration. - * - * @public @memberof CassValue - * - * @param[in] value - * @return true if the value is a duration, otherwise false. - */ -CASS_EXPORT cass_bool_t -cass_value_is_duration(const CassValue* value); - -/** - * Get the number of items in a collection. Works for all collection types. - * - * @public @memberof CassValue - * - * @param[in] collection - * @return Count of items in a collection. 0 if not a collection. - */ -CASS_EXPORT size_t -cass_value_item_count(const CassValue* collection); - -/** - * Get the primary sub-type for a collection. This returns the sub-type for a - * list or set and the key type for a map. - * - * @public @memberof CassValue - * - * @param[in] collection - * @return The type of the primary sub-type. CASS_VALUE_TYPE_UNKNOWN - * returned if not a collection. - */ -CASS_EXPORT CassValueType -cass_value_primary_sub_type(const CassValue* collection); - -/** - * Get the secondary sub-type for a collection. This returns the value type for a - * map. - * - * @public @memberof CassValue - * - * @param[in] collection - * @return The type of the primary sub-type. CASS_VALUE_TYPE_UNKNOWN - * returned if not a collection or not a map. - */ -CASS_EXPORT CassValueType -cass_value_secondary_sub_type(const CassValue* collection); - - -/*********************************************************************************** - * - * UUID - * - ************************************************************************************/ - -/** - * Creates a new UUID generator. - * - * Note: This object is thread-safe. It is best practice to create and reuse - * a single object per application. - * - * Note: If unique node information (IP address) is unable to be determined - * then random node information will be generated. - * - * @public @memberof CassUuidGen - * - * @return Returns a UUID generator that must be freed. - * - * @see cass_uuid_gen_free() - * @see cass_uuid_gen_new_with_node() - */ -CASS_EXPORT CassUuidGen* -cass_uuid_gen_new(); - -/** - * Creates a new UUID generator with custom node information. - * - * Note: This object is thread-safe. It is best practice to create and reuse - * a single object per application. - * - * @public @memberof CassUuidGen - * - * @return Returns a UUID generator that must be freed. - * - * @see cass_uuid_gen_free() - */ -CASS_EXPORT CassUuidGen* -cass_uuid_gen_new_with_node(cass_uint64_t node); - -/** - * Frees a UUID generator instance. - * - * @public @memberof CassUuidGen - * - * @param[in] uuid_gen - */ -CASS_EXPORT void -cass_uuid_gen_free(CassUuidGen* uuid_gen); - -/** - * Generates a V1 (time) UUID. - * - * Note: This method is thread-safe - * - * @public @memberof CassUuidGen - * - * @param[in] uuid_gen - * @param[out] output A V1 UUID for the current time. - */ -CASS_EXPORT void -cass_uuid_gen_time(CassUuidGen* uuid_gen, - CassUuid* output); - -/** - * Generates a new V4 (random) UUID - * - * Note:: This method is thread-safe - * - * @public @memberof CassUuidGen - * - * @param[in] uuid_gen - * @param output A randomly generated V4 UUID. - */ -CASS_EXPORT void -cass_uuid_gen_random(CassUuidGen* uuid_gen, - CassUuid* output); - -/** - * Generates a V1 (time) UUID for the specified time. - * - * Note:: This method is thread-safe - * - * @public @memberof CassUuidGen - * - * @param[in] uuid_gen - * @param[in] timestamp - * @param[out] output A V1 UUID for the specified time. - */ -CASS_EXPORT void -cass_uuid_gen_from_time(CassUuidGen* uuid_gen, - cass_uint64_t timestamp, - CassUuid* output); - -/** - * Sets the UUID to the minimum V1 (time) value for the specified time. - * - * @public @memberof CassUuid - * - * @param[in] time - * @param[out] output A minimum V1 UUID for the specified time. - */ -CASS_EXPORT void -cass_uuid_min_from_time(cass_uint64_t time, - CassUuid* output); - -/** - * Sets the UUID to the maximum V1 (time) value for the specified time. - * - * @public @memberof CassUuid - * - * @param[in] time - * @param[out] output A maximum V1 UUID for the specified time. - */ -CASS_EXPORT void -cass_uuid_max_from_time(cass_uint64_t time, - CassUuid* output); - -/** - * Gets the timestamp for a V1 UUID - * - * @public @memberof CassUuid - * - * @param[in] uuid - * @return The timestamp in milliseconds since the Epoch - * (00:00:00 UTC on 1 January 1970). 0 returned if the UUID - * is not V1. - */ -CASS_EXPORT cass_uint64_t -cass_uuid_timestamp(CassUuid uuid); - -/** - * Gets the version for a UUID - * - * @public @memberof CassUuid - * - * @param[in] uuid - * @return The version of the UUID (1 or 4) - */ -CASS_EXPORT cass_uint8_t -cass_uuid_version(CassUuid uuid); - -/** - * Returns a null-terminated string for the specified UUID. - * - * @public @memberof CassUuid - * - * @param[in] uuid - * @param[out] output A null-terminated string of length CASS_UUID_STRING_LENGTH. - */ -CASS_EXPORT void -cass_uuid_string(CassUuid uuid, - char* output); - -/** - * Returns a UUID for the specified string. - * - * Example: "550e8400-e29b-41d4-a716-446655440000" - * - * @public @memberof CassUuid - * - * @param[in] str - * @param[out] output - */ -CASS_EXPORT CassError -cass_uuid_from_string(const char* str, - CassUuid* output); - -/** - * Same as cass_uuid_from_string(), but with lengths for string - * parameters. - * - * @public @memberof CassUuid - * - * @param[in] str - * @param[in] str_length - * @param[out] output - * @return same as cass_uuid_from_string() - * - * @see cass_uuid_from_string() - */ -CASS_EXPORT CassError -cass_uuid_from_string_n(const char* str, - size_t str_length, - CassUuid* output); - -/*********************************************************************************** - * - * Timestamp generators - * - ***********************************************************************************/ - -/** - * Creates a new server-side timestamp generator. This generator allows Cassandra - * to assign timestamps server-side. - * - * Note: This is the default timestamp generator. - * - * @cassandra{2.1+} - * - * @public @memberof CassTimestampGen - * - * @return Returns a timestamp generator that must be freed. - * - * @see cass_timestamp_gen_free() - */ -CASS_EXPORT CassTimestampGen* -cass_timestamp_gen_server_side_new(); - -/** - * Creates a new monotonically increasing timestamp generator with microsecond - * precision. - * - * This implementation guarantees a monotonically increasing timestamp. If the - * timestamp generation rate exceeds one per microsecond or if the clock skews - * into the past the generator will artificially increment the previously - * generated timestamp until the request rate decreases or the clock skew - * is corrected. - * - * By default, this timestamp generator will generate warnings if more than - * 1 second of clock skew is detected. It will print an error every second until - * the clock skew is resolved. These settings can be changed by using - * `cass_timestamp_gen_monotonic_new_with_settings()` to create the generator - * instance. - * - * Note: This generator is thread-safe and can be shared by multiple - * sessions. - * - * @cassandra{2.1+} - * - * @public @memberof CassTimestampGen - * - * @return Returns a timestamp generator that must be freed. - * - * @see cass_timestamp_gen_monotonic_new_with_settings(); - * @see cass_timestamp_gen_free() - */ -CASS_EXPORT CassTimestampGen* -cass_timestamp_gen_monotonic_new(); - -/** - * Same as cass_timestamp_gen_monotonic_new(), but with settings for controlling - * warnings about clock skew. - * - * @param warning_threshold_us The amount of clock skew, in microseconds, that - * must be detected before a warning is triggered. A threshold less than 0 can - * be used to disable warnings. - * @param warning_interval_ms The amount of time, in milliseconds, to wait before - * warning again about clock skew. An interval value less than or equal to 0 allows - * the warning to be triggered every millisecond. - * @return Returns a timestamp generator that must be freed. - */ -CASS_EXPORT CassTimestampGen* -cass_timestamp_gen_monotonic_new_with_settings(cass_int64_t warning_threshold_us, - cass_int64_t warning_interval_ms); - -/** - * Frees a timestamp generator instance. - * - * @cassandra{2.1+} - * - * @public @memberof CassTimestampGen - * - * @param[in] timestamp_gen - */ -CASS_EXPORT void -cass_timestamp_gen_free(CassTimestampGen* timestamp_gen); - - -/*********************************************************************************** - * - * Retry policies - * - ***********************************************************************************/ - -/** - * Creates a new default retry policy. - * - * This policy retries queries in the following cases: - *
    - *
  • On a read timeout, if enough replicas replied but data was not received.
  • - *
  • On a write timeout, if a timeout occurs while writing the distributed batch log
  • - *
  • On unavailable, it will move to the next host
  • - *
- * - * In all other cases the error will be returned. - * - * This policy always uses the query's original consistency level. - * - * @public @memberof CassRetryPolicy - * - * @return Returns a retry policy that must be freed. - * - * @see cass_retry_policy_free() - */ -CASS_EXPORT CassRetryPolicy* -cass_retry_policy_default_new(); - -/** - * Creates a new downgrading consistency retry policy. - * - * Important: This policy may attempt to retry requests with a lower - * consistency level. Using this policy can break consistency guarantees. - * - * This policy will retry in the same scenarios as the default policy, but - * it will also retry in the following cases: - *
    - *
  • On a read timeout, if some replicas responded but is lower than - * required by the current consistency level then retry with a lower - * consistency level.
  • - *
  • On a write timeout, Retry unlogged batches at a lower consistency level - * if at least one replica responded. For single queries and batch if any - * replicas responded then consider the request successful and swallow the - * error.
  • - *
  • On unavailable, retry at a lower consistency if at lease one replica - * responded.
  • - *
- * - * This goal of this policy is to attempt to save a request if there's any - * chance of success. A writes succeeds as long as there's a single copy - * persisted and a read will succeed if there's some data available even - * if it increases the risk of reading stale data. - * - * @deprecated This still works, but should not be used in new applications. It - * can lead to unexpected behavior when the cluster is in a degraded state. - * Instead, applications should prefer using the lowest consistency level on - * statements that can be tolerated by a specific use case. - * - * @public @memberof CassRetryPolicy - * - * @return Returns a retry policy that must be freed. - * - * @see cass_retry_policy_free() - */ -CASS_EXPORT CASS_DEPRECATED(CassRetryPolicy* -cass_retry_policy_downgrading_consistency_new()); - -/** - * Creates a new fallthrough retry policy. - * - * This policy never retries or ignores a server-side failure. The error - * is always returned. - * - * @public @memberof CassRetryPolicy - * - * @return Returns a retry policy that must be freed. - * - * @see cass_retry_policy_free() - */ -CASS_EXPORT CassRetryPolicy* -cass_retry_policy_fallthrough_new(); - -/** - * Creates a new logging retry policy. - * - * This policy logs the retry decision of its child policy. Logging is - * done using CASS_LOG_INFO. - * - * @public @memberof CassRetryPolicy - * - * @param[in] child_retry_policy - * @return Returns a retry policy that must be freed. NULL is returned if - * the child_policy is a logging retry policy. - * - * @see cass_retry_policy_free() - */ -CASS_EXPORT CassRetryPolicy* -cass_retry_policy_logging_new(CassRetryPolicy* child_retry_policy); - -/** - * Frees a retry policy instance. - * - * @public @memberof CassRetryPolicy - * - * @param[in] policy - */ -CASS_EXPORT void -cass_retry_policy_free(CassRetryPolicy* policy); - -/*********************************************************************************** - * - * Custom payload - * - ***********************************************************************************/ - -/** - * Creates a new custom payload. - * - * @public @memberof CassCustomPayload - * - * @cassandra{2.2+} - * - * @return Returns a custom payload that must be freed. - * - * @see cass_custom_payload_free() - */ -CASS_EXPORT CassCustomPayload* -cass_custom_payload_new(); - -/** - * Frees a custom payload instance. - * - * @cassandra{2.2+} - * - * @public @memberof CassCustomPayload - * - * @param[in] payload - */ -CASS_EXPORT void -cass_custom_payload_free(CassCustomPayload* payload); - -/** - * Sets an item to the custom payload. - * - * @cassandra{2.2+} - * - * @public @memberof CassCustomPayload - * - * @param[in] payload - * @param[in] name - * @param[in] value - * @param[in] value_size - */ -CASS_EXPORT void -cass_custom_payload_set(CassCustomPayload* payload, - const char* name, - const cass_byte_t* value, - size_t value_size); - -/** - * Same as cass_custom_payload_set(), but with lengths for string - * parameters. - * - * @cassandra{2.2+} - * - * @public @memberof CassCustomPayload - * - * @param[in] payload - * @param[in] name - * @param[in] name_length - * @param[in] value - * @param[in] value_size - */ -CASS_EXPORT void -cass_custom_payload_set_n(CassCustomPayload* payload, - const char* name, - size_t name_length, - const cass_byte_t* value, - size_t value_size); - -/** - * Removes an item from the custom payload. - * - * @cassandra{2.2+} - * - * @public @memberof CassCustomPayload - * - * @param[in] payload - * @param[in] name - */ -CASS_EXPORT void -cass_custom_payload_remove(CassCustomPayload* payload, - const char* name); - -/** - * Same as cass_custom_payload_set(), but with lengths for string - * parameters. - * - * @cassandra{2.2+} - * - * @public @memberof CassCustomPayload - * - * @param[in] payload - * @param[in] name - * @param[in] name_length - */ -CASS_EXPORT void -cass_custom_payload_remove_n(CassCustomPayload* payload, - const char* name, - size_t name_length); - - -/*********************************************************************************** - * - * Consistency - * - ***********************************************************************************/ - -/** - * Gets the string for a consistency. - * - * @param[in] consistency - * @return A null-terminated string for the consistency. - * Example: "ALL", "ONE", "QUORUM", etc. - */ -CASS_EXPORT const char* -cass_consistency_string(CassConsistency consistency); - -/*********************************************************************************** - * - * Write type - * - ***********************************************************************************/ -/** - * Gets the string for a write type. - * - * @param[in] write_type - * @return A null-terminated string for the write type. - * Example: "BATCH", "SIMPLE", "COUNTER", etc. - */ -CASS_EXPORT const char* -cass_write_type_string(CassWriteType write_type); - -/*********************************************************************************** - * - * Error - * - ***********************************************************************************/ - -/** - * Gets a description for an error code. - * - * @param[in] error - * @return A null-terminated string describing the error. - */ -CASS_EXPORT const char* -cass_error_desc(CassError error); - -/*********************************************************************************** - * - * Log - * - ***********************************************************************************/ - -/** - * Explicitly wait for the log to flush and deallocate resources. - * This *MUST* be the last call using the library. It is an error - * to call any cass_*() functions after this call. - * - * @deprecated This is no longer useful and does nothing. Expect this to be - * removed in a future release. - */ -CASS_EXPORT CASS_DEPRECATED(void -cass_log_cleanup()); - -/** - * Sets the log level. - * - * Note: This needs to be done before any call that might log, such as - * any of the cass_cluster_*() or cass_ssl_*() functions. - * - * Default: CASS_LOG_WARN - * - * @param[in] log_level - */ -CASS_EXPORT void -cass_log_set_level(CassLogLevel log_level); - -/** - * Sets a callback for handling logging events. - * - * Note: This needs to be done before any call that might log, such as - * any of the cass_cluster_*() or cass_ssl_*() functions. - * - * Default: An internal callback that prints to stderr - * - * @param[in] data An opaque data object passed to the callback. - * @param[in] callback A callback that handles logging events. This is - * called in a separate thread so access to shared data must be synchronized. - */ -CASS_EXPORT void -cass_log_set_callback(CassLogCallback callback, - void* data); - -/** - * Sets the log queue size. - * - * Note: This needs to be done before any call that might log, such as - * any of the cass_cluster_*() or cass_ssl_*() functions. - * - * Default: 2048 - * - * @deprecated This is no longer useful and does nothing. Expect this to be - * removed in a future release. - * - * @param[in] queue_size - */ -CASS_EXPORT CASS_DEPRECATED(void -cass_log_set_queue_size(size_t queue_size)); - -/** - * Gets the string for a log level. - * - * @param[in] log_level - * @return A null-terminated string for the log level. - * Example: "ERROR", "WARN", "INFO", etc. - */ -CASS_EXPORT const char* -cass_log_level_string(CassLogLevel log_level); - -/*********************************************************************************** - * - * Inet - * - ************************************************************************************/ - -/** - * Constructs an inet v4 object. - * - * @public @memberof CassInet - * - * @param[in] address An address of size CASS_INET_V4_LENGTH - * @return An inet object. - */ -CASS_EXPORT CassInet -cass_inet_init_v4(const cass_uint8_t* address); - -/** - * Constructs an inet v6 object. - * - * @public @memberof CassInet - * - * @param[in] address An address of size CASS_INET_V6_LENGTH - * @return An inet object. - */ -CASS_EXPORT CassInet -cass_inet_init_v6(const cass_uint8_t* address); - -/** - * Returns a null-terminated string for the specified inet. - * - * @public @memberof CassInet - * - * @param[in] inet - * @param[out] output A null-terminated string of length CASS_INET_STRING_LENGTH. - */ -CASS_EXPORT void -cass_inet_string(CassInet inet, - char* output); - -/** - * Returns an inet for the specified string. - * - * Examples: "127.0.0.1" or "::1" - * - * @public @memberof CassInet - * - * @param[in] str - * @param[out] output - */ -CASS_EXPORT CassError -cass_inet_from_string(const char* str, - CassInet* output); - -/** - * Same as cass_inet_from_string(), but with lengths for string - * parameters. - * - * @public @memberof CassInet - * - * @param[in] str - * @param[in] str_length - * @param[out] output - * @return same as cass_inet_from_string() - * - * @see cass_inet_from_string() - */ -CASS_EXPORT CassError -cass_inet_from_string_n(const char* str, - size_t str_length, - CassInet* output); - -/*********************************************************************************** - * - * Date/Time - * - ************************************************************************************/ - -/** - * Converts a unix timestamp (in seconds) to the Cassandra "date" type. The "date" type - * represents the number of days since the Epoch (1970-01-01) with the Epoch centered at - * the value 2^31. - * - * @cassandra{2.2+} - * - * @param[in] epoch_secs - * @return the number of days since the date -5877641-06-23 - */ -CASS_EXPORT cass_uint32_t -cass_date_from_epoch(cass_int64_t epoch_secs); - -/** - * Converts a unix timestamp (in seconds) to the Cassandra "time" type. The "time" type - * represents the number of nanoseconds since midnight (range 0 to 86399999999999). - * - * @cassandra{2.2+} - * - * @param[in] epoch_secs - * @return nanoseconds since midnight - */ -CASS_EXPORT cass_int64_t -cass_time_from_epoch(cass_int64_t epoch_secs); - -/** - * Combines the Cassandra "date" and "time" types to Epoch time in seconds. - * - * @cassandra{2.2+} - * - * @param[in] date - * @param[in] time - * @return Epoch time in seconds. Negative times are possible if the date - * occurs before the Epoch (1970-1-1). - */ -CASS_EXPORT cass_int64_t -cass_date_time_to_epoch(cass_uint32_t date, - cass_int64_t time); - -/*********************************************************************************** - * - * Allocator - * - ************************************************************************************/ - -/** - * Set custom allocation functions. - * - * Note: This is not thread-safe. The allocation functions must be set - * before any other library function is called. - * - * Default: The C runtime's malloc(), realloc() and free() - * - * Important: The C runtime's malloc(), realloc() and free() will be - * used by libuv when using versions 1.5 or earlier. - * - * @param[in] malloc_func - * @param[in] realloc_func - * @param[in] free_func - */ -CASS_EXPORT void -cass_alloc_set_functions(CassMallocFunction malloc_func, - CassReallocFunction realloc_func, - CassFreeFunction free_func); - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* __CASS_H_INCLUDED__ */ From 0afb44b1c5b2fb4e6dc77894cb140386db2d9b9a Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Sat, 14 Mar 2026 09:40:35 +0700 Subject: [PATCH 10/13] docs: add Chinese translation for Cassandra/ScyllaDB documentation --- docs/docs.json | 2 + docs/zh/databases/cassandra.mdx | 356 ++++++++++++++++++++++++++ docs/zh/databases/connection-urls.mdx | 12 + docs/zh/databases/overview.mdx | 21 +- 4 files changed, 386 insertions(+), 5 deletions(-) create mode 100644 docs/zh/databases/cassandra.mdx diff --git a/docs/docs.json b/docs/docs.json index 8101323f0..2e2a5bfec 100644 --- a/docs/docs.json +++ b/docs/docs.json @@ -233,6 +233,8 @@ "zh/databases/redshift", "zh/databases/oracle", "zh/databases/clickhouse", + "zh/databases/cassandra", + "zh/databases/duckdb", "zh/databases/mssql", "zh/databases/oracle", "zh/databases/ssh-tunneling" diff --git a/docs/zh/databases/cassandra.mdx b/docs/zh/databases/cassandra.mdx new file mode 100644 index 000000000..bddb11336 --- /dev/null +++ b/docs/zh/databases/cassandra.mdx @@ -0,0 +1,356 @@ +--- +title: Cassandra / ScyllaDB +description: 连接 Cassandra 和 ScyllaDB 集群,浏览 keyspace,执行 CQL 查询 +--- + +# Cassandra / ScyllaDB 连接 + +TablePro 通过 CQL 原生协议支持 Apache Cassandra 3.11+ 和 ScyllaDB 4.0+。浏览 keyspace、查看表结构、查看物化视图,并在编辑器中执行 CQL 查询。 + +## 快速设置 + + + + 在欢迎界面点击 **New Connection**,或选择 **File** > **New Connection** + + + 从数据库类型选择器中选择 **Cassandra** 或 **ScyllaDB** + + + 填写 host、port、username、password 和 keyspace + + + 点击 **Test Connection**,然后点击 **Create** + + + +## 连接设置 + +### 必填字段 + +| 字段 | 描述 | 默认值 | +|-------|-------------|---------| +| **Name** | 连接标识名称 | - | +| **Host** | Contact point 主机名或 IP | `localhost` | +| **Port** | CQL 原生传输端口 | `9042` | + +### 可选字段 + +| 字段 | 描述 | +|-------|-------------| +| **Username** | 认证用户名 | +| **Password** | 认证密码 | +| **Keyspace** | 连接后使用的默认 keyspace | + + +本地 Cassandra 安装通常未启用认证。本地开发时可以留空 username 和 password。 + + +## 连接 URL 格式 + +使用 Cassandra 或 ScyllaDB URL 导入连接。 + +参阅 [连接 URL 参考](/zh/databases/connection-urls#cassandra--scylladb) 了解完整的 URL 格式。 + +## 配置示例 + +### 本地开发服务器 + +```text +Name: Local Cassandra +Host: localhost +Port: 9042 +Username: (留空) +Password: (留空) +Keyspace: my_keyspace +``` + +### Docker Cassandra 容器 + +```text +Name: Docker Cassandra +Host: localhost +Port: 9042(或你映射的端口) +Username: cassandra +Password: cassandra +Keyspace: (留空) +``` + +### DataStax Astra DB(云) + +```text +Name: Astra DB +Host: -.apps.astra.datastax.com +Port: 29042 +Username: (来自 token 的 Client ID) +Password: (来自 token 的 Client Secret) +Keyspace: my_keyspace +``` + + +Astra DB 需要 Secure Connect Bundle 进行 TLS 连接。从 Astra 控制面板下载 bundle 并在 SSL/TLS 部分配置。 + + +### 远程服务器 + +```text +Name: Production Cassandra +Host: cassandra.example.com +Port: 9042 +Username: app_user +Password: (安全密码) +Keyspace: production +``` + + +对于生产环境的 Cassandra 集群,建议使用 [SSH tunneling](/zh/databases/ssh-tunneling) 进行安全连接。 + + +## SSL/TLS 连接 + +在连接表单的 **SSL/TLS** 部分配置 SSL。 + +| SSL 模式 | 描述 | +|----------|-------------| +| **Disabled** | 不使用 SSL 加密 | +| **Required** | 要求 SSL 加密 | +| **Verify CA** | 要求 SSL 并验证服务器证书是否由 CA 签发 | + +对于 **Verify CA** 模式,需要提供 CA 证书文件路径。也可以提供可选的客户端证书和密钥文件以实现 mutual TLS。 + + +如果不想配置 SSL 证书,[SSH tunneling](/zh/databases/ssh-tunneling) 可以通过 SSH tunnel 加密所有流量。 + + +## SSH Tunnel 支持 + +通过 SSH tunnel 连接 Cassandra 以安全访问远程集群。设置方法请参阅 [SSH Tunneling](/zh/databases/ssh-tunneling)。 + +## 功能 + +### Keyspace 浏览 + +连接后,侧栏会列出所有 keyspace。展开 keyspace 可以查看其表、物化视图、用户自定义类型(UDT)和二级索引。 + +1. 点击侧栏中的连接名称 +2. 展开 keyspace 查看其对象 +3. 点击表查看数据 + +### 表结构 + +查看任意表的完整 schema: + +- **列**:名称、CQL 类型、聚簇排序 +- **分区键**:决定数据分布的列 +- **聚簇列**:决定分区内行排序的列 +- **二级索引**:索引名称、目标列、索引类 +- **表选项**:压缩策略、压缩方式、TTL 默认值、gc_grace_seconds + +### 物化视图 + +在侧栏中可以与表一起浏览物化视图。查看视图定义、基表和列映射。 + +### 数据网格 + +带分页的表数据浏览。单元格值以 CQL 类型感知的格式显示: + +- **text/varchar** 值显示为纯文本 +- **int/bigint/varint** 显示为数字 +- **uuid/timeuuid** 显示为格式化的 UUID +- **timestamp** 值以可配置的日期格式显示 +- **map/set/list/tuple** 显示为格式化的集合 +- **blob** 值显示为十六进制 + +### CQL 编辑器 + +在编辑器标签页中直接执行 CQL 语句: + +```sql +-- 使用分区键限制查询 +SELECT * FROM users WHERE user_id = 123e4567-e89b-12d3-a456-426614174000; + +-- 插入数据 +INSERT INTO users (user_id, name, email, created_at) +VALUES (uuid(), 'Alice', 'alice@example.com', toTimestamp(now())); + +-- 带 TTL 的更新 +UPDATE users USING TTL 86400 +SET email = 'new@example.com' +WHERE user_id = 123e4567-e89b-12d3-a456-426614174000; + +-- 删除 +DELETE FROM users WHERE user_id = 123e4567-e89b-12d3-a456-426614174000; + +-- 创建表 +CREATE TABLE IF NOT EXISTS events ( + event_id timeuuid, + user_id uuid, + event_type text, + payload text, + PRIMARY KEY ((user_id), event_id) +) WITH CLUSTERING ORDER BY (event_id DESC); + +-- 创建索引 +CREATE INDEX ON users (email); + +-- 描述表 +DESCRIBE TABLE users; +``` + +## CQL 特殊说明 + +Cassandra Query Language (CQL) 看起来像 SQL,但有重要区别: + +### 不支持 JOIN +CQL 不支持 JOIN 操作。请围绕查询模式设计数据模型,按需在多个表中反规范化数据。 + +### 不支持子查询 + +CQL 不支持子查询。将复杂查询拆分为多条顺序执行的语句。 + +### 分区键限制 + +每个 SELECT 查询的 WHERE 子句中必须包含完整的分区键,除非使用 `ALLOW FILTERING`(这会扫描整个集群,在生产环境中应避免使用)。 + +```sql +-- 正确:包含分区键 +SELECT * FROM orders WHERE customer_id = 42; + +-- 错误:缺少分区键,需要 ALLOW FILTERING +SELECT * FROM orders WHERE total > 100 ALLOW FILTERING; +``` + +### ALLOW FILTERING + +`ALLOW FILTERING` 子句会强制执行全集群扫描。它适用于开发和小型数据集,但在生产集群上会导致超时和性能问题。当查询包含 `ALLOW FILTERING` 时,TablePro 会显示警告。 + +### 轻量级事务 + +Cassandra 支持使用 `IF` 子句的条件写入(轻量级事务 / compare-and-set): + +```sql +INSERT INTO users (user_id, email) VALUES (uuid(), 'alice@example.com') IF NOT EXISTS; +UPDATE users SET email = 'new@example.com' WHERE user_id = ? IF email = 'old@example.com'; +``` + +### TTL 和 Writetime + +设置每行或每列的 TTL(生存时间),单位为秒: + +```sql +INSERT INTO cache (key, value) VALUES ('k1', 'v1') USING TTL 3600; +SELECT TTL(value), WRITETIME(value) FROM cache WHERE key = 'k1'; +``` + +## 故障排除 + +### 连接被拒绝 + +**症状**:"Connection refused" 或超时 + +**原因及解决方案**: + +1. **Cassandra 未运行** + ```bash + # 检查 Cassandra 是否运行 + nodetool status + + # 启动 Cassandra(macOS Homebrew) + brew services start cassandra + + # 启动 Cassandra(Docker) + docker run -d -p 9042:9042 cassandra:latest + ``` + +2. **端口错误** + - 检查 `cassandra.yaml` 中的 `native_transport_port` + - 默认 CQL 端口是 `9042`,不是 `9160`(Thrift,已废弃) + +3. **Cassandra 未监听预期地址** + - 检查 `cassandra.yaml` 中的 `rpc_address` 和 `listen_address` + - 对于远程连接,将 `rpc_address` 设为 `0.0.0.0` + +### 认证失败 + +**症状**:"Provided username and/or password are incorrect" + +**解决方案**: + +1. 验证凭据是否匹配 Cassandra 中配置的角色 +2. 检查认证是否已启用: + ```yaml + # cassandra.yaml + authenticator: PasswordAuthenticator + ``` +3. 默认超级用户为 `cassandra` / `cassandra`(生产环境中请更改) + +### 连接超时 + +**症状**:连接挂起或超时 + +**解决方案**: + +1. 验证 host 和 port 是否正确 +2. 检查网络连通性和防火墙规则(端口 9042) +3. 对于云托管的 Cassandra,确保你的 IP 已加入白名单 +4. 在 Advanced 标签页中增加连接超时时间 + +### 读取超时 + +**症状**:"Read timed out" + +**解决方案**: + +1. 在 WHERE 子句中添加完整的分区键 +2. 移除 `ALLOW FILTERING` 并重新设计查询 +3. 使用 `nodetool status` 检查集群健康状况 +4. 使用 `LIMIT` 限制结果集大小 + +## 已知限制 + +- **多数据中心**:尚不支持连接到特定数据中心。TablePro 连接到 contact point 解析到的节点。 +- **User-Defined Functions (UDFs)**:UDF 和 UDA 不会显示在侧栏中,但可以在 CQL 查询中使用。 +- **BATCH 语句**:在 CQL 编辑器中支持,但不会由变更跟踪系统生成。 +- **Counter 表**:counter 列在数据网格中为只读。使用 CQL 编辑器更新 counter。 +- **大分区**:包含数百万行的分区会自动分页以防止内存问题。 + +## 性能建议 + +### 查询性能 + +对于大数据集的 Cassandra 集群: + +1. 始终在 WHERE 子句中包含分区键 +2. 在生产环境中避免使用 `ALLOW FILTERING` +3. 使用 `LIMIT` 限制结果集大小 +4. 使用 `TOKEN()` 进行跨分区的范围扫描 + +### 监控 + +检查集群健康状况和性能: + +```sql +-- 检查集群状态(通过 nodetool,非 CQL) +-- nodetool status +-- nodetool info + +-- 检查表统计信息 +SELECT * FROM system.size_estimates WHERE keyspace_name = 'my_keyspace'; +``` + +## 后续步骤 + + + + 安全连接远程 Cassandra 集群 + + + 掌握查询编辑器功能 + + + 导入和导出 Cassandra 数据 + + + 在数据网格中浏览和编辑数据 + + diff --git a/docs/zh/databases/connection-urls.mdx b/docs/zh/databases/connection-urls.mdx index 230e0db8a..1320183eb 100644 --- a/docs/zh/databases/connection-urls.mdx +++ b/docs/zh/databases/connection-urls.mdx @@ -25,6 +25,8 @@ TablePro 解析标准的数据库连接 URL,用于导入连接、从浏览器 | `sqlserver://` | Microsoft SQL Server(别名) | | `oracle://` | Oracle Database | | `jdbc:oracle:thin:@//` | Oracle Database(JDBC thin) | +| `cassandra://` | Cassandra | +| `scylladb://` | ScyllaDB | 在任意 scheme 后追加 `+ssh`(SQLite 除外)即可使用 SSH tunnel: @@ -164,6 +166,16 @@ redis://:password@host:6379/2 # 数据库索引 2 rediss://:password@host:6380 # TLS,默认索引 0 ``` +### Cassandra / ScyllaDB + +路径部分设置默认 keyspace。`cassandra://` 和 `scylladb://` 使用相同的格式。 + +```text +cassandra://user:pass@host:9042/my_keyspace +scylladb://user:pass@host:9042/my_keyspace +cassandra://host:9042 # 无认证,无默认 keyspace +``` + ### SSH Tunnel | 参数 | 描述 | diff --git a/docs/zh/databases/overview.mdx b/docs/zh/databases/overview.mdx index a60e5e612..fe2920157 100644 --- a/docs/zh/databases/overview.mdx +++ b/docs/zh/databases/overview.mdx @@ -1,15 +1,15 @@ --- title: 连接管理 -description: 在 TablePro 中创建、组织和管理 10 种数据库引擎的连接 +description: 在 TablePro 中创建、组织和管理 12 种数据库引擎的连接 --- # 连接管理 -TablePro 通过统一界面连接十种数据库系统。你可以创建连接、用颜色、标签和分组来组织它们,并在不离开当前工作区的情况下自由切换。 +TablePro 通过统一界面连接十二种数据库系统。你可以创建连接、用颜色、标签和分组来组织它们,并在不离开当前工作区的情况下自由切换。 ## 支持的数据库 -TablePro 原生支持十种数据库系统: +TablePro 原生支持十二种数据库系统: @@ -42,6 +42,12 @@ TablePro 原生支持十种数据库系统: ClickHouse OLAP 数据库,通过 HTTP API 连接。默认端口:8123 + + Cassandra 3.11+ 和 ScyllaDB 4.0+,通过 CQL 原生协议连接。默认端口:9042 + + + DuckDB 嵌入式分析数据库。基于文件 + ## 创建连接 @@ -105,7 +111,7 @@ open "mysql://root:secret@localhost:3306/myapp" open "redis://:password@localhost:6379" ``` -TablePro 在 macOS 上注册了 `postgresql`、`postgres`、`mysql`、`mariadb`、`sqlite`、`mongodb`、`mongodb+srv`、`redis`、`rediss`、`redshift`、`mssql`、`sqlserver`、`oracle` 和 `clickhouse` 作为 URL scheme,因此系统会直接将这些 URL 路由到应用。 +TablePro 在 macOS 上注册了 `postgresql`、`postgres`、`mysql`、`mariadb`、`sqlite`、`mongodb`、`mongodb+srv`、`redis`、`rediss`、`redshift`、`mssql`、`sqlserver`、`oracle`、`clickhouse`、`cassandra`、`scylladb` 和 `duckdb` 作为 URL scheme,因此系统会直接将这些 URL 路由到应用。 **打开 URL 后的行为:** @@ -128,7 +134,7 @@ TablePro 在 macOS 上注册了 `postgresql`、`postgres`、`mysql`、`mariadb` | 字段 | 描述 | |-------|-------------| | **Name** | 用于标识此连接的名称 | -| **Type** | 数据库类型:MySQL、MariaDB、PostgreSQL、SQLite、MongoDB、Redis、Redshift、SQL Server 或 Oracle | +| **Type** | 数据库类型:MySQL、MariaDB、PostgreSQL、SQLite、MongoDB、Redis、Redshift、SQL Server、Oracle、ClickHouse、Cassandra、ScyllaDB 或 DuckDB | #### Appearance 部分 @@ -569,6 +575,8 @@ cp ~/Desktop/tablepro-backup.plist ~/Library/Preferences/com.TablePro.plist | Microsoft SQL Server | 1433 | | Oracle Database | 1521 | | ClickHouse | 8123 | +| Cassandra / ScyllaDB | 9042 | +| DuckDB | 不适用(基于文件) | ## 相关指南 @@ -600,6 +608,9 @@ cp ~/Desktop/tablepro-backup.plist ~/Library/Preferences/com.TablePro.plist 连接 ClickHouse OLAP 数据库 + + 连接 Cassandra 和 ScyllaDB 集群 + 通过 SSH 安全连接 From 8063e9f4e45de6a3029a82f83582a6a4db93c185 Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Sat, 14 Mar 2026 09:44:25 +0700 Subject: [PATCH 11/13] chore: remove extra blank line in build-release.sh --- scripts/build-release.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/build-release.sh b/scripts/build-release.sh index 6c8268377..070feeb12 100755 --- a/scripts/build-release.sh +++ b/scripts/build-release.sh @@ -180,7 +180,6 @@ prepare_hiredis() { echo "✅ hiredis libraries ready for $target_arch" } - # Bundle non-system dynamic libraries into the app bundle # so the app runs without Homebrew on end-user machines. bundle_dylibs() { From 7033779f7b205e77737561f9c2dbacad07c936e2 Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Sat, 14 Mar 2026 09:49:52 +0700 Subject: [PATCH 12/13] refactor: move Cassandra dialect and metadata from core app into plugin --- .../CassandraPlugin.swift | 69 +++++++++++++++++++ .../Services/Query/SQLDialectProvider.swift | 61 ---------------- 2 files changed, 69 insertions(+), 61 deletions(-) diff --git a/Plugins/CassandraDriverPlugin/CassandraPlugin.swift b/Plugins/CassandraDriverPlugin/CassandraPlugin.swift index 61efd2d18..9231e1f4a 100644 --- a/Plugins/CassandraDriverPlugin/CassandraPlugin.swift +++ b/Plugins/CassandraDriverPlugin/CassandraPlugin.swift @@ -35,6 +35,75 @@ internal final class CassandraPlugin: NSObject, TableProPlugin, DriverPlugin { ] static let additionalDatabaseTypeIds: [String] = ["ScyllaDB"] + // MARK: - UI/Capability Metadata + + static let urlSchemes: [String] = ["cassandra", "cql", "scylladb", "scylla"] + static let requiresAuthentication = false + static let supportsForeignKeys = false + static let brandColorHex = "#26A0D8" + static let queryLanguageName = "CQL" + static let supportsDatabaseSwitching = true + static let databaseGroupingStrategy: GroupingStrategy = .byDatabase + static let defaultGroupName = "default" + static let systemDatabaseNames: [String] = [ + "system", "system_schema", "system_auth", + "system_distributed", "system_traces", "system_virtual_schema", + ] + static let supportsImport = false + static let supportsExport = true + static let supportsCascadeDrop = false + static let supportsForeignKeyDisable = false + static let supportsSSH = true + static let supportsSSL = true + static let columnTypesByCategory: [String: [String]] = [ + "Numeric": ["TINYINT", "SMALLINT", "INT", "BIGINT", "VARINT", "FLOAT", "DOUBLE", "DECIMAL", "COUNTER"], + "String": ["TEXT", "VARCHAR", "ASCII"], + "Date": ["TIMESTAMP", "DATE", "TIME"], + "Binary": ["BLOB"], + "Boolean": ["BOOLEAN"], + "Other": ["UUID", "TIMEUUID", "INET", "LIST", "SET", "MAP", "TUPLE", "FROZEN"], + ] + + static var sqlDialect: SQLDialectDescriptor? { + SQLDialectDescriptor( + identifierQuote: "\"", + keywords: [ + "SELECT", "FROM", "WHERE", "AND", "OR", "NOT", "IN", "AS", + "ORDER", "BY", "LIMIT", + "INSERT", "INTO", "VALUES", "UPDATE", "SET", "DELETE", + "CREATE", "ALTER", "DROP", "TABLE", "INDEX", "VIEW", + "PRIMARY", "KEY", "ADD", "COLUMN", "RENAME", + "NULL", "IS", "ASC", "DESC", "DISTINCT", + "CASE", "WHEN", "THEN", "ELSE", "END", + "KEYSPACE", "USE", "TRUNCATE", "BATCH", "GRANT", "REVOKE", + "CLUSTERING", "PARTITION", "TTL", "WRITETIME", + "ALLOW FILTERING", "IF NOT EXISTS", "IF EXISTS", + "USING TIMESTAMP", "USING TTL", + "MATERIALIZED VIEW", "CONTAINS", "FROZEN", "COUNTER", "TOKEN", + ], + functions: [ + "COUNT", "SUM", "AVG", "MAX", "MIN", + "NOW", "UUID", "TOTIMESTAMP", "TOKEN", "TTL", "WRITETIME", + "MINTIMEUUID", "MAXTIMEUUID", "TODATE", "TOUNIXTIMESTAMP", + "CAST", + ], + dataTypes: [ + "TEXT", "VARCHAR", "ASCII", + "INT", "BIGINT", "SMALLINT", "TINYINT", "VARINT", + "FLOAT", "DOUBLE", "DECIMAL", + "BOOLEAN", "UUID", "TIMEUUID", + "TIMESTAMP", "DATE", "TIME", + "BLOB", "INET", "COUNTER", + "LIST", "SET", "MAP", "TUPLE", "FROZEN", + ], + regexSyntax: .unsupported, + booleanLiteralStyle: .truefalse, + likeEscapeStyle: .explicit, + paginationStyle: .limit, + autoLimitStyle: .limit + ) + } + func createDriver(config: DriverConnectionConfig) -> any PluginDatabaseDriver { CassandraPluginDriver(config: config) } diff --git a/TablePro/Core/Services/Query/SQLDialectProvider.swift b/TablePro/Core/Services/Query/SQLDialectProvider.swift index 82a12172f..e64ef7b40 100644 --- a/TablePro/Core/Services/Query/SQLDialectProvider.swift +++ b/TablePro/Core/Services/Query/SQLDialectProvider.swift @@ -33,67 +33,6 @@ private struct EmptyDialect: SQLDialectProvider { let dataTypes: Set = [] } -// MARK: - Cassandra/ScyllaDB Dialect - -struct CassandraDialect: SQLDialectProvider { - let identifierQuote = "\"" - - let keywords: Set = [ - // Core DML keywords - "SELECT", "FROM", "WHERE", "AND", "OR", "NOT", "IN", "AS", - "ORDER", "BY", "LIMIT", - "INSERT", "INTO", "VALUES", "UPDATE", "SET", "DELETE", - - // DDL keywords - "CREATE", "ALTER", "DROP", "TABLE", "INDEX", "VIEW", - "PRIMARY", "KEY", "ADD", "COLUMN", "RENAME", - - // Data attributes - "NULL", "IS", "ASC", "DESC", "DISTINCT", - - // Control flow - "CASE", "WHEN", "THEN", "ELSE", "END", - - // Cassandra-specific - "KEYSPACE", "USE", "TRUNCATE", "BATCH", "GRANT", "REVOKE", - "CLUSTERING", "PARTITION", "TTL", "WRITETIME", - "ALLOW FILTERING", "IF NOT EXISTS", "IF EXISTS", - "USING TIMESTAMP", "USING TTL", - "MATERIALIZED VIEW", "CONTAINS", "FROZEN", "COUNTER", "TOKEN" - ] - - let functions: Set = [ - // Aggregate - "COUNT", "SUM", "AVG", "MAX", "MIN", - - // Cassandra-specific - "NOW", "UUID", "TOTIMESTAMP", "TOKEN", "TTL", "WRITETIME", - "MINTIMEUUID", "MAXTIMEUUID", "TODATE", "TOUNIXTIMESTAMP", - - // Conversion - "CAST" - ] - - let dataTypes: Set = [ - // String types - "TEXT", "VARCHAR", "ASCII", - - // Integer types - "INT", "BIGINT", "SMALLINT", "TINYINT", "VARINT", - - // Decimal types - "FLOAT", "DOUBLE", "DECIMAL", - - // Other types - "BOOLEAN", "UUID", "TIMEUUID", - "TIMESTAMP", "DATE", "TIME", - "BLOB", "INET", "COUNTER", - - // Collection types - "LIST", "SET", "MAP", "TUPLE", "FROZEN" - ] -} - // MARK: - Dialect Factory struct SQLDialectFactory { From 2fbb90b8d85b21746ad8ae9ce44764ed8805c130 Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Sat, 14 Mar 2026 09:52:16 +0700 Subject: [PATCH 13/13] refactor: remove redundant explicit no-op case in DatabaseDriver switch --- TablePro/Core/Database/DatabaseDriver.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/TablePro/Core/Database/DatabaseDriver.swift b/TablePro/Core/Database/DatabaseDriver.swift index 110b2493b..364025e73 100644 --- a/TablePro/Core/Database/DatabaseDriver.swift +++ b/TablePro/Core/Database/DatabaseDriver.swift @@ -389,8 +389,6 @@ enum DatabaseDriverFactory { fields["mssqlSchema"] = connection.mssqlSchema ?? "dbo" case .oracle: fields["oracleServiceName"] = connection.oracleServiceName ?? "" - case .mysql, .mariadb, .sqlite, .clickhouse, .postgresql, .redshift, .cassandra, .scylladb, .duckdb: - break default: break }