reshke commented on issue #1566:
URL: https://github.com/apache/cloudberry/issues/1566#issuecomment-3863984022
> # part 2
>
> ace9973867c - small issues on apply, fixed 4b0d21b06c6 - clean e086b55381a
- clean 99504ff8265 - already-in e24615a0057 - clean apply fb81a93a644 -
already-in
>
> 5b94e2bd4d5: rebase conflicts with movable locales, fixed:
>
> ```
> #ifdef ENABLE_THREAD_SAFETY
> static pthread_mutex_t connections_mutex = PTHREAD_MUTEX_INITIALIZER;
> static pthread_key_t actual_connection_key;
> @@@ -518,7 -517,7 +522,11 @@@ ECPGconnect(int lineno, int c, const ch
> #ifdef HAVE_USELOCALE
> if (!ecpg_clocale)
> {
> ++<<<<<<< HEAD
> + ecpg_clocale = NEWLOCALE(LC_NUMERIC_MASK, "C", (locale_t)
0);
> ++=======
> + ecpg_clocale = newlocale(LC_NUMERIC_MASK, "C", (locale_t)
0);
> ++>>>>>>> 5b94e2bd4d5 (ecpglib: call newlocale() once per process.)
> if (!ecpg_clocale)
> {
> #ifdef ENABLE_THREAD_SAFETY
> ```
>
> 463a841d740 - clean 7fd43684fc9 - skip, already-in 0b71e43c489 - skip,
already-in 7c1f4261238 - clean apply
9783413cbff is troublesome:
```
reshke@yezzey-cbdb-bench:~/cbdb-pure$ git cherry-pick 9783413cbff
Auto-merging src/bin/pg_upgrade/check.c
CONFLICT (content): Merge conflict in src/bin/pg_upgrade/check.c
error: could not apply 9783413cbff... Tighten pg_upgrade's new check for
non-upgradable anyarray usages.
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
```
```
reshke@yezzey-cbdb-bench:~/cbdb-pure$ git diff src/bin/pg_upgrade/check.c
diff --cc src/bin/pg_upgrade/check.c
index 1859443ed87,cc4a4fd104e..00000000000
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@@ -1179,6 -979,135 +1179,138 @@@ check_for_user_defined_postfix_ops(Clus
}
/*
++<<<<<<< HEAD
++=======
+ * check_for_incompatible_polymorphics()
+ *
+ * Make sure nothing is using old polymorphic functions with
+ * anyarray/anyelement rather than the new anycompatible variants.
+ */
+ static void
+ check_for_incompatible_polymorphics(ClusterInfo *cluster)
+ {
+ PGresult *res;
+ FILE *script = NULL;
+ char output_path[MAXPGPATH];
+ PQExpBufferData old_polymorphics;
+
+ prep_status("Checking for incompatible polymorphic functions");
+
+ snprintf(output_path, sizeof(output_path),
+ "incompatible_polymorphics.txt");
+
+ /* The set of problematic functions varies a bit in different
versions */
+ initPQExpBuffer(&old_polymorphics);
+
+ appendPQExpBufferStr(&old_polymorphics,
+
"'array_append(anyarray,anyelement)'"
+ ",
'array_cat(anyarray,anyarray)'"
+ ",
'array_prepend(anyelement,anyarray)'");
+
+ if (GET_MAJOR_VERSION(cluster->major_version) >= 903)
+ appendPQExpBufferStr(&old_polymorphics,
+ ",
'array_remove(anyarray,anyelement)'"
+ ",
'array_replace(anyarray,anyelement,anyelement)'");
+
+ if (GET_MAJOR_VERSION(cluster->major_version) >= 905)
+ appendPQExpBufferStr(&old_polymorphics,
+ ",
'array_position(anyarray,anyelement)'"
+ ",
'array_position(anyarray,anyelement,integer)'"
+ ",
'array_positions(anyarray,anyelement)'"
+ ",
'width_bucket(anyelement,anyarray)'");
+
+ for (int dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
+ {
+ bool db_used = false;
+ DbInfo *active_db = &cluster->dbarr.dbs[dbnum];
+ PGconn *conn = connectToServer(cluster,
active_db->db_name);
+ int ntups;
+ int i_objkind,
+ i_objname;
+
+ /*
+ * The query below hardcodes FirstNormalObjectId as 16384
rather than
+ * interpolating that C #define into the query because, if
that
+ * #define is ever changed, the cutoff we want to use is the
value
+ * used by pre-version 14 servers, not that of some future
version.
+ */
+ res = executeQueryOrDie(conn,
+ /* Aggregate transition functions */
+ "SELECT
'aggregate' AS objkind, p.oid::regprocedure::text AS objname "
+ "FROM
pg_proc AS p "
+ "JOIN
pg_aggregate AS a ON a.aggfnoid=p.oid "
+ "JOIN
pg_proc AS transfn ON transfn.oid=a.aggtransfn "
+ "WHERE p.oid
>= 16384 "
+ "AND
a.aggtransfn = ANY(ARRAY[%s]::regprocedure[]) "
+ "AND
a.aggtranstype = ANY(ARRAY['anyarray', 'anyelement']::regtype[]) "
+
+ /* Aggregate final functions */
+ "UNION ALL "
+ "SELECT
'aggregate' AS objkind, p.oid::regprocedure::text AS objname "
+ "FROM
pg_proc AS p "
+ "JOIN
pg_aggregate AS a ON a.aggfnoid=p.oid "
+ "JOIN
pg_proc AS finalfn ON finalfn.oid=a.aggfinalfn "
+ "WHERE p.oid
>= 16384 "
+ "AND
a.aggfinalfn = ANY(ARRAY[%s]::regprocedure[]) "
+ "AND
a.aggtranstype = ANY(ARRAY['anyarray', 'anyelement']::regtype[]) "
+
+ /* Operators */
+ "UNION ALL "
+ "SELECT
'operator' AS objkind, op.oid::regoperator::text AS objname "
+ "FROM
pg_operator AS op "
+ "WHERE
op.oid >= 16384 "
+ "AND oprcode
= ANY(ARRAY[%s]::regprocedure[]) "
+ "AND oprleft
= ANY(ARRAY['anyarray', 'anyelement']::regtype[]);",
+
old_polymorphics.data,
+
old_polymorphics.data,
+
old_polymorphics.data);
+
+ ntups = PQntuples(res);
+
+ i_objkind = PQfnumber(res, "objkind");
+ i_objname = PQfnumber(res, "objname");
+
+ for (int rowno = 0; rowno < ntups; rowno++)
+ {
+ if (script == NULL &&
+ (script = fopen_priv(output_path, "w")) ==
NULL)
+ pg_fatal("could not open file \"%s\": %s\n",
+ output_path,
strerror(errno));
+ if (!db_used)
+ {
+ fprintf(script, "In database: %s\n",
active_db->db_name);
+ db_used = true;
+ }
+
+ fprintf(script, " %s: %s\n",
+ PQgetvalue(res, rowno, i_objkind),
+ PQgetvalue(res, rowno, i_objname));
+ }
+
+ PQclear(res);
+ PQfinish(conn);
+ }
+
+ if (script)
+ {
+ fclose(script);
+ pg_log(PG_REPORT, "fatal\n");
+ pg_fatal("Your installation contains user-defined objects
that refer to internal\n"
+ "polymorphic functions with arguments of
type 'anyarray' or 'anyelement'.\n"
+ "These user-defined objects must be dropped
before upgrading and restored\n"
+ "afterwards, changing them to refer to the
new corresponding functions with\n"
+ "arguments of type 'anycompatiblearray' and
'anycompatible'.\n"
+ "A list of the problematic objects is in
the file:\n"
+ " %s\n\n", output_path);
+ }
+ else
+ check_ok();
+
+ termPQExpBuffer(&old_polymorphics);
+ }
+
+ /*
++>>>>>>> 9783413cbff (Tighten pg_upgrade's new check for non-upgradable
anyarray usages.)
* Verify that no tables are declared WITH OIDS.
*/
static void
(END)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]