postgresql-9.2

NULL vs. `infinity` in PostgreSQL range types

China☆狼群 提交于 2019-12-01 07:54:41
What is the meaning of 'infinity' in PostgreSQL range types? Is there any difference between specifying infinity or -infinity as a bound, or NULL ? I.e. is infinity an explicit form of specifying that the range bound is infinite, whereas NULL would implicit specify an infinite bound range? See the following examples: SELECT tstzrange('-infinity','infinity') && tstzrange(NULL, NULL); ?column? ---------- t SELECT tstzrange('2013-01-01 00:00:00+01', '2013-02-01 00:00:00+01') && tstzrange(NULL, '2013-03-01 00:00:00+01'); ?column? ---------- t SELECT tstzrange('2013-01-01 00:00:00+01', '2013-02-01

NULL vs. `infinity` in PostgreSQL range types

走远了吗. 提交于 2019-12-01 05:08:48
问题 What is the meaning of 'infinity' in PostgreSQL range types? Is there any difference between specifying infinity or -infinity as a bound, or NULL ? I.e. is infinity an explicit form of specifying that the range bound is infinite, whereas NULL would implicit specify an infinite bound range? See the following examples: SELECT tstzrange('-infinity','infinity') && tstzrange(NULL, NULL); ?column? ---------- t SELECT tstzrange('2013-01-01 00:00:00+01', '2013-02-01 00:00:00+01') && tstzrange(NULL,

Months between two dates function

喜夏-厌秋 提交于 2019-12-01 03:14:29
In oracle i can find out no:of months between using MONTHS_BETWEEN function. In postgres i am using extract function for this. eg.like select extract(year from age(current_date, '2012-12-09')) * 12 + extract(month from age(current_date, '2012-12-09')) Is there any other ways(built in functions) in postgres?? This is easy to re-implement in PostgreSQL just using SQL functions to tidy up what you've already got: create function months_of(interval) returns int strict immutable language sql as $$ select extract(years from $1)::int * 12 + extract(month from $1)::int $$; create function months

ROWID equivalent in postgres 9.2

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 02:29:37
Is there any way to get rowid of a record in postgres?? In oracle i can use like SELECT MAX(BILLS.ROWID) FROM BILLS baklarz2048 Yes, there is ctid column which is equivalent for rowid. But is useless for you. Rowid and ctid are physical row/tuple identifiers => can change after rebuild/vacuum. See: Chapter 5. Data Definition > 5.4. System Columns The PostgreSQL row_number() window function can be used for most purposes where you would use rowid. Whereas in Oracle the rowid is an intrinsic numbering of the result data rows, in Postgres row_number() computes a numbering within a logical ordering

Postgres log file contains: missing chunk number 0 for toast value 815441 in pg_toast_2619

╄→гoц情女王★ 提交于 2019-12-01 02:10:24
Below log message is available in postgres log file several thousand times. How to resolve. missing chunk number 0 for toast value 815441 in pg_toast_2619. pg_toast_2619 is the pg_statistic table. it (pg_statistic) contains duplicated records also. How to resolve this situation. What is the reason behind this. Something went wrong with you server. Server crashed? Disk failure? Anyway you could do: Stop your server and make a physical copy of your data directory to a secure place; Since pg_statistic is populated by ANALYZE , just clean it DELETE FROM pg_catalog.pg_statistic; and issue an

ROWID equivalent in postgres 9.2

ぐ巨炮叔叔 提交于 2019-11-30 22:06:38
问题 Is there any way to get rowid of a record in postgres?? In oracle i can use like SELECT MAX(BILLS.ROWID) FROM BILLS 回答1: Yes, there is ctid column which is equivalent for rowid. But is useless for you. Rowid and ctid are physical row/tuple identifiers => can change after rebuild/vacuum. See: Chapter 5. Data Definition > 5.4. System Columns 回答2: The PostgreSQL row_number() window function can be used for most purposes where you would use rowid. Whereas in Oracle the rowid is an intrinsic

What's the easiest way to represent a bytea as a single integer in PostgreSQL?

為{幸葍}努か 提交于 2019-11-30 20:51:41
I have a bytea column that contains 14 bytes of data. The last 3 bytes of the 14 contain the CRC code of the data. I would like to extract the CRC as a single integer to be stored in a new column. How would I go about doing this? To clarify, here's one way of doing it in Java: int crc = ((rawData[len - 3] & 0xff) << 16 | (rawData[len - 2] & 0xff) << 8 | (rawData[len - 1] & 0xff)) & 0xffffff; I'm hoping to find a solution without bit shifting, i.e. something like a method that accepts 4 bytes and converts them into an integer. Erwin Brandstetter Another way is to extract the last 6 characters

Postgres Installation Error reading file postgresql.conf

时光总嘲笑我的痴心妄想 提交于 2019-11-30 20:48:35
I have Windows Server 2003 machine on which I tried to install Postgres 9.2 . At the end of the installation it pops a warning saying Problem running post-install step. Installation may not complete correctly. Error reading file C:\Program Files\PostgreSQL\9.2\data\postgresql.conf I checked for the file postgresql.conf in C:\Program Files\PostgreSQL\9.2\data and found that it does not exist. I also found that there is not much under the data folder except for pg_log folder which is also empty. Any ideas on what I may be doing wrong? I recommend you to try following, it worked for me: Make sure

Passing a ResultSet into a Postgresql Function

断了今生、忘了曾经 提交于 2019-11-30 19:27:42
Is it possible to pass the results of a postgres query as an input into another function? As a very contrived example, say I have one query like SELECT id, name FROM users LIMIT 50 and I want to create a function my_function that takes the resultset of the first query and returns the minimum id. Is this possible in pl/pgsql? SELECT my_function(SELECT id, name FROM Users LIMIT 50); --returns 50 It is not possible to pass an array of generic type RECORD to a plpgsql function which is essentially what you are trying to do. What you can do is pass in an array of a specific user defined TYPE or of

Postgres Installation Error reading file postgresql.conf

扶醉桌前 提交于 2019-11-30 17:01:29
问题 I have Windows Server 2003 machine on which I tried to install Postgres 9.2 . At the end of the installation it pops a warning saying Problem running post-install step. Installation may not complete correctly. Error reading file C:\Program Files\PostgreSQL\9.2\data\postgresql.conf I checked for the file postgresql.conf in C:\Program Files\PostgreSQL\9.2\data and found that it does not exist. I also found that there is not much under the data folder except for pg_log folder which is also empty