Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ALTER TABLE ADD COLUMN commands may cause crash. #7520

Closed
emelsimsek opened this issue Feb 20, 2024 · 0 comments · Fixed by #7522
Closed

ALTER TABLE ADD COLUMN commands may cause crash. #7520

emelsimsek opened this issue Feb 20, 2024 · 0 comments · Fixed by #7522

Comments

@emelsimsek
Copy link
Contributor

emelsimsek commented Feb 20, 2024

Repro steps:

> drop table lt;
> drop table rt;
> 
> create table lt(i int);
> select citus_add_local_table_to_metadata($$citus.lt$$);
> 
> create table rt(j int primary key, k int unique);
> select create_reference_table('rt');
> 
> 
> alter table lt add column is_nds bool,
>                add column new_col int references rt;
Program received signal SIGSEGV, Segmentation fault.
0x00007fd865d67151 in ErrorUnsupportedAlterTableAddColumn (relationId=17269, command=0x56160801ed50, constraint=0x56160801f088) at commands/table.c:3056
3056                    char *referencedColumn = strVal(lfirst(list_head(constraint->pk_attrs)));
(gdb) bt
#0  0x00007fd865d67151 in ErrorUnsupportedAlterTableAddColumn (relationId=17269, command=0x56160801ed50, constraint=0x56160801f088)
    at commands/table.c:3056
#1  0x00007fd865d66648 in PostprocessAlterTableStmt (alterTableStatement=0x56160801ea58) at commands/table.c:2681
#2  0x00007fd865d70d7a in citus_ProcessUtilityInternal (pstmt=0x56160801e948,
    queryString=0x561607da2e08 "alter table lt add column is_nds bool,\n", ' ' <repeats 15 times>, "add column new_col int references rt;", context=PROCESS_UTILITY_TOPLEVEL, params=0x0, queryEnv=0x0, dest=0x561607da4798, completionTag=0x7ffd4aea2ec0)
    at commands/utility_hook.c:861
#3  0x00007fd865d6ff8c in citus_ProcessUtility (pstmt=0x561607da3f68,
    queryString=0x561607da2e08 "alter table lt add column is_nds bool,\n", ' ' <repeats 15 times>, "add column new_col int references rt;", readOnlyTree=false, context=PROCESS_UTILITY_TOPLEVEL, params=0x0, queryEnv=0x0, dest=0x561607da4798, completionTag=0x7ffd4aea2ec0)
    at commands/utility_hook.c:357
#4  0x00007fd8651b7969 in pgss_ProcessUtility (pstmt=0x561607da3f68,
    queryString=0x561607da2e08 "alter table lt add column is_nds bool,\n", ' ' <repeats 15 times>, "add column new_col int references rt;", readOnlyTree=false, context=PROCESS_UTILITY_TOPLEVEL, params=0x0, queryEnv=0x0, dest=0x561607da4798, qc=0x7ffd4aea2ec0)
    at pg_stat_statements.c:1141
#5  0x00005616064e64f8 in ProcessUtility (pstmt=0x561607da3f68,
    queryString=0x561607da2e08 "alter table lt add column is_nds bool,\n", ' ' <repeats 15 times>, "add column new_col int references rt;", readOnlyTree=false, context=PROCESS_UTILITY_TOPLEVEL, params=0x0, queryEnv=0x0, dest=0x561607da4798, qc=0x7ffd4aea2ec0)
    at utility.c:526
#6  0x00005616064e4dfb in PortalRunUtility (portal=0x561607eb8d88, pstmt=0x561607da3f68, isTopLevel=true, setHoldSnapshot=false,
    dest=0x561607da4798, qc=0x7ffd4aea2ec0) at pquery.c:1158
#7  0x00005616064e5072 in PortalRunMulti (portal=0x561607eb8d88, isTopLevel=true, setHoldSnapshot=false, dest=0x561607da4798,
    altdest=0x561607da4798, qc=0x7ffd4aea2ec0) at pquery.c:1315
#8  0x00005616064e44bc in PortalRun (portal=0x561607eb8d88, count=9223372036854775807, isTopLevel=true, run_once=true,
    dest=0x561607da4798, altdest=0x561607da4798, qc=0x7ffd4aea2ec0) at pquery.c:791
