-href="ftp://ftp.postgreSQL.org/pub">ftp://ftp.postgreSQL.org/pub to
-see if there is a more recent PostgreSQL version.
-You can also fill out the "bug-template" file and send it to:
-
-This is the address of the developers mailing list.
-
-
+ Remember, you need to use the internal name when creating indexes on
+ these fields or when doing other internal operations.
+
+ The last four types above are "varlena" types (i.e. the first four
+ bytes is the length, followed by the data). CHAR(#) and VARCHAR(#)
+ allocate the maximum number of bytes no matter how much data is stored
+ in the field. TEXT and BYTEA are the only character types that have
+ variable length on the disk.
+
+ 3.21) In a query, how do I detect if a field is NULL?
+
+ PostgreSQL has two builtin keywords, "isnull" and "notnull" (note no
+ spaces). Version 1.05 and later and 6.* understand IS NULL and IS NOT
+ NULL.
+
+ 3.22) How do I see how the query optimizer is evaluating my query?
+
+ Place the word 'EXPLAIN' at the beginning of the query, for example:
+
+ EXPLAIN SELECT * FROM table1 WHERE age = 23;
+
+ 3.23) How do I create a serial field?
+
+ Postgres does not allow the user to specifiy a user column as type
+ SERIAL. Instead, you can use each row's oid field as a unique value.
+ However, if you need to dump and reload the database, you need to be
+ using postgres version 1.07 or later or 6.* with pgdump's -o option or
+ COPY's WITH OIDS option to preserver the oids.
+
+ Another valid way of doing this is to create a function:
+
+ create table my_oids (f1 int4);
+ insert into my_oids values (1);
+ create function new_oid () returns int4 as
+ 'update my_oids set f1 = f1 + 1; select f1 from my_oids; '
+ language 'sql';
+
+ then:
+
+ create table my_stuff (my_key int4, value text);
+ insert into my_stuff values (new_oid(), 'hello');
+
+ However, keep in mind there is a race condition here where one server
+ could do the update, then another one do an update, and they both
+ could select the same new id. This statement should be performed
+ within a transaction.
+
+ Sequences were implemented in 6.1
+
+ 3.24) How do I create a multi-column index?
+
+ In 6.0, you can not directly create a multi-column index using create
+ index. You need to define a function which acts on the multiple
+ columns, then use create index with that function.
+
+ In 6.1, this feature is available.
+
+ 3.25) What are the temp_XXX files in my database directory?
+
+ They are temp_ files generated by the query executor. For example, if
+ a sort needs to be done to satisfy an ORDER BY, some temp files are
+ generated as a result of the sort.
+
+ If you have no transactions or sorts running at the time, it is safe
+ to delete the temp_ files.
+
+ 3.26) Why are my table files not getting any smaller after a delete?
+
+ If you run vacuum in pre-6.0, unused rows will be marked for reuse,
+ but the file blocks are not released.
+
+ In 6.0, vacuum properly shrinks tables.
+
+ 3.27) Why can't I connect to my database from another machine?
+
+ The default configuration allows only connections from tcp/ip host
+ localhost. You need to add a host entry to the file pgsql/data/pg_hba.
+
+ 3.28) I get the error 'default index class unsupported' when creating an
+ index. How do I do it?
+
+ You probably used:
+
+ create index idx1 on person using btree (name);
+
+ PostgreSQL indexes are extensible, and therefore in pre-6.0, you must
+ specify a class_type when creating an index. Read the manual page for
+ create index (called create_index).
+
+ Version 6.0, if you do not specify a class_type, it defaults to the
+ proper type for the column.
+
+ 3.29) Why does creating an index crash the backend server?
+
+ You have probably defined an incorrect *_ops type class for the field
+ you are indexing.
+
+ 3.30) How do I find out what indexes or operations are defined in the
+ database?
+
+ Run the file pgsql/src/tutorial/syscat.source. It illustrates many of
+ the 'select's needed to get information out of the database system
+ tables.
+
+ 3.31) Why do statements require an extra character at the end? Why does
+ 'createuser' return 'unexpected last match in input()'? Why does pg_dump
+ fail?
+
+ You have compile postgres with flex version 2.5.3. There is bug in
+ this version of flex. Use flex version 2.5.2 or flex 2.5.4 instead.
+ There is a doc/README.flex file which will properly patch the flex
+ 2.5.3 source code.
+
+ 3.32) All my servers crash under concurrent table access. Why?
+
+ This problem can be caused by a kernel that is not configured to
+ support semaphores.
+
+ 3.33) What tools are available for hooking postgres to Web pages?
+
+ For web integration, PHP/FI is an excellent interface. The URL for
+ that is http://www.vex.net/php/
+
+ PHP is great for simple stuff, but for more complex stuff, some still
+ use the perl interface and CGI.pm.
+
+ An example of using WWW with C to talk to Postgres is can be tried at:
+ * http://postgreSQL.org/~mlc
+
+ An WWW gatway based on WDB using perl can be downloaded from:
+ * http://www.eol.ists.ca/~dunlop/wdb -p95
+
+ 3.34) What is the time-warp feature and how does it relate to vacuum?
+
+ PostgreSQL handles data changes differently than most database
+ systems. When a row is changed in a table, the original row is marked
+ with the time it was changed, and a new row is created with the
+ current data. By default, only current rows are used in a table. If
+ you specify a date/time after the table name in a FROM clause, you can
+ access the data that was current at that time, i.e.
+
+
+ SELECT *
+ FROM employees ['July 24, 1996 09:00:00']
+
+ displays employee rows in the table at the specified time. You can
+ specify intervals like [date,date], [date,], [,date], or [,]. This
+ last option accesses all rows that ever existed.
+
+ INSERTed rows get a timestamp too, so rows that were not in the table
+ at the desired time will not appear.
+
+ Vacuum removes rows that are no longer current. This time-warp feature
+ is used by the engine for rollback and crash recovery. Expiration
+ times can be set with purge.
+
+ In 6.0, once a table is vacuumed, the creation time of a row may be
+ incorrect, causing time-traval to fail.
+
+ The time-travel feature will be removed in 7.0.
+
+ 3.35) How do I tune the database engine for better performance?
+
+ There are two things that can be done. You can use Openlink's option
+ to disable fsync() by starting the postmaster with a '-o -F' option.
+ This will prevent fsync()'s from flushing to disk after every
+ transaction.
+
+ You can also use the postmaster -B option to increase the number of
+ shared memory buffers shared among the backend processes. If you make
+ this parameter too high, the process will not start or crash
+ unexpectedly. Each buffer is 8K and the defualt is 64 buffers.
+
+ 3.36) What debugging features are available in PostgreSQL?
+
+ PostgreSQL has several features that report status information that
+ can be valuable for debugging purposes.
+
+ First, by compiling with DEBUG defined, many assert()'s monitor the
+ progress of the backend and halt the program when something unexpected
+ occurs.
+
+ Both postmaster and postgres have several debug options available.
+ First, whenever you start the postmaster, make sure you send the
+ standard output and error to a log file, like:
+
+
+ cd /usr/local/pgsql
+ ./bin/postmaster >server.log 2>&1 &
+
+ This will put a server.log file in the top-level PostgreSQL directory.
+ This file can contain useful information about problems or errors
+ encountered by the server. Postmaster has a -d option that allows even
+ more detailed information to be reported. The -d option takes a number
+ 1-3 that specifies the debug level. The query plans in a verbose debug
+ file can be formatted using the 'indent' program. (You may need to
+ remove the '====' lines in 1.* releases.) Be warned that a debug level
+ greater than one generates large log files in 1.* releases.
+
+ You can actuall run the postgres backend from the command line, and
+ type your SQL statement directly. This is recommended ONLY for
+ debugging purposes. Note that a newline terminates the query, not a
+ semicolon. If you have compiled with debugging symbols, you can
+ perhaps use a debugger to see what is happening. Because the backend
+ was not started from the postmaster, it is not running in an identical
+ environment and locking/backend interaction problems may not be
+ duplicated. Some operating system can attach to a running backend
+ directly to diagnose problems.
+
+ The postgres program has a -s, -A, -t options that can be very usefull
+ for debugging and performance measurements.
+
+ The EXPLAIN command (see this FAQ) allows you to see how PostgreSQL is
+ iterpreting your query.
+
+ 3.37) What is an oid? What is a tid?
+
+ Oids are Postgres's answer to unique row ids or serial columns. Every
+ row that is created in Postgres gets a unique oid. All oids generated
+ by initdb are less than 16384 (from backend/access/transam.h). All
+ post-initdb (user-created) oids are equal or greater that this. All
+ these oids are unique not only within a table, or database, but unique
+ within the entire postgres installation.
+
+ Postgres uses oids in its internal system tables to link rows in
+ separate tables. These oids can be used to identify specific user rows
+ and used in joins. It is recommended you use column type oid to store
+ oid values. See the sql(l) manual page to see the other internal
+ columns.
+
+ Tids are used to indentify specific physical rows with block and
+ offset values. Tids change after rows are modified or reloaded. They
+ are used by index entries to point to physical rows. They can not be
+ accessed through sql.
+
+ 3.38) What is the meaning of some of the terms used in Postgres?
+
+ Some of the source code and older documentation use terms that have
+ more common usage. Here are some:
+ * row, record, tuple
+ * attribute, field, column
+ * table, class
+ * retrieve, select
+ * replace, update
+ * append, insert
+ * oid, serial value
+ * portal, cursor
+ * range variable, table name, table alias
+
+ Please let me know if you think of any more.
+
+ 3.39) What is Genetic Query Optimization?
+
+ The GEQO module in PostgreSQL is intended to solve the query
+ optimization problem of joining many tables by means of a Genetic
+ Algorithm (GA). It allows the handling of large join queries through
+ non-exhaustive search.
+
+ For further information see README.GEQO .
+
+ 3.40) I am running Solaris and my dates display wrong. Why?
+
+ There was a bug in 6.0 that caused this problem under Solaris with -O2
+ optimization. Upgrade to 6.1.1.
+
+ 3.41) How do I enable more than 32 concurrent backends?
+
+ Edit include/storage/sinvaladt.h, and change the value of
+ MaxBackendId. In the future, we plan to make this a configurable
+ prameter.
+
+ _________________________________________________________________
+
+Section 4: Extending PostgreSQL
+
+ 4.1) I wrote a user-defined function and when I run it in psql, it dumps
+ core.
+
+ The problem could be a number of things. Try testing your user-defined
+ function in a stand alone test program first. Also, make sure you are
+ not sending elog NOTICES when the front-end is expecting data, such as
+ during a type_in() or type_out() functions
+
+ 4.2) I get messages of the type NOTICE:PortalHeapMemoryFree: 0x402251d0 not
+ in alloc set!
+
+ You are pfree'ing something that was not palloc'ed. When writing
+ user-defined functions, do not include the file "libpq-fe.h". Doing so
+ will cause your palloc to be a malloc instead of a free. Then, when
+ the backend pfrees the storage, you get the notice message.
+
+ 4.3) I've written some nifty new types and functions for PostgreSQL.
+
+ Please share them with other PostgreSQL users. Send your extensions to
+ mailing list, and they will eventually end up in the contrib/
+ subdirectory.
+
+ 4.4) How do I write a C function to return a tuple?
+
+ This requires extreme wizardry, so extreme that the authors have not
+ ever tried it, though in principle it can be done. The short answer is
+ ... you can't. This capability is forthcoming in the future.
+
+ _________________________________________________________________
+
+Section 5: Bugs
+
+ 5.1) How do I make a bug report?
+
+ Check the current FAQ at http://postgreSQL.org
+
+ Also check out our ftp site ftp://ftp.postgreSQL.org/pub to see if
+ there is a more recent PostgreSQL version.
+
+ You can also fill out the "bug-template" file and send it to:
+
+ This is the address of the developers mailing list.