Giter Club home page Giter Club logo

pg_protobuf's Introduction

pg_protobuf

Protobuf support for PostgreSQL.

Quick start

How to install:

# On Ubuntu:
sudo apt install postgresql-server-dev-13
cd /tmp
git clone https://github.com/afiskon/pg_protobuf.git
cd pg_protobuf
make
sudo make install
chmod a+w .
sudo -u postgres make installcheck

Usage example:

create extension pg_protobuf;

create table heroes (x bytea);

-- fill table with random Protobuf data
insert into heroes
  select E'\\x10191880082a060a0200011064822007' ||
         convert_to(substring(md5('' || random() || random()), 0, 8), 'utf-8')
  from generate_series(1,10000);

create function hero_name(x bytea) returns text as $$
begin
return protobuf_get_string(x, 512);
end
$$ language 'plpgsql' immutable;

create function hero_hp(x bytea) returns text as $$
begin
return protobuf_get_int(x, 2);
end
$$ language 'plpgsql' immutable;

create function hero_xp(x bytea) returns text as $$
begin
return protobuf_get_int(x, 3);
end
$$ language 'plpgsql' immutable;

create index hero_name_idx on heroes using btree(hero_name(x));

select hero_name(x) from heroes order by hero_name(x) limit 10;

-- make sure index is used
explain select hero_name(x) from heroes order by hero_name(x) limit 10;

Limitations

Current limitations and possible workarounds:

  • Modification of the Protobuf data is not supported.
  • Enums are not directly supported. However, you can read them using protobuf_get_int and protobuf_get_int_multi procedures;
  • Unsigned Protobuf types (uint, fixed32, fixed64) are not directly supported due to lack of unsigned integer types in PostgreSQL;
  • Attribute [packed=true] for repeated values is not supported by *_multi procedures. However these values can be decoded as raw byte arrays using protobuf_get_bytes* procedures. Warning! In Protobuf 3 values are packed by default unless specified otherwise;

pg_protobuf's People

Contributors

afiskon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pg_protobuf's Issues

How can I install pg_protobuf extension on Postgresql 10/11 ?

Hi,
When I run in order of " make , makeinstall, makeinstall " commands at terminal ,

it says "No Target"

or

"Makefile:14: /usr/lib64/pgsql/pgxs/src/makefiles/pgxs.mk: No such file or directory make: *** No rule to make target `/usr/lib64/pgsql/pgxs/src/makefiles/pgxs.mk'. Stop."

What should I do ?

Please help
Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.