postgresql

How to get permission to debug postgres?

I have a system that uses C methods as functions in a Postgres database. When I try to run gdb with my user account I get this: ptrace: Operation not permitted It looks like a permission thing. It seemed to work when I ran gdb as the "postgres" user. I would like to continue running postgres as the "postgres" user and not have to su ...

text search query biulding in postgres

Hi , I need to bulid a stored procedure that takes input an array of varchars . It will search for these using syntax like SELECT * FROM mytable WHERE search_index @@ to_tsquery(' '); If i give input to the procedure like tom ,dick,harry the query should be dynamically build like SELECT * FROM mytable WHERE search_index @@ to_tsque...

DELETE records without associated ones.

I have a 'guests' table and 'invitations' table bound with many-to-one relationship in a postgreSQL database. I have removed some guests and now I want to remove invitations that have no guests. I tried using 'COUNT', but aggregates are not allowed in WHERE clause. ...

array to string conversion with delimter |

HI, I need to form a string from a given array. IF array[1] = gvk, array[2] = gvk1 and array[3] = gvk2 i need to get these values into a string like: Mystring = gvk | gvk1 | gvk2 ...

move data from one table to another, postgresql edition

Hi All, I'd like to move some data from one table to another (with a possibly different schema). Straightforward solution that comes into mind is - start a transaction with serializable isolation level; INSERT INTO dest_table SELECT data FROM orig_table,other-tables WHERE <condition>; DELETE FROM orig_table USING other-tables WHERE <co...

Is there a way I can create database documentation from model documentation

I'm finishing a certain django project. It's a data entry application with more than 170 tables in a postgresql database. The application would primarily serve to support a large data entry operation that would last about 2 months. After that it would only serve to export the entered data as xml and json. Plus people may use just the dat...

"getaddrinfo: Name or service not known" while rake db:migrate

# rake db:migrate --trace (in /www/rails_app) ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:migrate rake aborted! getaddrinfo: Name or service not known /usr/local/lib/ruby/gems/1.9.1/gems/postgres-pr-0.6.3/lib/postgres-pr/connection.rb:165:in `initialize' /usr/local/lib/ruby/ge...

Inner join on regexes

I have an inner join on regular expressions - it is very slow. Is there any easy way to speed this up? I am using postgres. FROM A inner join B ON trim(lower(replace(replace(replace(B.enginequery,',',' '),'"',' '),'+',' '))) = trim(lower(A.keyphrase)) OR trim(lower(replace(replace(replace(B.enginequery,',',' '),'"',' ')...

need help with installing php bbs discuz 7.0 english

hi, does anyone knows how to install discuz 7.0 with postgresql instead of the mysql? ...

DatabaseError: current transaction is aborted, commands ignored until end of transaction block

I got a lot of "DatabaseError: current transaction is aborted, commands ignored until end of transaction block" errors after changed from python-psycopg to python-psycopg2 as Django project's database engine. The code remains the same, just dont know where those errors are from. ...

How to manage db connections on server?

I have a severe problem with my database connection in my web application. Since I use a single database connection for the whole application from singleton Database class, if i try concurrent db operations (two users) the database rollsback the transactions. This is my static method used: All threads/servlets call static Database.doSom...

Database model for storing expressions and their occurrence in text

Hey, I'm doing a statistical research application. I need to store words according to 2 initial letters which is 676 combinations and each word has its number of occurrences (minimal, maximal, average) in text. I'm not sure how the model/schema should look like. There will be a lot of checking whether the keyword was already persisted. ...

Force max length for string in PostgreSQL

Hey guys, I am using heroku for a RoR application and am trying to manually set the length of a string column and am having trouble. I tried making a migration along the lines of change_column :posts, :content, :string, :length => 10000 I assumed this would work but no such luck, anyone have some pointers? Thanks! ...

How to stop NpgsqlDataReader from blocking?

Running the following code against a large PostgreSQL table, the NpgsqlDataReader object blocks until all data is fetched. NpgsqlCommand cmd = new NpgsqlCommand(strQuery, _conn); NpgsqlDataReader reader = cmd.ExecuteReader(); // <-- takes 30 seconds How can I get it to behave such that it doesn't prefetch all the data? I want to step ...

How to call Postgres function returning SETOF record?

I have written the following function: -- Gets stats for all markets CREATE OR REPLACE FUNCTION GetMarketStats ( ) RETURNS SETOF record AS $$ BEGIN SELECT 'R approved offer' AS Metric, SUM(CASE WHEN M.MarketName = 'A+' AND M.Term = 24 THEN LO.Amount ELSE 0 end) AS MarketAPlus24, SUM(CASE WHEN M.MarketName = 'A+' AND M.Term = 36 T...

How to do case-insensitive order in Rails with postgresql

I am in the process of switching my development environment from sqlite3 to postgresql 8.4 and have one last hurdle. In my original I had the following line in a helper method; result = Users.find(:all, :order => "name collate NOCASE") which provided a very nice case-insensitive search. I can't replicate this for postgresql. Should b...

Tomcat Postgres Connection

Hi, I'm using a singleton class for a PostgresSQL connection inside a servelet. The problem is that once it is open it works for a while (I guess until some timeout), and then it starts throwing a I/O exception. Any idea what is happening to the singleton class inside Tomcat VM? Thanks ...

SQLAlchemy Expression Language problem

I'm trying to convert this to something sqlalchemy expression language compatible, I don't know if it's possible out of box and are hoping someone more experienced can help me along. The backend is PostgreSQL and if I can't make it as an expression I'll create a string instead:: SELECT DISTINCT date_trunc('month', x.x) as date, ...

Import CSV file data into Postgres table

Hi , Iam new to postgres, i want to write an stored procedure that imports data from a csv file and populates the table . Kindly help. ...

PostgreSQL: SELECT all fields, filter some

Hi, In one of our databases, there is a table with dozens of columns, one of which is a geometry column. I want to SELECT rows from the table, with the geometry transformed to another SRID. I want to use something like: `SELECT *` in order to avoid: SELECT col_a, col_b, col_c, col_d, col_e, col_f, col_g, col_h, transform(t...