Search code examples
postgresqldockercentoslibpqxx

PostgreSQL: ERROR: syntax error at or near "NOT"


What is possibly wrong with this (PostgreSQL 9.2.24 on CentOS used from Docker container):

terminate called after throwing an instance of 'pqxx::syntax_error'
  what():  ERROR:  syntax error at or near "NOT"
LINE 1: ...olver_fit_length BIGINT NOT NULL);CREATE INDEX IF NOT EXISTS...
                                                             ^

This same code works fine on my host Ubuntu 18.04 and PostgreSQL 10 so I'm not sure what to fix and where.


Solution

  • "IF NOT EXISTS" has been introduced in PostgreSQL 9.5- version 9.2 does not support it -> https://www.postgresql.org/docs/9.2/sql-createindex.html and https://www.postgresql.org/docs/9.5/sql-createindex.html .