postgresql-9.1

pg_dump version mismatch in Rails

时光怂恿深爱的人放手 提交于 2019-12-10 14:53:43
问题 When running the rake db:structure:dump command, I encountered the following error: Larson-2:app larson$ rake db:structure:dump pg_dump: server version: 9.1.3; pg_dump version: 9.0.4 pg_dump: aborting because of server version mismatch rake aborted! Error dumping database How can I go about updating pg_dump? I have pg 9.1.3 installed, is there a way to update the references inside of Rails to the new version? When I try to update postgres via homebrew, I get the following output: Larson-2:app

Postgres creating a local temp table (on commit drop) from a dynamic sql string

橙三吉。 提交于 2019-12-10 14:12:24
问题 I have a query string generated in a postgres UDF, i'd like to put it's result in a temp table to perform joins against (I'm using LIMIT and OFFSET , and I don't want to join against other ttables only to end up choping the data off at the end --i.e., the LIMIT operator in the query plan). I attempt to create the temp table with the following statement. CREATE LOCAL TEMP TABLE query_result ON COMMIT DROP AS EXECUTE query_string_; But I get the following error notice : ********** Error *******

postgres hstore exists and doesn't exist at same time [duplicate]

人走茶凉 提交于 2019-12-10 12:30:58
问题 This question already has an answer here : How to create a new database with the hstore extension already installed? (1 answer) Closed 6 years ago . I set up a Rails app on a remote server and created an hstore extension sudo -u postgres psql CREATE EXTENSION hstore; I then deployed an iteration of the app that uses hstore in one of the postgres tables, but when it ran the migrations it gave an error message PG::UndefinedObject: ERROR: type "hstore" does not exist I then tried to do this

In a multi-server environment, if a site has inactivity for more than 15 mn, the server loses connection to PostgreSQL database

限于喜欢 提交于 2019-12-10 11:42:26
问题 I get the following errors in airbrake if my staging (2 servers) or production (4 servers) servers have no activity for about 15 minutes. Here are the error messages: ActiveRecord::StatementInvalid: PG::Error: could not receive data from server: Connection timed out OR PG::Error: could not connect to server: Connection timed out Is the server running on host "tci-db4.dev.prod" and accepting TCP/IP connections on port 5432? I'm using PostgreSQL as my database. One of the servers also acts as

Return records that don't have specific key - Rails4 HStore Postgresql query

为君一笑 提交于 2019-12-10 11:15:59
问题 I have a model Task t.string "name" t.hstore "actions" Example: #<Task id: 1, name: "first", actions: {"today"=>"9"}, #<Task id: 2, name: "second", actions: {"yesterday"=>"1"}, #<Task id: 3, name: "third", actions: nil, #<Task id: 4, name: "four", actions: {"today"=>"11"}, I need to find all records where actions: nil, :today<10 and key :today not present. It is 1,2,3 task. Task.where("actions -> 'today' < '10'") - it return only first task. Task.where("actions -> 'today' < '10' OR actions IS

Not able to install pg gem on Ubuntu 12.10

安稳与你 提交于 2019-12-10 11:13:17
问题 I am using Ubuntu 12.10 64-bit and I have following packages installed : dpkg --get-selections | grep postgre output: postgresql postgresql-9.1 postgresql-client postgresql-client-9.1 postgresql-client-common postgresql-common postgresql-contrib postgresql-contrib-9.1 postgresql-server-dev-9.1 postgresql-server-dev-all libpq-dev libpq5 rvm 1.17.9 ruby 1.9.3p362 (2012-12-25 revision 38607) [x86_64-linux] I am not able to install pg gem I am getting following error : ERROR: Error installing pg:

Find cluster given node in PostgreSQL

白昼怎懂夜的黑 提交于 2019-12-10 10:25:12
问题 I am representing a graph in Postgres 9.1 (happens to be bidirectional and cyclic): CREATE TABLE nodes ( id SERIAL PRIMARY KEY, name text ); CREATE TABLE edges ( id SERIAL PRIMARY KEY, node1_id int REFERENCES nodes(id), node2_id int REFERENCES nodes(id) ); Given a particular node ID, want to retrieve all other nodes in that cluster. I started with the "Paths from a single node" example here, and this is where I got: WITH RECURSIVE search_graph(id, path) AS ( SELECT id, ARRAY[id] FROM nodes

How to get unique values from each column based on a condition?

♀尐吖头ヾ 提交于 2019-12-10 10:01:34
问题 I have been trying to find an optimal solution to select unique values from each column . My problem is I don't know column names in advance since different table has different number of columns. So first, I have to find column names and I could use below query to do it: select column_name from information_schema.columns where table_name='m0301010000_ds' and column_name like 'c%' Sample output for column names: c1, c2a, c2b, c2c, c2d, c2e, c2f, c2g, c2h, c2i, c2j, c2k, ... Then I would use

multiply(num) aggregate function in postgresql

≯℡__Kan透↙ 提交于 2019-12-10 09:54:02
问题 This could be incredibly simple by the documentation is quite on it. Is there a way to aggregate columns via multiplication operator in postgresql. I know i can do count(column) or sum(column), but is there a multiply(column) or product(column) function that i can use. If not, any ideas how to achieve it. I'm using postgres 9.1 regards, Hassan 回答1: Sure, just define an aggregate over the base multiplication function. E.g. for bigint: CREATE AGGREGATE mul(bigint) ( SFUNC = int8mul, STYPE

Different results for extract epoch on different PostgreSQL servers

a 夏天 提交于 2019-12-10 06:56:25
问题 We convert time stamps to epoch, do some math on them and then convert them back to time stamps. All times in the database are TIMESTAMP WITHOUT TIME ZONE . Since the switch to summer time here in the UK times are off by one hour on one server but not on the other so I did a little test: SHOW SERVER_VERSION; SHOW TIMEZONE; SELECT extract(EPOCH FROM TIMESTAMP '1970-01-01'); On one server I get server_version ---------------- 9.1.15 (1 row) TimeZone ---------- GB (1 row) date_part ----------- 0