This is an automated email from the ASF dual-hosted git repository.

ztao1987 pushed a commit to branch taoz
in repository https://gitbox.apache.org/repos/asf/hawq.git

commit fac6938054306143041be50c778202bdd6d2c26e
Author: ztao1987 <zhenglin.ta...@gmail.com>
AuthorDate: Fri Aug 27 14:42:45 2021 +0800

    HAWQ-1802. analyze inherits resource if possible
---
 contrib/magma/monitor_install.sql                  |   2 +-
 contrib/orc/hive_install.sql                       |   4 +-
 contrib/orc/orc.c                                  |  20 +-
 contrib/orc/orc_install.sql                        |  12 +-
 src/Makefile                                       |  16 +-
 src/backend/access/orc/orcam.c                     |   2 +-
 src/backend/catalog/Makefile                       |   1 +
 src/backend/catalog/catalog.c                      |   3 +
 src/backend/catalog/heap.c                         |  15 +
 src/backend/commands/analyze.c                     |  34 +-
 src/backend/utils/adt/array_distance_install.sql   |   8 +-
 src/backend/utils/adt/json_install.sql             | 361 +++++++++++++++++++++
 src/backend/utils/misc/guc.c                       |  10 +
 src/include/utils/guc.h                            |   1 +
 src/test/feature/UDF/TestUDF.cpp                   |   9 +
 src/test/feature/UDF/ans/test_udf_with_analyze.ans |  21 ++
 src/test/feature/UDF/sql/test_udf_with_analyze.sql |  19 ++
 tools/bin/upgrade.sh                               |  34 +-
 18 files changed, 512 insertions(+), 60 deletions(-)

diff --git a/contrib/magma/monitor_install.sql 
b/contrib/magma/monitor_install.sql
index 7950fd5..1160e3b 100644
--- a/contrib/magma/monitor_install.sql
+++ b/contrib/magma/monitor_install.sql
@@ -1,7 +1,7 @@
 ------------------------------------------------------------------
 -- hawq status
 ------------------------------------------------------------------
-CREATE FUNCTION hawq_magma_status() RETURNS SETOF record LANGUAGE internal 
VOLATILE STRICT AS 'hawq_magma_status' WITH (OID=5085, DESCRIPTION="Return 
magma node information");
+CREATE FUNCTION pg_catalog.hawq_magma_status() RETURNS SETOF record LANGUAGE 
internal VOLATILE STRICT AS 'hawq_magma_status' WITH (OID=5085, 
DESCRIPTION="Return magma node information");
 
 CREATE OR REPLACE FUNCTION pg_catalog.magma_getstatus() RETURNS void
 AS '$libdir/magma.so', 'magma_getstatus'
diff --git a/contrib/orc/hive_install.sql b/contrib/orc/hive_install.sql
index 624a499..3409adf 100644
--- a/contrib/orc/hive_install.sql
+++ b/contrib/orc/hive_install.sql
@@ -6,10 +6,10 @@
 --
 -- --------------------------------------------------------------------
 
-CREATE OR REPLACE FUNCTION hive_validate() RETURNS void
+CREATE OR REPLACE FUNCTION pg_catalog.hive_validate() RETURNS void
 AS '$libdir/exthive.so', 'hiveprotocol_validate'
 LANGUAGE C STABLE;
 
-CREATE OR REPLACE FUNCTION hive_blocklocation() RETURNS void
+CREATE OR REPLACE FUNCTION pg_catalog.hive_blocklocation() RETURNS void
 AS '$libdir/exthive.so', 'hiveprotocol_blocklocation'
 LANGUAGE C STABLE;
diff --git a/contrib/orc/orc.c b/contrib/orc/orc.c
index e636081..465e4f3 100644
--- a/contrib/orc/orc.c
+++ b/contrib/orc/orc.c
@@ -643,7 +643,7 @@ Datum orc_beginscan(PG_FUNCTION_ARGS)
         ORCFormatCatchedError *e = ORCFormatGetErrorORCFormatC(user_data->fmt);
        if (e->errCode != ERRCODE_SUCCESSFUL_COMPLETION)
        {
-               ereport(ERROR, (errcode(e->errCode), errmsg("ORC:%s", 
e->errMessage)));
+               ereport(ERROR, (errcode(e->errCode), errmsg("%s", 
e->errMessage)));
        }
 
        /* 5. Save file_scan_desc */
@@ -772,7 +772,7 @@ Datum orc_getnext(PG_FUNCTION_ARGS) {
     ORCFormatEndORCFormatC(user_data->fmt);
     e = ORCFormatGetErrorORCFormatC(user_data->fmt);
     if (e->errCode != ERRCODE_SUCCESSFUL_COMPLETION) {
-      ereport(ERROR, (errcode(e->errCode), errmsg("ORC:%s", e->errMessage)));
+      ereport(ERROR, (errcode(e->errCode), errmsg("%s", e->errMessage)));
     }
 
     ORCFormatFreeORCFormatC(&(user_data->fmt));
@@ -802,7 +802,7 @@ Datum orc_getnext(PG_FUNCTION_ARGS) {
     slot->PRIVATE_tts_values = NULL;
     ExecClearTuple(slot);
   } else {
-    ereport(ERROR, (errcode(e->errCode), errmsg("ORC:%s", e->errMessage)));
+    ereport(ERROR, (errcode(e->errCode), errmsg("%s", e->errMessage)));
   }
   PG_RETURN_BOOL(false);
 }
@@ -865,14 +865,14 @@ Datum orc_rescan(PG_FUNCTION_ARGS)
                ORCFormatCatchedError *e = 
ORCFormatGetErrorORCFormatC(user_data->fmt);
                if (e->errCode != ERRCODE_SUCCESSFUL_COMPLETION)
                {
-                       ereport(ERROR, (errcode(e->errCode), errmsg("ORC:%s", 
e->errMessage)));
+                       ereport(ERROR, (errcode(e->errCode), errmsg("%s", 
e->errMessage)));
                }
        } else {
                ORCFormatRescanORCFormatC(user_data->fmt);
                ORCFormatCatchedError *e = 
ORCFormatGetErrorORCFormatC(user_data->fmt);
                if (e->errCode != ERRCODE_SUCCESSFUL_COMPLETION)
                {
-                       ereport(ERROR, (errcode(e->errCode), errmsg("ORC:%s", 
e->errMessage)));
+                       ereport(ERROR, (errcode(e->errCode), errmsg("%s", 
e->errMessage)));
                }
        }
 
@@ -993,7 +993,7 @@ Datum orc_stopscan(PG_FUNCTION_ARGS)
     ORCFormatEndORCFormatC(user_data->fmt);
     e = ORCFormatGetErrorORCFormatC(user_data->fmt);
     if (e->errCode != ERRCODE_SUCCESSFUL_COMPLETION) {
-      ereport(LOG, (errcode(e->errCode), errmsg("ORC:%s", e->errMessage)));
+      ereport(LOG, (errcode(e->errCode), errmsg("%s", e->errMessage)));
     }
 
     ORCFormatFreeORCFormatC(&(user_data->fmt));
@@ -1029,7 +1029,7 @@ Datum orc_stopscan(PG_FUNCTION_ARGS)
     tts->PRIVATE_tts_isnull = NULL;
     ExecClearTuple(tts);
   } else {
-    ereport(ERROR, (errcode(e->errCode), errmsg("ORC:%s", e->errMessage)));
+    ereport(ERROR, (errcode(e->errCode), errmsg("%s", e->errMessage)));
   }
 
   PG_RETURN_VOID();
@@ -1261,7 +1261,7 @@ Datum orc_insert_init(PG_FUNCTION_ARGS)
        ORCFormatCatchedError *e = ORCFormatGetErrorORCFormatC(user_data->fmt);
        if (e->errCode != ERRCODE_SUCCESSFUL_COMPLETION)
        {
-               ereport(ERROR, (errcode(e->errCode), errmsg("ORC:%s", 
e->errMessage)));
+               ereport(ERROR, (errcode(e->errCode), errmsg("%s", 
e->errMessage)));
        }
 
        /* 4. Save the result */
@@ -1515,7 +1515,7 @@ Datum orc_insert(PG_FUNCTION_ARGS)
        ORCFormatCatchedError *e = ORCFormatGetErrorORCFormatC(user_data->fmt);
        if (e->errCode != ERRCODE_SUCCESSFUL_COMPLETION)
        {
-               ereport(ERROR,(errcode(e->errCode),errmsg("ORC::%s", 
e->errMessage)));
+               ereport(ERROR,(errcode(e->errCode),errmsg("%s", 
e->errMessage)));
        }
 
        ps->ps_tuple_oid = InvalidOid;
@@ -1540,7 +1540,7 @@ Datum orc_insert_finish(PG_FUNCTION_ARGS)
        ORCFormatCatchedError *e = ORCFormatGetErrorORCFormatC(user_data->fmt);
        if (e->errCode != ERRCODE_SUCCESSFUL_COMPLETION)
        {
-               ereport(ERROR, (errcode(e->errCode), errmsg("ORC:%s", 
e->errMessage)));
+               ereport(ERROR, (errcode(e->errCode), errmsg("%s", 
e->errMessage)));
        }
 
        ORCFormatFreeORCFormatC(&(user_data->fmt));
diff --git a/contrib/orc/orc_install.sql b/contrib/orc/orc_install.sql
index 21f9c09..6baeefb 100644
--- a/contrib/orc/orc_install.sql
+++ b/contrib/orc/orc_install.sql
@@ -60,26 +60,26 @@ CREATE OR REPLACE FUNCTION pg_catalog.orc_insert_finish() 
RETURNS void
 AS '$libdir/orc.so', 'orc_insert_finish'
 LANGUAGE C STABLE;
 
-CREATE OR REPLACE FUNCTION hdfs_validate() RETURNS void
+CREATE OR REPLACE FUNCTION pg_catalog.hdfs_validate() RETURNS void
 AS '$libdir/exthdfs.so', 'hdfsprotocol_validate'
 LANGUAGE C STABLE;
 
-CREATE OR REPLACE FUNCTION hdfs_blocklocation() RETURNS void
+CREATE OR REPLACE FUNCTION pg_catalog.hdfs_blocklocation() RETURNS void
 AS '$libdir/exthdfs.so', 'hdfsprotocol_blocklocation'
 LANGUAGE C STABLE;
 
-CREATE OR REPLACE FUNCTION csv_in() RETURNS record
+CREATE OR REPLACE FUNCTION pg_catalog.csv_in() RETURNS record
 AS '$libdir/extfmtcsv.so', 'extfmtcsv_in'
 LANGUAGE C STABLE;
 
-CREATE OR REPLACE FUNCTION csv_out(record) RETURNS bytea
+CREATE OR REPLACE FUNCTION pg_catalog.csv_out(record) RETURNS bytea
 AS '$libdir/extfmtcsv.so', 'extfmtcsv_out'
 LANGUAGE C STABLE;
 
-CREATE OR REPLACE FUNCTION text_in() RETURNS record
+CREATE OR REPLACE FUNCTION pg_catalog.text_in() RETURNS record
 AS '$libdir/extfmtcsv.so', 'extfmttext_in'
 LANGUAGE C STABLE;
 
-CREATE OR REPLACE FUNCTION text_out(record) RETURNS bytea
+CREATE OR REPLACE FUNCTION pg_catalog.text_out(record) RETURNS bytea
 AS '$libdir/extfmtcsv.so', 'extfmttext_out'
 LANGUAGE C STABLE;
diff --git a/src/Makefile b/src/Makefile
index c48a5f0..e026e92 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -46,16 +46,18 @@ install-local: installdirs-local
        $(INSTALL_DATA) $(srcdir)/nls-global.mk 
'$(DESTDIR)$(pgxsdir)/$(subdir)/nls-global.mk'
 
 installdirs: installdirs-local
-ifeq ($(with_oushudb_extension), yes)
-       ${INSTALL_PROGRAM} $(DEPENDENCY_PATH)/bin/magma_* $(DESTDIR)${bindir}
-       ${INSTALL_PROGRAM} $(DEPENDENCY_PATH)/bin/hawq_heartbeat* 
$(DESTDIR)${bindir}
-       ${INSTALL_PROGRAM} $(DEPENDENCY_PATH)/bin/hawq_magma_tool 
$(DESTDIR)${bindir}
-       ${INSTALL_DATA} 
$(DEPENDENCY_PATH)/include/magma/utils/template-magma-site.xml 
$(DESTDIR)${sysconfdir}
-       ${INSTALL_DATA} $(DEPENDENCY_PATH)/include/magma/utils/magma-site.xml 
$(DESTDIR)${sysconfdir}
-endif
 
 installdirs-local:
        $(MKDIR_P) '$(DESTDIR)$(pgxsdir)/$(subdir)'
+ifeq ($(with_oushudb_extension), yes)
+       ${INSTALL_PROGRAM} $(DEPENDENCY_PATH)/bin/magma_ctl 
'$(DESTDIR)${bindir}/magma_ctl'
+       ${INSTALL_PROGRAM} $(DEPENDENCY_PATH)/bin/magma_server 
'$(DESTDIR)${bindir}/magma_server'
+       ${INSTALL_PROGRAM} $(DEPENDENCY_PATH)/bin/hawq_heartbeat_monitor 
'$(DESTDIR)${bindir}/hawq_heartbeat_monitor'
+       ${INSTALL_PROGRAM} $(DEPENDENCY_PATH)/bin/hawq_heartbeat_sender 
'$(DESTDIR)${bindir}/hawq_heartbeat_sender'
+       ${INSTALL_PROGRAM} $(DEPENDENCY_PATH)/bin/hawq_magma_tool 
'$(DESTDIR)${bindir}/hawq_magma_tool'
+       ${INSTALL_DATA} 
$(DEPENDENCY_PATH)/include/magma/utils/template-magma-site.xml 
'$(DESTDIR)${sysconfdir}/template-magma-site.xml'
+       ${INSTALL_DATA} $(DEPENDENCY_PATH)/include/magma/utils/magma-site.xml 
'$(DESTDIR)${sysconfdir}/magma-site.xml'
+endif
 
 uninstall: uninstall-local
 
diff --git a/src/backend/access/orc/orcam.c b/src/backend/access/orc/orcam.c
index 3ea3edb..f1d4f02 100644
--- a/src/backend/access/orc/orcam.c
+++ b/src/backend/access/orc/orcam.c
@@ -122,7 +122,7 @@ static void checkOrcError(OrcFormatData *orcFormatData) {
     ORCFormatFreeORCFormatC(&orcFormatData->fmt);
     ORCFormatFreeStorageFormatC(&orcFormatData->updateDeleteFmt);
     ereport(ERROR,
-            (errcode(errBuf.errCode), errmsg("ORC: %s", errBuf.errMessage)));
+            (errcode(errBuf.errCode), errmsg("%s", errBuf.errMessage)));
   }
 }
 
diff --git a/src/backend/catalog/Makefile b/src/backend/catalog/Makefile
index 398b97f..8c81bb1 100644
--- a/src/backend/catalog/Makefile
+++ b/src/backend/catalog/Makefile
@@ -144,6 +144,7 @@ install-data: $(BKIFILES) installdirs
        $(INSTALL_DATA) $(call vpathsearch,filesystem.sql) 
'$(DESTDIR)$(datadir)/filesystem.sql'
        $(INSTALL_DATA) $(srcdir)/../utils/adt/array_distance_install.sql 
'$(DESTDIR)$(datadir)/array_distance_install.sql'
        $(INSTALL_DATA) $(srcdir)/../utils/adt/array_distance_uninstall.sql 
'$(DESTDIR)$(datadir)/array_distance_uninstall.sql'
+       $(INSTALL_DATA) $(srcdir)/../utils/adt/json_install.sql 
'$(DESTDIR)$(datadir)/json_install.sql'
 
 ifeq ($(with_orc), yes)
        $(INSTALL_DATA) $(srcdir)/../../../contrib/orc/orc_install.sql 
'$(DESTDIR)$(datadir)/orc_install.sql'
diff --git a/src/backend/catalog/catalog.c b/src/backend/catalog/catalog.c
index 1495956..c7b1c47 100755
--- a/src/backend/catalog/catalog.c
+++ b/src/backend/catalog/catalog.c
@@ -970,6 +970,9 @@ relationId == PgResQueueToastIndex ||
 Oid
 GetNewOid(Relation relation)
 {
+  if (gp_upgrade_mode && gen_new_oid_value != InvalidOid) {
+    return gen_new_oid_value;
+  }
        Oid                     newOid;
        Oid                     oidIndex;
        Relation        indexrel;
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
index 67b56b0..76e9c91 100644
--- a/src/backend/catalog/heap.c
+++ b/src/backend/catalog/heap.c
@@ -790,6 +790,21 @@ void CheckAttributeForOrc(TupleDesc desc) {
                       errmsg("array type of column \"%s\" is not supported 
yet",
                              NameStr(desc->attrs[i]->attname))));
     }
+
+    int32_t datatype =
+        (int32_t)(((Form_pg_attribute)(desc->attrs[i]))->atttypid);
+    int4 typmod = ((Form_pg_attribute)(desc->attrs[i]))->atttypmod;
+    if (HAWQ_TYPE_NUMERIC == datatype) {
+      int4 tmp_typmod = typmod - VARHDRSZ;
+      int precision = (tmp_typmod >> 16) & 0xffff;
+      int scale = tmp_typmod & 0xffff;
+      if (precision < 1 || 38 < precision)
+        ereport(ERROR,
+                (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+                 errmsg("ORC DECIMAL precision must be between 1 and 38")));
+      if (scale == 0)
+        ereport(NOTICE, (errmsg("Using a scale of zero for ORC DECIMAL")));
+    }
   }
 }
 
diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c
index 9769e83..b3fcf4a 100644
--- a/src/backend/commands/analyze.c
+++ b/src/backend/commands/analyze.c
@@ -522,15 +522,24 @@ void analyzeStmt(VacuumStmt *stmt, List *relids, int 
preferred_seg_num)
        CurrentResourceOwner = asOwner;
 
        /**
-        *  we use preferred_seg_num as default and
-        *  compute target_seg_num based on data size and distributed type
-        *  if there is no preferred_seg_num.
+        * We allocate query resource for analyze if there is no active resource
+        * otherwise, we inherit instead
         */
+       QueryResource *savedResource = NULL;
+       savedResource = GetActiveQueryResource();
+
+       QueryResource *resource = NULL;
        int target_seg_num = preferred_seg_num;
