Saturday, July 19, 2008

Re: [GENERAL] Writing a user defined function

I get this error

ERROR: syntax error at or near "cursor"
CONTEXT: invalid type name "scroll cursor for select * from tpcd.customer"
compile of PL/pgSQL function "udf" near line 5


Douglas McNaught wrote:
>
> On Fri, Jul 18, 2008 at 12:07 PM, Suresh_ <suiyengar@yahoo.com> wrote:
>>
>> Hello,
>> I am trying to code a simple udf in postgres. How do I write sql
>> commands
>> into pl/sql ? The foll. code doesnt work.
>>
>> CREATE OR REPLACE FUNCTION udf()
>> RETURNS integer AS $$
>> BEGIN
>> for i in 1..2000 loop
>> for j in 1...10000 loop
>> end loop;
>> begin work;
>
> Postgres doesn't let you do transactions inside a function.
>
> Take out the BEGIN and COMMIT, and if you still get errors post the
> function code and the error message that you get.
>
> -Doug
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>
>

--
View this message in context: http://www.nabble.com/Writing-a-user-defined-function-tp18532591p18551845.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: [PATCHES] pg_dump additional options for performance

Index: doc/src/sgml/ref/pg_dump.sgml
===================================================================
RCS file: /home/sriggs/pg/REPOSITORY/pgsql/doc/src/sgml/ref/pg_dump.sgml,v
retrieving revision 1.102
diff -c -r1.102 pg_dump.sgml
*** doc/src/sgml/ref/pg_dump.sgml 13 Apr 2008 03:49:21 -0000 1.102
--- doc/src/sgml/ref/pg_dump.sgml 20 Jul 2008 06:33:30 -0000
***************
*** 133,139 ****
<para>
Include large objects in the dump. This is the default behavior
except when <option>--schema</>, <option>--table</>, or
! <option>--schema-only</> is specified, so the <option>-b</>
switch is only useful to add large objects to selective dumps.
</para>
</listitem>
--- 133,140 ----
<para>
Include large objects in the dump. This is the default behavior
except when <option>--schema</>, <option>--table</>, or
! <option>--schema-only</> or <option>--schema-pre-load</> or
! <option>--schema-post-load</> is specified, so the <option>-b</>
switch is only useful to add large objects to selective dumps.
</para>
</listitem>
***************
*** 443,448 ****
--- 444,471 ----
</varlistentry>

<varlistentry>
+ <term><option>--schema-pre-load</option></term>
+ <listitem>
+ <para>
+ Dump only the object definitions (schema) required to load data. Dumps
+ exactly what <option>--schema-only</> would dump, but only those
+ statements before the data load.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--schema-post-load</option></term>
+ <listitem>
+ <para>
+ Dump only the object definitions (schema) required after data has been
+ loaded. Dumps exactly what <option>--schema-only</> would dump, but
+ only those statements after the data load.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><option>-S <replaceable class="parameter">username</replaceable></option></term>
<term><option>--superuser=<replaceable class="parameter">username</replaceable></option></term>
<listitem>
***************
*** 774,779 ****
--- 797,830 ----
</para>

<para>
+ The output of pg_dump can be notionally divided into three parts:
+ <itemizedlist>
+ <listitem>
+ <para>
+ Pre-Schema - objects required before data loading, such as
+ <command>CREATE TABLE</command>.
+ This part can be requested using <option>--schema-pre-load</>.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Table Data - data can be requested using <option>--data-only</>.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Post-Schema - objects required after data loading, such as
+ <command>ALTER TABLE</command> and <command>CREATE INDEX</command>.
+ This part can be requested using <option>--schema-post-load</>.
+ </para>
+ </listitem>
+ </itemizedlist>
+ This allows us to work more easily with large data dump files when
+ there is some need to edit commands or resequence their execution for
+ performance.
+ </para>
+
+ <para>
Because <application>pg_dump</application> is used to transfer data
to newer versions of <productname>PostgreSQL</>, the output of
<application>pg_dump</application> can be loaded into
Index: doc/src/sgml/ref/pg_restore.sgml
===================================================================
RCS file: /home/sriggs/pg/REPOSITORY/pgsql/doc/src/sgml/ref/pg_restore.sgml,v
retrieving revision 1.75
diff -c -r1.75 pg_restore.sgml
*** doc/src/sgml/ref/pg_restore.sgml 13 Apr 2008 03:49:21 -0000 1.75
--- doc/src/sgml/ref/pg_restore.sgml 20 Jul 2008 06:33:18 -0000
***************
*** 321,326 ****
--- 321,350 ----
</varlistentry>

<varlistentry>
+ <term><option>--schema-post-load</option></term>
+ <listitem>
+ <para>
+ Dump only the object definitions (schema) required after data has been
+ loaded. Dumps exactly what <option>--schema-only</> would dump, but
+ only those statements after the data load.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>-S <replaceable class="parameter">username</replaceable></option></term>
+ <term><option>--superuser=<replaceable class="parameter">username</replaceable></option></term>
+ <listitem>
+ <para>
+ Specify the superuser user name to use when disabling triggers.
+ This is only relevant if <option>--disable-triggers</> is used.
+ (Usually, it's better to leave this out, and instead start the
+ resulting script as superuser.)
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><option>-S <replaceable class="parameter">username</replaceable></option></term>
<term><option>--superuser=<replaceable class="parameter">username</replaceable></option></term>
<listitem>
***************
*** 572,577 ****
--- 596,629 ----
</para>

<para>
+ The actions of pg_restore can be notionally divided into three parts:
+ <itemizedlist>
+ <listitem>
+ <para>
+ Pre-Schema - objects required before data loading, such as
+ <command>CREATE TABLE</command>.
+ This part can be requested using <option>--schema-pre-load</>.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Table Data - data can be requested using <option>--data-only</>.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Post-Schema - objects required after data loading, such as
+ <command>ALTER TABLE</command> and <command>CREATE INDEX</command>.
+ This part can be requested using <option>--schema-post-load</>.
+ </para>
+ </listitem>
+ </itemizedlist>
+ This allows us to work more easily with large data dump files when
+ there is some need to edit commands or resequence their execution for
+ performance.
+ </para>
+
+ <para>
The limitations of <application>pg_restore</application> are detailed below.

