Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 113 lines (64 sloc) 4.258 kb
f1b8c46 @theirix Restructured to match PGXN layout
authored
1 JSON accessor functions for PostgreSQL
2 ======================================
3
02f37b0 @theirix Added PGXN metadata, version 1.3.0
authored
4 Extension provides stored functions for accessing [JSON](http://www.json.org/) fields by keys and converting JSON arrays.
f1b8c46 @theirix Restructured to match PGXN layout
authored
5
7eeec14 @theirix Some docs
authored
6 This project contains PostgreSQL [extension](http://www.postgresql.org/docs/9.1/static/extend-extensions.html) `json_accessors` with stored functions. Extension is native and writen in C on top of [cJSON](http://sourceforge.net/projects/cjson/) library.
7
4ec941f @theirix Works with PostgreSQL 9.2
authored
8 Extension supports PostgreSQL 9.1 and 9.2.
9
f1b8c46 @theirix Restructured to match PGXN layout
authored
10 PostgreSQL have had no JSON support until version 9.2, which [introduced some support](http://www.postgresql.org/docs/9.2/static/functions-json.html).
11 These 9.2 functions won't help with indexing JSON data.
12
13 JSON parsing functions may be written using [PL/V8](http://code.google.com/p/plv8js/wiki/PLV8) module,
14 [this article](http://people.planetpostgresql.org/andrew/index.php?/archives/249-Using-PLV8-to-index-JSON.html) has an example of PL/V8 usage.
15 This project provides accessor functions for JSON without using PL/V8.
16
4ec941f @theirix Works with PostgreSQL 9.2
authored
17
b3e5e5e @theirix Adjusted doc, fixed one edge case
authored
18 Usage
1559ba3 @theirix Doc changes
authored
19 -----
f1b8c46 @theirix Restructured to match PGXN layout
authored
20
37bda5f @theirix Doc fixes, version bump
authored
21 Please consult with doc/json_accessors.md for a function and operator reference.
22
23 On PGXN please click on extension from _Extensions_ section to view reference.
f1b8c46 @theirix Restructured to match PGXN layout
authored
24
25
26 Installing extension
27 --------------------
28
4ec941f @theirix Works with PostgreSQL 9.2
authored
29 To use an extension one must be built, installed into PostgreSQL directory
30 and registered in a database.
31
32 ### Building extension
33
34 #### Using PGXN network
35
36 The easisest method to get and install an extension from PGXN network.
37 PGXN client downloads and builds the extension.
38
39 pgxn --pg_config <postgresql_install_dir>/bin/pg_config install json_accessors
40
41 PGXN client itself is available at [github](https://github.com/dvarrazzo/pgxnclient) and
42 can be installed with your favourite method, i.e. `easy_install pgxnclient`.
43
44 #### Using PGXS makefiles
f1b8c46 @theirix Restructured to match PGXN layout
authored
45
46 C extension are best built and installed using [PGXS](http://www.postgresql.org/docs/9.1/static/extend-pgxs.html).
47 PGXS ensures that make is performed with needed compiler and flags. You only need GNU make and a compiler to build
ac27d4d @theirix Builds on windows
authored
48 an extension on an almost any UNIX platform (Linux, Solaris, OS X).
f1b8c46 @theirix Restructured to match PGXN layout
authored
49
50 Compilation:
51
52 gmake PG_CONFIG=<postgresql_install_dir>/bin/pg_config
53
54 Installation (as superuser):
55
56 gmake PG_CONFIG=<postgresql_install_dir>/bin/pg_config install
57
4ec941f @theirix Works with PostgreSQL 9.2
authored
58 PostgreSQL server must be restarted.
f1b8c46 @theirix Restructured to match PGXN layout
authored
59
60 To uninstall extension completely you may use this command (as superuser):
61
62 gmake PG_CONFIG=<postgresql_install_dir>/bin/pg_config uninstall
63
64 Project contains SQL tests that can be launched on PostgreSQL with installed extension.
65 Tests are performed on a dynamically created database with a specified user (with the
66 appropriated permissions - create database, for example):
67
f244050 @theirix Fixed test fail due to conflicted names
authored
68 gmake PG_CONFIG=<postgresql_install_dir>/bin/pg_config PGUSER=postgres installcheck
f1b8c46 @theirix Restructured to match PGXN layout
authored
69
4ec941f @theirix Works with PostgreSQL 9.2
authored
70 #### Manually
f1b8c46 @theirix Restructured to match PGXN layout
authored
71
72 Use this method if you have a precompiled extension and do not want to install this with help of PGXS.
73 Or maybe you just do not have GNU make on a production server.
ac27d4d @theirix Builds on windows
authored
74 Or if you use Windows (use MSVC 2008 for Postgres 9.1 and MSVC 2010 for Postgres 9.2).
f1b8c46 @theirix Restructured to match PGXN layout
authored
75
76 Copy library to the PostgreSQL library directory:
77
78 cp json_accessors.so `<postgresql_install_dir>/bin/pg_config --pkglibdir`
79
80 Copy control file to the extension directory:
81
82 cp json_accessors.control `<postgresql_install_dir>/bin/pg_config --sharedir`/extension
83
84 Copy SQL prototypes file to the extension directory:
85
37bda5f @theirix Doc fixes, version bump
authored
86 cp json_accessors--<version>.sql `<postgresql_install_dir>/bin/pg_config --sharedir`/extension
f1b8c46 @theirix Restructured to match PGXN layout
authored
87
4ec941f @theirix Works with PostgreSQL 9.2
authored
88 To uninstall extension just remove files you copied before.
f1b8c46 @theirix Restructured to match PGXN layout
authored
89
4ec941f @theirix Works with PostgreSQL 9.2
authored
90 ### Creating extension in a database
f1b8c46 @theirix Restructured to match PGXN layout
authored
91
4ec941f @theirix Works with PostgreSQL 9.2
authored
92 Extension must be previously installed to a PostgreSQL directory.
f1b8c46 @theirix Restructured to match PGXN layout
authored
93
4ec941f @theirix Works with PostgreSQL 9.2
authored
94 Extension is created in a particular database (as superuser):
f1b8c46 @theirix Restructured to match PGXN layout
authored
95
4ec941f @theirix Works with PostgreSQL 9.2
authored
96 create extension json_accessors;
f1b8c46 @theirix Restructured to match PGXN layout
authored
97
4ec941f @theirix Works with PostgreSQL 9.2
authored
98 It creates all the functions, operators and other stuff from extension.
99 Note that you must restart a server if a previous library was already installed
100 at the same place. In other words, always restart to be sure.
101
102 To drop an extension use:
103
104 drop extension json_accessors cascade;
f1b8c46 @theirix Restructured to match PGXN layout
authored
105
106
107 License information
108 -------------------
109
a814ca0 @theirix Changed license to PostgreSQL
authored
110 You can use any code from this project under the terms of [PostgreSQL License](http://www.postgresql.org/about/licence/).
37bda5f @theirix Doc fixes, version bump
authored
111
a814ca0 @theirix Changed license to PostgreSQL
authored
112 Please consult with the COPYING for license information.
Something went wrong with that request. Please try again.