Skip to content

[Bug]: Conversion of MariaDB to Postgres17 fails on oc_storages_numeric_id_seq sequence #56128

@psych0d0g

Description

@psych0d0g

⚠️ This issue respects the following points: ⚠️

Bug description

While converting my mariaDB instance to pgsql i get the following exception:

In ExceptionConverter.php line 62:

  An exception occurred while executing a query: SQLSTATE[42601]: Syntax error: 7 ERROR:  syntax error at or near ")"
  LINE 1: ...nextcloud.oc_storages_numeric_id_seq', (SELECT MAX() FROM ))
                                                                       ^


In Exception.php line 24:

  SQLSTATE[42601]: Syntax error: 7 ERROR:  syntax error at or near ")"
  LINE 1: ...nextcloud.oc_storages_numeric_id_seq', (SELECT MAX() FROM ))
                                                                       ^


In Connection.php line 71:

  SQLSTATE[42601]: Syntax error: 7 ERROR:  syntax error at or near ")"
  LINE 1: ...nextcloud.oc_storages_numeric_id_seq', (SELECT MAX() FROM ))
                                                                       ^

oc_storages in mysql looks like this:

MariaDB [nextcloud]> select * from oc_storages;
+------------+----------------------------+-----------+--------------+
| numeric_id | id                         | available | last_checked |
+------------+----------------------------+-----------+--------------+
|          1 | home::User1                |         1 |         NULL |
|          3 | home::User2                |         1 |         NULL |
|          4 | local::/var/www/html/data/ |         1 |         NULL |
+------------+----------------------------+-----------+--------------+
3 rows in set (0.001 sec)

and:

MariaDB [nextcloud]> explain oc_storages;
+--------------+-------------+------+-----+---------+----------------+
| Field        | Type        | Null | Key | Default | Extra          |
+--------------+-------------+------+-----+---------+----------------+
| numeric_id   | bigint(20)  | NO   | PRI | NULL    | auto_increment |
| id           | varchar(64) | YES  | UNI | NULL    |                |
| available    | int(11)     | NO   |     | 1       |                |
| last_checked | int(11)     | YES  |     | NULL    |                |
+--------------+-------------+------+-----+---------+----------------+
4 rows in set (0.001 sec)

the sequence in postgresql exists despite the exception:

nextcloud=# \d nextcloud.oc_storages_numeric_id_seq
               Sequence "nextcloud.oc_storages_numeric_id_seq"
  Type  | Start | Minimum |       Maximum       | Increment | Cycles? | Cache
--------+-------+---------+---------------------+-----------+---------+-------
 bigint |     1 |       1 | 9223372036854775807 |         1 | no      |     1
Owned by: nextcloud.oc_storages.numeric_id

nextcloud=# SELECT * FROM nextcloud.oc_storages_numeric_id_seq;
 last_value | log_cnt | is_called
------------+---------+-----------
          1 |       0 | f
(1 row)

Steps to reproduce

php occ db:convert-type --password="xxxx" pgsql nextcloud nextcloud-psql-primary.nextcloud.svc nextcloud

Expected behavior

have a working PGSQL conversion on the target

Nextcloud Server version

30, 31.0.10, 32.0.1

Operating system

None

PHP engine version

None

Web server

None

Database engine version

None

Is this bug present after an update or on a fresh install?

None

Are you using the Nextcloud Server Encryption module?

None

What user-backends are you using?

  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other

Configuration report

{
    "system": {
        "htaccess.RewriteBase": "\/",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "apps_paths": [
            {
                "path": "\/var\/www\/html\/apps",
                "url": "\/apps",
                "writable": false
            },
            {
                "path": "\/var\/www\/html\/custom_apps",
                "url": "\/custom_apps",
                "writable": true
            }
        ],
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "***REMOVED SENSITIVE VALUE***"
        ],
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "31.0.10.2",
        "overwrite.cli.url": "http:\/\/localhost",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "loglevel": 0,
        "maintenance": false,
        "app_install_overwrite": [
            "occweb",
            "passman",
            "news",
            "files_opds",
            "folderplayer"
        ],
        "theme": "",
        "mail_smtpmode": "smtp",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_sendmailmode": "smtp",
        "mail_smtpauth": 1,
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "default_phone_region": "DE",
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "password": "***REMOVED SENSITIVE VALUE***",
            "port": 6379
        }
    }
}

List of activated Apps

Nextcloud Signing status

No errors have been found.

Nextcloud Logs

Additional info

Running docker image via helm chart, version 31.0.10, also version 30 was affected.
after upgrading nextcloud to version 32.0.1 this issue is still present.

Metadata

Metadata

Assignees

No one assigned

    Labels

    0. Needs triagePending check for reproducibility or if it fits our roadmap30-feedbackbug

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions