class SQLRConnection

Public Class Methods

new(host, port, socket, user, password, retrytime, tries) click to toggle source

Initiates a connection to “host” on “port” or to the unix “socket” on the local machine and auths with “user” and “password”. Failed connections will be retried for “tries” times, waiting “retrytime” seconds between each try. If “tries” is 0 then retries will continue forever. If “retrytime” is 0 then retries will be attempted on a default interval.

If “server” is a comma-separated list of hosts, then an attempt will be made to connect to each until the attempt succeeds, or there are no more hosts left to try.

If the “socket” parameter is neither nil nor “” then an attempt will be made to connect through it before attempting to connect to “host” on “port”. If it is nil or “” then no attempt will be made to connect through the socket.

static VALUE sqlrcon_new(VALUE self, VALUE host, VALUE port, VALUE socket,
                                VALUE user, VALUE password,
                                VALUE retrytime, VALUE tries) {
        sqlrconnection *sqlrcon=new sqlrconnection(STR2CSTR_NIL(host),
                                                        NUM2INT(port),
                                                        STR2CSTR_NIL(socket),
                                                        STR2CSTR_NIL(user),
                                                        STR2CSTR_NIL(password),
                                                        NUM2INT(retrytime),
                                                        NUM2INT(tries),
                                                        true);
        return Data_Wrap_Struct(self,0,sqlrcon_free,(void *)sqlrcon);
}

Public Instance Methods

autoCommitOff() click to toggle source

Instructs the database to wait for the client to tell it when to commit.

static VALUE sqlrcon_autoCommitOff(VALUE self) {
        sqlrconnection *sqlrcon;
        bool           result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,br,sqlrcon,autoCommitOff);
        return INT2NUM(result);
}
autoCommitOn() click to toggle source

Instructs the database to perform a commit after every successful query.

static VALUE sqlrcon_autoCommitOn(VALUE self) {
        sqlrconnection *sqlrcon;
        bool           result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,br,sqlrcon,autoCommitOn);
        return INT2NUM(result);
}
begin() click to toggle source

Begins a transaction. Returns true if the begin succeeded, false if it failed. If the database automatically begins a new transaction when a commit or rollback is issued then this doesn’t do anything unless SQL Relay is faking transaction blocks.

static VALUE sqlrcon_begin(VALUE self) {
        sqlrconnection *sqlrcon;
        bool           result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,br,sqlrcon,begin);
        return INT2NUM(result);
}
bindFormat() click to toggle source

Returns a string representing the bind variable format used by the database. For example:

? - database uses a ? to represent a bind variable @* - database uses a @ followed by any characters to

represent a bind variable

$1 - database uses a $ followed by a number to represent a

bind variable

:* - database uses a : followed by any characters to

represent a bind variable
static VALUE sqlrcon_bindFormat(VALUE self) {
        sqlrconnection *sqlrcon;
        const char     *result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,ccpr,sqlrcon,bindFormat);
        if (result) {
                return rb_str_new2(result);
        } else {
                return Qnil;
        }
}
clientVersion() click to toggle source

Returns the version of the sqlrelay client software.

static VALUE sqlrcon_clientVersion(VALUE self) {
        sqlrconnection *sqlrcon;
        const char     *result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,ccpr,sqlrcon,clientVersion);
        if (result) {
                return rb_str_new2(result);
        } else {
                return Qnil;
        }
}
commit() click to toggle source

Commits a transaction. Returns true if the commit succeeded, false if it failed.

static VALUE sqlrcon_commit(VALUE self) {
        sqlrconnection *sqlrcon;
        bool           result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,br,sqlrcon,commit);
        return INT2NUM(result);
}
dbHostName() click to toggle source

Returns the host name of the database

static VALUE sqlrcon_dbHostName(VALUE self) {
        sqlrconnection *sqlrcon;
        const char     *result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,ccpr,sqlrcon,dbHostName);
        if (result) {
                return rb_str_new2(result);
        } else {
                return Qnil;
        }
}
dbIpAddress() click to toggle source

Returns the ip address of the database

static VALUE sqlrcon_dbIpAddress(VALUE self) {
        sqlrconnection *sqlrcon;
        const char     *result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,ccpr,sqlrcon,dbIpAddress);
        if (result) {
                return rb_str_new2(result);
        } else {
                return Qnil;
        }
}
dbVersion() click to toggle source

Returns the version of the database

static VALUE sqlrcon_dbVersion(VALUE self) {
        sqlrconnection *sqlrcon;
        const char     *result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,ccpr,sqlrcon,dbVersion);
        if (result) {
                return rb_str_new2(result);
        } else {
                return Qnil;
        }
}
debugOff() click to toggle source

Turns debugging off.

static VALUE sqlrcon_debugOff(VALUE self) {
        sqlrconnection *sqlrcon;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        CON(sqlrcon,debugOff);
        return Qnil;
}
debugOn() click to toggle source

Causes verbose debugging information to be sent to standard output. Another way to do this is to start a query with “– debugn”. Yet another way is to set the environment variable SQLR_CLIENT_DEBUG to “ON”

