bitnine-oss / agensgraph

AgensGraph, a transactional graph database based on PostgreSQL
http://www.agensgraph.org
Other
1.33k stars 148 forks source link

Dump graph schema and data in cypher format (v2.12) #554

Closed uhayat closed 2 years ago

uhayat commented 2 years ago

Dump graph schema and data in cypher format which is portable in major version upgrade. This will help in dump/restore scenario and pg_upgrade scenarios for major and minor version upgrades.

emotionbug commented 2 years ago

Some regressions are failed. please check it. :) ( pg_upgrade regression )

command: "/home/emotionbug/CLionProjects/agensgraph-emotionbug/tmp_install/usr/local/pgsql/bin/pg_dump" --host /home/emotionbug/CLionProjects/agensgraph-emotionbug/src/bin/pg_upgrade --port 54472 --username emotionbug --schema-only --quote-all-identifiers --binary-upgrade --format=custom  --file="pg_upgrade_dump_16387.custom" 'dbname=regression' >> "pg_upgrade_dump_16387.log" 2>&1
pg_dump: warning: archive items not in correct section order

command: "/home/emotionbug/CLionProjects/agensgraph-emotionbug/tmp_install/usr/local/pgsql/bin/pg_restore" --host /home/emotionbug/CLionProjects/agensgraph-emotionbug/src/bin/pg_upgrade --port 54472 --username emotionbug --create --exit-on-error --verbose --dbname template1 "pg_upgrade_dump_16387.custom" >> "pg_upgrade_dump_16387.log" 2>&1
pg_restore: connecting to database for restore
pg_restore: creating DATABASE "regression"
pg_restore: connecting to new database "regression"
pg_restore: creating DATABASE PROPERTIES "regression"
pg_restore: connecting to new database "regression"
pg_restore: creating pg_largeobject "pg_largeobject"
pg_restore: creating GRAPH "Graph Schema"
pg_restore: while PROCESSING TOC:
pg_restore: from TOC entry 6080; 0 0 GRAPH Graph Schema (no owner)
pg_restore: error: could not execute query: ERROR:  pg_class heap OID value not set when in binary upgrade mode
Command was: CREATE GRAPH propidx;

also, this is not your code. but, depeding functions, ( this is current REL_2.12_STABLE's bug ) these functions uses dopt.cparams.dbname params. but, it is not safe to use.

static void dumpDatabaseGraphPath(Archive *fout, const char *dbname);
static void makeAlterGraphPathConfigCommand(Archive *fout,PGconn *conn,
                                            const char *arrayitem,
                                            const char *name);
pg_dump: warning: archive items not in correct section order
pg_dump: error: query failed: ERROR:  syntax error at or near "regression"
LINE 1: ...CT oid FROM pg_database WHERE datname = ' dbname='regression...
                                                             ^
pg_dump: error: query was: SELECT setconfig[1] FROM pg_db_role_setting WHERE setrole = 0 AND setdatabase = (SELECT oid FROM pg_database WHERE datname = ' dbname='regression./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ'');

need to change as ALTER DATABASE CURRENT..., datname = current_database()...

emotionbug commented 2 years ago

More deeper look, in binary-upgrade mode, when create table or sequence needs to call binary_upgrade_set_next_heap_pg_class_oid.

but, CREATE GRAPH ... syntax have a 4 operations.

due to its integrated work, there is no way to use binary_upgrade_set_next_heap_pg_class_oid in the middle. so, it need to be implement more separated things to syntax or function.

also, CEATE ELABEL, VLABEL syntax either too.