postgresql

Installing PostgreSQL on Windows

I'm in a bit of a mess here. I installed PostgreSQL on my Vista computer a couple of days ago but then when asked to enter the password for the postgre user account I couldn't remember it (allegedly I was asked during setup but I don't remember that). Anyway, so I uninstalled Pg with the intention of reinstalling it, removed the user ac...

PHP not loading php_pgsql.dll on Windows

PHP 5.2.8 is refusing to load php_pgsql.dll, with the following error: Warning: PHP Startup: Unable to load dynamic library 'D:\PHP\ext\php_pgsql.dll' - The specified module could not be found. in Unknown on line 0 The .dll exists in PHP/ext/. Has anyone else had this problem with PHP on Windows before? ...

How to know a timezone of a timestamp in postgresql 8.3

I'm using postgresql 8.3 and i would like to know the timezone of a particular timestamp (a column in a table). In the documentation i've found the keyword "timezone" But i don't understand how to apply it in a column of table. Is it possible ? ...

PostgreSQL management and monitoring

Moving from Oracle to PostgreSQL, what (preferably free/OSS) software/tools are available that replace Oracle Enterprise Manager? I'm aware of pgAdmin, as well as some tools bundled into EnterpriseDB's Postgres Plus AS, but am looking for more context and a better overview of the PostgreSQL ecosystem. Specifically I'm interested in tool...

Read number of columns and their type from query result table (in C)

I use PostgreSQL database and C to connect to it. With a help from dyntest.pgc I can access to number of columns and their (SQL3) types from a result table of a query. Problem is that when result table is empty, I can't fetch a row to get this data. Does anyone have a solution for this? Query can be SELECT 1,2,3 - so, I think I can't ...

How do you do mysqldump in postgresql?

And how do I restore from my dump back to the db? ...

How do I find all references from other tables to a specific row?

So I have an address table that is shared among various other tables, such as schools, parks, churches, etc. Schools, parks, etc all foreign key to a row in address. What I'm wondering is, if I have a specific row in the address table, is there a way to find out which row in which table points to it. So basically just this: SELECT *...

Does PostgreSQL keep its pl* interpreters loaded persistently?

If I wrote something in plperlu, when would that module be reloaded? Every time the function ran? The first time it ran? Does the Perl DLL get unloaded if it hasn't been used in a while, and then after that it'd be another module reload? ...

Database replication for redundancy using a free database and a Java with Spring & Hibernate web application

Hi, I have this in mind: On each server: (they all are set up identically) A free database like MySQL or PostgreSQL. Tomcat 6.x for hosting Servlet based Java applications Hibernate 3.x as the ORM tool Spring 2.5 for the business layer Wicket 1.3.2 for the presentation layer I place a load balancer in front of the servers and a rep...

Polymorphism in SQL database tables?

I currently have multiple tables in my database which consist of the same 'basic fields' like: name character varying(100), description text, url character varying(255) But I have multiple specializations of that basic table, which is for example that tv_series has the fields season, episode, airing, while the movies table has release_...

Does plperlu reload Perl modules if they change?

If I wrote something in plperlu, and it used a Perl module (e.g. MyModule::Foo), when would that module be reloaded? Does it keep track of them like mod_perl's Apache2::Reload, so that a touch will cause a reinterpretation? ...

Modify postgresql "list" aggregate to remove duplicates

One of my favorite postgres aggregates is "list", attributed to "Chris Rohlfs in the idocs" according to the scanty evidence I can find on the web. CREATE FUNCTION comma_cat (text, text) RETURNS text AS 'SELECT CASE WHEN $2 is null or $2 = '''' THEN $1 WHEN $1 is null or $1 = '''' THEN $2 ELSE $1 || '', '' || $2 END' L...

Why this NpgsqlDataAdapter.Update command always return 1?

I want to make my program robust by putting concurrency check, but somehow UpdateCommand fails me even in the most basic update sql. Using Npgsql 2.0.2 var dax = new NpgsqlDataAdapter(); using (var dtStore = delta.Tables["brand"].GetChanges(DataRowState.Modified)) if (dtStore != null) { dax.UpdateCommand = new NpgsqlCommand( @"upda...

Best way to create a unique number for each many to many relationship

I have a table of Students and a table of Courses that are connected through an intermediate table to create a many-to-many relationship (ie. a student can enroll in multiple courses and a course can have multiple students). The problem is that the client wants a unique student ID per course. For example: rowid Course Student ID (c...

Programatically finding the number of rows affected by a Postgres COPY

I'm using Postgres 8.2 and the associated libpq library for ANSI C. I've skimmed the documentation and not found something that would give me that specific information. In the "COPY" section of the documentation, "Outputs" are described as such: On successful completion, a COPY command returns a command tag of the form COPY count ...

Determine cluster directory from Postgres service

Is it possible to determine the cluster directory being used by a Postgres server, from the server itself -- i.e. the service, (under Windows) was started by something like: C:\foo\postgres.exe -D "D:\emr\data" Is there a SELECT query or function one can make to the running server to retrieve the value "D:\emr\data"? Thanks Vince Marc...

How do you debug functions with postgres?

I'm using pgAdmin III 1.8.4 and finding it a harsh mistress. When writing stored procedures (functions), there's no query compilation. So I have no idea if my function will work until I call it. How do other people work around this deficiency? (Other than getting it right first time :p) ...

Postgres integer arrays as parameters?

I understand that in Postgres pure, you can pass an integer array into a function but that this isn't supported in the .NET data provider Npgsql. I currently have a DbCommand into which I load a call to a stored proc, add in a parameter and execute scalar to get back an Id to populate an object with. This now needs to take n integers ...

Scaling a postgres server to multiple servers

Our postgres server is about hitting its capacity and we're looking into adding a second database server. Are there any scaling solutions that are particularly good for a postgres setup? ...

How can I enforce a constraint only if a column is not null in Postgresql?

I would like a solution to enforce a constraint only if a column is not null. I can't seem to find a way to do this in the documentation. create table mytable( table_identifier_a INTEGER, table_identifier_b INTEGER, table_value1,...) Do to the nature of the data, I will have identifier b and a value when the table is created. Af...