static VALUE sqlrcon_debugOn(VALUE self) {
        sqlrconnection *sqlrcon;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        CON(sqlrcon,debugOn);
        return Qnil;
}
disableEncryption() click to toggle source

Disables encryption.

static VALUE sqlrcon_disableEncryption(VALUE self) {
        sqlrconnection *sqlrcon;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        CON(sqlrcon,disableEncryption);
        return Qnil;
}
enableKerberos(p1, p2, p3) click to toggle source

Enables Kerberos authentication and encryption.

“service” indicates the Kerberos service name of the SQL Relay server. If left empty or NULL then the service name “sqlrelay” will be used. “sqlrelay” is the default service name of the SQL Relay server. Note that on Windows platforms the service name must be fully qualified, including the host and realm name. For example: “sqlrelay/sqlrserver.firstworks.com@AD.FIRSTWORKS.COM”.

“mech” indicates the specific Kerberos mechanism to use. On Linux/Unix platforms, this should be a string representation of the mechnaism’s OID, such as:

{ 1 2 840 113554 1 2 2 }

On Windows platforms, this should be a string like:

Kerberos

If left empty or NULL then the default mechanism will be used. Only set this if you know that you have a good reason to.

“flags” indicates what Kerberos flags to use. Multiple flags may be specified, separated by commas. If left empty or NULL then a defalt set of flags will be used. Only set this if you know that you have a good reason to.

Valid flags include:

* GSS_C_MUTUAL_FLAG
* GSS_C_REPLAY_FLAG
* GSS_C_SEQUENCE_FLAG
* GSS_C_CONF_FLAG
* GSS_C_INTEG_FLAG

For a full list of flags, consult the GSSAPI documentation, though note that only the flags listed above are supported on Windows.

static VALUE sqlrcon_enableKerberos(VALUE self,
                                VALUE service, VALUE mech, VALUE flags) {
        sqlrconnection *sqlrcon;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        CON3(sqlrcon,enableKerberos,service,mech,flags);
        return Qnil;
}
enableTls(p1, p2, p3, p4, p5, p6, p7) click to toggle source

Enables TLS/SSL encryption, and optionally authentication.

“version” specifies the TLS/SSL protocol version that the client will attempt to use. Valid values include SSL2, SSL3, TLS1, TLS1.1, TLS1.2 or any more recent version of TLS, as supported by and enabled in the underlying TLS/SSL library. If left blank or empty then the highest supported version will be negotiated.

“cert” is the file name of the certificate chain file to send to the SQL Relay server. This is only necessary if the SQL Relay server is configured to authenticate and authorize clients by certificate.

If “cert” contains a password-protected private key, then “password” may be supplied to access it. If the private key is not password-protected, then this argument is ignored, and may be left empty or NULL.

“ciphers” is a list of ciphers to allow. Ciphers may be separated by spaces, commas, or colons. If “ciphers” is empty or NULL then a default set is used. Only set this if you know that you have a good reason to.

For a list of valid ciphers on Linux/Unix platforms, see:

man ciphers

For a list of valid ciphers on Windows platforms, see:

https://msdn.microsoft.com/en-us/library/windows/desktop/aa375549%28v=vs.85%29.aspx

On Windows platforms, the ciphers (alg_id’s) should omit CALG_ and may be given with underscores or dashes. For example: 3DES_112

“validate” indicates whether to validate the SQL Relay’s server certificate, and may be set to one of the following:

"no" - Don't validate the server's certificate.
"ca" - Validate that the server's certificate was
       signed by a trusted certificate authority.
"ca+host" - Perform "ca" validation and also validate
       that one of the subject altenate names (or the
       common name if no SANs are present) in the
       certificate matches the host parameter.
       (Falls back to "ca" validation when a unix
       socket is used.)
"ca+domain" - Perform "ca" validation and also validate
       that the domain name of one of the subject
       alternate names (or the common name if no SANs
       are present) in the certificate matches the
       domain name of the host parameter.  (Falls back
       to "ca" validation when a unix socket is used.)

“ca” is the location of a certificate authority file to use, in addition to the system’s root certificates, when validating the SQL Relay server’s certificate. This is useful if the SQL Relay server’s certificate is self-signed.

On Windows, “ca” must be a file name.

On non-Windows systems, “ca” can be either a file or directory name. If it is a directory name, then all certificate authority files found in that directory will be used. If it a file name, then only that file will be used.

Note that the supported “cert” and “ca” file formats may vary between platforms. A variety of file formats are generally supported on Linux/Unix platfoms (.pem, .pfx, etc.) but only the .pfx format is currently supported on Windows.

static VALUE sqlrcon_enableTls(VALUE self,
                                VALUE version, VALUE cert, VALUE password,
                                VALUE ciphers, VALUE validate, VALUE ca,
                                VALUE depth) {
        sqlrconnection *sqlrcon;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        CON7(sqlrcon,enableTls,version,cert,password,ciphers,validate,ca,depth);
        return Qnil;
}
endSession() click to toggle source

Ends the session.

