Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Failed upgrade to 26.4.7 - sql generated for manual database upgrade contains invalid statements #45107

@silk

Description

@silk

Before reporting an issue

  • I have read and understood the above terms for submitting issues, and I understand that my issue may be closed without action if I do not follow them.

Area

No response

Describe the bug

Upgrading database from 26.3.4 -> 26.4.7 failed.
We are using manual strategy for upgrades (--spi-connections-jpa--quarkus--migration-strategy=manual).
SQL generated for upgrades to version 26.4.x is incorrect. It contains:

-- Changeset META-INF/jpa-changelog-26.4.0.xml::26.4.0-40933-saml-encryption-attributes::keycloak
-- WARNING The following SQL may change each run and therefore is possibly incorrect and/or invalid:
INSERT INTO KEYCLOAK_PUBLIC.CLIENT_ATTRIBUTES (CLIENT_ID,NAME,VALUE) SELECT ID, ?, ? FROM KEYCLOAK_PUBLIC.CLIENT WHERE PROTOCOL = ? AND ID NOT IN (SELECT CLIENT_ID FROM KEYCLOAK_PUBLIC.CLIENT_ATTRIBUTES WHERE NAME = ?);

INSERT INTO KEYCLOAK_PUBLIC.CLIENT_ATTRIBUTES (CLIENT_ID,NAME,VALUE) SELECT ID, ?, ? FROM KEYCLOAK_PUBLIC.CLIENT WHERE PROTOCOL = ? AND ID NOT IN (SELECT CLIENT_ID FROM KEYCLOAK_PUBLIC.CLIENT_ATTRIBUTES WHERE NAME = ?);

INSERT INTO KEYCLOAK_PUBLIC.CLIENT_ATTRIBUTES (CLIENT_ID,NAME,VALUE) SELECT ID, ?, ? FROM KEYCLOAK_PUBLIC.CLIENT WHERE PROTOCOL = ? AND ID NOT IN (SELECT CLIENT_ID FROM KEYCLOAK_PUBLIC.CLIENT_ATTRIBUTES WHERE NAME = ?);

Which contains parametrized sql's without values.

We are using Oracle, using: ojdbc17-23.6.0.24.10.jar and orai18n-23.6.0.24.10.jar

Version

26.4.7

Regression

  • The issue is a regression

Expected behavior

SQL's for DB upgrade with manual strategy contains proper statements.

Actual behavior

SQL's for DB upgrade with manual strategy contains invalid SQL statements.

How to Reproduce?

Try to generate DB upgrade SQL for database with version 26.3.4 to 26.4.7 (probably every 26.4.x version).

/.../keycloak-26.4.7/bin/kc.sh \
    start \
    --spi-connections-jpa-quarkus-migration-strategy=manual \
    --spi-connections-jpa-quarkus-initialize-empty=false \
    --spi-connections-jpa-quarkus-migration-export="$SQL_PATH"

Anything else?

No response

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions