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

tuhaihe pushed a commit to branch REL_2_STABLE
in repository https://gitbox.apache.org/repos/asf/cloudberry.git

commit 319060692d67dc405801177f5f9e064d697baee1
Author: Brent Doil <[email protected]>
AuthorDate: Thu Jul 21 14:57:43 2022 -0400

    pg_dump: Remove dead code.
    
    Remove remaining checks for versions pre-8.3
    
    Authored-by: Brent Doil <[email protected]>
---
 src/bin/pg_dump/pg_dump.c | 144 +++++++++++-----------------------------------
 src/bin/pg_dump/pg_dump.h |   2 -
 2 files changed, 32 insertions(+), 114 deletions(-)

diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 69a05f30660..b4a618785ab 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -322,7 +322,6 @@ static char *format_function_signature(Archive *fout,
 static char *convertRegProcReference(const char *proc);
 static char *getFormattedOperatorName(const char *oproid);
 static char *convertTSFunction(Archive *fout, Oid funcOid);
-static Oid     findLastBuiltinOid_V71(Archive *fout);
 static const char *getFormattedTypeName(Archive *fout, Oid oid, OidOptions 
opts);
 static void getBlobs(Archive *fout);
 static void dumpBlob(Archive *fout, const BlobInfo *binfo);
@@ -1036,15 +1035,7 @@ main(int argc, char **argv)
        if (dumpsnapshot && fout->remoteVersion < 90200)
                fatal("Exported snapshots are not supported by this server 
version.");
 
-       /*
-        * Find the last built-in OID, if needed (prior to 8.1)
-        *
-        * With 8.1 and above, we can just use FirstNormalObjectId - 1.
-        */
-       if (fout->remoteVersion < 80100)
-               g_last_builtin_oid = findLastBuiltinOid_V71(fout);
-       else
-               g_last_builtin_oid = FirstNormalObjectId - 1;
+       g_last_builtin_oid = FirstNormalObjectId - 1;
 
        pg_log_info("last built-in OID is %u", g_last_builtin_oid);
 
@@ -5848,15 +5839,6 @@ getExtensions(Archive *fout, int *numExtensions)
        int                     i_extconfig;
        int                     i_extcondition;
 
-       /*
-        * Before 8.3 (porting from PG 9.1), there are no extensions.
-        */
-       if (fout->remoteVersion < 80300)
-       {
-               *numExtensions = 0;
-               return NULL;
-       }
-
        query = createPQExpBuffer();
 
        appendPQExpBufferStr(query, "SELECT x.tableoid, x.oid, "
@@ -9957,13 +9939,6 @@ getTSParsers(Archive *fout, int *numTSParsers)
        int                     i_prsheadline;
        int                     i_prslextype;
 
-       /* Before 8.3, there is no built-in text search support */
-       if (fout->remoteVersion < 80300)
-       {
-               *numTSParsers = 0;
-               return NULL;
-       }
-
        query = createPQExpBuffer();
 
        /*
@@ -10042,13 +10017,6 @@ getTSDictionaries(Archive *fout, int *numTSDicts)
        int                     i_dicttemplate;
        int                     i_dictinitoption;
 
-       /* Before 8.3, there is no built-in text search support */
-       if (fout->remoteVersion < 80300)
-       {
-               *numTSDicts = 0;
-               return NULL;
-       }
-
        query = createPQExpBuffer();
 
        appendPQExpBuffer(query, "SELECT tableoid, oid, dictname, "
@@ -10120,13 +10088,6 @@ getTSTemplates(Archive *fout, int *numTSTemplates)
        int                     i_tmplinit;
        int                     i_tmpllexize;
 
-       /* Before 8.3, there is no built-in text search support */
-       if (fout->remoteVersion < 80300)
-       {
-               *numTSTemplates = 0;
-               return NULL;
-       }
-
        query = createPQExpBuffer();
 
        appendPQExpBufferStr(query, "SELECT tableoid, oid, tmplname, "
@@ -10192,13 +10153,6 @@ getTSConfigurations(Archive *fout, int *numTSConfigs)
        int                     i_cfgowner;
        int                     i_cfgparser;
 
-       /* Before 8.3, there is no built-in text search support */
-       if (fout->remoteVersion < 80300)
-       {
-               *numTSConfigs = 0;
-               return NULL;
-       }
-
        query = createPQExpBuffer();
 
        appendPQExpBuffer(query, "SELECT tableoid, oid, cfgname, "
@@ -18051,23 +18005,15 @@ dumpTableSchema(Archive *fout, const TableInfo 
*tbinfo)
                 */
                if (gp_partitioning_available)
                {
-                       bool            isTemplatesSupported = 
fout->remoteVersion >= 80214;
                        bool            isPartitioned = false;
                        PQExpBuffer query = createPQExpBuffer();
                        PGresult   *res;
 
                        /* does support GP partitioning. */
                        resetPQExpBuffer(query);
-                       /* MPP-6297: dump by tablename */
-                       if (isTemplatesSupported)
-                               /* use 4.x version of function */
-                               appendPQExpBuffer(query, "SELECT "
-                                  "pg_get_partition_def('%u'::pg_catalog.oid, 
true, true) ",
-                                                                 
tbinfo->dobj.catId.oid);
-                       else    /* use 3.x version of function */
-                               appendPQExpBuffer(query, "SELECT "
-                                                
"pg_get_partition_def('%u'::pg_catalog.oid, true) ",
-                                                                 
tbinfo->dobj.catId.oid);
+                       appendPQExpBuffer(query, "SELECT "
+                                 "pg_get_partition_def('%u'::pg_catalog.oid, 
true, true) ",
+                                                               
tbinfo->dobj.catId.oid);
 
                        res = ExecuteSqlQuery(fout, query->data, 
PGRES_TUPLES_OK);
 
@@ -18087,42 +18033,39 @@ dumpTableSchema(Archive *fout, const TableInfo 
*tbinfo)
 
                        PQclear(res);
 
-                       /*
-                        * MPP-6095: dump ALTER TABLE statements for 
subpartition
-                        * templates
-                        */
-                       if (isTemplatesSupported)
-                       {
-                               resetPQExpBuffer(query);
+                /*
+                       * MPP-6095: dump ALTER TABLE statements for subpartition
+                       * templates
+                       */
+                       resetPQExpBuffer(query);
 
-                               appendPQExpBuffer(
-                                                                 query, 
"SELECT "
-                                                                 
"pg_get_partition_template_def('%u'::pg_catalog.oid, true, true) ",
-                                                                 
tbinfo->dobj.catId.oid);
+                       appendPQExpBuffer(
+                                                               query, "SELECT "
+                                                               
"pg_get_partition_template_def('%u'::pg_catalog.oid, true, true) ",
+                                                               
tbinfo->dobj.catId.oid);
 
-                               res = ExecuteSqlQuery(fout, query->data, 
PGRES_TUPLES_OK);
+                       res = ExecuteSqlQuery(fout, query->data, 
PGRES_TUPLES_OK);
 
-                               if (PQntuples(res) != 1)
-                               {
-                                       if (PQntuples(res) < 1)
-                                               pg_log_warning("query to obtain 
definition of table \"%s\" returned no data",
-                                                                          
tbinfo->dobj.name);
-                                       else
-                                               pg_log_warning("query to obtain 
definition of table \"%s\" returned more than one definition",
-                                                                          
tbinfo->dobj.name);
-                                       exit_nicely(1);
-                               }
+                       if (PQntuples(res) != 1)
+                       {
+                               if (PQntuples(res) < 1)
+                                       pg_log_warning("query to obtain 
definition of table \"%s\" returned no data",
+                                                                               
tbinfo->dobj.name);
+                               else
+                                       pg_log_warning("query to obtain 
definition of table \"%s\" returned more than one definition",
+                                                                               
tbinfo->dobj.name);
+                               exit_nicely(1);
+                       }
 
-                               /*
-                                * MPP-9537: terminate (with semicolon) the 
previous
-                                * statement, and dump the template definitions
-                                */
-                               if (!PQgetisnull(res, 0, 0) &&
-                                       PQgetlength(res, 0, 0))
-                                       appendPQExpBuffer(q, ";\n %s", 
PQgetvalue(res, 0, 0));
+                       /*
+                               * MPP-9537: terminate (with semicolon) the 
previous
+                               * statement, and dump the template definitions
+                               */
+                       if (!PQgetisnull(res, 0, 0) &&
+                               PQgetlength(res, 0, 0))
+                               appendPQExpBuffer(q, ";\n %s", PQgetvalue(res, 
0, 0));
 
-                               PQclear(res);
-                       }
+                       PQclear(res);
 
                        if (isPartitioned)
                        {
@@ -19425,29 +19368,6 @@ dumpTableConstraintComment(Archive *fout, const 
ConstraintInfo *coninfo)
        free(qtabname);
 }
 
-/*
- * findLastBuiltinOid_V71 -
- *
- * find the last built in oid
- *
- * For 7.1 through 8.0, we do this by retrieving datlastsysoid from the
- * pg_database entry for the current database.  (Note: current_database()
- * requires 7.3; pg_dump requires 8.0 now.)
- */
-static Oid
-findLastBuiltinOid_V71(Archive *fout)
-{
-       PGresult   *res;
-       Oid                     last_oid;
-
-       res = ExecuteSqlQueryForSingleRow(fout,
-                                                                         
"SELECT datlastsysoid FROM pg_database WHERE datname = current_database()");
-       last_oid = atooid(PQgetvalue(res, 0, PQfnumber(res, "datlastsysoid")));
-       PQclear(res);
-
-       return last_oid;
-}
-
 /*
  * dumpSequence
  *       write the declaration (not data) of one user-defined sequence
diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h
index dc6791deb49..3d431c02081 100644
--- a/src/bin/pg_dump/pg_dump.h
+++ b/src/bin/pg_dump/pg_dump.h
@@ -772,8 +772,6 @@ extern void getSubscriptions(Archive *fout);
 /* START MPP ADDITION */
 extern ExtProtInfo *getExtProtocols(Archive *fout, int *numExtProtocols);
 extern BinaryUpgradeInfo *getBinaryUpgradeObjects(void);
-
-extern bool    testExtProtocolSupport(Archive *fout);
 /* END MPP ADDITION */
 
 #endif                                                 /* PG_DUMP_H */


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to