Skip to content

Commit

Permalink
rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
lacanoid committed May 29, 2021
1 parent 736e4a8 commit d148466
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 3 deletions.
4 changes: 2 additions & 2 deletions META.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "datalink",
"abstract": "SQL/MED DATALINK type and functions",
"description": "A toy implementation SQL/MED datalinks",
"version": "0.11",
"version": "0.12",
"maintainer": [
"Ziga Kranjec <ziga@ljudmila.org>"
],
Expand All @@ -25,7 +25,7 @@
"datalink": {
"file": "datalink.sql",
"docfile": "README.md",
"version": "0.11",
"version": "0.12",
"abstract": "SQL/MED DATALINK type and functions"
}
},
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This extension uses a number of advanced PostgreSQL features for implementation,
including transactions, jsonb, event and instead-of triggers, listen/notify, plperlu...

Currently, it implements the following:
- SQL/MED DATALINK type
- SQL/MED DATALINK type, currently defined as domain over jsonb
- SQL/MED DATALINK constructors DLVALUE, DLPREVIOUSCOPY and DLNEWCOPY
- SQL/MED functions DLURLCOMPLETE, DLURLCOMPLETEONLY
- SQL/MED functions DLURLSCHEME, DLURLSERVER
Expand Down
50 changes: 50 additions & 0 deletions docs/primer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
Here are some examples on how to use datalink

##Creating datalink values

You can create datalink values from URLs by using `dlvalue()` function.

select dlvalue('http://www.github.io/');
dlvalue
----------------------------------
{"url": "http://www.github.io/"}
(1 row)

URLs are checked for syntax and wrong ones throw errors.

postgres=# select dlvalue('foo bar');
ERROR: invalid input syntax for type uri at or near " bar"
CONTEXT: PL/pgSQL function dlvalue(text,datalink.dl_linktype,text) line 15 at assignment

URLs are normalized before they are converted to datalinks.

select dlvalue('http://www.github.io/a/b/c/d/../../e');
dlvalue
---------------------------------------
{"url": "http://www.github.io/a/b/e"}
(1 row)

Use `dlurlcompleteonly()` function to convert a datalink back to URL.

select dlurlcompleteonly(dlvalue('http://www.github.io/a/b/c/d/../../e'));
dlurlcompleteonly
----------------------------
http://www.github.io/a/b/e
(1 row)

You can also use dlvalue() with absolute paths for file links.

select dlvalue('/var/www/datalink/index.html');
dlvalue
------------------------------------------------
{"url": "file:///var/www/datalink/index.html"}
(1 row)

Use `dlurlpatheonly()` function to get file path from a datalink.

select dlurlpathonly(dlvalue('/var/www/datalink/index.html'));
dlurlpathonly
------------------------------
/var/www/datalink/index.html
(1 row)

0 comments on commit d148466

Please sign in to comment.