static VALUE sqlrcon_endSession(VALUE self) {
        sqlrconnection *sqlrcon;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        CON(sqlrcon,endSession);
        return Qnil;
}
errorMessage() click to toggle source

If an operation failed and generated an error, the error message is available here. If there is no error then this method returns nil.

static VALUE sqlrcon_errorMessage(VALUE self) {
        sqlrconnection *sqlrcon;
        const char     *result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,ccpr,sqlrcon,conErrorMessage);
        if (result) {
                return rb_str_new2(result);
        } else {
                return Qnil;
        }
}
errorNumber() click to toggle source

If an operation failed and generated an error, the error number is available here. If there is no error then this method returns 0.

static VALUE sqlrcon_errorNumber(VALUE self) {
        sqlrconnection *sqlrcon;
        int64_t                result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,u64r,sqlrcon,conErrorNumber);
        return INT2NUM(result);
}
getAutoCommit() click to toggle source

Returns true if auto-commit is currently on, false otherwise.

static VALUE sqlrcon_getAutoCommit(VALUE self) {
        sqlrconnection *sqlrcon;
        bool           result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,br,sqlrcon,getAutoCommit);
        return INT2NUM(result);
}
getBindVariableDelimiterAtSignSupported() click to toggle source

Returns true if at-signs (@) are considered to be valid bind variable delimiters.

static VALUE sqlrcon_getBindVariableDelimiterAtSignSupported(VALUE self) {
        sqlrconnection *sqlrcon;
        bool result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,br,sqlrcon,getBindVariableDelimiterAtSignSupported);
        return INT2NUM(result);
}
getBindVariableDelimiterColonSupported() click to toggle source

Returns true if colons (:) are considered to be valid bind variable delimiters.

static VALUE sqlrcon_getBindVariableDelimiterColonSupported(VALUE self) {
        sqlrconnection *sqlrcon;
        bool result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,br,sqlrcon,getBindVariableDelimiterColonSupported);
        return INT2NUM(result);
}
getBindVariableDelimiterDollarSignSupported() click to toggle source

Returns true if dollar signs ($) are considered to be valid bind variable delimiters.

static VALUE sqlrcon_getBindVariableDelimiterDollarSignSupported(VALUE self) {
        sqlrconnection *sqlrcon;
        bool result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,br,sqlrcon,getBindVariableDelimiterDollarSignSupported);
        return INT2NUM(result);
}
getBindVariableDelimiterQuestionMarkSupported() click to toggle source

Returns true if question marks (?) are considered to be valid bind variable delimiters.

static VALUE sqlrcon_getBindVariableDelimiterQuestionMarkSupported(VALUE self) {
        sqlrconnection *sqlrcon;
        bool result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,br,sqlrcon,getBindVariableDelimiterQuestionMarkSupported);
        return INT2NUM(result);
}
getClientInfo() click to toggle source

Returns the string that was set by setClientInfo().

static VALUE sqlrcon_getClientInfo(VALUE self) {
        sqlrconnection *sqlrcon;
        const char     *result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,ccpr,sqlrcon,getClientInfo);
        if (result) {
                return rb_str_new2(result);
        } else {
                return Qnil;
        }
}
getConnectTimeoutMicroseconds() click to toggle source

Gets the server connect timeout in microseconds.

static VALUE sqlrcon_getConnectTimeoutMicroseconds(VALUE self) {
        sqlrconnection *sqlrcon;
        int32_t        result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,i32r,sqlrcon,getConnectTimeoutMicroseconds)
        return INT2NUM(result);
}
getConnectTimeoutSeconds() click to toggle source

Gets the server connect timeout in seconds.

static VALUE sqlrcon_getConnectTimeoutSeconds(VALUE self) {
        sqlrconnection *sqlrcon;
        int32_t        result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,i32r,sqlrcon,getConnectTimeoutSeconds)
        return INT2NUM(result);
}
getConnectionPort() click to toggle source

Returns the inet port that the connection is communicating over. This parameter may be passed to another connection for use in the resumeSession() method. Note: The value this method returns is only valid after a call to suspendSession().

static VALUE sqlrcon_getConnectionPort(VALUE self) {
        sqlrconnection *sqlrcon;
        uint16_t       result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,u16r,sqlrcon,getConnectionPort);
        return INT2NUM(result);
}
getConnectionSocket() click to toggle source

Returns the unix socket that the connection is communicating over. This parameter may be passed to another connection for use in the resumeSession() method. Note: The value this method returns is only valid after a call to suspendSession().

static VALUE sqlrcon_getConnectionSocket(VALUE self) {
        sqlrconnection *sqlrcon;
        const char     *result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,ccpr,sqlrcon,getConnectionSocket);
        if (result) {
                return rb_str_new2(result);
        } else {
                return Qnil;
        }
}
getCurrentCatalog() click to toggle source

Returns the catalog that is currently in use.

static VALUE sqlrcon_getCurrentCatalog(VALUE self) {
        sqlrconnection *sqlrcon;
        const char     *result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,ccpr,sqlrcon,getCurrentCatalog);
        if (result) {
                return rb_str_new2(result);
        } else {
                return Qnil;
        }
}
getCurrentDatabase() click to toggle source

