# Using PostgreSQL from another source when Percona PostgreSQL repo is enabled

**URL:** <https://forums.percona.com/t/using-postgresql-from-another-source-when-percona-postgresql-repo-is-enabled/19842>\
**Category:** PostgreSQL\
**Created:** [January 30, 2023, 5:00pm UTC](https://forums.percona.com/t/using-postgresql-from-another-source-when-percona-postgresql-repo-is-enabled/19842 "2023-01-30T17:00:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gertvdb](https://avatars.discourse-cdn.com/v4/letter/g/cdc98d/32.png) [@Gertvdb](https://forums.percona.com/u/Gertvdb)\
**Post date:** [January 30, 2023, 5:00pm UTC](https://forums.percona.com/t/using-postgresql-from-another-source-when-percona-postgresql-repo-is-enabled/19842/1 "2023-01-30T17:00:13Z")

</div>

When I’m trying to use the postgresql-14 package from the Ubuntu Jammy OS repo, the postinst for the postgresql-14 package fails with the following error:

```auto
/var/lib/dpkg/info/postgresql-14.postinst: 104: db_stop: not found
dpkg: error processing package postgresql-14 (--configure):
 installed postgresql-14 package post-installation script subprocess returned error exit status 127

```

That postinst script is simple:

```auto
#!/bin/sh

set -e

VERSION=${DPKG_MAINTSCRIPT_PACKAGE##*-}

if ["$1" = configure]; then
    . /usr/share/postgresql-common/maintscripts-functions

    configure_version $VERSION "$2"
fi

```

`db_stop` is from `/usr/share/debconf/confmodule`… I’ve figured out that that does not get loaded, due to `/usr/share/postgresql-common/maintscripts-functions` containing this at the bottom: (where it should be sourcing that file)

```auto
# start debconf if we are in the server's postinst (can't run from a function)
if ["${DPKG_MAINTSCRIPT_NAME:-}" = "postinst"] && ["$1" = "configure"]; then
    case $DPKG_MAINTSCRIPT_PACKAGE in
        percona-postgresql-[89].?|percona-postgresql-[1-9]?)
            . /usr/share/debconf/confmodule
            ;;
    esac
fi

```

That matches [the one from the Debian package](https://salsa.debian.org/postgresql/postgresql-common/-/blob/master/debian/maintscripts-functions#L245), after [this Percona patch](https://github.com/percona/postgres-packaging/blob/main/postgres-common/maintscripts-functions.patch) has been applied.

I’ve managed to track down the reason for that - apt prefers installing `percona-postgresql-common` when attempting to install `postgresql-common`: (this is with the PGDG repo disabled)

```auto
# apt-cache policy postgresql-common
postgresql-common:
  Installed: 1:241-6.jammy
  Candidate: 1:241-6.jammy
  Version table:
 *** 1:241-6.jammy 500
        500 http://repo.percona.com/ppg-14/apt jammy/main amd64 Packages
        100 /var/lib/dpkg/status
     1:241-5.jammy 500
        500 http://repo.percona.com/ppg-14/apt jammy/main amd64 Packages
     1:241-4.jammy 500
        500 http://repo.percona.com/ppg-14/apt jammy/main amd64 Packages
     1:241-3.jammy 500
        500 http://repo.percona.com/ppg-14/apt jammy/main amd64 Packages
     238 500
        500 http://us-east-1.ec2.archive.ubuntu.com/ubuntu jammy/main amd64 Packages

```

apt-show on that also shows the Percona package instead:

```auto
# apt show postgresql-common
Package: postgresql-common
Version: 1:241-6.jammy
Priority: optional
Section: database
Source: percona-postgresql-common
Maintainer: Percona Development Team <info@percona.com>
Installed-Size: 642 kB
Provides: percona-postgresql-common, postgresql-common
Depends: adduser, debconf (>= 0.5.00) | debconf-2.0, libjson-perl, lsb-base (>= 3.0-3), perl (>= 5.14), percona-postgresql-client-common | postgresql-client-common, ssl-cert (>= 1.0.11), ucf
Recommends: e2fsprogs, logrotate
Conflicts: postgresql-common
Breaks: percona-postgresql-server-dev-all (<< 204), postgresql-9.1 (<< 9.1.1-3~), postgresql-server-dev-all (<< 204), systemd (<< 204)
Replaces: percona-postgresql-server-dev-all (<< 204), postgresql-common, postgresql-server-dev-all (<< 204)
Download-Size: 188 kB
APT-Manual-Installed: no
APT-Sources: http://repo.percona.com/ppg-14/apt jammy/main amd64 Packages
<description removed>

```

I suspect (but can’t easily confirm) that the cause for this is that it is marked that it replaces the `postgresql-common` package, which might result in percona-postgresql-common being selected instead of the postgresql-common from the other source. (The [postgresql.org](http://postgresql.org) (PGDG) repos have the same issue)

---

<div class="post-metadata">

**Author:** ![Gertvdb](https://avatars.discourse-cdn.com/v4/letter/g/cdc98d/32.png) [@Gertvdb](https://forums.percona.com/u/Gertvdb)\
**Post date:** [January 31, 2023, 9:20am UTC](https://forums.percona.com/t/using-postgresql-from-another-source-when-percona-postgresql-repo-is-enabled/19842/2 "2023-01-31T09:20:20Z")

</div>

For this some package pinning works.

For the postgres-15 stuff from PGDG: /etc/apt/preferences.d/postgresql

```auto
Package: postgresql-15
Pin: release o=apt.postgresql.org
Pin-Priority: 550

Package: postgresql-common
Pin: release o=apt.postgresql.org
Pin-Priority: 550

Package: postgresql-client-common
Pin: release o=apt.postgresql.org
Pin-Priority: 550

```

For the OS packages use `release o=Ubuntu` instead.
