-
Notifications
You must be signed in to change notification settings - Fork 2
/
duckdb.f90
3707 lines (3268 loc) · 134 KB
/
duckdb.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
module duckdb
use, intrinsic :: iso_fortran_env
use, intrinsic :: iso_c_binding
! use util
! use constants
implicit none
private
public :: duckdb_database
public :: duckdb_connection
public :: duckdb_prepared_statement
public :: duckdb_extracted_statements
public :: duckdb_pending_result
public :: duckdb_appender
public :: duckdb_arrow
public :: duckdb_arrow_schema
public :: duckdb_config
public :: duckdb_arrow_array
public :: duckdb_logical_type
public :: duckdb_data_chunk
public :: duckdb_vector
public :: duckdb_value
public :: duckdb_date
public :: duckdb_date_struct
public :: duckdb_time
public :: duckdb_time_struct
public :: duckdb_timestamp
public :: duckdb_timestamp_struct
public :: duckdb_interval
public :: duckdb_hugeint
public :: duckdb_decimal
public :: duckdb_string
public :: duckdb_blob
public :: duckdb_list_entry
public :: duckdb_column
public :: duckdb_result
public :: duckdb_type
public :: duckdb_type_invalid
public :: duckdb_type_boolean
public :: duckdb_type_tinyint
public :: duckdb_type_smallint
public :: duckdb_type_integer
public :: duckdb_type_bigint
public :: duckdb_type_utinyint
public :: duckdb_type_usmallint
public :: duckdb_type_uinteger
public :: duckdb_type_ubigint
public :: duckdb_type_float
public :: duckdb_type_double
public :: duckdb_type_timestamp
public :: duckdb_type_date
public :: duckdb_type_time
public :: duckdb_type_interval
public :: duckdb_type_hugeint
public :: duckdb_type_varchar
public :: duckdb_type_blob
public :: duckdb_type_decimal
public :: duckdb_type_timestamp_s
public :: duckdb_type_timestamp_ms
public :: duckdb_type_timestamp_ns
public :: duckdb_type_enum
public :: duckdb_type_list
public :: duckdb_type_struct
public :: duckdb_type_map
public :: duckdb_type_uuid
public :: duckdb_type_union
public :: duckdb_type_bit
public :: duckdb_pending_state
public :: duckdb_pending_result_ready
public :: duckdb_pending_result_not_ready
public :: duckdb_pending_error_state
public :: duckdb_state
public :: duckdbsuccess
public :: duckdberror
public :: duckdb_open
public :: duckdb_open_ext
public :: duckdb_close
public :: duckdb_connect
public :: duckdb_disconnect
public :: duckdb_create_config
public :: duckdb_config_count
public :: duckdb_get_config_flag
public :: duckdb_set_config
public :: duckdb_destroy_config
public :: duckdb_query
public :: duckdb_destroy_result
public :: duckdb_column_count
public :: duckdb_row_count
public :: duckdb_rows_changed
public :: duckdb_column_data
public :: duckdb_nullmask_data
public :: duckdb_library_version
public :: duckdb_column_name
public :: duckdb_column_type
public :: duckdb_result_error
public :: duckdb_result_get_chunk
public :: duckdb_result_chunk_count
public :: duckdb_value_boolean
public :: duckdb_value_int8
public :: duckdb_value_int16
public :: duckdb_value_int32
public :: duckdb_value_int64
public :: duckdb_value_hugeint
public :: duckdb_value_decimal
public :: duckdb_value_float
public :: duckdb_value_double
public :: duckdb_value_date
public :: duckdb_value_time
public :: duckdb_value_timestamp
public :: duckdb_value_interval
public :: duckdb_value_varchar
public :: duckdb_value_string
public :: duckdb_value_varchar_internal
public :: duckdb_value_string_internal
public :: duckdb_value_blob
public :: duckdb_value_is_null
public :: duckdb_malloc
public :: duckdb_free
public :: duckdb_vector_size
public :: duckdb_from_date
public :: duckdb_to_date
public :: duckdb_from_time
public :: duckdb_to_time
public :: duckdb_from_timestamp
public :: duckdb_to_timestamp
public :: duckdb_hugeint_to_double
public :: duckdb_double_to_hugeint
public :: duckdb_decimal_to_double
public :: duckdb_double_to_decimal
public :: duckdb_string_to_character
public :: duckdb_prepare
public :: duckdb_destroy_prepare
public :: duckdb_prepare_error
public :: duckdb_nparams
public :: duckdb_param_type
public :: duckdb_clear_bindings
public :: duckdb_bind_boolean
public :: duckdb_bind_int8
public :: duckdb_bind_int16
public :: duckdb_bind_int32
public :: duckdb_bind_int64
public :: duckdb_bind_hugeint
public :: duckdb_bind_decimal
! no uints in fortran - use ints instead
! public :: duckdb_bind_uint8
! public :: duckdb_bind_uint16
! public :: duckdb_bind_uint32
! public :: duckdb_bind_uint64
public :: duckdb_bind_float
public :: duckdb_bind_double
public :: duckdb_bind_date
public :: duckdb_bind_time
public :: duckdb_bind_timestamp
public :: duckdb_bind_interval
public :: duckdb_bind_varchar
public :: duckdb_bind_varchar_length
! TODO: helper function to wrap duckdb_bind_varchar_length
! public :: duckdb_bind_string
public :: duckdb_bind_blob ! the way it should work
public :: duckdb_bind_null
public :: duckdb_execute_prepared
! public :: duckdb_execute_prepared_arrow
public :: duckdb_extract_statements
public :: duckdb_prepare_extracted_statement
public :: duckdb_extract_statements_error
public :: duckdb_destroy_extracted
public :: duckdb_pending_prepared
public :: duckdb_destroy_pending
public :: duckdb_pending_error
public :: duckdb_pending_execute_task
public :: duckdb_execute_pending
public :: duckdb_data_chunk_get_size
public :: duckdb_data_chunk_get_vector
public :: duckdb_data_chunk_get_column_count
public :: duckdb_data_chunk_reset
public :: duckdb_data_chunk_set_size
public :: duckdb_destroy_data_chunk
public :: duckdb_vector_get_column_type
public :: duckdb_vector_get_data
public :: duckdb_vector_get_validity
public :: duckdb_vector_ensure_validity_writable
! public :: duckdb_vector_assign_string_element
! public :: duckdb_vector_assign_string_element_len
public :: duckdb_list_vector_get_child
public :: duckdb_list_vector_get_size
public :: duckdb_list_vector_set_size
public :: duckdb_list_vector_reserve
public :: duckdb_struct_vector_get_child
public :: duckdb_validity_row_is_valid
public :: duckdb_validity_set_row_validity
public :: duckdb_validity_set_row_invalid
public :: duckdb_validity_set_row_valid
public :: duckdb_create_logical_type
public :: duckdb_create_list_type
public :: duckdb_create_map_type
public :: duckdb_get_type_id
public :: duckdb_decimal_width
public :: duckdb_decimal_scale
public :: duckdb_decimal_internal_type
public :: duckdb_enum_internal_type
public :: duckdb_enum_dictionary_size
public :: duckdb_enum_dictionary_value
public :: duckdb_list_type_child_type
public :: duckdb_map_type_key_type
public :: duckdb_map_type_value_type
public :: duckdb_struct_type_child_count
public :: duckdb_struct_type_child_name
public :: duckdb_struct_type_child_type
public :: duckdb_destroy_logical_type
public :: duckdb_create_data_chunk
public :: duckdb_appender_create
public :: duckdb_appender_error
public :: duckdb_appender_flush
public :: duckdb_appender_close
public :: duckdb_appender_destroy
public :: duckdb_appender_begin_row
public :: duckdb_appender_end_row
public :: duckdb_append_bool
public :: duckdb_append_int8
public :: duckdb_append_int16
public :: duckdb_append_int32
public :: duckdb_append_int64
public :: duckdb_append_hugeint
public :: duckdb_append_float
public :: duckdb_append_double
public :: duckdb_append_date
public :: duckdb_append_time
public :: duckdb_append_timestamp
public :: duckdb_append_interval
public :: duckdb_append_varchar
public :: duckdb_append_varchar_length
public :: duckdb_append_blob
public :: duckdb_append_null
public :: duckdb_append_data_chunk
public :: duckdb_query_arrow
public :: duckdb_query_arrow_schema
public :: duckdb_query_arrow_array
public :: duckdb_query_arrow_error
public :: duckdb_destroy_arrow
public :: STANDARD_VECTOR_SIZE
enum, bind(c)
enumerator :: duckdb_state = 0
enumerator :: duckdbsuccess = 0
enumerator :: duckdberror = 1
end enum
enum, bind(c)
enumerator :: duckdb_type = 0
enumerator :: duckdb_type_invalid = 0
! bool
enumerator :: duckdb_type_boolean = 1
! int8_t
enumerator :: duckdb_type_tinyint = 2
! int16_t
enumerator :: duckdb_type_smallint = 3
! int32_t
enumerator :: duckdb_type_integer = 4
! int64_t
enumerator :: duckdb_type_bigint = 5
! uint8_t
enumerator :: duckdb_type_utinyint = 6
! uint16_t
enumerator :: duckdb_type_usmallint = 7
! uint32_t
enumerator :: duckdb_type_uinteger = 8
! uint64_t
enumerator :: duckdb_type_ubigint = 9
! float
enumerator :: duckdb_type_float = 10
! double
enumerator :: duckdb_type_double = 11
! duckdb_timestamp, in microseconds
enumerator :: duckdb_type_timestamp = 12
! duckdb_date
enumerator :: duckdb_type_date = 13
! duckdb_time
enumerator :: duckdb_type_time = 14
! duckdb_interval
enumerator :: duckdb_type_interval = 15
! duckdb_hugeint
enumerator :: duckdb_type_hugeint = 16
! const char*
enumerator :: duckdb_type_varchar = 17
! duckdb_blob
enumerator :: duckdb_type_blob = 18
! decimal
enumerator :: duckdb_type_decimal = 19
! duckdb_timestamp, in seconds
enumerator :: duckdb_type_timestamp_s = 20
! duckdb_timestamp, in milliseconds
enumerator :: duckdb_type_timestamp_ms = 21
! duckdb_timestamp, in nanoseconds
enumerator :: duckdb_type_timestamp_ns = 22
! enum type, only useful as logical type
enumerator :: duckdb_type_enum = 23
! list type, only useful as logical type
enumerator :: duckdb_type_list = 24
! struct type, only useful as logical type
enumerator :: duckdb_type_struct = 25
! map type, only useful as logical type
enumerator :: duckdb_type_map = 26
! duckdb_hugeint
enumerator :: duckdb_type_uuid = 27
! union type, only useful as logical type
enumerator :: duckdb_type_union = 28
! duckdb_bit
enumerator :: duckdb_type_bit = 29
end enum
enum, bind(c)
enumerator :: duckdb_pending_state = 0
enumerator :: duckdb_pending_result_ready = 0
enumerator :: duckdb_pending_result_not_ready = 1
enumerator :: duckdb_pending_error_state = 2
end enum
type, bind(c) :: duckdb_database
type(c_ptr) :: db = c_null_ptr
end type
type, bind(c) :: duckdb_connection
type(c_ptr) :: conn = c_null_ptr
end type
type, bind(c) :: duckdb_prepared_statement
type(c_ptr) :: prep = c_null_ptr
end type
type, bind(c) :: duckdb_extracted_statements
type(c_ptr) :: extrac = c_null_ptr
end type
type, bind(c) :: duckdb_pending_result
type(c_ptr) :: pend = c_null_ptr
end type
type, bind(c) :: duckdb_appender
type(c_ptr) :: appn = c_null_ptr
end type
type, bind(c) :: duckdb_arrow
type(c_ptr) :: arrw = c_null_ptr
end type
type, bind(c) :: duckdb_config
type(c_ptr) :: cnfg = c_null_ptr
end type
type, bind(c) :: duckdb_arrow_schema
type(c_ptr) :: arrs = c_null_ptr
end type
type, bind(c) :: duckdb_arrow_array
type(c_ptr) :: arra = c_null_ptr
end type
type, bind(c) :: duckdb_logical_type
type(c_ptr) :: lglt = c_null_ptr
end type
type, bind(c) :: duckdb_data_chunk
type(c_ptr) :: dtck = c_null_ptr
end type
type, bind(c) :: duckdb_vector
type(c_ptr) :: vctr = c_null_ptr
end type
type, bind(c) :: duckdb_value
type(c_ptr) :: val = c_null_ptr
end type
type, bind(c) :: duckdb_date
integer(kind=c_int32_t) :: days
end type
type, bind(c) :: duckdb_date_struct
integer(kind=c_int32_t) :: year
integer(kind=c_int8_t) :: month
integer(kind=c_int8_t) :: day
end type
type, bind(c) :: duckdb_time
integer(kind=c_int64_t) :: micros
end type
type, bind(c) :: duckdb_time_struct
integer(kind=c_int8_t) :: hour
integer(kind=c_int8_t) :: min
integer(kind=c_int8_t) :: sec
integer(kind=c_int32_t) :: micros
end type
type, bind(c) :: duckdb_timestamp
integer(kind=c_int64_t) :: micros
end type
type, bind(c) :: duckdb_timestamp_struct
type(duckdb_date_struct) :: date
type(duckdb_time_struct) :: time
end type
type, bind(c) :: duckdb_interval
integer(kind=c_int32_t) :: months
integer(kind=c_int32_t) :: days
integer(kind=c_int64_t) :: micros
end type
type, bind(c) :: duckdb_hugeint
integer(kind=c_int64_t) :: lower = 0
integer(kind=c_int64_t) :: upper = 0
end type
type, bind(c) :: duckdb_decimal
integer(kind=c_int8_t) :: width = 0
integer(kind=c_int8_t) :: scale = 0
type(duckdb_hugeint) :: value = duckdb_hugeint()
end type
type, bind(c) :: duckdb_string
type(c_ptr) :: data = c_null_ptr
integer(kind=c_int64_t) :: size = 0
end type
type, bind(c) :: duckdb_blob
type(c_ptr) :: data = c_null_ptr
integer(kind=c_int64_t) :: size = 0
end type
type, bind(c) :: duckdb_list_entry
integer(kind=c_int64_t) :: offset = 0
integer(kind=c_int64_t) :: length = 0
end type
type, bind(c) :: duckdb_column
type(c_ptr) :: deprecated_data = c_null_ptr
type(c_ptr) :: deprecated_nullmask = c_null_ptr
integer(kind(duckdb_type)) :: deprecated_type = duckdb_type_invalid
type(c_ptr) :: deprecated_name = c_null_ptr
type(c_ptr) :: internal_data = c_null_ptr
end type
type, bind(c) :: duckdb_result
integer(kind=c_int64_t) :: deprecated_column_count = 0
integer(kind=c_int64_t) :: deprecated_row_count = 0
integer(kind=c_int64_t) :: deprecated_rows_changed = 0
type(c_ptr) :: deprecated_columns = c_null_ptr
type(c_ptr) :: deprecated_error_message = c_null_ptr
type(c_ptr) :: internal_data = c_null_ptr
end type
! from vector_size.hpp
integer, parameter :: STANDARD_VECTOR_SIZE = 2048
interface !******************************************************************
function c_strlen(str) bind(c, name='strlen')
import :: c_ptr, c_size_t
type(c_ptr), value :: str
integer(c_size_t) :: c_strlen
end function c_strlen
! =========================================================================
! Open/Connect
! =========================================================================
! DUCKDB_API
! duckdb_state
! duckdb_open(const char *path, duckdb_database *db);
function duckdb_open_char(path, db) &
& bind(c, name='duckdb_open') result(res)
import :: duckdb_state, c_char, duckdb_database
integer(kind(duckdb_state)) :: res
character(kind=c_char) :: path
type(duckdb_database) :: db
end function duckdb_open_char
function duckdb_open_ptr(path, db) &
& bind(c, name='duckdb_open') result(res)
import :: duckdb_state, c_char, c_ptr, duckdb_database
integer(kind(duckdb_state)) :: res
type(c_ptr) :: path
type(duckdb_database) :: db
end function duckdb_open_ptr
! DUCKDB_API
! duckdb_state
! duckdb_open_ext(const char *path, duckdb_database *db,
! duckdb_config config,char **out_error);
function duckdb_open_ext_(path, db, config, out_error) &
& bind(c, name='duckdb_open_ext') result(res)
import :: duckdb_state, c_char, duckdb_database, duckdb_config, c_ptr
integer(kind(duckdb_state)) :: res
character(kind=c_char) :: path
type(duckdb_database) :: db
type(duckdb_config), value :: config
type(c_ptr) :: out_error
end function duckdb_open_ext_
! DUCKDB_API
! void
! duckdb_close(duckdb_database *database);
subroutine duckdb_close(database) bind(c, name='duckdb_close')
import :: duckdb_database
type(duckdb_database) :: database
end subroutine duckdb_close
! DUCKDB_API
! duckdb_state
! duckdb_connect(duckdb_database database,
! duckdb_connection *out_connection);
function duckdb_connect(database, out_connection) &
& bind(c, name='duckdb_connect') result(res)
import :: duckdb_state, duckdb_database, duckdb_connection
integer(kind(duckdb_state)) :: res
type(duckdb_database), value :: database
type(duckdb_connection) :: out_connection
end function duckdb_connect
! DUCKDB_API
! void
! duckdb_disconnect(duckdb_connection *connection);
subroutine duckdb_disconnect(connection) &
& bind(c, name='duckdb_disconnect')
import :: duckdb_connection
type(duckdb_connection) :: connection
end subroutine duckdb_disconnect
! DUCKDB_API
! const char
! *duckdb_library_version();
function duckdb_library_version_() &
& bind(c, name='duckdb_library_version') result(res)
import :: c_ptr
type(c_ptr) :: res
end function duckdb_library_version_
! =========================================================================
! Configuration
! =========================================================================
! DUCKDB_API
! duckdb_state
! duckdb_create_config(duckdb_config *out_config);
function duckdb_create_config(out_config) &
& bind(c, name='duckdb_create_config') result(res)
import :: duckdb_state, duckdb_config
integer(kind(duckdb_state)) :: res
type(duckdb_config) :: out_config
end function duckdb_create_config
! DUCKDB_API
! size_t
! duckdb_config_count();
function duckdb_config_count_() &
& bind(c, name='duckdb_config_count') result(res)
import :: c_size_t
integer(kind=c_size_t) :: res
end function duckdb_config_count_
! DUCKDB_API
! duckdb_state
! duckdb_get_config_flag(size_t index, const char **out_name,
! const char **out_description);
function duckdb_get_config_flag_(idx, out_name, out_description) &
& bind(c, name='duckdb_get_config_flag') result(res)
import :: duckdb_state, c_size_t, c_ptr
integer(kind(duckdb_state)) :: res
integer(kind=c_size_t), value :: idx
type(c_ptr) :: out_name
type(c_ptr) :: out_description
end function duckdb_get_config_flag_
! DUCKDB_API
! duckdb_state
! duckdb_set_config(duckdb_config config, const char *name,
! const char *option);
function duckdb_set_config_(config, name, option) &
& bind(c, name='duckdb_set_config') result(res)
import :: duckdb_state, duckdb_config, c_char
integer(kind(duckdb_state)) :: res
type(duckdb_config), value :: config
character(c_char) :: name
character(c_char) :: option
end function duckdb_set_config_
! DUCKDB_API
! void
! duckdb_destroy_config(duckdb_config *config);
subroutine duckdb_destroy_config(config) &
& bind(c, name='duckdb_destroy_config')
import :: duckdb_config
type(duckdb_config) :: config
end subroutine duckdb_destroy_config
! =========================================================================
! Query Execution
! =========================================================================
! DUCKDB_API
! duckdb_state
! duckdb_query(duckdb_connection connection, const char *query,
! duckdb_result *out_result);
function duckdb_query_(connection, query, out_result) &
& bind(c, name='duckdb_query') result(res)
import :: duckdb_state, duckdb_connection, duckdb_result, c_char
integer(kind(duckdb_state)) :: res
type(duckdb_connection), value :: connection
character(kind=c_char) :: query ! must be a c string
type(duckdb_result) :: out_result
end function duckdb_query_
! DUCKDB_API
! void
! duckdb_destroy_result(duckdb_result *result);
subroutine duckdb_destroy_result(res) &
& bind(c, name='duckdb_destroy_result')
import :: duckdb_result
type(duckdb_result) :: res
end subroutine duckdb_destroy_result
! DUCKDB_API
! const char
! *duckdb_column_name(duckdb_result *result, idx_t col);
function duckdb_column_name_(res, col) &
& bind(c, name='duckdb_column_name') result(name)
import :: c_ptr, duckdb_result, c_int64_t
type(c_ptr) :: name
type(duckdb_result) :: res
integer(kind=c_int64_t), value :: col
end function duckdb_column_name_
! DUCKDB_API
! duckdb_type
! duckdb_column_type(duckdb_result *result, idx_t col);
function duckdb_column_type_(res, col) &
& bind(c, name='duckdb_column_type') result(col_type)
import :: duckdb_result, duckdb_type, c_int64_t
integer(kind(duckdb_type)) :: col_type
type(duckdb_result) :: res
integer(kind=c_int64_t), value :: col
end function duckdb_column_type_
! DUCKDB_API
! duckdb_logical_type
! duckdb_column_logical_type(duckdb_result *result, idx_t col);
function duckdb_column_logical_type_(res, idx) &
& bind(c, name='duckdb_column_logical_type') result(t)
import :: duckdb_result, duckdb_logical_type, c_int64_t
type(duckdb_result) :: res
integer(kind=c_int64_t), value :: idx
type(duckdb_logical_type) :: t
end function duckdb_column_logical_type_
! DUCKDB_API
! idx_t
! duckdb_column_count(duckdb_result *result);
function duckdb_column_count_(res) &
& bind(c, name='duckdb_column_count') result(cc)
import :: duckdb_result, c_int64_t
type(duckdb_result) :: res
integer(kind=c_int64_t) :: cc
end function duckdb_column_count_
! DUCKDB_API
! idx_t
! duckdb_row_count(duckdb_result *result);
function duckdb_row_count_(res) &
& bind(c, name='duckdb_row_count') result(rc)
import :: duckdb_result, c_int64_t
type(duckdb_result) :: res
integer(kind=c_int64_t) :: rc
end function duckdb_row_count_
! DUCKDB_API
! idx_t
! duckdb_rows_changed(duckdb_result *result);
function duckdb_rows_changed_(res) &
& bind(c, name='duckdb_rows_changed') result(rc)
import :: duckdb_result, c_int64_t
type(duckdb_result) :: res
integer(kind=c_int64_t) :: rc
end function duckdb_rows_changed_
! DUCKDB_API
! void
! *duckdb_column_data(duckdb_result *result, idx_t col);
function duckdb_column_data_(res, col) &
& bind(c, name='duckdb_column_data') result(data)
import :: duckdb_result, c_int64_t, c_ptr
type(c_ptr) :: data
type(duckdb_result) :: res
integer(kind=c_int64_t), value :: col
end function duckdb_column_data_
! DUCKDB_API
! bool
! *duckdb_nullmask_data(duckdb_result *result, idx_t col);
function duckdb_nullmask_data_(res, col) &
& bind(c, name='duckdb_nullmask_data') result(ptr)
import :: duckdb_result, c_int64_t, c_ptr
type(c_ptr) :: ptr
type(duckdb_result) :: res
integer(kind=c_int64_t), value :: col
end function duckdb_nullmask_data_
! DUCKDB_API
! const char
! *duckdb_result_error(duckdb_result *result);
function duckdb_result_error_(res) &
& bind(c, name='duckdb_result_error') result(err)
import :: c_ptr, duckdb_result
type(duckdb_result) :: res
type(c_ptr) :: err
end function duckdb_result_error_
! =========================================================================
! Result Functions
! =========================================================================
! DUCKDB_API
! duckdb_data_chunk
! duckdb_result_get_chunk(duckdb_result result, idx_t chunk_index);
function duckdb_result_get_chunk_(res, idx) &
& bind(c, name='duckdb_result_get_chunk') result(chunk)
import :: c_int64_t, duckdb_result, duckdb_data_chunk
type(duckdb_result), value :: res
integer(kind=c_int64_t), value :: idx
type(duckdb_data_chunk) :: chunk
end function duckdb_result_get_chunk_
! DUCKDB_API
! idx_t
! duckdb_result_chunk_count(duckdb_result result);
function duckdb_result_chunk_count_(res) &
& bind(c, name='duckdb_result_chunk_count') result(cc)
import :: c_int64_t, duckdb_result
type(duckdb_result), value :: res
integer(kind=c_int64_t) :: cc
end function duckdb_result_chunk_count_
! DUCKDB_API
! bool
! duckdb_value_boolean(duckdb_result *result, idx_t col, idx_t row);
function duckdb_value_boolean_(res, col, row) &
& bind(c, name='duckdb_value_boolean') result(r)
import :: duckdb_result, c_bool, c_int64_t
type(duckdb_result) :: res
integer(kind=c_int64_t), value :: col, row
logical(kind=c_bool) :: r
end function duckdb_value_boolean_
! DUCKDB_API
! int8_t
! duckdb_value_int8(duckdb_result *result, idx_t col, idx_t row);
function duckdb_value_int8_(res, col, row) &
& bind(c, name='duckdb_value_int8') result(r)
import :: duckdb_result, c_int8_t, c_int64_t
type(duckdb_result) :: res
integer(kind=c_int64_t), value :: col, row
integer(kind=c_int8_t) :: r
end function duckdb_value_int8_
! DUCKDB_API
! int16_t
! duckdb_value_int16(duckdb_result *result, idx_t col, idx_t row);
function duckdb_value_int16_(res, col, row) &
& bind(c, name='duckdb_value_int16') result(r)
import :: duckdb_result, c_int16_t, c_int64_t
type(duckdb_result) :: res
integer(kind=c_int64_t), value :: col, row
integer(kind=c_int16_t) :: r
end function duckdb_value_int16_
! DUCKDB_API
! int32_t
! duckdb_value_int32(duckdb_result *result, idx_t col, idx_t row);
function duckdb_value_int32_(res, col, row) &
& bind(c, name='duckdb_value_int32') result(r)
import :: duckdb_result, c_int32_t, c_int64_t
type(duckdb_result) :: res
integer(kind=c_int64_t), value :: col, row
integer(kind=c_int32_t) :: r
end function duckdb_value_int32_
! DUCKDB_API
! int64_t
! duckdb_value_int64(duckdb_result *result, idx_t col, idx_t row);
function duckdb_value_int64_(res, col, row) &
& bind(c, name='duckdb_value_int64') result(r)
import :: duckdb_result, c_int64_t
type(duckdb_result) :: res
integer(kind=c_int64_t), value :: col, row
integer(kind=c_int64_t) :: r
end function duckdb_value_int64_
! DUCKDB_API
! duckdb_hugeint
! duckdb_value_hugeint(duckdb_result *result, idx_t col, idx_t row);
function duckdb_value_hugeint_(res, col, row) &
& bind(c, name='duckdb_value_hugeint') result(r)
import :: duckdb_result, c_ptr, c_int64_t, duckdb_hugeint
type(duckdb_result) :: res
integer(kind=c_int64_t), value :: col, row
type(duckdb_hugeint) :: r
end function duckdb_value_hugeint_
! DUCKDB_API
! duckdb_decimal
! duckdb_value_decimal(duckdb_result *result, idx_t col, idx_t row);
function duckdb_value_decimal_(res, col, row) &
& bind(c, name='duckdb_value_decimal') result(r)
import :: duckdb_result, c_ptr, c_int64_t, duckdb_decimal
type(duckdb_result) :: res
integer(kind=c_int64_t), value :: col, row
type(duckdb_decimal) :: r
end function duckdb_value_decimal_
! NOTE: Fortran doesn't currently have an unsigned integer definition.
! Use the signed versions of these functions above.
! DUCKDB_API
! uint8_t
! duckdb_value_uint8(duckdb_result *result, idx_t col, idx_t row);
! DUCKDB_API
! uint16_t
! duckdb_value_uint16(duckdb_result *result, idx_t col, idx_t row);
! DUCKDB_API
! uint32_t
! duckdb_value_uint32(duckdb_result *result, idx_t col, idx_t row);
! DUCKDB_API
! uint64_t
! duckdb_value_uint64(duckdb_result *result, idx_t col, idx_t row);
! DUCKDB_API
! float
! duckdb_value_float(duckdb_result *result, idx_t col, idx_t row);
function duckdb_value_float_(res, col, row) &
& bind(c, name='duckdb_value_float') result(r)
import :: duckdb_result, c_float, c_int64_t
type(duckdb_result) :: res
integer(kind=c_int64_t), value :: col, row
real(kind=c_float) :: r
end function duckdb_value_float_
! DUCKDB_API
! double
! duckdb_value_double(duckdb_result *result, idx_t col, idx_t row);
function duckdb_value_double_(res, col, row) &
& bind(c, name='duckdb_value_double') result(r)
import :: duckdb_result, c_double, c_int64_t
type(duckdb_result) :: res
integer(kind=c_int64_t), value :: col, row
real(kind=c_double) :: r
end function duckdb_value_double_
! DUCKDB_API
! duckdb_date
! duckdb_value_date(duckdb_result *result, idx_t col, idx_t row);
function duckdb_value_date_(res, col, row) &
& bind(c, name='duckdb_value_date') result(r)
import :: duckdb_result, c_int64_t, duckdb_date
type(duckdb_result) :: res
integer(kind=c_int64_t), value :: col, row
type(duckdb_date) :: r
end function duckdb_value_date_
! DUCKDB_API
! duckdb_time
! duckdb_value_time(duckdb_result *result, idx_t col, idx_t row);
function duckdb_value_time_(res, col, row) &
& bind(c, name='duckdb_value_time') result(r)
import :: duckdb_result, c_int64_t, duckdb_time
type(duckdb_result) :: res
integer(kind=c_int64_t), value :: col, row
type(duckdb_time) :: r
end function duckdb_value_time_
! DUCKDB_API
! duckdb_timestamp
! duckdb_value_timestamp(duckdb_result *result, idx_t col, idx_t row);
function duckdb_value_timestamp_(res, col, row) &
& bind(c, name='duckdb_value_timestamp') result(r)
import :: duckdb_result, c_int64_t, duckdb_timestamp
type(duckdb_result) :: res
integer(kind=c_int64_t), value :: col, row
type(duckdb_timestamp) :: r
end function duckdb_value_timestamp_
! DUCKDB_API
! duckdb_interval
! duckdb_value_interval(duckdb_result *result, idx_t col, idx_t row);
function duckdb_value_interval_(res, col, row) &
& bind(c, name='duckdb_value_interval') result(r)
import :: duckdb_result, c_int64_t, duckdb_interval
type(duckdb_result) :: res
integer(kind=c_int64_t), value :: col, row
type(duckdb_interval) :: r
end function duckdb_value_interval_
! DUCKDB_API
! char
! *duckdb_value_varchar(duckdb_result *result, idx_t col, idx_t row);
function duckdb_value_varchar_(res, col, row) &
& bind(c, name='duckdb_value_varchar') result(ptr)
import :: duckdb_result, c_int64_t, c_ptr
type(duckdb_result) :: res
integer(kind=c_int64_t), value :: col, row
type(c_ptr) :: ptr
end function duckdb_value_varchar_
! DUCKDB_API
! duckdb_string
! duckdb_value_string(duckdb_result *result, idx_t col, idx_t row);
! NOTE: The result must be freed with `duckdb_free`.
function duckdb_value_string_(res, col, row) &
& bind(c, name='duckdb_value_string') result(r)
import :: duckdb_result, c_int64_t, duckdb_string
type(duckdb_result), intent(in) :: res
integer(kind=c_int64_t), value :: col, row
type(duckdb_string) :: r
end function duckdb_value_string_
! DUCKDB_API
! char
! *duckdb_value_varchar_internal(duckdb_result *result, idx_t col,
! idx_t row);
function duckdb_value_varchar_internal_(res, col, row) &
& bind(c, name='duckdb_value_varchar_internal') result(ptr)
import :: duckdb_result, c_int64_t, c_ptr
type(duckdb_result) :: res
integer(kind=c_int64_t), value :: col, row
type(c_ptr) :: ptr
end function duckdb_value_varchar_internal_
! DUCKDB_API
! duckdb_string
! duckdb_value_string_internal(duckdb_result *result, idx_t col, idx_t row);
function duckdb_value_string_internal_(res, col, row) &
& bind(c, name='duckdb_value_string_internal') result(str)
import :: duckdb_result, c_int64_t, duckdb_string
type(duckdb_result) :: res
integer(kind=c_int64_t), value :: col, row
type(duckdb_string) :: str
end function duckdb_value_string_internal_
! DUCKDB_API
! duckdb_blob
! duckdb_value_blob(duckdb_result *result, idx_t col, idx_t row);
function duckdb_value_blob_(res, col, row) &
& bind(c, name='duckdb_value_blob') result(r)
import :: duckdb_result, c_int64_t, duckdb_blob
type(duckdb_result) :: res
integer(kind=c_int64_t), value :: col, row
type(duckdb_blob) :: r
end function duckdb_value_blob_
! DUCKDB_API
! bool
! duckdb_value_is_null(duckdb_result *result, idx_t col, idx_t row);
function duckdb_value_is_null_(res, col, row) &
& bind(c, name='duckdb_value_is_null') result(r)
import :: duckdb_result, c_bool, c_int64_t
type(duckdb_result), intent(in) :: res
integer(kind=c_int64_t), value :: col, row
logical(kind=c_bool) :: r
end function duckdb_value_is_null_
! =========================================================================
! Helpers
! =========================================================================
! DUCKDB_API
! void
! *duckdb_malloc(size_t size);
function duckdb_malloc(siz) &
& bind(c, name='duckdb_malloc') result(res)
import :: c_ptr, c_size_t
integer(kind=c_size_t) :: siz
type(c_ptr) :: res
end function duckdb_malloc