profile
viewpoint

gzliudan/abieos 0

Binary <> JSON conversion using ABIs. Compatible with languages which can interface to C

gzliudan/eos 0

An open source smart contract platform

gzliudan/libpqxx 0

The official C++ client API for PostgreSQL.

issue openedEOSIO/abieos

bug: compile error after apply commit 64c5b07 and d218cb7

compile error after apply latest commit of master branch:

In file included from xxxxxx/eosio/abieos/src/abi.cpp:2:
xxxxxx/eosio/abieos/src/abieos.hpp:39:10: fatal error: 'abieos_numeric.hpp' file not found
#include "abieos_numeric.hpp"
         ^~~~~~~~~~~~~~~~~~~~
1 error generated.
src/CMakeFiles/baozi-db.dir/build.make:367: recipe for target 'src/CMakeFiles/baozi-db.dir/__/eosio/abieos/src/abi.cpp.o' failed
make[2]: *** [src/CMakeFiles/baozi-db.dir/__/eosio/abieos/src/abi.cpp.o] Error 1
CMakeFiles/Makefile2:140: recipe for target 'src/CMakeFiles/baozi-db.dir/all' failed
make[1]: *** [src/CMakeFiles/baozi-db.dir/all] Error 2
Makefile:148: recipe for target 'all' failed
make: *** [all] Error 2


xxxxxx/eosio/abieos/src/abieos.cpp:3:10: fatal error: 'abieos.h' file not found
#include "abieos.h"
         ^~~~~~~~~~
1 error generated.
src/CMakeFiles/baozi-db.dir/build.make:393: recipe for target 'src/CMakeFiles/baozi-db.dir/__/eosio/abieos/src/abieos.cpp.o' failed
make[2]: *** [src/CMakeFiles/baozi-db.dir/__/eosio/abieos/src/abieos.cpp.o] Error 1
CMakeFiles/Makefile2:140: recipe for target 'src/CMakeFiles/baozi-db.dir/all' failed
make[1]: *** [src/CMakeFiles/baozi-db.dir/all] Error 2
Makefile:148: recipe for target 'all' failed
make: *** [all] Error 2

my fix: in file src/abieos.hpp :

// #include "abieos_numeric.hpp"
#include <eosio/abieos_numeric.hpp>

in file src/abieos.cpp:

// #include "abieos.h"
#include <eosio/abieos.h>

created time in 9 days

issue openedEOSIO/eos

about compatibility of eos and clang version

Does EOS support clang 10 and clang 11?

created time in 14 days

startedrust-lang/rust

started time in 24 days

startedsteve0511/resty-redis-cluster

started time in a month

issue commentEOSIO/eos

How to debug eos

for smart contract, maybe you can use print function

Tinide

comment created time in a month

Pull request review commentEOSIO/abieos

