diff --git a/Gemfile b/Gemfile index 8ad897db..cda0054d 100644 --- a/Gemfile +++ b/Gemfile @@ -16,7 +16,6 @@ gem 'rtoolsHCK', git: 'https://github.com/HCK-CI/rtoolsHCK.git', tag: 'v0.4.0' gem 'rubyzip' gem 'sentry-ruby' gem 'sorbet-runtime' -gem 'sqlite3' group :development, :test do gem 'sorbet', require: false diff --git a/Gemfile.lock b/Gemfile.lock index ceed21b7..92b56a83 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -151,7 +151,6 @@ GEM sorbet-static-and-runtime (>= 0.5.10187) syntax_tree (>= 6.1.1) thor (>= 0.19.2) - sqlite3 (1.6.6-x86_64-linux) stringio (3.0.8) syntax_tree (6.2.0) prettier_print (>= 1.2.0) @@ -208,7 +207,6 @@ DEPENDENCIES sentry-ruby sorbet sorbet-runtime - sqlite3 tapioca RUBY VERSION diff --git a/lib/auxiliary/id_gen.rb b/lib/auxiliary/id_gen.rb deleted file mode 100644 index 1a90781c..00000000 --- a/lib/auxiliary/id_gen.rb +++ /dev/null @@ -1,90 +0,0 @@ -# frozen_string_literal: true - -require 'sqlite3' -require 'time' - -# AutoHCK module -module AutoHCK - # Id Generator class - class Idgen - def initialize(scope, range, timeout) - @db = './id_gen.db' - @range = range - @threshold = timeout * 24 * 60 * 60 - @conn = SQLite3::Database.new @db.to_s - scope << @conn - end - - def load_data - ids = Array.new(@range.last + 1 - @range.first, true) - @conn.execute <<~SQL - CREATE TABLE IF NOT EXISTS ActiveIds( - IdNumber INT PRIMARY KEY NOT NULL, PID INT NOT NULL, - Time TIMESTAMP NOT NULL - ) - SQL - fetch_data(ids) - ids - rescue SQLite3::Exception - -1 - end - - def gen_id - ids = load_data - return -1 if ids == -1 - return -1 unless ids.index(true) - - release_timeouts - ids.index(true) + @range.first - end - - def allocate - id = gen_id - return -1 if id.negative? - - time = Time.now.to_i - @conn.execute "INSERT INTO ActiveIds VALUES(#{id},#{Process.pid},#{time})" - id - rescue SQLite3::ConstraintException - retry - rescue SQLite3::Exception - -1 - end - - def release(id) - @conn.execute "DELETE FROM ActiveIds WHERE IdNumber=#{id}" - 1 - rescue SQLite3::Exception - -1 - end - - private - - def release_timeouts - now = Time.now.to_i - kill_if_alive(now) - @conn.execute "DELETE FROM ActiveIds WHERE (#{now} - Time) > #{@threshold}" - rescue SQLite3::Exception - -1 - end - - def fetch_data(ids) - res = @conn.execute 'SELECT IdNumber FROM ActiveIds' - res.each do |row| - ids[row[0].to_i - @range.first] = false - end - end - - def kill_if_alive(now) - res = @conn.execute <<~SQL - SELECT PID FROM ActiveIds - WHERE (#{now} - Time) > #{@threshold} - SQL - res.each do |row| - pid = row[0].to_i - check_cmd = "sudo ps -ef | grep #{pid} | grep auto_hck | grep -v grep" - Process.kill('TERM', pid) unless `#{check_cmd}`.empty? - end - end - end -end diff --git a/lib/cli.rb b/lib/cli.rb index b90b79c2..0c17eebc 100644 --- a/lib/cli.rb +++ b/lib/cli.rb @@ -25,7 +25,7 @@ def initialize # class CommonOptions class CommonOptions - attr_accessor :debug, :config, :client_world_net + attr_accessor :debug, :config, :client_world_net, :id def create_parser(sub_parser) OptionParser.new do |parser| @@ -46,9 +46,11 @@ def define_options(parser) @debug = false @config = nil @client_world_net = false + @id = 2 debug_option(parser) config_option(parser) client_world_net_option(parser) + id_option(parser) version_option(parser) end @@ -73,6 +75,13 @@ def client_world_net_option(parser) end end + def id_option(parser) + parser.on('--id ', Integer, + 'Set ID for AutoHCK run') do |id| + @id = id + end + end + def version_option(parser) parser.on('-v', '--version', 'Display version information and exit') do diff --git a/lib/project.rb b/lib/project.rb index 3d23e693..0410ba30 100644 --- a/lib/project.rb +++ b/lib/project.rb @@ -9,7 +9,6 @@ require './lib/auxiliary/multi_logger' require './lib/auxiliary/diff_checker' require './lib/auxiliary/json_helper' -require './lib/auxiliary/id_gen' require './lib/auxiliary/extra_software/manager' require './lib/auxiliary/time_helper' @@ -33,7 +32,7 @@ def initialize(scope, options) init_multilog(options.common.debug) init_class_variables init_workspace - @id = assign_id + @id = options.common.id scope << self end @@ -119,23 +118,6 @@ def init_class_variables @run_terminated = false end - def assign_id - @id_gen = Idgen.new(@scope, @config['id_range'], @config['time_out']) - id = @id_gen.allocate - while id.negative? - @logger.info('No available ID') - sleep 20 - id = @id_gen.allocate - end - @logger.info("Assigned ID: #{id}") - id.to_s - end - - def release_id - @logger.info("Releasing ID: #{@id}") - @id_gen.release(@id) - end - def configure_result_uploader @logger.info('Initializing result uploaders') @result_uploader = ResultUploader.new(@scope, self) @@ -216,7 +198,6 @@ def handle_error def close @logger.debug('Closing AutoHCK project') @result_uploader&.upload_file(@logfile_path, 'AutoHCK.log') - release_id end end end diff --git a/sorbet/rbi/gems/sqlite3@1.6.6.rbi b/sorbet/rbi/gems/sqlite3@1.6.6.rbi deleted file mode 100644 index 17bb2122..00000000 --- a/sorbet/rbi/gems/sqlite3@1.6.6.rbi +++ /dev/null @@ -1,1673 +0,0 @@ -# typed: true - -# DO NOT EDIT MANUALLY -# This is an autogenerated file for types exported from the `sqlite3` gem. -# Please instead update this file by running `bin/tapioca gem sqlite3`. - -# source://sqlite3//lib/sqlite3/constants.rb#1 -module SQLite3 - class << self - # source://sqlite3//lib/sqlite3/version.rb#16 - def const_missing(name); end - - def libversion; end - def sqlcipher?; end - def threadsafe; end - - # Was sqlite3 compiled with thread safety on? - # - # @return [Boolean] - # - # source://sqlite3//lib/sqlite3.rb#14 - def threadsafe?; end - end -end - -# source://sqlite3//lib/sqlite3/errors.rb#12 -class SQLite3::AbortException < ::SQLite3::Exception; end - -# source://sqlite3//lib/sqlite3/errors.rb#31 -class SQLite3::AuthorizationException < ::SQLite3::Exception; end - -class SQLite3::Backup - def initialize(_arg0, _arg1, _arg2, _arg3); end - - def finish; end - def pagecount; end - def remaining; end - def step(_arg0); end -end - -class SQLite3::Blob < ::String; end - -# source://sqlite3//lib/sqlite3/errors.rb#13 -class SQLite3::BusyException < ::SQLite3::Exception; end - -# source://sqlite3//lib/sqlite3/errors.rb#22 -class SQLite3::CantOpenException < ::SQLite3::Exception; end - -# source://sqlite3//lib/sqlite3/constants.rb#1 -module SQLite3::Constants; end - -# source://sqlite3//lib/sqlite3/constants.rb#12 -module SQLite3::Constants::ColumnType; end - -# source://sqlite3//lib/sqlite3/constants.rb#16 -SQLite3::Constants::ColumnType::BLOB = T.let(T.unsafe(nil), Integer) - -# source://sqlite3//lib/sqlite3/constants.rb#14 -SQLite3::Constants::ColumnType::FLOAT = T.let(T.unsafe(nil), Integer) - -# source://sqlite3//lib/sqlite3/constants.rb#13 -SQLite3::Constants::ColumnType::INTEGER = T.let(T.unsafe(nil), Integer) - -# source://sqlite3//lib/sqlite3/constants.rb#17 -SQLite3::Constants::ColumnType::NULL = T.let(T.unsafe(nil), Integer) - -# source://sqlite3//lib/sqlite3/constants.rb#15 -SQLite3::Constants::ColumnType::TEXT = T.let(T.unsafe(nil), Integer) - -# source://sqlite3//lib/sqlite3/constants.rb#20 -module SQLite3::Constants::ErrorCode; end - -# Callback routine requested an abort -# -# source://sqlite3//lib/sqlite3/constants.rb#25 -SQLite3::Constants::ErrorCode::ABORT = T.let(T.unsafe(nil), Integer) - -# Authorization denied -# -# source://sqlite3//lib/sqlite3/constants.rb#44 -SQLite3::Constants::ErrorCode::AUTH = T.let(T.unsafe(nil), Integer) - -# The database file is locked -# -# source://sqlite3//lib/sqlite3/constants.rb#26 -SQLite3::Constants::ErrorCode::BUSY = T.let(T.unsafe(nil), Integer) - -# Unable to open the database file -# -# source://sqlite3//lib/sqlite3/constants.rb#35 -SQLite3::Constants::ErrorCode::CANTOPEN = T.let(T.unsafe(nil), Integer) - -# Abort due to constraint violation -# -# source://sqlite3//lib/sqlite3/constants.rb#40 -SQLite3::Constants::ErrorCode::CONSTRAINT = T.let(T.unsafe(nil), Integer) - -# The database disk image is malformed -# -# source://sqlite3//lib/sqlite3/constants.rb#32 -SQLite3::Constants::ErrorCode::CORRUPT = T.let(T.unsafe(nil), Integer) - -# sqlite_step() has finished executing -# -# source://sqlite3//lib/sqlite3/constants.rb#47 -SQLite3::Constants::ErrorCode::DONE = T.let(T.unsafe(nil), Integer) - -# (Internal Only) Database table is empty -# -# source://sqlite3//lib/sqlite3/constants.rb#37 -SQLite3::Constants::ErrorCode::EMPTY = T.let(T.unsafe(nil), Integer) - -# SQL error or missing database -# -# source://sqlite3//lib/sqlite3/constants.rb#22 -SQLite3::Constants::ErrorCode::ERROR = T.let(T.unsafe(nil), Integer) - -# Insertion failed because database is full -# -# source://sqlite3//lib/sqlite3/constants.rb#34 -SQLite3::Constants::ErrorCode::FULL = T.let(T.unsafe(nil), Integer) - -# An internal logic error in SQLite -# -# source://sqlite3//lib/sqlite3/constants.rb#23 -SQLite3::Constants::ErrorCode::INTERNAL = T.let(T.unsafe(nil), Integer) - -# Operation terminated by sqlite_interrupt() -# -# source://sqlite3//lib/sqlite3/constants.rb#30 -SQLite3::Constants::ErrorCode::INTERRUPT = T.let(T.unsafe(nil), Integer) - -# Some kind of disk I/O error occurred -# -# source://sqlite3//lib/sqlite3/constants.rb#31 -SQLite3::Constants::ErrorCode::IOERR = T.let(T.unsafe(nil), Integer) - -# A table in the database is locked -# -# source://sqlite3//lib/sqlite3/constants.rb#27 -SQLite3::Constants::ErrorCode::LOCKED = T.let(T.unsafe(nil), Integer) - -# Data type mismatch -# -# source://sqlite3//lib/sqlite3/constants.rb#41 -SQLite3::Constants::ErrorCode::MISMATCH = T.let(T.unsafe(nil), Integer) - -# Library used incorrectly -# -# source://sqlite3//lib/sqlite3/constants.rb#42 -SQLite3::Constants::ErrorCode::MISUSE = T.let(T.unsafe(nil), Integer) - -# Uses OS features not supported on host -# -# source://sqlite3//lib/sqlite3/constants.rb#43 -SQLite3::Constants::ErrorCode::NOLFS = T.let(T.unsafe(nil), Integer) - -# A malloc() failed -# -# source://sqlite3//lib/sqlite3/constants.rb#28 -SQLite3::Constants::ErrorCode::NOMEM = T.let(T.unsafe(nil), Integer) - -# (Internal Only) Table or record not found -# -# source://sqlite3//lib/sqlite3/constants.rb#33 -SQLite3::Constants::ErrorCode::NOTFOUND = T.let(T.unsafe(nil), Integer) - -# Successful result -# -# source://sqlite3//lib/sqlite3/constants.rb#21 -SQLite3::Constants::ErrorCode::OK = T.let(T.unsafe(nil), Integer) - -# Access permission denied -# -# source://sqlite3//lib/sqlite3/constants.rb#24 -SQLite3::Constants::ErrorCode::PERM = T.let(T.unsafe(nil), Integer) - -# Database lock protocol error -# -# source://sqlite3//lib/sqlite3/constants.rb#36 -SQLite3::Constants::ErrorCode::PROTOCOL = T.let(T.unsafe(nil), Integer) - -# Attempt to write a readonly database -# -# source://sqlite3//lib/sqlite3/constants.rb#29 -SQLite3::Constants::ErrorCode::READONLY = T.let(T.unsafe(nil), Integer) - -# sqlite_step() has another row ready -# -# source://sqlite3//lib/sqlite3/constants.rb#46 -SQLite3::Constants::ErrorCode::ROW = T.let(T.unsafe(nil), Integer) - -# The database schema changed -# -# source://sqlite3//lib/sqlite3/constants.rb#38 -SQLite3::Constants::ErrorCode::SCHEMA = T.let(T.unsafe(nil), Integer) - -# Too much data for one row of a table -# -# source://sqlite3//lib/sqlite3/constants.rb#39 -SQLite3::Constants::ErrorCode::TOOBIG = T.let(T.unsafe(nil), Integer) - -module SQLite3::Constants::Open; end -SQLite3::Constants::Open::AUTOPROXY = T.let(T.unsafe(nil), Integer) -SQLite3::Constants::Open::CREATE = T.let(T.unsafe(nil), Integer) -SQLite3::Constants::Open::DELETEONCLOSE = T.let(T.unsafe(nil), Integer) -SQLite3::Constants::Open::EXCLUSIVE = T.let(T.unsafe(nil), Integer) -SQLite3::Constants::Open::FULLMUTEX = T.let(T.unsafe(nil), Integer) -SQLite3::Constants::Open::MAIN_DB = T.let(T.unsafe(nil), Integer) -SQLite3::Constants::Open::MAIN_JOURNAL = T.let(T.unsafe(nil), Integer) -SQLite3::Constants::Open::MASTER_JOURNAL = T.let(T.unsafe(nil), Integer) -SQLite3::Constants::Open::MEMORY = T.let(T.unsafe(nil), Integer) -SQLite3::Constants::Open::NOMUTEX = T.let(T.unsafe(nil), Integer) -SQLite3::Constants::Open::PRIVATECACHE = T.let(T.unsafe(nil), Integer) -SQLite3::Constants::Open::READONLY = T.let(T.unsafe(nil), Integer) -SQLite3::Constants::Open::READWRITE = T.let(T.unsafe(nil), Integer) -SQLite3::Constants::Open::SHAREDCACHE = T.let(T.unsafe(nil), Integer) -SQLite3::Constants::Open::SUBJOURNAL = T.let(T.unsafe(nil), Integer) -SQLite3::Constants::Open::TEMP_DB = T.let(T.unsafe(nil), Integer) -SQLite3::Constants::Open::TEMP_JOURNAL = T.let(T.unsafe(nil), Integer) -SQLite3::Constants::Open::TRANSIENT_DB = T.let(T.unsafe(nil), Integer) -SQLite3::Constants::Open::URI = T.let(T.unsafe(nil), Integer) -SQLite3::Constants::Open::WAL = T.let(T.unsafe(nil), Integer) - -# source://sqlite3//lib/sqlite3/constants.rb#3 -module SQLite3::Constants::TextRep; end - -# source://sqlite3//lib/sqlite3/constants.rb#8 -SQLite3::Constants::TextRep::ANY = T.let(T.unsafe(nil), Integer) - -# source://sqlite3//lib/sqlite3/constants.rb#9 -SQLite3::Constants::TextRep::DETERMINISTIC = T.let(T.unsafe(nil), Integer) - -# source://sqlite3//lib/sqlite3/constants.rb#7 -SQLite3::Constants::TextRep::UTF16 = T.let(T.unsafe(nil), Integer) - -# source://sqlite3//lib/sqlite3/constants.rb#6 -SQLite3::Constants::TextRep::UTF16BE = T.let(T.unsafe(nil), Integer) - -# source://sqlite3//lib/sqlite3/constants.rb#5 -SQLite3::Constants::TextRep::UTF16LE = T.let(T.unsafe(nil), Integer) - -# source://sqlite3//lib/sqlite3/constants.rb#4 -SQLite3::Constants::TextRep::UTF8 = T.let(T.unsafe(nil), Integer) - -# source://sqlite3//lib/sqlite3/errors.rb#27 -class SQLite3::ConstraintException < ::SQLite3::Exception; end - -# source://sqlite3//lib/sqlite3/errors.rb#19 -class SQLite3::CorruptException < ::SQLite3::Exception; end - -# The Database class encapsulates a single connection to a SQLite3 database. -# Its usage is very straightforward: -# -# require 'sqlite3' -# -# SQLite3::Database.new( "data.db" ) do |db| -# db.execute( "select * from table" ) do |row| -# p row -# end -# end -# -# It wraps the lower-level methods provides by the selected driver, and -# includes the Pragmas module for access to various pragma convenience -# methods. -# -# The Database class provides type translation services as well, by which -# the SQLite3 data types (which are all represented as strings) may be -# converted into their corresponding types (as defined in the schemas -# for their tables). This translation only occurs when querying data from -# the database--insertions and updates are all still typeless. -# -# Furthermore, the Database class has been designed to work well with the -# ArrayFields module from Ara Howard. If you require the ArrayFields -# module before performing a query, and if you have not enabled results as -# hashes, then the results will all be indexible by field name. -# -# source://sqlite3//lib/sqlite3/database.rb#35 -class SQLite3::Database - include ::SQLite3::Pragmas - - # call-seq: SQLite3::Database.new(file, options = {}) - # - # Create a new Database object that opens the given file. If utf16 - # is +true+, the filename is interpreted as a UTF-16 encoded string. - # - # By default, the new database will return result rows as arrays - # (#results_as_hash) and has type translation disabled (#type_translation=). - # - # @return [Database] a new instance of Database - # - # source://sqlite3//lib/sqlite3/database.rb#65 - def initialize(file, options = T.unsafe(nil), zvfs = T.unsafe(nil)); end - - # Installs (or removes) a block that will be invoked for every access - # to the database. If the block returns 0 (or +nil+), the statement - # is allowed to proceed. Returning 1 causes an authorization error to - # occur, and returning 2 causes the access to be silently denied. - # - # source://sqlite3//lib/sqlite3/database.rb#140 - def authorizer(&block); end - - def authorizer=(_arg0); end - def busy_handler(*_arg0); end - def busy_timeout(_arg0); end - def busy_timeout=(_arg0); end - def changes; end - def close; end - def closed?; end - def collation(_arg0, _arg1); end - - # Returns the value of attribute collations. - # - # source://sqlite3//lib/sqlite3/database.rb#36 - def collations; end - - # Commits the current transaction. If there is no current transaction, - # this will cause an error to be raised. This returns +true+, in order - # to allow it to be used in idioms like - # abort? and rollback or commit. - # - # source://sqlite3//lib/sqlite3/database.rb#644 - def commit; end - - def complete?(_arg0); end - - # Creates a new aggregate function for use in SQL statements. Aggregate - # functions are functions that apply over every row in the result set, - # instead of over just a single row. (A very common aggregate function - # is the "count" function, for determining the number of rows that match - # a query.) - # - # The new function will be added as +name+, with the given +arity+. (For - # variable arity functions, use -1 for the arity.) - # - # The +step+ parameter must be a proc object that accepts as its first - # parameter a FunctionProxy instance (representing the function - # invocation), with any subsequent parameters (up to the function's arity). - # The +step+ callback will be invoked once for each row of the result set. - # - # The +finalize+ parameter must be a +proc+ object that accepts only a - # single parameter, the FunctionProxy instance representing the current - # function invocation. It should invoke FunctionProxy#result= to - # store the result of the function. - # - # Example: - # - # db.create_aggregate( "lengths", 1 ) do - # step do |func, value| - # func[ :total ] ||= 0 - # func[ :total ] += ( value ? value.length : 0 ) - # end - # - # finalize do |func| - # func.result = func[ :total ] || 0 - # end - # end - # - # puts db.get_first_value( "select lengths(name) from table" ) - # - # See also #create_aggregate_handler for a more object-oriented approach to - # aggregate functions. - # - # source://sqlite3//lib/sqlite3/database.rb#435 - def create_aggregate(name, arity, step = T.unsafe(nil), finalize = T.unsafe(nil), text_rep = T.unsafe(nil), &block); end - - # This is another approach to creating an aggregate function (see - # #create_aggregate). Instead of explicitly specifying the name, - # callbacks, arity, and type, you specify a factory object - # (the "handler") that knows how to obtain all of that information. The - # handler should respond to the following messages: - # - # +arity+:: corresponds to the +arity+ parameter of #create_aggregate. This - # message is optional, and if the handler does not respond to it, - # the function will have an arity of -1. - # +name+:: this is the name of the function. The handler _must_ implement - # this message. - # +new+:: this must be implemented by the handler. It should return a new - # instance of the object that will handle a specific invocation of - # the function. - # - # The handler instance (the object returned by the +new+ message, described - # above), must respond to the following messages: - # - # +step+:: this is the method that will be called for each step of the - # aggregate function's evaluation. It should implement the same - # signature as the +step+ callback for #create_aggregate. - # +finalize+:: this is the method that will be called to finalize the - # aggregate function's evaluation. It should implement the - # same signature as the +finalize+ callback for - # #create_aggregate. - # - # Example: - # - # class LengthsAggregateHandler - # def self.arity; 1; end - # def self.name; 'lengths'; end - # - # def initialize - # @total = 0 - # end - # - # def step( ctx, name ) - # @total += ( name ? name.length : 0 ) - # end - # - # def finalize( ctx ) - # ctx.result = @total - # end - # end - # - # db.create_aggregate_handler( LengthsAggregateHandler ) - # puts db.get_first_value( "select lengths(name) from A" ) - # - # source://sqlite3//lib/sqlite3/database.rb#533 - def create_aggregate_handler(handler); end - - # Creates a new function for use in SQL statements. It will be added as - # +name+, with the given +arity+. (For variable arity functions, use - # -1 for the arity.) - # - # The block should accept at least one parameter--the FunctionProxy - # instance that wraps this function invocation--and any other - # arguments it needs (up to its arity). - # - # The block does not return a value directly. Instead, it will invoke - # the FunctionProxy#result= method on the +func+ parameter and - # indicate the return value that way. - # - # Example: - # - # db.create_function( "maim", 1 ) do |func, value| - # if value.nil? - # func.result = nil - # else - # func.result = value.split(//).sort.join - # end - # end - # - # puts db.get_first_value( "select maim(name) from table" ) - # - # source://sqlite3//lib/sqlite3/database.rb#390 - def create_function(name, arity, text_rep = T.unsafe(nil), &block); end - - # Define an aggregate function named +name+ using a object template - # object +aggregator+. +aggregator+ must respond to +step+ and +finalize+. - # +step+ will be called with row information and +finalize+ must return the - # return value for the aggregator function. - # - # _API Change:_ +aggregator+ must also implement +clone+. The provided - # +aggregator+ object will serve as template that is cloned to provide the - # individual instances of the aggregate function. Regular ruby objects - # already provide a suitable +clone+. - # The functions arity is the arity of the +step+ method. - # - # source://sqlite3//lib/sqlite3/database.rb#570 - def define_aggregator(name, aggregator); end - - def define_function(_arg0); end - def define_function_with_flags(_arg0, _arg1); end - def enable_load_extension(_arg0); end - def encoding; end - def errcode; end - def errmsg; end - - # Executes the given SQL statement. If additional parameters are given, - # they are treated as bind variables, and are bound to the placeholders in - # the query. - # - # Note that if any of the values passed to this are hashes, then the - # key/value pairs are each bound separately, with the key being used as - # the name of the placeholder to bind the value to. - # - # The block is optional. If given, it will be invoked for each row returned - # by the query. Otherwise, any results are accumulated into an array and - # returned wholesale. - # - # See also #execute2, #query, and #execute_batch for additional ways of - # executing statements. - # - # source://sqlite3//lib/sqlite3/database.rb#181 - def execute(sql, bind_vars = T.unsafe(nil), *args, &block); end - - # Executes the given SQL statement, exactly as with #execute. However, the - # first row returned (either via the block, or in the returned array) is - # always the names of the columns. Subsequent rows correspond to the data - # from the result set. - # - # Thus, even if the query itself returns no rows, this method will always - # return at least one row--the names of the columns. - # - # See also #execute, #query, and #execute_batch for additional ways of - # executing statements. - # - # source://sqlite3//lib/sqlite3/database.rb#218 - def execute2(sql, *bind_vars); end - - # Executes all SQL statements in the given string. By contrast, the other - # means of executing queries will only execute the first statement in the - # string, ignoring all subsequent statements. This will execute each one - # in turn. The same bind parameters, if given, will be applied to each - # statement. - # - # This always returns +nil+, making it unsuitable for queries that return - # rows. - # - # See also #execute_batch2 for additional ways of - # executing statements. - # - # source://sqlite3//lib/sqlite3/database.rb#242 - def execute_batch(sql, bind_vars = T.unsafe(nil), *args); end - - # Executes all SQL statements in the given string. By contrast, the other - # means of executing queries will only execute the first statement in the - # string, ignoring all subsequent statements. This will execute each one - # in turn. Bind parameters cannot be passed to #execute_batch2. - # - # If a query is made, all values will be returned as strings. - # If no query is made, an empty array will be returned. - # - # Because all values except for 'NULL' are returned as strings, - # a block can be passed to parse the values accordingly. - # - # See also #execute_batch for additional ways of - # executing statements. - # - # source://sqlite3//lib/sqlite3/database.rb#295 - def execute_batch2(sql, &block); end - - def extended_result_codes=(_arg0); end - - # Returns the filename for the database named +db_name+. +db_name+ defaults - # to "main". Main return `nil` or an empty string if the database is - # temporary or in-memory. - # - # source://sqlite3//lib/sqlite3/database.rb#163 - def filename(db_name = T.unsafe(nil)); end - - # A convenience method for obtaining the first row of a result set, and - # discarding all others. It is otherwise identical to #execute. - # - # See also #get_first_value. - # - # source://sqlite3//lib/sqlite3/database.rb#347 - def get_first_row(sql, *bind_vars); end - - # A convenience method for obtaining the first value of the first row of a - # result set, and discarding all other values and rows. It is otherwise - # identical to #execute. - # - # See also #get_first_row. - # - # source://sqlite3//lib/sqlite3/database.rb#356 - def get_first_value(sql, *bind_vars); end - - def interrupt; end - def last_insert_row_id; end - def load_extension(_arg0); end - - # Returns a Statement object representing the given SQL. This does not - # execute the statement; it merely prepares the statement for execution. - # - # The Statement can then be executed using Statement#execute. - # - # source://sqlite3//lib/sqlite3/database.rb#149 - def prepare(sql); end - - # This is a convenience method for creating a statement, binding - # parameters to it, and calling execute: - # - # result = db.query( "select * from foo where a=?", [5]) - # # is the same as - # result = db.prepare( "select * from foo where a=?" ).execute( 5 ) - # - # You must be sure to call +close+ on the ResultSet instance that is - # returned, or you could have problems with locks on the table. If called - # with a block, +close+ will be invoked implicitly when the block - # terminates. - # - # source://sqlite3//lib/sqlite3/database.rb#317 - def query(sql, bind_vars = T.unsafe(nil), *args); end - - # Returns +true+ if the database has been open in readonly mode - # A helper to check before performing any operation - # - # @return [Boolean] - # - # source://sqlite3//lib/sqlite3/database.rb#660 - def readonly?; end - - # A boolean that indicates whether rows in result sets should be returned - # as hashes or not. By default, rows are returned as arrays. - # - # source://sqlite3//lib/sqlite3/database.rb#55 - def results_as_hash; end - - # A boolean that indicates whether rows in result sets should be returned - # as hashes or not. By default, rows are returned as arrays. - # - # source://sqlite3//lib/sqlite3/database.rb#55 - def results_as_hash=(_arg0); end - - # Rolls the current transaction back. If there is no current transaction, - # this will cause an error to be raised. This returns +true+, in order - # to allow it to be used in idioms like - # abort? and rollback or commit. - # - # source://sqlite3//lib/sqlite3/database.rb#653 - def rollback; end - - def total_changes; end - def trace(*_arg0); end - - # Begins a new transaction. Note that nested transactions are not allowed - # by SQLite, so attempting to nest a transaction will result in a runtime - # exception. - # - # The +mode+ parameter may be either :deferred (the default), - # :immediate, or :exclusive. - # - # If a block is given, the database instance is yielded to it, and the - # transaction is committed when the block terminates. If the block - # raises an exception, a rollback will be performed instead. Note that if - # a block is given, #commit and #rollback should never be called - # explicitly or you'll get an error when the block terminates. - # - # If a block is not given, it is the caller's responsibility to end the - # transaction explicitly, either by calling #commit, or by calling - # #rollback. - # - # source://sqlite3//lib/sqlite3/database.rb#622 - def transaction(mode = T.unsafe(nil)); end - - def transaction_active?; end - - # Translates a +row+ of data from the database with the given +types+ - # - # source://sqlite3//lib/sqlite3/database.rb#711 - def translate_from_db(types, row); end - - # Return the type translator employed by this database instance. Each - # database instance has its own type translator; this allows for different - # type handlers to be installed in each instance without affecting other - # instances. Furthermore, the translators are instantiated lazily, so that - # if a database does not use type translation, it will not be burdened by - # the overhead of a useless type translator. (See the Translator class.) - # - # source://sqlite3//lib/sqlite3/database.rb#132 - def translator; end - - # source://sqlite3//lib/sqlite3/database.rb#124 - def type_translation; end - - # source://sqlite3//lib/sqlite3/database.rb#117 - def type_translation=(value); end - - private - - def db_filename(_arg0); end - def define_aggregator2(_arg0, _arg1); end - def disable_quirk_mode; end - def exec_batch(_arg0, _arg1); end - - # source://sqlite3//lib/sqlite3/database.rb#719 - def make_type_translator(should_translate); end - - def open16(_arg0); end - def open_v2(_arg0, _arg1, _arg2); end - - class << self - def open(*_arg0); end - - # Quotes the given string, making it safe to use in an SQL statement. - # It replaces all instances of the single-quote character with two - # single-quote characters. The modified string is returned. - # - # source://sqlite3//lib/sqlite3/database.rb#47 - def quote(string); end - end -end - -# A helper class for dealing with custom functions (see #create_function, -# #create_aggregate, and #create_aggregate_handler). It encapsulates the -# opaque function object that represents the current invocation. It also -# provides more convenient access to the API functions that operate on -# the function object. -# -# This class will almost _always_ be instantiated indirectly, by working -# with the create methods mentioned above. -# -# source://sqlite3//lib/sqlite3/database.rb#672 -class SQLite3::Database::FunctionProxy - # Create a new FunctionProxy that encapsulates the given +func+ object. - # If context is non-nil, the functions context will be set to that. If - # it is non-nil, it must quack like a Hash. If it is nil, then none of - # the context functions will be available. - # - # @return [FunctionProxy] a new instance of FunctionProxy - # - # source://sqlite3//lib/sqlite3/database.rb#679 - def initialize; end - - # Returns the value with the given key from the context. This is only - # available to aggregate functions. - # - # source://sqlite3//lib/sqlite3/database.rb#699 - def [](key); end - - # Sets the value with the given key in the context. This is only - # available to aggregate functions. - # - # source://sqlite3//lib/sqlite3/database.rb#705 - def []=(key, value); end - - # (Only available to aggregate functions.) Returns the number of rows - # that the aggregate has processed so far. This will include the current - # row, and so will always return at least 1. - # - # source://sqlite3//lib/sqlite3/database.rb#693 - def count; end - - # Returns the value of attribute result. - # - # source://sqlite3//lib/sqlite3/database.rb#673 - def result; end - - # Sets the attribute result - # - # @param value the value to set the attribute result to. - # - # source://sqlite3//lib/sqlite3/database.rb#673 - def result=(_arg0); end - - # Set the result of the function to the given error message. - # The function will then return that error. - # - # source://sqlite3//lib/sqlite3/database.rb#686 - def set_error(error); end -end - -# source://sqlite3//lib/sqlite3/database.rb#717 -SQLite3::Database::NULL_TRANSLATOR = T.let(T.unsafe(nil), Proc) - -# source://sqlite3//lib/sqlite3/errors.rb#24 -class SQLite3::EmptyException < ::SQLite3::Exception; end - -# source://sqlite3//lib/sqlite3/errors.rb#4 -class SQLite3::Exception < ::StandardError - # A convenience for accessing the error code for this exception. - # - # source://sqlite3//lib/sqlite3/errors.rb#6 - def code; end -end - -# source://sqlite3//lib/sqlite3/errors.rb#32 -class SQLite3::FormatException < ::SQLite3::Exception; end - -# source://sqlite3//lib/sqlite3/errors.rb#21 -class SQLite3::FullException < ::SQLite3::Exception; end - -# source://sqlite3//lib/sqlite3/errors.rb#18 -class SQLite3::IOException < ::SQLite3::Exception; end - -# source://sqlite3//lib/sqlite3/errors.rb#10 -class SQLite3::InternalException < ::SQLite3::Exception; end - -# source://sqlite3//lib/sqlite3/errors.rb#17 -class SQLite3::InterruptException < ::SQLite3::Exception; end - -# source://sqlite3//lib/sqlite3/errors.rb#14 -class SQLite3::LockedException < ::SQLite3::Exception; end - -# source://sqlite3//lib/sqlite3/errors.rb#15 -class SQLite3::MemoryException < ::SQLite3::Exception; end - -# source://sqlite3//lib/sqlite3/errors.rb#28 -class SQLite3::MismatchException < ::SQLite3::Exception; end - -# source://sqlite3//lib/sqlite3/errors.rb#29 -class SQLite3::MisuseException < ::SQLite3::Exception; end - -# source://sqlite3//lib/sqlite3/errors.rb#34 -class SQLite3::NotADatabaseException < ::SQLite3::Exception; end - -# source://sqlite3//lib/sqlite3/errors.rb#20 -class SQLite3::NotFoundException < ::SQLite3::Exception; end - -# source://sqlite3//lib/sqlite3/errors.rb#11 -class SQLite3::PermissionException < ::SQLite3::Exception; end - -# This module is intended for inclusion solely by the Database class. It -# defines convenience methods for the various pragmas supported by SQLite3. -# -# For a detailed description of these pragmas, see the SQLite3 documentation -# at http://sqlite.org/pragma.html. -# -# source://sqlite3//lib/sqlite3/pragmas.rb#10 -module SQLite3::Pragmas - # source://sqlite3//lib/sqlite3/pragmas.rb#104 - def application_id; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#108 - def application_id=(integer); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#112 - def auto_vacuum; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#116 - def auto_vacuum=(mode); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#120 - def automatic_index; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#124 - def automatic_index=(mode); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#128 - def busy_timeout; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#132 - def busy_timeout=(milliseconds); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#136 - def cache_size; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#140 - def cache_size=(size); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#144 - def cache_spill; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#148 - def cache_spill=(mode); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#152 - def case_sensitive_like=(mode); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#156 - def cell_size_check; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#160 - def cell_size_check=(mode); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#164 - def checkpoint_fullfsync; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#168 - def checkpoint_fullfsync=(mode); end - - # :yields: row - # - # source://sqlite3//lib/sqlite3/pragmas.rb#172 - def collation_list(&block); end - - # :yields: row - # - # source://sqlite3//lib/sqlite3/pragmas.rb#176 - def compile_options(&block); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#180 - def count_changes; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#184 - def count_changes=(mode); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#188 - def data_version; end - - # :yields: row - # - # source://sqlite3//lib/sqlite3/pragmas.rb#192 - def database_list(&block); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#196 - def default_cache_size; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#200 - def default_cache_size=(size); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#204 - def default_synchronous; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#208 - def default_synchronous=(mode); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#212 - def default_temp_store; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#216 - def default_temp_store=(mode); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#220 - def defer_foreign_keys; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#224 - def defer_foreign_keys=(mode); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#228 - def encoding; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#232 - def encoding=(mode); end - - # :yields: row - # - # source://sqlite3//lib/sqlite3/pragmas.rb#236 - def foreign_key_check(*table, &block); end - - # :yields: row - # - # source://sqlite3//lib/sqlite3/pragmas.rb#240 - def foreign_key_list(table, &block); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#244 - def foreign_keys; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#248 - def foreign_keys=(mode); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#252 - def freelist_count; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#256 - def full_column_names; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#260 - def full_column_names=(mode); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#264 - def fullfsync; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#268 - def fullfsync=(mode); end - - # Returns +true+ or +false+ depending on the value of the named pragma. - # - # source://sqlite3//lib/sqlite3/pragmas.rb#13 - def get_boolean_pragma(name); end - - # Return the value of the given pragma. - # - # source://sqlite3//lib/sqlite3/pragmas.rb#55 - def get_enum_pragma(name); end - - # Returns the value of the given pragma as an integer. - # - # source://sqlite3//lib/sqlite3/pragmas.rb#72 - def get_int_pragma(name); end - - # Requests the given pragma (and parameters), and if the block is given, - # each row of the result set will be yielded to it. Otherwise, the results - # are returned as an array. - # - # source://sqlite3//lib/sqlite3/pragmas.rb#45 - def get_query_pragma(name, *params, &block); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#272 - def ignore_check_constraints=(mode); end - - # :yields: row - # - # source://sqlite3//lib/sqlite3/pragmas.rb#276 - def incremental_vacuum(pages, &block); end - - # :yields: row - # - # source://sqlite3//lib/sqlite3/pragmas.rb#280 - def index_info(index, &block); end - - # :yields: row - # - # source://sqlite3//lib/sqlite3/pragmas.rb#284 - def index_list(table, &block); end - - # :yields: row - # - # source://sqlite3//lib/sqlite3/pragmas.rb#288 - def index_xinfo(index, &block); end - - # :yields: row - # - # source://sqlite3//lib/sqlite3/pragmas.rb#292 - def integrity_check(*num_errors, &block); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#296 - def journal_mode; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#300 - def journal_mode=(mode); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#304 - def journal_size_limit; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#308 - def journal_size_limit=(size); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#312 - def legacy_file_format; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#316 - def legacy_file_format=(mode); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#320 - def locking_mode; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#324 - def locking_mode=(mode); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#328 - def max_page_count; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#332 - def max_page_count=(size); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#336 - def mmap_size; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#340 - def mmap_size=(size); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#344 - def page_count; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#348 - def page_size; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#352 - def page_size=(size); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#356 - def parser_trace=(mode); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#360 - def query_only; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#364 - def query_only=(mode); end - - # :yields: row - # - # source://sqlite3//lib/sqlite3/pragmas.rb#368 - def quick_check(*num_errors, &block); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#372 - def read_uncommitted; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#376 - def read_uncommitted=(mode); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#380 - def recursive_triggers; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#384 - def recursive_triggers=(mode); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#388 - def reverse_unordered_selects; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#392 - def reverse_unordered_selects=(mode); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#396 - def schema_cookie; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#400 - def schema_cookie=(cookie); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#404 - def schema_version; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#408 - def schema_version=(version); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#412 - def secure_delete; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#416 - def secure_delete=(mode); end - - # Sets the given pragma to the given boolean value. The value itself - # may be +true+ or +false+, or any other commonly used string or - # integer that represents truth. - # - # source://sqlite3//lib/sqlite3/pragmas.rb#20 - def set_boolean_pragma(name, mode); end - - # Set the value of the given pragma to +mode+. The +mode+ parameter must - # conform to one of the values in the given +enum+ array. Each entry in - # the array is another array comprised of elements in the enumeration that - # have duplicate values. See #synchronous, #default_synchronous, - # #temp_store, and #default_temp_store for usage examples. - # - # @raise [Exception] - # - # source://sqlite3//lib/sqlite3/pragmas.rb#64 - def set_enum_pragma(name, mode, enums); end - - # Set the value of the given pragma to the integer value of the +value+ - # parameter. - # - # source://sqlite3//lib/sqlite3/pragmas.rb#78 - def set_int_pragma(name, value); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#420 - def short_column_names; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#424 - def short_column_names=(mode); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#428 - def shrink_memory; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#432 - def soft_heap_limit; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#436 - def soft_heap_limit=(mode); end - - # :yields: row - # - # source://sqlite3//lib/sqlite3/pragmas.rb#440 - def stats(&block); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#444 - def synchronous; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#448 - def synchronous=(mode); end - - # Returns information about +table+. Yields each row of table information - # if a block is provided. - # - # source://sqlite3//lib/sqlite3/pragmas.rb#527 - def table_info(table); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#452 - def temp_store; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#456 - def temp_store=(mode); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#460 - def threads; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#464 - def threads=(count); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#468 - def user_cookie; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#472 - def user_cookie=(cookie); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#476 - def user_version; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#480 - def user_version=(version); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#484 - def vdbe_addoptrace=(mode); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#488 - def vdbe_debug=(mode); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#492 - def vdbe_listing=(mode); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#496 - def vdbe_trace; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#500 - def vdbe_trace=(mode); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#504 - def wal_autocheckpoint; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#508 - def wal_autocheckpoint=(mode); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#512 - def wal_checkpoint; end - - # source://sqlite3//lib/sqlite3/pragmas.rb#516 - def wal_checkpoint=(mode); end - - # source://sqlite3//lib/sqlite3/pragmas.rb#520 - def writable_schema=(mode); end - - private - - # Since SQLite 3.3.8, the table_info pragma has returned the default - # value of the row as a quoted SQL value. This method essentially - # unquotes those values. - # - # source://sqlite3//lib/sqlite3/pragmas.rb#583 - def tweak_default(hash); end - - # Compares two version strings - # - # source://sqlite3//lib/sqlite3/pragmas.rb#567 - def version_compare(v1, v2); end -end - -# The enumeration of valid auto vacuum modes. -# -# source://sqlite3//lib/sqlite3/pragmas.rb#89 -SQLite3::Pragmas::AUTO_VACUUM_MODES = T.let(T.unsafe(nil), Array) - -# The list of valid encodings. -# -# source://sqlite3//lib/sqlite3/pragmas.rb#99 -SQLite3::Pragmas::ENCODINGS = T.let(T.unsafe(nil), Array) - -# The list of valid journaling modes. -# -# source://sqlite3//lib/sqlite3/pragmas.rb#92 -SQLite3::Pragmas::JOURNAL_MODES = T.let(T.unsafe(nil), Array) - -# The list of valid locking modes. -# -# source://sqlite3//lib/sqlite3/pragmas.rb#96 -SQLite3::Pragmas::LOCKING_MODES = T.let(T.unsafe(nil), Array) - -# The enumeration of valid synchronous modes. -# -# source://sqlite3//lib/sqlite3/pragmas.rb#83 -SQLite3::Pragmas::SYNCHRONOUS_MODES = T.let(T.unsafe(nil), Array) - -# The enumeration of valid temp store modes. -# -# source://sqlite3//lib/sqlite3/pragmas.rb#86 -SQLite3::Pragmas::TEMP_STORE_MODES = T.let(T.unsafe(nil), Array) - -# The list of valid WAL checkpoints. -# -# source://sqlite3//lib/sqlite3/pragmas.rb#102 -SQLite3::Pragmas::WAL_CHECKPOINTS = T.let(T.unsafe(nil), Array) - -# source://sqlite3//lib/sqlite3/errors.rb#23 -class SQLite3::ProtocolException < ::SQLite3::Exception; end - -# source://sqlite3//lib/sqlite3/errors.rb#33 -class SQLite3::RangeException < ::SQLite3::Exception; end - -# source://sqlite3//lib/sqlite3/errors.rb#16 -class SQLite3::ReadOnlyException < ::SQLite3::Exception; end - -# The ResultSet object encapsulates the enumerability of a query's output. -# It is a simple cursor over the data that the query returns. It will -# very rarely (if ever) be instantiated directly. Instead, clients should -# obtain a ResultSet instance via Statement#execute. -# -# source://sqlite3//lib/sqlite3/resultset.rb#10 -class SQLite3::ResultSet - include ::Enumerable - - # Create a new ResultSet attached to the given database, using the - # given sql text. - # - # @return [ResultSet] a new instance of ResultSet - # - # source://sqlite3//lib/sqlite3/resultset.rb#64 - def initialize(db, stmt); end - - # Closes the statement that spawned this result set. - # Use with caution! Closing a result set will automatically - # close any other result sets that were spawned from the same statement. - # - # source://sqlite3//lib/sqlite3/resultset.rb#141 - def close; end - - # Queries whether the underlying statement has been closed or not. - # - # @return [Boolean] - # - # source://sqlite3//lib/sqlite3/resultset.rb#146 - def closed?; end - - # Returns the names of the columns returned by this result set. - # - # source://sqlite3//lib/sqlite3/resultset.rb#156 - def columns; end - - # Required by the Enumerable mixin. Provides an internal iterator over the - # rows of the result set. - # - # source://sqlite3//lib/sqlite3/resultset.rb#124 - def each; end - - # Provides an internal iterator over the rows of the result set where - # each row is yielded as a hash. - # - # source://sqlite3//lib/sqlite3/resultset.rb#132 - def each_hash; end - - # Query whether the cursor has reached the end of the result set or not. - # - # @return [Boolean] - # - # source://sqlite3//lib/sqlite3/resultset.rb#78 - def eof?; end - - # Obtain the next row from the cursor. If there are no more rows to be - # had, this will return +nil+. If type translation is active on the - # corresponding database, the values in the row will be translated - # according to their types. - # - # The returned value will be an array, unless Database#results_as_hash has - # been set to +true+, in which case the returned value will be a hash. - # - # For arrays, the column names are accessible via the +fields+ property, - # and the column types are accessible via the +types+ property. - # - # For hashes, the column names are the keys of the hash, and the column - # types are accessible via the +types+ property. - # - # source://sqlite3//lib/sqlite3/resultset.rb#95 - def next; end - - # Return the next row as a hash - # - # source://sqlite3//lib/sqlite3/resultset.rb#161 - def next_hash; end - - # Reset the cursor, so that a result set which has reached end-of-file - # can be rewound and reiterated. - # - # source://sqlite3//lib/sqlite3/resultset.rb#71 - def reset(*bind_params); end - - # Returns the types of the columns returned by this result set. - # - # source://sqlite3//lib/sqlite3/resultset.rb#151 - def types; end -end - -# source://sqlite3//lib/sqlite3/resultset.rb#13 -class SQLite3::ResultSet::ArrayWithTypes < ::Array - # Returns the value of attribute types. - # - # source://sqlite3//lib/sqlite3/resultset.rb#14 - def types; end - - # Sets the attribute types - # - # @param value the value to set the attribute types to. - # - # source://sqlite3//lib/sqlite3/resultset.rb#14 - def types=(_arg0); end -end - -# source://sqlite3//lib/sqlite3/resultset.rb#17 -class SQLite3::ResultSet::ArrayWithTypesAndFields < ::Array - # source://sqlite3//lib/sqlite3/resultset.rb#28 - def fields; end - - # Sets the attribute fields - # - # @param value the value to set the attribute fields to. - # - # source://sqlite3//lib/sqlite3/resultset.rb#19 - def fields=(_arg0); end - - # source://sqlite3//lib/sqlite3/resultset.rb#21 - def types; end - - # Sets the attribute types - # - # @param value the value to set the attribute types to. - # - # source://sqlite3//lib/sqlite3/resultset.rb#18 - def types=(_arg0); end -end - -# The class of which we return an object in case we want a Hash as -# result. -# -# source://sqlite3//lib/sqlite3/resultset.rb#38 -class SQLite3::ResultSet::HashWithTypesAndFields < ::Hash - # source://sqlite3//lib/sqlite3/resultset.rb#56 - def [](key); end - - # source://sqlite3//lib/sqlite3/resultset.rb#49 - def fields; end - - # Sets the attribute fields - # - # @param value the value to set the attribute fields to. - # - # source://sqlite3//lib/sqlite3/resultset.rb#40 - def fields=(_arg0); end - - # source://sqlite3//lib/sqlite3/resultset.rb#42 - def types; end - - # source://sqlite3//lib/sqlite3/resultset.rb#39 - def types=(_arg0); end -end - -# source://sqlite3//lib/sqlite3/errors.rb#9 -class SQLite3::SQLException < ::SQLite3::Exception; end - -SQLite3::SQLITE_LOADED_VERSION = T.let(T.unsafe(nil), String) -SQLite3::SQLITE_VERSION = T.let(T.unsafe(nil), String) -SQLite3::SQLITE_VERSION_NUMBER = T.let(T.unsafe(nil), Integer) - -# source://sqlite3//lib/sqlite3/errors.rb#25 -class SQLite3::SchemaChangedException < ::SQLite3::Exception; end - -# A statement represents a prepared-but-unexecuted SQL query. It will rarely -# (if ever) be instantiated directly by a client, and is most often obtained -# via the Database#prepare method. -# -# source://sqlite3//lib/sqlite3/statement.rb#14 -class SQLite3::Statement - include ::Enumerable - - def initialize(_arg0, _arg1); end - - # Returns true if the statement is currently active, meaning it has an - # open result set. - # - # @return [Boolean] - # - # source://sqlite3//lib/sqlite3/statement.rb#94 - def active?; end - - def bind_param(_arg0, _arg1); end - def bind_parameter_count; end - - # Binds the given variables to the corresponding placeholders in the SQL - # text. - # - # See Database#execute for a description of the valid placeholder - # syntaxes. - # - # Example: - # - # stmt = db.prepare( "select * from table where a=? and b=?" ) - # stmt.bind_params( 15, "hello" ) - # - # See also #execute, #bind_param, Statement#bind_param, and - # Statement#bind_params. - # - # source://sqlite3//lib/sqlite3/statement.rb#35 - def bind_params(*bind_vars); end - - def clear_bindings!; end - def close; end - def closed?; end - def column_count; end - def column_decltype(_arg0); end - def column_name(_arg0); end - - # Return an array of the column names for this statement. Note that this - # may execute the statement in order to obtain the metadata; this makes it - # a (potentially) expensive operation. - # - # source://sqlite3//lib/sqlite3/statement.rb#101 - def columns; end - - def done?; end - - # source://sqlite3//lib/sqlite3/statement.rb#106 - def each; end - - # Execute the statement. This creates a new ResultSet object for the - # statement's virtual machine. If a block was given, the new ResultSet will - # be yielded to it; otherwise, the ResultSet will be returned. - # - # Any parameters will be bound to the statement using #bind_params. - # - # Example: - # - # stmt = db.prepare( "select * from table" ) - # stmt.execute do |result| - # ... - # end - # - # See also #bind_params, #execute!. - # - # @yield [@results] - # - # source://sqlite3//lib/sqlite3/statement.rb#61 - def execute(*bind_vars); end - - # Execute the statement. If no block was given, this returns an array of - # rows returned by executing the statement. Otherwise, each row will be - # yielded to the block. - # - # Any parameters will be bound to the statement using #bind_params. - # - # Example: - # - # stmt = db.prepare( "select * from table" ) - # stmt.execute! do |row| - # ... - # end - # - # See also #bind_params, #execute. - # - # source://sqlite3//lib/sqlite3/statement.rb#87 - def execute!(*bind_vars, &block); end - - # Performs a sanity check to ensure that the statement is not - # closed. If it is, an exception is raised. - # - # source://sqlite3//lib/sqlite3/statement.rb#125 - def must_be_open!; end - - # This is any text that followed the first valid SQL statement in the text - # with which the statement was initialized. If there was no trailing text, - # this will be the empty string. - # - # source://sqlite3//lib/sqlite3/statement.rb#20 - def remainder; end - - def reset!; end - def step; end - - # Return an array of the data types for each column in this statement. Note - # that this may execute the statement in order to obtain the metadata; this - # makes it a (potentially) expensive operation. - # - # source://sqlite3//lib/sqlite3/statement.rb#117 - def types; end - - private - - # A convenience method for obtaining the metadata about the query. Note - # that this will actually execute the SQL, which means it can be a - # (potentially) expensive operation. - # - # source://sqlite3//lib/sqlite3/statement.rb#135 - def get_metadata; end -end - -# source://sqlite3//lib/sqlite3/errors.rb#26 -class SQLite3::TooBigException < ::SQLite3::Exception; end - -# The Translator class encapsulates the logic and callbacks necessary for -# converting string data to a value of some specified type. Every Database -# instance may have a Translator instance, in order to assist in type -# translation (Database#type_translation). -# -# Further, applications may define their own custom type translation logic -# by registering translator blocks with the corresponding database's -# translator instance (Database#translator). -# -# source://sqlite3//lib/sqlite3/translator.rb#14 -class SQLite3::Translator - # Create a new Translator instance. It will be preinitialized with default - # translators for most SQL data types. - # - # @return [Translator] a new instance of Translator - # - # source://sqlite3//lib/sqlite3/translator.rb#18 - def initialize; end - - # Add a new translator block, which will be invoked to process type - # translations to the given type. The type should be an SQL datatype, and - # may include parentheses (i.e., "VARCHAR(30)"). However, any parenthetical - # information is stripped off and discarded, so type translation decisions - # are made solely on the "base" type name. - # - # The translator block itself should accept two parameters, "type" and - # "value". In this case, the "type" is the full type name (including - # parentheses), so the block itself may include logic for changing how a - # type is translated based on the additional data. The "value" parameter - # is the (string) data to convert. - # - # The block should return the translated value. - # - # source://sqlite3//lib/sqlite3/translator.rb#37 - def add_translator(type, &block); end - - # Translate the given string value to a value of the given type. In the - # absence of an installed translator block for the given type, the value - # itself is always returned. Further, +nil+ values are never translated, - # and are always passed straight through regardless of the type parameter. - # - # source://sqlite3//lib/sqlite3/translator.rb#48 - def translate(type, value); end - - private - - # Register the default translators for the current Translator instance. - # This includes translators for most major SQL data types. - # - # source://sqlite3//lib/sqlite3/translator.rb#72 - def register_default_translators; end - - # A convenience method for working with type names. This returns the "base" - # type name, without any parenthetical data. - # - # source://sqlite3//lib/sqlite3/translator.rb#61 - def type_name(type); end -end - -# source://sqlite3//lib/sqlite3/errors.rb#30 -class SQLite3::UnsupportedException < ::SQLite3::Exception; end - -# source://sqlite3//lib/sqlite3/version.rb#3 -SQLite3::VERSION = T.let(T.unsafe(nil), String) - -# source://sqlite3//lib/sqlite3/value.rb#5 -class SQLite3::Value - # @return [Value] a new instance of Value - # - # source://sqlite3//lib/sqlite3/value.rb#8 - def initialize(db, handle); end - - # Returns the value of attribute handle. - # - # source://sqlite3//lib/sqlite3/value.rb#6 - def handle; end - - # source://sqlite3//lib/sqlite3/value.rb#21 - def length(utf16 = T.unsafe(nil)); end - - # @return [Boolean] - # - # source://sqlite3//lib/sqlite3/value.rb#13 - def null?; end - - # source://sqlite3//lib/sqlite3/value.rb#17 - def to_blob; end - - # source://sqlite3//lib/sqlite3/value.rb#29 - def to_f; end - - # source://sqlite3//lib/sqlite3/value.rb#33 - def to_i; end - - # source://sqlite3//lib/sqlite3/value.rb#37 - def to_int64; end - - # source://sqlite3//lib/sqlite3/value.rb#41 - def to_s(utf16 = T.unsafe(nil)); end - - # source://sqlite3//lib/sqlite3/value.rb#45 - def type; end -end - -# source://sqlite3//lib/sqlite3/version.rb#5 -module SQLite3::VersionProxy; end - -# source://sqlite3//lib/sqlite3/version.rb#9 -SQLite3::VersionProxy::BUILD = T.let(T.unsafe(nil), T.untyped) - -# source://sqlite3//lib/sqlite3/version.rb#6 -SQLite3::VersionProxy::MAJOR = T.let(T.unsafe(nil), Integer) - -# source://sqlite3//lib/sqlite3/version.rb#7 -SQLite3::VersionProxy::MINOR = T.let(T.unsafe(nil), Integer) - -# source://sqlite3//lib/sqlite3/version.rb#11 -SQLite3::VersionProxy::STRING = T.let(T.unsafe(nil), String) - -# source://sqlite3//lib/sqlite3/version.rb#8 -SQLite3::VersionProxy::TINY = T.let(T.unsafe(nil), Integer) - -# source://sqlite3//lib/sqlite3/version.rb#13 -SQLite3::VersionProxy::VERSION = T.let(T.unsafe(nil), String) - -# source://sqlite3//lib/sqlite3/statement.rb#4 -class String - include ::Comparable - - # source://sqlite3//lib/sqlite3/statement.rb#5 - def to_blob; end -end