Uploaded image for project: 'Debezium'
  1. Debezium
  2. DBZ-2045

Postgres schema does not update when altering an enum type

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • Backlog
    • None
    • postgresql-connector
    • None

    Description

      Here is a failing test demonstrating the bug

          @Test
          public void shouldUpdateSchemaWhenEnumOptionsChange() throws Exception {
              TestHelper.execute("CREATE TYPE test_type AS ENUM ('V1');");
              TestHelper.execute("CREATE TABLE enum_table (pk SERIAL, value test_type NOT NULL, PRIMARY KEY (pk));");
              startConnector(config -> config
                      .with(PostgresConnectorConfig.INCLUDE_UNKNOWN_DATATYPES, true)
                      .with(PostgresConnectorConfig.SNAPSHOT_MODE, SnapshotMode.NEVER)
                      .with("column.propagate.source.type", "public.enum_table.value")
                      .with(PostgresConnectorConfig.TABLE_WHITELIST, "public.enum_table"), false);
      
              waitForStreamingToStart();
      
              // Alter the enum type to include a new option
              try (Connection connection = TestHelper.create().connection()) {
                  Statement statement = connection.createStatement();
                  statement.execute("ALTER TYPE test_type ADD VALUE 'V2'");
              }
              catch (Exception e) {
                  throw new RuntimeException(e);
              }
      
              consumer = testConsumer(1);
              executeAndWait("INSERT INTO enum_table (value) VALUES ('V2');");
      
              SourceRecord rec = assertRecordInserted("public.enum_table", PK_FIELD, 1);
              assertSourceInfo(rec, "postgres", "public", "enum_table");
      
              List<SchemaAndValueField> expected = Arrays.asList(
                      new SchemaAndValueField(PK_FIELD, Schema.INT32_SCHEMA, 1),
                      new SchemaAndValueField("value", Enum.builder("V1,V2")
                              .parameter(TestHelper.TYPE_NAME_PARAMETER_KEY, "TEST_TYPE")
                              .parameter(TestHelper.TYPE_LENGTH_PARAMETER_KEY, String.valueOf(Integer.MAX_VALUE))
                              .parameter(TestHelper.TYPE_SCALE_PARAMETER_KEY, "0")
                              .build(), "V2"));
      
              assertRecordSchemaAndValues(expected, rec, Envelope.FieldName.AFTER);
              assertThat(consumer.isEmpty()).isTrue();
          }
      

      Attachments

        Activity

          People

            bradengroom Braden Groom (Inactive)
            bradengroom Braden Groom (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: