Browse files

Preparing for release

  • Loading branch information...
1 parent dd8443e commit 2c6420055d4c781bd469d3bbae53f1ca6083835d @claesjac committed Sep 5, 2011
Showing with 70 additions and 32 deletions.
  1. +19 −0 META.json
  2. +9 −2 Makefile
  3. +9 −7 README
  4. +8 −3 pg-json.c
  5. +14 −0 pg-json.control
  6. +0 −17 pg-json.h
  7. +11 −3 pg-json.sql.in → pg-json.sql
View
19 META.json
@@ -0,0 +1,19 @@
+{
+ "name": "pg-json",
+ "abstract": "A json data type and related functions",
+ "description": "This library contains a json datatype and some functionality for working with it",
+ "version": "0.0.1",
+ "maintainer": "Claes Jakobsson <claes@surfar.nu>"
+ "license": "mit",
+ "resources": {
+ "repository": {
+ "url": "git://github.com/claesjac/pg-json.git",
+ "web": "https://github.com/claesjac/pg-json",
+ "type": "git"
+ }
+ },
+ "meta-spec": {
+ "version": "1.0.0",
+ "url": "http://pgxn.org/meta/spec.txt"
+ }
+}
View
11 Makefile
@@ -1,10 +1,17 @@
MODULE_big = pg-json
OBJS = pg-json.o
-DATA_built = pg-json.sql
-DATA = uninstall_pg-json.sql
+
+EXTENSION = pg-json
+DATA = pg-json.sql
SHLIB_LINK += -ljansson
+ifdef USE_PGXS
PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
+else
+subdir = contrib/pg-json
+include $(top_builddir)/src/Makefile.global
+include $(top_srcdir)/contrib/contrib-global.mk
+endif
View
16 README
@@ -1,18 +1,20 @@
pg-json - JSON support for PostgreSQL
--------------------------------------
+=====================================
This is a postgres extension which provides a JSON type and rudimentary opertators
and functions on them. It uses the Jansson JSON library (http://www.digip.org/jansson/)
which you need installed and findable by your linker.
-INSTALL
+Building
--------------
-$ make
-$ make install
-$ psql -f <path to pg-json.sql> <your database>
-USAGE
--------------
+$ make USE_PGXS=1
+$ sudo make install USE_PGXS=1
+
+It'll install a pg-json.sql in your postgres which you might have to load for your database also.
+
+Usage
+-----
This module provides a 'json' datatype. It's more or less just a bytea which assumes that
the data is UTF-8 encoded. When created it validates that it's parseable as JSON.
View
11 pg-json.c
@@ -9,7 +9,12 @@
*-------------------------------------------------------------------------
*/
-#include "pg-json.h"
+#include "postgres.h"
+#include "fmgr.h"
+#include "utils/builtins.h"
+#include <jansson.h>
+
+typedef struct varlena Json;
PG_MODULE_MAGIC;
@@ -226,10 +231,10 @@ static int json_compare(Json *ja, Json *jb) {
PG_FUNCTION_INFO_V1(json_equals);
Datum json_equals(PG_FUNCTION_ARGS) {
- PG_RETURN_BOOL(json_compare(PG_GETARG_POINTER(0), PG_GETARG_POINTER(1)) == 1);
+ PG_RETURN_BOOL(json_compare((Json *) PG_GETARG_POINTER(0), (Json *) PG_GETARG_POINTER(1)) == 1);
}
PG_FUNCTION_INFO_V1(json_not_equals);
Datum json_not_equals(PG_FUNCTION_ARGS) {
- PG_RETURN_BOOL(json_compare(PG_GETARG_POINTER(0), PG_GETARG_POINTER(1)) != 1);
+ PG_RETURN_BOOL(json_compare((Json *) PG_GETARG_POINTER(0), (Json *) PG_GETARG_POINTER(1)) != 1);
}
View
14 pg-json.control
@@ -0,0 +1,14 @@
+#####################################################################
+#
+# JSON functions using the Jansson JSON library
+#
+# Copyright (c) 2011, Claes Jakobsson, Glue Finance AB
+#
+# This software is licensed under the MIT license. See LICENSE
+#
+#####################################################################
+
+comment = 'A json data type'
+default_version = '0.0.1'
+module_pathname = '$libdir/pg-json'
+relocatable = true
View
17 pg-json.h
@@ -1,17 +0,0 @@
-/*-------------------------------------------------------------------------
- *
- * JSON functions using the Jansson JSON library
- *
- * Copyright (c) 2011, Claes Jakobsson, Glue Finance AB
- *
- * This software is licensed under the MIT license. See LICENSE
- *
- *-------------------------------------------------------------------------
- */
-
-#include "postgres.h"
-#include "fmgr.h"
-#include "utils/builtins.h"
-#include <jansson.h>
-
-typedef struct varlena Json;
View
14 pg-json.sql.in → pg-json.sql
@@ -1,6 +1,14 @@
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
-
+/*-------------------------------------------------------------------------
+ *
+ * JSON functions using the Jansson JSON library
+ *
+ * Copyright (c) 2011, Claes Jakobsson, Glue Finance AB
+ *
+ * This software is licensed under the MIT license. See LICENSE
+ *
+ *-------------------------------------------------------------------------
+ */
+
CREATE OR REPLACE FUNCTION json_in(cstring)
RETURNS json
AS '$libdir/pg-json'

0 comments on commit 2c64200

Please sign in to comment.