- Notifications
You must be signed in to change notification settings - Fork49
start docs#5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
niquola wants to merge4 commits intopostgrespro:masterChoose a base branch fromniquola:master
base:master
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Uh oh!
There was an error while loading.Please reload this page.
Open
Changes from1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
NextNext commit
Start documentation & travis ci
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
commit1f710fb2f1e45ac32962f1c35a7b9b5b7f66f056
There are no files selected for viewing
1 change: 1 addition & 0 deletions.gitignore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -6,3 +6,4 @@ jsquery_gram.h | ||
regression.diffs | ||
regression.out | ||
results | ||
*sw? |
8 changes: 8 additions & 0 deletions.travis.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
before_script: | ||
- sudo su $USER -c ".travis/install" | ||
script: sudo su $USER -c ".travis/test" | ||
addons: | ||
postgresql: "9.3" | ||
47 changes: 47 additions & 0 deletions.travis/install
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/bash | ||
export ROOT=`pwd` | ||
export BUILD_DIR=/home/travis/build/pg | ||
export SOURCE_DIR=$BUILD_DIR/src | ||
export PGDATA=$BUILD_DIR/data | ||
export PGPORT=5777 | ||
export PGHOST=localhost | ||
export PG_BIN=$BUILD_DIR/bin | ||
export PG_CONFIG=$BUILD_DIR | ||
export PATH=$PATH:$PG_BIN | ||
sudo apt-get -y -qq --purge remove postgresql libpq-dev libpq5 postgresql-client-common postgresql-common | ||
sudo apt-get -qq update | ||
sudo apt-get -qqy install \ | ||
git \ | ||
build-essential \ | ||
gettext \ | ||
libreadline6 \ | ||
libreadline6-dev \ | ||
zlib1g-dev \ | ||
flex \ | ||
bison \ | ||
libxml2-dev \ | ||
libxslt-dev | ||
git clone -b REL9_4_STABLE --depth=1 git://git.postgresql.org/git/postgresql.git $SOURCE_DIR | ||
# XML2_CONFIG=`which xml2-config` cd $SOURCE_DIR ./configure --prefix=$BUILD_DIR --with-libxml &&\ | ||
cd $SOURCE_DIR && ./configure --prefix=$BUILD_DIR && make && make install | ||
cd $ROOT && make USE_PGXS=1 && make install USE_PGXS=1 | ||
mkdir -p $PGDATA | ||
$PG_BIN/initdb -D $PGDATA -E utf8 | ||
# echo "host all all 0.0.0.0/0 md5" >> $PGDATA/pg_hba.conf | ||
# echo "listen_addresses='*'" >> $PGDATA/postgresql.conf | ||
# echo "port=$PGPORT" >> $PGDATA/postgresql.conf | ||
$PG_BIN/pg_ctl -D $PGDATA start |
17 changes: 17 additions & 0 deletions.travis/test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
export BUILD_DIR=/home/travis/build/pg | ||
export SOURCE_DIR=$BUILD_DIR/src | ||
export PGDATA=$BUILD_DIR/data | ||
export PGPORT=5777 | ||
export PGHOST=localhost | ||
export PG_BIN=$BUILD_DIR/bin | ||
export PG_CONFIG=$BUILD_DIR | ||
export PATH=$PATH:$PG_BIN | ||
export ROOT=`pwd` | ||
make installcheck USE_PGXS=1 |
56 changes: 56 additions & 0 deletionsDockerfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
FROM ubuntu:14.04 | ||
MAINTAINER Nikolay Ryzhikov <niquola@gmail.com> | ||
RUN apt-get -qq update | ||
RUN apt-get -qqy install git \ | ||
build-essential \ | ||
gettext \ | ||
libreadline6 \ | ||
libreadline6-dev \ | ||
zlib1g-dev \ | ||
flex \ | ||
bison \ | ||
libxml2-dev \ | ||
libxslt-dev | ||
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen | ||
RUN useradd -m -s /bin/bash db && echo "db:db"|chpasswd && adduser db sudo | ||
RUN echo 'db ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers | ||
USER db | ||
ENV HOME /home/db | ||
ENV PG_BRANCH REL9_4_STABLE | ||
ENV PG_REPO git://git.postgresql.org/git/postgresql.git | ||
RUN git clone -b $PG_BRANCH --depth=1 $PG_REPO $HOME/src | ||
RUN cd $HOME/src && ./configure --prefix=$HOME/bin && make && make install | ||
ENV SOURCE_DIR $HOME/src | ||
ENV PATH $HOME/bin/bin:$PATH | ||
ENV PGDATA $HOME/data | ||
ENV PGPORT 5432 | ||
ENV PGHOST localhost | ||
RUN mkdir -p $PGDATA | ||
RUN initdb -D $PGDATA -E utf8 | ||
RUN echo "host all all 0.0.0.0/0 md5" >> $PGDATA/pg_hba.conf | ||
RUN echo "listen_addresses='*'" >> $PGDATA/postgresql.conf | ||
RUN echo "port=$PGPORT" >> $PGDATA/postgresql.conf | ||
RUN pg_ctl -D $HOME/data -w start && psql postgres -c "alter user db with password 'db';" | ||
RUN pg_ctl -D $HOME/data -w start && \ | ||
cd $SOURCE_DIR/contrib/pgcrypto && \ | ||
make && make install && make installcheck && \ | ||
pg_ctl -w stop | ||
RUN pg_ctl -D $HOME/data -w start && \ | ||
cd $SOURCE_DIR/contrib && \ | ||
git clone https://github.com/akorotkov/jsquery.git && \ | ||
cd jsquery && make && make install && make installcheck && \ | ||
pg_ctl -w stop | ||
EXPOSE 5432 | ||
CMD pg_ctl -D $HOME/data -w start && psql postgres |
102 changes: 102 additions & 0 deletionsREADME.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
# jsquery | ||
[](https://travis-ci.org/niquola/jsquery) | ||
`Jsquery` is PostgreSQL extension, | ||
which provides advanced query language for jsonb documents. | ||
Features: | ||
* recursive structure of query | ||
* search in array | ||
* rich set of comparison operators | ||
* types support | ||
* schema support (constraints on keys, values) | ||
* indexes support | ||
* hinting support | ||
Jsquery implemented as datatype `jsquery` and operator `@@`. | ||
Examples: | ||
`#` - any element array | ||
```SQL | ||
SELECT '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.# = 2'; | ||
``` | ||
`%` - any key | ||
```SQL | ||
SELECT '{"a": {"b": [1,2,3]}}'::jsonb @@ '%.b.# = 2'; | ||
``` | ||
`*` - anything | ||
```SQL | ||
SELECT '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.# = 2'; | ||
``` | ||
`$` - current element | ||
```SQL | ||
select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.# ($ = 2 OR $ < 3)'; | ||
``` | ||
Use "double quotes" for key ! | ||
```SQL | ||
select 'a1."12222" < 111'::jsquery; | ||
``` | ||
## Documentation | ||
* [Getting Started](doc/intro.md) | ||
* [Syntax](doc/syntax.md) | ||
* [Operators](doc/operators.md) | ||
* [Indexes](doc/indexes.md) | ||
* [Optimizer](doc/optimiser.md) | ||
## Installation | ||
Requirements: | ||
* PostgreSQL >= 9.4 | ||
### Using pgxn.org ? | ||
http://pgxn.org/ | ||
### Build from sources | ||
```sh | ||
git clone https://github.com/akorotkov/jsquery.git $SOURCE_DIR/contrib | ||
cd $SOURCE_DIR/contrib/jsquery && make && make install && make installcheck | ||
``` | ||
### Using docker | ||
``` | ||
docker run --name=myjsquery -p 5432:5555 -i -t jsquery/jsquery | ||
psql -p 5555 | ||
``` | ||
## Roadmap | ||
* TODO1 | ||
* TODO2 | ||
## Contribution | ||
You can contribute by: | ||
* stars | ||
* [issues](https://github.com/akorotkov/jsquery/issues) | ||
* documentation | ||
* pull requests | ||
## License | ||
MIT? |
Empty file addeddoc/indexes.md
Empty file.
39 changes: 39 additions & 0 deletionsdoc/intro.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Jsquery intro | ||
```jsquery``` implemented as datatype and `@@` operator. | ||
Search query has a form: | ||
```SQL | ||
SELECT * FROM mytable | ||
WHERE jsonb_column @@ 'jsquery_expression'; | ||
``` | ||
```jsquery_expression``` usually consists | ||
of *path* and *value_expression*. | ||
For example if we are looking for: | ||
```json | ||
{ | ||
"user": { | ||
"name": "Diego" | ||
}, | ||
"site": { | ||
"url": "diego.com" | ||
} | ||
} | ||
``` | ||
the expresion is: | ||
``` | ||
user.name = 'diego' | ||
``` | ||
Sevral expressions could be connected using `AND` & `OR` operators: | ||
``` | ||
user.name = 'diego' AND site.url = 'diego.com' | ||
``` |
75 changes: 75 additions & 0 deletionsdoc/jsquery.ebnf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
result ::= ( expr | null) | ||
array ::= '[' value_list ']' | ||
scalar_value ::= ( | ||
STRING_P | ||
| IN_P | ||
| IS_P | ||
| OR_P | ||
| AND_P | ||
| NOT_P | ||
| NULL_P | ||
| TRUE_P | ||
| ARRAY_T | ||
| FALSE_P | ||
| NUMERIC_T | ||
| OBJECT_T | ||
| STRING_T | ||
| BOOLEAN_T | ||
| NUMERIC_P ) | ||
value_list ::= (scalar_value | value_list ',' scalar_value) | ||
right_expr ::= ( | ||
'='right_exprscalar_value | ||
| IN_P '(' value_list ')' | ||
| '=' array | ||
| '=' '*' | ||
| '<' NUMERIC_P | ||
| '>' NUMERIC_P | ||
| '<' '=' NUMERIC_P | ||
| '>' '=' NUMERIC_P | ||
| '@' '>' array | ||
| '<' '@' array | ||
| '&' '&' array | ||
| IS_P ARRAY_T | ||
| IS_P NUMERIC_T | ||
| IS_P OBJECT_T | ||
| IS_P STRING_T | ||
| IS_P BOOLEAN_T ) | ||
expr ::= ( | ||
path right_expr | ||
| path HINT_P right_expr | ||
| NOT_P expr | ||
| NOT_P HINT_P right_expr | ||
| NOT_P right_expr | ||
| path '(' expr ')' | ||
| '(' expr ')' | ||
| expr AND_P expr | ||
| expr OR_P expr) | ||
key ::= ( | ||
'*' | ||
| '#' | ||
| '%' | ||
| '$' | ||
| STRING_P | ||
| IN_P | ||
| IS_P | ||
| OR_P | ||
| AND_P | ||
| NULL_P | ||
| TRUE_P | ||
| ARRAY_T | ||
| FALSE_P | ||
| NUMERIC_T | ||
| OBJECT_T | ||
| STRING_T | ||
| BOOLEAN_T | ||
| NUMERIC_P ) | ||
key_any ::= ( key | NOT_P) | ||
path ::= ( key | path '.' key_any | NOT_P '.' key_any ) |
Empty file addeddoc/operators.md
Empty file.
Empty file addeddoc/optimizer.md
Empty file.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.