Returns the database that is currently in use.

May return the current catalog or schema, depending on whether the backend database equates “database” with catalog or schema.

See getDatabaseIsSchema().

static VALUE sqlrcon_getCurrentDatabase(VALUE self) {
        sqlrconnection *sqlrcon;
        const char     *result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,ccpr,sqlrcon,getCurrentDatabase);
        if (result) {
                return rb_str_new2(result);
        } else {
                return Qnil;
        }
}
getCurrentSchema() click to toggle source

Returns the schema that is currently in use.

static VALUE sqlrcon_getCurrentSchema(VALUE self) {
        sqlrconnection *sqlrcon;
        const char     *result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,ccpr,sqlrcon,getCurrentSchema);
        if (result) {
                return rb_str_new2(result);
        } else {
                return Qnil;
        }
}
getCurrentUser() click to toggle source

Returns the user that sqlrelay is currently logged in to the database as, or NULL if no user could be determined or if an error occurred.

static VALUE sqlrcon_getCurrentUser(VALUE self) {
        sqlrconnection *sqlrcon;
        const char     *result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,ccpr,sqlrcon,getCurrentUser);
        if (result) {
                return rb_str_new2(result);
        } else {
                return Qnil;
        }
}
getDatabaseFeature(p1) click to toggle source

Returns the value of the specified database “feature”.