#9  0x00005616064dd1cb in exec_simple_query (
    query_string=0x561607da2e08 "alter table lt add column is_nds bool,\n", ' ' <repeats 15 times>, "add column new_col int references rt;") at postgres.c:1274
#10 0x00005616064e2239 in PostgresMain (dbname=0x561607e74c40 "emel", username=0x561607e74c28 "emel") at postgres.c:4637
#11 0x000056160640320c in BackendRun (port=0x561607e70e60) at postmaster.c:4464
#12 0x0000561606402a98 in BackendStartup (port=0x561607e70e60) at postmaster.c:4192
#13 0x00005616063fed23 in ServerLoop () at postmaster.c:1782
#14 0x00005616063fe5cd in PostmasterMain (argc=5, argv=0x561607d09d70) at postmaster.c:1466
emelsimsek added a commit that referenced this issue Mar 20, 2024
…7522)

DESCRIPTION: Fixes a crash caused by some form of ALTER TABLE ADD COLUMN
statements. When adding multiple columns, if one of the ADD COLUMN
statements contains a FOREIGN constraint ommitting the referenced
columns in the statement, a SEGFAULT occurs.

For instance, the following statement results in a crash:

```
  ALTER TABLE lt ADD COLUMN new_col1 bool,
                          ADD COLUMN new_col2 int references rt;

```                      


Fixes #7520.
JelteF pushed a commit that referenced this issue Apr 16, 2024
…7522)

DESCRIPTION: Fixes a crash caused by some form of ALTER TABLE ADD COLUMN
statements. When adding multiple columns, if one of the ADD COLUMN
statements contains a FOREIGN constraint ommitting the referenced
columns in the statement, a SEGFAULT occurs.

For instance, the following statement results in a crash:

```
  ALTER TABLE lt ADD COLUMN new_col1 bool,
                          ADD COLUMN new_col2 int references rt;

```

Fixes #7520.

(cherry picked from commit fdd658a)
JelteF pushed a commit that referenced this issue Apr 16, 2024
…7522)

DESCRIPTION: Fixes a crash caused by some form of ALTER TABLE ADD COLUMN
statements. When adding multiple columns, if one of the ADD COLUMN
statements contains a FOREIGN constraint ommitting the referenced
columns in the statement, a SEGFAULT occurs.

For instance, the following statement results in a crash:

```
  ALTER TABLE lt ADD COLUMN new_col1 bool,
                          ADD COLUMN new_col2 int references rt;

```

Fixes #7520.

(cherry picked from commit fdd658a)
JelteF pushed a commit that referenced this issue Apr 16, 2024
…7522)

DESCRIPTION: Fixes a crash caused by some form of ALTER TABLE ADD COLUMN
statements. When adding multiple columns, if one of the ADD COLUMN
statements contains a FOREIGN constraint ommitting the referenced
columns in the statement, a SEGFAULT occurs.

For instance, the following statement results in a crash:

```
  ALTER TABLE lt ADD COLUMN new_col1 bool,
                          ADD COLUMN new_col2 int references rt;

```

Fixes #7520.

(cherry picked from commit fdd658a)
JelteF pushed a commit that referenced this issue Apr 16, 2024
…7522)

DESCRIPTION: Fixes a crash caused by some form of ALTER TABLE ADD COLUMN
statements. When adding multiple columns, if one of the ADD COLUMN
statements contains a FOREIGN constraint ommitting the referenced
columns in the statement, a SEGFAULT occurs.

For instance, the following statement results in a crash:

```
  ALTER TABLE lt ADD COLUMN new_col1 bool,
                          ADD COLUMN new_col2 int references rt;

```

Fixes #7520.

(cherry picked from commit fdd658a)
JelteF pushed a commit that referenced this issue Apr 17, 2024
…7522)

DESCRIPTION: Fixes a crash caused by some form of ALTER TABLE ADD COLUMN
statements. When adding multiple columns, if one of the ADD COLUMN
statements contains a FOREIGN constraint ommitting the referenced
columns in the statement, a SEGFAULT occurs.

For instance, the following statement results in a crash:

```
  ALTER TABLE lt ADD COLUMN new_col1 bool,
                          ADD COLUMN new_col2 int references rt;

```

Fixes #7520.

(cherry picked from commit fdd658a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant