> Hannu Krosing wrote:
>
>> It seems that my last mail on this did not get through to the list
>> ;(
>>
>> Please consider renaming the new builtin function
>> split(text,text,int)
>>
>> to something else, perhaps
>>
>> split_part(text,text,int)
>>
>> (like date_part)
>>
>> The reason for this request is that 3 most popular scripting
>> languages (perl, python, php) all have also a function with similar
>> signature, but returning an array instead of single element and the
>> (optional) third argument is limit (maximum number of splits to
>> perform)
>>
>> I think that it would be good to have similar function in (some
>> future release of) postgres, but if we now let in a function with
>> same name and arguments but returning a single string instead an
>> array of them, then we will need to invent a new and not so easy to
>> recognise name for the "real" split function.
>>
>
> This is a good point, and I'm not opposed to changing the name, but
> it is too bad your original email didn't get through before beta1 was
> rolled. The change would now require an initdb, which I know we were
> trying to avoid once beta started (although we could change it
> without *requiring* an initdb I suppose).
>
> I guess if we do end up needing an initdb for other reasons, we
> should make this change too. Any other opinions? Is split_part an
> acceptable name?
>
> Also, if we add a todo to produce a "real" split function that
> returns an array, similar to those languages, I'll take it for 7.4.
No one commented on the choice of name, so the attached patch changes
the name of split(text,text,int) to split_part(text,text,int) per
Hannu's recommendation above. This can be applied without an initdb if
current beta testers are advised to run:
update pg_proc set proname = 'split_part' where proname = 'split';
in the case they want to use this function. Regression and doc fix is
also included in the patch.
Joe Conway
creation to world, but disallow temp table creation in template1. Per
latest round of pghackers discussion.
I did not force initdb, but the permissions lockdown on template1 will
not take effect unless you do one (or manually REVOKE TEMP ON DATABASE template1 FROM public).
Gerhard Hintermayer, revised and documented by Tom Lane.
This patch also fixes a 'must fix' bug: libpgtcl's LISTEN/NOTIFY
support was broken by the recent changes to the PGnotify structure.
Guess that change wasn't quite so safe as we thought.
< o -ALTER TABLE ALTER COLUMN SET/DROP NOT NULL (Christopher Kings-Lynne)
< o ALTER TABLE ADD COLUMN column SERIAL doesn't create sequence
> o -ALTER TABLE ALTER COLUMN SET/DROP NOT NULL (Christopher)
200a200,201
> o ALTER TABLE ADD COLUMN column SERIAL doesn't create sequence because
> of the item above
232c233
< o -Disallow missing columns in INSERT ... VALUES, per ANSI
> o -Disallow missing columns in INSERT ... (col) VALUES, per ANSI
335,336d335
< * Have SERIAL generate non-colliding sequence names when we have
< auto-destruction
< * Allow logging of query durations
> * -Allow logging of query durations
51,52d50
< * Make single-user local access permissions the default by limiting
< permissions on the socket file (Peter E)
72,73c70,71
< * Reserve last few process slots for super-user if max_connections reached
< * Add GUC parameter to print queries that generate errors
> * -Reserve last few process slots for super-user if max_connections reached
> * -Add GUC parameter to print queries that generate errors
82,83c80,81
< * Declare typein/out functions in pg_proc with a special "C string" data type
< * Functions returning sets do not totally work
> * -Declare typein/out functions in pg_proc with a special "C string" data type
> * -Functions returning sets do not totally work
90c88
< * Allow bytea to handle LIKE with non-TEXT patterns
> * -Allow bytea to handle LIKE with non-TEXT patterns
94c92
< o Store binary-compatible type information in the system
> o -Store binary-compatible type information in the system
97d94
< o -SELECT col FROM tab WHERE numeric_col = 10.1 fails, requires quotes
102c99
< o Ensure we have array-eq operators for every built-in array type
> o -Ensure we have array-eq operators for every built-in array type
119d115
< * Allow setting database character set without multibyte enabled
152d147
< * Have UPDATE/DELETE clean out indexes
198,199d192
< o ALTER TABLE ADD COLUMN to inherited table put column in wrong place
< [inheritance]
201d193
< o Add ALTER FUNCTION
203,204c195,196
< o -ALTER TABLE ADD PRIMARY KEY (Tom)
< o -ALTER TABLE ADD UNIQUE (Tom)
> o -ALTER TABLE ADD PRIMARY KEY (Christopher)
> o -ALTER TABLE ADD UNIQUE (Christopher)
248c240
< o -Remove SET KSQO option now that OR processing is improved (Tom)
> o -Remove SET KSQO option now that OR processing is improved (Bruce)
280c272
< * Have pg_dump use LEFT OUTER JOIN in multi-table SELECTs
> * -Have pg_dump use LEFT OUTER JOIN in multi-table SELECTs
287d278
< * Add config file check for $ODBCINI, $HOME/.odbc.ini, installpath/etc/odbc.ini
318,322d308
< * ODBC
< o ODBC 3.0 support
< o Unicode(UCS-2) support
< o Updatable cursors support
<
337c323
< * Fix foreign key constraints to not error on intermediate db states (Stephan)
> * -Fix foreign key constraints to not error on intermediate db states (Stephan)
352c338
< * Propagate column or table renaming to foreign key constraints
> * -Propagate column or table renaming to foreign key constraints
447c433
< * Remove wal_files postgresql.conf option because WAL files are now recycled
> * -Remove wal_files postgresql.conf option because WAL files are now recycled
460c446
< * Improve dynamic memory allocation by introducing tuple-context memory
> * -Improve dynamic memory allocation by introducing tuple-context memory
463c449
< * Nested FULL OUTER JOINs don't work (Tom)
> * -Nested FULL OUTER JOINs don't work (Tom)
> * -Add OR REPLACE clauses to non-FUNCTION object creation
> * -Allow autocommit so always in a transaction block
> * -Cache most recent query plan(s) (Neil) [prepare]
not synonymous with CHECK (xxx IS NOT NULL) -- for example, consider
ALTER TABLE ADD PRIMARY KEY, which checks for 'NOT NULL', not a check
constraint.
Neil Conway
already fixed by You. However there were a few left and attached patch
should fix the rest of them.
I used StringInfo only in 2 places and both of them are inside debug
ifdefs. Only performance penalty will come from using strlen() like all
the other code does.
I also modified some of the already patched parts by changing
snprintf(buf, 2 * BUFSIZE, ... style lines to
snprintf(buf, sizeof(buf), ... where buf is an array.
Jukka Holappa
(overlaying low byte of page size) and add HEAP_HASOID bit to t_infomask,
per earlier discussion. Simplify scheme for overlaying fields in tuple
header (no need for cmax to live in more than one place). Don't try to
clear infomask status bits in tqual.c --- not safe to do it there. Don't
try to force output table of a SELECT INTO to have OIDs, either. Get rid
of unnecessarily complex three-state scheme for TupleDesc.tdhasoids, which
has already caused one recent failure. Improve documentation.
available (else there's no way to interpret the list links). Change
pg_locks view to show transaction ID locks separately from ordinary
relation locks. Avoid showing N duplicate rows when the same lock is
held multiple times (seems unlikely that users care about exact hold
count). Improve documentation.
to false provides more SQL-spec-compliant behavior than we had before.
I am not sure that setting it false is actually a good idea yet; there
is a lot of client-side code that will probably be broken by turning
autocommit off. But it's a start.
Loosely based on a patch by David Van Wie.
column additions, deletions, and renames that would let a child table
get out of sync with its parent. Patch by Alvaro Herrera, with some
kibitzing by Tom Lane.
to the table function, thus preventing memory leakage accumulation across
calls. This means that SRFs need to be careful to distinguish permanent
and local storage; adjust code and documentation accordingly. Patch by
Joe Conway, very minor tweaks by Tom Lane.
bit on the indexes.
I also attach clusterdb and clusterdb.sgml; both of them are blatant
rips of vacuumdb and vacuumdb.sgml, but get the job done. Please review
them, as I'm probably making a lot of mistakes with SGML and I can't
compile it here.
vacuumdb itself is not very comfortable to use when the databases have
passwords, because it has to connect once for each table (I can probably
make it connect only once for each database; should I?). Because of
this I added a mention of PGPASSWORDFILE in the documentation, but I
don't know if that is the correct place for that.
Alvaro Herrera
value '-2' is used to indicate a variable-width type whose width is
computed as strlen(datum)+1. Everything that looks at typlen is updated
except for array support, which Joe Conway is working on; at the moment
it wouldn't work to try to create an array of cstring.
>>" It's also possible to select no escape character by writing ESCAPE ''.
>>In this case there is no way to turn off the special meaning of
>>underscore and percent signs in the pattern."
Joe Conway
with OPAQUE, as per recent pghackers discussion. I still want to do some
more work on the 'cstring' pseudo-type, but I'm going to commit the bulk
of the changes now before the tree starts shifting under me ...
FOUND is set whenever a SELECT INTO returns > 0 rows, *or* when an
INSERT, UPDATE, or DELETE affects > 0 rows. We implemented the first
part of this behavior, but not the second.
I also improved the documentation on the various situations in which
FOUND can be set (excluding inside FOR loops, which I still need to
think about), and added some regression tests for this behavior.
Neil Conway
> Quick system function to pull out the current database.
>
> I've used this a number of times to allow stored procedures to find out
> where they are. Especially useful for those that do logging or hit a
> remote server.
>
> It's called current_database() to match with current_user().
It's also a necessity for an informational schema. The catalog
(database) name is required in a number of places.
Rod Taylor
The -n and -N options were removed. Quoting is now smart enough to
supply quotes if and only if necessary.
Numerical types are now printed without quotes, except in cases of
special values such as NaN.
Boolean values printed as true and false.
Most string literals now do not escape whitespace characters (newlines,
etc.) for portability.
SET SESSION AUTHORIZATION argument is a string literal, to follow SQL.
Made commands output by pg_dump use consistent spacing and indentation.
This patch is an updated version of the lock listing patch. I've made
the following changes:
- write documentation
- wrap the SRF in a view called 'pg_locks': all user-level
access should be done through this view
- re-diff against latest CVS
One thing I chose not to do is adapt the SRF to use the anonymous
composite type code from Joe Conway. I'll probably do that eventually,
but I'm not really convinced it's a significantly cleaner way to
bootstrap SRF builtins than the method this patch uses (of course, it
has other uses...)
Neil Conway
sets of triggers. Also modify psql \d command to show foreign key
constraints as such and hide the triggers. pg_get_constraintdef()
function added to backend to support these. From Rod Taylor, code
review and some editorialization by Tom Lane.
<
> * Prevent mismatch of frontend/backend encodings from converting bytea
> data from being interpreted as encoded strings
512a514,515
> * Fix glibc's mktime() to handle pre-1970's dates
>
> * -Improve control over user privileges, including table creation
> * -Add PGPASSWORDFILE environment variable or ~/.pgpass to store
> o -Compile under jdk 1.4
> There's no longer a separate call to heap_storage_create in that routine
> --- the right place to make the test is now in the storage_create
> boolean parameter being passed to heap_create. A simple change, but
> it passeth patch's understanding ...
Thanks.
Attached is a patch against cvs tip as of 8:30 PM PST or so. Turned out
that even after fixing the failed hunks, there was a new spot in
bufmgr.c which needed to be fixed (related to temp relations;
RelationUpdateNumberOfBlocks). But thankfully the regression test code
caught it :-)
Joe Conway
Chapter 1. libpq - C Library
1.3. Command Execution Functions
1.3.3. Escaping binary strings for inclusion in SQL queries
I found the line
"The result string length does not include the terminating zero byte of the result."
is not right.
The result string length does indeed include the terminating zero byte.
Christoph Haller
> > This patch improves the documentation of the UPDATE and ALTER TABLE
> > commands to elaborate on the effect of specifying an "ONLY" clause.
>
> Unfortunately this is still only half the truth ... see the
> SQL_INHERITANCE configuration variable.
Okay, I've attached an updated patch with more information on
SQL_INHERITANCE and inheritance behavior in prior releases.
Neil Conway
PGPASSWORDFILE environment variable. I have modified libpq to make use
of this variable. I present the first cut here.
Currently the format for the file should be
host:port:database:user:password
Alvaro Herrera
sys = malloc(strlen(editorName) + strlen(fname) + 10 + 1);
if (!sys)
return false;
sprintf(sys, "exec '%s' '%s'", editorName, fname);
(note the added quotes to provide a little protection against spaces
and such). Then it's perfectly obvious what the calculation is doing.
I don't care about wasting 20-some bytes, but confusing readers of the
code is worth avoiding.
regards, tom lane
< * Allow temporary views
< * Require view using temporary tables to be temporary views
> * -Have views on temporary tables exist in the temporary namespace
<
> o Improve PL/PgSQL exception handling
> o Allow PL/PgSQL parameters to be specified by name and type during
> definition
> o Allow PL/PgSQL function parameters to be passed by name,
> get_employee_salary(emp_id => 12345, tax_year => 2001)
> o Add PL/PgSQL packages
> o Allow array declarations and other data types in PL/PgSQl DECLARE
> o Add PL/PgSQL PROCEDURES that can return multiple values
to make a reasonable attempt at accounting for palloc overhead, not just
the requested size of each memory chunk. Since in many scenarios this
will make for a significant reduction in the amount of space acquired,
partially compensate by doubling the default value of SORT_MEM to 1Mb.
Per discussion in pgsql-general around 9-Jun-2002..
relfilenode.
I sent the CLUSTER patch a few days ago and I think it was missed. I
append it again, this time including the regression test files. For the
committer, please note that you have to cvs add the files as they don't
exist. Maybe add to the parallel and serial schedules also, but I don't
know such stuff.
Alvaro Herrera (<alvherre[a]atentus.com>)
has_language_privilege, has_schema_privilege to let SQL queries test
all the new privilege types in 7.3. Also, add functions pg_table_is_visible,
pg_type_is_visible, pg_function_is_visible, pg_operator_is_visible,
pg_opclass_is_visible to test whether objects contained in schemas are
visible in the current search path. Do some minor cleanup to centralize
accesses to pg_database, as well.
Still needs to be filled with more information, but it gives us a
framework to have a User's Guide with complete coverage of the basic
SQL operations. Move arrays into data type chapter, inheritance into
DDL chapter (for now).
Make <comment>s show up in the output while the version number ends in
"devel".
Allow cross-book references with entities &cite-user; etc.
of functions returning domain types, update documentation for typtype,
move get_typtype to lsyscache.c (actually, resurrect the old version),
add defense against creating pseudo-typed table columns, fix some
bogus list-parsing in grammar. Issues remain with respect to alias
handling and type checking; Joe is on those.
types for Table Functions, as previously proposed on HACKERS. Here is a
brief explanation:
1. Creates a new pg_type typtype: 'p' for pseudo type (currently either
'b' for base or 'c' for catalog, i.e. a class).
2. Creates new builtin type of typtype='p' named RECORD. This is the
first of potentially several pseudo types.
3. Modify FROM clause grammer to accept:
SELECT * FROM my_func() AS m(colname1 type1, colname2 type1, ...)
where m is the table alias, colname1, etc are the column names, and
type1, etc are the column types.
4. When typtype == 'p' and the function return type is RECORD, a list
of column defs is required, and when typtype != 'p', it is
disallowed.
5. A check was added to ensure that the tupdesc provide via the parser
and the actual return tupdesc match in number and type of
attributes.
When creating a function you can do:
CREATE FUNCTION foo(text) RETURNS setof RECORD ...
When using it you can do:
SELECT * from foo(sqlstmt) AS (f1 int, f2 text, f3 timestamp)
or
SELECT * from foo(sqlstmt) AS f(f1 int, f2 text, f3 timestamp)
or
SELECT * from foo(sqlstmt) f(f1 int, f2 text, f3 timestamp)
Included in the patches are adjustments to the regression test sql and
expected files, and documentation.
p.s.
This potentially solves (or at least improves) the issue of builtin
Table Functions. They can be bootstrapped as returning RECORD, and
we can wrap system views around them with properly specified column
defs. For example:
CREATE VIEW pg_settings AS
SELECT s.name, s.setting
FROM show_all_settings()AS s(name text, setting text);
Then we can also add the UPDATE RULE that I previously posted to
pg_settings, and have pg_settings act like a virtual table, allowing
settings to be queried and set.
Joe Conway
functionality of the command is basically identical to that of
BEGIN; it just accepts a few extra options (only one of which
PostgreSQL currently implements), and is standards-compliant.
The patch includes a simple regression test and documentation.
[ Regression tests removed, per Peter.]
Neil Conway
code review by Tom Lane. Remaining issues: functions that take or
return tuple types are likely to break if one drops (or adds!)
a column in the table defining the type. Need to think about what
to do here.
Along the way: some code review for recent COPY changes; mark system
columns attnotnull = true where appropriate, per discussion a month ago.
attstattarget to indicate 'use the default'. The default is now a GUC
variable default_statistics_target, and so may be changed on the fly. Along
the way we gain the ability to have pg_dump dump the per-column statistics
target when it's not the default. Patch by Neil Conway, with some kibitzing
from Tom Lane.
All of the internal tags are of the latter.
The other thing I noticed is that most of the quick examples in the file
use a para and synopsis. Is there a reason we're not using <example/> ?
Rod Taylor
The attached patch completes the following TODO item:
* Generate failure on short COPY lines rather than pad NULLs
I also restructed a lot of the existing COPY code, did some code
review on the column list patch sent in by Brent Verner a little
while ago, and added some regression tests. I also added an
explicit check (and resultant error) for extra data before
the end-of-line.
Neil Conway
changes mentioned above, and also adds a new function to the tablefunc
API. The tablefunc API change adds the following function:
* Oid foidGetTypeId(Oid foid) - Get a function's typeid given the
* function Oid. Use this together with TypeGetTupleDesc() to get a
* TupleDesc which is derived from the function's declared return type.
In the next post I'll send the contrib/tablefunc patch, which
illustrates the usage of this new function. Also attached is a doc patch
for this change. The doc patch also adds a function that I failed to
document previously.
Joe Conway
documentation (xindex.sgml should be rewritten), need to teach pg_dump
about it, need to update contrib modules that currently build pg_opclass
entries by hand. Original patch by Bill Studenmund, grammar adjustments
and general update for 7.3 by Tom Lane.
pg_language.lancompiler
pg_operator.oprprec
pg_operator.oprisleft
pg_proc.proimplicit
pg_proc.probyte_pct
pg_proc.properbyte_cpu
pg_proc.propercall_cpu
pg_proc.prooutin_ratio
pg_shadow.usetrace
pg_type.typprtlen
pg_type.typreceive
pg_type.typsend
Attempts to use the obsoleted attributes of pg_operator or pg_proc
in the CREATE commands will be greeted by a warning. For pg_type,
there is no warning (yet) because pg_dump scripts still contain these
attributes.
Also remove new but already obsolete spellings
isVolatile, isStable, isImmutable in WITH clause. (Use new syntax
instead.)
> * -Add GUC parameter for DATESTYLE
> o -Allow specification of column names
> o -Change syntax to WITH DELIMITER, (keep old syntax around?)
> o -Remove SET KSQO option now that OR processing is improved (Tom)
> o -Allow SHOW to output as a query result, like EXPLAIN
> * -Add SQL92 schemas (Tom)
extension to create binary compatible casts. Includes dependency tracking
as well.
pg_proc.proimplicit is now defunct, but will be removed in a separate
commit.
pg_dump provides a migration path from the previous scheme to declare
casts. Dumping binary compatible casts is currently impossible, though.
reflects the changes in the tablefunc-fix patch that I sent in the other
day. It also refers to "see contrib/tablefunc for more examples", which
is next on my list of things to finish and submit.
Joe Conway
COPY x (a,d,c,b) from stdin;
COPY x (a,c) to stdout;
as well as the corresponding changes to pg_dump to use the new
functionality. This functionality is not available when using
the BINARY option. If a column is not specified in the COPY FROM
statement, its default values will be used.
In addition to this functionality, I tweaked a couple of the
error messages emitted by the new COPY <options> checks.
Brent Verner
> > David Clark (dclarknospam@opsi.co.za) reports a bug with a severity
> > Table 3-7 SQL Literal escaped octets shows the input escape
> > representation for a single quote as '\\'' , but the third paragraph
> > below table 3-8 SQL Output Escaped Octets says that the single quote
> > must be input as '\''
>
> Nice catch. '\'' is correct as shown in the example in Table 3-7.
>
> >
> > Also in the same paragraph mentioned above it says input for the
> > single quote must be '\'' (or '\\134') shouldn't this be (or '\\047')
>
> Also a bug. Should be '\\047', as you pointed out.
>
Here's a patch to fix the binary string doc errors.
Joe Conway
UNIQUE and DISTINCT predicates are both listed as implemented -- AFAIK,
neither is.
I also included another trivial patch which adds the default location
of the DSSSL stylesheets on my system (Debian unstable, docbook-dsssl
1.76) to the list of paths that configure looks for.
Neil Conway
> o -Add ALTER TABLE DROP non-CHECK CONSTRAINT
> * -Allow psql \d to show foreign keys
> * -Auto-destroy sequence on DROP of table with SERIAL; perhaps a separate
> * -Prevent column dropping if column is used by foreign key
> * -Automatically drop constraints/functions when object is dropped
> * -Make foreign key constraints clearer in dump file
> * -Make foreign keys easier to identify
pg_relcheck is gone; CHECK, UNIQUE, PRIMARY KEY, and FOREIGN KEY
constraints all have real live entries in pg_constraint. pg_depend
exists, and RESTRICT/CASCADE options work on most kinds of DROP;
however, pg_depend is not yet very well populated with dependencies.
(Most of the ones that are present at this point just replace formerly
hardwired associations, such as the implicit drop of a relation's pg_type
entry when the relation is dropped.) Need to add more logic to create
dependency entries, improve pg_dump to dump constraints in place of
indexes and triggers, and add some regression tests.