Valid features include:

  • aggregate_functions

  • list - ALL,AVG,COUNT,DISTINCT,MAX,MIN,SUM

  • all_procedures_are_callable

  • true/false

  • all_tables_are_selectable

  • true/false

  • alter_domain_clauses

  • list - ADD_DOMAIN_CONSTRAINT,ADD_DOMAIN_DEFAULT,…

  • alter_table_operations

  • list - ADD_COLUMN,DROP_COLUMN

  • ansi92_sql_levels

  • list - ENTRY_LEVEL,FULL,INTERMEDIATE

  • auto_commit_failure_closes_all_result_sets

  • true/false

  • batch_operations

  • list - SELECT_EXPLICIT,ROW_COUNT_EXPLICIT,SELECT_PROC,ROW_COUNT_PROC

  • batch_row_counts

  • list - PROCEDURES,EXPLICIT,ROLLED_UP

  • catalog_separator

  • string

  • catalog_term

  • string

  • catalog_usage

  • list - DATA_MANIPULATION,INDEX_DEFINITIONS,…

  • collation_seq

  • string

  • create_assertion_clauses

  • list - CREATE_ASSERTION,CONSTRAINT_INITIALLY_DEFERRED,…

  • create_character_set_clauses

  • list - CREATE_CHARACTER_SET,COLLATE_CLAUSE,…

  • create_collation_clauses

  • list - CREATE_COLLATION

  • create_domain_clauses

  • list - CREATE_DOMAIN,CONSTRAINT_NAME_DEFINITION,…

  • create_schema_clauses

  • list - CREATE_SCHEMA,AUTHORIZATION,DEFAULT_CHARACTER_SET

  • create_table_clauses

  • list - CREATE_TABLE,TABLE_CONSTRAINT,…

  • create_translation_clauses

  • list - CREATE_TRANSLATION

  • create_view_clauses

  • list - CREATE_VIEW,CHECK_OPTION,CASCADED,LOCAL

  • data_definition_transaction_behavior

  • list - CAUSES_COMMIT,IGNORED_IN_TRANSACTIONS

  • ddl_index_operations

  • list - CREATE_INDEX,DROP_INDEX

  • string

  • default_result_set_holdability

  • string

  • deletes_are_detected

  • list - FORWARD_ONLY,SCROLL_INSENSITIVE,SCROLL_SENSITIVE

  • does_max_row_size_include_blobs

  • true/false

  • drop_assertion_clauses

  • list - DROP_ASSERTION

  • drop_character_set_clauses

  • list - DROP_CHARACTER_SET

  • drop_collation_clauses

  • list - DROP_COLLATION

  • drop_domain_clauses

  • list - DROP_DOMAIN,CASCADE,RESTRICT

  • drop_schema_clauses

  • list - DROP_SCHEMA,CASCADE,RESTRICT

  • drop_table_clauses

  • list - DROP_TABLE,CASCADE,RESTRICT

  • drop_translation_clauses

  • list - DROP_TRANSLATION

  • drop_view_clauses

  • list - DROP_VIEW,CASCADE,RESTRICT

  • extra_name_characters

  • string

  • foreign_key_delete_rules

  • list - CASCADE,NO_ACTION,SET_DEFAULT,SET_NULL

  • foreign_key_update_rules

  • list - CASCADE,NO_ACTION,SET_DEFAULT,SET_NULL

  • forward_only_cursor_attributes

  • list - NEXT,ABSOLUTE,RELATIVE,BOOKMARK,…

  • generated_key_always_returned

  • true/false

  • grant_clauses

  • list - DELETE_TABLE,INSERT_COLUMN,INSERT_TABLE,…

  • group_by_clauses

  • list - BASIC,BEYOND_SELECT,UNRELATED

  • identifier_case_storage

  • list - LOWER,MIXED,SENSITIVE,UPPER

  • identifier_quote_string

  • string

  • index_keywords

  • list - ASC,DESC

  • info_schema_views

  • list - ASSERTIONS,CHARACTER_SETS,CHECK_CONSTRAINTS,…

  • insert_operations

  • list - INSERT_LITERALS,INSERT_SEARCHED,SELECT_INTO

  • inserts_are_detected

  • list - FORWARD_ONLY,SCROLL_INSENSITIVE,SCROLL_SENSITIVE

  • is_catalog_at_start

  • true/false

  • isolation_levels

  • list - READ_UNCOMMITTED,READ_COMMITTED,…

  • local_file_usage

  • list - LOCAL_FILE_PER_TABLE,LOCAL_FILES

  • locators_update_copy

  • true/false

  • lock_types

  • list - NO_CHANGE,EXCLUSIVE,UNLOCK

  • max_binary_literal_length

  • number

  • max_catalog_name_length

  • number

  • max_char_literal_length

  • number

  • max_column_name_length

  • number

  • max_columns_in_group_by

  • number

  • max_columns_in_index

  • number

  • max_columns_in_order_by

  • number

  • max_columns_in_select

  • number

  • max_columns_in_table

  • number

  • max_connections

  • number

  • max_cursor_name_length

  • number

  • max_identifier_length

  • number

  • max_index_length

  • number

  • max_procedure_name_length

  • number

  • max_row_size

  • number

  • max_schema_name_length

  • number

  • max_statement_length

  • number

  • max_statements

  • number

  • max_table_name_length

  • number

  • max_tables_in_select

  • number

  • max_user_name_length

  • number

  • need_long_data_length

  • true/false

  • null_plus_non_null_is_null

  • true/false

  • null_sort_order

  • list - AT_END,AT_START,HIGH,LOW

  • numeric_functions

  • list - ABS,ACOS,ASIN,ATAN,ATAN2,CEILING,COS,COT,…

  • open_cursors_across

  • list - COMMIT,ROLLBACK

  • open_statements_across

  • list - COMMIT,ROLLBACK

  • others_deletes_are_visible

  • list - FORWARD_ONLY,SCROLL_INSENSITIVE,SCROLL_SENSITIVE

  • others_inserts_are_visible

  • list - FORWARD_ONLY,SCROLL_INSENSITIVE,SCROLL_SENSITIVE

  • others_updates_are_visible

  • list - FORWARD_ONLY,SCROLL_INSENSITIVE,SCROLL_SENSITIVE

  • outer_joins

  • list - BASIC,FULL,LIMITED

  • own_deletes_are_visible

  • list - FORWARD_ONLY,SCROLL_INSENSITIVE,SCROLL_SENSITIVE

  • own_inserts_are_visible

  • list - FORWARD_ONLY,SCROLL_INSENSITIVE,SCROLL_SENSITIVE

  • own_updates_are_visible

  • list - FORWARD_ONLY,SCROLL_INSENSITIVE,SCROLL_SENSITIVE

  • predicates

  • list - BETWEEN,COMPARISON,EXISTS,IN,ISNOTNULL,ISNULL,…

  • procedure_term

  • string

  • quoted_identifier_case_storage

  • list - LOWER,MIXED,SENSITIVE,UPPER

  • relational_join_operators

  • list - CORRESPONDING_CLAUSE,CROSS_JOIN,EXCEPT_JOIN,…

  • result_set_concurrencies

  • list - FORWARD_ONLY/READ_ONLY,FORWARD_ONLY/UPDATABLE,…

  • result_set_holdabilities

  • list - CLOSE_CURSORS_AT_COMMIT,HOLD_CURSORS_OVER_COMMIT

  • result_set_types

  • list - FORWARD_ONLY,SCROLL_INSENSITIVE,SCROLL_SENSITIVE

  • revoke_clauses

  • list - CASCADE,DELETE_TABLE,GRANT_OPTION_FOR,…

  • row_id_lifetime

  • string

  • row_value_constructor_expressions

  • list - VALUE_EXPRESSION,NULL,DEFAULT,ROW_SUBQUERY

  • schema_term

  • string

  • schema_usage

  • list - DATA_MANIPULATION,INDEX_DEFINITIONS,…

  • scroll_concurrencies

  • list - READ_ONLY,LOCK,OPT_ROWVER,OPT_VALUES

  • search_string_escape

  • string

  • sql_grammar_levels

  • list - CORE,EXTENDED,MINIMUM

  • sql_keywords

  • list - ACCESS,ADD,ALTER,AUDIT,CLUSTER,COLUMN,COMMENT,…

  • sql_state_type

  • number

  • static_cursor_attributes

  • list - NEXT,ABSOLUTE,RELATIVE,BOOKMARK,…

  • stored_programs

  • list - FUNCTIONS,PROCEDURES

  • string_functions

  • list - CONCAT,INSERT,LEFT,LTRIM,LENGTH,LOCATE,LCASE,…

  • subquery_usage

  • list - COMPARISONS,EXISTS,INS,QUANTIFIEDS

  • supports_batch_updates

  • true/false

  • supports_column_aliasing

  • true/false

  • supports_convert

  • true/false

  • supports_correlated_subqueries

  • true/false

  • supports_describe_parameter

  • true/false

  • supports_expressions_in_order_by

  • true/false

  • supports_get_generated_keys

  • true/false

  • supports_integrity_enhancement_facility

  • true/false

  • supports_like_escape_clause

  • true/false

  • supports_multiple_result_sets

  • true/false

  • supports_multiple_transactions

  • true/false

  • supports_named_parameters

  • true/false

  • supports_non_nullable_columns

  • true/false

  • supports_order_by_unrelated

  • true/false

  • supports_savepoints

  • true/false

  • supports_select_for_update

  • true/false

  • supports_transactions

  • true/false

  • system_functions

  • list - USER,DBNAME,IFNULL

  • table_correlation_names

  • list - BASIC,DIFFERENT

  • table_term

  • string

  • time_date_add_intervals

  • list - FRAC_SECOND,SECOND,MINUTE,HOUR,DAY,WEEK,MONTH,…

  • time_date_diff_intervals

  • list - FRAC_SECOND,SECOND,MINUTE,HOUR,DAY,WEEK,MONTH,…

  • time_date_functions

  • list - NOW,CURDATE,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,…

  • time_date_literals

  • list - DATE,TIME,TIMESTAMP,INTERVAL_YEAR,…

  • transaction_ddl_dml

  • list - DDL_AND_DML,DML_ONLY

  • union_clauses

  • list - UNION,UNION_ALL

  • updates_are_detected

  • list - FORWARD_ONLY,SCROLL_INSENSITIVE,SCROLL_SENSITIVE

  • value_expressions

  • list - CASE,CAST,COALESCE,NULLIF

  • where_current_of_operations

  • list - DELETE,UPDATE

