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

Create table unique index parameters problem fixed #193

Merged
merged 4 commits into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/pg_query_deparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -4798,6 +4798,17 @@ static void deparseConstraint(StringInfo str, Constraint *constraint)
appendStringInfoString(str, ") ");
}

switch (constraint->contype)
{
case CONSTR_PRIMARY:
case CONSTR_UNIQUE:
case CONSTR_EXCLUSION:
deparseOptWith(str, constraint->options);
break;
default:
break;
}

if (constraint->indexname != NULL)
appendStringInfo(str, "USING INDEX %s ", quote_identifier(constraint->indexname));

Expand Down Expand Up @@ -9429,7 +9440,7 @@ static void deparseVariableShowStmt(StringInfo str, VariableShowStmt *variable_s
else if (strcmp(variable_show_stmt->name, "session_authorization") == 0)
appendStringInfoString(str, "SESSION AUTHORIZATION");
else if (strcmp(variable_show_stmt->name, "all") == 0)
appendStringInfoString(str, "SESSION ALL");
appendStringInfoString(str, "ALL");
else
appendStringInfoString(str, quote_identifier(variable_show_stmt->name));
}
Expand Down
2 changes: 2 additions & 0 deletions test/deparse_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,8 @@ const char* tests[] = {
"MERGE INTO measurement m USING new_measurement nm ON m.city_id = nm.city_id AND m.logdate = nm.logdate WHEN MATCHED AND nm.peaktemp IS NULL THEN DELETE WHEN MATCHED THEN UPDATE SET peaktemp = GREATEST(m.peaktemp, nm.peaktemp), unitsales = m.unitsales + COALESCE(nm.unitsales, 0) WHEN NOT MATCHED THEN INSERT (city_id, logdate, peaktemp, unitsales) VALUES (city_id, logdate, peaktemp, unitsales)",
"COPY vistest FROM STDIN FREEZE CSV",
"CREATE INDEX \"foo.index\" ON foo USING btree (bar)",
"CREATE TABLE distributors (did int, name varchar(40), UNIQUE (name) WITH (fillfactor=70)) WITH (fillfactor=70)",
"SHOW ALL",
};

size_t testsLength = __LINE__ - 4;