;ELC ;;; Compiled ;;; in Emacs version 28.0.50 ;;; with all optimizations. (require 'cl-lib) #@71 Defines a new error symbol for EmacSQL. (fn SYMBOL PARENTS MESSAGE) (defalias 'emacsql-deferror '(macro . #[771 "\300\301\302\303E\"!\304\305D\306\307\305D\310BB\305D\307\305\nD\311BB\257E\207" [cl-remove-duplicates append emacsql-error error prog1 quote setf get ('error-conditions) ('error-message)] 12 (#$ . 105)])) (byte-code "\300\301\302\303#\304\305\306\307#\210\304\305\310\311#\210\304\312\306\313#\210\304\312\310\314#\210\304\315\306\316#\210\304\315\310\317#\210\304\320\306\321#\210\304\320\310\322#\210\304\323\306\324#\210\304\323\310\325#\210\304\326\306\327#\210\304\326\310\330#\210\304\331\306\332#\210\304\331\310\333#\210\304\334\306\335#\210\304\334\310\336#\210\304\337\306\340#\210\304\337\310\341#\210\304\342\306\343#\210\304\342\310\344#\207" [function-put emacsql-deferror lisp-indent-function 2 put emacsql-error error-conditions (emacsql-error error) error-message "EmacSQL had an unhandled condition" emacsql-syntax (emacsql-syntax emacsql-error error) "Invalid SQL statement" emacsql-internal (emacsql-internal emacsql-error error) "Internal error" emacsql-locked (emacsql-locked emacsql-error error) "Database locked" emacsql-fatal (emacsql-fatal emacsql-error error) "Fatal error" emacsql-memory (emacsql-memory emacsql-error error) "Out of memory" emacsql-corruption (emacsql-corruption emacsql-error error) "Database corrupted" emacsql-access (emacsql-access emacsql-error error) "Database access error" emacsql-timeout (emacsql-timeout emacsql-error error) "Query timeout error" emacsql-warning (emacsql-warning emacsql-error error) "Warning message"] 5) #@79 Like `error', but signal an emacsql-syntax condition. (fn FORMAT &rest ARGS) (defalias 'emacsql-error #[385 "\300\301\302\303#C\"\207" [signal emacsql-syntax apply format] 8 (#$ . 1715)]) #@60 Collection of all known reserved words, used for escaping. (defvar emacsql-reserved (make-hash-table :test 'equal) (#$ . 1912)) #@75 Register sequence of keywords as reserved words, returning SEQ. (fn SEQ) (defalias 'emacsql-register-reserved #[257 "\3012F\211\302\303\203>:\204GW\203>:\203%\211A\262\242\202(H\262\304\305\"\226\306\307#\266T\262\202\310\301\"\266\3030\207" [emacsql-reserved --cl-block-nil-- 0 nil format "%s" puthash t throw] 10 (#$ . 2046)]) #@61 Returns non-nil if string NAME is a SQL keyword. (fn NAME) (defalias 'emacsql-reserved-p #[257 "\301\226\"\207" [emacsql-reserved gethash] 4 (#$ . 2410)]) #@72 Single-quote (scalar) STRING for use in a SQL expression. (fn STRING) (defalias 'emacsql-quote-scalar #[257 "\300\301\302\"r\211q\210\303\304\"\216c\210eb\210\305\306\307\302#\203\"\310\311!\210\202eb\210\306c\210db\210\306c\210\312 *\207" [generate-new-buffer " *temp*" t make-closure #[0 "\301\300!\205 \302\300!\207" [V0 buffer-name kill-buffer] 2] re-search-forward "'" nil replace-match "''" buffer-string] 6 (#$ . 2574)]) #@76 Double-quote (identifier) STRING for use in a SQL expression. (fn STRING) (defalias 'emacsql-quote-identifier #[257 "\300\301\302\303\304#\"\207" [format "\"%s\"" replace-regexp-in-string "\"" "\"\""] 7 (#$ . 3015)]) #@60 Escape an identifier, if needed, for SQL. (fn IDENTIFIER) (defalias 'emacsql-escape-identifier #[257 "\211\203\301!\204\2119\204\302!\204\303\304\"\210\302!\203&\305\306\307#\207\211\310=\203.\311\207\312!\313\314\315\316#)\266\203\203M\305\306\317\320\321\313\"\"\322#\207\323\324\325\326\327\"#\330\314\315\316#)\266\203\204|\331\314\315\316#)\266\203\204|\332!\203\200\333!\207\207" [inhibit-changing-match-data keywordp vectorp emacsql-error "Invalid identifier: %S" mapconcat emacsql-escape-identifier ", " * "*" symbol-name ":" nil t string-match mapcar intern split-string "." replace-regexp-in-string "-" "_" format "%S" "[]-- !\"#%&'()*+,./:;<=>?@[\\^`{|}~]" "^[0-9$]" emacsql-reserved-p emacsql-quote-identifier] 10 (#$ . 3240)]) #@49 Escape VALUE for sending to SQLite. (fn VALUE) (defalias 'emacsql-escape-scalar #[257 "\302\211\211\204\f\303\202\211\247\203\304!\202\305\304!!*\207" [print-escape-control-characters print-escape-newlines t "NULL" prin1-to-string emacsql-quote-scalar] 4 (#$ . 4029)]) #@49 Escape VALUE for sending to SQLite. (fn VALUE) (defalias 'emacsql-escape-raw #[257 "\211\204\300\207\211;\203\301!\207\302\303!\207" ["NULL" emacsql-quote-scalar error "Expected string or nil"] 3 (#$ . 4316)]) #@54 Encode VECTOR into a SQL vector scalar. (fn VECTOR) (defalias 'emacsql-escape-vector #[257 "\211\204\300\301!\207\211<\203\302\303\304#\207\305!\203\"\306\302\307\304#\310Q\207\300\311\"\207" [emacsql-error "Empty SQL vector expression." mapconcat emacsql-escape-vector ", " vectorp "(" emacsql-escape-scalar ")" "Invalid vector %S"] 6 (#$ . 4538)]) #@54 Escape THING for use as a `format' spec. (fn THING) (defalias 'emacsql-escape-format #[257 "\300\301\302#\207" [replace-regexp-in-string "%" "%%"] 5 (#$ . 4904)]) #@46 An alist mapping EmacSQL types to SQL types. (defvar emacsql-type-map '((integer "&INTEGER") (float "&REAL") (object "&TEXT") (nil "&NONE")) (#$ . 5075)) #@41 Convert KEYWORD into SQL. (fn KEYWORD) (defalias 'emacsql--from-keyword #[257 "\300!\301\302O\303\304\305#\226\207" [symbol-name 1 nil replace-regexp-in-string "-" " "] 6 (#$ . 5235)]) #@69 Compile CONSTRAINTS into a partial SQL expresson. (fn CONSTRAINTS) (defalias 'emacsql--prepare-constraints #[257 "\300\301\302\211:\203[@\262\204\303\202P\304!\203\"\305!\202P9\203-\306!\202P\307!\203>\310\311\300\306\312#\"\202P<\203M\310\311\313!@\"\202P\314!B\262A\262\202\211\237\266\203\315#\207" [mapconcat identity nil "NULL" keywordp emacsql--from-keyword emacsql-escape-identifier vectorp format "(%s)" ", " emacsql--*expr emacsql-escape-scalar " "] 12 (#$ . 5429)]) #@56 Convert COLUMN into a partial SQL string. (fn COLUMN) (defalias 'emacsql--prepare-column #[257 "\301\3029\203\303!\304\236A@D\202`<\203W\211\203&\211A\262\242\202-\305\306\307GD\"\310\311\303!@\312>\203G\313\211A\262\242\"A@\202L\304\236A@\314!E\"\266\202\202`\315\316\317#\205`\304\320#\207" [emacsql-type-map mapconcat identity emacsql-escape-identifier nil signal wrong-number-of-arguments (name . constraints) cl-delete-if #[257 "\211G\300U\207" [0] 3 "\n\n(fn S)"] (integer float object) assoc emacsql--prepare-constraints error "cl-etypecase failed: %s, %s" (symbol list) " "] 11 (#$ . 5944)]) #@48 Compile SCHEMA into a SQL string. (fn SCHEMA) (defalias 'emacsql-prepare-schema #[257 "\300!\203 \301C!\207\211\211\203\211A\262\242\202 \302\303\304GD\"\305\306\307\310\"\307\311\"\244\312#\207" [vectorp emacsql-prepare-schema signal wrong-number-of-arguments (columns . constraints) mapconcat identity mapcar emacsql--prepare-column emacsql--prepare-constraints ", "] 9 (#$ . 6578)]) #@42 Cache used to memoize `emacsql-prepare'. (defvar emacsql-prepare-cache (make-hash-table :test 'equal :weakness 'key) (#$ . 6983)) #@58 Used within `emacsql-with-params' to collect parameters. (defvar emacsql--vars nil (#$ . 7119)) #@70 Return non-nil if THING looks like a prepared statement. (fn THING) (defalias 'emacsql-sql-p #[257 "\300!\205\211G\301V\205\302\301H!\207" [vectorp 0 keywordp] 4 (#$ . 7221)]) #@244 Return the index and type of THING, or nil if THING is not a parameter. A parameter is a symbol that looks like $i1, $s2, $v3, etc. The letter refers to the type: identifier (i), scalar (s), vector (v), raw string (r), schema (S). (fn THING) (defalias 'emacsql-param #[257 "\2119\205J\301!\302\303\304\305#)\266\203\205H\306\307\303O!S\310H\211\311\267\202<\312\202E\313\202E\314\202E\315\202E\316\202E\317\320\321#\205E\303\262B\262\207" [inhibit-changing-match-data symbol-name "^\\$[isvrS][0-9]+$" nil t string-match read 2 1 #s(hash-table size 5 test eq rehash-size 1.5 rehash-threshold 0.8125 purecopy t data (105 40 115 44 118 48 114 52 83 56)) :identifier :scalar :vector :raw :schema error "cl-ecase failed: %s, %s" (105 115 118 114 83)] 9 (#$ . 7411)]) #@252 Evaluate BODY, collecting parameters. Provided local functions: `param', `identifier', `scalar', `raw', `svector', `expr', `subsql', and `combine'. BODY should return a string, which will be combined with variable definitions. (fn PREFIX &rest BODY) (defalias 'emacsql-with-params '(macro . #[385 "\300\301\302\303\304\305\306BE\307BBEE\207" [let ((emacsql--vars nil)) cl-flet* ((combine (prepared) (emacsql--*combine prepared)) (param (thing) (emacsql--!param thing)) (identifier (thing) (emacsql--!param thing :identifier)) (scalar (thing) (emacsql--!param thing :scalar)) (raw (thing) (emacsql--!param thing :raw)) (svector (thing) (combine (emacsql--*vector thing))) (expr (thing) (combine (emacsql--*expr thing))) (subsql (thing) (format "(%s)" (combine (emacsql-prepare thing))))) cons concat progn (emacsql--vars)] 11 (#$ . 8201)])) (byte-code "\300\301\302\303#\300\207" [function-put emacsql-with-params lisp-indent-function 1] 4) #@156 Parse, escape, and store THING. If optional KIND is not specified, then try to guess it. Only use within `emacsql-with-params'! (fn THING &optional KIND) (defalias 'emacsql--!param #[513 "\301\302!\211\204O\303\2035\304\267\2021\305!\202M\306!\202M\307!\202M\310!\202M\311!\202M\312\202M\203J\313!\204J9\203J\305!\202M\306!!\207\211A\314=\203Z\315\202[\316#\210C\244\207" [emacsql--vars #[771 "\205A=?\205\300\301#\207" [emacsql-error "Invalid parameter type %s, expecting %s"] 7 "\n\n(fn THING KIND PARAM)"] emacsql-param emacsql-escape-format #s(hash-table size 5 test eq rehash-size 1.5 rehash-threshold 0.8125 purecopy t data (:identifier 19 :scalar 25 :vector 31 :raw 37 :schema 43)) emacsql-escape-identifier emacsql-escape-scalar emacsql-escape-vector emacsql-escape-raw emacsql-prepare-schema nil keywordp :schema "(%s)" "%s"] 9 (#$ . 9153)]) #@30 Prepare VECTOR. (fn VECTOR) (defalias 'emacsql--*vector #[257 "\301\302\301\211\303\301\304\305\"\301\2119\203\306 \307\"\202D<\203+\310\n\311#\202D\312 !\203?\313\314\310\f\311#\"\202D\315\316\n\"\260B\262\262\262\262\262\262\262\262)\207" [emacsql--vars nil #[257 "\300!\207" [emacsql--*combine] 3 "\n\n(fn PREPARED)"] #[257 "\300\301\"\207" [emacsql--!param :scalar] 4 "\n\n(fn THING)"] make-closure #[257 "\300\301!!\207" [V0 emacsql--*vector] 4 "\n\n(fn THING)"] emacsql--!param :vector mapconcat ", " vectorp format "(%s)" emacsql-error "Invalid vector: %S"] 15 (#$ . 10055)]) #@37 Expand EXPR recursively. (fn EXPR) (defalias 'emacsql--*expr #[257 "\301\302\303\301\304\305\306\301\307\310 !\203\211\n\"\202\316\311 !\203*\n\"\202\316:\2048 !\202\316C\211\242\203L\211\242\211\242A\240\210\242\202T\312\313\314\242GD\"\315\316 #\317\320>\203\251\242G\211\321\267\202\237\322\323\324!\325!$\202\242\322\326\325!\327=\203\212\330\202\213\324!\327=\203\231\324\202\232\330!$\202\242!\262\266\204\202\316\331=\203\327\242G\211\332\267\202\315\322\333\324!\"\202\320\322\334\324!\325!#\202\320!\262\266\204\202\316\335=\203\350\322\336\324!\"\266\204\202\316\337=\203\371\322\340\324!\"\266\204\202\316\341=\203\n\322\342\324!\"\266\204\202\316\343>\203 \322\344\324!\345!\226#\266\204\202\316\346=\203@\242@\211;\2035!\2029 !\262\266\204\202\316\347=\203\245\322\350\324!\242G\330U\203b\242A@\351=\203b\352\202\237\242G\353U\203\242A@\354=\203\322\355\330!\"\206\237\356\325 \242G\301W\203\231B\262T\262\202\207\211\237\266\203\357##\266\204\202\316\356\324\242G\301W\203\277B\262T\262\202\255\211\237\266\203\322\360\345!\226\"#\266\204\260B\262\262\262\262\262\262\262\262)\207" [emacsql--vars nil #[257 "\300!\207" [emacsql--*combine] 3 "\n\n(fn PREPARED)"] #[257 "\300!\207" [emacsql--!param] 3 "\n\n(fn THING)"] #[257 "\300\301\"\207" [emacsql--!param :scalar] 4 "\n\n(fn THING)"] #[257 "\300\301\"\207" [emacsql--!param :raw] 4 "\n\n(fn THING)"] #[514 "\300!!\207" [emacsql--*vector] 5 "\n\n(fn --CL-COMBINE-- THING)"] #[514 "\300\301\302!!\"\207" [format "(%s)" emacsql-prepare] 7 "\n\n(fn --CL-COMBINE-- THING)"] emacsql-sql-p vectorp signal wrong-number-of-arguments (op . args) make-closure #[257 "\300\302\301\2428!!\207" [V0 V1 emacsql--*expr] 5 "\n\n(fn N)"] #[257 "\300\301\"\207" [emacsql-error "Wrong number of operands for %s"] 4 "\n\n(fn OP)"] (<= >=) #s(hash-table size 2 test eq rehash-size 1.5 rehash-threshold 0.8125 purecopy t data (2 106 3 121)) format "%s %s %s" 0 1 "%s BETWEEN %s AND %s" >= 2 - #s(hash-table size 2 test eq rehash-size 1.5 rehash-threshold 0.8125 purecopy t data (1 184 2 193)) "-(%s)" "%s - %s" not "NOT %s" notnull "%s NOTNULL" isnull "%s ISNULL" (asc desc) "%s %s" symbol-name quote funcall "%s(%s)" * "*" 3 :distinct "DISTINCT %s" mapconcat ", " " %s "] 23 (#$ . 10680)]) #@84 Read in a vector of IDENTS identifiers, or just an single identifier. (fn IDENTS) (defalias 'emacsql--*idents #[257 "\301\302\301\211\211\211\211\303\304\"\301\305\n\306#\260B\262\262\262\262\262\262\262\262)\207" [emacsql--vars nil #[257 "\300!\207" [emacsql--*combine] 3 "\n\n(fn PREPARED)"] make-closure #[257 "\300\301!!\207" [V0 emacsql--*expr] 4 "\n\n(fn THING)"] mapconcat ", "] 13 (#$ . 13089)]) #@126 Append parameters from PREPARED to `emacsql--vars', return the string. Only use within `emacsql-with-params'! (fn PREPARED) (defalias 'emacsql--*combine #[257 "\211\211\203\211A\262\242\202\301\302\303GD\"\244\207" [emacsql--vars signal wrong-number-of-arguments (string . vars)] 6 (#$ . 13518)]) #@55 Create a prepared statement from STRING. (fn STRING) (defalias 'emacsql-prepare--string #[257 "\301\302\303\301\211\211\211\211\211\304\305\306\307\n\" #\260B\262\262\262\262\262\262\262\262)\207" [emacsql--vars nil #[257 "\300!\207" [emacsql--*combine] 3 "\n\n(fn PREPARED)"] #[257 "\300!\207" [emacsql--!param] 3 "\n\n(fn THING)"] replace-regexp-in-string "\\$[isv][0-9]+" make-closure #[257 "\300\301!!\207" [V0 intern] 4 "\n\n(fn V)"]] 14 (#$ . 13832)]) #@51 Create a prepared statement from SEXP. (fn SEXP) (defalias 'emacsql-prepare--sexp #[257 "\301\302\303\301\211\211\304\301\305\3062\313\307 \310\"\301\211\211\211\203\277\211A\262\242\262\311!\203G\312=\203A\313 \211A\262\n\242\"P\202\262\314!\202\2629\203]\315=\203V\316\202\262\f!\202\262\317!\203\214\320!\203r\"\202\262 \321!!\311!\203\203\211\202\207\322\323\"\262\202\262<\203\255\317@!\203\244\324\322\323\325!\"!\202\262 \326!!\202\262\324\327!!C\244\262\262\301\262\202\330\306\331\332\333#\"\266\3010\260B\262\262\262\262\262\262\262\262)\207" [emacsql--vars nil #[257 "\300!\207" [emacsql--*combine] 3 "\n\n(fn PREPARED)"] #[257 "\300!\207" [emacsql--!param] 3 "\n\n(fn THING)"] #[514 "\300!!\207" [emacsql--*vector] 5 "\n\n(fn --CL-COMBINE-- THING)"] #[514 "\300\301\302!!\"\207" [format "(%s)" emacsql-prepare] 7 "\n\n(fn --CL-COMBINE-- THING)"] --cl-block-nil-- cl-coerce list keywordp :values "VALUES " emacsql--from-keyword * "*" vectorp emacsql-sql-p emacsql--*idents format "(%s)" emacsql-escape-format emacsql-prepare-schema emacsql--*expr emacsql-escape-scalar throw mapconcat identity " "] 20 (#$ . 14313)]) #@66 Expand SQL (string or sexp) into a prepared statement. (fn SQL) (defalias 'emacsql-prepare #[257 " B\302\"\206$\211\303;\203\304!\202 \305!#\266\202\207" [emacsql-prepare-cache emacsql-type-map gethash puthash emacsql-prepare--string emacsql-prepare--sexp] 9 (#$ . 15531)]) #@71 Fill in the variables EXPANSION with ARGS. (fn EXPANSION &rest ARGS) (defalias 'emacsql-format #[385 "\211\203\211A\262\242\202\300\301\302GD\"\303\304\305\211\211:\203f@\262\211A\262\242\262\n8\306\267\202U\307!\202Y\310!\202Y\311!\202Y\312!\202Y\313!\202Y\314\315\"\262B\262A\262\202\211\237\266\204#\207" [signal wrong-number-of-arguments (format . vars) apply format nil #s(hash-table size 5 test eq rehash-size 1.5 rehash-threshold 0.8125 purecopy t data (:identifier 55 :scalar 61 :vector 67 :raw 73 :schema 79)) emacsql-escape-identifier emacsql-escape-scalar emacsql-escape-vector emacsql-escape-raw emacsql-prepare-schema emacsql-error "Invalid var type %S"] 15 (#$ . 15829)]) (provide 'emacsql-compiler)