Specify Windows paths in terms of PostgreSQL

Not so much expression there is in the SQL dialect of the Postgres database'but that requires as argument a filesystem path. I can name a couple:
the
    the
  • CREATE TABLESPACE...
  • the
  • CREATE FUNCTION... (in case of dynamic loading of C functions)


So, the crux of the matter is that these arguments are string constants. And this, in turn, means no lexical check, which leads to different effects in different operating systems. In order not to spread the idea of the tree:

the
Windows Users! Replace your usual slashes (backslash's, actually) these slashes: '/', parameters specifying the system path!


the NO:
CREATE TABLESPACE dbspace
LOCATION 'C:\Program Files\PostgreSQL\8.3\data\dbs';


CREATE TABLESPACE dbspace
LOCATION E'C:\Program Files\PostgreSQL\8.3\data\dbs';


* This source code was highlighted with Source Code Highlighter.


the YES:

CREATE TABLESPACE dbspace
LOCATION 'C:/Program Files/PostgreSQL/8.3/data/dbs';


CREATE TABLESPACE dbspace
LOCATION 'C:\\Program Files\\PostgreSQL\\8.3\\data\\dbs';
the -- but with a warning! We strongly recommend to do so


CREATE TABLESPACE dbspace
LOCATION E'C:\\Program Files\\PostgreSQL\\8.3\\data\\dbs';


* This source code was highlighted with Source Code Highlighter.


the PS: I'm not a fan of absolute paths, and therefore asked: "Why do we have magic dynamic_library_path for CREATE FUNCTION and CREATE TABLESPACE nothing (even the seedy run-time parameter)?
Article based on information from habrahabr.ru

Комментарии

Популярные сообщения из этого блога

Integration of PostgreSQL with MS SQL Server for those who want faster and deeper

Custom database queries in MODx Revolution

Parse URL in Zend Framework 2