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

Support Procedures- Postgres 11 #251

Merged
merged 30 commits into from
Oct 4, 2021
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
3618b04
All changes from my PRs:244,238,236,234,
Nov 24, 2018
4bda394
Update with PR 227(steve-chavez)
Nov 24, 2018
08ee990
Support Procedure https://www.postgresql.org/docs/11/sql-createproced…
Feb 21, 2019
6184333
Merge with fordfrog/apgdiff
Feb 21, 2019
6e69e25
Drop e Add constraint if table exists
Mar 27, 2019
f2e986e
Error on disable/enable trigger on trigger that dont exists on old sc…
May 10, 2020
b512284
Add tests for Support Postgresql 12 -Add support for FUNCTION in CREA…
May 10, 2020
f20b29d
Build with java 14
May 10, 2020
a5a412b
Merge branch 'develop' of https://github.com/jalissonmello/apgdiff in…
May 10, 2020
67e09cd
Initial Support to PARTITION BY on Create Table
Jun 11, 2020
e1e9e03
Null point comment
Jul 11, 2020
f40b387
Compile on java 8 and 11
Aug 21, 2020
40698e2
Avoid schema duplication. Similar to #265 from jschaf
Aug 21, 2020
c5574f1
Avoid schema duplication. Similar to #265 from jschaf
Aug 21, 2020
388cb8f
Identity column sequence
Sep 19, 2021
8bd0558
Identity column sequence
Sep 19, 2021
1ed0cab
Identity column sequence
Oct 2, 2021
5ea1916
Identity column sequence
Oct 2, 2021
6523c52
Merge
Oct 2, 2021
a42c324
Merge branch 'develop' of https://github.com/fordfrog/apgdiff into de…
Oct 2, 2021
36f3de3
Code from PR #273
Oct 2, 2021
5d45452
2.6.1 teste release
Oct 2, 2021
8272fcd
2.6.1 changes
Oct 2, 2021
221bc65
update readme
Oct 2, 2021
c93e0ad
Release 2.7.0
Oct 3, 2021
911425f
Remove useless if
Oct 3, 2021
12be202
Correct indentation and unnecessary extra line
Oct 3, 2021
09e927f
Change weird if else chain
Oct 3, 2021
5d2f20a
Improve Identation of the changes
Oct 3, 2021
8cd1a62
jar 2.7.0 generated using java 11
Oct 3, 2021
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
Empty file modified .gitignore
100644 → 100755
Empty file.
15 changes: 15 additions & 0 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@ This repo is mainly unmaintained. But if you found a bug and create a pull reque

## Changelog

### Version 2.6.1
jalissonmello marked this conversation as resolved.
Show resolved Hide resolved

#### New Features
* Initial Support to PARTITION BY on Create Table jalissonmello
* Initial suport to identity column. #277 jalissonmello
* Support Postgresql 12 -Add support for FUNCTION in CREATE TRIGGER #273 alexander-smyslov
* Add supports for CREATE SEQUENCE IF NOT EXISTS and CREATE INDEX IF NOT EXISTS. UltramanJack
#### Fixes
* Fix incorrect disable trigger parsing of quoted identifiers. Bugfixes #271 marcus-kempe
* fix for null pointer exception #270 marco44
* Fix issue where rule parsing was throwing # 269-marcus-kempe
* fixed some crashes #257 d1maxa
* Error on disable/enable trigger on trigger that dont exists on old schema.
* Drop and Add constraint if table exists, issue #252

### Version 2.6

#### New Features
Expand Down
35 changes: 18 additions & 17 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<groupId>cz.startnet</groupId>
<artifactId>apgdiff</artifactId>
<name>Another PostgreSQL Diff Tool</name>
<version>2.6.0-SNAPSHOT</version>
<version>2.6.1-SNAPSHOT</version>
jalissonmello marked this conversation as resolved.
Show resolved Hide resolved
<description>Simple PostgreSQL diff tool that is useful for schema upgrades. The tool compares two schema dump files and creates output file that is (after some hand-made modifications) suitable for upgrade of old schema.</description>

<url>http://www.apgdiff.com/</url>
Expand Down Expand Up @@ -113,7 +113,7 @@
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
Expand All @@ -125,15 +125,15 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.21.0</version>
<version>2.22.2</version>
</plugin>
<plugin>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.21.0</version>
<version>2.22.2</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<version>3.2.0</version>
<configuration>
<archive>
<manifest>
Expand All @@ -147,7 +147,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<version>3.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
Expand All @@ -161,7 +161,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.0</version>
<version>3.2.0</version>
<executions>
<execution>
<id>attach-javadoc</id>
Expand All @@ -183,6 +183,7 @@
<head>To do something:</head>
</tag>
</tags>
<source>8</source>
</configuration>
</plugin>
<plugin>
Expand All @@ -198,15 +199,15 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<version>3.1.0</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
<version>3.1.0</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
Expand All @@ -218,21 +219,21 @@
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<version>3.1.0</version>
<type>maven-plugin</type>
</dependency>

<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<version>3.8.1</version>
<type>maven-plugin</type>
</dependency>

<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
<version>3.1.0</version>
<type>maven-plugin</type>
</dependency>

Expand All @@ -254,11 +255,11 @@
<plugins>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.9</version>
<version>3.0.0</version>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.0</version>
<version>3.2.0</version>
<configuration>
<minmemory>128m</minmemory>
<maxmemory>512</maxmemory>
Expand All @@ -280,10 +281,10 @@
</plugin>
<plugin>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.9.0</version>
<version>3.13.0</version>
<configuration>
<sourceEncoding>utf-8</sourceEncoding>
<targetJdk>1.6</targetJdk>
<targetJdk>1.8</targetJdk>
</configuration>
</plugin>
<plugin>
Expand All @@ -293,7 +294,7 @@
</plugin>
<plugin>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.5</version>
<version>3.0.0</version>
<configuration>
<inputEncoding>UTF-8</inputEncoding>
<outputEncoding>UTF-8</outputEncoding>
Expand Down
Binary file added releases/apgdiff-2.6.1-SNAPSHOT.jar
Binary file not shown.
Empty file modified src/main/java/cz/startnet/utils/pgdiff/Pair.java
100644 → 100755
Empty file.
6 changes: 6 additions & 0 deletions src/main/java/cz/startnet/utils/pgdiff/PgDiff.java
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@ private static void updateSchemas(final PrintWriter writer,
writer, oldSchema, newSchema, searchPathHelper);
PgDiffFunctions.dropFunctions(
writer, arguments, oldSchema, newSchema, searchPathHelper);
PgDiffProcedures.dropPocedures(
writer, arguments, oldSchema, newSchema, searchPathHelper);
PgDiffViews.dropViews(
writer, oldSchema, newSchema, searchPathHelper);
PgDiffConstraints.dropConstraints(
Expand Down Expand Up @@ -308,6 +310,8 @@ private static void updateSchemas(final PrintWriter writer,
writer, oldSchema, newSchema, searchPathHelper);
PgDiffFunctions.createFunctions(
writer, arguments, oldSchema, newSchema, searchPathHelper);
PgDiffProcedures.createProducedures(
writer, arguments, oldSchema, newSchema, searchPathHelper);
PgDiffConstraints.createConstraints(
writer, oldSchema, newSchema, true, searchPathHelper);
PgDiffConstraints.createConstraints(
Expand All @@ -331,6 +335,8 @@ private static void updateSchemas(final PrintWriter writer,
writer, oldSchema, newSchema, searchPathHelper);
PgDiffFunctions.alterComments(
writer, oldSchema, newSchema, searchPathHelper);
PgDiffProcedures.alterComments(
writer, oldSchema, newSchema, searchPathHelper);
PgDiffConstraints.alterComments(
writer, oldSchema, newSchema, searchPathHelper);
PgDiffIndexes.alterComments(
Expand Down
158 changes: 158 additions & 0 deletions src/main/java/cz/startnet/utils/pgdiff/PgDiffProcedures.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
/**
* Copyright 2006 StartNet s.r.o.
*
* Distributed under MIT license
*/
package cz.startnet.utils.pgdiff;

import cz.startnet.utils.pgdiff.schema.PgProcedure;
import cz.startnet.utils.pgdiff.schema.PgSchema;
import java.io.PrintWriter;

/**
* Diffs procedures.
*
* @author jalissonmello
*/
public class PgDiffProcedures {

/**
* Outputs statements for new or modified procedures.
*
* @param writer writer the output should be written to
* @param arguments object containing arguments settings
* @param oldSchema original schema
* @param newSchema new schema
* @param searchPathHelper search path helper
*/
public static void createProducedures(final PrintWriter writer,
final PgDiffArguments arguments, final PgSchema oldSchema,
final PgSchema newSchema, final SearchPathHelper searchPathHelper) {
// Add new procedures and replace modified procedures
for (final PgProcedure newProcedure : newSchema.getProcedures()) {
final PgProcedure oldProcedure;

if (oldSchema == null) {
oldProcedure = null;
} else {
oldProcedure = oldSchema.getProcedure(newProcedure.getSignature());
}

if ((oldProcedure == null) || !newProcedure.equals(
oldProcedure, arguments.isIgnoreFunctionWhitespace())) {
searchPathHelper.outputSearchPath(writer);
writer.println();
writer.println(newProcedure.getCreationSQL());
}
}
}

/**
* Outputs statements for dropping of procedures that exist no more.
*
* @param writer writer the output should be written to
* @param arguments object containing arguments settings
* @param oldSchema original schema
* @param newSchema new schema
* @param searchPathHelper search path helper
*/
public static void dropPocedures(final PrintWriter writer,
final PgDiffArguments arguments, final PgSchema oldSchema,
final PgSchema newSchema, final SearchPathHelper searchPathHelper) {
if (oldSchema == null) {
return;
}

// Drop procedures that exist no more
for (final PgProcedure oldProcedure : oldSchema.getProcedures()) {
if (!newSchema.containsProcedure(oldProcedure.getSignature())) {
searchPathHelper.outputSearchPath(writer);
writer.println();
writer.println(oldProcedure.getDropSQL());
}
}
}

/**
* Outputs statements for procedure comments that have changed.
*
* @param writer writer
* @param oldSchema old schema
* @param newSchema new schema
* @param searchPathHelper search path helper
*/
public static void alterComments(final PrintWriter writer,
final PgSchema oldSchema, final PgSchema newSchema,
final SearchPathHelper searchPathHelper) {
if (oldSchema == null) {
return;
}

for (final PgProcedure oldprocedure : oldSchema.getProcedures()) {
final PgProcedure newProcedure =
newSchema.getProcedure(oldprocedure.getSignature());

if (newProcedure == null) {
continue;
}

if (oldprocedure.getComment() == null
&& newProcedure.getComment() != null
|| oldprocedure.getComment() != null
&& newProcedure.getComment() != null
&& !oldprocedure.getComment().equals(
newProcedure.getComment())) {
searchPathHelper.outputSearchPath(writer);
writer.println();
writer.print("COMMENT ON PROCEDURE ");
writer.print(PgDiffUtils.getQuotedName(newProcedure.getName()));
writer.print('(');

boolean addComma = false;

for (final PgProcedure.Argument argument :
newProcedure.getArguments()) {
if (addComma) {
writer.print(", ");
} else {
addComma = true;
}

writer.print(argument.getDeclaration(false));
}

writer.print(") IS ");
writer.print(newProcedure.getComment());
writer.println(';');
} else if (oldprocedure.getComment() != null
&& newProcedure.getComment() == null) {
searchPathHelper.outputSearchPath(writer);
writer.println();
writer.print("COMMENT ON PROCEDURE ");
writer.print(PgDiffUtils.getQuotedName(newProcedure.getName()));
writer.print('(');

boolean addComma = false;

for (final PgProcedure.Argument argument :
newProcedure.getArguments()) {
if (addComma) {
writer.print(", ");
} else {
addComma = true;
}

writer.print(argument.getDeclaration(false));
}

writer.println(") IS NULL;");
}
}
}

/**
* Creates a new instance of PgDiffProcedures.
*/
private PgDiffProcedures() {
}
}
Loading