1
0

stdlib.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985
  1. package sqlite
  2. import (
  3. "github.com/sqlc-dev/sqlc/internal/sql/ast"
  4. "github.com/sqlc-dev/sqlc/internal/sql/catalog"
  5. )
  6. // sqlite functions from:
  7. // https://www.sqlite.org/lang_aggfunc.html
  8. // https://www.sqlite.org/lang_mathfunc.html
  9. // https://www.sqlite.org/lang_corefunc.html
  10. func defaultSchema(name string) *catalog.Schema {
  11. s := &catalog.Schema{Name: name}
  12. s.Funcs = []*catalog.Function{
  13. // Aggregation Functions
  14. {
  15. Name: "AVG",
  16. Args: []*catalog.Argument{
  17. {
  18. Type: &ast.TypeName{Name: "any"},
  19. },
  20. },
  21. ReturnType: &ast.TypeName{Name: "real"},
  22. ReturnTypeNullable: true,
  23. },
  24. {
  25. Name: "COUNT",
  26. Args: []*catalog.Argument{},
  27. ReturnType: &ast.TypeName{Name: "integer"},
  28. },
  29. {
  30. Name: "COUNT",
  31. Args: []*catalog.Argument{
  32. {
  33. Type: &ast.TypeName{Name: "any"},
  34. },
  35. },
  36. ReturnType: &ast.TypeName{Name: "integer"},
  37. },
  38. {
  39. Name: "GROUP_CONCAT",
  40. Args: []*catalog.Argument{
  41. {
  42. Type: &ast.TypeName{Name: "any"},
  43. },
  44. },
  45. ReturnType: &ast.TypeName{Name: "text"},
  46. },
  47. {
  48. Name: "GROUP_CONCAT",
  49. Args: []*catalog.Argument{
  50. {
  51. Type: &ast.TypeName{Name: "any"},
  52. },
  53. {
  54. Type: &ast.TypeName{Name: "text"},
  55. },
  56. },
  57. ReturnType: &ast.TypeName{Name: "text"},
  58. },
  59. {
  60. Name: "MAX",
  61. Args: []*catalog.Argument{
  62. {
  63. Type: &ast.TypeName{Name: "any"},
  64. },
  65. },
  66. ReturnType: &ast.TypeName{Name: "any"},
  67. ReturnTypeNullable: true,
  68. },
  69. {
  70. Name: "MIN",
  71. Args: []*catalog.Argument{
  72. {
  73. Type: &ast.TypeName{Name: "any"},
  74. },
  75. },
  76. ReturnType: &ast.TypeName{Name: "any"},
  77. ReturnTypeNullable: true,
  78. },
  79. {
  80. Name: "SUM",
  81. Args: []*catalog.Argument{
  82. {
  83. Type: &ast.TypeName{Name: "any"},
  84. },
  85. },
  86. ReturnType: &ast.TypeName{Name: "real"},
  87. ReturnTypeNullable: true,
  88. },
  89. {
  90. Name: "TOTAL",
  91. Args: []*catalog.Argument{
  92. {
  93. Type: &ast.TypeName{Name: "any"},
  94. },
  95. },
  96. ReturnType: &ast.TypeName{Name: "real"},
  97. },
  98. // Math Functions
  99. {
  100. Name: "ACOS",
  101. Args: []*catalog.Argument{
  102. {
  103. Type: &ast.TypeName{Name: "any"},
  104. },
  105. },
  106. ReturnType: &ast.TypeName{Name: "real"},
  107. },
  108. {
  109. Name: "ACOSH",
  110. Args: []*catalog.Argument{
  111. {
  112. Type: &ast.TypeName{Name: "any"},
  113. },
  114. },
  115. ReturnType: &ast.TypeName{Name: "real"},
  116. },
  117. {
  118. Name: "ASIN",
  119. Args: []*catalog.Argument{
  120. {
  121. Type: &ast.TypeName{Name: "any"},
  122. },
  123. },
  124. ReturnType: &ast.TypeName{Name: "real"},
  125. },
  126. {
  127. Name: "ASINH",
  128. Args: []*catalog.Argument{
  129. {
  130. Type: &ast.TypeName{Name: "any"},
  131. },
  132. },
  133. ReturnType: &ast.TypeName{Name: "real"},
  134. },
  135. {
  136. Name: "ATAN",
  137. Args: []*catalog.Argument{
  138. {
  139. Type: &ast.TypeName{Name: "any"},
  140. },
  141. },
  142. ReturnType: &ast.TypeName{Name: "real"},
  143. },
  144. {
  145. Name: "ATAN2",
  146. Args: []*catalog.Argument{
  147. {
  148. Type: &ast.TypeName{Name: "any"},
  149. },
  150. {
  151. Type: &ast.TypeName{Name: "any"},
  152. },
  153. },
  154. ReturnType: &ast.TypeName{Name: "real"},
  155. },
  156. {
  157. Name: "ATANH",
  158. Args: []*catalog.Argument{
  159. {
  160. Type: &ast.TypeName{Name: "any"},
  161. },
  162. },
  163. ReturnType: &ast.TypeName{Name: "real"},
  164. },
  165. {
  166. Name: "CEIL",
  167. Args: []*catalog.Argument{
  168. {
  169. Type: &ast.TypeName{Name: "any"},
  170. },
  171. },
  172. ReturnType: &ast.TypeName{Name: "integer"},
  173. },
  174. {
  175. Name: "CEILING",
  176. Args: []*catalog.Argument{
  177. {
  178. Type: &ast.TypeName{Name: "any"},
  179. },
  180. },
  181. ReturnType: &ast.TypeName{Name: "integer"},
  182. },
  183. {
  184. Name: "COS",
  185. Args: []*catalog.Argument{
  186. {
  187. Type: &ast.TypeName{Name: "any"},
  188. },
  189. },
  190. ReturnType: &ast.TypeName{Name: "real"},
  191. },
  192. {
  193. Name: "COSH",
  194. Args: []*catalog.Argument{
  195. {
  196. Type: &ast.TypeName{Name: "any"},
  197. },
  198. },
  199. ReturnType: &ast.TypeName{Name: "real"},
  200. },
  201. {
  202. Name: "DEGREES",
  203. Args: []*catalog.Argument{
  204. {
  205. Type: &ast.TypeName{Name: "any"},
  206. },
  207. },
  208. ReturnType: &ast.TypeName{Name: "real"},
  209. },
  210. {
  211. Name: "EXP",
  212. Args: []*catalog.Argument{
  213. {
  214. Type: &ast.TypeName{Name: "any"},
  215. },
  216. },
  217. ReturnType: &ast.TypeName{Name: "real"},
  218. },
  219. {
  220. Name: "FLOOR",
  221. Args: []*catalog.Argument{
  222. {
  223. Type: &ast.TypeName{Name: "any"},
  224. },
  225. },
  226. ReturnType: &ast.TypeName{Name: "integer"},
  227. },
  228. {
  229. Name: "LN",
  230. Args: []*catalog.Argument{
  231. {
  232. Type: &ast.TypeName{Name: "any"},
  233. },
  234. },
  235. ReturnType: &ast.TypeName{Name: "real"},
  236. },
  237. {
  238. Name: "LOG",
  239. Args: []*catalog.Argument{
  240. {
  241. Type: &ast.TypeName{Name: "any"},
  242. },
  243. },
  244. ReturnType: &ast.TypeName{Name: "real"},
  245. },
  246. {
  247. Name: "LOG10",
  248. Args: []*catalog.Argument{
  249. {
  250. Type: &ast.TypeName{Name: "any"},
  251. },
  252. },
  253. ReturnType: &ast.TypeName{Name: "real"},
  254. },
  255. {
  256. Name: "LOG",
  257. Args: []*catalog.Argument{
  258. {
  259. Type: &ast.TypeName{Name: "any"},
  260. },
  261. {
  262. Type: &ast.TypeName{Name: "any"},
  263. },
  264. },
  265. ReturnType: &ast.TypeName{Name: "real"},
  266. },
  267. {
  268. Name: "LOG2",
  269. Args: []*catalog.Argument{
  270. {
  271. Type: &ast.TypeName{Name: "any"},
  272. },
  273. },
  274. ReturnType: &ast.TypeName{Name: "real"},
  275. },
  276. {
  277. Name: "MOD",
  278. Args: []*catalog.Argument{
  279. {
  280. Type: &ast.TypeName{Name: "any"},
  281. },
  282. {
  283. Type: &ast.TypeName{Name: "any"},
  284. },
  285. },
  286. ReturnType: &ast.TypeName{Name: "real"},
  287. },
  288. {
  289. Name: "PI",
  290. Args: []*catalog.Argument{},
  291. ReturnType: &ast.TypeName{Name: "real"},
  292. },
  293. {
  294. Name: "POW",
  295. Args: []*catalog.Argument{
  296. {
  297. Type: &ast.TypeName{Name: "any"},
  298. },
  299. {
  300. Type: &ast.TypeName{Name: "any"},
  301. },
  302. },
  303. ReturnType: &ast.TypeName{Name: "real"},
  304. },
  305. {
  306. Name: "POWER",
  307. Args: []*catalog.Argument{
  308. {
  309. Type: &ast.TypeName{Name: "any"},
  310. },
  311. {
  312. Type: &ast.TypeName{Name: "any"},
  313. },
  314. },
  315. ReturnType: &ast.TypeName{Name: "real"},
  316. },
  317. {
  318. Name: "RADIANS",
  319. Args: []*catalog.Argument{
  320. {
  321. Type: &ast.TypeName{Name: "any"},
  322. },
  323. },
  324. ReturnType: &ast.TypeName{Name: "real"},
  325. },
  326. {
  327. Name: "SIN",
  328. Args: []*catalog.Argument{
  329. {
  330. Type: &ast.TypeName{Name: "any"},
  331. },
  332. },
  333. ReturnType: &ast.TypeName{Name: "real"},
  334. },
  335. {
  336. Name: "SINH",
  337. Args: []*catalog.Argument{
  338. {
  339. Type: &ast.TypeName{Name: "any"},
  340. },
  341. },
  342. ReturnType: &ast.TypeName{Name: "real"},
  343. },
  344. {
  345. Name: "SQRT",
  346. Args: []*catalog.Argument{
  347. {
  348. Type: &ast.TypeName{Name: "any"},
  349. },
  350. },
  351. ReturnType: &ast.TypeName{Name: "real"},
  352. },
  353. {
  354. Name: "TAN",
  355. Args: []*catalog.Argument{
  356. {
  357. Type: &ast.TypeName{Name: "any"},
  358. },
  359. },
  360. ReturnType: &ast.TypeName{Name: "real"},
  361. },
  362. {
  363. Name: "TANH",
  364. Args: []*catalog.Argument{
  365. {
  366. Type: &ast.TypeName{Name: "any"},
  367. },
  368. },
  369. ReturnType: &ast.TypeName{Name: "real"},
  370. },
  371. {
  372. Name: "TRUNC",
  373. Args: []*catalog.Argument{
  374. {
  375. Type: &ast.TypeName{Name: "any"},
  376. },
  377. },
  378. ReturnType: &ast.TypeName{Name: "integer"},
  379. },
  380. // Scalar functions
  381. {
  382. Name: "ABS",
  383. Args: []*catalog.Argument{
  384. {
  385. Type: &ast.TypeName{Name: "any"},
  386. },
  387. },
  388. ReturnType: &ast.TypeName{Name: "real"},
  389. },
  390. {
  391. Name: "CHANGES",
  392. Args: []*catalog.Argument{},
  393. ReturnType: &ast.TypeName{Name: "integer"},
  394. },
  395. {
  396. Name: "CHAR",
  397. Args: []*catalog.Argument{
  398. {
  399. Type: &ast.TypeName{Name: "int"},
  400. },
  401. {
  402. Type: &ast.TypeName{Name: "int"},
  403. Mode: ast.FuncParamVariadic,
  404. },
  405. },
  406. ReturnType: &ast.TypeName{Name: "text"},
  407. },
  408. {
  409. Name: "COALESCE",
  410. Args: []*catalog.Argument{
  411. {
  412. Type: &ast.TypeName{Name: "any"},
  413. },
  414. {
  415. Type: &ast.TypeName{Name: "any"},
  416. },
  417. {
  418. Type: &ast.TypeName{Name: "any"},
  419. Mode: ast.FuncParamVariadic,
  420. },
  421. },
  422. ReturnType: &ast.TypeName{Name: "any"},
  423. ReturnTypeNullable: true,
  424. },
  425. {
  426. Name: "FORMAT",
  427. Args: []*catalog.Argument{
  428. {
  429. Type: &ast.TypeName{Name: "text"},
  430. },
  431. {
  432. Type: &ast.TypeName{Name: "any"},
  433. Mode: ast.FuncParamVariadic,
  434. },
  435. },
  436. ReturnType: &ast.TypeName{Name: "text"},
  437. ReturnTypeNullable: true,
  438. },
  439. {
  440. Name: "GLOB",
  441. Args: []*catalog.Argument{
  442. {
  443. Type: &ast.TypeName{Name: "text"},
  444. },
  445. {
  446. Type: &ast.TypeName{Name: "text"},
  447. },
  448. },
  449. ReturnType: &ast.TypeName{Name: "integer"},
  450. },
  451. {
  452. Name: "HEX",
  453. Args: []*catalog.Argument{
  454. {
  455. Type: &ast.TypeName{Name: "any"},
  456. },
  457. },
  458. ReturnType: &ast.TypeName{Name: "text"},
  459. },
  460. {
  461. Name: "IFNULL",
  462. Args: []*catalog.Argument{
  463. {
  464. Type: &ast.TypeName{Name: "any"},
  465. },
  466. {
  467. Type: &ast.TypeName{Name: "any"},
  468. },
  469. },
  470. ReturnType: &ast.TypeName{Name: "any"},
  471. ReturnTypeNullable: true,
  472. },
  473. {
  474. Name: "IIF",
  475. Args: []*catalog.Argument{
  476. {
  477. Type: &ast.TypeName{Name: "any"},
  478. },
  479. {
  480. Type: &ast.TypeName{Name: "any"},
  481. },
  482. {
  483. Type: &ast.TypeName{Name: "any"},
  484. },
  485. },
  486. ReturnType: &ast.TypeName{Name: "any"},
  487. ReturnTypeNullable: true,
  488. },
  489. {
  490. Name: "INSTR",
  491. Args: []*catalog.Argument{
  492. {
  493. Type: &ast.TypeName{Name: "text"},
  494. },
  495. {
  496. Type: &ast.TypeName{Name: "text"},
  497. },
  498. },
  499. ReturnType: &ast.TypeName{Name: "integer"},
  500. ReturnTypeNullable: true,
  501. },
  502. {
  503. Name: "LAST_INSERT_ROWID",
  504. Args: []*catalog.Argument{},
  505. ReturnType: &ast.TypeName{Name: "integer"},
  506. },
  507. {
  508. Name: "LENGTH",
  509. Args: []*catalog.Argument{
  510. {
  511. Type: &ast.TypeName{Name: "any"},
  512. },
  513. },
  514. ReturnType: &ast.TypeName{Name: "integer"},
  515. ReturnTypeNullable: true,
  516. },
  517. {
  518. Name: "LIKE",
  519. Args: []*catalog.Argument{
  520. {
  521. Type: &ast.TypeName{Name: "text"},
  522. },
  523. {
  524. Type: &ast.TypeName{Name: "text"},
  525. },
  526. },
  527. ReturnType: &ast.TypeName{Name: "integer"},
  528. },
  529. {
  530. Name: "LIKE",
  531. Args: []*catalog.Argument{
  532. {
  533. Type: &ast.TypeName{Name: "text"},
  534. },
  535. {
  536. Type: &ast.TypeName{Name: "text"},
  537. },
  538. {
  539. Type: &ast.TypeName{Name: "text"},
  540. },
  541. },
  542. ReturnType: &ast.TypeName{Name: "integer"},
  543. },
  544. {
  545. Name: "LIKELIHOOD",
  546. Args: []*catalog.Argument{
  547. {
  548. Type: &ast.TypeName{Name: "any"},
  549. },
  550. {
  551. Type: &ast.TypeName{Name: "real"},
  552. },
  553. },
  554. ReturnType: &ast.TypeName{Name: "any"},
  555. ReturnTypeNullable: true,
  556. },
  557. {
  558. Name: "LIKELY",
  559. Args: []*catalog.Argument{
  560. {
  561. Type: &ast.TypeName{Name: "any"},
  562. },
  563. },
  564. ReturnType: &ast.TypeName{Name: "any"},
  565. ReturnTypeNullable: true,
  566. },
  567. {
  568. Name: "LOWER",
  569. Args: []*catalog.Argument{
  570. {
  571. Type: &ast.TypeName{Name: "text"},
  572. },
  573. },
  574. ReturnType: &ast.TypeName{Name: "text"},
  575. },
  576. {
  577. Name: "LTRIM",
  578. Args: []*catalog.Argument{
  579. {
  580. Type: &ast.TypeName{Name: "text"},
  581. },
  582. },
  583. ReturnType: &ast.TypeName{Name: "text"},
  584. },
  585. {
  586. Name: "LTRIM",
  587. Args: []*catalog.Argument{
  588. {
  589. Type: &ast.TypeName{Name: "text"},
  590. },
  591. {
  592. Type: &ast.TypeName{Name: "text"},
  593. },
  594. },
  595. ReturnType: &ast.TypeName{Name: "text"},
  596. },
  597. {
  598. Name: "MAX",
  599. Args: []*catalog.Argument{
  600. {
  601. Type: &ast.TypeName{Name: "any"},
  602. },
  603. {
  604. Type: &ast.TypeName{Name: "any"},
  605. },
  606. {
  607. Type: &ast.TypeName{Name: "any"},
  608. Mode: ast.FuncParamVariadic,
  609. },
  610. },
  611. ReturnType: &ast.TypeName{Name: "any"},
  612. ReturnTypeNullable: true,
  613. },
  614. {
  615. Name: "MIN",
  616. Args: []*catalog.Argument{
  617. {
  618. Type: &ast.TypeName{Name: "any"},
  619. },
  620. {
  621. Type: &ast.TypeName{Name: "any"},
  622. },
  623. {
  624. Type: &ast.TypeName{Name: "any"},
  625. Mode: ast.FuncParamVariadic,
  626. },
  627. },
  628. ReturnType: &ast.TypeName{Name: "any"},
  629. ReturnTypeNullable: true,
  630. },
  631. {
  632. Name: "NULLIF",
  633. Args: []*catalog.Argument{
  634. {
  635. Type: &ast.TypeName{Name: "any"},
  636. },
  637. {
  638. Type: &ast.TypeName{Name: "any"},
  639. },
  640. },
  641. ReturnType: &ast.TypeName{Name: "any"},
  642. ReturnTypeNullable: true,
  643. },
  644. {
  645. Name: "PRINTF",
  646. Args: []*catalog.Argument{
  647. {
  648. Type: &ast.TypeName{Name: "text"},
  649. },
  650. {
  651. Type: &ast.TypeName{Name: "any"},
  652. Mode: ast.FuncParamVariadic,
  653. },
  654. },
  655. ReturnType: &ast.TypeName{Name: "text"},
  656. ReturnTypeNullable: true,
  657. },
  658. {
  659. Name: "QUOTE",
  660. Args: []*catalog.Argument{
  661. {
  662. Type: &ast.TypeName{Name: "any"},
  663. },
  664. },
  665. ReturnType: &ast.TypeName{Name: "text"},
  666. },
  667. {
  668. Name: "RAMDOM",
  669. Args: []*catalog.Argument{},
  670. ReturnType: &ast.TypeName{Name: "integer"},
  671. },
  672. {
  673. Name: "RAMDOMBLOB",
  674. Args: []*catalog.Argument{
  675. {
  676. Type: &ast.TypeName{Name: "integer"},
  677. },
  678. },
  679. ReturnType: &ast.TypeName{Name: "blob"},
  680. },
  681. {
  682. Name: "REPLACE",
  683. Args: []*catalog.Argument{
  684. {
  685. Type: &ast.TypeName{Name: "text"},
  686. },
  687. {
  688. Type: &ast.TypeName{Name: "text"},
  689. },
  690. {
  691. Type: &ast.TypeName{Name: "text"},
  692. },
  693. },
  694. ReturnType: &ast.TypeName{Name: "text"},
  695. },
  696. {
  697. Name: "ROUND",
  698. Args: []*catalog.Argument{
  699. {
  700. Type: &ast.TypeName{Name: "real"},
  701. },
  702. },
  703. ReturnType: &ast.TypeName{Name: "real"},
  704. },
  705. {
  706. Name: "ROUND",
  707. Args: []*catalog.Argument{
  708. {
  709. Type: &ast.TypeName{Name: "real"},
  710. },
  711. {
  712. Type: &ast.TypeName{Name: "real"},
  713. },
  714. },
  715. ReturnType: &ast.TypeName{Name: "real"},
  716. },
  717. {
  718. Name: "RTRIM",
  719. Args: []*catalog.Argument{
  720. {
  721. Type: &ast.TypeName{Name: "text"},
  722. },
  723. },
  724. ReturnType: &ast.TypeName{Name: "text"},
  725. },
  726. {
  727. Name: "RTRIM",
  728. Args: []*catalog.Argument{
  729. {
  730. Type: &ast.TypeName{Name: "text"},
  731. },
  732. {
  733. Type: &ast.TypeName{Name: "text"},
  734. },
  735. },
  736. ReturnType: &ast.TypeName{Name: "text"},
  737. },
  738. {
  739. Name: "SIGN",
  740. Args: []*catalog.Argument{
  741. {
  742. Type: &ast.TypeName{Name: "any"},
  743. },
  744. },
  745. ReturnType: &ast.TypeName{Name: "integer"},
  746. ReturnTypeNullable: true,
  747. },
  748. {
  749. Name: "SOUNDEX",
  750. Args: []*catalog.Argument{
  751. {
  752. Type: &ast.TypeName{Name: "text"},
  753. },
  754. },
  755. ReturnType: &ast.TypeName{Name: "text"},
  756. },
  757. {
  758. Name: "SQLITE_COMPILEOPTION_GET",
  759. Args: []*catalog.Argument{
  760. {
  761. Type: &ast.TypeName{Name: "integer"},
  762. },
  763. },
  764. ReturnType: &ast.TypeName{Name: "text"},
  765. ReturnTypeNullable: true,
  766. },
  767. {
  768. Name: "SQLITE_COMPILEOPTION_USED",
  769. Args: []*catalog.Argument{
  770. {
  771. Type: &ast.TypeName{Name: "text"},
  772. },
  773. },
  774. ReturnType: &ast.TypeName{Name: "integer"},
  775. },
  776. {
  777. Name: "SQLITE_OFFSET",
  778. Args: []*catalog.Argument{
  779. {
  780. Type: &ast.TypeName{Name: "any"},
  781. },
  782. },
  783. ReturnType: &ast.TypeName{Name: "integer"},
  784. ReturnTypeNullable: true,
  785. },
  786. {
  787. Name: "SQLITE_SOURCE_ID",
  788. Args: []*catalog.Argument{},
  789. ReturnType: &ast.TypeName{Name: "text"},
  790. },
  791. {
  792. Name: "SQLITE_VERSION",
  793. Args: []*catalog.Argument{},
  794. ReturnType: &ast.TypeName{Name: "text"},
  795. },
  796. {
  797. Name: "SUBSTR",
  798. Args: []*catalog.Argument{
  799. {
  800. Type: &ast.TypeName{Name: "any"},
  801. },
  802. {
  803. Type: &ast.TypeName{Name: "integer"},
  804. },
  805. },
  806. ReturnType: &ast.TypeName{Name: "text"},
  807. },
  808. {
  809. Name: "SUBSTR",
  810. Args: []*catalog.Argument{
  811. {
  812. Type: &ast.TypeName{Name: "any"},
  813. },
  814. {
  815. Type: &ast.TypeName{Name: "integer"},
  816. },
  817. {
  818. Type: &ast.TypeName{Name: "integer"},
  819. },
  820. },
  821. ReturnType: &ast.TypeName{Name: "text"},
  822. },
  823. {
  824. Name: "SUBSTRING",
  825. Args: []*catalog.Argument{
  826. {
  827. Type: &ast.TypeName{Name: "any"},
  828. },
  829. {
  830. Type: &ast.TypeName{Name: "integer"},
  831. },
  832. },
  833. ReturnType: &ast.TypeName{Name: "text"},
  834. },
  835. {
  836. Name: "SUBSTRING",
  837. Args: []*catalog.Argument{
  838. {
  839. Type: &ast.TypeName{Name: "any"},
  840. },
  841. {
  842. Type: &ast.TypeName{Name: "integer"},
  843. },
  844. {
  845. Type: &ast.TypeName{Name: "integer"},
  846. },
  847. },
  848. ReturnType: &ast.TypeName{Name: "text"},
  849. },
  850. {
  851. Name: "TOTAL_CHANGES",
  852. Args: []*catalog.Argument{},
  853. ReturnType: &ast.TypeName{Name: "integer"},
  854. },
  855. {
  856. Name: "TRIM",
  857. Args: []*catalog.Argument{
  858. {
  859. Type: &ast.TypeName{Name: "text"},
  860. },
  861. },
  862. ReturnType: &ast.TypeName{Name: "text"},
  863. },
  864. {
  865. Name: "TRIM",
  866. Args: []*catalog.Argument{
  867. {
  868. Type: &ast.TypeName{Name: "text"},
  869. },
  870. {
  871. Type: &ast.TypeName{Name: "text"},
  872. },
  873. },
  874. ReturnType: &ast.TypeName{Name: "text"},
  875. },
  876. {
  877. Name: "TYPEOF",
  878. Args: []*catalog.Argument{
  879. {
  880. Type: &ast.TypeName{Name: "any"},
  881. },
  882. },
  883. ReturnType: &ast.TypeName{Name: "text"},
  884. },
  885. {
  886. Name: "UNICODE",
  887. Args: []*catalog.Argument{
  888. {
  889. Type: &ast.TypeName{Name: "any"},
  890. },
  891. },
  892. ReturnType: &ast.TypeName{Name: "integer"},
  893. },
  894. {
  895. Name: "UNLIKELY",
  896. Args: []*catalog.Argument{
  897. {
  898. Type: &ast.TypeName{Name: "any"},
  899. },
  900. },
  901. ReturnType: &ast.TypeName{Name: "any"},
  902. ReturnTypeNullable: true,
  903. },
  904. {
  905. Name: "UPPER",
  906. Args: []*catalog.Argument{
  907. {
  908. Type: &ast.TypeName{Name: "text"},
  909. },
  910. },
  911. ReturnType: &ast.TypeName{Name: "text"},
  912. },
  913. {
  914. Name: "ZEROBLOB",
  915. Args: []*catalog.Argument{
  916. {
  917. Type: &ast.TypeName{Name: "integer"},
  918. },
  919. },
  920. ReturnType: &ast.TypeName{Name: "blob"},
  921. },
  922. // fts5 funcs https://www.sqlite.org/fts5.html#_auxiliary_functions_
  923. {
  924. Name: "HIGHLIGHT",
  925. Args: []*catalog.Argument{
  926. {
  927. Type: &ast.TypeName{Name: "text"},
  928. },
  929. {
  930. Type: &ast.TypeName{Name: "integer"},
  931. },
  932. {
  933. Type: &ast.TypeName{Name: "text"},
  934. },
  935. {
  936. Type: &ast.TypeName{Name: "text"},
  937. },
  938. },
  939. ReturnType: &ast.TypeName{Name: "text"},
  940. },
  941. {
  942. Name: "SNIPPET",
  943. Args: []*catalog.Argument{
  944. {
  945. Type: &ast.TypeName{Name: "text"},
  946. },
  947. {
  948. Type: &ast.TypeName{Name: "integer"},
  949. },
  950. {
  951. Type: &ast.TypeName{Name: "text"},
  952. },
  953. {
  954. Type: &ast.TypeName{Name: "text"},
  955. },
  956. {
  957. Type: &ast.TypeName{Name: "text"},
  958. },
  959. {
  960. Type: &ast.TypeName{Name: "integer"},
  961. },
  962. },
  963. ReturnType: &ast.TypeName{Name: "text"},
  964. },
  965. {
  966. Name: "bm25",
  967. Args: []*catalog.Argument{
  968. {
  969. Type: &ast.TypeName{Name: "text"},
  970. },
  971. {
  972. Type: &ast.TypeName{Name: "real"},
  973. Mode: ast.FuncParamVariadic,
  974. },
  975. },
  976. ReturnType: &ast.TypeName{Name: "real"},
  977. },
  978. }
  979. return s
  980. }