Wednesday, August 1, 2012

PG_READ_FILE : absolute path not allowed, SQL state: 42501

Just I have got few error while working with PostgreSQL pg_read_file recently, later found the corrective action for that, Here are ..

 select pg_read_file('/root/server.key',0,(pg_stat_file('server.key')).size);
1) Error : Absolute path not allowed, SQL state: 42501 
                   Solution : pg_read_file can read the files only from the data directory path, if you would like to know your data directory path use

SHOW  data_directory command. 
It would return like "/var/lib/postgresql/9.1/main" 

move the " server.key " file into data_directory and execute the above statement by 
select pg_read_file('server.key',0,  (pg_stat_file('server.key')).size); 
here   (pg_stat_file('server.key')).size) --> return the size of the file.


2) Error: could not open file "serrrrrrver.key" for reading: No such file or directory,  SQL state: 58P01
              Solution : The given file not exist in the data dictionary.

note : Empty result would be returned  if the specified file is an image.



Post a Comment