=== Applying patches on top of PostgreSQL commit ID 9d8cdcbe0c8aee743e29079bdb2e4b5eeae4c70e === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Tue Jun 9 14:12:21 UTC 2026 On branch cf/5018 nothing to commit, working tree clean === using 'git am' to apply patch ./v10-0001-Add-support-for-extensions-with-an-owned-schema.patch === Applying: Add support for extensions with an owned schema Using index info to reconstruct a base tree... M src/backend/commands/extension.c M src/bin/pg_dump/pg_dump.c M src/bin/pg_dump/pg_dump.h M src/include/catalog/pg_proc.dat M src/test/modules/test_extensions/Makefile M src/test/modules/test_extensions/meson.build Falling back to patching base and 3-way merge... Auto-merging src/test/modules/test_extensions/meson.build Auto-merging src/test/modules/test_extensions/Makefile Auto-merging src/include/catalog/pg_proc.dat Auto-merging src/bin/pg_dump/pg_dump.h Auto-merging src/bin/pg_dump/pg_dump.c Auto-merging src/backend/commands/extension.c CONFLICT (content): Merge conflict in src/backend/commands/extension.c error: Failed to merge in the changes. hint: Use 'git am --show-current-patch=diff' to see the failed patch Patch failed at 0001 Add support for extensions with an owned schema When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort". === using patch(1) to apply patch ./v10-0001-Add-support-for-extensions-with-an-owned-schema.patch === patching file doc/src/sgml/extend.sgml patching file doc/src/sgml/ref/create_extension.sgml patching file src/backend/commands/extension.c Hunk #1 succeeded at 95 (offset 1 line). Hunk #2 succeeded at 796 (offset 3 lines). Hunk #3 succeeded at 1247 (offset 3 lines). Hunk #4 succeeded at 1313 (offset 3 lines). Hunk #5 succeeded at 1852 (offset 3 lines). Hunk #6 succeeded at 2039 (offset 3 lines). Hunk #7 FAILED at 2107. Hunk #8 succeeded at 2229 (offset 6 lines). Hunk #9 succeeded at 2435 (offset 6 lines). Hunk #10 succeeded at 2466 (offset 6 lines). Hunk #11 succeeded at 2511 (offset 6 lines). Hunk #12 succeeded at 3456 (offset 6 lines). Hunk #13 succeeded at 3478 (offset 6 lines). Hunk #14 succeeded at 3490 (offset 6 lines). Hunk #15 succeeded at 3513 (offset 6 lines). Hunk #16 succeeded at 3622 (offset 6 lines). Hunk #17 succeeded at 3672 (offset 6 lines). 1 out of 17 hunks FAILED -- saving rejects to file src/backend/commands/extension.c.rej patching file src/backend/utils/adt/pg_upgrade_support.c patching file src/bin/pg_dump/pg_dump.c Hunk #2 succeeded at 6055 (offset 2 lines). Hunk #3 succeeded at 6069 (offset 2 lines). Hunk #4 succeeded at 6252 (offset 2 lines). Hunk #5 succeeded at 6261 (offset 2 lines). Hunk #6 succeeded at 6284 (offset 2 lines). Hunk #7 succeeded at 6298 (offset 2 lines). Hunk #8 succeeded at 12075 (offset 54 lines). Hunk #9 succeeded at 12189 (offset 54 lines). patching file src/bin/pg_dump/pg_dump.h patching file src/include/catalog/pg_extension.h patching file src/include/catalog/pg_proc.dat Hunk #1 succeeded at 11923 (offset 6 lines). patching file src/include/commands/extension.h patching file src/test/modules/test_extensions/Makefile Hunk #1 succeeded at 10 with fuzz 2 (offset 1 line). Hunk #2 succeeded at 30 (offset 3 lines). patching file src/test/modules/test_extensions/expected/test_extensions.out patching file src/test/modules/test_extensions/meson.build Hunk #1 succeeded at 44 with fuzz 1. patching file src/test/modules/test_extensions/sql/test_extensions.sql patching file src/test/modules/test_extensions/test_ext_owned_schema--1.0--1.1.sql patching file src/test/modules/test_extensions/test_ext_owned_schema--1.0.sql patching file src/test/modules/test_extensions/test_ext_owned_schema.control patching file src/test/modules/test_extensions/test_ext_owned_schema_nosuperuser--1.0--1.1.sql patching file src/test/modules/test_extensions/test_ext_owned_schema_nosuperuser--1.0.sql patching file src/test/modules/test_extensions/test_ext_owned_schema_nosuperuser.control patching file src/test/modules/test_extensions/test_ext_owned_schema_relocatable--1.0.sql patching file src/test/modules/test_extensions/test_ext_owned_schema_relocatable.control patching file src/test/modules/test_extensions/test_ext_owned_schema_trusted--1.0--1.1.sql patching file src/test/modules/test_extensions/test_ext_owned_schema_trusted--1.0.sql patching file src/test/modules/test_extensions/test_ext_owned_schema_trusted.control patching file src/test/modules/test_pg_dump/t/001_base.pl Unstaged changes after reset: M doc/src/sgml/extend.sgml M doc/src/sgml/ref/create_extension.sgml M src/backend/commands/extension.c M src/backend/utils/adt/pg_upgrade_support.c M src/bin/pg_dump/pg_dump.c M src/bin/pg_dump/pg_dump.h M src/include/catalog/pg_extension.h M src/include/catalog/pg_proc.dat M src/include/commands/extension.h M src/test/modules/test_extensions/Makefile M src/test/modules/test_extensions/expected/test_extensions.out M src/test/modules/test_extensions/meson.build M src/test/modules/test_extensions/sql/test_extensions.sql M src/test/modules/test_pg_dump/t/001_base.pl Removing src/backend/commands/extension.c.rej Removing src/test/modules/test_extensions/test_ext_owned_schema--1.0--1.1.sql Removing src/test/modules/test_extensions/test_ext_owned_schema--1.0.sql Removing src/test/modules/test_extensions/test_ext_owned_schema.control Removing src/test/modules/test_extensions/test_ext_owned_schema_nosuperuser--1.0--1.1.sql Removing src/test/modules/test_extensions/test_ext_owned_schema_nosuperuser--1.0.sql Removing src/test/modules/test_extensions/test_ext_owned_schema_nosuperuser.control Removing src/test/modules/test_extensions/test_ext_owned_schema_relocatable--1.0.sql Removing src/test/modules/test_extensions/test_ext_owned_schema_relocatable.control Removing src/test/modules/test_extensions/test_ext_owned_schema_trusted--1.0--1.1.sql Removing src/test/modules/test_extensions/test_ext_owned_schema_trusted--1.0.sql Removing src/test/modules/test_extensions/test_ext_owned_schema_trusted.control === using 'git apply' to apply patch ./v10-0001-Add-support-for-extensions-with-an-owned-schema.patch === Applied patch to 'doc/src/sgml/extend.sgml' cleanly. Applied patch to 'doc/src/sgml/ref/create_extension.sgml' cleanly. Applied patch to 'src/backend/commands/extension.c' with conflicts. Applied patch to 'src/backend/utils/adt/pg_upgrade_support.c' cleanly. Applied patch to 'src/bin/pg_dump/pg_dump.c' cleanly. Applied patch to 'src/bin/pg_dump/pg_dump.h' cleanly. Applied patch to 'src/include/catalog/pg_extension.h' cleanly. Applied patch to 'src/include/catalog/pg_proc.dat' cleanly. Applied patch to 'src/include/commands/extension.h' cleanly. Applied patch to 'src/test/modules/test_extensions/Makefile' cleanly. Applied patch to 'src/test/modules/test_extensions/expected/test_extensions.out' cleanly. Applied patch to 'src/test/modules/test_extensions/meson.build' cleanly. Applied patch to 'src/test/modules/test_extensions/sql/test_extensions.sql' cleanly. Falling back to direct application... Falling back to direct application... Falling back to direct application... Falling back to direct application... Falling back to direct application... Falling back to direct application... Falling back to direct application... Falling back to direct application... Falling back to direct application... Falling back to direct application... Falling back to direct application... Applied patch to 'src/test/modules/test_pg_dump/t/001_base.pl' cleanly. U src/backend/commands/extension.c diff --cc src/backend/commands/extension.c index d073585c421,5e88c1b0e12..00000000000 --- a/src/backend/commands/extension.c +++ b/src/backend/commands/extension.c @@@ -1921,80 -2107,25 +2110,45 @@@ CreateExtensionInternal(char *extension control = read_extension_aux_control_file(pcontrol, versionName); /* - * Determine the target schema to install the extension into + * For trusted extensions with owned schemas, we need to create the schema + * as superuser to ensure proper ownership. */ - if (schemaName) + if (control->owned_schema) { - /* If the user is giving us the schema name, it must exist already. */ - schemaOid = get_namespace_oid(schemaName, false); - } - - if (control->schema != NULL) - { - /* - * The extension is not relocatable and the author gave us a schema - * for it. - * - * Unless CASCADE parameter was given, it's an error to give a schema - * different from control->schema if control->schema is specified. - */ - if (schemaName && strcmp(control->schema, schemaName) != 0 && - !cascade) - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("extension \"%s\" must be installed in schema \"%s\"", - control->name, - control->schema))); - - /* Always use the schema from control file for current extension. */ - schemaName = control->schema; - - /* Find or create the schema in case it does not exist. */ - schemaOid = get_namespace_oid(schemaName, true); - - if (!OidIsValid(schemaOid)) + switch_to_superuser = check_extension_superuser_requirements(control, NULL); + if (switch_to_superuser) { ++<<<<<<< ours + ParseState *pstate = make_parsestate(NULL); + CreateSchemaStmt *csstmt = makeNode(CreateSchemaStmt); + + pstate->p_sourcetext = "(generated CREATE SCHEMA command)"; + + csstmt->schemaname = schemaName; + csstmt->authrole = NULL; /* will be created by current user */ + csstmt->schemaElts = NIL; + csstmt->if_not_exists = false; + + CreateSchemaCommand(pstate, csstmt, -1, -1); + + /* + * CreateSchemaCommand includes CommandCounterIncrement, so new + * schema is now visible. + */ + schemaOid = get_namespace_oid(schemaName, false); ++======= + GetUserIdAndSecContext(&save_userid, &save_sec_context); + SetUserIdAndSecContext(BOOTSTRAP_SUPERUSERID, + save_sec_context | SECURITY_LOCAL_USERID_CHANGE); ++>>>>>>> theirs } } - else if (!OidIsValid(schemaOid)) - { - /* - * Neither user nor author of the extension specified schema; use the - * current default creation namespace, which is the first explicit - * entry in the search_path. - */ - List *search_path = fetch_search_path(false); - if (search_path == NIL) /* nothing valid in search_path? */ - ereport(ERROR, - (errcode(ERRCODE_UNDEFINED_SCHEMA), - errmsg("no schema has been selected to create in"))); - schemaOid = linitial_oid(search_path); - schemaName = get_namespace_name(schemaOid); - if (schemaName == NULL) /* recently-deleted namespace? */ - ereport(ERROR, - (errcode(ERRCODE_UNDEFINED_SCHEMA), - errmsg("no schema has been selected to create in"))); + schemaOid = GetOrCreateSchemaForExtension(&schemaName, control, cascade); - list_free(search_path); - } + /* Restore authentication state after schema creation if needed */ + if (switch_to_superuser) + SetUserIdAndSecContext(save_userid, save_sec_context); /* * Make note if a temporary namespace has been accessed in this