erase old version abi before insert new version abi when set abi

 extern "C" abieos_bool abieos_set_abi_bin(abieos_context* context, uint64_t cont         from_bin(def, stream);         abieos::abi c;         convert(def, c);-        context->contracts.insert({name{contract}, std::move(c)});+        const name key {contract};+        context->contracts.erase(key);+        context->contracts.insert({key, std::move(c)});

Yes, insert_or_assign is better.

gzliudan

comment created time in 2 months

PullRequestReviewEvent

issue openedTencent/rapidjson

Does rapidjson support data type: int128, uint128, float128 ?

Does rapidjson support data type: int128, uint128, float128 ? Please notice that: clang has a data type named long double which is 16 bytes float number, and function snprintf supports this data type use length modifier L: https://en.cppreference.com/w/cpp/io/c/fprintf; GCC and MSVC also support long doube, but seems is 12 bytes and 80 bit.

created time in 2 months

issue commentEOSIO/abieos

abieos_set_abi_bin should update if contract is existing

I submited a PR #70 which resolves this problem.

farss

comment created time in 2 months

issue commentEOSIO/fc

Why return s._hash[3];?

_hash[3] is lowest uint64 in uint256 which has 4 uint64

UMU618

comment created time in 2 months

issue commentjtv/libpqxx

Is there a simple way to handle composite data type?

How about as_composite or as_tuple ?

gzliudan

comment created time in 2 months

issue commentjtv/libpqxx

Is there a simple way to handle composite data type?

I have no objection to closing this issus. Thank you very much.

gzliudan

comment created time in 2 months

issue commentEOSIO/eos

State history plugin: Block details does not include transaction hash.

I support trx_id should be included

datnguyencse

comment created time in 2 months

startedthibaultcha/lua-resty-mlcache

started time in 2 months

startedmoonbingbing/openresty-best-practices

started time in 2 months

issue commentEOSIO/eos

many empty rows of table_deltas from state history plugin output

The small problem is than when I decodes data from state history plugin, sometimes empty vectors are received. I feel strange at this issue, I think I got the reason after debug, so I reminds everyone here.

gzliudan

comment created time in 2 months

issue openedcameron314/concurrentqueue

require feature of dequeue data but not pop out from queue

such as: bool try_dequeue(item&, bool pop_flag = true);
When pop_flag is false, the data is not poped out from queue. This is very helpful, especially in the single consumer scenario.

created time in 2 months

issue openedcameron314/concurrentqueue

Need peek function for single consumer case

In single consumer and multi producer case, I want peek method, in case of consumer fails to handle message, the message can stay in queue and handled again later.

created time in 2 months

issue openedEOSIO/eos

How to decode packed_context_free_data, context_free_data, key_value_object.value and extensions_type ?

Does any one konw the format of packed_context_free_data, context_free_data, key_value_object.value, block_header.header_extensions and signed_block.block_extensions ? Or how to decode these binary fields ?

created time in 2 months

PR opened EOSIO/abieos

erase old version abi before insert new version abi when set abi

Because element keys in a map are unique, the insertion operation checks whether each inserted element has a key equivalent to the one of an element already in the container, and if so, the element is not inserted. So when we set a contract of new version, we must erase old version first. Otherwise the new contract is not inserted, and the old contract is still in context.

+6 -2

0 comment

1 changed file

pr created time in 2 months

push eventgzliudan/abieos

liudan

commit sha 720ca5dd210aa3403fd6cb4b1adfe6de195eaf8c

erase old contract before insert new contract because the std::map not insert new element when there's same key already in it

view details

push time in 2 months

fork gzliudan/abieos

Binary <> JSON conversion using ABIs. Compatible with languages which can interface to C

fork in 2 months

issue commentEOSIO/eos

How to debug eos

You can compile a debug version, then use IDE such as clion to debug EOS.

Tinide

comment created time in 2 months

issue openedEOSIO/eos

Question about extensions_type

The type of signed_block.block_extensions and block_header.header_extensions are extensions_type, what's kind of data is storaged in extensions_type? How to decode then? Is there documents?

created time in 2 months

startedsewenew/redis-plus-plus

started time in 2 months

startedEOSIO/abieos

started time in 2 months

issue closedjtv/libpqxx

Question about reuse pqxx::work

Sorry to trouble you again. Here‘s a question about reuse transaction: After commited a transaction, can this transaction object be used to execute a new query? I saw a std::exception when I doing so: Could not execute query : transaction is already closed.

closed time in 2 months

gzliudan

issue commentjtv/libpqxx

Question about reuse pqxx::work

thanks.

gzliudan

comment created time in 2 months

issue openedjtv/libpqxx

Question about reuse pqxx::work

Sorry to trouble you again. Here‘s a question about reuse transaction: After commited a transaction, can this transaction object be used to execute a new query? I saw a std::exception when I doing so: Could not execute query : transaction is already closed.

created time in 2 months

issue commentjtv/libpqxx

Is there a simple way to handle composite data type?

Here's an nested composite type example:

CREATE TYPE key_weight AS 
(
    weight int2,
    key    text
);


CREATE TYPE authority AS 
(
    threshold int4,
    keys      key_weight[]
);

CREATE TYPE producer AS 
(
    name text,
    auth authority[]
);

CREATE TABLE schedules
(
    id serial PRIMARY KEY,
    version   int4 NOT NULL,
    producers producer[] NOT NULL DEFAULT '{}'
);
gzliudan

comment created time in 2 months

issue commentjtv/libpqxx

not support std::nullopt as NULL

Yes, I saw your new commit which support std::nullopt as NULL, so I closed this issue. Thanks your hard work.

gzliudan

comment created time in 3 months

issue closedjtv/libpqxx

not support std::nullopt as NULL

When I pass std::nullopt as NULL, The compiler report below errors:

In function `void pqxx::internal::params::add_field<std::nullopt_t>(std::nullopt_t const&)':
undefined reference to `pqxx::nullness<std::nullopt_t, void>::is_null(std::nullopt_t const&)'
In function `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > pqxx::to_string<std::nullopt_t>(std::nullopt_t const&)':
undefined reference to `pqxx::nullness<std::nullopt_t, void>::is_null(std::nullopt_t const&)'
undefined reference to `pqxx::string_traits<std::nullopt_t>::size_buffer(std::nullopt_t const&)'
undefined reference to `pqxx::string_traits<std::nullopt_t>::into_buf(char*, char*, std::nullopt_t const&)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

When I pass std::optional<TypeName>(), the above erros disappears.

closed time in 3 months

gzliudan

startedcitusdata/pg_cron

started time in 3 months

issue commentjtv/libpqxx

not support std::nullopt as NULL

But write std::nullopt is more handy than write std::optional<type>(), since nullptr is treated as NULL, std::nullopt can be as NULL for same reason.

gzliudan

comment created time in 3 months

issue commentjtv/libpqxx

not support std::nullopt as NULL

Below expression is valid in C++: auto var = std::optional<int>(123456); auto data = bool_expression ? var : std::nullopt;

If std::nullopt is supported as NULL, then our codes will be more simpler.

A ternery expression only has a single type, it can't return one of two types. The type of your expression will always be a std::optional<> with the std::nullopt being lifted to the optional type when returned. As far as I know all expressions in C++ (that return values) are monotypical.

There are way too many unit types in C++ and I don't blame Jeroen for only wanting to support one (or two of them).

gzliudan

comment created time in 3 months

PR opened EOSIO/eos

distinguish old and new table_delta in state history plugin

replace bool with uint8_t to distinguish old and new table_delta in state history plugin: 0=removed; 1=old; 2=new

+5 -5

0 comment

2 changed files

pr created time in 3 months

push eventgzliudan/eos

liudan

commit sha 7269eaedfa852c1f40586285fd826d24412e730b

replace bool with uint8_t to distinguish old and new table_delta in state history plugin: 0=removed; 1=old; 2=new

view details

push time in 3 months

issue commentjtv/libpqxx

not support std::nullopt as NULL

Yes, I can use nullptr since I know data is null when coding. But support std::nullopt is also usefull, for example in ternary expression: some_condition ? std:::optional<TYPE>(data) : std::nullopt

gzliudan

comment created time in 3 months

issue commentEOSIO/eos

state_history_plugin maybe can not distinguish old and new delta

I decoded table delta data from state history plugin, no block number in row, so use bool can't distinguish between old values and new values.

I think there is block number in the row delta update, which will indicate new and old.

gzliudan

comment created time in 3 months

issue openedEOSIO/eos

many empty rows of table_deltas from state history plugin output

When I decodes table_deltas data from state history plugin, I find many empty rows, especially account_metadata table. codes as https://github.com/EOSIO/eos/blob/master/plugins/state_history_plugin/state_history_plugin.cpp#L524:

            if (undo.old_values.empty() && undo.new_ids.empty() && undo.removed_values.empty())
               return;
            deltas.push_back({});
            auto& delta = deltas.back();
            delta.name  = name;
            for (auto& old : undo.old_values) {
               auto& row = index.get(old.first);
               if (include_delta(old.second, row))
                  delta.rows.obj.emplace_back(true, pack_row(row));
            }
            for (auto& old : undo.removed_values)
               delta.rows.obj.emplace_back(false, pack_row(old.second));
            for (auto id : undo.new_ids) {
               auto& row = index.get(id);
               delta.rows.obj.emplace_back(true, pack_row(row));
            }

When undo.old_values is not empty, undo.removed_values and undo.new_ids is empty, but include_delta(old.second, row) is false, the above codes will not output any row.

created time in 3 months

issue commentjtv/libpqxx

Is there a simple way to handle composite data type?

We can use ARRAY and ROW construct some nested composite types, then use select command print it in psql to check the text format of output string. Like this article: https://stackoverflow.com/questions/7363516/how-to-formulate-an-array-literal-of-a-composite-type-containing-arrays

gzliudan

comment created time in 3 months

issue commentjtv/libpqxx

Is there a simple way to handle composite data type?

Please refer to https://www.postgresql.org/docs/12/rowtypes.html#ROWTYPES-IO-SYNTAX

gzliudan

comment created time in 3 months

issue openedjtv/libpqxx

not support std::nullopt as NULL

When I pass std::nullopt as NULL, The compiler report below errors:

In function `void pqxx::internal::params::add_field<std::nullopt_t>(std::nullopt_t const&)':
undefined reference to `pqxx::nullness<std::nullopt_t, void>::is_null(std::nullopt_t const&)'
In function `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > pqxx::to_string<std::nullopt_t>(std::nullopt_t const&)':
undefined reference to `pqxx::nullness<std::nullopt_t, void>::is_null(std::nullopt_t const&)'
undefined reference to `pqxx::string_traits<std::nullopt_t>::size_buffer(std::nullopt_t const&)'
undefined reference to `pqxx::string_traits<std::nullopt_t>::into_buf(char*, char*, std::nullopt_t const&)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

When I pass std::optional<TypeName>(), the above erros disappears.

created time in 3 months

issue commentjtv/libpqxx

Is there a simple way to handle composite data type?

OK, I will test it this week. Is there any new document?

gzliudan

comment created time in 3 months

issue commentjtv/libpqxx

Is there a simple way to handle composite data type?

std::tuple is not bad. How about use reflect, such as: https://github.com/EOSIO/fc/blob/master/include/fc/reflect/reflect.hpp ?

gzliudan

comment created time in 3 months

issue commentjtv/libpqxx

Is there a simple way to handle composite data type?

I'm work on a project which has many new basic data type and composite data type, all types are ASCII encoding. If there is a feature supports define string_traits for composite data type and array automatically, it will save much time greatly and reduce code errors.

gzliudan

comment created time in 3 months

issue commentjtv/libpqxx

Is there a simple way to handle composite data type?

Since psql can print composite data type in text format when we run select command in console, I believe there is a way to package the whole struct automatically when each field's string_traits is provied. By use each member field's from_string and to_buf functions, maybe we don't need consider encodings. Only consider format of composite data type, such as single and double quotation mark, arrays. And maybe we need write a function to tell libpqxx handles which fields.

Yes, it's documented. The hard part is dealing with different encodings. For example, when you see a quote in that text, it could be a quote, or it could be just one byte in a completely different Japanese character.

gzliudan

comment created time in 3 months

PR opened jtv/libpqxx

eliminate compile warning: extra qualification on member 'type_name' [-Wextra-qualification]

change

template<> std::string const pqxx::type_name<T>{"T"};

to

template<> std::string const :type_name<T>{"T"};
+1 -1

0 comment

1 changed file

pr created time in 3 months

push eventgzliudan/libpqxx

liudan

commit sha fc843ed0206f3cf7f1846e503da85de8482bb737

eliminate compile warning: extra qualification on member 'type_name' [-Wextra-qualification]

view details

push time in 3 months

fork gzliudan/libpqxx

The official C++ client API for PostgreSQL.

http://pqxx.org/

fork in 3 months

issue commentjtv/libpqxx

Is there a simple way to handle composite data type?

Do you meam: libpqxx can use array_parser convert std::vector to array of postgresql composite data type automatically ? Should I write string_traits::to_buf function for composite data type, such as (‘StringOfFiled1’,‘StringOfFiled2’,‘StringOfFiled3') format string ?

Yes, you can convert a std::vector or std::array directly to a string in the normal way.

The other direction is more complicated, but it is supported: see the array_parser class.

gzliudan

comment created time in 3 months

issue commentjtv/libpqxx

Is there a simple way to handle composite data type?

BTW, does libpqxx support array data type of PostgreSQL ?

gzliudan

comment created time in 3 months

issue commentjtv/libpqxx

Is there a simple way to handle composite data type?

We can only support utf8 encoding and refuse input when a quote is not quote.

gzliudan

comment created time in 3 months

issue commentjtv/libpqxx

Is there a simple way to handle composite data type?

For composite data type, PostgreSQL support ('member1','member2','member3') format

gzliudan

comment created time in 3 months

issue closedjtv/libpqxx

Does libpqxx support user defined data types with binary mode?

I read the document today. It seems libpqxx can only translate new data type from text format and to text format. How can I use the more efficient binary format mode? Since I have some data types only support binary mode, no text mode. For example, if I defined a new data type named uint8 in postgresql which is uint64 in C++:

CREATE TYPE     uint8;
CREATE FUNCTION uint8_in(cstring)       RETURNS uint8   IMMUTABLE STRICT LANGUAGE C AS '$libdir/abc', 'uint8_in';
CREATE FUNCTION uint8_out(uint8)        RETURNS cstring IMMUTABLE STRICT LANGUAGE C AS '$libdir/abc', 'uint8_out';
CREATE FUNCTION uint8_receive(internal) RETURNS uint8   IMMUTABLE STRICT LANGUAGE C AS '$libdir/abc', 'uint8_receive';
CREATE FUNCTION uint8_send(uint8)       RETURNS bytea   IMMUTABLE STRICT LANGUAGE C AS '$libdir/abc', 'uint8_send';

CREATE TYPE uint8 
(
    INPUT   = uint8_in, 
    OUTPUT  = uint8_out, 
    RECEIVE = uint8_receive,
    SEND    = uint8_send,
    INTERNALLENGTH = 8, 
    ALIGNMENT = double,
    PASSEDBYVALUE
);

PG_FUNCTION_INFO_V1(uint8_receive);
Datum uint8_receive(PG_FUNCTION_ARGS) {
    StringInfo msg = (StringInfo)PG_GETARG_POINTER(0);
    PG_RETURN_UINT64((uint64_t)pq_getmsgint64(msg));
}

PG_FUNCTION_INFO_V1(uint8_send);
Datum uint8_send(PG_FUNCTION_ARGS) {
    uint64         arg = PG_GETARG_UINT64(0);
    StringInfoData buf;

    pq_begintypsend(&buf);
    pq_sendint64(&buf, arg);
    PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
}

In this case, can I use function such as memcpy copy C++ uint64 data type to libpqxx, let postgresql get uint8 by binary mode use function uint8_receive? And postgressql send uint8 data type by binary mode use function uint8_send, then I copy binary data to C++ type uint64 directly from libpqxx?

Originally posted by @jtv in https://github.com/jtv/libpqxx/issues/346#issuecomment-653631531

closed time in 3 months

gzliudan

issue openedjtv/libpqxx

Is there a simple way to handle composite data type?

If a composite data type is created in PostgreSQL, such as below:

CREATE TYPE new_data_type AS (
    name            text,
    supplier_id     integer,
    price           double precision
);

Then is there a simple way to define it in libpqxx? assume all data type of each field has been defined in libpqxx already.

created time in 3 months

startedtrezor/trezor-firmware

started time in 3 months

more