Returns the value of the feature as a string, or nil if an error occurred or an invalid feature was requested.

static VALUE sqlrcon_getDatabaseFeature(VALUE self, VALUE feature) {
        sqlrconnection *sqlrcon;
        const char     *result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON1(result,ccpr,sqlrcon,getDatabaseFeature,feature);
        if (result) {
                return rb_str_new2(result);
        } else {
                return Qnil;
        }
}
getDatabaseIsSchema() click to toggle source

Returns true if the backend database equates “database” with “schema”, and false if it equates “database” with “catalog”.

static VALUE sqlrcon_getDatabaseIsSchema(VALUE self) {
        sqlrconnection *sqlrcon;
        bool           result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,br,sqlrcon,getDatabaseIsSchema);
        return INT2NUM(result);
}
getDebug() click to toggle source

Returns false if debugging is off and true if debugging is on.

static VALUE sqlrcon_getDebug(VALUE self) {
        sqlrconnection *sqlrcon;
        bool           result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,br,sqlrcon,getDebug);
        return INT2NUM(result);
}
getDefaultTransactionModel() click to toggle source

Returns the database’s native transaction model. See setTranscationModel() for a list of potential return values. Returns nil if an error occurred.

static VALUE sqlrcon_getDefaultTransactionModel(VALUE self) {
        sqlrconnection *sqlrcon;
        const char     *result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,ccpr,sqlrcon,getDefaultTransactionModel);
        if (result) {
                return rb_str_new2(result);
        } else {
                return Qnil;
        }
}
getInTransaction() click to toggle source

Returns true if the session is currently inside a transaction, false otherwise.

static VALUE sqlrcon_getInTransaction(VALUE self) {
        sqlrconnection *sqlrcon;
        bool           result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,br,sqlrcon,getInTransaction);
        return INT2NUM(result);
}
getIsolationLevel() click to toggle source

Returns the database-specific isolation level, “unknown” if the isolation level is unknown, or nil if an error occurred.

static VALUE sqlrcon_getIsolationLevel(VALUE self) {
        sqlrconnection *sqlrcon;
        const char     *result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,ccpr,sqlrcon,getIsolationLevel);
        if (result) {
                return rb_str_new2(result);
        } else {
                return Qnil;
        }
}
getLastInsertId() click to toggle source

Returns the value of the autoincrement column for the last insert

static VALUE sqlrcon_getLastInsertId(VALUE self) {
        sqlrconnection *sqlrcon;
        uint64_t       result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,u64r,sqlrcon,getLastInsertId);
        return INT2NUM(result);
}
getResponseTimeoutMicroseconds() click to toggle source

Gets the response timeout in microseconds.

static VALUE sqlrcon_getResponseTimeoutMicroseconds(VALUE self) {
        sqlrconnection *sqlrcon;
        int32_t        result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,i32r,sqlrcon,getResponseTimeoutMicroseconds)
        return INT2NUM(result);
}
getResponseTimeoutSeconds() click to toggle source

Gets the response timeout in seconds.

static VALUE sqlrcon_getResponseTimeoutSeconds(VALUE self) {
        sqlrconnection *sqlrcon;
        int32_t        result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,i32r,sqlrcon,getResponseTimeoutSeconds)
        return INT2NUM(result);
}
getTransactionModel() click to toggle source