<itemizedlist>
Index: src/bin/pg_dump/pg_backup.h
===================================================================
RCS file: /home/sriggs/pg/REPOSITORY/pgsql/src/bin/pg_dump/pg_backup.h,v
retrieving revision 1.47
diff -c -r1.47 pg_backup.h
*** src/bin/pg_dump/pg_backup.h 13 Apr 2008 03:49:21 -0000 1.47
--- src/bin/pg_dump/pg_backup.h 20 Jul 2008 05:19:34 -0000
***************
*** 89,95 ****
int use_setsessauth;/* Use SET SESSION AUTHORIZATION commands
* instead of OWNER TO */
char *superuser; /* Username to use as superuser */
! int dataOnly;
int dropSchema;
char *filename;
int schemaOnly;
--- 89,95 ----
int use_setsessauth;/* Use SET SESSION AUTHORIZATION commands
* instead of OWNER TO */
char *superuser; /* Username to use as superuser */
! int dumpObjFlags; /* which objects types to dump */
int dropSchema;
char *filename;
int schemaOnly;
Index: src/bin/pg_dump/pg_backup_archiver.c
===================================================================
RCS file: /home/sriggs/pg/REPOSITORY/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v
retrieving revision 1.157
diff -c -r1.157 pg_backup_archiver.c
*** src/bin/pg_dump/pg_backup_archiver.c 4 May 2008 08:32:21 -0000 1.157
--- src/bin/pg_dump/pg_backup_archiver.c 20 Jul 2008 05:19:34 -0000
***************
*** 56,62 ****
static void _selectTablespace(ArchiveHandle *AH, const char *tablespace);
static void processEncodingEntry(ArchiveHandle *AH, TocEntry *te);
static void processStdStringsEntry(ArchiveHandle *AH, TocEntry *te);
! static teReqs _tocEntryRequired(TocEntry *te, RestoreOptions *ropt, bool include_acls);
static void _disableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static void _enableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static TocEntry *getTocEntryByDumpId(ArchiveHandle *AH, DumpId id);
--- 56,62 ----
static void _selectTablespace(ArchiveHandle *AH, const char *tablespace);
static void processEncodingEntry(ArchiveHandle *AH, TocEntry *te);
static void processStdStringsEntry(ArchiveHandle *AH, TocEntry *te);
! static int _tocEntryRequired(TocEntry *te, RestoreOptions *ropt, bool include_acls);
static void _disableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static void _enableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static TocEntry *getTocEntryByDumpId(ArchiveHandle *AH, DumpId id);
***************
*** 129,135 ****
{
ArchiveHandle *AH = (ArchiveHandle *) AHX;
TocEntry *te;
! teReqs reqs;
OutputContext sav;
bool defnDumped;

--- 129,135 ----
{
ArchiveHandle *AH = (ArchiveHandle *) AHX;
TocEntry *te;
! int reqs;
OutputContext sav;
bool defnDumped;

***************
*** 175,193 ****
* Work out if we have an implied data-only restore. This can happen if
* the dump was data only or if the user has used a toc list to exclude
* all of the schema data. All we do is look for schema entries - if none
! * are found then we set the dataOnly flag.
*
! * We could scan for wanted TABLE entries, but that is not the same as
! * dataOnly. At this stage, it seems unnecessary (6-Mar-2001).
*/
! if (!ropt->dataOnly)
{
int impliedDataOnly = 1;

for (te = AH->toc->next; te != AH->toc; te = te->next)
{
reqs = _tocEntryRequired(te, ropt, true);
! if ((reqs & REQ_SCHEMA) != 0)
{ /* It's schema, and it's wanted */
impliedDataOnly = 0;
break;
--- 175,193 ----
* Work out if we have an implied data-only restore. This can happen if
* the dump was data only or if the user has used a toc list to exclude
* all of the schema data. All we do is look for schema entries - if none
! * are found then say we only want DATA type objects.
*
! * We could scan for wanted TABLE entries, but that is not the same.
! * At this stage, it seems unnecessary (6-Mar-2001).
*/
! if (!WANT_DATA(ropt->dumpObjFlags))
{
int impliedDataOnly = 1;

for (te = AH->toc->next; te != AH->toc; te = te->next)
{
reqs = _tocEntryRequired(te, ropt, true);
! if (WANT_PRE_SCHEMA(reqs) || WANT_POST_SCHEMA(reqs))
{ /* It's schema, and it's wanted */
impliedDataOnly = 0;
break;
***************
*** 195,201 ****
}
if (impliedDataOnly)
{
! ropt->dataOnly = impliedDataOnly;
ahlog(AH, 1, "implied data-only restore\n");
}
}
--- 195,201 ----
}
if (impliedDataOnly)
{
! ropt->dumpObjFlags = REQ_DATA;
ahlog(AH, 1, "implied data-only restore\n");
}
}
***************
*** 236,242 ****
AH->currentTE = te;

reqs = _tocEntryRequired(te, ropt, false /* needn't drop ACLs */ );
! if (((reqs & REQ_SCHEMA) != 0) && te->dropStmt)
{
/* We want the schema */
ahlog(AH, 1, "dropping %s %s\n", te->desc, te->tag);
--- 236,242 ----
AH->currentTE = te;

reqs = _tocEntryRequired(te, ropt, false /* needn't drop ACLs */ );
! if (((reqs & REQ_PRE_SCHEMA) != 0) && te->dropStmt)
{
/* We want the schema */
ahlog(AH, 1, "dropping %s %s\n", te->desc, te->tag);
***************
*** 278,284 ****
/* Dump any relevant dump warnings to stderr */
if (!ropt->suppressDumpWarnings && strcmp(te->desc, "WARNING") == 0)
{
! if (!ropt->dataOnly && te->defn != NULL && strlen(te->defn) != 0)
write_msg(modulename, "warning from original dump file: %s\n", te->defn);
else if (te->copyStmt != NULL && strlen(te->copyStmt) != 0)
write_msg(modulename, "warning from original dump file: %s\n", te->copyStmt);
--- 278,284 ----
/* Dump any relevant dump warnings to stderr */
if (!ropt->suppressDumpWarnings && strcmp(te->desc, "WARNING") == 0)
{
! if (!WANT_DATA(ropt->dumpObjFlags) && te->defn != NULL && strlen(te->defn) != 0)
write_msg(modulename, "warning from original dump file: %s\n", te->defn);
else if (te->copyStmt != NULL && strlen(te->copyStmt) != 0)
write_msg(modulename, "warning from original dump file: %s\n", te->copyStmt);
***************
*** 286,292 ****

defnDumped = false;

! if ((reqs & REQ_SCHEMA) != 0) /* We want the schema */
{
ahlog(AH, 1, "creating %s %s\n", te->desc, te->tag);

--- 286,293 ----

defnDumped = false;

! if ((WANT_PRE_SCHEMA(reqs) && WANT_PRE_SCHEMA(ropt->dumpObjFlags)) ||
! (WANT_POST_SCHEMA(reqs) && WANT_POST_SCHEMA(ropt->dumpObjFlags))) /* We want the schema */
{
ahlog(AH, 1, "creating %s %s\n", te->desc, te->tag);

***************
*** 331,337 ****
/*
* If we have a data component, then process it
*/
! if ((reqs & REQ_DATA) != 0)
{
/*
* hadDumper will be set if there is genuine data component for
--- 332,338 ----
/*
* If we have a data component, then process it
*/
! if (WANT_DATA(reqs))
{
/*
* hadDumper will be set if there is genuine data component for
***************
*** 343,349 ****
/*
* If we can output the data, then restore it.
*/
! if (AH->PrintTocDataPtr !=NULL && (reqs & REQ_DATA) != 0)
{
#ifndef HAVE_LIBZ
if (AH->compression != 0)
--- 344,350 ----
/*
* If we can output the data, then restore it.
*/
! if (AH->PrintTocDataPtr !=NULL && WANT_DATA(reqs))
{
#ifndef HAVE_LIBZ
if (AH->compression != 0)
***************
*** 415,421 ****
/* Work out what, if anything, we want from this entry */
reqs = _tocEntryRequired(te, ropt, true);

! if ((reqs & REQ_SCHEMA) != 0) /* We want the schema */
{
ahlog(AH, 1, "setting owner and privileges for %s %s\n",
te->desc, te->tag);
--- 416,422 ----
/* Work out what, if anything, we want from this entry */
reqs = _tocEntryRequired(te, ropt, true);

! if (WANT_PRE_SCHEMA(reqs)) /* We want the schema */
{
ahlog(AH, 1, "setting owner and privileges for %s %s\n",
te->desc, te->tag);
***************
*** 473,479 ****
_disableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
{
/* This hack is only needed in a data-only restore */
! if (!ropt->dataOnly || !ropt->disable_triggers)
return;

ahlog(AH, 1, "disabling triggers for %s\n", te->tag);
--- 474,480 ----
_disableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
{
/* This hack is only needed in a data-only restore */
! if (!WANT_DATA(ropt->dumpObjFlags) || !ropt->disable_triggers)
return;

ahlog(AH, 1, "disabling triggers for %s\n", te->tag);
***************
*** 499,505 ****
_enableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
{
/* This hack is only needed in a data-only restore */
! if (!ropt->dataOnly || !ropt->disable_triggers)
return;

ahlog(AH, 1, "enabling triggers for %s\n", te->tag);
--- 500,506 ----
_enableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
{
/* This hack is only needed in a data-only restore */
! if (!WANT_DATA(ropt->dumpObjFlags) || !ropt->disable_triggers)
return;

ahlog(AH, 1, "enabling triggers for %s\n", te->tag);
***************
*** 1321,1327 ****
return NULL;
}

! teReqs
TocIDRequired(ArchiveHandle *AH, DumpId id, RestoreOptions *ropt)
{
TocEntry *te = getTocEntryByDumpId(AH, id);
--- 1322,1328 ----
return NULL;
}

! int
TocIDRequired(ArchiveHandle *AH, DumpId id, RestoreOptions *ropt)
{
TocEntry *te = getTocEntryByDumpId(AH, id);
***************
*** 2026,2035 ****
te->defn);
}

! static teReqs
_tocEntryRequired(TocEntry *te, RestoreOptions *ropt, bool include_acls)
{
! teReqs res = REQ_ALL;

/* ENCODING and STDSTRINGS items are dumped specially, so always reject */
if (strcmp(te->desc, "ENCODING") == 0 ||
--- 2027,2036 ----
te->defn);
}

! static int
_tocEntryRequired(TocEntry *te, RestoreOptions *ropt, bool include_acls)
{
! int res = ropt->dumpObjFlags;

/* ENCODING and STDSTRINGS items are dumped specially, so always reject */
if (strcmp(te->desc, "ENCODING") == 0 ||
***************
*** 2109,2125 ****
if ((strcmp(te->desc, "<Init>") == 0) && (strcmp(te->tag, "Max OID") == 0))
return 0;

- /* Mask it if we only want schema */
- if (ropt->schemaOnly)
- res = res & REQ_SCHEMA;
-
- /* Mask it we only want data */
- if (ropt->dataOnly)
- res = res & REQ_DATA;
-
/* Mask it if we don't have a schema contribution */
if (!te->defn || strlen(te->defn) == 0)
! res = res & ~REQ_SCHEMA;

/* Finally, if there's a per-ID filter, limit based on that as well */
if (ropt->idWanted && !ropt->idWanted[te->dumpId - 1])
--- 2110,2118 ----
if ((strcmp(te->desc, "<Init>") == 0) && (strcmp(te->tag, "Max OID") == 0))
return 0;

/* Mask it if we don't have a schema contribution */
if (!te->defn || strlen(te->defn) == 0)
! res = res & ~(REQ_PRE_SCHEMA | REQ_POST_SCHEMA);

/* Finally, if there's a per-ID filter, limit based on that as well */
if (ropt->idWanted && !ropt->idWanted[te->dumpId - 1])
Index: src/bin/pg_dump/pg_backup_archiver.h
===================================================================
RCS file: /home/sriggs/pg/REPOSITORY/pgsql/src/bin/pg_dump/pg_backup_archiver.h,v
retrieving revision 1.76
diff -c -r1.76 pg_backup_archiver.h
*** src/bin/pg_dump/pg_backup_archiver.h 7 Nov 2007 12:24:24 -0000 1.76
--- src/bin/pg_dump/pg_backup_archiver.h 20 Jul 2008 05:19:34 -0000
***************
*** 158,169 ****
STAGE_FINALIZING
} ArchiverStage;

! typedef enum
! {
! REQ_SCHEMA = 1,
! REQ_DATA = 2,
! REQ_ALL = REQ_SCHEMA + REQ_DATA
! } teReqs;

typedef struct _archiveHandle
{
--- 158,173 ----
STAGE_FINALIZING
} ArchiverStage;

! #define REQ_PRE_SCHEMA (1 << 0)
! #define REQ_DATA (1 << 1)
! #define REQ_POST_SCHEMA (1 << 2)
! #define REQ_ALL (REQ_PRE_SCHEMA + REQ_DATA + REQ_POST_SCHEMA)
!
! #define WANT_PRE_SCHEMA(req) ((req & REQ_PRE_SCHEMA) == REQ_PRE_SCHEMA)
! #define WANT_DATA(req) ((req & REQ_DATA) == REQ_DATA)
! #define WANT_POST_SCHEMA(req) ((req & REQ_POST_SCHEMA) == REQ_POST_SCHEMA)
! #define WANT_ALL(req) ((req & REQ_ALL) == REQ_ALL)
!

typedef struct _archiveHandle
{
***************
*** 317,323 ****
extern void ReadToc(ArchiveHandle *AH);
extern void WriteDataChunks(ArchiveHandle *AH);

! extern teReqs TocIDRequired(ArchiveHandle *AH, DumpId id, RestoreOptions *ropt);
extern bool checkSeek(FILE *fp);

#define appendStringLiteralAHX(buf,str,AH) \
--- 321,327 ----
extern void ReadToc(ArchiveHandle *AH);
extern void WriteDataChunks(ArchiveHandle *AH);

! extern int TocIDRequired(ArchiveHandle *AH, DumpId id, RestoreOptions *ropt);
extern bool checkSeek(FILE *fp);

#define appendStringLiteralAHX(buf,str,AH) \
Index: src/bin/pg_dump/pg_dump.c
===================================================================
RCS file: /home/sriggs/pg/REPOSITORY/pgsql/src/bin/pg_dump/pg_dump.c,v
retrieving revision 1.496
diff -c -r1.496 pg_dump.c
*** src/bin/pg_dump/pg_dump.c 18 Jul 2008 03:32:52 -0000 1.496
--- src/bin/pg_dump/pg_dump.c 20 Jul 2008 05:57:58 -0000
***************
*** 72,77 ****
--- 72,81 ----
bool dataOnly;
bool aclsSkip;

+ /* groups of objects: default is we dump all groups */
+
+ int dumpObjFlags;
+
/* subquery used to convert user ID (eg, datdba) to user name */
static const char *username_subquery;

***************
*** 224,231 ****
RestoreOptions *ropt;

static int disable_triggers = 0;
! static int outputNoTablespaces = 0;
static int use_setsessauth = 0;

static struct option long_options[] = {
{"data-only", no_argument, NULL, 'a'},
--- 228,237 ----
RestoreOptions *ropt;

static int disable_triggers = 0;
! static int outputNoTablespaces = 0;
static int use_setsessauth = 0;
+ static int use_schemaPreLoadOnly;
+ static int use_schemaPostLoadOnly;

static struct option long_options[] = {
{"data-only", no_argument, NULL, 'a'},
***************
*** 265,270 ****
--- 271,278 ----
{"disable-dollar-quoting", no_argument, &disable_dollar_quoting, 1},
{"disable-triggers", no_argument, &disable_triggers, 1},
{"no-tablespaces", no_argument, &outputNoTablespaces, 1},
+ {"schema-pre-load", no_argument, &use_schemaPreLoadOnly, 1},
+ {"schema-post-load", no_argument, &use_schemaPostLoadOnly, 1},
{"use-set-session-authorization", no_argument, &use_setsessauth, 1},

{NULL, 0, NULL, 0}
***************
*** 456,467 ****
if (optind < argc)
dbname = argv[optind];

! if (dataOnly && schemaOnly)
{
! write_msg(NULL, "options -s/--schema-only and -a/--data-only cannot be used together\n");
exit(1);
}

if (dataOnly && outputClean)
{
write_msg(NULL, "options -c/--clean and -a/--data-only cannot be used together\n");
--- 464,504 ----
if (optind < argc)
dbname = argv[optind];

! /*
! * Look for conflicting options relating to object groupings
! */
! if (schemaOnly && dataOnly)
! {
! write_msg(NULL, "options %s and %s cannot be used together\n",
! "-s/--schema-only", "-a/--data-only");
! exit(1);
! }
! else if ((schemaOnly || dataOnly) &&
! (use_schemaPreLoadOnly == 1 || use_schemaPostLoadOnly == 1))
{
! write_msg(NULL, "options %s and %s cannot be used together\n",
! schemaOnly ? "-s/--schema-only" : "-a/--data-only",
! use_schemaPostLoadOnly == 1 ? "--schema-post-load" : "--schema-pre-load ");
exit(1);
}

+ /*
+ * Decide which of the object groups we will dump
+ */
+ dumpObjFlags = REQ_ALL;
+
+ if (dataOnly)
+ dumpObjFlags = REQ_DATA;
+
+ if (use_schemaPreLoadOnly == 1)
+ dumpObjFlags = REQ_PRE_SCHEMA;
+
+ if (use_schemaPostLoadOnly == 1)
+ dumpObjFlags = REQ_POST_SCHEMA;
+
+ if (schemaOnly)
+ dumpObjFlags = (REQ_PRE_SCHEMA | REQ_POST_SCHEMA);
+
if (dataOnly && outputClean)
{
write_msg(NULL, "options -c/--clean and -a/--data-only cannot be used together\n");
***************
*** 638,644 ****
* Dumping blobs is now default unless we saw an inclusion switch or -s
* ... but even if we did see one of these, -b turns it back on.
*/
! if (include_everything && !schemaOnly)
outputBlobs = true;

/*
--- 675,681 ----
* Dumping blobs is now default unless we saw an inclusion switch or -s
* ... but even if we did see one of these, -b turns it back on.
*/
! if (include_everything && WANT_PRE_SCHEMA(dumpObjFlags))
outputBlobs = true;

/*
***************
*** 650,656 ****
if (g_fout->remoteVersion < 80400)
guessConstraintInheritance(tblinfo, numTables);

! if (!schemaOnly)
getTableData(tblinfo, numTables, oids);

if (outputBlobs && hasBlobs(g_fout))
--- 687,693 ----
if (g_fout->remoteVersion < 80400)
guessConstraintInheritance(tblinfo, numTables);

! if (WANT_DATA(dumpObjFlags))
getTableData(tblinfo, numTables, oids);

if (outputBlobs && hasBlobs(g_fout))
***************
*** 704,710 ****
dumpStdStrings(g_fout);

/* The database item is always next, unless we don't want it at all */
! if (include_everything && !dataOnly)
dumpDatabase(g_fout);

/* Now the rearrangeable objects. */
--- 741,747 ----
dumpStdStrings(g_fout);

/* The database item is always next, unless we don't want it at all */
! if (include_everything && WANT_DATA(dumpObjFlags))
dumpDatabase(g_fout);

/* Now the rearrangeable objects. */
***************
*** 726,732 ****
ropt->noTablespace = outputNoTablespaces;
ropt->disable_triggers = disable_triggers;
ropt->use_setsessauth = use_setsessauth;
! ropt->dataOnly = dataOnly;

if (compressLevel == -1)
ropt->compression = 0;
--- 763,769 ----
ropt->noTablespace = outputNoTablespaces;
ropt->disable_triggers = disable_triggers;
ropt->use_setsessauth = use_setsessauth;
! ropt->dumpObjFlags = dumpObjFlags;

if (compressLevel == -1)
ropt->compression = 0;
***************
*** 3389,3395 ****
continue;

/* Ignore indexes of tables not to be dumped */
! if (!tbinfo->dobj.dump)
continue;

if (g_verbose)
--- 3426,3432 ----
continue;

/* Ignore indexes of tables not to be dumped */
! if (!tbinfo->dobj.dump || !WANT_POST_SCHEMA(dumpObjFlags))
continue;

if (g_verbose)
***************
*** 5140,5146 ****
int ncomments;

/* Comments are SCHEMA not data */
! if (dataOnly)
return;

/* Search for comments associated with catalogId, using table */
--- 5177,5183 ----
int ncomments;

/* Comments are SCHEMA not data */
! if (!WANT_PRE_SCHEMA(dumpObjFlags))
return;

/* Search for comments associated with catalogId, using table */
***************
*** 5191,5197 ****
PQExpBuffer target;

/* Comments are SCHEMA not data */
! if (dataOnly)
return;

/* Search for comments associated with relation, using table */
--- 5228,5234 ----
PQExpBuffer target;

/* Comments are SCHEMA not data */
! if (!WANT_PRE_SCHEMA(dumpObjFlags))
return;

/* Search for comments associated with relation, using table */
***************
*** 5543,5549 ****
char *qnspname;

/* Skip if not to be dumped */
! if (!nspinfo->dobj.dump || dataOnly)
return;

/* don't dump dummy namespace from pre-7.3 source */
--- 5580,5586 ----
char *qnspname;

/* Skip if not to be dumped */
! if (!nspinfo->dobj.dump || !WANT_PRE_SCHEMA(dumpObjFlags))
return;

/* don't dump dummy namespace from pre-7.3 source */
***************
*** 5592,5598 ****
dumpType(Archive *fout, TypeInfo *tinfo)
{
/* Skip if not to be dumped */
! if (!tinfo->dobj.dump || dataOnly)
return;

/* Dump out in proper style */
--- 5629,5635 ----
dumpType(Archive *fout, TypeInfo *tinfo)
{
/* Skip if not to be dumped */
! if (!tinfo->dobj.dump || !WANT_PRE_SCHEMA(dumpObjFlags))
return;

/* Dump out in proper style */
***************
*** 6237,6243 ****
PQExpBuffer q;

/* Skip if not to be dumped */
! if (!stinfo->dobj.dump || dataOnly)
return;

q = createPQExpBuffer();
--- 6274,6280 ----
PQExpBuffer q;

/* Skip if not to be dumped */
! if (!stinfo->dobj.dump || !WANT_PRE_SCHEMA(dumpObjFlags))
return;

q = createPQExpBuffer();
***************
*** 6284,6290 ****
if (!include_everything)
return false;
/* And they're schema not data */
! if (dataOnly)
return false;
return true;
}
--- 6321,6327 ----
if (!include_everything)
return false;
/* And they're schema not data */
! if (!WANT_PRE_SCHEMA(dumpObjFlags))
return false;
return true;
}
***************
*** 6305,6311 ****
FuncInfo *funcInfo;
FuncInfo *validatorInfo = NULL;

! if (dataOnly)
return;

/*
--- 6342,6348 ----
FuncInfo *funcInfo;
FuncInfo *validatorInfo = NULL;

! if (!WANT_PRE_SCHEMA(dumpObjFlags))
return;

/*
***************
*** 6565,6571 ****
int i;

/* Skip if not to be dumped */
! if (!finfo->dobj.dump || dataOnly)
return;

query = createPQExpBuffer();
--- 6602,6608 ----
int i;

/* Skip if not to be dumped */
! if (!finfo->dobj.dump || !WANT_PRE_SCHEMA(dumpObjFlags))
return;

query = createPQExpBuffer();
***************
*** 6960,6966 ****
TypeInfo *sourceInfo;
TypeInfo *targetInfo;

! if (dataOnly)
return;

if (OidIsValid(cast->castfunc))
--- 6997,7003 ----
TypeInfo *sourceInfo;
TypeInfo *targetInfo;

! if (!WANT_PRE_SCHEMA(dumpObjFlags))
return;

if (OidIsValid(cast->castfunc))
***************
*** 7110,7116 ****
char *oprcanhash;

/* Skip if not to be dumped */
! if (!oprinfo->dobj.dump || dataOnly)
return;

/*
--- 7147,7153 ----
char *oprcanhash;

/* Skip if not to be dumped */
! if (!oprinfo->dobj.dump || !WANT_PRE_SCHEMA(dumpObjFlags))
return;

/*
***************
*** 7494,7500 ****
int i;

/* Skip if not to be dumped */
! if (!opcinfo->dobj.dump || dataOnly)
return;

/*
--- 7531,7537 ----
int i;

/* Skip if not to be dumped */
! if (!opcinfo->dobj.dump || !WANT_PRE_SCHEMA(dumpObjFlags))
return;

/*
***************
*** 7802,7808 ****
int i;

/* Skip if not to be dumped */
! if (!opfinfo->dobj.dump || dataOnly)
return;

/*
--- 7839,7845 ----
int i;

/* Skip if not to be dumped */
! if (!opfinfo->dobj.dump || !WANT_PRE_SCHEMA(dumpObjFlags))
return;

/*
***************
*** 8071,8077 ****
bool condefault;

/* Skip if not to be dumped */
! if (!convinfo->dobj.dump || dataOnly)
return;

query = createPQExpBuffer();
--- 8108,8114 ----
bool condefault;

/* Skip if not to be dumped */
! if (!convinfo->dobj.dump || !WANT_PRE_SCHEMA(dumpObjFlags))
return;

query = createPQExpBuffer();
***************
*** 8225,8231 ****
bool convertok;

/* Skip if not to be dumped */
! if (!agginfo->aggfn.dobj.dump || dataOnly)
return;

query = createPQExpBuffer();
--- 8262,8268 ----
bool convertok;

/* Skip if not to be dumped */
! if (!agginfo->aggfn.dobj.dump || !WANT_PRE_SCHEMA(dumpObjFlags))
return;

query = createPQExpBuffer();
***************
*** 8428,8434 ****
PQExpBuffer delq;

/* Skip if not to be dumped */
! if (!prsinfo->dobj.dump || dataOnly)
return;

q = createPQExpBuffer();
--- 8465,8471 ----
PQExpBuffer delq;

/* Skip if not to be dumped */
! if (!prsinfo->dobj.dump || !WANT_PRE_SCHEMA(dumpObjFlags))
return;

q = createPQExpBuffer();
***************
*** 8497,8503 ****
char *tmplname;

/* Skip if not to be dumped */
! if (!dictinfo->dobj.dump || dataOnly)
return;

q = createPQExpBuffer();
--- 8534,8540 ----
char *tmplname;

/* Skip if not to be dumped */
! if (!dictinfo->dobj.dump || !WANT_PRE_SCHEMA(dumpObjFlags))
return;

q = createPQExpBuffer();
***************
*** 8582,8588 ****
PQExpBuffer delq;

/* Skip if not to be dumped */
! if (!tmplinfo->dobj.dump || dataOnly)
return;

q = createPQExpBuffer();
--- 8619,8625 ----
PQExpBuffer delq;

/* Skip if not to be dumped */
! if (!tmplinfo->dobj.dump || !WANT_PRE_SCHEMA(dumpObjFlags))
return;

q = createPQExpBuffer();
***************
*** 8648,8654 ****
int i_dictname;

/* Skip if not to be dumped */
! if (!cfginfo->dobj.dump || dataOnly)
return;

q = createPQExpBuffer();
--- 8685,8691 ----
int i_dictname;

/* Skip if not to be dumped */
! if (!cfginfo->dobj.dump || !WANT_PRE_SCHEMA(dumpObjFlags))
return;

q = createPQExpBuffer();
***************
*** 8784,8790 ****
PQExpBuffer sql;

/* Do nothing if ACL dump is not enabled */
! if (dataOnly || aclsSkip)
return;

sql = createPQExpBuffer();
--- 8821,8827 ----
PQExpBuffer sql;

/* Do nothing if ACL dump is not enabled */
! if (!WANT_PRE_SCHEMA(dumpObjFlags) || aclsSkip)
return;

sql = createPQExpBuffer();
***************
*** 8821,8827 ****
{
if (tbinfo->relkind == RELKIND_SEQUENCE)
dumpSequence(fout, tbinfo);
! else if (!dataOnly)
dumpTableSchema(fout, tbinfo);

/* Handle the ACL here */
--- 8858,8864 ----
{
if (tbinfo->relkind == RELKIND_SEQUENCE)
dumpSequence(fout, tbinfo);
! else if (WANT_PRE_SCHEMA(dumpObjFlags))
dumpTableSchema(fout, tbinfo);

/* Handle the ACL here */
***************
*** 9128,9134 ****
PQExpBuffer delq;

/* Only print it if "separate" mode is selected */
! if (!tbinfo->dobj.dump || !adinfo->separate || dataOnly)
return;

/* Don't print inherited defaults, either */
--- 9165,9171 ----
PQExpBuffer delq;

/* Only print it if "separate" mode is selected */
! if (!tbinfo->dobj.dump || !adinfo->separate || !WANT_PRE_SCHEMA(dumpObjFlags))
return;

/* Don't print inherited defaults, either */
***************
*** 9213,9219 ****
PQExpBuffer q;
PQExpBuffer delq;

! if (dataOnly)
return;

q = createPQExpBuffer();
--- 9250,9256 ----
PQExpBuffer q;
PQExpBuffer delq;

! if (!WANT_POST_SCHEMA(dumpObjFlags))
return;

q = createPQExpBuffer();
***************
*** 9282,9288 ****
PQExpBuffer delq;

/* Skip if not to be dumped */
! if (!coninfo->dobj.dump || dataOnly)
return;

q = createPQExpBuffer();
--- 9319,9325 ----
PQExpBuffer delq;

/* Skip if not to be dumped */
! if (!coninfo->dobj.dump || !WANT_POST_SCHEMA(dumpObjFlags))
return;

q = createPQExpBuffer();
***************
*** 9675,9681 ****
*
* Add a 'SETVAL(seq, last_val, iscalled)' as part of a "data" dump.
*/
! if (!dataOnly)
{
resetPQExpBuffer(delqry);

--- 9712,9718 ----
*
* Add a 'SETVAL(seq, last_val, iscalled)' as part of a "data" dump.
*/
! if (WANT_PRE_SCHEMA(dumpObjFlags))
{
resetPQExpBuffer(delqry);

***************
*** 9778,9784 ****
tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId);
}

! if (!schemaOnly)
{
resetPQExpBuffer(query);
appendPQExpBuffer(query, "SELECT pg_catalog.setval(");
--- 9815,9821 ----
tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId);
}

! if (WANT_PRE_SCHEMA(dumpObjFlags))
{
resetPQExpBuffer(query);
appendPQExpBuffer(query, "SELECT pg_catalog.setval(");
***************
*** 9811,9817 ****
const char *p;
int findx;

! if (dataOnly)
return;

query = createPQExpBuffer();
--- 9848,9854 ----
const char *p;
int findx;

! if (!WANT_POST_SCHEMA(dumpObjFlags))
return;

query = createPQExpBuffer();
***************
*** 10019,10025 ****
PGresult *res;

/* Skip if not to be dumped */
! if (!rinfo->dobj.dump || dataOnly)
return;

/*
--- 10056,10062 ----
PGresult *res;

/* Skip if not to be dumped */
! if (!rinfo->dobj.dump || !WANT_POST_SCHEMA(dumpObjFlags))
return;

/*
Index: src/bin/pg_dump/pg_restore.c
===================================================================
RCS file: /home/sriggs/pg/REPOSITORY/pgsql/src/bin/pg_dump/pg_restore.c,v
retrieving revision 1.88
diff -c -r1.88 pg_restore.c
*** src/bin/pg_dump/pg_restore.c 13 Apr 2008 03:49:22 -0000 1.88
--- src/bin/pg_dump/pg_restore.c 20 Jul 2008 05:57:51 -0000
***************
*** 78,83 ****
--- 78,90 ----
static int no_data_for_failed_tables = 0;
static int outputNoTablespaces = 0;
static int use_setsessauth = 0;
+ bool dataOnly = false;
+ bool schemaOnly = false;
+
+ static int use_schemaPreLoadOnly;
+ static int use_schemaPostLoadOnly;
+
+ int dumpObjFlags;

struct option cmdopts[] = {
{"clean", 0, NULL, 'c'},
***************
*** 114,119 ****
--- 121,128 ----
{"disable-triggers", no_argument, &disable_triggers, 1},
{"no-data-for-failed-tables", no_argument, &no_data_for_failed_tables, 1},
{"no-tablespaces", no_argument, &outputNoTablespaces, 1},
+ {"schema-pre-load", no_argument, &use_schemaPreLoadOnly, 1},
+ {"schema-post-load", no_argument, &use_schemaPostLoadOnly, 1},
{"use-set-session-authorization", no_argument, &use_setsessauth, 1},

{NULL, 0, NULL, 0}
***************
*** 145,151 ****
switch (c)
{
case 'a': /* Dump data only */
! opts->dataOnly = 1;
break;
case 'c': /* clean (i.e., drop) schema prior to create */
opts->dropSchema = 1;
--- 154,160 ----
switch (c)
{
case 'a': /* Dump data only */
! dataOnly = true;
break;
case 'c': /* clean (i.e., drop) schema prior to create */
opts->dropSchema = 1;
***************
*** 213,219 ****
opts->triggerNames = strdup(optarg);
break;
case 's': /* dump schema only */
! opts->schemaOnly = 1;
break;
case 'S': /* Superuser username */
if (strlen(optarg) != 0)
--- 222,228 ----
opts->triggerNames = strdup(optarg);
break;
case 's': /* dump schema only */
! schemaOnly = true;
break;
case 'S': /* Superuser username */
if (strlen(optarg) != 0)
***************
*** 295,300 ****
--- 304,344 ----
opts->useDB = 1;
}

+ /*
+ * Look for conflicting options relating to object groupings
+ */
+ if (schemaOnly && dataOnly)
+ {
+ write_msg(NULL, "options %s and %s cannot be used together\n",
+ "-s/--schema-only", "-a/--data-only");
+ exit(1);
+ }
+ else if ((schemaOnly || dataOnly) &&
+ (use_schemaPreLoadOnly == 1 || use_schemaPostLoadOnly == 1))
+ {
+ write_msg(NULL, "options %s and %s cannot be used together\n",
+ schemaOnly ? "-s/--schema-only" : "-a/--data-only",
+ use_schemaPostLoadOnly == 1 ? "--schema-post-load" : "--schema-pre-load ");
+ exit(1);
+ }
+
+ /*
+ * Decide which of the object groups we will dump
+ */
+ dumpObjFlags = REQ_ALL;
+
+ if (dataOnly)
+ dumpObjFlags = REQ_DATA;
+
+ if (use_schemaPreLoadOnly == 1)
+ dumpObjFlags = REQ_PRE_SCHEMA;
+
+ if (use_schemaPostLoadOnly == 1)
+ dumpObjFlags = REQ_POST_SCHEMA;
+
+ if (schemaOnly)
+ dumpObjFlags = (REQ_PRE_SCHEMA | REQ_POST_SCHEMA);
+
opts->disable_triggers = disable_triggers;
opts->noDataForFailedTables = no_data_for_failed_tables;
opts->noTablespace = outputNoTablespaces;
On Sun, 2008-07-20 at 05:47 +0100, Simon Riggs wrote:
> On Sat, 2008-07-19 at 23:07 -0400, Stephen Frost wrote:
> > Simon,
> >
> > I agree with adding these options in general, since I find myself
> > frustrated by having to vi huge dumps to change simple schema things.
> > A couple of comments on the patch though:
> >
> > - Conflicting option handling
> > I think we are doing our users a disservice by putting it on them to
> > figure out exactly what:
> > multiple object groups cannot be used together
> > means to them. You and I may understand what an "object group" is,
> > and why there can be only one, but it's a great deal less clear than
> > the prior message of
> > options -s/--schema-only and -a/--data-only cannot be used together
> > My suggestion would be to either list out the specific options which
> > can't be used together, as was done previously, or add a bit of (I
> > realize, boring) code and actually tell the user which of the
> > conflicting options were used.
> >
> > - Documentation
> > When writing the documentation I would stress that "pre-schema" and
> > "post-schema" be defined in terms of PostgreSQL objects and why they
> > are pre vs. post.
> >
> > - Technically, the patch needs to be updated slightly since another
> > pg_dump-related patch was committed recently which also added
> > options and thus causes a conflict.
> >
> > Beyond those minor points, the patch looks good to me.
>
> Thanks for the review. I'll make the changes you suggest.

Patch updated to head, plus changes/docs requested.

--
Simon Riggs www.2ndQuadrant.com
PostgreSQL Training, Services and Support

Re: [HACKERS] .psqlrc output for \pset commands

Peter Eisentraut wrote:
> Am Thursday, 17. July 2008 schrieb Bruce Momjian:
>
> > > Anyways the thing that struck me as odd was the messages appearing
> > > *before* the header. It seems to me the header should print followed by
> > > .psqlrc output followed by normal output.
> >
> > Do you like this better?
> >
> > $ psql test
> > psql (8.4devel)
> > Type "help" for help.
> > Output format is wrapped.
> >
> > test=>
> >
> > The attached patch accomplishes this.
>
> The psqlrc file must be read before the welcome message is printed, so that
> you can disable the welcome message in the psqlrc file. Otherwise we are
> reopening the whole issue of when and whether to print a welcome message that
> we had just settled.

Oh, yea, sorry. Reverted.

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

[COMMITTERS] pgsql: Revert patch so .psqlrc can suppress startup banner: In psql,

Log Message:
-----------
Revert patch so .psqlrc can suppress startup banner:

In psql, run .psqlrc _after_ printing warnings and banner.

Modified Files:
--------------
pgsql/src/bin/psql:
startup.c (r1.150 -> r1.151)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/bin/psql/startup.c?r1=1.150&r2=1.151)

--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers

Re: [HACKERS] Getting to universal binaries for Darwin

Peter Eisentraut <peter_e@gmx.net> writes:
> I'd imagine a related problem are the run tests in configure. They will
> produce results for the platform that you run configure on. More properly,
> you should run configure in cross-compilation mode (twice, and then merge the
> output, as previously described), but I am not sure how that will turn out
> when configure attempts to determine alignment and endianness with
> compilation-only tests.

For the record, I got plausible-looking configure output from tests like

CFLAGS="-arch ppc64" ./configure --host=powerpc64-apple-darwin9.4.0

Whether it'd actually work I dunno, but it looked plausible. Two notes:

* You have to use both parts of the recipe: without --host, configure
doesn't think it's cross-compiling, and without CFLAGS, gcc doesn't ;-)

* This disables AC_TRY_RUN tests, of course. The only adverse
consequence I noticed was failure to recognize that
-Wl,-dead_strip_dylibs is applicable, which is marginally annoying but
hardly fatal.

On the whole I still wouldn't trust cross-compiled configure results.
Better to get your prototype pg_config.h from the real deal.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

[COMMITTERS] npgsql - Npgsql2: [#1010231] Reading result set with UUID is very slow

Log Message:
-----------

[#1010231] Reading result set with UUID is very slow
[#1010230] Reading result set with UUID is very slow

Applied patch to handle uuid types better. Now, instead of relying on ChangeType, it was added an explicit handler for uuid types.
Thanks Michael Parshin and Matthew Gabeler-Lee for patches.

Modified Files:
--------------
Npgsql2/src/NpgsqlTypes:
NpgsqlTypesHelper.cs (r1.16 -> r1.17)
(http://cvs.pgfoundry.org/cgi-bin/cvsweb.cgi/npgsql/Npgsql2/src/NpgsqlTypes/NpgsqlTypesHelper.cs.diff?r1=1.16&r2=1.17)
Npgsql2/src/Npgsql:
NpgsqlDataReader.cs (r1.14 -> r1.15)
(http://cvs.pgfoundry.org/cgi-bin/cvsweb.cgi/npgsql/Npgsql2/src/Npgsql/NpgsqlDataReader.cs.diff?r1=1.14&r2=1.15)

--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers

Re: [PATCHES] pg_dump additional options for performance

On Sat, 2008-07-19 at 23:07 -0400, Stephen Frost wrote:
> Simon,
>
> I agree with adding these options in general, since I find myself
> frustrated by having to vi huge dumps to change simple schema things.
> A couple of comments on the patch though:
>
> - Conflicting option handling
> I think we are doing our users a disservice by putting it on them to
> figure out exactly what:
> multiple object groups cannot be used together
> means to them. You and I may understand what an "object group" is,
> and why there can be only one, but it's a great deal less clear than
> the prior message of
> options -s/--schema-only and -a/--data-only cannot be used together
> My suggestion would be to either list out the specific options which
> can't be used together, as was done previously, or add a bit of (I
> realize, boring) code and actually tell the user which of the
> conflicting options were used.
>
> - Documentation
> When writing the documentation I would stress that "pre-schema" and
> "post-schema" be defined in terms of PostgreSQL objects and why they
> are pre vs. post.
>
> - Technically, the patch needs to be updated slightly since another
> pg_dump-related patch was committed recently which also added
> options and thus causes a conflict.
>
> Beyond those minor points, the patch looks good to me.

Thanks for the review. I'll make the changes you suggest.

--
Simon Riggs www.2ndQuadrant.com
PostgreSQL Training, Services and Support


--
Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-patches

Re: [PERFORM] An "obvious" index not being used

Daniele Varrazzo <piro@develer.com> writes:
> In my problem I had 2 tables: a small one (accounts), a large one (foo). The
> way the query is written doesn't allow the stats from the large table to be
> used at all, unless the records from the small table are fetched. This is
> independent from the stats accuracy.

> What the planner does is to assume an even distribution in the data in the
> joined fields.

Sir, you don't know what you're talking about.

regards, tom lane

--
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance

Re: [GENERAL] Initdb problem on debian mips cobalt: Bus error

Glyn Astill <glynastill@yahoo.co.uk> writes:
> A recompile with --enable-debug, then rerunning the make check gave me the same backtrace from gdb

Did you actually give a "bt" command, or was that just the initial
output from gdb?

Another thing to try is looking around the current instruction pointer:

x/i $pc
x/32i $pc-32

regards, tom lane

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Whassup with this? (Create table xxx like yyy fails)


Douglas McNaught wrote:
On Sat, Jul 19, 2008 at 9:02 PM, Karl Denninger <karl@denninger.net> wrote:   
childrensjustice=# create table petition_bail like petition_white; ERROR:  syntax error at or near "like" LINE 1: create table petition_bail like petition_white;     
 It's not super-easy to see from the docs, but I think you need parentheses:  CREATE TABLE petition_bail (LIKE petition_white);  -Doug    
Aha.

Thank you.

Karl Denninger (karl@denninger.net) http://www.denninger.net

Re: [GENERAL] Whassup with this? (Create table xxx like yyy fails)

On Sat, Jul 19, 2008 at 9:02 PM, Karl Denninger <karl@denninger.net> wrote:
> childrensjustice=# create table petition_bail like petition_white;
> ERROR: syntax error at or near "like"
> LINE 1: create table petition_bail like petition_white;

It's not super-easy to see from the docs, but I think you need parentheses:

CREATE TABLE petition_bail (LIKE petition_white);

-Doug

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Whassup with this? (Create table xxx like yyy fails)

>
> childrensjustice=# create table petition_bail like petition_white;
> ERROR: syntax error at or near "like"
> LINE 1: create table petition_bail like petition_white;
>
> Huh?
>
> Yes, the source table exists and obviously as postgres superuser
> ("pgsql") I have select permission on the parent.
>

What version of postgresql are you using?

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: [SQL] Whassup with this? (create table .... like ... fails)

On Sat, 19 Jul 2008, Karl Denninger wrote:

> childrensjustice=# create table petition_new like petition_bail;
> ERROR: syntax error at or near "like"
> LINE 1: create table petition_new like petition_bail;

As far as I can tell from the syntax description, the LIKE petition_bail
should be in the table definition parens, so probably
create table petition_new (like petition_bail);

--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

[SQL] Whassup with this? (create table .... like ... fails)

childrensjustice=# create table petition_new like petition_bail;
ERROR: syntax error at or near "like"
LINE 1: create table petition_new like petition_bail;

--
Karl Denninger (karl@denninger.net)
http://www.denninger.net

--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

[PATCHES] pg_dump additional options for performance

Simon,

I agree with adding these options in general, since I find myself
frustrated by having to vi huge dumps to change simple schema things.
A couple of comments on the patch though:

- Conflicting option handling
I think we are doing our users a disservice by putting it on them to
figure out exactly what:
multiple object groups cannot be used together
means to them. You and I may understand what an "object group" is,
and why there can be only one, but it's a great deal less clear than
the prior message of
options -s/--schema-only and -a/--data-only cannot be used together
My suggestion would be to either list out the specific options which
can't be used together, as was done previously, or add a bit of (I
realize, boring) code and actually tell the user which of the
conflicting options were used.

- Documentation
When writing the documentation I would stress that "pre-schema" and
"post-schema" be defined in terms of PostgreSQL objects and why they
are pre vs. post.

- Technically, the patch needs to be updated slightly since another
pg_dump-related patch was committed recently which also added
options and thus causes a conflict.

Beyond those minor points, the patch looks good to me.

Thanks,

Stephen

[GENERAL] Whassup with this? (Create table xxx like yyy fails)

childrensjustice=# create table petition_bail like petition_white;
ERROR: syntax error at or near "like"
LINE 1: create table petition_bail like petition_white;

Huh?

Yes, the source table exists and obviously as postgres superuser
("pgsql") I have select permission on the parent.

--
Karl Denninger (karl@denninger.net)
http://www.denninger.net

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[ADMIN] Created non-owner user cannot see database

I'm running PostgreSQL 8.3 on Kubuntu 8.04. My goal is to create a
database with one user as its owner, and another as a user with
non-administrative access to this database that I'll use as the runtime
user for a web application. As the user "postgres", I executed the
following commands in psql; (names changed to protect the innocent)

create database custom_database;
create user user_no_1 with password 'thisPassword';
alter database custom_database owner to user_no_1;
create user user_no_2 with password 'anotherPw';
grant usage on database custom_database to user_no_2;

Now, none of these commands failed - they all came back with "CREATE
ROLE" (or the appropriate response). Then, as the owner user, I was
able to run my create schema/table script. I grant "usage" on the
schema to this user, and within this script, each CREATE TABLE is
followed by a

grant select, insert, update, delete on table this_schema.this_table to
user_no_2;

However, when I log in with this user using phpPgAdmin, I cannot see any
databases, and when I try to execute a SQL statement through my web
application (using PHP's PDO), I'm told that the table I'm trying to hit
doesn't exist (specifically, SQL state 42P01, "Undefined table: 7 ERROR:
relation "this_table" does not exist"). I tried

grant all privileges on custom_database to user_no_2;

, but that still doesn't do anything for me. I also created this user
as a Linux user, with the same password as it has in the database, but
that didn't do anything either. I've been Googling this and banging my
head (figuratively, of course) over this for a few days, but I haven't
come to any good conclusion. I'd rather not run the web application as
the schema owner - I'm sure there's something I'm missing. I'd
appreciate any advice anyone may have - thanks!

--
Daniel J. Summers
Owner, DJS Consulting
E-mail - daniel@djs-consulting.com <mailto:daniel@djs-consulting.com>
Website - http://www.djs-consulting.com <http://www.djs-consulting.com/>
Technology Blog - http://www.djs-consulting.com/linux/blog

GEEKCODE 3.12 GCS/IT d s-:+ a C++ L++ E--- W++ N++ o? K- w !O M--
V PS+ PE++ Y? !PGP t+ 5? X+ R* tv b+ DI++ D+ G- e h---- r+++ y++++

--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin

Re: [pgsql-www] How to contribute to site?

Alvaro Herrera writes:

> Postgres source. You can probably check out git.postgresql.org to get
> this source, edit it (see the doc/src/sgml directory), and use GIT to
> build a patch and mail it to the pgsql-docs list.

Ok. Thanks.


Will subscribe to pg-docs then.

--
Sent via pgsql-www mailing list (pgsql-www@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-www

Re: [pgus-board] Flyer text, v.1

Tri fold! getting dinner in the oven, then i'll plug it in and send a PDF

-selena

On Sat, Jul 19, 2008 at 5:25 PM, Michael Alan Brewer <mbrewer@gmail.com> wrote:
> Hey, y'all; here's my first pass at putting together the PgUS flyer:
>
> [Is this a single sheet? Trifold?]
> ###############################
> The United States PostgreSQL Association welcomes you!
>
> ***GOALS***
> The US PostgreSQL Association (PgUS) is a non profit corporation with
> the following primary goals:
>
> (a) Educate, promote and support the creation, development and use of
> the PostgreSQL Open Source Database software, a software system which
> is available to the general public without charge;
>
> (b) Provide information and education regarding the use of PostgreSQL; and
>
> (c) Organize, hold and conduct meetings, discussion, and forums on the
> contemporary issues concerning the use of PostgreSQL.
>
> What do these mean for you?
>
>>>>.COM
> * Create sponsorship programs that utilize the power and influence of
> the for-profit market to continue the promotion of PostgreSQL by
> educating professional users and corporations on the benefits of using
> the database. Further the education of PostgreSQL through the use of development
> grants.
>
>>>>.EDU
> * Promote the use of PostgreSQL in academic curriculum, educational
> support applications, and in papers and presentations. From the server
> to the classroom, expand the presence of PostgreSQL.
>
>>>>.YOU
> * Support and offer PostgreSQL Conferences, Workshops and other
> educational events centered around PostgreSQL, such as the PostgreSQL Community
> conferences (EAST and WEST). Support User Groups in their quest to
> bring community together as a
> way to advance their own knowledge of PostgreSQL.
>
> ***MEMBERSHIP***
> There are many benefits to PgUS membership:
>
> 1. A postgresql.us email forward (username@postgresql.us)
> 2. Aggregation of member blog
> 3. Eligibility for grants
> 4. Eligibility to serve or lead committee
> 5. Ability to vote in elections
> 6. Ability to bring motions
> 7. Professional listing in member directory
> 8. A postgresql.us Jabber(R) account
>
> Membership dues shall be the following:
>
> $75 -- Professional
> $20 -- Student
>
> **********************
>
> To learn more about us and our mission, please visit us on the web at:
>
> postgresql.us
>
> #####################################################
> #####################################################
> This is 286 words (according to, umm, Word). The parts in ****CAPS
> **** and/or in >>>CAPS would require special formatting (larger font,
> drop letter, etc.); Selena, would this fit in your template?
>
> Please send suggestions/corrections/updates ASAP; I'd like to get
> this to the printer. ;)
>
> ---Michael Brewer
> mbrewer@gmail.com
>
> --
> Sent via pgus-board mailing list (pgus-board@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgus-board
>

--
Selena Deckelmann
United States PostgreSQL Association - http://www.postgresql.us
PDXPUG - http://pugs.postgresql.org/pdx
Me - http://www.chesnok.com/daily

--
Sent via pgus-board mailing list (pgus-board@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgus-board

Re: [pgsql-www] How to contribute to site?

Francisco Reyes wrote:
> I am looking at https://pgweb.postgresql.org and don't see any pointers
> on how one contributes to the pg doc project.
>
> Also checked http://wiki.postgresql.org/wiki/Developer_FAQ and the wiki
> in general.
>
> Any URLs or any pointers on how to contribute?
> I particular I want to provide examples for this page:
> http://www.postgresql.org/docs/8.3/interactive/ddl-partitioning.html

Well, that's a different codebase from pgweb. pgweb deals with the
website itself; the docs are produced from SGML source found in the core
Postgres source. You can probably check out git.postgresql.org to get
this source, edit it (see the doc/src/sgml directory), and use GIT to
build a patch and mail it to the pgsql-docs list.

(You could also use CVS if you feel so inclined, but it probably does
not have any benefit over GIT).

Note that pgsql-www is not involved anywhere in this task :-)

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

--
Sent via pgsql-www mailing list (pgsql-www@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-www

[pgus-board] Flyer text, v.1

Hey, y'all; here's my first pass at putting together the PgUS flyer:

[Is this a single sheet? Trifold?]
###############################
The United States PostgreSQL Association welcomes you!

***GOALS***
The US PostgreSQL Association (PgUS) is a non profit corporation with
the following primary goals:

(a) Educate, promote and support the creation, development and use of
the PostgreSQL Open Source Database software, a software system which
is available to the general public without charge;

(b) Provide information and education regarding the use of PostgreSQL; and

(c) Organize, hold and conduct meetings, discussion, and forums on the
contemporary issues concerning the use of PostgreSQL.

What do these mean for you?

>>>.COM
* Create sponsorship programs that utilize the power and influence of
the for-profit market to continue the promotion of PostgreSQL by
educating professional users and corporations on the benefits of using
the database. Further the education of PostgreSQL through the use of development
grants.

>>>.EDU
* Promote the use of PostgreSQL in academic curriculum, educational
support applications, and in papers and presentations. From the server
to the classroom, expand the presence of PostgreSQL.

>>>.YOU
* Support and offer PostgreSQL Conferences, Workshops and other
educational events centered around PostgreSQL, such as the PostgreSQL Community
conferences (EAST and WEST). Support User Groups in their quest to
bring community together as a
way to advance their own knowledge of PostgreSQL.

***MEMBERSHIP***
There are many benefits to PgUS membership:

1. A postgresql.us email forward (username@postgresql.us)
2. Aggregation of member blog
3. Eligibility for grants
4. Eligibility to serve or lead committee
5. Ability to vote in elections
6. Ability to bring motions
7. Professional listing in member directory
8. A postgresql.us Jabber(R) account

Membership dues shall be the following:

$75 -- Professional
$20 -- Student

**********************

To learn more about us and our mission, please visit us on the web at:

postgresql.us

#####################################################
#####################################################
This is 286 words (according to, umm, Word). The parts in ****CAPS
**** and/or in >>>CAPS would require special formatting (larger font,
drop letter, etc.); Selena, would this fit in your template?

Please send suggestions/corrections/updates ASAP; I'd like to get
this to the printer. ;)

---Michael Brewer
mbrewer@gmail.com

--
Sent via pgus-board mailing list (pgus-board@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgus-board

Re: [HACKERS] Postgres-R: primary key patches

Markus Wanner wrote:

> (Although, I'm still less than thrilled about the internal storage
> format of these tuple collections. That can certainly be improved and
> simplified.)

Care to expand more on what it is? On Replicator we're using the binary
send/recv routines to transmit tuples. (Obviously this fails when the
master and slave have differing binary output, but currently we just
punt on this point).

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Re: [GENERAL] Reducing memory usage of insert into select operations? [Solved]

Francisco Reyes wrote:

> I knew it sounded too good to be true.
> 1- The trigger was not set in the master (ie nothing went to the children).
> 2- The master had no index and no RI.. so it was a straight insert.
>
> I corrected (ie set the trigger in the master and RI in the children).
> Has been running for 10 hours and has not finished.

FWIW it tends to be faster to do the bulk load first and add the
indexes and constraints later. (Though obviously you must be prepared
to cope with the failing rows, if any). However, if you do this
INSERT/SELECT thing frequently, this is probably not very workable.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: [HACKERS] Getting to universal binaries for Darwin

Am Saturday, 19. July 2008 schrieb Tom Lane:
> The bad news is that if you only do that, only the arch that you
> actually build on will work.  We have configure set up to insert
> various hardware-dependent definitions into pg_config.h and
> ecpg_config.h, and if you don't have the right values visible for
> each compilation, the resulting executables will fail.

I'd imagine a related problem are the run tests in configure. They will
produce results for the platform that you run configure on. More properly,
you should run configure in cross-compilation mode (twice, and then merge the
output, as previously described), but I am not sure how that will turn out
when configure attempts to determine alignment and endianness with
compilation-only tests. You should probably check some of those results very
carefully and help it out with some cache variables.

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Re: [GENERAL] Reducing memory usage of insert into select operations? [Solved]

Alvaro Herrera writes:

> Heh -- but are the FKs now checked? Try inserting something that
> violates the constraints and see if they are rejected.

I knew it sounded too good to be true.
1- The trigger was not set in the master (ie nothing went to the children).
2- The master had no index and no RI.. so it was a straight insert.

I corrected (ie set the trigger in the master and RI in the children). Has
been running for 10 hours and has not finished.

The good news is that memory doesn't seem to be going up.
I will give it till tomorrow AM.. and if hasn't finished will turn off the
foreign keys in the children. Already modified the scripts so I can easily
build/drop the foreign keys as needed.

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: [HACKERS] .psqlrc output for \pset commands

Am Thursday, 17. July 2008 schrieb Bruce Momjian:

> > Anyways the thing that struck me as odd was the messages appearing
> > *before* the header. It seems to me the header should print followed by
> > .psqlrc output followed by normal output.
>
> Do you like this better?
>
> $ psql test
> psql (8.4devel)
> Type "help" for help.
> Output format is wrapped.
>
> test=>
>
> The attached patch accomplishes this.

The psqlrc file must be read before the welcome message is printed, so that
you can disable the welcome message in the psqlrc file. Otherwise we are
reopening the whole issue of when and whether to print a welcome message that
we had just settled.

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Re: [HACKERS] Getting to universal binaries for Darwin

Tom Lane wrote:
> You can get around that by hacking up the generated config files
> with #ifdef __i386__ and so on to expose the correct values of
> the hardware-dependent symbols to each build. Of course you have
> to know what the correct values are --- if you don't have a sample
> of each architecture handy to run configure against, it'd be easy
> to miss some things. And even then it's pretty tedious. I am
> not sure if it is possible or worth the trouble to try to automate
> this part better.

Hm - configure *does* the right thing if CFLAGS is set to *just* "-arch
i386" or "-arch ppc" (at least on intel hardware, because OSX can run
ppc binaries there, but not vice versa), right? If this is true, we need
some way to run configure multiple times, once for each arch, but then
still get *one* set of Makefiles that have all the archs in their CFLAGS..

> Modulo the above problems, I was able to build i386+ppc binaries that
> do in fact work on both architectures. I haven't got any 64-bit Apple
> machines to play with, so there might be 64-bit issues I missed.
> Still, this is a huge step forward compared to what was discussed here:
> http://archives.postgresql.org/pgsql-general/2008-02/msg00200.php
I think that my MacBook should be able to build and run 64-bit binaries,
so I can test that if you want. Do you have a script that does the
necessary config file magic, or did you do that by hand?

regards, Florian Pflug

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Re: [pgsql-www] pugs.postgresql.org error in pg_query()

On Fri, Jul 18, 2008 at 4:44 AM, Alexey Klyukin <alexk@commandprompt.com> wrote:

> I've noticed that pugs.postgresql.org shows this error on some pages:

Thank you. I had applied that patch a while back, but Marc tried to
upgrade using ports, and it failed. Must have eaten the patch
somewhere along the line.

I've re-applied the patch!

-selena

--
Selena Deckelmann
United States PostgreSQL Association - http://www.postgresql.us
PDXPUG - http://pugs.postgresql.org/pdx
Me - http://www.chesnok.com/daily

--
Sent via pgsql-www mailing list (pgsql-www@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-www

Re: [GENERAL] Initdb problem on debian mips cobalt: Bus error

Glyn Astill <glynastill@yahoo.co.uk> writes:
> Would the mips specific code behave differently on different oses?

I'm more worried about there being more than one type of MIPS CPU out
there. Do all qubes contain exactly the same sub-architecture?
The references to "mips2" in s_lock.h are attention-getting ...

regards, tom lane

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: [HACKERS] Getting to universal binaries for Darwin

Adriaan van Os <postgres@microbizz.nl> writes:
> Tom Lane wrote:
>> You can get around that by hacking up the generated config files
>> with #ifdef __i386__ and so on to expose the correct values of
>> the hardware-dependent symbols to each build. Of course you have
>> to know what the correct values are --- if you don't have a sample
>> of each architecture handy to run configure against, it'd be easy
>> to miss some things. And even then it's pretty tedious. I am
>> not sure if it is possible or worth the trouble to try to automate
>> this part better.

> It may be less pain to simply config and build for ppc and i386 in separate build directories and
> then glue the resulting binaries together with lipo

That might give you working executables, but you still need a
glued-together pg_config.h for installation purposes, if you'd
like people to be able to build extensions against the installation.

In any case, the preceding thread showed exactly how to do it that
way, and it didn't look like "less pain" to me ...

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Re: [HACKERS] Postgres-R: primary key patches

Hi,

chris wrote:
> You may want to have a chat with Jan; he's got some thoughts on a more
> general purpose mechanism that would be good for this as well as for
> (we think) extremely efficient bulk data loading.

Jan, mind to share your thoughts? What use cases for such a general
purpose mechanism do you see?

What I can imagine doing on top of Postgres-R is: splitting up the data
and feeding multiple backends with it. Unlike Postgres-R's internal use,
you'd still have to check the data against constraints, I think.

It would involve the origin backend asking for help from the manager.
That one checks for available helper backends and then serves as a
message dispatcher between the origin and helper backends (as it does
for replication purposes). Please note that it already uses shared
memory extensively, so the manager doesn't need to copy around the data
itself.

Regards

Markus

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Re: [HACKERS] Postgres-R: primary key patches

Hi,

chris wrote:
> I agree with you that tables are *supposed* to have primary keys;
> that's proper design, and if tables are missing them, then something
> is definitely broken.

Ah, I see, so you are not concerned about tables with a PRIMARY KEY for
which one wants another REPLICATION KEY, but only about tables without a
PRIMARY KEY, for which one doesn't want a PRIMARY KEY in the first place.

However, that's a general limitation of replication at tuple level: you
need to be able to uniquely identify tuples. (Unlike replication on
storage level, which can use the storage location for that).

> Sometimes, unfortunately, people make errors in design, and we wind up
> needing to accomodate situations that are "less than perfect."
>
> The "happy happenstance" is that, in modern versions of PostgreSQL, a
> unique index may be added in the background so that this may be
> rectified without outage if you can live with a "candidate primary
> key" rather than a true PRIMARY KEY.

I cannot see any reason for not wanting a PRIMARY KEY, but wanting
replication, and therefore a REPLICATION KEY.

Or are you saying we should add a hidden REPLICATION KEY for people who
are afraid of schema changes and dislike a visible primary key? Would
you want to hide the underlying index as well?

> It seems to me that this extension can cover over a number of "design
> sins," which looks like a very kind accomodation where it is surely
> preferable to design it in earlier rather than later.

Sorry, but I fail to see any real advantage of that covering of "sins".
I would find it rather confusing to have keys and indices hidden from
the admin. It's not like an additional index or a primary key would lead
to functional changes.

That's certainly different for additional columns, where a SELECT *
could all of a sudden return more columns than before. So that's the
exception where I agree that hiding such an additional column like we
already do for system columns would make sense. That's for example the
situation where you add an 'id' column later on and make that the new
primary (and thus replication) key. Maybe that's what you meant?
However, even in that case, I wouldn't hide the index nor the primary
key, but only the column.

Regards

Markus


--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Re: [ADMIN] Database Link

On 2008-07-19, at 10:00, Govind wrote:

> Hi all,
>
> Like oracle dblink, is it possible to connect two database's in
> greenplum??? If yes please pass the command how to create the dblink
> to connect two databases.
>
> Regards
>
> Govindarajan
>
> --
> Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-admin

http://www.postgresql.org/docs/8.3/static/contrib.html

and

http://www.postgresql.org/docs/8.3/static/contrib-dblink.html

all dblink functions
http://www.postgresql.org/docs/8.3/static/dblink.html

-
Pawel Socha
pawel.socha@gmail.com

perl -le 's**02).4^&-%2,).^9%4^!./4(%2^3,!#+7!2%^53%2&**y%& -;^[%"`-
{ a%%s%%$_%ee'


--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin

Re: [pgadmin-hackers] Dialogs review

Index: pgadmin/ui/dlgCast.xrc
===================================================================
--- pgadmin/ui/dlgCast.xrc (revision 7393)
+++ pgadmin/ui/dlgCast.xrc (working copy)
@@ -2,147 +2,221 @@
<resource>
<object class="wxDialog" name="dlgCast">
<title></title>
- <object class="wxNotebook" name="nbNotebook">
- <object class="notebookpage">
- <label>Properties</label>
- <object class="wxPanel" name="pnlProperties">
- <object class="wxStaticText" name="stName">
-
- <label>Name</label>
-
- <pos>5,7d</pos>
+ <style>wxDEFAULT_DIALOG_STYLE|wxCAPTION|wxSYSTEM_MENU|wxRESIZE_BORDER|wxRESIZE_BOX|wxTHICK_FRAME</style>
+ <object class="wxFlexGridSizer">
+ <cols>1</cols>
+ <object class="sizeritem">
+ <object class="wxNotebook" name="nbNotebook">
+ <object class="notebookpage">
+ <label>Properties</label>
+ <object class="wxPanel" name="pnlProperties">
+ <object class="wxFlexGridSizer">
+ <cols>2</cols>
+ <rows>8</rows>
+ <vgap>5</vgap>
+ <hgap>5</hgap>
+ <growablerows>6</growablerows>
+ <growablecols>1</growablecols>
+ <object class="sizeritem">
+ <object class="wxStaticText" name="stName">
+ <label>Name</label>
+ <pos>5,7d</pos>
+ </object>
+ <flag>wxALIGN_CENTRE_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+ <border>8</border>
+ </object>
+ <object class="sizeritem">
+ <object class="wxTextCtrl" name="txtCastname">
+ <pos>70,5d</pos>
+ <size>135,-1d</size>
+ </object>
+ <flag>wxEXPAND|wxALIGN_TOP|wxTOP|wxLEFT|wxRIGHT</flag>
+ <border>8</border>
+ </object>
+ <object class="sizeritem">
+ <object class="wxStaticText" name="stOID">
+ <label>OID</label>
+ <pos>5,22d</pos>
+ </object>
+ <flag>wxALIGN_CENTRE_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+ <border>8</border>
+ </object>
+ <object class="sizeritem">
+ <object class="wxTextCtrl" name="txtOID">
+ <pos>70,20d</pos>
+ <size>135,-1d</size>
+ </object>
+ <flag>wxEXPAND|wxALIGN_TOP|wxTOP|wxLEFT|wxRIGHT</flag>
+ <border>8</border>
+ </object>
+ <object class="sizeritem">
+ <object class="wxStaticText" name="stSourceType">
+ <label>Source type</label>
+ <pos>5,37d</pos>
+ </object>
+ <flag>wxALIGN_CENTRE_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+ <border>8</border>
+ </object>
+ <object class="sizeritem">
+ <object class="ctlComboBox" name="cbSourceType">
+ <content/>
+ <pos>70,35d</pos>
+ <size>130,12d</size>
+ <style>wxCB_DROPDOWN</style>
+ </object>
+ <flag>wxEXPAND|wxALIGN_TOP|wxTOP|wxLEFT|wxRIGHT</flag>
+ <border>8</border>
+ </object>
+ <object class="sizeritem">
+ <object class="wxStaticText" name="stTargetType">
+ <label>Target type</label>
+ <pos>5,52d</pos>
+ </object>
+ <flag>wxALIGN_CENTRE_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+ <border>8</border>
+ </object>
+ <object class="sizeritem">
+ <object class="ctlComboBox" name="cbTargetType">
+ <content/>
+ <pos>70,50d</pos>
+ <size>130,12d</size>
+ <style>wxCB_DROPDOWN</style>
+ </object>
+ <flag>wxEXPAND|wxALIGN_TOP|wxTOP|wxLEFT|wxRIGHT</flag>
+ <border>8</border>
+ </object>
+ <object class="sizeritem">
+ <object class="wxStaticText" name="stFunction">
+ <label>Function</label>
+ <pos>5,67d</pos>
+ </object>
+ <flag>wxALIGN_CENTRE_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+ <border>8</border>
+ </object>
+ <object class="sizeritem">
+ <object class="wxComboBox" name="cbFunction">
+ <content/>
+ <pos>70,65d</pos>
+ <size>135,12d</size>
+ <style>wxCB_READONLY|wxCB_DROPDOWN</style>
+ </object>
+ <flag>wxEXPAND|wxALIGN_TOP|wxTOP|wxLEFT|wxRIGHT</flag>
+ <border>8</border>
+ </object>
+ <object class="sizeritem">
+ <object class="wxStaticText" name="stImplicit">
+ <label>Implicit</label>
+ <pos>5,82d</pos>
+ </object>
+ <flag>wxALIGN_CENTRE_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+ <border>8</border>
+ </object>
+ <object class="sizeritem">
+ <object class="wxCheckBox" name="chkImplicit">
+ <label></label>
+ <pos>70,80d</pos>
+ <size>13,12d</size>
+ </object>
+ <flag>wxEXPAND|wxALIGN_TOP|wxTOP|wxLEFT|wxRIGHT</flag>
+ <border>8</border>
+ </object>
+ <object class="sizeritem">
+ <object class="wxStaticText" name="stComment">
+ <label>Comment</label>
+ <pos>5,97d</pos>
+ </object>
+ <flag>wxALIGN_TOP|wxTOP|wxLEFT|wxRIGHT</flag>
+ <border>8</border>
+ </object>
+ <object class="sizeritem">
+ <object class="wxTextCtrl" name="txtComment">
+ <pos>70,95d</pos>
+ <size>135,83d</size>
+ <style>wxTE_MULTILINE</style>
+ </object>
+ <flag>wxEXPAND|wxALL</flag>
+ <border>8</border>
+ </object>
+ <object class="sizeritem">
+ <object class="wxStaticText" name="stClusterSet">
+ <label>Use replication</label>
+ <pos>5,183d</pos>
+ </object>
+ <flag>wxALIGN_CENTRE_VERTICAL</flag>
+ </object>
+ <object class="sizeritem">
+ <object class="wxComboBox" name="cbClusterSet">
+ <content/>
+ <pos>70,181d</pos>
+ <size>135,12d</size>
+ <style>wxCB_READONLY|wxCB_DROPDOWN</style>
+ </object>
+ <flag>wxEXPAND|wxALIGN_TOP|wxALL</flag>
+ <border>8</border>
+ </object>
+ </object>
+ <selected>1</selected>
</object>
- <object class="wxTextCtrl" name="txtCastname">
-
- <pos>70,5d</pos>
-
- <size>135,-1d</size>
+ <pos>2,2d</pos>
+ <size>214,415d</size>
+ </object>
+ </object>
+ <flag>wxALL|wxGROW|wxALIGN_CENTRE</flag>
+ <border>3</border>
+ </object>
+ <growablecols>0</growablecols>
+ <growablerows>0</growablerows>
+ <object class="spacer">
+ <size>2,2d</size>
+ </object>
+ <object class="sizeritem">
+ <object class="wxFlexGridSizer">
+ <cols>7</cols>
+ <object class="spacer">
+ <size>3,3d</size>
</object>
- <object class="wxStaticText" name="stOID">
-
- <label>OID</label>
-
- <pos>5,22d</pos>
+ <object class="sizeritem">
+ <object class="wxButton" name="wxID_HELP">
+ <label>Help</label>
+ <pos>135,220d</pos>
+ </object>
</object>
- <object class="wxTextCtrl" name="txtOID">
-
- <pos>70,20d</pos>
-
- <size>135,-1d</size>
+ <object class="spacer">
+ <size>3,3d</size>
</object>
- <object class="wxStaticText" name="stSourceType">
-
- <label>Source type</label>
-
- <pos>5,37d</pos>
+ <object class="sizeritem">
+ <object class="wxButton" name="wxID_OK">
+ <label>&amp;OK</label>
+ <default>1</default>
+ <pos>135,220d</pos>
+ </object>
</object>
- <object class="ctlComboBox" name="cbSourceType">
-
- <content/>
-
- <pos>70,35d</pos>
-
- <size>135,12d</size>
-
- <style>wxCB_DROPDOWN</style>
+ <object class="spacer">
+ <size>3,3d</size>
</object>
- <object class="wxStaticText" name="stTargetType">
-
- <label>Target type</label>
-
- <pos>5,52d</pos>
+ <object class="sizeritem">
+ <object class="wxButton" name="wxID_CANCEL">
+ <label>&amp;Cancel</label>
+ <pos>176,220d</pos>
+ </object>
</object>
- <object class="ctlComboBox" name="cbTargetType">
-
- <content/>
-
- <pos>70,50d</pos>
-
- <size>135,12d</size>
-
- <style>wxCB_DROPDOWN</style>
+ <object class="spacer">
+ <size>3,3d</size>
</object>
- <object class="wxStaticText" name="stFunction">
-
- <label>Function</label>
-
- <pos>5,67d</pos>
- </object>
- <object class="wxComboBox" name="cbFunction">
-
- <content/>
-
- <pos>70,65d</pos>
-
- <size>135,12d</size>
-
- <style>wxCB_READONLY|wxCB_DROPDOWN</style>
- </object>
- <object class="wxStaticText" name="stImplicit">
-
- <label>Implicit</label>
-
- <pos>5,82d</pos>
- </object>
- <object class="wxCheckBox" name="chkImplicit">
-
- <label></label>
-
- <pos>70,80d</pos>
-
- <size>13,12d</size>
- </object>
- <object class="wxStaticText" name="stComment">
-
- <label>Comment</label>
-
- <pos>5,97d</pos>
- </object>
- <object class="wxTextCtrl" name="txtComment">
-
- <pos>70,95d</pos>
-
- <size>135,83d</size>
-
- <style>wxTE_MULTILINE</style>
- </object>
- <object class="wxStaticText" name="stClusterSet">
- <label>Use replication</label>
- <pos>5,183d</pos>
- </object>
- <object class="wxComboBox" name="cbClusterSet">
- <content/>
- <pos>70,181d</pos>
- <size>135,12d</size>
- <style>wxCB_READONLY|wxCB_DROPDOWN</style>
- </object>
+ <growablecols>2</growablecols>
</object>
-
- <selected>1</selected>
+ <flag>wxTOP|wxLEFT|wxRIGHT|wxGROW</flag>
</object>
- <pos>2,2d</pos>
- <size>214,215d</size>
+ <object class="spacer">
+ <size>3,3d</size>
+ </object>
+ <object class="sizeritem">
+ <object class="unknown" name="unkStatusBar">
+ <size>-1,15d</size>
+ </object>
+ <flag>wxGROW|wxALIGN_CENTRE</flag>
+ <border>3</border>
+ </object>
</object>
- <object class="wxButton" name="wxID_HELP">
-
- <label>Help</label>
-
- <pos>2,220d</pos>
- </object>
- <object class="wxButton" name="wxID_OK">
-
- <label>&amp;OK</label>
-
- <default>1</default>
-
- <pos>113,220d</pos>
- </object>
- <object class="wxButton" name="wxID_CANCEL">
-
- <label>&amp;Cancel</label>
-
- <pos>166,220d</pos>
- </object>
- <size>218,238d</size>
</object>
</resource>
Guillaume Lelarge a écrit :
> Dave Page a écrit :
>> On Mon, Jul 14, 2008 at 8:17 PM, Guillaume Lelarge
>> <guillaume@lelarge.info> wrote:
>>
>>> Hmmmm, I see... that I can't do anything till I get my Mac. I will
>>> work on
>>> it but I don't know now how to fix it.
>>
>> Understood. I'm really busy right now (yeah, I know I'm starting to
>> sound like a broken record with that one!) but if you send over the
>> latest version of the patch sometime I'll try out a couple of ideas
>> for this and the combo box thing when I can get five minutes..
>>
>
> :)
>
> Now that I have a MacMini, that I'm able to build a pgAdmin3.app file,
> things should go faster and with less burden. Or so I hope.
>
> BTW, I have the same issue with the two dialogs. I'm statring to work on
> this.
>

Okay... the wxListCtrl resize problem seems to be a wxMac confirmed bug.
See http://trac.wxwidgets.org/ticket/4814 bug report for more details.
Not sure about what we should do with this... debug the stuff on wxMac
source files? or simply put it in the BUGS file and continue the work ?

... hmmm ... (a few moments later) ... I can try to see what's going on
between 2.8.6 and 2.8.7 and if 2.8.6 works for us. (again a few moments
later) Nope, doesn't work on 2.8.6 and 2.8.0. I added a comment on the
trac tricket.

Anyways, I attach the new dlgCast.xrc patch file.


--
Guillaume.
http://www.postgresqlfr.org
http://dalibo.com