pglite icon indicating copy to clipboard operation
pglite copied to clipboard

"memory access out of bounds" when creating tables

Open mokeefe-paa opened this issue 1 year ago • 0 comments

I want to preface this bug report by saying I really appreciate this project! I've been waiting for this to exist for use in unit tests for years :)

When creating tables with certain schema, a RuntimeError: memory access out of bounds error is thrown.

One way to reproduce is creating a table with at least 20 columns.

So for instance this throws the error in my testing:

create table example_table
  (
    column_1 text,
    column_2 text,
    column_3 text,
    column_4 text,
    column_5 text,
    column_6 text,
    column_7 text,
    column_8 text,
    column_9 text,
    column_10 text,
    column_11 text,
    column_12 text,
    column_13 text,
    column_14 text,
    column_15 text,
    column_16 text,
    column_17 text,
    column_18 text,
    column_19 text,
    column_20 text
  );

but this does not:

create table example_table
  (
    column_1 text,
    column_2 text,
    column_3 text,
    column_4 text,
    column_5 text,
    column_6 text,
    column_7 text,
    column_8 text,
    column_9 text,
    column_10 text,
    column_11 text,
    column_12 text,
    column_13 text,
    column_14 text,
    column_15 text,
    column_16 text,
    column_17 text,
    column_18 text,
    column_19 text
  );

But this isn't limited to column count, I've seen it happen for all kinds of different setups. An especially confusing one is this case, where the only difference is whitespace:

Working:

create table files
  (
    id uuid not null primary key,
    name text not null,
    file_type text not null,
    size integer not null,
    demographics jsonb not null,
    person_id uuid,
    facility_id uuid
  );

Error:

    create table files
      (
        id               uuid                                               not null primary key,
        name             text                                               not null,
        file_type        text                                               not null,
        size             integer                                            not null,
        demographics     jsonb                                              not null,
        person_id        uuid,
        facility_id      uuid,
      );

But the whitespace alone isn't a problem. The same whitespace, but only for the first 4 columns works:

    create table files
      (
        id               uuid                                               not null primary key,
        name             text                                               not null,
        file_type        text                                               not null,
        size             integer                                            not null
      );

and it's not because we removed the only jsonb column. the same as the previous, but with the first column jsonb also works:

    create table files
      (
        id               jsonb                                               not null primary key,
        name             text                                               not null,
        file_type        text                                               not null,
        size             integer                                            not null
      );

I can't discern a pattern here.

Any help would be appreciated, I'd love to start using this for unit tests but this issue is preventing me from being able to use it.

mokeefe-paa avatar Feb 27 '24 16:02 mokeefe-paa