1

I have a very simple query:

DROP TYPE IF EXISTS abc;

When run on my local machine, all good. When run on my production machine, it returns:

ERROR:  syntax error at or near "EXISTS" at character 14

I have tried typing it manually rather than copying to make sure there is no hidden character somewhere, but I can not figure out how this can given an error at one place but not at another.

2
  • check for the postgres versions on client and server Commented Apr 23, 2013 at 3:59
  • 1
    Always include your PostgreSQL version in questions. You probably need to upgrade PostgreSQL; you are almost certainly on a very old and unsupported version. See postgresql.org/support/versioning . The longer you delay the upgrade the more painful it will get. Read the release notes for each .0 version between yours and the current version for upgrade advice. Commented Apr 23, 2013 at 6:28

1 Answer 1

2

Check the versions that you're using, for both local and production.

The if exists clause was only added to drop type in 8.2.

And, before anyone questions why it complains about the exists rather than the if, it's because the statement:

drop type if

is perfectly valid up to that point, as an attempt to drop the if type. It's only the exists after that which makes the syntax bad.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.