Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 0a653b9

Browse files
committed
Fix compability with latest master and the patch
1 parent e94dc73 commit 0a653b9

File tree

3 files changed

+28
-25
lines changed

3 files changed

+28
-25
lines changed

jsonbd--0.1.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CREATE OR REPLACE FUNCTION jsonbd_compression_handler(INTERNAL)
2-
RETURNS COMPRESSION_HANDLER AS 'MODULE_PATHNAME', 'jsonbd_compression_handler'
2+
RETURNS COMPRESSION_AM_HANDLER AS 'MODULE_PATHNAME', 'jsonbd_compression_handler'
33
LANGUAGE C STRICT;
44

5-
CREATE COMPRESSION METHOD jsonbd HANDLER jsonbd_compression_handler;
5+
CREATE ACCESS METHOD jsonbd TYPE COMPRESSION HANDLER jsonbd_compression_handler;

jsonbd.c

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "postgres.h"
55
#include "fmgr.h"
66

7-
#include "access/compression.h"
7+
#include "access/cmapi.h"
88
#include "access/htup_details.h"
99
#include "access/sysattr.h"
1010
#include "access/xact.h"
@@ -643,7 +643,7 @@ packJsonbValue(JsonbValue *val, int header_size, int *len)
643643

644644
/* Compress jsonb using dictionary */
645645
static struct varlena *
646-
jsonbd_compress(CompressionMethodOptions *cmoptions, const struct varlena *data)
646+
jsonbd_cmcompress(CompressionAmOptions *cmoptions, const struct varlena *data)
647647
{
648648
int size;
649649
JsonbIteratorToken r;
@@ -712,7 +712,7 @@ jsonbd_compress(CompressionMethodOptions *cmoptions, const struct varlena *data)
712712
Assert(offset == len);
713713

714714
/* retrieve or generate ids */
715-
jsonbd_worker_get_key_ids(cmoptions->cmoptoid, buf, len, idsbuf, nkeys);
715+
jsonbd_worker_get_key_ids(cmoptions->acoid, buf, len, idsbuf, nkeys);
716716

717717
/* replace the old keys with encoded ids */
718718
for (i = 0; i < nkeys; i++)
@@ -740,21 +740,23 @@ jsonbd_compress(CompressionMethodOptions *cmoptions, const struct varlena *data)
740740
return res;
741741
}
742742

743-
static void
744-
jsonbd_configure(Form_pg_attribute attr, List *options)
743+
static void *
744+
jsonbd_cminitstate(Oid acoid, List *options)
745745
{
746746
if (!OidIsValid(jsonbd_get_dictionary_relid()))
747747
elog(ERROR, "could not create jsonbd dictionary");
748+
749+
return NULL;
748750
}
749751

750752
static void
751-
jsonbd_drop(Form_pg_attribute attr, List *options)
753+
jsonbd_cmdrop(Oid acoid)
752754
{
753755
/* TODO: if there is no compression options, remove the dictionary */
754756
}
755757

756758
static struct varlena *
757-
jsonbd_decompress(CompressionMethodOptions *cmoptions, const struct varlena *data)
759+
jsonbd_cmdecompress(CompressionAmOptions *cmoptions, const struct varlena *data)
758760
{
759761
JsonbIteratorToken r;
760762
JsonbValue v,
@@ -802,7 +804,7 @@ jsonbd_decompress(CompressionMethodOptions *cmoptions, const struct varlena *dat
802804
}
803805

804806
/* retrieve keys */
805-
buf = jsonbd_worker_get_keys(cmoptions->cmoptoid, compression_buffers->idsbuf, nkeys, &buflen);
807+
buf = jsonbd_worker_get_keys(cmoptions->acoid, compression_buffers->idsbuf, nkeys, &buflen);
806808
if (buf == NULL)
807809
elog(ERROR, "jsonbd: decompression error");
808810

@@ -830,21 +832,24 @@ jsonbd_decompress(CompressionMethodOptions *cmoptions, const struct varlena *dat
830832
return res;
831833
}
832834

835+
static void
836+
jsonbd_cmcheck(Form_pg_attribute att, List *options)
837+
{
838+
if (att->atttypid != JSONBOID)
839+
elog(ERROR, "unexpected type %d for jsonbd compression handler",
840+
att->atttypid);
841+
}
842+
833843
Datum
834844
jsonbd_compression_handler(PG_FUNCTION_ARGS)
835845
{
836-
CompressionMethodRoutine *cmr = makeNode(CompressionMethodRoutine);
837-
CompressionMethodOpArgs *opargs =
838-
(CompressionMethodOpArgs *) PG_GETARG_POINTER(0);
839-
Oid typeid = opargs->typeid;
840-
841-
if (OidIsValid(typeid) && typeid != JSONBOID)
842-
elog(ERROR, "unexpected type %d for jsonbd compression handler", typeid);
846+
CompressionAmRoutine *routine = makeNode(CompressionAmRoutine);
843847

844-
cmr->configure = jsonbd_configure;
845-
cmr->drop = jsonbd_drop;
846-
cmr->compress = jsonbd_compress;
847-
cmr->decompress = jsonbd_decompress;
848+
routine->cmcheck = jsonbd_cmcheck;
849+
routine->cmdrop = jsonbd_cmdrop; /* no drop behavior */
850+
routine->cminitstate = jsonbd_cminitstate;
851+
routine->cmcompress = jsonbd_cmcompress;
852+
routine->cmdecompress = jsonbd_cmdecompress;
848853

849-
PG_RETURN_POINTER(cmr);
854+
PG_RETURN_POINTER(routine);
850855
}

jsonbd_worker.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,7 @@ init_worker(dsm_segment *seg)
141141
Assert(worker_context == NULL);
142142
worker_context = AllocSetContextCreate(TopMemoryContext,
143143
"jsonbd worker context",
144-
ALLOCSET_DEFAULT_MINSIZE,
145-
ALLOCSET_DEFAULT_INITSIZE,
146-
ALLOCSET_DEFAULT_MAXSIZE);
144+
ALLOCSET_DEFAULT_SIZES);
147145

148146
worker_cache_context = AllocSetContextCreate(TopMemoryContext,
149147
"jsonbd worker cache context",

0 commit comments

Comments
 (0)