Returns the current transaction model. See setTranscationModel() for a list of potential return values. Returns nil if an error occurred.

static VALUE sqlrcon_getTransactionModel(VALUE self) {
        sqlrconnection *sqlrcon;
        const char     *result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,ccpr,sqlrcon,getTransactionModel);
        if (result) {
                return rb_str_new2(result);
        } else {
                return Qnil;
        }
}
identify() click to toggle source

Returns the type of database: oracle, postgresql, mysql, etc.

static VALUE sqlrcon_identify(VALUE self) {
        sqlrconnection *sqlrcon;
        const char     *result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,ccpr,sqlrcon,identify);
        if (result) {
                return rb_str_new2(result);
        } else {
                return Qnil;
        }
}
nextvalFormat() click to toggle source

Returns a string representing the format of the sequence nextval command used in the database. The format will contain a %s in place of the sequence name. For example:

(nextval for %s) next value for %s nextval(‘%s’) %s.nextval

Returns an empty string if the database does not support sequences.

static VALUE sqlrcon_nextvalFormat(VALUE self) {
        sqlrconnection *sqlrcon;
        const char     *result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,ccpr,sqlrcon,nextvalFormat);
        if (result) {
                return rb_str_new2(result);
        } else {
                return Qnil;
        }
}
ping() click to toggle source

Returns true if the database is up and false if it’s down.

static VALUE sqlrcon_ping(VALUE self) {
        sqlrconnection *sqlrcon;
        bool           result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,br,sqlrcon,ping);
        return INT2NUM(result);
}
resumeSession(port,socket) click to toggle source

Resumes a session previously left open using suspendSession(). Returns true on success and false on failure.

static VALUE sqlrcon_resumeSession(VALUE self, VALUE port, VALUE socket) {
        sqlrconnection *sqlrcon;
        bool           result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON2(result,br,sqlrcon,resumeSession,port,socket);
        return INT2NUM(result);
}
rollback() click to toggle source

Rolls back a transaction. Returns true if the rollback succeeded, false if it failed.

static VALUE sqlrcon_rollback(VALUE self) {
        sqlrconnection *sqlrcon;
        bool           result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,br,sqlrcon,rollback);
        return INT2NUM(result);
}
selectCatalog(catalog) click to toggle source

Sets the current catalog to “catalog”

static VALUE sqlrcon_selectCatalog(VALUE self, VALUE catalog) {
        sqlrconnection *sqlrcon;
        bool           result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON1(result,br,sqlrcon,selectCatalog,catalog);
        return INT2NUM(result);
}
selectDatabase(database) click to toggle source

Sets the current database to “database”.

May set the current catalog or schema, depending on whether the backend database equates “database” with catalog or schema.

See getDatabaseIsSchema().

static VALUE sqlrcon_selectDatabase(VALUE self, VALUE db) {
        sqlrconnection *sqlrcon;
        bool           result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON1(result,br,sqlrcon,selectDatabase,db);
        return INT2NUM(result);
}
selectSchema(schema) click to toggle source

Sets the current schema to “schema”

static VALUE sqlrcon_selectSchema(VALUE self, VALUE schema) {
        sqlrconnection *sqlrcon;
        bool           result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON1(result,br,sqlrcon,selectSchema,schema);
        return INT2NUM(result);
}
serverVersion() click to toggle source

Returns the version of the sqlrelay server software.

static VALUE sqlrcon_serverVersion(VALUE self) {
        sqlrconnection *sqlrcon;
        const char     *result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,ccpr,sqlrcon,serverVersion);
        if (result) {
                return rb_str_new2(result);
        } else {
                return Qnil;
        }
}
setBindVariablesDelimiters(delimiters) click to toggle source

Sets which delimiters are used to identify bind variables in countBindVariables() and validateBinds(). Valid delimiters include ?,:,@, and $. Defaults to “?:@$”

static VALUE sqlrcon_setBindVariableDelimiters(VALUE self, VALUE delimiters) {
        sqlrconnection *sqlrcon;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        CON1(sqlrcon,setBindVariableDelimiters,delimiters);
        return Qnil;
}
setClientInfo(clientinfo) click to toggle source

Allows you to set a string that will be passed to the server and ultimately included in server-side logging along with queries that were run by this instance of the client.

static VALUE sqlrcon_setClientInfo(VALUE self, VALUE clientinfo) {
        sqlrconnection *sqlrcon;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        CON1(sqlrcon,setClientInfo,clientinfo);
        return Qnil;
}
setConnectTimeout(timeoutsec,timeoutusec) click to toggle source

Sets the server connect timeout in seconds and microseconds. Setting either parameter to -1 disables the timeout. You can also set this timeout using the SQLR_CLIENT_CONNECT_TIMEOUT environment variable.

static VALUE sqlrcon_setConnectTimeout(VALUE self,
                                VALUE timeoutsec, VALUE timeoutusec) {
        sqlrconnection *sqlrcon;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        CON2(sqlrcon,setConnectTimeout,timeoutsec,timeoutusec)
        return Qnil;
}
setDebugFile(filename) click to toggle source