-       if (target_seg_num <= 0) {
-               target_seg_num = calculate_virtual_segment_number(lFullRelOids);
+       if (!savedResource) {
+               /**
+                *  we use preferred_seg_num as default and
+                *  compute target_seg_num based on data size and distributed 
type
+                *  if there is no preferred_seg_num.
+                */
+               if (target_seg_num <= 0) {
+                       target_seg_num = 
calculate_virtual_segment_number(lFullRelOids);
+               }
        }
-       elog(LOG, "virtual segment number of analyze is: %d\n", target_seg_num);
 
        /**
         * We open relations with appropreciate locks
@@ -559,13 +568,12 @@ void analyzeStmt(VacuumStmt *stmt, List *relids, int 
preferred_seg_num)
                }
        }
 
-       /**
-        * We allocate query resource for analyze
-        */
-       QueryResource *resource = AllocateResource(QRL_ONCE, 1, 0, 
target_seg_num, target_seg_num, NULL, 0);
-       QueryResource *savedResource = NULL;
-
-       savedResource = GetActiveQueryResource();
+       if (!savedResource) {
+               elog(LOG, "virtual segment number of analyze is: %d\n", 
target_seg_num);
+               resource = AllocateResource(QRL_ONCE, 1, 0, target_seg_num, 
target_seg_num, NULL, 0);
+       } else {
+               resource = AllocateResource(QRL_INHERIT, 0, 0, 0, 0, NULL, 0);
+       }
        SetActiveQueryResource(resource);
 
        /**
diff --git a/src/backend/utils/adt/array_distance_install.sql 
b/src/backend/utils/adt/array_distance_install.sql
index a41d3dd..d17ea89 100644
--- a/src/backend/utils/adt/array_distance_install.sql
+++ b/src/backend/utils/adt/array_distance_install.sql
@@ -6,10 +6,10 @@
 --
 -- --------------------------------------------------------------------
 
-CREATE OR REPLACE FUNCTION euclidean_metric_float4array(anyarray, anyarray) 
RETURNS float4 LANGUAGE internal IMMUTABLE AS 'euclidean_metric_float4array';
+CREATE OR REPLACE FUNCTION pg_catalog.euclidean_metric_float4array(anyarray, 
anyarray) RETURNS float4 LANGUAGE internal IMMUTABLE AS 
'euclidean_metric_float4array';
 
-CREATE OR REPLACE FUNCTION euclidean_metric_float8array(anyarray, anyarray) 
RETURNS float8 LANGUAGE internal STABLE AS 'euclidean_metric_float8array';
+CREATE OR REPLACE FUNCTION pg_catalog.euclidean_metric_float8array(anyarray, 
anyarray) RETURNS float8 LANGUAGE internal STABLE AS 
'euclidean_metric_float8array';
 
-CREATE OR REPLACE FUNCTION cosine_distance_float4array(anyarray, anyarray) 
RETURNS float8 LANGUAGE internal IMMUTABLE AS 'cosine_distance_float4array';
+CREATE OR REPLACE FUNCTION pg_catalog.cosine_distance_float4array(anyarray, 
anyarray) RETURNS float8 LANGUAGE internal IMMUTABLE AS 
'cosine_distance_float4array';
 
-CREATE OR REPLACE FUNCTION cosine_distance_float8array(anyarray, anyarray) 
RETURNS float8 LANGUAGE internal IMMUTABLE AS 'cosine_distance_float8array';
+CREATE OR REPLACE FUNCTION pg_catalog.cosine_distance_float8array(anyarray, 
anyarray) RETURNS float8 LANGUAGE internal IMMUTABLE AS 
'cosine_distance_float8array';
diff --git a/src/backend/utils/adt/json_install.sql 
b/src/backend/utils/adt/json_install.sql
new file mode 100644
index 0000000..5eb9d4b
--- /dev/null
+++ b/src/backend/utils/adt/json_install.sql
@@ -0,0 +1,361 @@
+------------------------------------------------------------------
+-- pg_proc
+------------------------------------------------------------------
+set gen_new_oid_value to 321;
+insert into pg_proc values 
('json_in',11,10,12,'f','f','t','f','i',1,193,'f','2275',null,null,null,'json_in','-',null,'n');
+set gen_new_oid_value to 322;
+insert into pg_proc values 
('json_out',11,10,12,'f','f','t','f','i',1,2275,'f','193',null,null,null,'json_out','-',null,'n');
+set gen_new_oid_value to 323;
+insert into pg_proc values 
('json_recv',11,10,12,'f','f','t','f','i',1,193,'f','2281',null,null,null,'json_recv','-',null,'n');
+set gen_new_oid_value to 324;
+insert into pg_proc values 
('json_send',11,10,12,'f','f','t','f','i',1,17,'f','193',null,null,null,'json_send','-',null,'n');
+set gen_new_oid_value to 3153;
+insert into pg_proc values 
('array_to_json',11,10,12,'f','f','t','f','s',1,193,'f','2277',null,null,null,'array_to_json','-',null,'n');
+set gen_new_oid_value to 3154;
+insert into pg_proc values 
('array_to_json',11,10,12,'f','f','t','f','s',2,193,'f','2277 
16',null,null,null,'array_to_json_pretty','-',null,'n');
+set gen_new_oid_value to 3155;
+insert into pg_proc values 
('row_to_json',11,10,12,'f','f','t','f','s',1,193,'f','2249',null,null,null,'row_to_json','-',null,'n');
+set gen_new_oid_value to 3156;
+insert into pg_proc values 
('row_to_json',11,10,12,'f','f','t','f','s',2,193,'f','2249 
16',null,null,null,'row_to_json_pretty','-',null,'n');
+set gen_new_oid_value to 3173;
+insert into pg_proc values 
('json_agg_transfn',11,10,12,'f','f','f','f','i',2,2281,'f','2281 
2283',null,null,null,'json_agg_transfn','-',null,'n');
+set gen_new_oid_value to 3174;
+insert into pg_proc values 
('json_agg_finalfn',11,10,12,'f','f','f','f','i',1,193,'f','2281',null,null,null,'json_agg_finalfn','-',null,'n');
+set gen_new_oid_value to 3175;
+insert into pg_proc values 
('json_agg',11,10,12,'t','f','f','f','i',1,193,'f','2283',null,null,null,'aggregate_dummy','-',null,'n');
+set gen_new_oid_value to 3176;
+insert into pg_proc values 
('to_json',11,10,12,'f','f','t','f','s',1,193,'f','2283',null,null,null,'to_json','-',null,'n');
+
+set gen_new_oid_value to 3947;
+insert into pg_proc values 
('json_object_field',11,10,12,'f','f','t','f','s',2,193,'f','193 
25',null,null,'{from_json,field_name}','json_object_field','-',null,'n');
+set gen_new_oid_value to 3948;
+insert into pg_proc values 
('json_object_field_text',11,10,12,'f','f','t','f','s',2,25,'f','193 
25',null,null,'{from_json,field_name}','json_object_field_text','-',null,'n');
+set gen_new_oid_value to 3949;
+insert into pg_proc values 
('json_array_element',11,10,12,'f','f','t','f','s',2,193,'f','193 
23',null,null,'{from_json,element_index}','json_array_element','-',null,'n');
+set gen_new_oid_value to 3950;
+insert into pg_proc values 
('json_array_element_text',11,10,12,'f','f','t','f','s',2,25,'f','193 
23',null,null,'{from_json,element_index}','json_array_element_text','-',null,'n');
+set gen_new_oid_value to 3951;
+insert into pg_proc values 
('json_extract_path',11,10,12,'f','f','t','f','s',2,193,'f','193 
1009','{193,1009}','{i,v}','{from_json,path_elems}','json_extract_path','-',null,'n');
+set gen_new_oid_value to 3952;
+insert into pg_proc values 
('json_extract_path_op',11,10,12,'f','f','t','f','s',2,193,'f','193 
1009',null,null,'{from_json,path_elems}','json_extract_path','-',null,'n');
+set gen_new_oid_value to 3953;
+insert into pg_proc values 
('json_extract_path_text',11,10,12,'f','f','t','f','s',2,25,'f','193 
1009','{193,1009}','{i,v}','{from_json,path_elems}','json_extract_path_text','-',null,'n');
+set gen_new_oid_value to 3954;
+insert into pg_proc values 
('json_extract_path_text_op',11,10,12,'f','f','t','f','s',2,25,'f','193 
1009',null,null,'{from_json,path_elems}','json_extract_path_text','-',null,'n');
+set gen_new_oid_value to 3955;
+insert into pg_proc values 
('json_array_elements',11,10,12,'f','f','t','t','s',1,193,'f','193','{193,193}','{i,o}','{from_json,value}','json_array_elements','-',null,'n');
+set gen_new_oid_value to 3956;
+insert into pg_proc values 
('json_array_length',11,10,12,'f','f','t','f','s',1,23,'f','193',null,null,null,'json_array_length','-',null,'n');
+set gen_new_oid_value to 3957;
+insert into pg_proc values 
('json_object_keys',11,10,12,'f','f','t','t','s',1,25,'f','193',null,null,null,'json_object_keys','-',null,'n');
+set gen_new_oid_value to 3958;
+insert into pg_proc values 
('json_each',11,10,12,'f','f','t','t','s',1,2249,'f','193','{193,25,193}','{i,o,o}','{from_json,key,value}','json_each','-',null,'n');
+set gen_new_oid_value to 3959;
+insert into pg_proc values 
('json_each_text',11,10,12,'f','f','t','t','s',1,2249,'f','193','{193,25,25}','{i,o,o}','{from_json,key,value}','json_each_text','-',null,'n');
+set gen_new_oid_value to 3960;
+insert into pg_proc values 
('json_populate_record',11,10,12,'f','f','f','f','s',3,2283,'f','2283 193 
16',null,null,null,'json_populate_record','-',null,'n');
+set gen_new_oid_value to 3961;
+insert into pg_proc values 
('json_populate_recordset',11,10,12,'f','f','f','t','s',3,2283,'f','2283 193 
16',null,null,null,'json_populate_recordset','-',null,'n');
+set gen_new_oid_value to 3968;
+insert into pg_proc values 
('json_typeof',11,10,12,'f','f','t','f','i',1,25,'f','193',null,null,null,'json_typeof','-',null,'n');
+set gen_new_oid_value to 3180;
+insert into pg_proc values 
('json_object_agg_transfn',11,10,12,'f','f','f','f','i',3,2281,'f','2281 2276 
2276',null,null,null,'json_object_agg_transfn','-',null,'n');
+set gen_new_oid_value to 3196;
+insert into pg_proc values 
('json_object_agg_finalfn',11,10,12,'f','f','f','f','i',1,193,'f','2281',null,null,null,'json_object_agg_finalfn','-',null,'n');
+set gen_new_oid_value to 3197;
+insert into pg_proc values 
('json_object_agg',11,10,12,'t','f','f','f','i',2,193,'f','2276 
2276',null,null,null,'aggregate_dummy','-',null,'n');
+set gen_new_oid_value to 3198;
+insert into pg_proc values 
('json_build_array',11,10,12,'f','f','f','f','i',1,193,'f','2276','{2276}','{v}',null,'json_build_array','-',null,'n');
+set gen_new_oid_value to 3199;
+insert into pg_proc values 
('json_build_array',11,10,12,'f','f','f','f','i',0,193,'f','',null,null,null,'json_build_array_noargs','-',null,'n');
+set gen_new_oid_value to 3500;
+insert into pg_proc values 
('json_build_object',11,10,12,'f','f','f','f','i',1,193,'f','2276','{2276}','{v}',null,'json_build_object','-',null,'n');
+set gen_new_oid_value to 3501;
+insert into pg_proc values 
('json_build_object',11,10,12,'f','f','f','f','i',0,193,'f','',null,null,null,'json_build_object_noargs','-',null,'n');
+set gen_new_oid_value to 3502;
+insert into pg_proc values 
('json_object',11,10,12,'f','f','t','f','s',1,193,'f','1009',null,null,null,'json_object','-',null,'n');
+set gen_new_oid_value to 3503;
+insert into pg_proc values 
('json_object',11,10,12,'f','f','t','f','s',2,193,'f','1009 
1009',null,null,null,'json_object_two_arg','-',null,'n');
+set gen_new_oid_value to 3504;
+insert into pg_proc values 
('json_to_record',11,10,12,'f','f','f','f','s',2,2249,'f','193 
16',null,null,null,'json_to_record','-',null,'n');
+set gen_new_oid_value to 3505;
+insert into pg_proc values 
('json_to_recordset',11,10,12,'f','f','f','t','s',2,2249,'f','193 
16',null,null,null,'json_to_recordset','-',null,'n');
+set gen_new_oid_value to 3969;
+insert into pg_proc values 
('json_array_elements_text',11,10,12,'f','f','t','t','i',1,25,'f','193','{193,25}','{i,o}','{from_json,value}','json_array_elements_text','-',null,'n');
+set gen_new_oid_value to 3506;
+insert into pg_proc values 
('json_strip_nulls',11,10,12,'f','f','t','f','i',1,193,'f','193',null,null,null,'json_strip_nulls','-',null,'n');
+-- jsonb
+set gen_new_oid_value to 3806;
+insert into pg_proc values 
('jsonb_in',11,10,12,'f','f','t','f','i',1,3802,'f','2275',null,null,null,'jsonb_in','-',null,'n');
+set gen_new_oid_value to 3805;
+insert into pg_proc values 
('jsonb_recv',11,10,12,'f','f','t','f','i',1,3802,'f','2281',null,null,null,'jsonb_recv','-',null,'n');
+set gen_new_oid_value to 3804;
+insert into pg_proc values 
('jsonb_out',11,10,12,'f','f','t','f','i',1,2275,'f','3802',null,null,null,'jsonb_out','-',null,'n');
+set gen_new_oid_value to 3803;
+insert into pg_proc values 
('jsonb_send',11,10,12,'f','f','t','f','i',1,17,'f','3802',null,null,null,'jsonb_send','-',null,'n');
+set gen_new_oid_value to 3478;
+insert into pg_proc values 
('jsonb_object_field',11,10,12,'f','f','t','f','i',2,3802,'f','3802 
25',null,null,'{from_json,field_name}','jsonb_object_field','-',null,'n');
+set gen_new_oid_value to 5509;
+insert into pg_proc values 
('jsonb_object_field_text',11,10,12,'f','f','t','f','i',2,25,'f','3802 
25',null,null,'{from_json,field_name}','jsonb_object_field_text','-',null,'n');
+set gen_new_oid_value to 5510;
+insert into pg_proc values 
('jsonb_array_element',11,10,12,'f','f','t','f','i',2,3802,'f','3802 
23',null,null,'{from_json,element_index}','jsonb_array_element','-',null,'n');
+set gen_new_oid_value to 5511;
+insert into pg_proc values 
('jsonb_array_element_text',11,10,12,'f','f','t','f','i',2,25,'f','3802 
23',null,null,'{from_json,element_index}','jsonb_array_element_text','-',null,'n');
+set gen_new_oid_value to 5512;
+insert into pg_proc values 
('jsonb_extract_path',11,10,12,'f','f','t','f','i',2,3802,'f','3802 
1009','{3802,1009}','{i,v}','{from_json,path_elems}','jsonb_extract_path','-',null,'n');
+set gen_new_oid_value to 3939;
+insert into pg_proc values 
('jsonb_extract_path_op',11,10,12,'f','f','t','f','i',2,3802,'f','3802 
1009',null,null,'{from_json,path_elems}','jsonb_extract_path','-',null,'n');
+set gen_new_oid_value to 3940;
+insert into pg_proc values 
('jsonb_extract_path_text',11,10,12,'f','f','t','f','i',2,25,'f','3802 
1009','{3802,1009}','{i,v}','{from_json,path_elems}','jsonb_extract_path_text','-',null,'n');
+set gen_new_oid_value to 5513;
+insert into pg_proc values 
('jsonb_extract_path_text_op',11,10,12,'f','f','t','f','i',2,25,'f','3802 
1009',null,null,'{from_json,path_elems}','jsonb_extract_path_text','-',null,'n');
+set gen_new_oid_value to 5514;
+insert into pg_proc values 
('jsonb_array_elements',11,10,12,'f','f','t','t','i',1,3802,'f','3802','{3802,3802}','{i,o}','{from_json,value}','jsonb_array_elements','-',null,'n');
+set gen_new_oid_value to 3465;
+insert into pg_proc values 
('jsonb_array_elements_text',11,10,12,'f','f','t','t','i',1,25,'f','3802','{3802,25}','{i,o}','{from_json,value}','jsonb_array_elements_text','-',null,'n');
+set gen_new_oid_value to 5502;
+insert into pg_proc values 
('jsonb_array_length',11,10,12,'f','f','t','f','i',1,23,'f','3802',null,null,null,'jsonb_array_length','-',null,'n');
+set gen_new_oid_value to 3931;
+insert into pg_proc values 
('jsonb_object_keys',11,10,12,'f','f','t','t','i',1,25,'f','3802',null,null,null,'jsonb_object_keys','-',null,'n');
+set gen_new_oid_value to 5503;
+insert into pg_proc values 
('jsonb_each',11,10,12,'f','f','t','t','i',1,2249,'f','3802','{3802,25,3802}','{i,o,o}','{from_json,key,value}','jsonb_each','-',null,'n');
+set gen_new_oid_value to 3932;
+insert into pg_proc values 
('jsonb_each_text',11,10,12,'f','f','t','t','i',1,2249,'f','3802','{3802,25,25}','{i,o,o}','{from_json,key,value}','jsonb_each_text','-',null,'n');
+set gen_new_oid_value to 5504;
+insert into pg_proc values 
('jsonb_populate_record',11,10,12,'f','f','f','f','s',3,2283,'f','2283 3802 
16',null,null,null,'jsonb_populate_record','-',null,'n');
+set gen_new_oid_value to 3475;
+insert into pg_proc values 
('jsonb_populate_recordset',11,10,12,'f','f','f','t','s',3,2283,'f','2283 3802 
16',null,null,null,'jsonb_populate_recordset','-',null,'n');
+set gen_new_oid_value to 5505;
+insert into pg_proc values 
('jsonb_typeof',11,10,12,'f','f','t','f','i',1,25,'f','3802',null,null,null,'jsonb_typeof','-',null,'n');
+set gen_new_oid_value to 4038;
+insert into pg_proc values 
('jsonb_ne',11,10,12,'f','f','t','f','i',2,16,'f','3802 
3802',null,null,null,'jsonb_ne','-',null,'n');
+set gen_new_oid_value to 4039;
+insert into pg_proc values 
('jsonb_lt',11,10,12,'f','f','t','f','i',2,16,'f','3802 
3802',null,null,null,'jsonb_lt','-',null,'n');
+set gen_new_oid_value to 4040;
+insert into pg_proc values 
('jsonb_gt',11,10,12,'f','f','t','f','i',2,16,'f','3802 
3802',null,null,null,'jsonb_gt','-',null,'n');
+set gen_new_oid_value to 4041;
+insert into pg_proc values 
('jsonb_le',11,10,12,'f','f','t','f','i',2,16,'f','3802 
3802',null,null,null,'jsonb_le','-',null,'n');
+set gen_new_oid_value to 4042;
+insert into pg_proc values 
('jsonb_ge',11,10,12,'f','f','t','f','i',2,16,'f','3802 
3802',null,null,null,'jsonb_ge','-',null,'n');
+set gen_new_oid_value to 4043;
+insert into pg_proc values 
('jsonb_eq',11,10,12,'f','f','t','f','i',2,16,'f','3802 
3802',null,null,null,'jsonb_eq','-',null,'n');
+set gen_new_oid_value to 4044;
+insert into pg_proc values 
('jsonb_cmp',11,10,12,'f','f','t','f','i',2,23,'f','3802 
3802',null,null,null,'jsonb_cmp','-',null,'n');
+set gen_new_oid_value to 4045;
+insert into pg_proc values 
('jsonb_hash',11,10,12,'f','f','t','f','i',1,23,'f','3802',null,null,null,'jsonb_hash','-',null,'n');
+set gen_new_oid_value to 4046;
+insert into pg_proc values 
('jsonb_contains',11,10,12,'f','f','t','f','i',2,16,'f','3802 
3802',null,null,null,'jsonb_contains','-',null,'n');
+set gen_new_oid_value to 4047;
+insert into pg_proc values 
('jsonb_exists',11,10,12,'f','f','t','f','i',2,16,'f','3802 
25',null,null,null,'jsonb_exists','-',null,'n');
+set gen_new_oid_value to 4048;
+insert into pg_proc values 
('jsonb_exists_any',11,10,12,'f','f','t','f','i',2,16,'f','3802 
1009',null,null,null,'jsonb_exists_any','-',null,'n');
+set gen_new_oid_value to 4049;
+insert into pg_proc values 
('jsonb_exists_all',11,10,12,'f','f','t','f','i',2,16,'f','3802 
1009',null,null,null,'jsonb_exists_all','-',null,'n');
+set gen_new_oid_value to 4050;
+insert into pg_proc values 
('jsonb_contained',11,10,12,'f','f','t','f','i',2,16,'f','3802 
3802',null,null,null,'jsonb_contained','-',null,'n');
+set gen_new_oid_value to 3480;
+insert into pg_proc values 
('gin_compare_jsonb',11,10,12,'f','f','t','f','i',2,23,'f','25 
25',null,null,null,'gin_compare_jsonb','-',null,'n');
+set gen_new_oid_value to 3482;
+insert into pg_proc values 
('gin_extract_jsonb',11,10,12,'f','f','t','f','i',3,2281,'f','2281 2281 
2281',null,null,null,'gin_extract_jsonb','-',null,'n');
+set gen_new_oid_value to 3483;
+insert into pg_proc values 
('gin_extract_jsonb_query',11,10,12,'f','f','t','f','i',7,2281,'f','2277 2281 
21 2281 2281 2281 2281',null,null,null,'gin_extract_jsonb_query','-',null,'n');
+set gen_new_oid_value to 3484;
+insert into pg_proc values 
('gin_consistent_jsonb',11,10,12,'f','f','t','f','i',8,16,'f','2281 21 2277 23 
2281 2281 2281 2281',null,null,null,'gin_consistent_jsonb','-',null,'n');
+set gen_new_oid_value to 3488;
+insert into pg_proc values 
('gin_triconsistent_jsonb',11,10,12,'f','f','t','f','i',7,16,'f','2281 21 2277 
23 2281 2281 2281',null,null,null,'gin_triconsistent_jsonb','-',null,'n');
+set gen_new_oid_value to 5516;
+insert into pg_proc values 
('jsonb_object',11,10,12,'f','f','t','f','i',1,3802,'f','1009',null,null,null,'jsonb_object','-',null,'n');
+set gen_new_oid_value to 5517;
+insert into pg_proc values 
('jsonb_object',11,10,12,'f','f','t','f','i',2,3802,'f','1009 
1009',null,null,null,'jsonb_object_two_arg','-',null,'n');
+set gen_new_oid_value to 5518;
+insert into pg_proc values 
('to_jsonb',11,10,12,'f','f','t','f','s',1,3802,'f','2283',null,null,null,'to_jsonb','-',null,'n');
+set gen_new_oid_value to 5519;
+insert into pg_proc values 
('jsonb_agg_transfn',11,10,12,'f','f','f','f','s',2,2281,'f','2281 
2283',null,null,null,'jsonb_agg_transfn','-',null,'n');
+set gen_new_oid_value to 5520;
+insert into pg_proc values 
('jsonb_agg_finalfn',11,10,12,'f','f','f','f','s',1,3802,'f','2281',null,null,null,'jsonb_agg_finalfn','-',null,'n');
+set gen_new_oid_value to 5521;
+insert into pg_proc values 
('jsonb_agg',11,10,12,'t','f','f','f','s',1,3802,'f','2283',null,null,null,'aggregate_dummy','-',null,'n');
+set gen_new_oid_value to 5522;
+insert into pg_proc values 
('jsonb_object_agg_transfn',11,10,12,'f','f','f','f','s',3,2281,'f','2281 2276 
2276',null,null,null,'jsonb_object_agg_transfn','-',null,'n');
+set gen_new_oid_value to 5523;
+insert into pg_proc values 
('jsonb_object_agg_finalfn',11,10,12,'f','f','f','f','s',1,3802,'f','2281',null,null,null,'jsonb_object_agg_finalfn','-',null,'n');
+set gen_new_oid_value to 5524;
+insert into pg_proc values 
('jsonb_object_agg',11,10,12,'t','f','f','f','i',2,3802,'f','2276 
2276',null,null,null,'aggregate_dummy','-',null,'n');
+set gen_new_oid_value to 5525;
+insert into pg_proc values 
('jsonb_build_array',11,10,12,'f','f','f','f','s',1,3802,'f','2276','{2276}','{v}',null,'jsonb_build_array','-',null,'n');
+set gen_new_oid_value to 5526;
+insert into pg_proc values 
('jsonb_build_array',11,10,12,'f','f','f','f','s',0,3802,'f','',null,null,null,'jsonb_build_array_noargs','-',null,'n');
+set gen_new_oid_value to 5527;
+insert into pg_proc values 
('jsonb_build_object',11,10,12,'f','f','f','f','s',1,3802,'f','2276','{2276}','{v}',null,'jsonb_build_object','-',null,'n');
+set gen_new_oid_value to 5528;
+insert into pg_proc values 
('jsonb_build_object',11,10,12,'f','f','f','f','s',0,3802,'f','',null,null,null,'jsonb_build_object_noargs','-',null,'n');
+set gen_new_oid_value to 5529;
+insert into pg_proc values 
('jsonb_strip_nulls',11,10,12,'f','f','t','f','i',1,3802,'f','3802',null,null,null,'jsonb_strip_nulls','-',null,'n');
+set gen_new_oid_value to 5530;
+insert into pg_proc values 
('jsonb_to_record',11,10,12,'f','f','t','f','s',1,2249,'f','3802',null,null,null,'jsonb_to_record','-',null,'n');
+set gen_new_oid_value to 5531;
+insert into pg_proc values 
('jsonb_to_recordset',11,10,12,'f','f','f','t','s',1,2249,'f','3802',null,null,null,'jsonb_to_recordset','-',null,'n');
+set gen_new_oid_value to 5532;
+insert into pg_proc values 
('gin_extract_jsonb_path',11,10,12,'f','f','t','f','i',3,2281,'f','2281 2281 
2281',null,null,null,'gin_extract_jsonb_path','-',null,'n');
+set gen_new_oid_value to 5533;
+insert into pg_proc values 
('gin_extract_jsonb_query_path',11,10,12,'f','f','t','f','i',7,2281,'f','2277 
2281 21 2281 2281 2281 
2281',null,null,null,'gin_extract_jsonb_query_path','-',null,'n');
+set gen_new_oid_value to 5534;
+insert into pg_proc values 
('gin_consistent_jsonb_path',11,10,12,'f','f','t','f','i',8,16,'f','2281 21 
2277 23 2281 2281 2281 
2281',null,null,null,'gin_consistent_jsonb_path','-',null,'n');
+set gen_new_oid_value to 5535;
+insert into pg_proc values 
('gin_triconsistent_jsonb_path',11,10,12,'f','f','t','f','i',7,18,'f','2281 21 
2277 23 2281 2281 
2281',null,null,null,'gin_triconsistent_jsonb_path','-',null,'n');
+set gen_new_oid_value to 5536;
+insert into pg_proc values 
('jsonb_concat',11,10,12,'f','f','t','f','i',2,3802,'f','3802 
3802',null,null,null,'jsonb_concat','-',null,'n');
+set gen_new_oid_value to 5537;
+insert into pg_proc values 
('jsonb_delete',11,10,12,'f','f','t','f','i',2,3802,'f','3802 
25',null,null,null,'jsonb_delete','-',null,'n');
+set gen_new_oid_value to 5538;
+insert into pg_proc values 
('jsonb_delete',11,10,12,'f','f','t','f','i',2,3802,'f','3802 
23',null,null,null,'jsonb_delete_idx','-',null,'n');
+set gen_new_oid_value to 5539;
+insert into pg_proc values 
('jsonb_delete_path',11,10,12,'f','f','t','f','i',2,3802,'f','3802 
1009',null,null,null,'jsonb_delete_path','-',null,'n');
+set gen_new_oid_value to 5540;
+insert into pg_proc values 
('jsonb_set',11,10,12,'f','f','t','f','i',4,3802,'f','3802 1009 3802 
16',null,null,null,'jsonb_set','-',null,'n');
+set gen_new_oid_value to 5541;
+insert into pg_proc values 
('jsonb_pretty',11,10,12,'f','f','t','f','i',1,25,'f','3802',null,null,null,'jsonb_pretty','-',null,'n');
+reset gen_new_oid_value;
+
+------------------------------------------------------------------
+-- pg_type
+------------------------------------------------------------------
+set gen_new_oid_value to 193;
+insert into pg_type values 
('json',11,10,-1,'f','b','t',',',0,0,'json_in','json_out','json_recv','json_send','-','i','x','f',0,-1,0,null,null);
+set gen_new_oid_value to 199;
+insert into pg_type values ('_json',11 
,10,-1,'f','b','t',',',0,193,'array_in','array_out','array_recv','array_send','-','i','x','f',0,-1,0,null,null);
                
+set gen_new_oid_value to 3802;
+insert into pg_type values 
('jsonb',11,10,-1,'f','b','t',',',0,0,'jsonb_in','jsonb_out','jsonb_recv','jsonb_send','-','i','x','f',0,-1,0,null,null);
+set gen_new_oid_value to 3807;
+insert into pg_type values 
('_jsonb',11,10,-1,'f','b','t',',',0,3802,'array_in','array_out','array_recv','array_send','-','i','x','f',0,-1,0,null,null);
+reset gen_new_oid_value;
+
+------------------------------------------------------------------
+-- pg_aggregate
+------------------------------------------------------------------
+-- json
+insert into pg_aggregate values 
(3175,'json_agg_transfn','-','-','-','json_agg_finalfn',0,2281,null,'f');
+insert into pg_aggregate values 
(3197,'json_object_agg_transfn','-','-','-','json_object_agg_finalfn',0,2281,null,'f');
+
+-- jsonb
+insert into pg_aggregate values 
(5521,'jsonb_agg_transfn','-','-','-','jsonb_agg_finalfn',0,2281,null,'f');
+insert into pg_aggregate values 
(5524,'jsonb_object_agg_transfn','-','-','-','jsonb_object_agg_finalfn',0,2281,null,'f');
+
+
+------------------------------------------------------------------
+-- pg_amop
+------------------------------------------------------------------
+-- btree jsonb_ops
+insert into pg_amop values (4033,0,1,'f',3242);
+insert into pg_amop values (4033,0,2,'f',3244);
+insert into pg_amop values (4033,0,3,'f',5515);
+insert into pg_amop values (4033,0,4,'f',3245);
+insert into pg_amop values (4033,0,5,'f',3243);
+
+-- hash jsonb ops
+insert into pg_amop values (4034,0,1,'f',5515);
+
+
+-- GIN jsonb ops
+insert into pg_amop values (4036,0,7,'f',3246);
+insert into pg_amop values (4036,25,9,'f',3247);
+insert into pg_amop values (4036,1009,10,'f',3248);
+insert into pg_amop values (4036,1009,11,'f',3249);
+
+-- GIN jsonb hash ops
+insert into pg_amop values (4037,0,7,'f',3246);
+
+
+------------------------------------------------------------------
+-- pg_amproc
+------------------------------------------------------------------
+insert into pg_amproc values (4033,0,1,4044);
+insert into pg_amproc values (4034,0,1,4045);
+insert into pg_amproc values (4036,0,1,3480);
+insert into pg_amproc values (4036,0,2,3482);
+insert into pg_amproc values (4036,0,3,3483);
+insert into pg_amproc values (4036,0,4,3484);
+insert into pg_amproc values (4036,0,6,3488);
+insert into pg_amproc values (4037,0,1,351);
+insert into pg_amproc values (4037,0,2,3485);
+insert into pg_amproc values (4037,0,3,3486);
+insert into pg_amproc values (4037,0,4,3487);
+insert into pg_amproc values (4037,0,6,3489);
+
+------------------------------------------------------------------
+-- pg_cast
+------------------------------------------------------------------
+insert into pg_cast values (193,3802,0,'e');
+insert into pg_cast values (3802,193,0,'e');
+
+------------------------------------------------------------------
+-- pg_opclass
+------------------------------------------------------------------
+set gen_new_oid_value to 4033;
+insert into pg_opclass values (403,'jsonb_ops',11,10,3802,'t',0);
+set gen_new_oid_value to 4034;
+insert into pg_opclass values (405,'jsonb_ops',11,10,3802,'t',0); 
+set gen_new_oid_value to 4036;
+insert into pg_opclass values (2742,'jsonb_ops',11,10,3802,'t',25);
+set gen_new_oid_value to 4037;
+insert into pg_opclass values (2742,'jsonb_hash_ops',11,10,3802,'f',23);
+reset gen_new_oid_value;
+
+------------------------------------------------------------------
+-- pg_operator
+------------------------------------------------------------------
+set gen_new_oid_value to 3962;
+insert into pg_operator values ('->' ,11,10,'b','f',193 ,25  ,193 ,0   ,0   
,0,0,0,0,'json_object_field','-','-' );
+set gen_new_oid_value to 3963;
+insert into pg_operator values ('->>',11,10,'b','f',193 ,25  ,25  ,0   ,0   
,0,0,0,0,'json_object_field_text','-','-' );
+set gen_new_oid_value to 3964;
+insert into pg_operator values ('->' ,11,10,'b','f',193 ,23  ,193 ,0   ,0   
,0,0,0,0,'json_array_element','-','-' );
+set gen_new_oid_value to 3965;
+insert into pg_operator values ('->>',11,10,'b','f',193 ,23  ,25  ,0   ,0   
,0,0,0,0,'json_array_element_text','-','-' );
+set gen_new_oid_value to 3966;
+insert into pg_operator values ('#>' ,11,10,'b','f',193 ,1009,193 ,0   ,0   
,0,0,0,0,'json_extract_path_op','-','-' );
+set gen_new_oid_value to 3967;
+insert into pg_operator values ('#>>',11,10,'b','f',193 ,1009,25  ,0   ,0   
,0,0,0,0,'json_extract_path_text_op','-','-' );
+set gen_new_oid_value to 5506;
+insert into pg_operator values ('->' ,11,10,'b','f',3802,25  ,3802,0   ,0   
,0,0,0,0,'jsonb_object_field','-','-' );
+set gen_new_oid_value to 3477;
+insert into pg_operator values ('->>',11,10,'b','f',3802,25  ,25  ,0   ,0   
,0,0,0,0,'jsonb_object_field_text','-','-' );
+set gen_new_oid_value to 5507;
+insert into pg_operator values ('->' ,11,10,'b','f',3802,23  ,3802,0   ,0   
,0,0,0,0,'jsonb_array_element','-','-' );
+set gen_new_oid_value to 3481;
+insert into pg_operator values ('->>',11,10,'b','f',3802,23  ,25  ,0   ,0   
,0,0,0,0,'jsonb_array_element_text','-','-' );
+set gen_new_oid_value to 5508;
+insert into pg_operator values ('#>' ,11,10,'b','f',3802,1009,3802,0   ,0   
,0,0,0,0,'jsonb_extract_path_op','-','-' );
+set gen_new_oid_value to 5501;
+insert into pg_operator values ('#>>',11,10,'b','f',3802,1009,25  ,0   ,0   
,0,0,0,0,'jsonb_extract_path_text_op','-','-' );
+set gen_new_oid_value to 5515;
+insert into pg_operator values ('='  ,11,10,'b','t',3802,3802,16  
,5515,3241,0,0,0,0,'jsonb_eq','eqsel','eqjoinsel');
+set gen_new_oid_value to 3241;
+insert into pg_operator values ('<>' ,11,10,'b','f',3802,3802,16  
,3241,5515,0,0,0,0,'jsonb_ne','neqsel','neqjoinsel');
+set gen_new_oid_value to 3242;
+insert into pg_operator values ('<'  ,11,10,'b','f',3802,3802,16  
,3243,3245,0,0,0,0,'jsonb_lt','scalarltsel','scalarltjoinsel');
+set gen_new_oid_value to 3243;
+insert into pg_operator values ('>'  ,11,10,'b','f',3802,3802,16  
,3242,3244,0,0,0,0,'jsonb_gt','scalargtsel','scalargtjoinsel');
+set gen_new_oid_value to 3244;
+insert into pg_operator values ('<=' ,11,10,'b','f',3802,3802,16  
,3245,3243,0,0,0,0,'jsonb_le','scalarltsel','scalarltjoinsel');
+set gen_new_oid_value to 3245;
+insert into pg_operator values ('>=' ,11,10,'b','f',3802,3802,16  
,3244,3242,0,0,0,0,'jsonb_ge','scalargtsel','scalargtjoinsel');
+set gen_new_oid_value to 3246;
+insert into pg_operator values ('@>' ,11,10,'b','f',3802,3802,16  ,0   
,3250,0,0,0,0,'jsonb_contains','contsel','contjoinsel');
+set gen_new_oid_value to 3247;
+insert into pg_operator values ('?'  ,11,10,'b','f',3802,25  ,16  ,0   ,0   
,0,0,0,0,'jsonb_exists','contsel','contjoinsel');
+set gen_new_oid_value to 3248;
+insert into pg_operator values ('?|' ,11,10,'b','f',3802,1009,16  ,0   ,0   
,0,0,0,0,'jsonb_exists_any','contsel','contjoinsel');
+set gen_new_oid_value to 3249;
+insert into pg_operator values ('?&' ,11,10,'b','f',3802,1009,16  ,0   ,0   
,0,0,0,0,'jsonb_exists_all','contsel','contjoinsel');
+set gen_new_oid_value to 3250;
+insert into pg_operator values ('<@' ,11,10,'b','f',3802,3802,16  ,0   
,3246,0,0,0,0,'jsonb_contained','contsel','contjoinsel');
+set gen_new_oid_value to 3284;
+insert into pg_operator values ('||' ,11,10,'b','f',3802,3802,3802,0   ,0   
,0,0,0,0,'jsonb_concat','-','-');
+set gen_new_oid_value to 3285;
+insert into pg_operator values ('-'  ,11,10,'b','f',3802,25  ,3802,0   ,0   
,0,0,0,0,'5537','-','-' );
+set gen_new_oid_value to 3286;
+insert into pg_operator values ('-'  ,11,10,'b','f',3802,23  ,3802,0   ,0   
,0,0,0,0,'5538','-','-' );
+set gen_new_oid_value to 3287;
+insert into pg_operator values ('#-' ,11,10,'b','f',3802,1009,3802,0   ,0   
,0,0,0,0,'jsonb_delete_path','-','-');
+reset gen_new_oid_value;
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 797ab9b..99bc381 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -764,6 +764,7 @@ int         optimizer_plan_id;
 int  optimizer_samples_number;
 int  optimizer_log_failure;
 int default_hash_table_bucket_number;
+int gen_new_oid_value;
 int default_magma_hash_table_nvseg_per_seg;
 int hawq_auto_ha_timeout;
 int default_magma_block_size;
@@ -4650,6 +4651,15 @@ static struct config_int ConfigureNamesInt[] =
                8, 1, 65535, NULL, NULL
        },
 
+  {
+    {"gen_new_oid_value", PGC_USERSET, DEVELOPER_OPTIONS,
+      gettext_noop("Hardcode each newly generated oid value"),
+      NULL
+    },
+    &gen_new_oid_value,
+    0, 0, INT_MAX, NULL, NULL
+  },
+
        {
                {"new_executor_partitioned_hash_recursive_depth_limit", 
PGC_USERSET, QUERY_TUNING_OTHER,
                        gettext_noop("Sets 
new_executor_partitioned_hash_recursive_depth_limit"),
diff --git a/src/include/utils/guc.h b/src/include/utils/guc.h
index 5cf9b21..e68ab6b 100644
--- a/src/include/utils/guc.h
+++ b/src/include/utils/guc.h
@@ -313,6 +313,7 @@ extern int Debug_dtm_action_delay_ms;
 extern int Debug_dtm_action_segment;
 
 extern int default_hash_table_bucket_number;
+extern int gen_new_oid_value;
 extern int default_magma_hash_table_nvseg_per_seg;
 extern int hawq_auto_ha_timeout;
 extern int default_magma_block_size;  //  default magma block size
diff --git a/src/test/feature/UDF/TestUDF.cpp b/src/test/feature/UDF/TestUDF.cpp
index 04e01ab..48a2f2f 100644
--- a/src/test/feature/UDF/TestUDF.cpp
+++ b/src/test/feature/UDF/TestUDF.cpp
@@ -344,3 +344,12 @@ TEST_F(TestUDF, TestUDFDebug)
        std::string ansfile="UDF/ans/test_udf_debug.ans";
        util.execSpecificSQLFile(sqlfile, outfile, ansfile, "", "", "");
 }
+
+TEST_F(TestUDF, TestUDFWithAnalyzeMaintain)
+{
+       hawq::test::SQLUtility util;
+       std::string sqlfile="UDF/sql/test_udf_with_analyze.sql";
+       std::string outfile="UDF/ans/test_udf_with_analyze.out";
+       std::string ansfile="UDF/ans/test_udf_with_analyze.ans";
+       util.execSpecificSQLFile(sqlfile, outfile, ansfile, "", "", "");
+}
diff --git a/src/test/feature/UDF/ans/test_udf_with_analyze.ans 
b/src/test/feature/UDF/ans/test_udf_with_analyze.ans
new file mode 100644
index 0000000..90b221a
--- /dev/null
+++ b/src/test/feature/UDF/ans/test_udf_with_analyze.ans
@@ -0,0 +1,21 @@
+-- prepare table an test udf
+create table testUdfWithAnalyze(i int, c text);
+CREATE TABLE
+create function test() returns void as $$
+begin
+  insert into testUdfWithAnalyze select generate_series(1,100),'abc';
+  analyze testUdfWithAnalyze;
+end;
+$$ language plpgsql;
+CREATE FUNCTION
+-- run test
+alter resource queue pg_default with (active_statements=1);
+ALTER QUEUE
+select test();  -- should complete without error raised
+ test 
+------
+ 
+(1 row)
+
+alter resource queue pg_default with (active_statements=20);
+ALTER QUEUE
\ No newline at end of file
diff --git a/src/test/feature/UDF/sql/test_udf_with_analyze.sql 
b/src/test/feature/UDF/sql/test_udf_with_analyze.sql
new file mode 100644
index 0000000..596346f
--- /dev/null
+++ b/src/test/feature/UDF/sql/test_udf_with_analyze.sql
@@ -0,0 +1,19 @@
+-- start_ignore
+drop table if exists testUdfWithAnalyze;
+drop function test();
+-- end_ignore
+
+-- prepare table an test udf
+create table testUdfWithAnalyze(i int, c text);
+
+create function test() returns void as $$
+begin
+  insert into testUdfWithAnalyze select generate_series(1,100),'abc';
+  analyze testUdfWithAnalyze;
+end;
+$$ language plpgsql;
+
+-- run test
+alter resource queue pg_default with (active_statements=1);
+select test();  -- should complete without error raised
+alter resource queue pg_default with (active_statements=20);
\ No newline at end of file
diff --git a/tools/bin/upgrade.sh b/tools/bin/upgrade.sh
index 8e5077c..7574c58 100755
--- a/tools/bin/upgrade.sh
+++ b/tools/bin/upgrade.sh
@@ -18,9 +18,10 @@
 #
 
 # parse parameters
-usage() { echo "Usage: $0 [-s <3.3.x.x|2.4.0.0|2.4.0.1>] [-t <4.0.0.0>]" ; 
exit 1; }
+usage() { echo "Usage: $0 [-s <3.3.x.x|2.4.0.0|2.4.0.1>] [-t <4.0.0.0>] [-h]" 
; exit 1; }
 
-while getopts ":s:t:" opt; do
+delete_hcatalog=true;
+while getopts ":s:t:h" opt; do
     case "${opt}" in
         s)
             source_version=${OPTARG}
@@ -38,6 +39,10 @@ while getopts ":s:t:" opt; do
                 usage
             fi
             ;;
+        h)
+            delete_hcatalog=false
+            echo "Don't delete hcatalog."
+            ;;
         *)
             usage
             ;;
@@ -121,10 +126,12 @@ check_error "start cluster in upgrade mode"
 
 echo "Start hawq cluster in upgrade mode successfully."
 
-# 删除master节点hcatalog数据库
-PGOPTIONS="$OPTIONS" psql -t -p $MASTER_PORT -d template1 -c "delete from 
pg_database where datname='hcatalog';"
-check_error " delete hcatalog database in master"
-echo "Delete hacatalog database in master successfully."
+if $delete_hcatalog ; then
+    # 删除master节点hcatalog数据库
+    PGOPTIONS="$OPTIONS" psql -t -p $MASTER_PORT -d template1 -c "delete from 
pg_database where datname='hcatalog';"
+    check_error " delete hcatalog database in master"
+    echo "Delete hacatalog database in master successfully."
+fi
 
 # 删除segment节点hcatalog数据库
 gpssh -f $GPHOME/etc/slaves "source 
$GPHOME/greenplum_path.sh;PGOPTIONS='$OPTIONS' psql -p $SEGMENT_PORT -d 
template1 -c \"delete from pg_database where datname='hcatalog';\""
@@ -176,14 +183,6 @@ upgrade_catalog() {
         # 2、hive 安装
         install_function_by_database $1 "hive_install"
     
-        # json defered because oid issue
-        # 3、json相关元数据改动
-        #hawq ssh -f hostfile -e 'PGOPTIONS=\'-c gp_maintenance_conn=true\' 
psql -a -p $hawq_master_address_port -d template1 -f 
$GPHOME/share/postgresql/json_install.sql 2>&1 /tmp/json_install.out'
-        #grep ERROR /tmp/josn_install.out | wc -l
-        #if [[ num -ne 0 ]]
-        #echo 'Failed to register json function'
-        #fi
-    
         # 4、orc安装
         install_function_by_database $1 "orc_install"
     
@@ -203,10 +202,13 @@ upgrade_catalog() {
         echo "Add magma role column in pg_authid in database $1 in segment 
successfully."
     fi
     
-    # 7、magma函数注册
+    # 7、json函数注册
+    install_function_by_database $1 "json_install"
+
+    # 8、magma函数注册
     install_function_by_database $1 "magma_install"
     
-    # 8、监控函数注册
+    # 9、监控函数注册
     install_function_by_database $1 "monitor_install"
 }
 

Reply via email to