├── .github └── workflows │ └── ci.yml ├── .gitignore ├── LICENSE-APACHE ├── LICENSE-MIT ├── benches ├── bun.mjs ├── deno.mjs ├── jit-bun.mjs └── jit-deno.mjs ├── build.sh ├── deno.json ├── deno.lock ├── lib.js ├── lib_test.ts ├── mod.ts ├── mod_test.ts ├── readme.md └── src ├── sql.c └── sql.h /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: [master] 6 | pull_request: 7 | 8 | jobs: 9 | build: 10 | name: Build ${{ matrix.os }} 11 | runs-on: ${{ matrix.os }} 12 | strategy: 13 | matrix: 14 | os: [macos-latest, ubuntu-latest] 15 | fail-fast: false 16 | steps: 17 | - uses: actions/checkout@v2 18 | - uses: denoland/setup-deno@v1 19 | with: 20 | deno-version: canary 21 | 22 | - name: typecheck & formatting 23 | shell: bash 24 | run: | 25 | set -xeuo pipefail 26 | deno cache --unstable mod.ts 27 | deno fmt --check 28 | 29 | - name: build (macOS) 30 | shell: bash 31 | if: matrix.os == 'macos-latest' 32 | run: | 33 | mkdir bin 34 | brew install duckdb 35 | ./build.sh 36 | 37 | - name: build (linux) 38 | shell: bash 39 | if: matrix.os == 'ubuntu-latest' 40 | run: | 41 | mkdir bin 42 | wget https://github.com/duckdb/duckdb/releases/download/v0.4.0/libduckdb-linux-amd64.zip 43 | unzip libduckdb-linux-amd64.zip 44 | clang src/sql.c \ 45 | -O3 -flto \ 46 | -shared \ 47 | -mtune=native \ 48 | -o bin/libduckdb.so \ 49 | -lduckdb -I./ -L./ 50 | 51 | - name: Release 52 | uses: softprops/action-gh-release@master 53 | env: 54 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 55 | with: 56 | tag_name: "release draft" 57 | draft: true 58 | files: | 59 | bin/libduckdb.dylib 60 | bin/libduckdb.so 61 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | .vscode/ 3 | bun.lockb 4 | node_modules/ 5 | package-lock.json 6 | package.json -------------------------------------------------------------------------------- /LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | Copyright 2022 evanwashere 179 | 180 | Licensed under the Apache License, Version 2.0 (the "License"); 181 | you may not use this file except in compliance with the License. 182 | You may obtain a copy of the License at 183 | 184 | http://www.apache.org/licenses/LICENSE-2.0 185 | 186 | Unless required by applicable law or agreed to in writing, software 187 | distributed under the License is distributed on an "AS IS" BASIS, 188 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 189 | See the License for the specific language governing permissions and 190 | limitations under the License. -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright 2022 Divy Srivastava 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /benches/bun.mjs: -------------------------------------------------------------------------------- 1 | import { open } from "@evan/duckdb"; 2 | import { bench, run } from "mitata"; 3 | 4 | const db = open("/tmp/test2.db"); 5 | const connection = db.connect(); 6 | 7 | const q = "select i, i as a from generate_series(1, 100000) s(i)"; 8 | 9 | const p = connection.prepare(q); 10 | console.log("benchmarking query: " + q); 11 | 12 | bench("duckdb", () => { 13 | p.query(); 14 | }); 15 | 16 | await run({ percentiles: false }); 17 | 18 | connection.close(); 19 | db.close(); 20 | -------------------------------------------------------------------------------- /benches/deno.mjs: -------------------------------------------------------------------------------- 1 | import { open } from "../mod.ts"; 2 | import { bench, run } from "https://esm.sh/mitata"; 3 | 4 | const db = open("/tmp/test.db"); 5 | const connection = db.connect(); 6 | 7 | const q = "select i, i as a from generate_series(1, 100000) s(i)"; 8 | 9 | const p = connection.prepare(q); 10 | console.log("benchmarking query: " + q); 11 | 12 | bench("duckdb", () => { 13 | p.query(); 14 | }); 15 | 16 | await run({ percentiles: false }); 17 | 18 | connection.close(); 19 | db.close(); 20 | -------------------------------------------------------------------------------- /benches/jit-bun.mjs: -------------------------------------------------------------------------------- 1 | import { open } from "@evan/duckdb"; 2 | import { bench, group, run } from "mitata"; 3 | 4 | const db = open(":memory:"); 5 | const connection = db.connect(db); 6 | const q = "select i, i as a from generate_series(1, 100000) s(i)"; 7 | 8 | const p = connection.prepare(q); 9 | console.log("benchmarking query: " + q); 10 | 11 | group("query", () => { 12 | bench("jit query()", () => p.query()); 13 | bench("query()", () => connection.query(q)); 14 | }); 15 | 16 | group("stream", () => { 17 | bench("jit stream()", () => { 18 | for (const x of p.stream()) x; 19 | }); 20 | 21 | bench("stream()", () => { 22 | for (const x of connection.stream(q)) x; 23 | }); 24 | }); 25 | 26 | await run({ percentiles: false }); 27 | 28 | connection.close(); 29 | db.close(); 30 | -------------------------------------------------------------------------------- /benches/jit-deno.mjs: -------------------------------------------------------------------------------- 1 | import { open } from "../mod.ts"; 2 | import { bench, group, run } from "https://esm.sh/mitata"; 3 | 4 | const db = open(":memory:"); 5 | const connection = db.connect(db); 6 | const q = "select i, i as a from generate_series(1, 100000) s(i)"; 7 | 8 | const p = connection.prepare(q); 9 | console.log("benchmarking query: " + q); 10 | 11 | group("query", () => { 12 | bench("jit query()", () => p.query()); 13 | bench("query()", () => connection.query(q)); 14 | }); 15 | 16 | group("stream", () => { 17 | bench("jit stream()", () => { 18 | for (const x of p.stream()) x; 19 | }); 20 | 21 | bench("stream()", () => { 22 | for (const x of connection.stream(q)) x; 23 | }); 24 | }); 25 | 26 | await run({ percentiles: false }); 27 | 28 | connection.close(); 29 | db.close(); 30 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | clang src/sql.c \ 2 | -O3 -flto \ 3 | -dynamiclib \ 4 | -mtune=native \ 5 | -o bin/libduckdb.dylib \ 6 | -undefined dynamic_lookup \ 7 | -lduckdb -L$(brew --prefix duckdb)/lib -I$(brew --prefix duckdb)/include -------------------------------------------------------------------------------- /deno.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@divy/duckdb", 3 | "version": "0.2.1", 4 | "exports": "./mod.ts" 5 | } 6 | -------------------------------------------------------------------------------- /deno.lock: -------------------------------------------------------------------------------- 1 | { 2 | "version": "3", 3 | "packages": { 4 | "specifiers": { 5 | "jsr:@divy/plug@1.0.3": "jsr:@divy/plug@1.0.3", 6 | "jsr:@std/assert@^0.213.1": "jsr:@std/assert@0.213.1", 7 | "jsr:@std/encoding@0.213.1": "jsr:@std/encoding@0.213.1", 8 | "jsr:@std/fmt@0.213.1": "jsr:@std/fmt@0.213.1", 9 | "jsr:@std/fs@0.213.1": "jsr:@std/fs@0.213.1", 10 | "jsr:@std/path@0.213.1": "jsr:@std/path@0.213.1", 11 | "jsr:@std/path@^0.213.1": "jsr:@std/path@0.213.1" 12 | }, 13 | "jsr": { 14 | "@divy/plug@1.0.3": { 15 | "dependencies": [ 16 | "jsr:@std/encoding@0.213.1", 17 | "jsr:@std/fmt@0.213.1", 18 | "jsr:@std/fs@0.213.1", 19 | "jsr:@std/path@0.213.1" 20 | ] 21 | }, 22 | "@std/fs@0.213.1": { 23 | "dependencies": [ 24 | "jsr:@std/assert@^0.213.1", 25 | "jsr:@std/path@^0.213.1" 26 | ] 27 | }, 28 | "@std/path@0.213.1": { 29 | "dependencies": [ 30 | "jsr:@std/assert@^0.213.1" 31 | ] 32 | } 33 | } 34 | }, 35 | "remote": { 36 | "https://deno.land/std@0.122.0/_util/assert.ts": "2f868145a042a11d5ad0a3c748dcf580add8a0dbc0e876eaa0026303a5488f58", 37 | "https://deno.land/std@0.122.0/_util/os.ts": "dfb186cc4e968c770ab6cc3288bd65f4871be03b93beecae57d657232ecffcac", 38 | "https://deno.land/std@0.122.0/fmt/colors.ts": "8368ddf2d48dfe413ffd04cdbb7ae6a1009cf0dccc9c7ff1d76259d9c61a0621", 39 | "https://deno.land/std@0.122.0/path/_constants.ts": "1247fee4a79b70c89f23499691ef169b41b6ccf01887a0abd131009c5581b853", 40 | "https://deno.land/std@0.122.0/path/_interface.ts": "1fa73b02aaa24867e481a48492b44f2598cd9dfa513c7b34001437007d3642e4", 41 | "https://deno.land/std@0.122.0/path/_util.ts": "2e06a3b9e79beaf62687196bd4b60a4c391d862cfa007a20fc3a39f778ba073b", 42 | "https://deno.land/std@0.122.0/path/common.ts": "f41a38a0719a1e85aa11c6ba3bea5e37c15dd009d705bd8873f94c833568cbc4", 43 | "https://deno.land/std@0.122.0/path/glob.ts": "7bf2349e818e332a830f3d8874c3f45dd7580b6c742ed50dbf6282d84ab18405", 44 | "https://deno.land/std@0.122.0/path/mod.ts": "4465dc494f271b02569edbb4a18d727063b5dbd6ed84283ff906260970a15d12", 45 | "https://deno.land/std@0.122.0/path/posix.ts": "34349174b9cd121625a2810837a82dd8b986bbaaad5ade690d1de75bbb4555b2", 46 | "https://deno.land/std@0.122.0/path/separator.ts": "8fdcf289b1b76fd726a508f57d3370ca029ae6976fcde5044007f062e643ff1c", 47 | "https://deno.land/std@0.122.0/path/win32.ts": "11549e8c6df8307a8efcfa47ad7b2a75da743eac7d4c89c9723a944661c8bd2e", 48 | "https://deno.land/std@0.149.0/fmt/colors.ts": "6f9340b7fb8cc25a993a99e5efc56fe81bb5af284ff412129dd06df06f53c0b4", 49 | "https://deno.land/std@0.149.0/testing/_diff.ts": "029a00560b0d534bc0046f1bce4bd36b3b41ada3f2a3178c85686eb2ff5f1413", 50 | "https://deno.land/std@0.149.0/testing/_format.ts": "0d8dc79eab15b67cdc532826213bbe05bccfd276ca473a50a3fc7bbfb7260642", 51 | "https://deno.land/std@0.149.0/testing/asserts.ts": "0ee58a557ac764e762c62bb21f00e7d897e3919e71be38b2d574fb441d721005", 52 | "https://deno.land/std@0.195.0/_util/diff.ts": "1a3c044aedf77647d6cac86b798c6417603361b66b54c53331b312caeb447aea", 53 | "https://deno.land/std@0.195.0/assert/_constants.ts": "8a9da298c26750b28b326b297316cdde860bc237533b07e1337c021379e6b2a9", 54 | "https://deno.land/std@0.195.0/assert/_format.ts": "a69126e8a469009adf4cf2a50af889aca364c349797e63174884a52ff75cf4c7", 55 | "https://deno.land/std@0.195.0/assert/assert.ts": "9a97dad6d98c238938e7540736b826440ad8c1c1e54430ca4c4e623e585607ee", 56 | "https://deno.land/std@0.195.0/assert/assert_almost_equals.ts": "e15ca1f34d0d5e0afae63b3f5d975cbd18335a132e42b0c747d282f62ad2cd6c", 57 | "https://deno.land/std@0.195.0/assert/assert_array_includes.ts": "6856d7f2c3544bc6e62fb4646dfefa3d1df5ff14744d1bca19f0cbaf3b0d66c9", 58 | "https://deno.land/std@0.195.0/assert/assert_equals.ts": "a0ee60574e437bcab2dcb79af9d48dc88845f8fd559468d9c21b15fd638ef943", 59 | "https://deno.land/std@0.195.0/assert/assert_exists.ts": "407cb6b9fb23a835cd8d5ad804e2e2edbbbf3870e322d53f79e1c7a512e2efd7", 60 | "https://deno.land/std@0.195.0/assert/assert_false.ts": "a9962749f4bf5844e3fa494257f1de73d69e4fe0e82c34d0099287552163a2dc", 61 | "https://deno.land/std@0.195.0/assert/assert_instance_of.ts": "09fd297352a5b5bbb16da2b5e1a0d8c6c44da5447772648622dcc7df7af1ddb8", 62 | "https://deno.land/std@0.195.0/assert/assert_is_error.ts": "b4eae4e5d182272efc172bf28e2e30b86bb1650cd88aea059e5d2586d4160fb9", 63 | "https://deno.land/std@0.195.0/assert/assert_match.ts": "c4083f80600bc190309903c95e397a7c9257ff8b5ae5c7ef91e834704e672e9b", 64 | "https://deno.land/std@0.195.0/assert/assert_not_equals.ts": "9f1acab95bd1f5fc9a1b17b8027d894509a745d91bac1718fdab51dc76831754", 65 | "https://deno.land/std@0.195.0/assert/assert_not_instance_of.ts": "0c14d3dfd9ab7a5276ed8ed0b18c703d79a3d106102077ec437bfe7ed912bd22", 66 | "https://deno.land/std@0.195.0/assert/assert_not_match.ts": "3796a5b0c57a1ce6c1c57883dd4286be13a26f715ea662318ab43a8491a13ab0", 67 | "https://deno.land/std@0.195.0/assert/assert_not_strict_equals.ts": "ca6c6d645e95fbc873d25320efeb8c4c6089a9a5e09f92d7c1c4b6e935c2a6ad", 68 | "https://deno.land/std@0.195.0/assert/assert_object_match.ts": "27439c4f41dce099317566144299468ca822f556f1cc697f4dc8ed61fe9fee4c", 69 | "https://deno.land/std@0.195.0/assert/assert_rejects.ts": "45c59724de2701e3b1f67c391d6c71c392363635aad3f68a1b3408f9efca0057", 70 | "https://deno.land/std@0.195.0/assert/assert_strict_equals.ts": "5cf29b38b3f8dece95287325723272aa04e04dbf158d886d662fa594fddc9ed3", 71 | "https://deno.land/std@0.195.0/assert/assert_string_includes.ts": "b821d39ebf5cb0200a348863c86d8c4c4b398e02012ce74ad15666fc4b631b0c", 72 | "https://deno.land/std@0.195.0/assert/assert_throws.ts": "63784e951475cb7bdfd59878cd25a0931e18f6dc32a6077c454b2cd94f4f4bcd", 73 | "https://deno.land/std@0.195.0/assert/assertion_error.ts": "4d0bde9b374dfbcbe8ac23f54f567b77024fb67dbb1906a852d67fe050d42f56", 74 | "https://deno.land/std@0.195.0/assert/equal.ts": "9f1a46d5993966d2596c44e5858eec821859b45f783a5ee2f7a695dfc12d8ece", 75 | "https://deno.land/std@0.195.0/assert/fail.ts": "c36353d7ae6e1f7933d45f8ea51e358c8c4b67d7e7502028598fe1fea062e278", 76 | "https://deno.land/std@0.195.0/assert/mod.ts": "08d55a652c22c5da0215054b21085cec25a5da47ce4a6f9de7d9ad36df35bdee", 77 | "https://deno.land/std@0.195.0/assert/unimplemented.ts": "d56fbeecb1f108331a380f72e3e010a1f161baa6956fd0f7cf3e095ae1a4c75a", 78 | "https://deno.land/std@0.195.0/assert/unreachable.ts": "4600dc0baf7d9c15a7f7d234f00c23bca8f3eba8b140286aaca7aa998cf9a536", 79 | "https://deno.land/std@0.195.0/fmt/colors.ts": "a7eecffdf3d1d54db890723b303847b6e0a1ab4b528ba6958b8f2e754cf1b3bc", 80 | "https://deno.land/std@0.195.0/testing/asserts.ts": "4da3dca17ff6b852e4e689f7e42562c24c3ee182cc55ff04852811e321538c24", 81 | "https://deno.land/std@0.97.0/_util/assert.ts": "2f868145a042a11d5ad0a3c748dcf580add8a0dbc0e876eaa0026303a5488f58", 82 | "https://deno.land/std@0.97.0/_util/os.ts": "e282950a0eaa96760c0cf11e7463e66babd15ec9157d4c9ed49cc0925686f6a7", 83 | "https://deno.land/std@0.97.0/encoding/base64.ts": "eecae390f1f1d1cae6f6c6d732ede5276bf4b9cd29b1d281678c054dc5cc009e", 84 | "https://deno.land/std@0.97.0/encoding/hex.ts": "f952e0727bddb3b2fd2e6889d104eacbd62e92091f540ebd6459317a61932d9b", 85 | "https://deno.land/std@0.97.0/fs/_util.ts": "f2ce811350236ea8c28450ed822a5f42a0892316515b1cd61321dec13569c56b", 86 | "https://deno.land/std@0.97.0/fs/ensure_dir.ts": "b7c103dc41a3d1dbbb522bf183c519c37065fdc234831a4a0f7d671b1ed5fea7", 87 | "https://deno.land/std@0.97.0/fs/exists.ts": "b0d2e31654819cc2a8d37df45d6b14686c0cc1d802e9ff09e902a63e98b85a00", 88 | "https://deno.land/std@0.97.0/hash/_wasm/hash.ts": "cb6ad1ab429f8ac9d6eae48f3286e08236d662e1a2e5cfd681ba1c0f17375895", 89 | "https://deno.land/std@0.97.0/hash/_wasm/wasm.js": "94b1b997ae6fb4e6d2156bcea8f79cfcd1e512a91252b08800a92071e5e84e1a", 90 | "https://deno.land/std@0.97.0/hash/hasher.ts": "57a9ec05dd48a9eceed319ac53463d9873490feea3832d58679df6eec51c176b", 91 | "https://deno.land/std@0.97.0/hash/mod.ts": "5d032bd34186cda2f8d17fc122d621430953a6030d4b3f11172004715e3e2441", 92 | "https://deno.land/std@0.97.0/path/_constants.ts": "1247fee4a79b70c89f23499691ef169b41b6ccf01887a0abd131009c5581b853", 93 | "https://deno.land/std@0.97.0/path/_interface.ts": "1fa73b02aaa24867e481a48492b44f2598cd9dfa513c7b34001437007d3642e4", 94 | "https://deno.land/std@0.97.0/path/_util.ts": "2e06a3b9e79beaf62687196bd4b60a4c391d862cfa007a20fc3a39f778ba073b", 95 | "https://deno.land/std@0.97.0/path/common.ts": "eaf03d08b569e8a87e674e4e265e099f237472b6fd135b3cbeae5827035ea14a", 96 | "https://deno.land/std@0.97.0/path/glob.ts": "314ad9ff263b895795208cdd4d5e35a44618ca3c6dd155e226fb15d065008652", 97 | "https://deno.land/std@0.97.0/path/mod.ts": "4465dc494f271b02569edbb4a18d727063b5dbd6ed84283ff906260970a15d12", 98 | "https://deno.land/std@0.97.0/path/posix.ts": "f56c3c99feb47f30a40ce9d252ef6f00296fa7c0fcb6dd81211bdb3b8b99ca3b", 99 | "https://deno.land/std@0.97.0/path/separator.ts": "8fdcf289b1b76fd726a508f57d3370ca029ae6976fcde5044007f062e643ff1c", 100 | "https://deno.land/std@0.97.0/path/win32.ts": "77f7b3604e0de40f3a7c698e8a79e7f601dc187035a1c21cb1e596666ce112f8", 101 | "https://deno.land/x/cache@0.2.13/cache.ts": "4005aad54fb9aac9ff02526ffa798032e57f2d7966905fdeb7949263b1c95f2f", 102 | "https://deno.land/x/cache@0.2.13/deps.ts": "6f14e76a1a09f329e3f3830c6e72bd10b53a89a75769d5ea886e5d8603e503e6", 103 | "https://deno.land/x/cache@0.2.13/directories.ts": "ef48531cab3f827252e248596d15cede0de179a2fb15392ae24cf8034519994f", 104 | "https://deno.land/x/cache@0.2.13/file.ts": "5abe7d80c6ac594c98e66eb4262962139f48cd9c49dbe2a77e9608760508a09a", 105 | "https://deno.land/x/cache@0.2.13/file_fetcher.ts": "5c793cc83a5b9377679ec313b2a2321e51bf7ed15380fa82d387f1cdef3b924f", 106 | "https://deno.land/x/cache@0.2.13/helpers.ts": "d1545d6432277b7a0b5ea254d1c51d572b6452a8eadd9faa7ad9c5586a1725c4", 107 | "https://deno.land/x/cache@0.2.13/mod.ts": "3188250d3a013ef6c9eb060e5284cf729083af7944a29e60bb3d8597dd20ebcd", 108 | "https://deno.land/x/plug@0.5.2/deps.ts": "0f53866f60dc4f89bbc3be9d096f7501f2068a51923db220f43f0ad284b6b892", 109 | "https://deno.land/x/plug@0.5.2/plug.ts": "e495c772bc3b19eb30d820bb83f1b75f6047e3009e19d9a5d81dbe68ca642fd9", 110 | "https://jsr.io/@divy/plug/1.0.3/deps.ts": "4518c332757c16e1b10e01f6d7f618053a45c6c467cc4302827cefea7294f00b", 111 | "https://jsr.io/@divy/plug/1.0.3/download.ts": "ada314a1a273c43559acd341155fbfc4aba41247d84361f2db7423d1648bd816", 112 | "https://jsr.io/@divy/plug/1.0.3/mod.ts": "5dec80ee7a3a325be45c03439558531bce7707ac118f4376cebbd6740ff24bfb", 113 | "https://jsr.io/@divy/plug/1.0.3/types.ts": "0490359117c53783138f2b6692a34f85bca9237314ba8cdef8ad682d81218d21", 114 | "https://jsr.io/@divy/plug/1.0.3/util.ts": "aa96bc3cdae1787220bac9d37e90879b3d5deea5b46adebb1ff2fcb3ea84e0e6", 115 | "https://jsr.io/@std/assert/0.213.1/assert.ts": "501b416473ec27c71885aaf819e363c8df617f89ce68ae57fec7acf9d62743b2", 116 | "https://jsr.io/@std/assert/0.213.1/assertion_error.ts": "dd027fb33707dbff22cd2ef9b55fdb70e2095876caf3c68ecfbb811505ecc022", 117 | "https://jsr.io/@std/encoding/0.213.1/_util.ts": "beacef316c1255da9bc8e95afb1fa56ed69baef919c88dc06ae6cb7a6103d376", 118 | "https://jsr.io/@std/encoding/0.213.1/hex.ts": "1aecfa504efd0ffcd176037abc7eb7d775a7b38a9e775d9e7260b583ad1301e7", 119 | "https://jsr.io/@std/fmt/0.213.1/colors.ts": "59b5de7c07cdc0322ed61b2d98da1ca4fbc9f576d45c2beee577a27556e52d63", 120 | "https://jsr.io/@std/fs/0.213.1/_create_walk_entry.ts": "b48774274e42cb540eb2aa31ea64e2734ec909900d14bdf9ce73bd0d3ce465e7", 121 | "https://jsr.io/@std/fs/0.213.1/_get_file_info_type.ts": "da7bec18a7661dba360a1db475b826b18977582ce6fc9b25f3d4ee0403fe8cbd", 122 | "https://jsr.io/@std/fs/0.213.1/_is_same_path.ts": "8f3810e02b6018c1c1e1019715b8ff1deb523f03d08ade597ddba2ec96b5e1ab", 123 | "https://jsr.io/@std/fs/0.213.1/_is_subdir.ts": "2310298ba1017545e8b7d121387b0b1e94dd1e2c91c4c9fa28eb249823312647", 124 | "https://jsr.io/@std/fs/0.213.1/_to_path_string.ts": "da4e710ec2f58266a609d4c649d86731129db1bc7c72fa275f6d13e81576ce45", 125 | "https://jsr.io/@std/fs/0.213.1/copy.ts": "4b3673d4dcbf4957422350c7964868a89622ccbd66f15a12ad3d2fe80a792670", 126 | "https://jsr.io/@std/fs/0.213.1/empty_dir.ts": "78456f5aaf04a911cafd2c21b4dd3c0f5c6620b311aa048541c39ab43f858b84", 127 | "https://jsr.io/@std/fs/0.213.1/ensure_dir.ts": "a6c127285f5bdfe10e6ff5b55ff7f9b5c7f67c74d3dcfe66081c5780a5e1ee85", 128 | "https://jsr.io/@std/fs/0.213.1/ensure_file.ts": "1d99467da9aeb55557412f5773dfdbd78b6c2ba38907b4d4108c8f51bab0c0f1", 129 | "https://jsr.io/@std/fs/0.213.1/ensure_link.ts": "e4efe0a0111a6fa8da52309500eaa740864bf33c5957154b3d3cb727e71e340d", 130 | "https://jsr.io/@std/fs/0.213.1/ensure_symlink.ts": "dd656834384e7131c7ddb5307c84370e2927ece924e7f9fc8176537fc67bcb4d", 131 | "https://jsr.io/@std/fs/0.213.1/eol.ts": "d560d5e3cc3a1acff483f1339d7de31ca6025808b2c499a8b246984b84282e0b", 132 | "https://jsr.io/@std/fs/0.213.1/exists.ts": "e636a0e535793d8677095e7a75308eda47cc4c784f83c4e2beaa90825a5b84de", 133 | "https://jsr.io/@std/fs/0.213.1/expand_glob.ts": "180ee5fd8616d6f5be8ee0d98a1766498594b566c44a51710f964121295d1151", 134 | "https://jsr.io/@std/fs/0.213.1/mod.ts": "107f5afa4424c2d3ce2f7e9266173198da30302c69af662c720115fe504dc5ee", 135 | "https://jsr.io/@std/fs/0.213.1/move.ts": "8301ee1883b3d5e0eda7c5b670e7fe5ca9ac98fe74258551ec513d222c1af85f", 136 | "https://jsr.io/@std/fs/0.213.1/walk.ts": "3a0af602e996a11e3e0305548bfa4b60ba1b8e2dfc582da890604217b52732d6", 137 | "https://jsr.io/@std/path/0.213.1/_common/assert_path.ts": "2ca275f36ac1788b2acb60fb2b79cb06027198bc2ba6fb7e163efaedde98c297", 138 | "https://jsr.io/@std/path/0.213.1/_common/basename.ts": "569744855bc8445f3a56087fd2aed56bdad39da971a8d92b138c9913aecc5fa2", 139 | "https://jsr.io/@std/path/0.213.1/_common/common.ts": "6157c7ec1f4db2b4a9a187efd6ce76dcaf1e61cfd49f87e40d4ea102818df031", 140 | "https://jsr.io/@std/path/0.213.1/_common/constants.ts": "dc5f8057159f4b48cd304eb3027e42f1148cf4df1fb4240774d3492b5d12ac0c", 141 | "https://jsr.io/@std/path/0.213.1/_common/dirname.ts": "684df4aa71a04bbcc346c692c8485594fc8a90b9408dfbc26ff32cf3e0c98cc8", 142 | "https://jsr.io/@std/path/0.213.1/_common/format.ts": "92500e91ea5de21c97f5fe91e178bae62af524b72d5fcd246d6d60ae4bcada8b", 143 | "https://jsr.io/@std/path/0.213.1/_common/from_file_url.ts": "d672bdeebc11bf80e99bf266f886c70963107bdd31134c4e249eef51133ceccf", 144 | "https://jsr.io/@std/path/0.213.1/_common/glob_to_reg_exp.ts": "2007aa87bed6eb2c8ae8381adcc3125027543d9ec347713c1ad2c68427330770", 145 | "https://jsr.io/@std/path/0.213.1/_common/normalize.ts": "684df4aa71a04bbcc346c692c8485594fc8a90b9408dfbc26ff32cf3e0c98cc8", 146 | "https://jsr.io/@std/path/0.213.1/_common/normalize_string.ts": "dfdf657a1b1a7db7999f7c575ee7e6b0551d9c20f19486c6c3f5ff428384c965", 147 | "https://jsr.io/@std/path/0.213.1/_common/relative.ts": "faa2753d9b32320ed4ada0733261e3357c186e5705678d9dd08b97527deae607", 148 | "https://jsr.io/@std/path/0.213.1/_common/strip_trailing_separators.ts": "7024a93447efcdcfeaa9339a98fa63ef9d53de363f1fbe9858970f1bba02655a", 149 | "https://jsr.io/@std/path/0.213.1/_common/to_file_url.ts": "7f76adbc83ece1bba173e6e98a27c647712cab773d3f8cbe0398b74afc817883", 150 | "https://jsr.io/@std/path/0.213.1/_interface.ts": "a1419fcf45c0ceb8acdccc94394e3e94f99e18cfd32d509aab514c8841799600", 151 | "https://jsr.io/@std/path/0.213.1/_os.ts": "8fb9b90fb6b753bd8c77cfd8a33c2ff6c5f5bc185f50de8ca4ac6a05710b2c15", 152 | "https://jsr.io/@std/path/0.213.1/basename.ts": "5d341aadb7ada266e2280561692c165771d071c98746fcb66da928870cd47668", 153 | "https://jsr.io/@std/path/0.213.1/common.ts": "4c80da2ee5563eb31f87cf7d21879db90d614a3fae83358670625e4b90342745", 154 | "https://jsr.io/@std/path/0.213.1/constants.ts": "0c206169ca104938ede9da48ac952de288f23343304a1c3cb6ec7625e7325f36", 155 | "https://jsr.io/@std/path/0.213.1/dirname.ts": "85bd955bf31d62c9aafdd7ff561c4b5fb587d11a9a5a45e2b01aedffa4238a7c", 156 | "https://jsr.io/@std/path/0.213.1/extname.ts": "593303db8ae8c865cbd9ceec6e55d4b9ac5410c1e276bfd3131916591b954441", 157 | "https://jsr.io/@std/path/0.213.1/format.ts": "98fad25f1af7b96a48efb5b67378fcc8ed77be895df8b9c733b86411632162af", 158 | "https://jsr.io/@std/path/0.213.1/from_file_url.ts": "7c87244ca07e4065cb024016b03d012facb856cc7aed089d9b6f1e4ea6152316", 159 | "https://jsr.io/@std/path/0.213.1/glob.ts": "04510962905d4b1513b44da9cb195914e0fa46c24359f6feaca20848d797dcb0", 160 | "https://jsr.io/@std/path/0.213.1/glob_to_regexp.ts": "83c5fd36a8c86f5e72df9d0f45317f9546afa2ce39acaafe079d43a865aced08", 161 | "https://jsr.io/@std/path/0.213.1/is_absolute.ts": "4791afc8bfd0c87f0526eaa616b0d16e7b3ab6a65b62942e50eac68de4ef67d7", 162 | "https://jsr.io/@std/path/0.213.1/is_glob.ts": "a65f6195d3058c3050ab905705891b412ff942a292bcbaa1a807a74439a14141", 163 | "https://jsr.io/@std/path/0.213.1/join.ts": "ae2ec5ca44c7e84a235fd532e4a0116bfb1f2368b394db1c4fb75e3c0f26a33a", 164 | "https://jsr.io/@std/path/0.213.1/join_globs.ts": "e9589869a33dc3982101898ee50903db918ca00ad2614dbe3934d597d7b1fbea", 165 | "https://jsr.io/@std/path/0.213.1/mod.ts": "8a61b81dd91a8cca0326bf0011db8d227b23b982dd4647fb119674594e29e544", 166 | "https://jsr.io/@std/path/0.213.1/normalize.ts": "4155743ccceeed319b350c1e62e931600272fad8ad00c417b91df093867a8352", 167 | "https://jsr.io/@std/path/0.213.1/normalize_glob.ts": "98ee8268fad271193603271c203ae973280b5abfbdd2cbca1053fd2af71869ca", 168 | "https://jsr.io/@std/path/0.213.1/parse.ts": "65e8e285f1a63b714e19ef24b68f56e76934c3df0b6e65fd440d3991f4f8aefb", 169 | "https://jsr.io/@std/path/0.213.1/posix/_util.ts": "1e3937da30f080bfc99fe45d7ed23c47dd8585c5e473b2d771380d3a6937cf9d", 170 | "https://jsr.io/@std/path/0.213.1/posix/basename.ts": "265d3360c49c1af372a10891518b785fc2ae138f019892c89642e1f1c523b2dc", 171 | "https://jsr.io/@std/path/0.213.1/posix/common.ts": "4c896e6e9357f33c3ffe027cb13cb2ccf5dbe3575604b43c195befffb0f40b2b", 172 | "https://jsr.io/@std/path/0.213.1/posix/constants.ts": "93481efb98cdffa4c719c22a0182b994e5a6aed3047e1962f6c2c75b7592bef1", 173 | "https://jsr.io/@std/path/0.213.1/posix/dirname.ts": "ecdaeec17d5fdd00da89bb05962e209c7aa41ad4967279bc8662c0bb3a243b2f", 174 | "https://jsr.io/@std/path/0.213.1/posix/extname.ts": "b1400d9d0ac2160accda327790c93daa4ee8325b87f4c4d9b21887e7c8fd73db", 175 | "https://jsr.io/@std/path/0.213.1/posix/format.ts": "47318e54ac8cd2e9c35ef2a143d02c198ce093e31f9789b6ecb95cbc60fec71b", 176 | "https://jsr.io/@std/path/0.213.1/posix/from_file_url.ts": "dc4a092de0d117d94bfd54390b4bc360ea1c68d4a1e42d2ea94d6fe75b483c37", 177 | "https://jsr.io/@std/path/0.213.1/posix/glob_to_regexp.ts": "4db789540039ea4c75f1ba8182c43fc2965a019df3c26a825945642452e8bf75", 178 | "https://jsr.io/@std/path/0.213.1/posix/is_absolute.ts": "e7147b25e786abb51dd888eca89d2fd3770c41e6bd556d19db26cca348fb78a4", 179 | "https://jsr.io/@std/path/0.213.1/posix/is_glob.ts": "135ac8b1e647f673ea650fb713e2d9c42d0108c29cae3a2b77399fec0dae8864", 180 | "https://jsr.io/@std/path/0.213.1/posix/join.ts": "1bbf0d9303160d4b9be76161d0ef73d67198cf7bf66e84d88eb560abc492070f", 181 | "https://jsr.io/@std/path/0.213.1/posix/join_globs.ts": "3d77c1a2e29997f6d993105b5f5e8e89a280320a3e0e3df7e6b912506d69103f", 182 | "https://jsr.io/@std/path/0.213.1/posix/mod.ts": "c9d57eb43df561742cf545816a7d6e1382680425de245588197bbf3d325931ad", 183 | "https://jsr.io/@std/path/0.213.1/posix/normalize.ts": "9b9f666159c0e5ee3df292cf56555547b1be4cd3ca54da6a263a3074b8e44964", 184 | "https://jsr.io/@std/path/0.213.1/posix/normalize_glob.ts": "c1b8a6f001d7cad1a6c8eefb4d7f7a027d3a7bc7a0c91c6e08222f4cbac6105f", 185 | "https://jsr.io/@std/path/0.213.1/posix/parse.ts": "96aad4733eb1091db6b3de423f23c25a2ac3e3a5b29b35c3ee808b123eef73e5", 186 | "https://jsr.io/@std/path/0.213.1/posix/relative.ts": "f0617bf5614ac45462d71d8d03a5bbe3db9f5aaadc9e470a560013d0416d4cc0", 187 | "https://jsr.io/@std/path/0.213.1/posix/resolve.ts": "00f39f36478ad11b64604ad9b508b137a930aae2423e757ba53ec5f11a919ee1", 188 | "https://jsr.io/@std/path/0.213.1/posix/separator.ts": "c9ecae5c843170118156ac5d12dc53e9caf6a1a4c96fc8b1a0ab02dff5c847b0", 189 | "https://jsr.io/@std/path/0.213.1/posix/to_file_url.ts": "e1c2f7b256100610ae85a443f89404f4b5d730d882c388a76b8e4fa1ecfc5ac7", 190 | "https://jsr.io/@std/path/0.213.1/posix/to_namespaced_path.ts": "28b216b3c76f892a4dca9734ff1cc0045d135532bfd9c435ae4858bfa5a2ebf0", 191 | "https://jsr.io/@std/path/0.213.1/relative.ts": "ab739d727180ed8727e34ed71d976912461d98e2b76de3d3de834c1066667add", 192 | "https://jsr.io/@std/path/0.213.1/resolve.ts": "a6f977bdb4272e79d8d0ed4333e3d71367cc3926acf15ac271f1d059c8494d8d", 193 | "https://jsr.io/@std/path/0.213.1/separator.ts": "c6c890507f944a1f5cb7d53b8d638d6ce3cf0f34609c8d84a10c1eaa400b77a9", 194 | "https://jsr.io/@std/path/0.213.1/to_file_url.ts": "ce1a439e03377882e58f06ef43ef2259d483bab235d1eb727f1637b0a6bd7070", 195 | "https://jsr.io/@std/path/0.213.1/to_namespaced_path.ts": "b706a4103b104cfadc09600a5f838c2ba94dbcdb642344557122dda444526e40", 196 | "https://jsr.io/@std/path/0.213.1/windows/_util.ts": "d5f47363e5293fced22c984550d5e70e98e266cc3f31769e1710511803d04808", 197 | "https://jsr.io/@std/path/0.213.1/windows/basename.ts": "20179a24e3b4a8d5d957f0b6c5515d1d05c47c7e5824d595844f3ff5558e6e5b", 198 | "https://jsr.io/@std/path/0.213.1/windows/common.ts": "4c896e6e9357f33c3ffe027cb13cb2ccf5dbe3575604b43c195befffb0f40b2b", 199 | "https://jsr.io/@std/path/0.213.1/windows/constants.ts": "5afaac0a1f67b68b0a380a4ef391bf59feb55856aa8c60dfc01bd3b6abb813f5", 200 | "https://jsr.io/@std/path/0.213.1/windows/dirname.ts": "f5aee3cff1830aa804bee6b947c51a667dfc713b339923d884e590cffdf5d8e0", 201 | "https://jsr.io/@std/path/0.213.1/windows/extname.ts": "297ff46e51d75b97d4096cf5664471dca65b529f557c2e6e08aec3f2441767bf", 202 | "https://jsr.io/@std/path/0.213.1/windows/format.ts": "8986f9e9b1cd48b404aa7c3873bfb976a9af08eeb40a58f1001a8d887d0dfe14", 203 | "https://jsr.io/@std/path/0.213.1/windows/from_file_url.ts": "d67e4c8e7453597bf8071da6a995d6c9ad41f3c30192dc6494a25beb14647ff7", 204 | "https://jsr.io/@std/path/0.213.1/windows/glob_to_regexp.ts": "5a9251ea357ec619f8b370a87e3ec010f36ceb9a0112973b6a1122684b72ccdb", 205 | "https://jsr.io/@std/path/0.213.1/windows/is_absolute.ts": "d3534d9fd5680d4c6895bbb59193335e5753cdef875f095297be66eb96f2f530", 206 | "https://jsr.io/@std/path/0.213.1/windows/is_glob.ts": "135ac8b1e647f673ea650fb713e2d9c42d0108c29cae3a2b77399fec0dae8864", 207 | "https://jsr.io/@std/path/0.213.1/windows/join.ts": "a62e4f0cc65e0f6f2b033f5df3b11e0b51362aef2e1fb7c9aef2b299ac224810", 208 | "https://jsr.io/@std/path/0.213.1/windows/join_globs.ts": "3d77c1a2e29997f6d993105b5f5e8e89a280320a3e0e3df7e6b912506d69103f", 209 | "https://jsr.io/@std/path/0.213.1/windows/mod.ts": "8b483812e8f38abcbf5aad4352409e7828d9ef9ecd4aa0a241fbeb0f8ba7a890", 210 | "https://jsr.io/@std/path/0.213.1/windows/normalize.ts": "f5d8b971161eff7b4f8e45c7520cbb0c6553ccff7c4b3ced2dfe0d6ad46a2328", 211 | "https://jsr.io/@std/path/0.213.1/windows/normalize_glob.ts": "c37afcaf52f2ce977f52a2b7820cad7e1fb7b9651df1fe130dda52401ae12263", 212 | "https://jsr.io/@std/path/0.213.1/windows/parse.ts": "c63488c9d581576f955eaa8c4ab09c165b8d922ec3911b302c31331c8303973f", 213 | "https://jsr.io/@std/path/0.213.1/windows/relative.ts": "366eb25bd3469433e47dd4cac52d03048d5e27e8a89e059217065d3afa4e7e71", 214 | "https://jsr.io/@std/path/0.213.1/windows/resolve.ts": "671e70d150bd933832ffcf02e97572fdfbb8ed199082bdabdf4e92d3e898636e", 215 | "https://jsr.io/@std/path/0.213.1/windows/separator.ts": "e51c5522140eff4f8402617c5c68a201fdfa3a1a8b28dc23587cff931b665e43", 216 | "https://jsr.io/@std/path/0.213.1/windows/to_file_url.ts": "cdead9ba8f1e4062c3c45a7c9fa6384e209b734526b4c6ab36ce2f17339367f5", 217 | "https://jsr.io/@std/path/0.213.1/windows/to_namespaced_path.ts": "96dd0d55d484905e06553fd7d5feb6b3e4c0c99c337fda4199b6c32bce44833a" 218 | } 219 | } 220 | -------------------------------------------------------------------------------- /lib.js: -------------------------------------------------------------------------------- 1 | import { dlopen } from "jsr:@divy/plug@1.0.3"; 2 | 3 | function ptr(v) { 4 | return Deno.UnsafePointer.of(v); 5 | } 6 | function toArrayBuffer(v, start, offset) { 7 | const view = new Deno.UnsafePointerView(v); 8 | return view.getArrayBuffer(start, offset); 9 | } 10 | function getCString(v) { 11 | const view = new Deno.UnsafePointerView(v); 12 | return view.getCString(); 13 | } 14 | 15 | const name = "duckdb"; 16 | const utf8e = new TextEncoder(); 17 | const GeneratorFunction = (function* () {}).constructor; 18 | 19 | const path = { 20 | linux() { 21 | return new URL(`./bin/libduckdb.so`, import.meta.url); 22 | }, 23 | darwin() { 24 | return new URL(`./bin/libduckdb.dylib`, import.meta.url); 25 | }, 26 | }[Deno.build.os]().pathname; 27 | 28 | const devMode = Deno.env.get("DENO_DUCKDB_DEV"); 29 | let options = { name: "duckdb" }; 30 | if (devMode) { 31 | options.url = path; 32 | } else { 33 | options.url = "https://github.com/littledivy/duckdb/releases/download/0.1.0/"; 34 | options.suffixes = { 35 | darwin: { 36 | aarch64: `_aarch64`, 37 | }, 38 | }; 39 | } 40 | 41 | const { symbols: duck } = await dlopen(options, { 42 | duckffi_free: { parameters: ["pointer"], result: "void" }, 43 | duckffi_dfree: { parameters: ["pointer"], result: "void" }, 44 | duckffi_close: { parameters: ["pointer"], result: "void" }, 45 | duckffi_connect: { parameters: ["pointer"], result: "pointer" }, 46 | duckffi_row_count: { parameters: ["pointer"], result: "u32" }, 47 | duckffi_enum_size: { parameters: ["pointer"], result: "u32" }, 48 | duckffi_enum_type: { parameters: ["pointer"], result: "u32" }, 49 | duckffi_blob_size: { parameters: ["pointer"], result: "u32" }, 50 | duckffi_blob_data: { parameters: ["pointer"], result: "pointer" }, 51 | duckffi_free_blob: { parameters: ["pointer"], result: "void" }, 52 | duckffi_free_ltype: { parameters: ["pointer"], result: "void" }, 53 | duckffi_disconnect: { parameters: ["pointer"], result: "void" }, 54 | duckffi_param_count: { parameters: ["pointer"], result: "u32" }, 55 | duckffi_open: { parameters: ["u8", "pointer"], result: "pointer" }, 56 | duckffi_query: { parameters: ["pointer", "pointer"], result: "pointer" }, 57 | duckffi_free_result: { parameters: ["pointer"], result: "void" }, 58 | duckffi_column_count: { parameters: ["pointer"], result: "u32" }, 59 | duckffi_result_error: { parameters: ["pointer"], result: "pointer" }, 60 | duckffi_free_prepare: { parameters: ["pointer"], result: "void" }, 61 | duckffi_prepare_error: { parameters: ["pointer"], result: "pointer" }, 62 | duckffi_prepare: { parameters: ["pointer", "pointer"], result: "pointer" }, 63 | duckffi_row_count_slow: { parameters: ["pointer"], result: "u64" }, 64 | duckffi_query_prepared: { parameters: ["pointer"], result: "pointer" }, 65 | duckffi_row_count_large: { parameters: ["pointer"], result: "u8" }, 66 | duckffi_param_type: { parameters: ["pointer", "u32"], result: "u32" }, 67 | duckffi_enum_string: { parameters: ["pointer", "u32"], result: "pointer" }, 68 | duckffi_column_name: { parameters: ["pointer", "u32"], result: "pointer" }, 69 | duckffi_column_type: { parameters: ["pointer", "u32"], result: "u32" }, 70 | duckffi_column_ltype: { parameters: ["pointer", "u32"], result: "pointer" }, 71 | duckffi_null_bitmap: { 72 | parameters: ["pointer", "u32", "u32"], 73 | result: "pointer", 74 | }, 75 | 76 | duckffi_bind_null: { parameters: ["pointer", "u32"], result: "u8" }, 77 | duckffi_bind_u8: { parameters: ["pointer", "u32", "u8"], result: "u8" }, 78 | duckffi_bind_i8: { parameters: ["pointer", "u32", "i8"], result: "u8" }, 79 | duckffi_bind_u16: { parameters: ["pointer", "u32", "u16"], result: "u8" }, 80 | duckffi_bind_i16: { parameters: ["pointer", "u32", "i16"], result: "u8" }, 81 | duckffi_bind_u32: { parameters: ["pointer", "u32", "u32"], result: "u8" }, 82 | duckffi_bind_i32: { parameters: ["pointer", "u32", "i32"], result: "u8" }, 83 | duckffi_bind_f32: { parameters: ["pointer", "u32", "f32"], result: "u8" }, 84 | duckffi_bind_u64: { parameters: ["pointer", "u32", "u64"], result: "u8" }, 85 | duckffi_bind_i64: { parameters: ["pointer", "u32", "i64"], result: "u8" }, 86 | duckffi_bind_f64: { parameters: ["pointer", "u32", "f64"], result: "u8" }, 87 | duckffi_bind_blob: { 88 | parameters: ["pointer", "u32", "pointer", "u32"], 89 | result: "u8", 90 | }, 91 | duckffi_bind_string: { 92 | parameters: ["pointer", "u32", "pointer", "u32"], 93 | result: "u8", 94 | }, 95 | duckffi_bind_timestamp: { 96 | parameters: ["pointer", "u32", "u64"], 97 | result: "u8", 98 | }, 99 | duckffi_bind_interval: { 100 | parameters: ["pointer", "u32", "u32", "u32", "u32"], 101 | result: "u8", 102 | }, 103 | 104 | duckffi_value_u8: { parameters: ["pointer", "u32", "u32"], result: "u8" }, 105 | duckffi_value_i8: { parameters: ["pointer", "u32", "u32"], result: "i8" }, 106 | duckffi_value_u16: { parameters: ["pointer", "u32", "u32"], result: "u16" }, 107 | duckffi_value_i16: { parameters: ["pointer", "u32", "u32"], result: "i16" }, 108 | duckffi_value_u32: { parameters: ["pointer", "u32", "u32"], result: "u32" }, 109 | duckffi_value_i32: { parameters: ["pointer", "u32", "u32"], result: "i32" }, 110 | duckffi_value_f32: { parameters: ["pointer", "u32", "u32"], result: "f32" }, 111 | duckffi_value_u64: { parameters: ["pointer", "u32", "u32"], result: "u64" }, 112 | duckffi_value_i64: { parameters: ["pointer", "u32", "u32"], result: "i32" }, 113 | duckffi_value_f64: { parameters: ["pointer", "u32", "u32"], result: "f64" }, 114 | duckffi_value_time: { parameters: ["pointer", "u32", "u32"], result: "u32" }, 115 | duckffi_value_date: { parameters: ["pointer", "u32", "u32"], result: "u32" }, 116 | duckffi_value_blob: { 117 | parameters: ["pointer", "u32", "u32"], 118 | result: "pointer", 119 | }, 120 | duckffi_value_string: { 121 | parameters: ["pointer", "u32", "u32"], 122 | result: "pointer", 123 | }, 124 | duckffi_value_boolean: { 125 | parameters: ["pointer", "u32", "u32"], 126 | result: "u8", 127 | }, 128 | duckffi_value_is_null: { 129 | parameters: ["pointer", "u32", "u32"], 130 | result: "u8", 131 | }, 132 | duckffi_value_interval_days: { 133 | parameters: ["pointer", "u32", "u32"], 134 | result: "u32", 135 | }, 136 | duckffi_value_interval_months: { 137 | parameters: ["pointer", "u32", "u32"], 138 | result: "u32", 139 | }, 140 | duckffi_value_timestamp_ms: { 141 | parameters: ["pointer", "u32", "u32"], 142 | result: "u64", 143 | }, 144 | 145 | duckffi_value_u8_slow: { 146 | parameters: ["pointer", "u64", "u32"], 147 | result: "u8", 148 | }, 149 | duckffi_value_i8_slow: { 150 | parameters: ["pointer", "u64", "u32"], 151 | result: "i8", 152 | }, 153 | duckffi_value_u16_slow: { 154 | parameters: ["pointer", "u64", "u32"], 155 | result: "u16", 156 | }, 157 | duckffi_value_i16_slow: { 158 | parameters: ["pointer", "u64", "u32"], 159 | result: "i16", 160 | }, 161 | duckffi_value_u32_slow: { 162 | parameters: ["pointer", "u64", "u32"], 163 | result: "u32", 164 | }, 165 | duckffi_value_i32_slow: { 166 | parameters: ["pointer", "u64", "u32"], 167 | result: "i32", 168 | }, 169 | duckffi_value_f32_slow: { 170 | parameters: ["pointer", "u64", "u32"], 171 | result: "f32", 172 | }, 173 | duckffi_value_u64_slow: { 174 | parameters: ["pointer", "u64", "u32"], 175 | result: "u64", 176 | }, 177 | duckffi_value_i64_slow: { 178 | parameters: ["pointer", "u64", "u32"], 179 | result: "i64", 180 | }, 181 | duckffi_value_f64_slow: { 182 | parameters: ["pointer", "u64", "u32"], 183 | result: "f64", 184 | }, 185 | duckffi_value_time_slow: { 186 | parameters: ["pointer", "u64", "u32"], 187 | result: "u32", 188 | }, 189 | duckffi_value_date_slow: { 190 | parameters: ["pointer", "u64", "u32"], 191 | result: "u32", 192 | }, 193 | duckffi_value_blob_slow: { 194 | parameters: ["pointer", "u64", "u32"], 195 | result: "pointer", 196 | }, 197 | duckffi_value_string_slow: { 198 | parameters: ["pointer", "u64", "u32"], 199 | result: "pointer", 200 | }, 201 | duckffi_value_boolean_slow: { 202 | parameters: ["pointer", "u64", "u32"], 203 | result: "u8", 204 | }, 205 | duckffi_value_is_null_slow: { 206 | parameters: ["pointer", "u64", "u32"], 207 | result: "u8", 208 | }, 209 | duckffi_value_interval_days_slow: { 210 | parameters: ["pointer", "u64", "u32"], 211 | result: "u32", 212 | }, 213 | duckffi_value_interval_months_slow: { 214 | parameters: ["pointer", "u64", "u32"], 215 | result: "u32", 216 | }, 217 | duckffi_value_timestamp_ms_slow: { 218 | parameters: ["pointer", "u64", "u32"], 219 | result: "u64", 220 | }, 221 | }); 222 | 223 | for (const k in duck) duck[k] = duck[k].native || duck[k]; 224 | 225 | export function close(db) { 226 | duck.duckffi_close(db); 227 | } 228 | 229 | export function disconnect(c) { 230 | duck.duckffi_disconnect(c); 231 | } 232 | 233 | function bitmap_get(buf, offset) { 234 | return buf[(offset / 8) | 0] >> (offset % 8) & 1; 235 | } 236 | 237 | export function connect(db) { 238 | const c = duck.duckffi_connect(db); 239 | if (0 === c) throw new Error("duckdb: failed to connect to database"); 240 | return c; 241 | } 242 | 243 | const TRUE = 1; 244 | const FALSE = 0; 245 | 246 | export function open(path) { 247 | const db = path === null 248 | ? duck.duckffi_open(TRUE, 0) 249 | : duck.duckffi_open(FALSE, ptr(utf8e.encode(path + "\0"))); 250 | 251 | if (0 === db) throw new Error("duckdb: failed to open database"); 252 | return db; 253 | } 254 | 255 | const _t = { 256 | invalid: 0, 257 | boolean: 1, 258 | tinyint: 2, 259 | smallint: 3, 260 | integer: 4, 261 | bigint: 5, 262 | utinyint: 6, 263 | usmallint: 7, 264 | uinteger: 8, 265 | ubigint: 9, 266 | float: 10, 267 | double: 11, 268 | timestamp: 12, 269 | date: 13, 270 | time: 14, 271 | interval: 15, 272 | hugeint: 16, 273 | varchar: 17, 274 | blob: 18, 275 | decimal: 19, 276 | timestamp_s: 20, 277 | timestamp_ms: 21, 278 | timestamp_ns: 22, 279 | enum: 23, 280 | list: 24, 281 | struct: 25, 282 | map: 26, 283 | uuid: 27, 284 | json: 28, 285 | }; 286 | 287 | const _tr = Object.fromEntries(Object.entries(_t).map(([k, v]) => [v, k])); 288 | const blob_gc = new FinalizationRegistry((ptr) => duck.duckffi_free_blob(ptr)); 289 | const ltype_gc = new FinalizationRegistry((ptr) => 290 | duck.duckffi_free_ltype(ptr) 291 | ); 292 | const result_gc = new FinalizationRegistry((ptr) => 293 | duck.duckffi_free_result(ptr) 294 | ); 295 | const prepare_gc = new FinalizationRegistry((ptr) => 296 | duck.duckffi_free_prepare(ptr) 297 | ); 298 | 299 | const _tm = { 300 | [_t.time](r, _ltypes, _column) { 301 | return (row, column) => duck.duckffi_value_time(r, row, column); 302 | }, 303 | [_t.float](r, _ltypes, _column) { 304 | return (row, column) => duck.duckffi_value_f32(r, row, column); 305 | }, 306 | [_t.double](r, _ltypes, _column) { 307 | return (row, column) => duck.duckffi_value_f64(r, row, column); 308 | }, 309 | [_t.bigint](r, _ltypes, _column) { 310 | return (row, column) => duck.duckffi_value_i64(r, row, column); 311 | }, 312 | [_t.tinyint](r, _ltypes, _column) { 313 | return (row, column) => duck.duckffi_value_i8(r, row, column); 314 | }, 315 | [_t.ubigint](r, _ltypes, _column) { 316 | return (row, column) => duck.duckffi_value_u64(r, row, column); 317 | }, 318 | [_t.integer](r, _ltypes, _column) { 319 | return (row, column) => duck.duckffi_value_i32(r, row, column); 320 | }, 321 | [_t.utinyint](r, _ltypes, _column) { 322 | return (row, column) => duck.duckffi_value_u8(r, row, column); 323 | }, 324 | [_t.smallint](r, _ltypes, _column) { 325 | return (row, column) => duck.duckffi_value_i16(r, row, column); 326 | }, 327 | [_t.uinteger](r, _ltypes, _column) { 328 | return (row, column) => duck.duckffi_value_u32(r, row, column); 329 | }, 330 | [_t.usmallint](r, _ltypes, _column) { 331 | return (row, column) => duck.duckffi_value_u16(r, row, column); 332 | }, 333 | [_t.boolean](r, _ltypes, _column) { 334 | return (row, column) => duck.duckffi_value_boolean(r, row, column); 335 | }, 336 | [_t.timestamp](r, _ltypes, _column) { 337 | return (row, column) => duck.duckffi_value_timestamp_ms(r, row, column); 338 | }, 339 | [_t.varchar](r, _ltypes, _column) { 340 | return (row, column) => 341 | getCString(duck.duckffi_value_string(r, row, column)); 342 | }, 343 | [_t.date](r, _ltypes, _column) { 344 | return (row, column) => 345 | 24 * 60 * 60 * 1000 * duck.duckffi_value_date(r, row, column); 346 | }, 347 | 348 | [_t.blob](r, _ltypes, _column) { 349 | return (row, column) => { 350 | const blob = duck.duckffi_value_blob(r, row, column); 351 | const ab = toArrayBuffer( 352 | duck.duckffi_blob_data(blob), 353 | 0, 354 | duck.duckffi_blob_size(blob), 355 | ); 356 | 357 | return (blob_gc.register(ab, blob), new Uint8Array(ab)); 358 | }; 359 | }, 360 | 361 | [_t.interval](r, _ltypes, _column) { 362 | return (row, column) => { 363 | const ms = duck.duckffi_value_interval_days(r, row, column); 364 | 365 | const days = (ms / (24 * 60 * 60 * 1000)) | 0; 366 | 367 | return { 368 | days: days, 369 | ms: ms - days * (24 * 60 * 60 * 1000), 370 | months: duck.duckffi_value_interval_months(r, row, column), 371 | }; 372 | }; 373 | }, 374 | 375 | [_t.enum](r, ltypes, _column) { 376 | const ltype = ltypes[_column] = duck.duckffi_column_ltype(r, _column); 377 | 378 | const names = new Array(duck.duckffi_enum_size(ltype)); 379 | const tf = _tm[duck.duckffi_enum_type(ltype)](r, ltypes, _column); 380 | 381 | return (row, column) => { 382 | const offset = tf(row, column); 383 | 384 | let name = names[offset]; 385 | 386 | if (name === undefined) { 387 | const s = duck.duckffi_enum_string(ltype, offset); 388 | name = names[offset] = getCString(s); 389 | duck.duckffi_dfree(s); 390 | } 391 | 392 | return name; 393 | }; 394 | }, 395 | }; 396 | 397 | const _tms = { 398 | [_t.time](r, _ltypes, _column) { 399 | return (row, column) => duck.duckffi_value_time_slow(r, row, column); 400 | }, 401 | [_t.float](r, _ltypes, _column) { 402 | return (row, column) => duck.duckffi_value_f32_slow(r, row, column); 403 | }, 404 | [_t.double](r, _ltypes, _column) { 405 | return (row, column) => duck.duckffi_value_f64_slow(r, row, column); 406 | }, 407 | [_t.bigint](r, _ltypes, _column) { 408 | return (row, column) => duck.duckffi_value_i64_slow(r, row, column); 409 | }, 410 | [_t.tinyint](r, _ltypes, _column) { 411 | return (row, column) => duck.duckffi_value_i8_slow(r, row, column); 412 | }, 413 | [_t.ubigint](r, _ltypes, _column) { 414 | return (row, column) => duck.duckffi_value_u64_slow(r, row, column); 415 | }, 416 | [_t.integer](r, _ltypes, _column) { 417 | return (row, column) => duck.duckffi_value_i32_slow(r, row, column); 418 | }, 419 | [_t.utinyint](r, _ltypes, _column) { 420 | return (row, column) => duck.duckffi_value_u8_slow(r, row, column); 421 | }, 422 | [_t.smallint](r, _ltypes, _column) { 423 | return (row, column) => duck.duckffi_value_i16_slow(r, row, column); 424 | }, 425 | [_t.uinteger](r, _ltypes, _column) { 426 | return (row, column) => duck.duckffi_value_u32_slow(r, row, column); 427 | }, 428 | [_t.usmallint](r, _ltypes, _column) { 429 | return (row, column) => duck.duckffi_value_u16_slow(r, row, column); 430 | }, 431 | [_t.boolean](r, _ltypes, _column) { 432 | return (row, column) => duck.duckffi_value_boolean_slow(r, row, column); 433 | }, 434 | [_t.timestamp](r, _ltypes, _column) { 435 | return (row, column) => 436 | duck.duckffi_value_timestamp_ms_slow(r, row, column); 437 | }, 438 | [_t.varchar](r, _ltypes, _column) { 439 | return (row, column) => 440 | getCString(duck.duckffi_value_string_slow(r, row, column)); 441 | }, 442 | [_t.date](r, _ltypes, _column) { 443 | return (row, column) => 444 | 24 * 60 * 60 * 1000 * duck.duckffi_value_date_slow(r, row, column); 445 | }, 446 | 447 | [_t.blob](r, _ltypes, _column) { 448 | return (row, column) => { 449 | const blob = duck.duckffi_value_blob_slow(r, row, column); 450 | const ab = toArrayBuffer( 451 | duck.duckffi_blob_data(blob), 452 | 0, 453 | duck.duckffi_blob_size(blob), 454 | ); 455 | 456 | return (blob_gc.register(ab, blob), new Uint8Array(ab)); 457 | }; 458 | }, 459 | 460 | [_t.interval](r, _ltypes, _column) { 461 | return (row, column) => { 462 | const ms = duck.duckffi_value_interval_days_slow(r, row, column); 463 | 464 | const days = (ms / (24 * 60 * 60 * 1000)) | 0; 465 | 466 | return { 467 | days: days, 468 | ms: ms - days * (24 * 60 * 60 * 1000), 469 | months: duck.duckffi_value_interval_months_slow(r, row, column), 470 | }; 471 | }; 472 | }, 473 | 474 | [_t.enum](r, ltypes, _column) { 475 | const ltype = ltypes[_column] = duck.duckffi_column_ltype(r, _column); 476 | 477 | const names = new Array(duck.duckffi_enum_size(ltype)); 478 | const tf = _tms[duck.duckffi_enum_type(ltype)](r, ltypes, _column); 479 | 480 | return (row, column) => { 481 | const offset = tf(row, column); 482 | 483 | let name = names[offset]; 484 | 485 | if (name === undefined) { 486 | const s = duck.duckffi_enum_string(ltype, offset); 487 | name = names[offset] = getCString(s); 488 | duck.duckffi_dfree(s); 489 | } 490 | 491 | return name; 492 | }; 493 | }, 494 | }; 495 | 496 | export function query(c, query) { 497 | const r = duck.duckffi_query(c, ptr(utf8e.encode(query + "\0"))); 498 | 499 | { 500 | const e = duck.duckffi_result_error(r); 501 | 502 | if (e) { 503 | const s = getCString(e); 504 | throw (duck.duckffi_free_result(r), new Error(s)); 505 | } 506 | } 507 | 508 | const rows = duck.duckffi_row_count(r); 509 | const columns = duck.duckffi_column_count(r); 510 | if (0 === rows) return (duck.duckffi_free_result(r), []); 511 | 512 | const a = new Array(rows); 513 | const nulls = new Array(columns); 514 | const names = new Array(columns); 515 | const types = new Array(columns); 516 | const nullsv = new Array(columns); 517 | const ltypes = new Array(columns); 518 | 519 | for (let offset = 0; offset < columns; offset++) { 520 | nulls[offset] = duck.duckffi_null_bitmap(r, rows, offset); 521 | names[offset] = getCString(duck.duckffi_column_name(r, offset)); 522 | types[offset] = _tm[duck.duckffi_column_type(r, offset)](r, ltypes, offset); 523 | nullsv[offset] = new Uint8Array( 524 | toArrayBuffer(nulls[offset], 0, Math.ceil(rows / 8)), 525 | ); 526 | } 527 | 528 | try { 529 | for (let offset = 0; rows > offset; offset++) { 530 | const row = a[offset] = {}; 531 | 532 | for (let column = 0; column < columns; column++) { 533 | if (bitmap_get(nullsv[column], offset)) { 534 | row[names[column]] = null; 535 | } else { 536 | row[names[column]] = types[column](offset, column); 537 | } 538 | } 539 | } 540 | 541 | return a; 542 | } finally { 543 | const len = ltypes.length; 544 | 545 | for (let offset = 0; offset < columns; offset++) { 546 | duck.duckffi_free(nulls[offset]); 547 | } 548 | 549 | for (let offset = 0; len > offset; offset++) { 550 | const x = ltypes[offset]; 551 | if (x) duck.duckffi_free_ltype(x); 552 | } 553 | 554 | duck.duckffi_free_result(r); 555 | } 556 | } 557 | 558 | export function* stream(c, query) { 559 | const r = duck.duckffi_query(c, ptr(utf8e.encode(query + "\0"))); 560 | 561 | { 562 | const e = duck.duckffi_result_error(r); 563 | 564 | if (e) { 565 | const s = getCString(e); 566 | throw (duck.duckffi_free_result(r), new Error(s)); 567 | } 568 | } 569 | 570 | const t = {}; 571 | result_gc.register(t, r, t); 572 | const slow = duck.duckffi_row_count_large(r); 573 | const columns = duck.duckffi_column_count(r); 574 | 575 | const names = new Array(columns); 576 | const types = new Array(columns); 577 | const ltypes = new Array(columns); 578 | 579 | for (let offset = 0; offset < columns; offset++) { 580 | names[offset] = getCString(duck.duckffi_column_name(r, offset)); 581 | types[offset] = (!slow ? _tm : _tms)[duck.duckffi_column_type(r, offset)]( 582 | r, 583 | ltypes, 584 | offset, 585 | ); 586 | } 587 | 588 | const len = ltypes.length; 589 | 590 | for (let offset = 0; len > offset; offset++) { 591 | const ltype = ltypes[offset]; 592 | if (ltype) ltype_gc.register(t, ltype, t); 593 | } 594 | 595 | if (!slow) { 596 | const rows = duck.duckffi_row_count(r); 597 | 598 | for (let offset = 0; rows > offset; offset++) { 599 | const row = {}; 600 | 601 | for (let column = 0; column < columns; column++) { 602 | if (duck.duckffi_value_is_null(r, offset, column)) { 603 | row[names[column]] = null; 604 | } else { 605 | row[names[column]] = types[column](offset, column); 606 | } 607 | } 608 | 609 | yield row; 610 | } 611 | } else { 612 | const rows = duck.duckffi_row_count_slow(r); 613 | 614 | for (let offset = 0n; rows > offset; offset++) { 615 | const row = {}; 616 | 617 | for (let column = 0; column < columns; column++) { 618 | if (duck.duckffi_value_is_null_slow(r, offset, column)) { 619 | row[names[column]] = null; 620 | } else { 621 | row[names[column]] = types[column](offset, column); 622 | } 623 | } 624 | 625 | yield row; 626 | } 627 | } 628 | 629 | for (let offset = 0; len > offset; offset++) { 630 | const x = ltypes[offset]; 631 | if (x) duck.duckffi_free_ltype(x); 632 | } 633 | 634 | ltype_gc.unregister(t); 635 | result_gc.unregister(t); 636 | duck.duckffi_free_result(r); 637 | } 638 | 639 | const _trm = { 640 | [_t.enum](n, offset) { 641 | return _trm[_t.varchar](n, offset); 642 | }, 643 | [_t.time](n, offset) { 644 | return `if (type === 'string') { ${_trm[_t.varchar](n, offset)} } else { ${ 645 | _trm[_t.timestamp](n, offset) 646 | } }`; 647 | }, 648 | [_t.date](n, offset) { 649 | return `if (type === 'string') { ${_trm[_t.varchar](n, offset)} } else { ${ 650 | _trm[_t.timestamp](n, offset) 651 | } }`; 652 | }, 653 | [_t.float](n, offset) { 654 | return `if (duck.duckffi_bind_f32(p, ${offset}, ${n})) throw new Error('failed to bind float at ${offset}');`; 655 | }, 656 | [_t.bigint](n, offset) { 657 | return `if (duck.duckffi_bind_i64(p, ${offset}, ${n})) throw new Error('failed to bind bigint at ${offset}');`; 658 | }, 659 | [_t.double](n, offset) { 660 | return `if (duck.duckffi_bind_f64(p, ${offset}, ${n})) throw new Error('failed to bind double at ${offset}');`; 661 | }, 662 | [_t.ubigint](n, offset) { 663 | return `if (duck.duckffi_bind_u64(p, ${offset}, ${n})) throw new Error('failed to bind ubigint at ${offset}');`; 664 | }, 665 | [_t.boolean](n, offset) { 666 | return `if (duck.duckffi_bind_bool(p, ${offset}, ${n})) throw new Error('failed to bind boolean at ${offset}');`; 667 | }, 668 | [_t.tinyint](n, offset) { 669 | return `if (duck.duckffi_bind_i8(p, ${offset}, ${n} | 0)) throw new Error('failed to bind tinyint at ${offset}');`; 670 | }, 671 | [_t.integer](n, offset) { 672 | return `if (duck.duckffi_bind_i32(p, ${offset}, ${n} | 0)) throw new Error('failed to bind integer at ${offset}');`; 673 | }, 674 | [_t.utinyint](n, offset) { 675 | return `if (duck.duckffi_bind_u8(p, ${offset}, ${n} | 0)) throw new Error('failed to bind utinyint at ${offset}');`; 676 | }, 677 | [_t.smallint](n, offset) { 678 | return `if (duck.duckffi_bind_i16(p, ${offset}, ${n} | 0)) throw new Error('failed to bind smallint at ${offset}');`; 679 | }, 680 | [_t.usmallint](n, offset) { 681 | return `if (duck.duckffi_bind_u16(p, ${offset}, ${n} | 0)) throw new Error('failed to bind usmallint at ${offset}');`; 682 | }, 683 | [_t.uinteger](n, offset) { 684 | return `if (duck.duckffi_bind_u32(p, ${offset}, ${n} >>> 0)) throw new Error('failed to bind uinteger at ${offset}');`; 685 | }, 686 | [_t.timestamp](n, offset) { 687 | return `if (duck.duckffi_bind_timestamp(p, ${offset}, ${n})) throw new Error('failed to bind timestamp at ${offset}');`; 688 | }, 689 | [_t.blob](n, offset) { 690 | return `if (duck.duckffi_bind_blob(p, ${offset}, ptr(${n}), ${n}.byteLength)) throw new Error('failed to bind blob at ${offset}');`; 691 | }, 692 | 693 | [_t.varchar](n, offset) { 694 | return ` 695 | const ${n}_utf8 = utf8e.encode(${n}); 696 | if (duck.duckffi_bind_string(p, ${offset}, ptr(${n}_utf8), ${n}_utf8.length)) throw new Error('failed to bind varchar at ${offset}'); 697 | `; 698 | }, 699 | 700 | [_t.interval](n, offset) { 701 | return ` 702 | if (type === 'string') { 703 | ${_trm[_t.varchar](n, offset)}; 704 | } else { 705 | if (duck.duckffi_bind_interval(p, ${offset}, ${n}.ms, ${n}.days, ${n}.months)) throw new Error('failed to bind interval at ${offset}'); 706 | } 707 | `; 708 | }, 709 | }; 710 | 711 | const _trmc = { 712 | [_t.enum](n) { 713 | return `(type === 'string')`; 714 | }, 715 | [_t.float](n) { 716 | return `(type === 'number')`; 717 | }, 718 | [_t.double](n) { 719 | return `(type === 'number')`; 720 | }, 721 | [_t.varchar](n) { 722 | return `(type === 'string')`; 723 | }, 724 | [_t.boolean](n) { 725 | return `(type === 'boolean')`; 726 | }, 727 | [_t.time](n) { 728 | return `(type === 'string') || (type === 'number')`; 729 | }, 730 | [_t.date](n) { 731 | return `(type === 'number') || (type === 'string')`; 732 | }, 733 | [_t.timestamp](n) { 734 | return `(type === 'number') || (type === 'bigint')`; 735 | }, 736 | [_t.utinyint](n) { 737 | return `(type === 'number') && (0 <= ${n}) && (${n} <= 255)`; 738 | }, 739 | [_t.tinyint](n) { 740 | return `(type === 'number') && (${n} <= 127) && (${n} >= -127)`; 741 | }, 742 | [_t.usmallint](n) { 743 | return `(type === 'number') && (0 <= ${n}) && (${n} <= 65535)`; 744 | }, 745 | [_t.blob](n) { 746 | return `(ArrayBuffer.isView(${n})) || (${n} instanceof ArrayBuffer)`; 747 | }, 748 | [_t.uinteger](n) { 749 | return `(type === 'number') && (0 <= ${n}) && (${n} <= 4294967295)`; 750 | }, 751 | [_t.smallint](n) { 752 | return `(type === 'number') && (${n} <= 32767) && (${n} >= -32767)`; 753 | }, 754 | [_t.integer](n) { 755 | return `(type === 'number') && (${n} <= 2147483647) && (${n} >= -2147483647)`; 756 | }, 757 | [_t.ubigint](n) { 758 | return `(type === 'bigint') && (0n <= ${n}) && (${n} <= 18446744073709551615n)`; 759 | }, 760 | [_t.bigint](n) { 761 | return `(type === 'bigint') && (${n} <= 9223372036854775807n) && (${n} >= -9223372036854775807n)`; 762 | }, 763 | [_t.interval](n) { 764 | return `(type === 'string') || ((type === 'object') && ('number' === typeof ${n}.ms) && ('number' === typeof ${n}.days) && ('number' === typeof ${n}.months))`; 765 | }, 766 | }; 767 | 768 | export function prepare(c, query) { 769 | const p = duck.duckffi_prepare(c, ptr(utf8e.encode(query + "\0"))); 770 | 771 | { 772 | const e = duck.duckffi_prepare_error(p); 773 | 774 | if (e) { 775 | const s = getCString(e); 776 | throw (duck.duckffi_free_prepare(p), new Error(s)); 777 | } 778 | } 779 | 780 | const ctx = {}; 781 | prepare_gc.register(ctx, p, ctx); 782 | const len = duck.duckffi_param_count(p); 783 | 784 | const types = new Array(len); 785 | const names = new Array(len); 786 | 787 | for (let offset = 0; len > offset; offset++) { 788 | types[offset] = duck.duckffi_param_type(p, offset); 789 | names[offset] = `$${offset}_${_tr[types[offset]]}`; 790 | } 791 | 792 | ctx.close = () => { 793 | prepare_gc.unregister(ctx); 794 | duck.duckffi_free_prepare(p); 795 | }; 796 | 797 | ctx.query = new Function( 798 | ...names, 799 | ` 800 | function ptr(v) { return Deno.UnsafePointer.of(v) }; 801 | function getCString(v) { 802 | const view = new Deno.UnsafePointerView(v); 803 | return view.getCString(); 804 | } 805 | const { p, _tm, ctx, duck, utf8e, bitmap_get } = this; 806 | 807 | ${ 808 | names.map((name, offset) => ` 809 | if (null === ${name}) duck.duckffi_bind_null(p, ${offset}); 810 | else { 811 | const type = typeof ${name}; 812 | if (!(${_trmc[types[offset]](name)})) throw new TypeError('expected ${ 813 | _tr[types[offset]] 814 | } at ${offset}'); 815 | 816 | ${_trm[types[offset]](name, offset)} 817 | } 818 | `).join("\n") 819 | } 820 | 821 | const r = duck.duckffi_query_prepared(p); 822 | 823 | { 824 | const e = duck.duckffi_result_error(r); 825 | 826 | if (e) { 827 | const s = getCString(e); 828 | throw (duck.duckffi_free_result(r), new Error(s)); 829 | } 830 | } 831 | 832 | const rows = duck.duckffi_row_count(r); 833 | const columns = duck.duckffi_column_count(r); 834 | 835 | const a = new Array(rows); 836 | const names = new Array(columns); 837 | const types = new Array(columns); 838 | const ltypes = new Array(columns); 839 | const typesfn = new Array(columns); 840 | 841 | for (let offset = 0; offset < columns; offset++) { 842 | types[offset] = duck.duckffi_column_type(r, offset); 843 | typesfn[offset] = _tm[types[offset]](r, ltypes, offset); 844 | names[offset] = getCString(duck.duckffi_column_name(r, offset)); 845 | } 846 | 847 | try { 848 | { 849 | ctx.query = new Function(${names.map((n) => `'${n}', `).join("")} \` 850 | function ptr(v) { return Deno.UnsafePointer.of(v) }; 851 | function toArrayBuffer(v, start, offset) { 852 | const view = new Deno.UnsafePointerView(v); 853 | } 854 | const { p, _tm, duck, utf8e, bitmap_get } = this; 855 | 856 | ${ 857 | names.map((name, offset) => ` 858 | if (null === ${name}) duck.duckffi_bind_null(p, ${offset}); 859 | else { 860 | const type = typeof ${name}; 861 | if (!(${ 862 | _trmc[types[offset]](name) 863 | })) throw new TypeError('expected ${_tr[types[offset]]} at ${offset}'); 864 | 865 | ${_trm[types[offset]](name, offset)} 866 | } 867 | `).join("\n") 868 | } 869 | 870 | const r = duck.duckffi_query_prepared(p); 871 | 872 | { 873 | const e = duck.duckffi_result_error(r); 874 | 875 | if (e) { 876 | const s = new CString(e); 877 | throw (duck.duckffi_free_result(r), new Error(s)); 878 | } 879 | } 880 | 881 | const rows = duck.duckffi_row_count(r); 882 | const ltypes = new Array(\${ltypes.length}); 883 | if (0 === rows) return (duck.duckffi_free_result(r), []); 884 | 885 | \${types.map((type, column) => \` 886 | const _tm_\${column}_\${type} = _tm[\${type}](r, ltypes, \${column}); 887 | const nulls_\${column} = duck.duckffi_null_bitmap(r, rows, \${column}); 888 | const nulls_view_\${column} = new Uint8Array(toArrayBuffer(nulls_\${column}, 0, Math.ceil(rows / 8))); 889 | \`).join('\\n')} 890 | 891 | try { 892 | const a = new Array(rows); 893 | 894 | for (let offset = 0; rows > offset; offset++) { 895 | a[offset] = { 896 | \${names.map((name, column) => \` 897 | "\${name}": (bitmap_get(nulls_view_\${column}, offset)) ? null : _tm_\${column}_\${types[column]}(offset, \${column}), 898 | \`.trim()).join('\\n')} 899 | }; 900 | } 901 | 902 | return a; 903 | } finally { 904 | for (let offset = 0; \${ltypes.length} > offset; offset++) { 905 | const x = ltypes[offset]; 906 | if (x) duck.duckffi_free_ltype(x); 907 | } 908 | 909 | \${new Array(columns).fill(0).map((_, column) => \` 910 | duck.duckffi_free(nulls_\${column}); 911 | \`).join('\\n')} 912 | 913 | duck.duckffi_free_result(r); 914 | } 915 | \`).bind({ p, _tm, ctx, duck, utf8e, bitmap_get }); 916 | } 917 | 918 | for (let offset = 0; rows > offset; offset++) { 919 | const row = a[offset] = {}; 920 | 921 | for (let column = 0; column < columns; column++) { 922 | if (duck.duckffi_value_is_null(r, offset, column)) { 923 | row[names[column]] = null; 924 | } else { 925 | row[names[column]] = typesfn[column](offset, column); 926 | } 927 | } 928 | } 929 | 930 | return a; 931 | } finally { 932 | const len = ltypes.length; 933 | 934 | for (let offset = 0; len > offset; offset++) { 935 | const x = ltypes[offset]; 936 | if (x) duck.duckffi_free_ltype(x); 937 | } 938 | 939 | duck.duckffi_free_result(r); 940 | } 941 | `, 942 | ).bind({ p, _tm, ctx, duck, utf8e, bitmap_get }); 943 | 944 | ctx.stream = new GeneratorFunction( 945 | ...names, 946 | ` 947 | function ptr(v) { return Deno.UnsafePointer.of(v) }; 948 | function getCString(v) { 949 | const view = new Deno.UnsafePointerView(v); 950 | return view.getCString(); 951 | } 952 | const GeneratorFunction = (function* () { }).constructor; 953 | const { p, _tm, ctx, _tms, duck, utf8e, ltype_gc, result_gc } = this; 954 | 955 | ${ 956 | names.map((name, offset) => ` 957 | if (null === ${name}) duck.duckffi_bind_null(p, ${offset}); 958 | else { 959 | const type = typeof ${name}; 960 | if (!(${_trmc[types[offset]](name)})) throw new TypeError('expected ${ 961 | _tr[types[offset]] 962 | } at ${offset}'); 963 | 964 | ${_trm[types[offset]](name, offset)} 965 | } 966 | `).join("\n") 967 | } 968 | 969 | const r = duck.duckffi_query_prepared(p); 970 | 971 | const t = {}; 972 | result_gc.register(t, r, t); 973 | 974 | { 975 | const e = duck.duckffi_result_error(r); 976 | 977 | if (e) { 978 | const s = getCString(e); 979 | throw (duck.duckffi_free_result(r), new Error(s)); 980 | } 981 | } 982 | 983 | const slow = duck.duckffi_row_count_large(r); 984 | const columns = duck.duckffi_column_count(r); 985 | 986 | const names = new Array(columns); 987 | const types = new Array(columns); 988 | const ltypes = new Array(columns); 989 | const typesfn = new Array(columns); 990 | 991 | for (let offset = 0; offset < columns; offset++) { 992 | types[offset] = duck.duckffi_column_type(r, offset); 993 | names[offset] = getCString(duck.duckffi_column_name(r, offset)); 994 | typesfn[offset] = (!slow ? _tm : _tms)[types[offset]](r, ltypes, offset); 995 | } 996 | 997 | const len = ltypes.length; 998 | 999 | for (let offset = 0; len > offset; offset++) { 1000 | const x = ltypes[offset]; 1001 | if (x) ltype_gc.register(t, x, t); 1002 | } 1003 | 1004 | try { 1005 | { 1006 | ctx.stream = new GeneratorFunction(${ 1007 | names.map((n) => `'${n}', `).join("") 1008 | } \` 1009 | function ptr(v) { return Deno.UnsafePointer.of(v) }; 1010 | function getCString(v) { 1011 | const view = new Deno.UnsafePointerView(v); 1012 | return view.getCString(); 1013 | } 1014 | const { p, _tm, _tms, duck, utf8e, ltype_gc, result_gc } = this; 1015 | 1016 | ${ 1017 | names.map((name, offset) => ` 1018 | if (null === ${name}) duck.duckffi_bind_null(p, ${offset}); 1019 | else { 1020 | const type = typeof ${name}; 1021 | if (!(${ 1022 | _trmc[types[offset]](name) 1023 | })) throw new TypeError('expected ${_tr[types[offset]]} at ${offset}'); 1024 | 1025 | ${_trm[types[offset]](name, offset)} 1026 | } 1027 | `).join("\n") 1028 | } 1029 | 1030 | const r = duck.duckffi_query_prepared(p); 1031 | 1032 | { 1033 | const e = duck.duckffi_result_error(r); 1034 | 1035 | if (e) { 1036 | const s = getCString(e); 1037 | throw (duck.duckffi_free_result(r), new Error(s)); 1038 | } 1039 | } 1040 | 1041 | const t = {}; 1042 | result_gc.register(t, r, t); 1043 | const ltypes = new Array(\${len}); 1044 | const slow = duck.duckffi_row_count_large(r); 1045 | 1046 | try { 1047 | if (!slow) { 1048 | const rows = duck.duckffi_row_count(r); 1049 | 1050 | \${types.map((type, column) => \` 1051 | const _tm_\${column}_\${type} = _tm[\${type}](r, ltypes, \${column}); 1052 | \`).join('\\n')} 1053 | 1054 | for (let offset = 0; \${len} > offset; offset++) { 1055 | const x = ltypes[offset]; 1056 | if (x) ltype_gc.register(t, x, t); 1057 | } 1058 | 1059 | for (let offset = 0; rows > offset; offset++) { 1060 | yield { 1061 | \${names.map((name, column) => \` 1062 | "\${name}": duck.duckffi_value_is_null(r, offset, \${column}) ? null : _tm_\${column}_\${types[column]}(offset, \${column}), 1063 | \`.trim()).join('\\n')} 1064 | }; 1065 | } 1066 | } else { 1067 | const rows = duck.duckffi_row_count_slow(r); 1068 | 1069 | \${types.map((type, column) => \` 1070 | const _tms_\${column}_\${type} = _tms[\${type}](r, ltypes, \${column}); 1071 | \`).join('\\n')} 1072 | 1073 | for (let offset = 0; \${len} > offset; offset++) { 1074 | const x = ltypes[offset]; 1075 | if (x) ltype_gc.register(t, x, t); 1076 | } 1077 | 1078 | for (let offset = 0n; rows > offset; offset++) { 1079 | yield { 1080 | \${names.map((name, column) => \` 1081 | "\${name}": duck.duckffi_value_is_null_slow(r, offset, \${column}) ? null : _tms_\${column}_\${types[column]}(offset, \${column}), 1082 | \`.trim()).join('\\n')} 1083 | }; 1084 | } 1085 | } 1086 | } finally { 1087 | for (let offset = 0; \${len} > offset; offset++) { 1088 | const x = ltypes[offset]; 1089 | if (x) duck.duckffi_free_ltype(x); 1090 | } 1091 | 1092 | ltype_gc.unregister(t); 1093 | result_gc.unregister(t); 1094 | duck.duckffi_free_result(r); 1095 | } 1096 | \`).bind({ p, _tm, ctx, _tms, duck, utf8e, ltype_gc, result_gc }); 1097 | } 1098 | 1099 | if (!slow) { 1100 | const rows = duck.duckffi_row_count(r); 1101 | 1102 | for (let offset = 0; rows > offset; offset++) { 1103 | const row = {}; 1104 | 1105 | for (let column = 0; column < columns; column++) { 1106 | if (duck.duckffi_value_is_null(r, offset, column)) { 1107 | row[names[column]] = null; 1108 | } else { 1109 | row[names[column]] = typesfn[column](offset, column); 1110 | } 1111 | } 1112 | 1113 | yield row; 1114 | } 1115 | } else { 1116 | const rows = duck.duckffi_row_count_slow(r); 1117 | 1118 | for (let offset = 0n; rows > offset; offset++) { 1119 | const row = {}; 1120 | 1121 | for (let column = 0; column < columns; column++) { 1122 | if (duck.duckffi_value_is_null_slow(r, offset, column)) { 1123 | row[names[column]] = null; 1124 | } else { 1125 | row[names[column]] = typesfn[column](offset, column); 1126 | } 1127 | } 1128 | 1129 | yield row; 1130 | } 1131 | } 1132 | } finally { 1133 | for (let offset = 0; len > offset; offset++) { 1134 | const x = ltypes[offset]; 1135 | if (x) duck.duckffi_free_ltype(x); 1136 | } 1137 | 1138 | ltype_gc.unregister(t); 1139 | result_gc.unregister(t); 1140 | duck.duckffi_free_result(r); 1141 | } 1142 | `, 1143 | ).bind({ p, _tm, ctx, _tms, duck, utf8e, ltype_gc, result_gc }); 1144 | 1145 | ctx.c = null; 1146 | 1147 | return ctx; 1148 | } 1149 | -------------------------------------------------------------------------------- /lib_test.ts: -------------------------------------------------------------------------------- 1 | import { connect, open, prepare, query } from "./lib.js"; 2 | import { assertEquals } from "https://deno.land/std@0.149.0/testing/asserts.ts"; 3 | 4 | Deno.test("select * from test", () => { 5 | const db = open(":memory:"); 6 | const connection = connect(db); 7 | 8 | query( 9 | connection, 10 | ` 11 | create type mood as enum ('sad', 'ok', 'happy'); 12 | 13 | create table test (a varchar, m mood); 14 | insert into test (a, m) values ('a', 'sad'); 15 | `, 16 | ); 17 | 18 | const p = prepare(connection, `select * from test`); 19 | assertEquals(p.query(), [{ a: "a", m: "sad" }]); 20 | }); 21 | 22 | Deno.test("fts", () => { 23 | const db = open(":memory:"); 24 | const connection = connect(db); 25 | 26 | query( 27 | connection, 28 | ` 29 | install 'fts'; load 'fts'; 30 | `, 31 | ); 32 | }); 33 | -------------------------------------------------------------------------------- /mod.ts: -------------------------------------------------------------------------------- 1 | import * as lib from "./lib.js"; 2 | 3 | export function open(path: string): Database { 4 | return new Database(lib.open(path)); 5 | } 6 | 7 | const db_gc = new FinalizationRegistry((ptr) => lib.close(ptr)); 8 | const cc_gc = new FinalizationRegistry((ptr) => lib.disconnect(ptr)); 9 | 10 | class Database { 11 | #ptr: Deno.PointerValue; 12 | 13 | constructor(ptr: Deno.PointerValue) { 14 | this.#ptr = ptr; 15 | db_gc.register(this, ptr, this); 16 | } 17 | 18 | close() { 19 | lib.close(this.#ptr); 20 | db_gc.unregister(this); 21 | } 22 | connect(): Connection { 23 | return new Connection(this, lib.connect(this.#ptr)); 24 | } 25 | } 26 | 27 | // TODO: this needs proper typings. 28 | interface PreparedStatement { 29 | close(): void; 30 | query(...params: any[]): T[]; 31 | stream(): Generator; 32 | } 33 | 34 | class Connection { 35 | #db: Database; 36 | #ptr: Deno.PointerValue; 37 | 38 | constructor(db: Database, ptr: Deno.PointerValue) { 39 | this.#db = db; 40 | this.#ptr = ptr; 41 | cc_gc.register(this, ptr, this); 42 | } 43 | 44 | query(sql: string): T[] { 45 | return lib.query(this.#ptr, sql); 46 | } 47 | 48 | stream(sql: string): Generator { 49 | return lib.stream(this.#ptr, sql); 50 | } 51 | 52 | close(): void { 53 | lib.disconnect(this.#ptr); 54 | cc_gc.unregister(this); 55 | } 56 | 57 | prepare(sql: string): PreparedStatement { 58 | const p = lib.prepare(this.#ptr, sql); 59 | p.c = this; 60 | return p; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /mod_test.ts: -------------------------------------------------------------------------------- 1 | import { assertObjectMatch } from "https://deno.land/std@0.195.0/testing/asserts.ts"; 2 | 3 | import { open } from "./mod.ts"; 4 | 5 | Deno.test("BigInt issue in query statement", () => { 6 | const db = open(":memory:"); 7 | const connection = db.connect(); 8 | assertObjectMatch( 9 | connection.query("SELECT 1234 AS result")[0], 10 | { result: 1234 }, 11 | ); 12 | connection.close(); 13 | db.close(); 14 | }); 15 | 16 | Deno.test("BigInt issue in prepare statement", () => { 17 | const db = open(":memory:"); 18 | const connection = db.connect(); 19 | 20 | const prepared = connection.prepare( 21 | "select ?::INTEGER as number, ?::VARCHAR as text", 22 | ); 23 | 24 | assertObjectMatch( 25 | prepared.query(1337, "foo")[0], 26 | { number: 1337, text: "foo" }, 27 | ); 28 | 29 | assertObjectMatch( 30 | prepared.query(null, "bar")[0], 31 | { number: 0, text: "bar" }, 32 | ); 33 | 34 | connection.close(); 35 | db.close(); 36 | }); 37 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 |

