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

Commit 29e644f

Browse files
committed
Change README, add few fixes
1 parent 66d56a9 commit 29e644f

File tree

4 files changed

+15
-21
lines changed

4 files changed

+15
-21
lines changed

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ And something like this:
1212

1313
```
1414
CREATE EXTENSION jsonbd;
15-
CREATE COMPRESSION METHOD cm1 HANDLER jsonbd_compression_handler;
16-
CREATE TABLE t(a JSONB);
17-
ALTER TABLE t ALTER COLUMN a SET COMPRESSED cm1;
15+
CREATE TABLE t(a JSONB COMPRESSED jsonbd);
1816
```
1917

20-
This is very early version and should not be used in any real systems.
18+
This extension is in development and not finished yet.

jsonbd--0.1.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
CREATE OR REPLACE FUNCTION jsonbd_compression_handler(INTERNAL)
22
RETURNS COMPRESSION_HANDLER AS 'MODULE_PATHNAME', 'jsonbd_compression_handler'
33
LANGUAGE C STRICT;
4+
5+
CREATE COMPRESSION METHOD jsonbd HANDLER jsonbd_compression_handler;

jsonbd_worker.c

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,13 @@ jsonbd_worker_main(Datum arg)
649649
worker_num = worker_args->worker_num;
650650
dboid = worker_args->dboid;
651651

652+
/* Connect to our database */
653+
BackgroundWorkerInitializeConnectionByOid(dboid, InvalidOid);
654+
655+
/* Create resource owner */
656+
CurrentResourceOwner = ResourceOwnerCreate(NULL, "jsonbd_worker");
657+
init_local_variables(worker_num, dboid);
658+
652659
/* We don't need this segment anymore */
653660
dsm_detach(seg);
654661

@@ -662,13 +669,6 @@ jsonbd_worker_main(Datum arg)
662669
/* Set launcher free */
663670
SetLatch(&starter->procLatch);
664671

665-
/* Connect to our database */
666-
BackgroundWorkerInitializeConnectionByOid(dboid, InvalidOid);
667-
668-
/* Create resource owner */
669-
CurrentResourceOwner = ResourceOwnerCreate(NULL, "jsonbd_worker");
670-
init_local_variables(worker_num, dboid);
671-
672672
MemoryContextSwitchTo(worker_context);
673673

674674
while (true)
@@ -791,19 +791,14 @@ jsonbd_register_worker(int worker_num, Oid dboid)
791791
worker.bgw_notify_pid = MyProcPid;
792792
memcpy(worker.bgw_library_name, "jsonbd", BGW_MAXLEN);
793793
memcpy(worker.bgw_function_name, CppAsString(jsonbd_worker_main), BGW_MAXLEN);
794-
795-
/* we need transaction to access syscache */
796-
start_xact_command();
797-
snprintf(worker.bgw_name, BGW_MAXLEN, "jsonbd, worker %d, db: \"%s\"",
798-
worker_num, get_database_name(dboid));
799-
finish_xact_command();
800-
794+
snprintf(worker.bgw_name, BGW_MAXLEN, "jsonbd, worker %d, db: %d",
795+
worker_num, dboid);
801796
worker.bgw_main_arg = UInt32GetDatum(dsm_segment_handle(seg));
802797

803798
/* Start dynamic worker */
804799
if (!RegisterDynamicBackgroundWorker(&worker, &bgw_handle))
805800
{
806-
elog(LOG, "jsonbd: cannot start dictionary worker");
801+
elog(LOG, "jsonbd: could not start dictionary worker");
807802
return false;
808803
}
809804

sql/basic.sql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
CREATE SCHEMA comp;
22
CREATE EXTENSION jsonbd SCHEMA comp;
3-
CREATE COMPRESSION METHOD cm1 HANDLER comp.jsonbd_compression_handler;
4-
CREATE TABLE comp.t(a JSONB COMPRESSED cm1);
3+
CREATE TABLE comp.t(a JSONB COMPRESSED jsonbd);
54
\d+ comp.t;
65

76
CREATE OR REPLACE FUNCTION comp.add_record()

0 commit comments

Comments
 (0)