Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/steve-chavez/pltinyexpr
PostgreSQL toy language handler for learning purposes.
https://github.com/steve-chavez/pltinyexpr
Last synced: about 1 month ago
JSON representation
PostgreSQL toy language handler for learning purposes.
- Host: GitHub
- URL: https://github.com/steve-chavez/pltinyexpr
- Owner: steve-chavez
- License: mit
- Created: 2023-06-05T04:46:29.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-06-22T16:31:54.000Z (over 1 year ago)
- Last Synced: 2024-03-17T09:34:47.389Z (8 months ago)
- Language: C
- Homepage:
- Size: 13.7 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PL/tinyexpr
PL/tinyexpr is a procedural language handler created for learning purposes.
It evaluates math expressions using https://github.com/codeplea/tinyexpr.
## Installation
```bash
make && sudo make install
```## Usage
```sql
create extension pltinyexpr;
```It runs functions with parameters:
```sql
create or replace function sample(a float8, b float8) returns float8 as $$
abs(sqrt(a^2) - 5*b)
$$ language pltinyexpr;
-- all the functions in tinyexpr are supported https://github.com/codeplea/tinyexpr/#functions-supportedselect sample(9,2);
sample
--------
1
(1 row)
```It validates function's signatures:
```sql
create or replace function sample(x text) returns float8 as $$
x + 4
$$ language pltinyexpr;
ERROR: only parameters of double precision or float8 types are allowed
```It runs inline expressions, but they only LOG their result:
```sql
DO LANGUAGE pltinyexpr $$
5 * 4
$$;
INFO: expression result is: 20.000000
DO
```## Testing
```bash
make installcheck
```