x/duckdb

2 |
blazing fast duckdb bindings for deno
3 | 4 |
5 | 6 | ## performance 7 | 8 | - 2-4x faster than Bun. 9 | - 10x faster than Node. 10 | 11 |
View source 12 | 13 | ```typescript 14 | import { open } from "jsr:@divy/duckdb@0.2"; 15 | 16 | const db = open("/tmp/test.db"); 17 | const connection = db.connect(); 18 | 19 | const q = "select i, i as a from generate_series(1, 100000) s(i)"; 20 | 21 | const p = connection.prepare(q); 22 | console.log("benchmarking query: " + q); 23 | 24 | bench("duckdb", () => { 25 | p.query(); 26 | }); 27 | 28 | await run({ percentiles: false }); 29 | 30 | connection.close(); 31 | db.close(); 32 | ``` 33 | 34 |
35 | 36 | 37 | ``` 38 | # Deno canary 39 | 40 | benchmarking query: select i, i as a from generate_series(1, 100000) s(i) 41 | cpu: Apple M1 42 | runtime: deno 1.24.0 (aarch64-apple-darwin) 43 | 44 | benchmark time (avg) (min … max) 45 | ------------------------------------------------- 46 | duckdb 4.66 ms/iter (4.26 ms … 7.47 ms) 47 | ``` 48 | 49 | ``` 50 | # Bun 51 | benchmarking query: select i, i as a from generate_series(1, 100000) s(i) 52 | cpu: Apple M1 53 | runtime: bun 0.1.4 (arm64-darwin) 54 | 55 | benchmark time (avg) (min … max) 56 | ------------------------------------------------- 57 | duckdb 8.69 ms/iter (6.26 ms … 11.4 ms) 58 | ``` 59 | 60 |
View JIT benchmarks 61 | 62 | ```typescript 63 | const db = open(":memory:"); 64 | const connection = db.connect(db); 65 | const q = "select i, i as a from generate_series(1, 100000) s(i)"; 66 | 67 | const p = connection.prepare(q); 68 | console.log("benchmarking query: " + q); 69 | 70 | group("query", () => { 71 | bench("jit query()", () => p.query()); 72 | bench("query()", () => connection.query(q)); 73 | }); 74 | 75 | group("stream", () => { 76 | bench("jit stream()", () => { 77 | for (const x of p.stream()) x; 78 | }); 79 | 80 | bench("stream()", () => { 81 | for (const x of connection.stream(q)) x; 82 | }); 83 | }); 84 | ``` 85 | 86 | ``` 87 | # Deno canary 88 | 89 | benchmarking query: select i, i as a from generate_series(1, 100000) s(i) 90 | cpu: Apple M1 91 | runtime: deno 1.24.0 (aarch64-apple-darwin) 92 | 93 | benchmark time (avg) (min … max) 94 | ---------------------------------------------------- 95 | query 96 | ---------------------------------------------------- 97 | jit query() 4.79 ms/iter (4.31 ms … 12.06 ms) 98 | query() 8.26 ms/iter (7.54 ms … 16.44 ms) 99 | 100 | summary for query 101 | jit query() 102 | 1.72x faster than query() 103 | 104 | stream 105 | ---------------------------------------------------- 106 | jit stream() 9.96 ms/iter (9.84 ms … 10.18 ms) 107 | stream() 10.97 ms/iter (10.82 ms … 11.35 ms) 108 | 109 | summary for stream 110 | jit stream() 111 | 1.1x faster than stream() 112 | ``` 113 | 114 | ``` 115 | # Bun 116 | 117 | benchmarking query: select i, i as a from generate_series(1, 100000) s(i) 118 | cpu: Apple M1 119 | runtime: bun 0.1.4 (arm64-darwin) 120 | 121 | benchmark time (avg) (min … max) 122 | ---------------------------------------------------- 123 | query 124 | ---------------------------------------------------- 125 | jit query() 8.61 ms/iter (7.54 ms … 10.43 ms) 126 | query() 18.5 ms/iter (17.16 ms … 20.34 ms) 127 | 128 | summary for query 129 | jit query() 130 | 2.15x faster than query() 131 | 132 | stream 133 | ---------------------------------------------------- 134 | jit stream() 16.36 ms/iter (15.55 ms … 17.79 ms) 135 | stream() 21.44 ms/iter (21.02 ms … 23.18 ms) 136 | 137 | summary for stream 138 | jit stream() 139 | 1.31x faster than stream() 140 | ``` 141 | 142 |
143 | 144 | 145 | ## examples 146 | 147 | ```typescript 148 | import { open } from "https://deno.land/x/duckdb/mod.ts"; 149 | 150 | const db = open("./example.db"); 151 | // or const db = open(':memory:'); 152 | 153 | const connection = db.connect(); 154 | 155 | connection.query("select 1 as number"); // -> [{ number: 1 }] 156 | 157 | for (const row of connection.stream("select 42 as number")) { 158 | row; // -> { number: 42 } 159 | } 160 | 161 | const prepared = connection.prepare( 162 | "select ?::INTEGER as number, ?::VARCHAR as text", 163 | ); 164 | 165 | prepared.query(1337, "foo"); // -> [{ number: 1337, text: 'foo' }] 166 | prepared.query(null, "bar"); // -> [{ number: null, text: 'bar' }] 167 | 168 | connection.close(); 169 | db.close(); 170 | ``` 171 | 172 | ## Credits 173 | 174 | Thanks to the original author of `@evan/duckdb` 175 | [@evanwashere](https://github.com/evanwashere) for most of the implementation 176 | that has been reused in this module. 177 | 178 | ## License 179 | 180 | Modifications are licensed under MIT © [Divy](https://github.com/littledivy) 181 | 182 | Original (bun version): 183 | 184 | Apache-2.0 © [Evan](https://github.com/evanwashere) 185 | -------------------------------------------------------------------------------- /src/sql.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void duckffi_free(void* ptr) { free(ptr); } 6 | void duckffi_dfree(void* ptr) { duckdb_free(ptr); } 7 | void duckffi_free_blob(duckdb_blob* blob) { duckdb_free(blob->data); free(blob); } 8 | void duckffi_close(duckdb_database db) { duckdb_database d = db; duckdb_close(&d); } 9 | void duckffi_free_result(duckdb_result* result) { duckdb_destroy_result(result); free(result); } 10 | void duckffi_disconnect(duckdb_connection con) { duckdb_connection c = con; duckdb_disconnect(&c); } 11 | void duckffi_free_ltype(duckdb_logical_type ltype) { duckdb_logical_type t = ltype; duckdb_destroy_logical_type(&t); } 12 | void duckffi_free_prepare(duckdb_prepared_statement prepare) { duckdb_prepared_statement p = prepare; duckdb_destroy_prepare(&p); } 13 | 14 | duckdb_prepared_statement duckffi_prepare(duckdb_connection con, const char* query) { 15 | duckdb_prepared_statement p; duckdb_prepare(con, query, &p); return p; 16 | } 17 | 18 | duckdb_connection duckffi_connect(duckdb_database db) { 19 | duckdb_connection con; if (DuckDBError == duckdb_connect(db, &con)) return 0; return con; 20 | } 21 | 22 | duckdb_database duckffi_open(bool in_memory, const char* path) { 23 | duckdb_database db; if (DuckDBError == duckdb_open(in_memory ? NULL : path, &db)) return 0; return db; 24 | } 25 | 26 | duckdb_result* duckffi_query(duckdb_connection con, const char* query) { 27 | duckdb_result *res = (duckdb_result*)malloc(sizeof(duckdb_result)); duckdb_query(con, query, res); return res; 28 | } 29 | 30 | duckdb_result* duckffi_query_prepared(duckdb_prepared_statement prepare) { 31 | duckdb_result *res = (duckdb_result*)malloc(sizeof(duckdb_result)); duckdb_execute_prepared(prepare, res); return res; 32 | } 33 | 34 | void* duckffi_blob_data(duckdb_blob* blob) { return blob->data; } 35 | uint32_t duckffi_blob_size(duckdb_blob* blob) { return blob->size; } 36 | uint32_t duckffi_row_count(duckdb_result* result) { return duckdb_row_count(result); } 37 | uint64_t duckffi_row_count_slow(duckdb_result* result) { return duckdb_row_count(result); } 38 | uint32_t duckffi_column_count(duckdb_result* result) { return duckdb_column_count(result); } 39 | const char* duckffi_result_error(duckdb_result* result) { return duckdb_result_error(result); } 40 | uint32_t duckffi_enum_type(duckdb_logical_type type) { return duckdb_enum_internal_type(type); } 41 | uint32_t duckffi_enum_size(duckdb_logical_type type) { return duckdb_enum_dictionary_size(type); } 42 | uint32_t duckffi_param_count(duckdb_prepared_statement prepare) { return duckdb_nparams(prepare); } 43 | bool duckffi_row_count_large(duckdb_result* result) { return 4294967296 < duckdb_row_count(result); } 44 | const char* duckffi_prepare_error(duckdb_prepared_statement prepare) { return duckdb_prepare_error(prepare); } 45 | uint32_t duckffi_column_type(duckdb_result* result, uint32_t offset) { return duckdb_column_type(result, offset); } 46 | const char* duckffi_column_name(duckdb_result* result, uint32_t offset) { return duckdb_column_name(result, offset); } 47 | char* duckffi_enum_string(duckdb_logical_type type, uint32_t offset) { return duckdb_enum_dictionary_value(type, offset); } 48 | uint32_t duckffi_param_type(duckdb_prepared_statement prepare, uint32_t offset) { return duckdb_param_type(prepare, 1 + offset); } 49 | duckdb_logical_type duckffi_column_ltype(duckdb_result* result, uint32_t offset) { return duckdb_column_logical_type(result, offset); } 50 | 51 | bool duckffi_bind_null(duckdb_prepared_statement prepare, uint32_t offset) { return DuckDBError == duckdb_bind_null(prepare, 1 + offset); } 52 | bool duckffi_bind_i8(duckdb_prepared_statement prepare, uint32_t offset, int8_t value) { return DuckDBError == duckdb_bind_int8(prepare, 1 + offset, value); } 53 | bool duckffi_bind_f32(duckdb_prepared_statement prepare, uint32_t offset, float value) { return DuckDBError == duckdb_bind_float(prepare, 1 + offset, value); } 54 | bool duckffi_bind_u8(duckdb_prepared_statement prepare, uint32_t offset, uint8_t value) { return DuckDBError == duckdb_bind_uint8(prepare, 1 + offset, value); } 55 | bool duckffi_bind_i16(duckdb_prepared_statement prepare, uint32_t offset, int16_t value) { return DuckDBError == duckdb_bind_int16(prepare, 1 + offset, value); } 56 | bool duckffi_bind_i32(duckdb_prepared_statement prepare, uint32_t offset, int32_t value) { return DuckDBError == duckdb_bind_int32(prepare, 1 + offset, value); } 57 | bool duckffi_bind_i64(duckdb_prepared_statement prepare, uint32_t offset, int64_t value) { return DuckDBError == duckdb_bind_int64(prepare, 1 + offset, value); } 58 | bool duckffi_bind_f64(duckdb_prepared_statement prepare, uint32_t offset, double value) { return DuckDBError == duckdb_bind_double(prepare, 1 + offset, value); } 59 | bool duckffi_bind_u16(duckdb_prepared_statement prepare, uint32_t offset, uint16_t value) { return DuckDBError == duckdb_bind_uint16(prepare, 1 + offset, value); } 60 | bool duckffi_bind_u32(duckdb_prepared_statement prepare, uint32_t offset, uint32_t value) { return DuckDBError == duckdb_bind_uint32(prepare, 1 + offset, value); } 61 | bool duckffi_bind_u64(duckdb_prepared_statement prepare, uint32_t offset, uint64_t value) { return DuckDBError == duckdb_bind_uint64(prepare, 1 + offset, value); } 62 | bool duckffi_bind_boolean(duckdb_prepared_statement prepare, uint32_t offset, bool value) { return DuckDBError == duckdb_bind_boolean(prepare, 1 + offset, value); } 63 | bool duckffi_bind_blob(duckdb_prepared_statement prepare, uint32_t offset, const void* value, uint32_t length) { return DuckDBError == duckdb_bind_blob(prepare, 1 + offset, value, length); } 64 | bool duckffi_bind_string(duckdb_prepared_statement prepare, uint32_t offset, const char* value, uint32_t length) { return DuckDBError == duckdb_bind_varchar_length(prepare, 1 + offset, value, length); } 65 | bool duckffi_bind_timestamp(duckdb_prepared_statement prepare, uint32_t offset, uint64_t value) { duckdb_timestamp timestamp; timestamp.micros = 1000 * value; return DuckDBError == duckdb_bind_timestamp(prepare, 1 + offset, timestamp); } 66 | bool duckffi_bind_interval(duckdb_prepared_statement prepare, uint32_t offset, uint32_t ms, uint32_t days, uint32_t months) { duckdb_interval interval; interval.days = days; interval.months = months; interval.micros = ms * 1000; return DuckDBError == duckdb_bind_interval(prepare, 1 + offset, interval); } 67 | 68 | int8_t duckffi_value_i8(duckdb_result* result, uint32_t row, uint32_t column) { return duckdb_value_int8(result, column, row); } 69 | float duckffi_value_f32(duckdb_result* result, uint32_t row, uint32_t column) { return duckdb_value_float(result, column, row); } 70 | uint8_t duckffi_value_u8(duckdb_result* result, uint32_t row, uint32_t column) { return duckdb_value_uint8(result, column, row); } 71 | double duckffi_value_f64(duckdb_result* result, uint32_t row, uint32_t column) { return duckdb_value_double(result, column, row); } 72 | int16_t duckffi_value_i16(duckdb_result* result, uint32_t row, uint32_t column) { return duckdb_value_int16(result, column, row); } 73 | int32_t duckffi_value_i32(duckdb_result* result, uint32_t row, uint32_t column) { return duckdb_value_int32(result, column, row); } 74 | int64_t duckffi_value_i64(duckdb_result* result, uint32_t row, uint32_t column) { return duckdb_value_int64(result, column, row); } 75 | uint16_t duckffi_value_u16(duckdb_result* result, uint32_t row, uint32_t column) { return duckdb_value_uint16(result, column, row); } 76 | uint32_t duckffi_value_u32(duckdb_result* result, uint32_t row, uint32_t column) { return duckdb_value_uint32(result, column, row); } 77 | uint64_t duckffi_value_u64(duckdb_result* result, uint32_t row, uint32_t column) { return duckdb_value_uint64(result, column, row); } 78 | bool duckffi_value_boolean(duckdb_result* result, uint32_t row, uint32_t column) { return duckdb_value_boolean(result, column, row); } 79 | bool duckffi_value_is_null(duckdb_result* result, uint32_t row, uint32_t column) { return duckdb_value_is_null(result, column, row); } 80 | uint32_t duckffi_value_date(duckdb_result* result, uint32_t row, uint32_t column) { return duckdb_value_date(result, column, row).days; } 81 | char* duckffi_value_string(duckdb_result* result, uint32_t row, uint32_t column) { return duckdb_value_varchar_internal(result, column, row); } 82 | uint32_t duckffi_value_time(duckdb_result* result, uint32_t row, uint32_t column) { return duckdb_value_time(result, column, row).micros / 1000; } 83 | uint32_t duckffi_value_interval_months(duckdb_result* result, uint32_t row, uint32_t column) { return duckdb_value_interval(result, column, row).months; } 84 | uint64_t duckffi_value_timestamp_ms(duckdb_result* result, uint32_t row, uint32_t column) { return duckdb_value_timestamp(result, column, row).micros / 1000; } 85 | uint32_t duckffi_value_interval_days(duckdb_result* result, uint32_t row, uint32_t column) { duckdb_interval interval = duckdb_value_interval(result, column, row); return interval.micros / 1000 + 24 * 60 * 60000 * interval.days; } 86 | 87 | int8_t duckffi_value_i8_slow(duckdb_result* result, uint64_t row, uint32_t column) { return duckdb_value_int8(result, column, row); } 88 | float duckffi_value_f32_slow(duckdb_result* result, uint64_t row, uint32_t column) { return duckdb_value_float(result, column, row); } 89 | uint8_t duckffi_value_u8_slow(duckdb_result* result, uint64_t row, uint32_t column) { return duckdb_value_uint8(result, column, row); } 90 | double duckffi_value_f64_slow(duckdb_result* result, uint64_t row, uint32_t column) { return duckdb_value_double(result, column, row); } 91 | int16_t duckffi_value_i16_slow(duckdb_result* result, uint64_t row, uint32_t column) { return duckdb_value_int16(result, column, row); } 92 | int32_t duckffi_value_i32_slow(duckdb_result* result, uint64_t row, uint32_t column) { return duckdb_value_int32(result, column, row); } 93 | int64_t duckffi_value_i64_slow(duckdb_result* result, uint64_t row, uint32_t column) { return duckdb_value_int64(result, column, row); } 94 | uint16_t duckffi_value_u16_slow(duckdb_result* result, uint64_t row, uint32_t column) { return duckdb_value_uint16(result, column, row); } 95 | uint32_t duckffi_value_u32_slow(duckdb_result* result, uint64_t row, uint32_t column) { return duckdb_value_uint32(result, column, row); } 96 | uint64_t duckffi_value_u64_slow(duckdb_result* result, uint64_t row, uint32_t column) { return duckdb_value_uint64(result, column, row); } 97 | bool duckffi_value_boolean_slow(duckdb_result* result, uint64_t row, uint32_t column) { return duckdb_value_boolean(result, column, row); } 98 | bool duckffi_value_is_null_slow(duckdb_result* result, uint64_t row, uint32_t column) { return duckdb_value_is_null(result, column, row); } 99 | uint32_t duckffi_value_date_slow(duckdb_result* result, uint64_t row, uint32_t column) { return duckdb_value_date(result, column, row).days; } 100 | char* duckffi_value_string_slow(duckdb_result* result, uint64_t row, uint32_t column) { return duckdb_value_varchar_internal(result, column, row); } 101 | uint32_t duckffi_value_time_slow(duckdb_result* result, uint64_t row, uint32_t column) { return duckdb_value_time(result, column, row).micros / 1000; } 102 | uint32_t duckffi_value_interval_months_slow(duckdb_result* result, uint64_t row, uint32_t column) { return duckdb_value_interval(result, column, row).months; } 103 | uint64_t duckffi_value_timestamp_ms_slow(duckdb_result* result, uint64_t row, uint32_t column) { return duckdb_value_timestamp(result, column, row).micros / 1000; } 104 | uint32_t duckffi_value_interval_days_slow(duckdb_result* result, uint64_t row, uint32_t column) { duckdb_interval interval = duckdb_value_interval(result, column, row); return interval.micros / 1000 + 24 * 60 * 60000 * interval.days; } 105 | 106 | duckdb_blob* duckffi_value_blob(duckdb_result* result, uint32_t row, uint32_t column) { 107 | duckdb_blob stack = duckdb_value_blob(result, column, row); 108 | duckdb_blob *blob = (duckdb_blob*)malloc(sizeof(duckdb_blob)); 109 | 110 | memcpy(blob, &stack, sizeof(duckdb_blob)); 111 | 112 | return blob; 113 | } 114 | 115 | duckdb_blob* duckffi_value_blob_slow(duckdb_result* result, uint64_t row, uint32_t column) { 116 | duckdb_blob stack = duckdb_value_blob(result, column, row); 117 | duckdb_blob *blob = (duckdb_blob*)malloc(sizeof(duckdb_blob)); 118 | 119 | memcpy(blob, &stack, sizeof(duckdb_blob)); 120 | 121 | return blob; 122 | } 123 | 124 | uint8_t* duckffi_null_bitmap(duckdb_result* result, uint32_t rows, uint32_t column) { 125 | uint8_t* bitmap = (uint8_t*)malloc(ceilf(rows / 8.0)); 126 | 127 | for (uint32_t row = 0; row < rows; row++) { 128 | if (duckdb_value_is_null(result, column, row)) { 129 | bitmap[row / 8] |= (1 << (row % 8)); 130 | } 131 | } 132 | 133 | return bitmap; 134 | } -------------------------------------------------------------------------------- /src/sql.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void duckffi_free(void *ptr); 4 | void duckffi_dfree(void *ptr); 5 | void duckffi_close(duckdb_database db); 6 | void duckffi_free_blob(duckdb_blob* blob); 7 | void duckffi_disconnect(duckdb_connection con); 8 | void duckffi_free_result(duckdb_result* result); 9 | void duckffi_free_ltype(duckdb_logical_type ltype); 10 | void duckffi_free_prepare(duckdb_prepared_statement prepare); 11 | 12 | duckdb_connection duckffi_connect(duckdb_database db); 13 | duckdb_database duckffi_open(bool in_memory, const char* path); 14 | duckdb_result* duckffi_query(duckdb_connection con, const char* query); 15 | duckdb_result* duckffi_query_prepared(duckdb_prepared_statement prepare); 16 | duckdb_prepared_statement duckffi_prepare(duckdb_connection con, const char* query); 17 | 18 | void* duckffi_blob_data(duckdb_blob* blob); 19 | uint32_t duckffi_blob_size(duckdb_blob* blob); 20 | uint32_t duckffi_row_count(duckdb_result* result); 21 | bool duckffi_row_count_large(duckdb_result* result); 22 | uint32_t duckffi_enum_size(duckdb_logical_type type); 23 | uint32_t duckffi_enum_type(duckdb_logical_type type); 24 | uint32_t duckffi_column_count(duckdb_result* result); 25 | uint64_t duckffi_row_count_slow(duckdb_result* result); 26 | const char* duckffi_result_error(duckdb_result* result); 27 | uint32_t duckffi_param_count(duckdb_prepared_statement prepare); 28 | char* duckffi_enum_string(duckdb_logical_type type, uint32_t offset); 29 | uint32_t duckffi_column_type(duckdb_result* result, uint32_t offset); 30 | const char* duckffi_prepare_error(duckdb_prepared_statement prepare); 31 | const char* duckffi_column_name(duckdb_result* result, uint32_t offset); 32 | uint32_t duckffi_param_type(duckdb_prepared_statement prepare, uint32_t offset); 33 | duckdb_logical_type duckffi_column_ltype(duckdb_result* result, uint32_t offset); 34 | 35 | bool duckffi_bind_null(duckdb_prepared_statement prepare, uint32_t offset); 36 | bool duckffi_bind_i8(duckdb_prepared_statement prepare, uint32_t offset, int8_t value); 37 | bool duckffi_bind_f32(duckdb_prepared_statement prepare, uint32_t offset, float value); 38 | bool duckffi_bind_u8(duckdb_prepared_statement prepare, uint32_t offset, uint8_t value); 39 | bool duckffi_bind_f64(duckdb_prepared_statement prepare, uint32_t offset, double value); 40 | bool duckffi_bind_i16(duckdb_prepared_statement prepare, uint32_t offset, int16_t value); 41 | bool duckffi_bind_i32(duckdb_prepared_statement prepare, uint32_t offset, int32_t value); 42 | bool duckffi_bind_i64(duckdb_prepared_statement prepare, uint32_t offset, int64_t value); 43 | bool duckffi_bind_u16(duckdb_prepared_statement prepare, uint32_t offset, uint16_t value); 44 | bool duckffi_bind_u32(duckdb_prepared_statement prepare, uint32_t offset, uint32_t value); 45 | bool duckffi_bind_u64(duckdb_prepared_statement prepare, uint32_t offset, uint64_t value); 46 | bool duckffi_bind_boolean(duckdb_prepared_statement prepare, uint32_t offset, bool value); 47 | bool duckffi_bind_timestamp(duckdb_prepared_statement prepare, uint32_t offset, uint64_t value); 48 | bool duckffi_bind_blob(duckdb_prepared_statement prepare, uint32_t offset, const void* value, uint32_t length); 49 | bool duckffi_bind_string(duckdb_prepared_statement prepare, uint32_t offset, const char* value, uint32_t length); 50 | bool duckffi_bind_interval(duckdb_prepared_statement prepare, uint32_t offset, uint32_t ms, uint32_t days, uint32_t months); 51 | 52 | int8_t duckffi_value_i8(duckdb_result* result, uint32_t row, uint32_t column); 53 | float duckffi_value_f32(duckdb_result* result, uint32_t row, uint32_t column); 54 | uint8_t duckffi_value_u8(duckdb_result* result, uint32_t row, uint32_t column); 55 | double duckffi_value_f64(duckdb_result* result, uint32_t row, uint32_t column); 56 | int16_t duckffi_value_i16(duckdb_result* result, uint32_t row, uint32_t column); 57 | int32_t duckffi_value_i32(duckdb_result* result, uint32_t row, uint32_t column); 58 | int64_t duckffi_value_i64(duckdb_result* result, uint32_t row, uint32_t column); 59 | uint16_t duckffi_value_u16(duckdb_result* result, uint32_t row, uint32_t column); 60 | uint32_t duckffi_value_u32(duckdb_result* result, uint32_t row, uint32_t column); 61 | uint64_t duckffi_value_u64(duckdb_result* result, uint32_t row, uint32_t column); 62 | bool duckffi_value_boolean(duckdb_result* result, uint32_t row, uint32_t column); 63 | bool duckffi_value_is_null(duckdb_result* result, uint32_t row, uint32_t column); 64 | char* duckffi_value_string(duckdb_result* result, uint32_t row, uint32_t column); 65 | uint32_t duckffi_value_date(duckdb_result* result, uint32_t row, uint32_t column); 66 | uint32_t duckffi_value_time(duckdb_result* result, uint32_t row, uint32_t column); 67 | duckdb_blob* duckffi_value_blob(duckdb_result* result, uint32_t row, uint32_t column); 68 | uint64_t duckffi_value_timestamp_ms(duckdb_result* result, uint32_t row, uint32_t column); 69 | uint32_t duckffi_value_interval_days(duckdb_result* result, uint32_t row, uint32_t column); 70 | uint32_t duckffi_value_interval_months(duckdb_result* result, uint32_t row, uint32_t column); 71 | 72 | int8_t duckffi_value_i8_slow(duckdb_result* result, uint64_t row, uint32_t column); 73 | float duckffi_value_f32_slow(duckdb_result* result, uint64_t row, uint32_t column); 74 | uint8_t duckffi_value_u8_slow(duckdb_result* result, uint64_t row, uint32_t column); 75 | double duckffi_value_f64_slow(duckdb_result* result, uint64_t row, uint32_t column); 76 | int16_t duckffi_value_i16_slow(duckdb_result* result, uint64_t row, uint32_t column); 77 | int32_t duckffi_value_i32_slow(duckdb_result* result, uint64_t row, uint32_t column); 78 | int64_t duckffi_value_i64_slow(duckdb_result* result, uint64_t row, uint32_t column); 79 | uint16_t duckffi_value_u16_slow(duckdb_result* result, uint64_t row, uint32_t column); 80 | uint32_t duckffi_value_u32_slow(duckdb_result* result, uint64_t row, uint32_t column); 81 | uint64_t duckffi_value_u64_slow(duckdb_result* result, uint64_t row, uint32_t column); 82 | bool duckffi_value_boolean_slow(duckdb_result* result, uint64_t row, uint32_t column); 83 | bool duckffi_value_is_null_slow(duckdb_result* result, uint64_t row, uint32_t column); 84 | char* duckffi_value_string_slow(duckdb_result* result, uint64_t row, uint32_t column); 85 | uint32_t duckffi_value_date_slow(duckdb_result* result, uint64_t row, uint32_t column); 86 | uint32_t duckffi_value_time_slow(duckdb_result* result, uint64_t row, uint32_t column); 87 | duckdb_blob* duckffi_value_blob_slow(duckdb_result* result, uint64_t row, uint32_t column); 88 | uint64_t duckffi_value_timestamp_ms_slow(duckdb_result* result, uint64_t row, uint32_t column); 89 | uint32_t duckffi_value_interval_days_slow(duckdb_result* result, uint64_t row, uint32_t column); 90 | uint32_t duckffi_value_interval_months_slow(duckdb_result* result, uint64_t row, uint32_t column); 91 | 92 | uint8_t* duckffi_null_bitmap(duckdb_result* result, uint32_t rows, uint32_t column); --------------------------------------------------------------------------------