Allows you to specify a file to write debug to. Setting “filename” to NULL or an empty string causes debug to be written to standard output (the default).

static VALUE sqlrcon_setDebugFile(VALUE self, VALUE filename) {
        sqlrconnection *sqlrcon;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        CON1(sqlrcon,setDebugFile,filename);
        return Qnil;
}
setIsolationLevel(p1) click to toggle source

Sets the transaction isolation level to “isolationlevel”. The string is the database-specific (native) name and is matched case-insensitively.

Valid isolation levels include:

For PostgreSQL:

  • READ UNCOMMITTED

  • READ COMMITTED (default)

  • REPEATABLE READ

  • SERIALIZABLE

For MySQL/MariaDB:

  • READ-UNCOMMITTED

  • READ-COMMITTED

  • REPEATABLE-READ (default)

  • SERIALIZABLE

For Oracle:

  • READ COMMITTED (default)

  • SERIALIZABLE

For DB2:

  • UR (uncommitted read)

  • CS (cursor stability, default)

  • RS (read stability)

  • RR (repeatable read)

For MS SQL Server (via FreeTDS):

  • READ UNCOMMITTED

  • READ COMMITTED (default)

  • REPEATABLE READ

  • SERIALIZABLE

  • SNAPSHOT

For SAP ASE (Sybase):

  • 0 (read uncommitted)

  • 1 (read committed, default)

  • 2 (repeatable read)

  • 3 (serializable)

For Informix:

  • dirty read

  • committed read (default)

  • cursor stability

  • repeatable read

For Firebird:

  • read committed (default)

  • read committed no record version

  • read consistency

  • snapshot

  • snapshot table stability

For SQLite:

  • 0 (serializable, default)

  • 1 (read uncommitted)

For ODBC:

  • SQL_TXN_READ_UNCOMMITTED

  • SQL_TXN_READ_COMMITTED

  • SQL_TXN_REPEATABLE_READ

  • SQL_TXN_SERIALIZABLE

(whether a given level is actually supported depends on the underlying ODBC driver and target database). The generic ODBC backend also accepts the database-specific native names listed above for any of the other backends, as well as the JDBC TRANSACTION_* names, and maps them to the closest of the four ODBC levels above.

For other databases, the string is passed through to the backend as the argument to “set transaction isolation level”.

Returns true if setting the isolation level succeeded, false if it failed.

static VALUE sqlrcon_setIsolationLevel(VALUE self, VALUE isolationlevel) {
        sqlrconnection *sqlrcon;
        bool           result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON1(result,br,sqlrcon,setIsolationLevel,isolationlevel);
        return INT2NUM(result);
}
setResponseTimeout(timeoutsec,timeoutusec) click to toggle source

Sets the response timeout (for queries, commits, rollbacks, pings, etc.) in seconds and microseconds. Setting either parameter to -1 disables the timeout. You can also set this timeout using the SQLR_CLIENT_RESPONSE_TIMEOUT environment variable.

static VALUE sqlrcon_setResponseTimeout(VALUE self,
                                VALUE timeoutsec, VALUE timeoutusec) {
        sqlrconnection *sqlrcon;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        CON2(sqlrcon,setResponseTimeout,timeoutsec,timeoutusec)
        return Qnil;
}
setTransactionModel(p1) click to toggle source

Sets the current transaction model to “txmodel” which should be one of:

  • native - the database’s native transaction model

  • none - no transactions

  • “implicit”

    * in a transaction when the session begins
    * commit/rollback implicitly starts a new transcaction
    * autocommit on/off take effect immediately
  • “explicit”

    * not in a transaction when the session begins
    * begin required to start a new transaction
    * commit/rollback does not start a new transcaction
    * autocommit on/off take effect immediately
  • “explicit-deferred”

    * not in a transaction when the session begins
    * begin required to start a new transaction
    * commit/rollback does not start a new transcaction
    * while in a begin-initiated transaction, autocommit
      on takes effect at next commit/rollback (deferred)
    * while in an autocommit-off-initiated transaction,
      autocommit on takes effect immediately
  • “explicit-error”

    * not in a transaction when the session begins
    * begin required to start a new transaction
    * commit/rollback does not start a new transcaction
    * while in a transaction, autocommit on/off throw error

Returns true on success and false on failure.

static VALUE sqlrcon_setTransactionModel(VALUE self, VALUE txmodel) {
        sqlrconnection *sqlrcon;
        bool           result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON1(result,br,sqlrcon,setTransactionModel,txmodel);
        return INT2NUM(result);
}
suspendSession() click to toggle source

Disconnects this connection from the current session but leaves the session open so that another connection can connect to it using resumeSession().

static VALUE sqlrcon_suspendSession(VALUE self) {
        sqlrconnection *sqlrcon;
        bool           result;
        Data_Get_Struct(self,sqlrconnection,sqlrcon);
        RCON(result,br,sqlrcon,suspendSession);
        return INT2NUM(result);
}