postgresql-9.3

Can I store circle and polygon within the same spatially indexed column in postgis?

匆匆过客 提交于 2019-12-10 21:23:43
问题 According to their documentation the spatial objects can be of the following POINT(0 0) LINESTRING(0 0,1 1,1 2) POLYGON((0 0,4 0,4 4,0 4,0 0),(1 1, 2 1, 2 2, 1 2,1 1)) MULTIPOINT(0 0,1 2) MULTILINESTRING((0 0,1 1,1 2),(2 3,3 2,5 4)) MULTIPOLYGON(((0 0,4 0,4 4,0 4,0 0),(1 1,2 1,2 2,1 2,1 1)), ((-1 -1,-1 -2,-2 -2,-2 -1,-1 -1))) GEOMETRYCOLLECTION(POINT(2 3),LINESTRING(2 3,3 4)) However , there is no circle type, where I can just store a point and its radius. And have the same feature where I

Passing an array of arrays as parameter to a function

∥☆過路亽.° 提交于 2019-12-10 21:06:56
问题 A web application can send to a function an array of arrays like [ [ [1,2], [3,4] ], [ [], [4,5,6] ] ] The outer array length is n > 0 . The middle arrays are of constant length, 2 in this example. And the inner arrays lengths are n >= 0 . I could string build it like this: with t(a, b) as ( values (1, 4), (2, 3), (1, 4), (7, 3), (7, 4) ) select distinct a, b from t where (a = any(array[1,2]) or array_length(array[1,2],1) is null) and (b = any(array[3,4]) or array_length(array[3,4],1) is null

Why does postgres' upper range function for a daterange return an exclusive bound?

有些话、适合烂在心里 提交于 2019-12-10 18:06:37
问题 I've created a sql fiddle for this post: http://sqlfiddle.com/#!15/7b5d7/1/0 Question #1 Why does inserting a record with a daterange that has exclusive bounds actually store a range with an inclusive lower bound and an exclusive upper bound? Why doesn't pg store them both as inclusive bounds? Question #2 SELECT upper('[2016-06-19, 2016-06-21)'::daterange) returns 2016-06-21 . Note that [ signifies an inclusive lower bound and ) an exclusive upper bound. Shouldn't selecting the upper bound

Refreshing a materialized view does not include added column

我是研究僧i 提交于 2019-12-10 16:13:47
问题 From the manual CREATE MATERIALIZED VIEW is similar to CREATE TABLE AS, except that it also remembers the query used to initialize the view, so that it can be refreshed later upon demand. As I understand refreshing a materialized view should have the same effect as re create view as . But it is not what happens here. Create a table with a single column drop table if exists t cascade; create table t (a int); insert into t (a) values (1); Create the materialized view create materialized view

PostgreSQL error: query string argument of EXECUTE is null

孤者浪人 提交于 2019-12-10 15:48:06
问题 I have a table called evidence with a trigger which calls a stored procedure which basically does table partitioning by month. However I get an obscure error when I start inserting lots of rows under load: Npgsql.NpgsqlException: query string argument of EXECUTE is null Severity: ERROR Code: 22004 at Npgsql.NpgsqlState.<ProcessBackendResponses_Ver_3>d__a.MoveNext() in c:\C#Apps\github.npgsql.Npgsql.stock\src\Npgsql\NpgsqlState.cs:line890 at Npgsql.ForwardsOnlyDataReader.GetNextResponseObject(

How to resolve the error 'fe_sendauth: no password supplied' in Rails using PostgreSQL?

╄→гoц情女王★ 提交于 2019-12-10 13:04:49
问题 I've tried to create my Rails app with postgresql database, but when I started rails server , I got this error: fe_sendauth: no password supplied Here're my actions step by step: $ sudo apt-get install postgresql postgresql-contrib $ gem install pg $ rails new timetracker --database=postgresql --skip-unit-test My database.yml file looks like this: default: &default adapter: postgresql encoding: unicode pool: 5 host: localhost username: postgres password: development: <<: *default database:

Compare result of two table functions using one column from each

僤鯓⒐⒋嵵緔 提交于 2019-12-10 11:21:31
问题 According the instructions here I have created two functions that use EXECUTE FORMAT and return the same table of (int,smallint) . Sample definitions: CREATE OR REPLACE FUNCTION function1(IN _tbl regclass, IN _tbl2 regclass, IN field1 integer) RETURNS TABLE(id integer, dist smallint) CREATE OR REPLACE FUNCTION function2(IN _tbl regclass, IN _tbl2 regclass, IN field1 integer) RETURNS TABLE(id integer, dist smallint) Both functions return the exact same number of rows. Sample result ( will be

sequelize with postgres database not working after migration from mysql

丶灬走出姿态 提交于 2019-12-10 10:08:35
问题 I change MySQL databese into postgreSQL in sequelize. But After migration I have issue with upper and lowercase first letter in Table or Model... Before my MySQL version was working properly but after migration I got error message: 500 SequelizeDatabaseError: relation "Users" does not exist My User model: module.exports = function(sequelize, Sequelize) { var User = sequelize.define("User", { // profile userlevel: Sequelize.STRING, restaurant: Sequelize.STRING, access: Sequelize.STRING,

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

How to convert json array into postgres int array in postgres 9.3

青春壹個敷衍的年華 提交于 2019-12-10 03:03:59
问题 I have scenario where i need to convert a json array into postgres int array and query it for the result. Below is my array ID DATA 1 {"bookIds" : [1,2,3,5], "storeIds": [2,3]} 2 {"bookIds" : [4,5,6,7], "storeIds": [1,3]} 3 {"bookIds" : [11,12,10,9], "storeIds": [4,3]} I want convert booksId array into int array and later query it. Is it possible in postgres 9.3? I know 9.4 + provides much more JSON support but i can't update my db at the moment. Below query gives me error Select data::json->