amalgalite 1.4.1-x86-mingw32 → 1.7.0-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CONTRIBUTING.md +11 -0
- data/HISTORY.md +45 -0
- data/LICENSE +2 -0
- data/Manifest.txt +2 -1
- data/README.md +10 -14
- data/Rakefile +5 -5
- data/examples/fts5.rb +152 -0
- data/ext/amalgalite/c/amalgalite.c +26 -0
- data/ext/amalgalite/c/amalgalite_constants.c +1110 -56
- data/ext/amalgalite/c/amalgalite_database.c +80 -70
- data/ext/amalgalite/c/extconf.rb +31 -4
- data/ext/amalgalite/c/gen_constants.rb +313 -153
- data/ext/amalgalite/c/sqlite3.c +103967 -33836
- data/ext/amalgalite/c/sqlite3.h +5438 -1061
- data/ext/amalgalite/c/sqlite3ext.h +148 -12
- data/lib/amalgalite/2.2/amalgalite.so +0 -0
- data/lib/amalgalite/2.3/amalgalite.so +0 -0
- data/lib/amalgalite/2.4/amalgalite.so +0 -0
- data/lib/amalgalite/2.5/amalgalite.so +0 -0
- data/lib/amalgalite/2.6/amalgalite.so +0 -0
- data/lib/amalgalite/aggregate.rb +6 -0
- data/lib/amalgalite/csv_table_importer.rb +1 -1
- data/lib/amalgalite/database.rb +2 -53
- data/lib/amalgalite/profile_tap.rb +2 -2
- data/lib/amalgalite/statement.rb +5 -2
- data/lib/amalgalite/taps/io.rb +5 -2
- data/lib/amalgalite/trace_tap.rb +1 -1
- data/lib/amalgalite/type_maps/default_map.rb +2 -2
- data/lib/amalgalite/type_maps/storage_map.rb +1 -1
- data/lib/amalgalite/version.rb +1 -1
- data/spec/aggregate_spec.rb +4 -0
- data/spec/database_spec.rb +12 -15
- data/spec/default_map_spec.rb +1 -1
- data/spec/integeration_spec.rb +2 -2
- data/spec/json_spec.rb +24 -0
- data/spec/sqlite3/version_spec.rb +15 -9
- data/spec/storage_map_spec.rb +1 -1
- data/tasks/default.rake +3 -10
- data/tasks/extension.rake +4 -4
- data/tasks/this.rb +7 -5
- metadata +33 -25
- data/examples/fts3.rb +0 -144
- data/lib/amalgalite/1.8/amalgalite.so +0 -0
- data/lib/amalgalite/1.9/amalgalite.so +0 -0
- data/lib/amalgalite/2.0/amalgalite.so +0 -0
- data/lib/amalgalite/2.1/amalgalite.so +0 -0
@@ -15,12 +15,10 @@
|
|
15
15
|
** as extensions by SQLite should #include this file instead of
|
16
16
|
** sqlite3.h.
|
17
17
|
*/
|
18
|
-
#ifndef
|
19
|
-
#define
|
18
|
+
#ifndef SQLITE3EXT_H
|
19
|
+
#define SQLITE3EXT_H
|
20
20
|
#include "sqlite3.h"
|
21
21
|
|
22
|
-
typedef struct sqlite3_api_routines sqlite3_api_routines;
|
23
|
-
|
24
22
|
/*
|
25
23
|
** The following structure holds pointers to all of the SQLite API
|
26
24
|
** routines.
|
@@ -136,7 +134,7 @@ struct sqlite3_api_routines {
|
|
136
134
|
int (*set_authorizer)(sqlite3*,int(*)(void*,int,const char*,const char*,
|
137
135
|
const char*,const char*),void*);
|
138
136
|
void (*set_auxdata)(sqlite3_context*,int,void*,void (*)(void*));
|
139
|
-
char * (*
|
137
|
+
char * (*xsnprintf)(int,char*,const char*,...);
|
140
138
|
int (*step)(sqlite3_stmt*);
|
141
139
|
int (*table_column_metadata)(sqlite3*,const char*,const char*,const char*,
|
142
140
|
char const**,char const**,int*,int*,int*);
|
@@ -248,7 +246,7 @@ struct sqlite3_api_routines {
|
|
248
246
|
int (*uri_boolean)(const char*,const char*,int);
|
249
247
|
sqlite3_int64 (*uri_int64)(const char*,const char*,sqlite3_int64);
|
250
248
|
const char *(*uri_parameter)(const char*,const char*);
|
251
|
-
char *(*
|
249
|
+
char *(*xvsnprintf)(int,char*,const char*,va_list);
|
252
250
|
int (*wal_checkpoint_v2)(sqlite3*,const char*,int,int*,int*);
|
253
251
|
/* Version 3.8.7 and later */
|
254
252
|
int (*auto_extension)(void(*)(void));
|
@@ -272,8 +270,85 @@ struct sqlite3_api_routines {
|
|
272
270
|
void (*value_free)(sqlite3_value*);
|
273
271
|
int (*result_zeroblob64)(sqlite3_context*,sqlite3_uint64);
|
274
272
|
int (*bind_zeroblob64)(sqlite3_stmt*, int, sqlite3_uint64);
|
273
|
+
/* Version 3.9.0 and later */
|
274
|
+
unsigned int (*value_subtype)(sqlite3_value*);
|
275
|
+
void (*result_subtype)(sqlite3_context*,unsigned int);
|
276
|
+
/* Version 3.10.0 and later */
|
277
|
+
int (*status64)(int,sqlite3_int64*,sqlite3_int64*,int);
|
278
|
+
int (*strlike)(const char*,const char*,unsigned int);
|
279
|
+
int (*db_cacheflush)(sqlite3*);
|
280
|
+
/* Version 3.12.0 and later */
|
281
|
+
int (*system_errno)(sqlite3*);
|
282
|
+
/* Version 3.14.0 and later */
|
283
|
+
int (*trace_v2)(sqlite3*,unsigned,int(*)(unsigned,void*,void*,void*),void*);
|
284
|
+
char *(*expanded_sql)(sqlite3_stmt*);
|
285
|
+
/* Version 3.18.0 and later */
|
286
|
+
void (*set_last_insert_rowid)(sqlite3*,sqlite3_int64);
|
287
|
+
/* Version 3.20.0 and later */
|
288
|
+
int (*prepare_v3)(sqlite3*,const char*,int,unsigned int,
|
289
|
+
sqlite3_stmt**,const char**);
|
290
|
+
int (*prepare16_v3)(sqlite3*,const void*,int,unsigned int,
|
291
|
+
sqlite3_stmt**,const void**);
|
292
|
+
int (*bind_pointer)(sqlite3_stmt*,int,void*,const char*,void(*)(void*));
|
293
|
+
void (*result_pointer)(sqlite3_context*,void*,const char*,void(*)(void*));
|
294
|
+
void *(*value_pointer)(sqlite3_value*,const char*);
|
295
|
+
int (*vtab_nochange)(sqlite3_context*);
|
296
|
+
int (*value_nochange)(sqlite3_value*);
|
297
|
+
const char *(*vtab_collation)(sqlite3_index_info*,int);
|
298
|
+
/* Version 3.24.0 and later */
|
299
|
+
int (*keyword_count)(void);
|
300
|
+
int (*keyword_name)(int,const char**,int*);
|
301
|
+
int (*keyword_check)(const char*,int);
|
302
|
+
sqlite3_str *(*str_new)(sqlite3*);
|
303
|
+
char *(*str_finish)(sqlite3_str*);
|
304
|
+
void (*str_appendf)(sqlite3_str*, const char *zFormat, ...);
|
305
|
+
void (*str_vappendf)(sqlite3_str*, const char *zFormat, va_list);
|
306
|
+
void (*str_append)(sqlite3_str*, const char *zIn, int N);
|
307
|
+
void (*str_appendall)(sqlite3_str*, const char *zIn);
|
308
|
+
void (*str_appendchar)(sqlite3_str*, int N, char C);
|
309
|
+
void (*str_reset)(sqlite3_str*);
|
310
|
+
int (*str_errcode)(sqlite3_str*);
|
311
|
+
int (*str_length)(sqlite3_str*);
|
312
|
+
char *(*str_value)(sqlite3_str*);
|
313
|
+
/* Version 3.25.0 and later */
|
314
|
+
int (*create_window_function)(sqlite3*,const char*,int,int,void*,
|
315
|
+
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
|
316
|
+
void (*xFinal)(sqlite3_context*),
|
317
|
+
void (*xValue)(sqlite3_context*),
|
318
|
+
void (*xInv)(sqlite3_context*,int,sqlite3_value**),
|
319
|
+
void(*xDestroy)(void*));
|
320
|
+
/* Version 3.26.0 and later */
|
321
|
+
const char *(*normalized_sql)(sqlite3_stmt*);
|
322
|
+
/* Version 3.28.0 and later */
|
323
|
+
int (*stmt_isexplain)(sqlite3_stmt*);
|
324
|
+
int (*value_frombind)(sqlite3_value*);
|
325
|
+
/* Version 3.30.0 and later */
|
326
|
+
int (*drop_modules)(sqlite3*,const char**);
|
327
|
+
/* Version 3.31.0 and later */
|
328
|
+
sqlite3_int64 (*hard_heap_limit64)(sqlite3_int64);
|
329
|
+
const char *(*uri_key)(const char*,int);
|
330
|
+
const char *(*filename_database)(const char*);
|
331
|
+
const char *(*filename_journal)(const char*);
|
332
|
+
const char *(*filename_wal)(const char*);
|
333
|
+
/* Version 3.32.0 and later */
|
334
|
+
char *(*create_filename)(const char*,const char*,const char*,
|
335
|
+
int,const char**);
|
336
|
+
void (*free_filename)(char*);
|
337
|
+
sqlite3_file *(*database_file_object)(const char*);
|
338
|
+
/* Version 3.34.0 and later */
|
339
|
+
int (*txn_state)(sqlite3*,const char*);
|
275
340
|
};
|
276
341
|
|
342
|
+
/*
|
343
|
+
** This is the function signature used for all extension entry points. It
|
344
|
+
** is also defined in the file "loadext.c".
|
345
|
+
*/
|
346
|
+
typedef int (*sqlite3_loadext_entry)(
|
347
|
+
sqlite3 *db, /* Handle to the database. */
|
348
|
+
char **pzErrMsg, /* Used to set error string on failure. */
|
349
|
+
const sqlite3_api_routines *pThunk /* Extension API function pointers. */
|
350
|
+
);
|
351
|
+
|
277
352
|
/*
|
278
353
|
** The following macros redefine the API routines so that they are
|
279
354
|
** redirected through the global sqlite3_api structure.
|
@@ -285,7 +360,7 @@ struct sqlite3_api_routines {
|
|
285
360
|
** the API. So the redefinition macros are only valid if the
|
286
361
|
** SQLITE_CORE macros is undefined.
|
287
362
|
*/
|
288
|
-
#
|
363
|
+
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
|
289
364
|
#define sqlite3_aggregate_context sqlite3_api->aggregate_context
|
290
365
|
#ifndef SQLITE_OMIT_DEPRECATED
|
291
366
|
#define sqlite3_aggregate_count sqlite3_api->aggregate_count
|
@@ -388,7 +463,7 @@ struct sqlite3_api_routines {
|
|
388
463
|
#define sqlite3_rollback_hook sqlite3_api->rollback_hook
|
389
464
|
#define sqlite3_set_authorizer sqlite3_api->set_authorizer
|
390
465
|
#define sqlite3_set_auxdata sqlite3_api->set_auxdata
|
391
|
-
#define sqlite3_snprintf sqlite3_api->
|
466
|
+
#define sqlite3_snprintf sqlite3_api->xsnprintf
|
392
467
|
#define sqlite3_step sqlite3_api->step
|
393
468
|
#define sqlite3_table_column_metadata sqlite3_api->table_column_metadata
|
394
469
|
#define sqlite3_thread_cleanup sqlite3_api->thread_cleanup
|
@@ -412,6 +487,7 @@ struct sqlite3_api_routines {
|
|
412
487
|
#define sqlite3_value_text16le sqlite3_api->value_text16le
|
413
488
|
#define sqlite3_value_type sqlite3_api->value_type
|
414
489
|
#define sqlite3_vmprintf sqlite3_api->vmprintf
|
490
|
+
#define sqlite3_vsnprintf sqlite3_api->xvsnprintf
|
415
491
|
#define sqlite3_overload_function sqlite3_api->overload_function
|
416
492
|
#define sqlite3_prepare_v2 sqlite3_api->prepare_v2
|
417
493
|
#define sqlite3_prepare16_v2 sqlite3_api->prepare16_v2
|
@@ -487,7 +563,7 @@ struct sqlite3_api_routines {
|
|
487
563
|
#define sqlite3_uri_boolean sqlite3_api->uri_boolean
|
488
564
|
#define sqlite3_uri_int64 sqlite3_api->uri_int64
|
489
565
|
#define sqlite3_uri_parameter sqlite3_api->uri_parameter
|
490
|
-
#define sqlite3_uri_vsnprintf sqlite3_api->
|
566
|
+
#define sqlite3_uri_vsnprintf sqlite3_api->xvsnprintf
|
491
567
|
#define sqlite3_wal_checkpoint_v2 sqlite3_api->wal_checkpoint_v2
|
492
568
|
/* Version 3.8.7 and later */
|
493
569
|
#define sqlite3_auto_extension sqlite3_api->auto_extension
|
@@ -507,9 +583,69 @@ struct sqlite3_api_routines {
|
|
507
583
|
#define sqlite3_value_free sqlite3_api->value_free
|
508
584
|
#define sqlite3_result_zeroblob64 sqlite3_api->result_zeroblob64
|
509
585
|
#define sqlite3_bind_zeroblob64 sqlite3_api->bind_zeroblob64
|
510
|
-
|
586
|
+
/* Version 3.9.0 and later */
|
587
|
+
#define sqlite3_value_subtype sqlite3_api->value_subtype
|
588
|
+
#define sqlite3_result_subtype sqlite3_api->result_subtype
|
589
|
+
/* Version 3.10.0 and later */
|
590
|
+
#define sqlite3_status64 sqlite3_api->status64
|
591
|
+
#define sqlite3_strlike sqlite3_api->strlike
|
592
|
+
#define sqlite3_db_cacheflush sqlite3_api->db_cacheflush
|
593
|
+
/* Version 3.12.0 and later */
|
594
|
+
#define sqlite3_system_errno sqlite3_api->system_errno
|
595
|
+
/* Version 3.14.0 and later */
|
596
|
+
#define sqlite3_trace_v2 sqlite3_api->trace_v2
|
597
|
+
#define sqlite3_expanded_sql sqlite3_api->expanded_sql
|
598
|
+
/* Version 3.18.0 and later */
|
599
|
+
#define sqlite3_set_last_insert_rowid sqlite3_api->set_last_insert_rowid
|
600
|
+
/* Version 3.20.0 and later */
|
601
|
+
#define sqlite3_prepare_v3 sqlite3_api->prepare_v3
|
602
|
+
#define sqlite3_prepare16_v3 sqlite3_api->prepare16_v3
|
603
|
+
#define sqlite3_bind_pointer sqlite3_api->bind_pointer
|
604
|
+
#define sqlite3_result_pointer sqlite3_api->result_pointer
|
605
|
+
#define sqlite3_value_pointer sqlite3_api->value_pointer
|
606
|
+
/* Version 3.22.0 and later */
|
607
|
+
#define sqlite3_vtab_nochange sqlite3_api->vtab_nochange
|
608
|
+
#define sqlite3_value_nochange sqlite3_api->value_nochange
|
609
|
+
#define sqlite3_vtab_collation sqlite3_api->vtab_collation
|
610
|
+
/* Version 3.24.0 and later */
|
611
|
+
#define sqlite3_keyword_count sqlite3_api->keyword_count
|
612
|
+
#define sqlite3_keyword_name sqlite3_api->keyword_name
|
613
|
+
#define sqlite3_keyword_check sqlite3_api->keyword_check
|
614
|
+
#define sqlite3_str_new sqlite3_api->str_new
|
615
|
+
#define sqlite3_str_finish sqlite3_api->str_finish
|
616
|
+
#define sqlite3_str_appendf sqlite3_api->str_appendf
|
617
|
+
#define sqlite3_str_vappendf sqlite3_api->str_vappendf
|
618
|
+
#define sqlite3_str_append sqlite3_api->str_append
|
619
|
+
#define sqlite3_str_appendall sqlite3_api->str_appendall
|
620
|
+
#define sqlite3_str_appendchar sqlite3_api->str_appendchar
|
621
|
+
#define sqlite3_str_reset sqlite3_api->str_reset
|
622
|
+
#define sqlite3_str_errcode sqlite3_api->str_errcode
|
623
|
+
#define sqlite3_str_length sqlite3_api->str_length
|
624
|
+
#define sqlite3_str_value sqlite3_api->str_value
|
625
|
+
/* Version 3.25.0 and later */
|
626
|
+
#define sqlite3_create_window_function sqlite3_api->create_window_function
|
627
|
+
/* Version 3.26.0 and later */
|
628
|
+
#define sqlite3_normalized_sql sqlite3_api->normalized_sql
|
629
|
+
/* Version 3.28.0 and later */
|
630
|
+
#define sqlite3_stmt_isexplain sqlite3_api->stmt_isexplain
|
631
|
+
#define sqlite3_value_frombind sqlite3_api->value_frombind
|
632
|
+
/* Version 3.30.0 and later */
|
633
|
+
#define sqlite3_drop_modules sqlite3_api->drop_modules
|
634
|
+
/* Version 3.31.0 and later */
|
635
|
+
#define sqlite3_hard_heap_limit64 sqlite3_api->hard_heap_limit64
|
636
|
+
#define sqlite3_uri_key sqlite3_api->uri_key
|
637
|
+
#define sqlite3_filename_database sqlite3_api->filename_database
|
638
|
+
#define sqlite3_filename_journal sqlite3_api->filename_journal
|
639
|
+
#define sqlite3_filename_wal sqlite3_api->filename_wal
|
640
|
+
/* Version 3.32.0 and later */
|
641
|
+
#define sqlite3_create_filename sqlite3_api->create_filename
|
642
|
+
#define sqlite3_free_filename sqlite3_api->free_filename
|
643
|
+
#define sqlite3_database_file_object sqlite3_api->database_file_object
|
644
|
+
/* Version 3.34.0 and later */
|
645
|
+
#define sqlite3_txn_state sqlite3_api->txn_state
|
646
|
+
#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
|
511
647
|
|
512
|
-
#
|
648
|
+
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
|
513
649
|
/* This case when the file really is being compiled as a loadable
|
514
650
|
** extension */
|
515
651
|
# define SQLITE_EXTENSION_INIT1 const sqlite3_api_routines *sqlite3_api=0;
|
@@ -524,4 +660,4 @@ struct sqlite3_api_routines {
|
|
524
660
|
# define SQLITE_EXTENSION_INIT3 /*no-op*/
|
525
661
|
#endif
|
526
662
|
|
527
|
-
#endif /*
|
663
|
+
#endif /* SQLITE3EXT_H */
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/lib/amalgalite/aggregate.rb
CHANGED
@@ -13,6 +13,7 @@ module Amalgalite
|
|
13
13
|
# implementation you must:
|
14
14
|
#
|
15
15
|
# * implement _initalize_ with 0 arguments
|
16
|
+
# * call super() in your _initialize_ method
|
16
17
|
# * set the @arity data member
|
17
18
|
# * set the @name data member
|
18
19
|
# * implement _step_ with arity of +@arity+
|
@@ -25,6 +26,7 @@ module Amalgalite
|
|
25
26
|
# attr_accessor :words
|
26
27
|
#
|
27
28
|
# def initialize
|
29
|
+
# super
|
28
30
|
# @name = 'unique_word_count'
|
29
31
|
# @arity = 1
|
30
32
|
# @words = Hash.new { |h,k| h[k] = 0 }
|
@@ -50,6 +52,10 @@ module Amalgalite
|
|
50
52
|
# The arity of the SQL function
|
51
53
|
attr_accessor :arity
|
52
54
|
|
55
|
+
def initialize
|
56
|
+
@_exception = nil
|
57
|
+
end
|
58
|
+
|
53
59
|
# finalize should return the final value of the aggregate function
|
54
60
|
def finalize
|
55
61
|
raise NotImplementedError, "Aggregate#finalize must be implemented"
|
data/lib/amalgalite/database.rb
CHANGED
@@ -339,7 +339,6 @@ module Amalgalite
|
|
339
339
|
#
|
340
340
|
def clear_taps!
|
341
341
|
self.trace_tap = nil
|
342
|
-
self.profile_tap = nil
|
343
342
|
end
|
344
343
|
|
345
344
|
##
|
@@ -393,20 +392,19 @@ module Amalgalite
|
|
393
392
|
#
|
394
393
|
# db.trace_tap = nil
|
395
394
|
#
|
396
|
-
# This will
|
395
|
+
# This will unregister the trace tap
|
397
396
|
#
|
398
397
|
#
|
399
398
|
def trace_tap=( tap_obj )
|
400
399
|
|
401
400
|
# unregister any previous trace tap
|
402
401
|
#
|
403
|
-
|
402
|
+
if !@trace_tap.nil? then
|
404
403
|
@trace_tap.trace( 'unregistered as trace tap' )
|
405
404
|
@trace_tap = nil
|
406
405
|
end
|
407
406
|
return @trace_tap if tap_obj.nil?
|
408
407
|
|
409
|
-
|
410
408
|
# wrap the tap if we need to
|
411
409
|
#
|
412
410
|
if tap_obj.respond_to?( 'trace' ) then
|
@@ -424,55 +422,6 @@ module Amalgalite
|
|
424
422
|
@trace_tap.trace( 'registered as trace tap' )
|
425
423
|
end
|
426
424
|
|
427
|
-
|
428
|
-
##
|
429
|
-
# call-seq:
|
430
|
-
# db.profile_tap = obj
|
431
|
-
#
|
432
|
-
# Register a profile tap.
|
433
|
-
#
|
434
|
-
# Registering a profile tap means that the +obj+ registered will have its
|
435
|
-
# +profile+ method called with an Integer and a String parameter every time
|
436
|
-
# a profile event happens. The Integer is the number of nanoseconds it took
|
437
|
-
# for the String (SQL) to execute in wall-clock time.
|
438
|
-
#
|
439
|
-
# That is, every time a profile event happens in SQLite the following is
|
440
|
-
# invoked:
|
441
|
-
#
|
442
|
-
# obj.profile( str, int )
|
443
|
-
#
|
444
|
-
# For instance:
|
445
|
-
#
|
446
|
-
# db.profile_tap = Amalgalite::ProfileTap.new( logger, 'debug' )
|
447
|
-
#
|
448
|
-
# This will register an instance of ProfileTap, which wraps an logger object.
|
449
|
-
# On each +profile+ event the ProfileTap#profile method will be called
|
450
|
-
# which in turn will call <tt>logger.debug<tt> with a formatted string containing
|
451
|
-
# the String and Integer from the profile event.
|
452
|
-
#
|
453
|
-
# db.profile_tap = nil
|
454
|
-
#
|
455
|
-
# This will unregister the profile tap
|
456
|
-
#
|
457
|
-
#
|
458
|
-
def profile_tap=( tap_obj )
|
459
|
-
|
460
|
-
# unregister any previous profile tap
|
461
|
-
unless @profile_tap.nil?
|
462
|
-
@profile_tap.profile( 'unregistered as profile tap', 0.0 )
|
463
|
-
@profile_tap = nil
|
464
|
-
end
|
465
|
-
return @profile_tap if tap_obj.nil?
|
466
|
-
|
467
|
-
if tap_obj.respond_to?( 'profile' ) then
|
468
|
-
@profile_tap = tap_obj
|
469
|
-
else
|
470
|
-
raise Amalgalite::Error, "#{tap_obj.class.name} cannot be used to tap. It has no 'profile' method"
|
471
|
-
end
|
472
|
-
@api.register_profile_tap( @profile_tap )
|
473
|
-
@profile_tap.profile( 'registered as profile tap', 0.0 )
|
474
|
-
end
|
475
|
-
|
476
425
|
##
|
477
426
|
# call-seq:
|
478
427
|
# db.type_map = DefaultMap.new
|
@@ -120,8 +120,8 @@ module Amalgalite
|
|
120
120
|
# time information.
|
121
121
|
#
|
122
122
|
def profile( msg, time )
|
123
|
-
|
124
|
-
|
123
|
+
msg = msg.gsub(/\s+/,' ')
|
124
|
+
unless sampler = @samplers[msg]
|
125
125
|
sampler = @samplers[msg] = ProfileSampler.new( msg )
|
126
126
|
end
|
127
127
|
sampler.sample( time )
|
data/lib/amalgalite/statement.rb
CHANGED
@@ -347,7 +347,7 @@ module Amalgalite
|
|
347
347
|
# only check for rowid if we have a table name and it is not one of the
|
348
348
|
# sqlite_master tables. We could get recursion in those cases.
|
349
349
|
if not using_rowid_column? and tbl_name and
|
350
|
-
not %w[ sqlite_master sqlite_temp_master].include?( tbl_name ) and is_column_rowid?( tbl_name, col_name ) then
|
350
|
+
not %w[ sqlite_master sqlite_temp_master ].include?( tbl_name ) and is_column_rowid?( tbl_name, col_name ) then
|
351
351
|
@rowid_index = idx
|
352
352
|
end
|
353
353
|
|
@@ -363,7 +363,10 @@ module Amalgalite
|
|
363
363
|
# is the column indicated by the Column a 'rowid' column
|
364
364
|
#
|
365
365
|
def is_column_rowid?( table_name, column_name )
|
366
|
-
|
366
|
+
table_schema = @db.schema.tables[table_name]
|
367
|
+
return false unless table_schema
|
368
|
+
|
369
|
+
column_schema = table_schema.columns[column_name]
|
367
370
|
if column_schema then
|
368
371
|
if column_schema.primary_key? and column_schema.declared_data_type and column_schema.declared_data_type.upcase == "INTEGER" then
|
369
372
|
return true
|
data/lib/amalgalite/taps/io.rb
CHANGED
@@ -9,7 +9,7 @@ require 'stringio'
|
|
9
9
|
module Amalgalite
|
10
10
|
module Taps
|
11
11
|
#
|
12
|
-
# An IOTap is an easy way to send all top information to
|
12
|
+
# An IOTap is an easy way to send all top information to any IO based
|
13
13
|
# object. Both profile and trace tap information can be captured
|
14
14
|
# This means you can send the events to STDOUT with:
|
15
15
|
#
|
@@ -20,14 +20,17 @@ module Amalgalite
|
|
20
20
|
|
21
21
|
attr_reader :profile_tap
|
22
22
|
attr_reader :io
|
23
|
+
attr_reader :trace_count
|
23
24
|
|
24
25
|
def initialize( io )
|
25
26
|
@io = io
|
26
27
|
@profile_tap = ProfileTap.new( self, 'output_profile_event' )
|
28
|
+
@trace_count = 0
|
27
29
|
end
|
28
30
|
|
29
31
|
def trace( msg )
|
30
|
-
|
32
|
+
@trace_count += 1
|
33
|
+
io.puts msg
|
31
34
|
end
|
32
35
|
|
33
36
|
# need a profile method, it routes through the profile tap which calls back
|
data/lib/amalgalite/trace_tap.rb
CHANGED
@@ -19,7 +19,7 @@ module Amalgalite
|
|
19
19
|
attr_reader :delegate_method
|
20
20
|
|
21
21
|
def initialize( wrapped_obj, send_to = 'trace' )
|
22
|
-
unless wrapped_obj.respond_to?( send_to )
|
22
|
+
unless wrapped_obj.respond_to?( send_to )
|
23
23
|
raise Amalgalite::Error, "#{wrapped_obj.class.name} does not respond to #{send_to.to_s} "
|
24
24
|
end
|
25
25
|
|
@@ -23,7 +23,7 @@ module Amalgalite::TypeMaps
|
|
23
23
|
'time' => %w[ timestamp time ],
|
24
24
|
'float' => %w[ double float real numeric decimal ],
|
25
25
|
'integer' => %w[ integer tinyint smallint int int2 int4 int8 bigint serial bigserial ],
|
26
|
-
'string' => %w[ text char string varchar character ],
|
26
|
+
'string' => %w[ text char string varchar character json ],
|
27
27
|
'boolean' => %w[ bool boolean ],
|
28
28
|
'blob' => %w[ binary blob ],
|
29
29
|
}
|
@@ -65,7 +65,7 @@ module Amalgalite::TypeMaps
|
|
65
65
|
case obj
|
66
66
|
when Float
|
67
67
|
::Amalgalite::SQLite3::Constants::DataType::FLOAT
|
68
|
-
when
|
68
|
+
when Integer
|
69
69
|
::Amalgalite::SQLite3::Constants::DataType::INTEGER
|
70
70
|
when NilClass
|
71
71
|
::Amalgalite::SQLite3::Constants::DataType::NULL
|